[
  {
    "path": ".gitignore",
    "content": "# Prerequisites\n*.d\n\n# Compiled Object files\n*.lo\n*.o\n\n# Compiled Dynamic libraries\n*.so\n\n# Compiled Static libraries\n*.a\n*.la\n\n# Generated Makefiles\n/Makefile\n/Makefile.in\n/configure\n\n# opensmile executable\nSMILExtract\n\n# generated .m4 macro files\n/aclocal.m4\n/m4/libtool.m4\n/m4/ltoptions.m4\n/m4/ltsugar.m4\n/m4/ltversion.m4\n/m4/lt~obsolete.m4\n\n\n# generated config files\n/config.guess\n/config.h\n/config.h.in\n/config.log\n/config.status\n/config.sub\n\n# other generated files\n*.cache\n.deps\n.dirstamp\n/.libs\n/inst\n/install-sh\n/ltmain.sh\n/missing\n/stamp-h1\n/compile\n/depcomp\n/libtool\n\n# android debug\ngdb.setup\ngdbserver\nerr_outp_n\n\n# IMPORTANT: keep all compiled filed in /bin\n!/bin/**/*"
  },
  {
    "path": "AUTHORS",
    "content": "\nopenSMILE is maintained by the following people:\n=============================================================\n\nDipl.-Ing. Florian Eyben (main code, architecture, most core components, debugging, testing, releases)\nDipl.-Ing. Felix Weninger (debugging, IS challenge sets, various components)\nDipl.-Ing. Martin Woellmer (testing, and various components as Julius LVCSR interface)\nProf. Bjoern Schuller (testing, coordination, and theory)\n\nContact e-mail: info@audeering.com\n\naudEERING GmbH\nFriedrichshafener Str. 3\n82205 Gilching\nGERMANY\n\nPlease see the file CREDITS for additional contributors!\n\n"
  },
  {
    "path": "COPYING",
    "content": "\n  openSMILE \n   - open-source\n     Speech and Music Interpretation by Large-space Extraction -\n\n  Main authors: Florian Eyben, Felix Weninger, Martin Woellmer, Bjoern Schuller\n\n  Copyright (c) audEERING GmbH, Gilching, Germany. All rights reserved. \n  http://www.audeeering.com/\n\n  Copyright (c) 2016,      audEERING GmbH\n  Copyright (c) 2013-2015, audEERING UG (haftungsbeschraenkt)\n  Copyright (c) 2008-2013, Institute for Human-Machine Communication, \n                           Technische Universitaet Muenchen, Germany\n \nLicensing terms & your rights\n=============================\n  \n********************************************************************** \n If you use openSMILE or any code from openSMILE in your research work,\n you are kindly asked to acknowledge the use of openSMILE in your \n publications. See the file CITING.txt for details.\n**********************************************************************\n\nThis audEERING Research License Agreement (license, license agreement, \nor agreement in the ongoing), is a legal agreement between you \nand audEERING GmbH, Gilching, Germany (audEERING or we in the following) \nfor the software or data identified above, which may include source code, \nand any associated materials, text or speech files, \nassociated media and \"online\" or electronic documentation \n(together, the \"Software\").  \n\nBy installing, copying, or otherwise using this Software, \nyou agree to be bound by the terms in this license. \nIf you do not agree, you may not install copy or use the Software. \nThe Software is protected by copyright and other intellectual \nproperty laws and is licensed, not sold.\n\nThis license grants you the following rights:\nA. You may use, copy, reproduce, and distribute this Software \n   for any non-commercial purpose, subject to the restrictions \n   set out below. Some purposes which can be non-commercial are teaching, \n   academic research, public demonstrations and personal experimentation \n   or personal home use. You may also distribute this Software with \n   books or other teaching materials, or publish the Software on websites, \n   that are intended to teach the use of the Software for academic or \n   other non-commercial purposes. \n   You may NOT use or distribute this Software or any derivative works \n   in any form for commercial purposes, except those outlined in (B). \n   Examples of commercial purposes are running business operations, \n   licensing, leasing, or selling the Software, distributing the \n   Software for use with commercial products (no matter whether free or paid), \n   using the Software in the creation or use of commercial products or any \n   other activity which purpose is to procure a commercial gain to you or \n   others (except for conditions set out in (B)).\nB. Further, you may use the software for commercial research, which meets\n   the following conditions: commercial research which is not directly\n   associated with product development and has the primary purpose of \n   publishing and sharing results with the academic world; pre-product \n   evaluations of algorithms and methods, as long as these evaluations\n   are more of an evaluatory, planning, and research nature than \n   of a product development nature. \n   Any further commercial use requires you to obtain a commercial\n   license or written approval from audEERING GmbH which grants\n   you extended usage rights for this software. In particular any direct \n   (software) or indirect (models, features extracted with the software)\n   use of the software, parts of the software, or derivatives in a \n   product (no matter whether free or paid), is not allowed without \n   an additional commercial license.\nC. If the software includes source code or data, you may create \n   derivative works of such portions of the software and distribute the \n   modified software for non-commercial purposes, as provided herein.\n   If you distribute the software or any derivative works of the Software, \n   you must distribute them under the same terms and conditions as in this\n   license, and you must not grant other rights to the software or \n   derivative works that are different from those provided by this \n   license agreement. \n   If you have created derivative works of the software, and distribute \n   such derivative works, you will cause the modified files to carry \n   prominent notices so that recipients know that they are not receiving \n   the original software. Such notices must state: \n   (i) that you have altered the software; \n   and (ii) the date of any changes as well as your name.\n\nIn return for the above rights, you agree to:\n1. That you will not remove any copyright or other notices (authors \n   and citing information, for example) from the software.\n2. That if any of the software is in binary format, you will not attempt \n   to modify such portions of the software, or to reverse engineer or \n   decompile them, except and only to the extent authorized by applicable \n   law. \n3. That the copyright holders (audEERING) are granted back, \n   without any restrictions or limitations, a non-exclusive, perpetual, \n   irrevocable, royalty-free, assignable and sub-licensable license, \n   to reproduce, publicly perform or display, install, use, modify, post, \n   distribute, make and have made, sell and transfer your modifications \n   to and/or derivative works of the software source code or data, \n   for any purpose.  \n4. That any feedback about the software provided by you to us is voluntarily \n   given, and audEERING shall be free to use the feedback \n   as they see fit without obligation or restriction of any kind, \n   even if the feedback is designated by you as confidential. \n\n5. THAT THE SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. \n   THIS MEANS NO EXPRESS, IMPLIED OR STATUTORY WARRANTY, INCLUDING \n   WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A \n   PARTICULAR PURPOSE, ANY WARRANTY AGAINST INTERFERENCE WITH YOUR \n   ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE OR NON-INFRINGEMENT.\n   THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL ANY OF YOUR \n   PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS DISCLAIMER ON \n   WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n   \n6. THAT NEITHER AUDEERING NOR ANY AUTHOR OR CONTRIBUTOR TO THE \n   SOFTWARE WILL BE LIABLE FOR ANY DAMAGES RELATED TO THE SOFTWARE OR THIS \n   LICENSE, INCLUDING DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL \n   DAMAGES, TO THE MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL \n   THEORY IT IS BASED ON. ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY \n   ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n   \n7. That we have no duty of reasonable care or lack of negligence, \n   and we are not obligated to (and will not) provide technical support for \n   the Software.\n8. That if you breach this license agreement or if you sue anyone over \n   patents that you think may apply to or read on the software or anyone's \n   use of the software, this license agreement (and your license and rights \n   obtained herein) terminate automatically. Upon any such termination, \n   you shall destroy all of your copies of the software immediately.  \n   Sections 3, 4, 5, 6, 7, 10 and 11 of this license agreement shall survive \n   any termination of this license agreement.\n9. That the patent rights, if any, granted to you in this license agreement \n   only apply to the software, not to any derivative works you make.\n10.That the software may be subject to European export or import laws or such \n   laws in other places. You agree to comply with all such laws and regulations \n   that may apply to the software after the delivery of the software to you.\n11.That all rights not expressly granted to you in this license agreement \n   are reserved by audEERING.\n12.That this license agreement shall be construed and controlled by the laws \n   of the Federal Republic of Germany, without regard to conflicts of law. \n   If any provision of this license agreement shall be deemed unenforceable \n   or contrary to law, the rest of this license agreement shall remain in \n   full effect and interpreted in an enforceable manner that most closely \n   captures the intent of the original language. \n\n\nCommerical license options\n==========================\n \nFor commercial and other licensing options, \nplease contact us at audEERING via E-mail: \n   info@audeering.com \n\n\nThird-party contributions and dependencies\n==========================================\n\nopenSMILE contains third-party contributions from the Speex codec package \n(in the cLsp component), which are distributed unter the following terms:\n-----------------------------------------------------------------------\nCopyright 2002-2008     Xiph.org Foundation\nCopyright 2002-2008     Jean-Marc Valin\nCopyright 2005-2007     Analog Devices Inc.\nCopyright 2005-2008     Commonwealth Scientific and Industrial Research\n                        Organisation (CSIRO)\nCopyright 1993, 2002, 2006 David Rowe\nCopyright 2003          EpicGames\nCopyright 1992-1994     Jutta Degener, Carsten Bormann\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n\n- Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n\n- Redistributions in binary form must reproduce the above copyright\nnotice, this list of conditions and the following disclaimer in the\ndocumentation and/or other materials provided with the distribution.\n\n- Neither the name of the Xiph.org Foundation nor the names of its\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR\nCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\nEXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\nPROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\nPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n-----------------------------------------------------------------------\n\nopenSMILE uses rapidjson to read RNN files in json format.\nRapidjson can be obtained from: https://code.google.com/p/rapidjson/\nIt is distributed under the MIT license and included with openSMILE\nin src/include/rapidjson\nIt is distributed under these terms:\n-----------------------------------------\nCopyright (C) 2011 Milo Yip\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n-----------------------------------------\n\n\nopenSMILE uses LibSVM (by Chih-Chung Chang and Chih-Jen Lin) for \nclassification tasks. It is distributed with openSMILE and is\n included in the src/classifiers/libsvm/ directory.\nSee the COPYRIGHT file in that directory for details on license terms\n of LivSVM.\n\nPortAudio is required for live recording from sound card and for \nthe SEMAINE components.\nYou can get the latest version from: http://www.portaudio.com\nHowever, we cannot guarantee compatibility with the latest versions.\nA snapshot of portaudio that is known to work with openSMILE\nis included in thirdparty/portaudio.tgz.\nCopyright and licensing information for portaudio is also contained\nin the .tgz package.\n\nOptionally, openSMILE can be linked against the SEMAINE API \nand the Julius LVCSR engine, enabling an interface to the \nSEMAINE system and a keyword spotter component. \nSee http://www.semaine-project.eu/ for details on running the \nSEMAINE system.\nOnly the older versions of openSMILE (1.0.1) are officially \nsupported to be build with the SEMAINE system.\nFor recent developments, check out the status of the ARIA VALUSPA\nEU-project: http://aria-agent.eu/\n\n--\nFor Unix platforms, openSMILE relies on automake and autoconf to build.\nIn order to easy compilation against pthreads library,\nthe m4 macro find_pthreads.m4 is shipped with openSMILE to ease\nthe build process.\nThis macro is not part of openSMILE, it is only\nused to build openSMILE - it is part of autoconf. \nIt is distributed separately under it's own license terms\nfrom http://autoconf-archive.cryp.to/acx_pthread.html\n#  Copyright © 2008 Steven G. Johnson <stevenj@alum.mit.edu>\n# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.\n# As a special exception, the respective Autoconf Macro's copyright owner gives unlimited permission to copy, distribute and modify the configure scripts that are the output of Autoconf when processing the Macro. You need not follow the terms of the GNU General Public License when using or distributing such scripts, even though portions of the text of the Macro appear in them. The GNU General Public License (GPL) does govern all other use of the material that constitutes the Autoconf Macro.\n# This special exception to the GPL applies to versions of the Autoconf Macro released by the Autoconf Macro Archive. When you make and distribute a modified version of the Autoconf Macro, you may extend this special exception to the GPL to apply to your modified version as well.\n--\n\n\n\n"
  },
  {
    "path": "CREDITS",
    "content": "\n*************\n** Authors **\n*************\n\nopenSMILE was started in 2008 at TUM-MMK in Munich.\nThe main authors are:\n  Florian Eyben,\n  Felix Weninger,\n  Martin Wöllmer,\n  Björn Schuller\n\nThere have also been many contributions by various people,\nwhich are acknowledged below.\n\nACKNOWLEDEGMENT\n==============\n\nThe development of openSMILE has received funding\nfrom the European Community's Seventh Framework\nProgramme (FP7/2007-2013) under grant agreement No.\n211486 (SEMAINE)\n\n\n*******************************************************************************\n** We would like to thank the following people for contributing to openSMILE **\n*******************************************************************************\n\nChristoph Kozielski (TUM), \n  - helped to fix many bugs in various components (toneSpec, ...), \n  - pointed out some missing essential features, \n  - implemented the Chroma component, \n  - helped with compilation on Windows and Mingw32.\n\nBenedikt Gollan (TUM), \n  - helped integrating openSMILE into Qt GUI's (ADMIRE project & openEAR GUI), \n  - implemented the components:\n       chromaFeatures, chordFeatures, \n       chromaPerFrame, channelMixer, and  stretchToTime. \n  - added support for negative start index to waveSource component\n  - added support for message based switching of models in libsvmliveSink\n  - helped with compilation under windows/mingw.\n  - various bugfixes\n\nDino Seppi (KU-LEUVEN),\n  - bugfixes in functionalTimes\n  - ideas for duration and onset functionals\n\nDainis Boumber (http://www2.cs.uh.edu/~boumber/)\n  - developed the first Android port for the open-source version (1.0.1 and 2.0)\n    and pointed out required changes to the code. Many thanks for this!\n\nBernd Huber (audEERING),\n  - full integration of Dainis Android ports into the trunk\n  - work on Android clients\n\n"
  },
  {
    "path": "ChangeLog",
    "content": "\nSee http://opensmile.audeering.com for more information.\n \n"
  },
  {
    "path": "INSTALL",
    "content": "================================================\nopenSMILE quick-start installation instructions:\n================================================\n\n\nFor comprehensive instructions on how to build and use openSMILE, please refer to the file:\n  >>>>  doc/openSMILE_book.pdf <<<<<\n\nQuick installation instructions for windows (Visual Studio):\n  open\n    ide\\vs10\\openSMILE.sln\n  and build the \"Release\" configuration for the standalone version.\n  For portaudio and/or openCV, read ide\\vs10\\README_*\n  and build the according configurations (ReleasePortaudio, ReleaseOpenCV, etc.).\n  \nQuick installation instructions for Linux:\n\n  unpack the archive (which you obviously already have when you are reading this file):\n    tar-zxvf opensmile-X.X.X.tar.gz\n    cd opensmile-X.X.X\n    (replace X.X.X by the version number of your version)\n\n  then type:\n    sh buildStandalone.sh\n  to build a standalone, statically linked SMILExtract binary without live audio support (via PortAudio)\n  \n  or type:\n    sh buildWithPortaudio.sh\n  to build the portaudio library, the libopensmile shared library, \n  and a SMILExtract binary linked against both libraries.\n  NOTE: portaudio.tgz (e.g. the current snapshot from their website)\n   must be present in ../thirdparty/portaudio.tgz  (relative to this directory).\n\n\n\n*********************************************************************\nBelow are generic GNU installation instructions:\n\n\n\nGENERIC Installation Instructions\n*********************************\n\nCopyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,\n2006, 2007 Free Software Foundation, Inc.\n\nThis file is free documentation; the Free Software Foundation gives\nunlimited permission to copy, distribute and modify it.\n\nBasic Installation\n==================\n\nBriefly, the shell commands `./configure; make; make install' should\nconfigure, build, and install this package.  The following\nmore-detailed instructions are generic; see the `README' file for\ninstructions specific to this package.\n\n   The `configure' shell script attempts to guess correct values for\nvarious system-dependent variables used during compilation.  It uses\nthose values to create a `Makefile' in each directory of the package.\nIt may also create one or more `.h' files containing system-dependent\ndefinitions.  Finally, it creates a shell script `config.status' that\nyou can run in the future to recreate the current configuration, and a\nfile `config.log' containing compiler output (useful mainly for\ndebugging `configure').\n\n   It can also use an optional file (typically called `config.cache'\nand enabled with `--cache-file=config.cache' or simply `-C') that saves\nthe results of its tests to speed up reconfiguring.  Caching is\ndisabled by default to prevent problems with accidental use of stale\ncache files.\n\n   If you need to do unusual things to compile the package, please try\nto figure out how `configure' could check whether to do them, and mail\ndiffs or instructions to the address given in the `README' so they can\nbe considered for the next release.  If you are using the cache, and at\nsome point `config.cache' contains results you don't want to keep, you\nmay remove or edit it.\n\n   The file `configure.ac' (or `configure.in') is used to create\n`configure' by a program called `autoconf'.  You need `configure.ac' if\nyou want to change it or regenerate `configure' using a newer version\nof `autoconf'.\n\nThe simplest way to compile this package is:\n\n  1. `cd' to the directory containing the package's source code and type\n     `./configure' to configure the package for your system.\n\n     Running `configure' might take a while.  While running, it prints\n     some messages telling which features it is checking for.\n\n  2. Type `make' to compile the package.\n\n  3. Optionally, type `make check' to run any self-tests that come with\n     the package.\n\n  4. Type `make install' to install the programs and any data files and\n     documentation.\n\n  5. You can remove the program binaries and object files from the\n     source code directory by typing `make clean'.  To also remove the\n     files that `configure' created (so you can compile the package for\n     a different kind of computer), type `make distclean'.  There is\n     also a `make maintainer-clean' target, but that is intended mainly\n     for the package's developers.  If you use it, you may have to get\n     all sorts of other programs in order to regenerate files that came\n     with the distribution.\n\n  6. Often, you can also type `make uninstall' to remove the installed\n     files again.\n\nCompilers and Options\n=====================\n\nSome systems require unusual options for compilation or linking that the\n`configure' script does not know about.  Run `./configure --help' for\ndetails on some of the pertinent environment variables.\n\n   You can give `configure' initial values for configuration parameters\nby setting variables in the command line or in the environment.  Here\nis an example:\n\n     ./configure CC=c99 CFLAGS=-g LIBS=-lposix\n\n   *Note Defining Variables::, for more details.\n\nCompiling For Multiple Architectures\n====================================\n\nYou can compile the package for more than one kind of computer at the\nsame time, by placing the object files for each architecture in their\nown directory.  To do this, you can use GNU `make'.  `cd' to the\ndirectory where you want the object files and executables to go and run\nthe `configure' script.  `configure' automatically checks for the\nsource code in the directory that `configure' is in and in `..'.\n\n   With a non-GNU `make', it is safer to compile the package for one\narchitecture at a time in the source code directory.  After you have\ninstalled the package for one architecture, use `make distclean' before\nreconfiguring for another architecture.\n\nInstallation Names\n==================\n\nBy default, `make install' installs the package's commands under\n`/usr/local/bin', include files under `/usr/local/include', etc.  You\ncan specify an installation prefix other than `/usr/local' by giving\n`configure' the option `--prefix=PREFIX'.\n\n   You can specify separate installation prefixes for\narchitecture-specific files and architecture-independent files.  If you\npass the option `--exec-prefix=PREFIX' to `configure', the package uses\nPREFIX as the prefix for installing programs and libraries.\nDocumentation and other data files still use the regular prefix.\n\n   In addition, if you use an unusual directory layout you can give\noptions like `--bindir=DIR' to specify different values for particular\nkinds of files.  Run `configure --help' for a list of the directories\nyou can set and what kinds of files go in them.\n\n   If the package supports it, you can cause programs to be installed\nwith an extra prefix or suffix on their names by giving `configure' the\noption `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.\n\nOptional Features\n=================\n\nSome packages pay attention to `--enable-FEATURE' options to\n`configure', where FEATURE indicates an optional part of the package.\nThey may also pay attention to `--with-PACKAGE' options, where PACKAGE\nis something like `gnu-as' or `x' (for the X Window System).  The\n`README' should mention any `--enable-' and `--with-' options that the\npackage recognizes.\n\n   For packages that use the X Window System, `configure' can usually\nfind the X include and library files automatically, but if it doesn't,\nyou can use the `configure' options `--x-includes=DIR' and\n`--x-libraries=DIR' to specify their locations.\n\nSpecifying the System Type\n==========================\n\nThere may be some features `configure' cannot figure out automatically,\nbut needs to determine by the type of machine the package will run on.\nUsually, assuming the package is built to be run on the _same_\narchitectures, `configure' can figure that out, but if it prints a\nmessage saying it cannot guess the machine type, give it the\n`--build=TYPE' option.  TYPE can either be a short name for the system\ntype, such as `sun4', or a canonical name which has the form:\n\n     CPU-COMPANY-SYSTEM\n\nwhere SYSTEM can have one of these forms:\n\n     OS KERNEL-OS\n\n   See the file `config.sub' for the possible values of each field.  If\n`config.sub' isn't included in this package, then this package doesn't\nneed to know the machine type.\n\n   If you are _building_ compiler tools for cross-compiling, you should\nuse the option `--target=TYPE' to select the type of system they will\nproduce code for.\n\n   If you want to _use_ a cross compiler, that generates code for a\nplatform different from the build platform, you should specify the\n\"host\" platform (i.e., that on which the generated programs will\neventually be run) with `--host=TYPE'.\n\nSharing Defaults\n================\n\nIf you want to set default values for `configure' scripts to share, you\ncan create a site shell script called `config.site' that gives default\nvalues for variables like `CC', `cache_file', and `prefix'.\n`configure' looks for `PREFIX/share/config.site' if it exists, then\n`PREFIX/etc/config.site' if it exists.  Or, you can set the\n`CONFIG_SITE' environment variable to the location of the site script.\nA warning: not all `configure' scripts look for a site script.\n\nDefining Variables\n==================\n\nVariables not defined in a site shell script can be set in the\nenvironment passed to `configure'.  However, some packages may run\nconfigure again during the build, and the customized values of these\nvariables may be lost.  In order to avoid this problem, you should set\nthem in the `configure' command line, using `VAR=value'.  For example:\n\n     ./configure CC=/usr/local2/bin/gcc\n\ncauses the specified `gcc' to be used as the C compiler (unless it is\noverridden in the site shell script).\n\nUnfortunately, this technique does not work for `CONFIG_SHELL' due to\nan Autoconf bug.  Until the bug is fixed you can use this workaround:\n\n     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash\n\n`configure' Invocation\n======================\n\n`configure' recognizes the following options to control how it operates.\n\n`--help'\n`-h'\n     Print a summary of the options to `configure', and exit.\n\n`--version'\n`-V'\n     Print the version of Autoconf used to generate the `configure'\n     script, and exit.\n\n`--cache-file=FILE'\n     Enable the cache: use and save the results of the tests in FILE,\n     traditionally `config.cache'.  FILE defaults to `/dev/null' to\n     disable caching.\n\n`--config-cache'\n`-C'\n     Alias for `--cache-file=config.cache'.\n\n`--quiet'\n`--silent'\n`-q'\n     Do not print messages saying which checks are being made.  To\n     suppress all normal output, redirect it to `/dev/null' (any error\n     messages will still be shown).\n\n`--srcdir=DIR'\n     Look for the package's source code in directory DIR.  Usually\n     `configure' can determine that directory automatically.\n\n`configure' also accepts some other, not widely useful, options.  Run\n`configure --help' for more details.\n\n"
  },
  {
    "path": "JULIUS_LICENSE",
    "content": "*** English translation is available in the latter of this file ***\r\n\r\n\tubAFGW Juliusv\r\n\t\t\tp\r\n\r\n  Copyright (c)   1991-2009 sw ͌\r\n  Copyright (c)   1997-2000 񏈗UƋ(IPA)\r\n  Copyright (c)   2000-2005 ޗǐ[ȊwZpw@w 쌤\r\n  Copyright (c)   2005-2009 ÉHƑw JuliusJ`[\r\n\r\n----------------------------------------------------------------------------\r\n\r\nubAFGW JuliusviJulian܂ށj́Asw ͌\r\nAޗǐ[ȊwZpw@w 쌤AyіÉHƑw \r\nJuliusJ`[ŊJĂ܂B1997Nx3NԁA񏈗U\r\nƋ(IPA){uƑnIZp琬Ɓv̉󂯂܂B\r\n\r\nsw ͌AIPAAޗǐ[ȊwZpw@w 쌤Ay\r\nÉHƑw JuliusJ`[iȉ킹āu쌠ҁvƌj́A\r\n҂ł蒘쌠𗯕ۂĂ܂A{p̑SĂ炷\r\nA\\[XR[h܂ޖ{vOyуhLe[Viȉ\r\nāu{\\tgEFAvƌj𖳏łȂɒ񋟂܂BȂ{\\\r\ntgEFA𗘗pƂ́A{p̑SĂ̂ƊŘ􂳂\r\nB\r\n\r\n\t\t\typz\r\n\r\n1. Ȃ́A{p̑SĂ炷A{\\tgEFȂS\r\n͈ꕔɂĎgpAA|āAύXAg݁A邱Ƃт\r\n̕A|ĕAύXzzAM邱Ƃł܂BA\r\nȂ܂ߖ{\\tgEFA̗p҂́A{\\tgEFȂS͂̈ꕔ\r\nύXĂ̕zzAMȂǂđO҂ɒ񋟂Ƃ͑2\r\n\\Lڂɉ{\\tgEFAύX|AύXҋyт̕ύX𖾊m\r\n\\̂Ƃ܂B\r\n\r\n2. Ȃ́AgpAA|āAύXAg݁Ȃ{\\tgEFA\r\n̗pԗl̔@ɂ炸A̕A|ĕAύX̑S͈\r\nO҂ɒ񋟂Ƃ́A{\\tgEFAɉL̒쌠\\yьJ\r\n|܂ޖ{p̑Sāi̕t@CjύX邱\r\nȂ̂܂ܕ\\YtȂ΂Ȃ܂B\r\n\r\n\t\t\tL\r\n  Copyright (c) 1991-2009 sw ͌\r\n  Copyright (c) 1997-2000 񏈗UƋ(IPA)\r\n  Copyright (c) 2000-2005 ޗǐ[ȊwZpw@w 쌤\r\n  Copyright (c) 2005-2009 ÉHƑw JuliusJ`[\r\n\r\n3. {\\tgEFA𗘗pēꂽmɊւĔ\\sȂۂɂ́A\r\nubAFGW Juliusv𗘗pƂ𖾋LĉB\r\n\r\n4. {\\tgEFÁAJ̎앨ƂĂ邪܂܂̏ԂŖJ\r\n񋟂̂łA{\\tgEFAɊւAAَ킸AȂ\r\nɂ闘pł邩킸A܂@߂ɂ萶̂ł邩ۂ\r\n킸A؂̕ۏ؂s܂BŌۏ؂ɂ́A{\\tgEFA̕i\r\nA\\AiAړIKÂׂȂƂё̑O҂̗L\r\n钘쌠AAW̖̍YcƔ閧̑̌vNQ\r\nȂƂ̕ۏ؂܂݂܂AɌ肳̂ł͂܂B\r\n܂ߖ{\\tgEFA̗p҂́A{\\tgEFAۏ؂ł邱Ƃ\r\nA{\\tgEFAۏ؂ł邱Ƃ̃XN𗘗pҎgŕ̂\r\n܂Bٔ̔̑炩̗Rɂ肠Ȃɉۂꂽ`Ɩ{\r\npeȂƂ́A{\\tgEFA𗘗pĂ͂Ȃ܂B{\\\r\ntgEFA̗p͗płȂƂɊւĂȂyёO҂ɐ\r\n푹QAʑQAړIAԐړIAtIAhIȑQi편v܂ށj\r\n؂ɂAꂪ_As@sאӔCArSېӔCAӔC\r\n鍑̂Ȃ@ɂ邩킸A܂B\r\n\r\n5. {\\tgEFA̗pɊւẮA{̖@@ƂAsn\r\nٔR̐ꑮǊٔƂ܂B\r\n\r\n6. {\\tgEFÃeiXT|[gALȊO̗pɊւ\r\nẮAÉHƑw JuliusJ`[A܂͋sw ͌ɏƉ\r\nB\r\n\r\n\r\n\r\n*** This is English translation of the Japanese original for reference ***\r\n\r\n\r\n     Large Vocabulary Continuous Speech Recognition Engine Julius\r\n\r\n\r\n Copyright (c) 1997-2000 Information-technology Promotion Agency, Japan\r\n Copyright (c) 1991-2009 Kawahara Lab., Kyoto University\r\n Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology\r\n Copyright (c) 2005-2009 Julius project team, Nagoya Institute of Technology\r\n\r\n\"Large Vocabulary Continuous Speech Recognition Engine Julius\",\r\nincluding Julian, is being developed at Kawahara Lab., Kyoto\r\nUniversity, Shikano Lab., Nara Institute of Science and Technology,\r\nand Julius project team, Nagoya Institute of Technology (collectively\r\nreferred to herein as the \"Licensers\").  Julius was funded by the\r\nAdvanced Information Technology Program Project of\r\nInformation-technology Promotion Agency (IPA), Japan for three years\r\nsince 1997.\r\n\r\nThe Licensers reserve the copyright thereto.  However, as long as you\r\naccept and remain in strict compliance with the terms and conditions\r\nof the license set forth herein, you are hereby granted a royalty-free\r\nlicense to use \"Large Vocabulary Continuous Speech Recognition Engine\r\nJulius\" including the source code thereof and the documentation\r\nthereto (collectively referred to herein as the \"Software\").  Use by\r\nyou of the Software shall constitute acceptance by you of all terms\r\nand conditions of the license set forth herein.\r\n\r\n\t      TERMS AND CONDITIONS OF LICENSE\r\n\r\n1. So long as you accept and strictly comply with the terms and\r\nconditions of the license set forth herein, the Licensers will not\r\nenforce the copyright or moral rights in respect of the Software, in\r\nconnection with the use, copying, duplication, adaptation,\r\nmodification, preparation of a derivative work, aggregation with\r\nanother program, or insertion into another program of the Software or\r\nthe distribution or transmission of the Software.  However, in the\r\nevent you or any other user of the Software revises all or any portion\r\nof the Software, and such revision is distributed, then, in addition\r\nto the notice required to be affixed pursuant to paragraph 2 below, a\r\nnotice shall be affixed indicating that the Software has been revised,\r\nand indicating the date of such revision and the name of the person or\r\nentity that made the revision.\r\n\r\n2. In the event you provide to any third party all or any portion of\r\nthe Software, whether for copying, duplication, adaptation,\r\nmodification, preparation of a derivative work, aggregation with\r\nanother program, insertion into another program, or other use, you\r\nshall affix the following copyright notice and all terms and\r\nconditions of this license (both the Japanese original and English\r\ntranslation) as set forth herein, without any revision or change\r\nwhatsoever.\r\n\r\n                      Form of copyright notice:\r\n\r\n Copyright (c) 1997-2000 Information-technology Promotion Agency, Japan\r\n Copyright (c) 1991-2009 Kawahara Lab., Kyoto University\r\n Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology\r\n Copyright (c) 2005-2009 Julius project team, Nagoya Institute of Technology\r\n\r\n3. When you publish or present any results by using the Software, you\r\nmust explicitly mention your use of \"Large Vocabulary Continuous\r\nSpeech Recognition Engine Julius\".\r\n\r\n4. The Licensers are licensing the Software, which is the trial\r\nproduct of research and project, on an \"as is\" and royalty-free basis,\r\nand makes no warranty or guaranty whatsoever with respect to the\r\nSoftware, whether express or implied, irrespective of the nation where\r\nused, and whether or not arising out of statute or otherwise,\r\nincluding but not limited to any warranty or guaranty with respect to\r\nquality, performance, merchantability, fitness for a particular\r\npurpose, absence of defects, or absence of infringement of copyright,\r\npatent rights, trademark rights or other intellectual property rights,\r\ntrade secrets or proprietary rights of any third party.  You and every\r\nother user of the Software hereby acknowledge that the Software is\r\nlicensed without any warranty or guaranty, and assume all risks\r\narising out of the absence of any warranty or guaranty.  In the event\r\nthe terms and conditions of this license are inconsistent with the\r\nobligations imposed upon you by judgment of a court or for any other\r\nreason, you may not use the Software.\r\n\r\nThe Licensers shall not have any liability to you or to any third\r\nparty for damages or liabilities of any nature whatsoever arising out\r\nof your use of or inability to use the Software, whether of an\r\nordinary, special, direct, indirect, consequential or incidental\r\nnature (including without limitation lost profits) or otherwise, and\r\nwhether arising out of contract, negligence, tortuous conduct, product\r\nliability or any other legal theory or reason whatsoever of any nation\r\nor jurisdiction.\r\n\r\n5. This license of use of the Software shall be governed by the laws\r\nof Japan, and the Kyoto District Court shall have exclusive primary\r\njurisdiction with respect to all disputes arising with respect\r\nthereto.\r\n\r\n6. Inquiries for support or maintenance of the Software, or inquiries\r\nconcerning this license of use besides the conditions above, may be\r\nsent to Julius project team, Nagoya Institute of Technology, or\r\nKawahara Lab., Kyoto University.\r\n"
  },
  {
    "path": "Makefile.am",
    "content": "\nACLOCAL_AMFLAGS = -I m4\n\nAUTOMAKE_OPTIONS = subdir-objects\n  \nbin_PROGRAMS = SMILExtract \n#bin_PROGRAMS += SEMAINExtract\n\nSMILELIB_SOURCES=\\\n\tsrc/classifiers/julius/juliusSink.cpp \\\n\tsrc/classifiers/libsvm/svm.cpp \\\n\tsrc/classifiers/libsvmliveSink.cpp \\\n\tsrc/classifiers/svmSink.cpp \\\n\tsrc/core/commandlineParser.cpp \\\n\tsrc/core/componentManager.cpp \\\n\tsrc/core/configManager.cpp \\\n\tsrc/core/dataMemory.cpp \\\n\tsrc/core/dataProcessor.cpp \\\n\tsrc/core/dataReader.cpp \\\n\tsrc/core/dataSelector.cpp \\\n\tsrc/core/dataSink.cpp \\\n\tsrc/core/dataSource.cpp \\\n\tsrc/core/dataWriter.cpp \\\n\tsrc/core/exceptions.cpp \\\n\tsrc/core/nullSink.cpp \\\n\tsrc/core/smileCommon.cpp \\\n\tsrc/core/smileComponent.cpp \\\n\tsrc/core/smileLogger.cpp \\\n\tsrc/core/vecToWinProcessor.cpp \\\n\tsrc/core/vectorProcessor.cpp \\\n\tsrc/core/vectorTransform.cpp \\\n\tsrc/core/winToVecProcessor.cpp \\\n\tsrc/core/windowProcessor.cpp \\\n\tsrc/dsp/dbA.cpp \\\n\tsrc/dsp/signalGenerator.cpp \\\n\tsrc/dsp/smileResample.cpp \\\n\tsrc/dsp/specResample.cpp \\\n\tsrc/dsp/vadV1.cpp \\\n\tsrc/dspcore/acf.cpp \\\n\tsrc/dspcore/amdf.cpp \\\n\tsrc/dspcore/contourSmoother.cpp \\\n\tsrc/dspcore/deltaRegression.cpp \\\n\tsrc/dspcore/fftmagphase.cpp \\\n\tsrc/dspcore/fftsg.c \\\n\tsrc/dspcore/framer.cpp \\\n\tsrc/dspcore/fullinputMean.cpp \\\n\tsrc/dspcore/fullturnMean.cpp \\\n\tsrc/dspcore/monoMixdown.cpp \\\n\tsrc/dspcore/preemphasis.cpp \\\n\tsrc/dspcore/transformFft.cpp \\\n\tsrc/dspcore/turnDetector.cpp \\\n\tsrc/dspcore/vectorMVN.cpp \\\n\tsrc/dspcore/vectorPreemphasis.cpp \\\n\tsrc/dspcore/windower.cpp \\\n\tsrc/examples/exampleSink.cpp \\\n\tsrc/examples/exampleSource.cpp \\\n        src/examples/simpleMessageSender.cpp \\\n\tsrc/functionals/functionalComponent.cpp \\\n\tsrc/functionals/functionalCrossings.cpp \\\n\tsrc/functionals/functionalDCT.cpp \\\n\tsrc/functionals/functionalExtremes.cpp \\\n\tsrc/functionals/functionalLpc.cpp \\\n\tsrc/functionals/functionalMeans.cpp \\\n\tsrc/functionals/functionalMoments.cpp \\\n\tsrc/functionals/functionalOnset.cpp \\\n\tsrc/functionals/functionalPeaks.cpp \\\n\tsrc/functionals/functionalPeaks2.cpp \\\n\tsrc/functionals/functionalPercentiles.cpp \\\n\tsrc/functionals/functionalRegression.cpp \\\n\tsrc/functionals/functionalSamples.cpp \\\n\tsrc/functionals/functionalSegments.cpp \\\n\tsrc/functionals/functionalTimes.cpp \\\n\tsrc/functionals/functionals.cpp \\\n\tsrc/lld/lsp.cpp \\\n\tsrc/dsp/specScale.cpp \\\n\tsrc/io/libsvmSink.cpp \\\n\tsrc/iocore/arffSink.cpp \\\n\tsrc/iocore/arffSource.cpp \\\n\tsrc/iocore/csvSink.cpp \\\n\tsrc/iocore/csvSource.cpp \\\n\tsrc/iocore/datadumpSink.cpp \\\n\tsrc/iocore/htkSink.cpp \\\n\tsrc/iocore/htkSource.cpp \\\n\tsrc/iocore/waveSink.cpp \\\n\tsrc/iocore/waveSinkCut.cpp \\\n\tsrc/iocore/waveSource.cpp \\\n\tsrc/lld/cens.cpp \\\n\tsrc/lld/chroma.cpp \\\n\tsrc/lld/harmonics.cpp \\\n\tsrc/lld/formantLpc.cpp \\\n\tsrc/lld/formantSmoother.cpp \\\n\tsrc/lld/lpc.cpp \\\n\tsrc/lld/pitchDirection.cpp \\\n\tsrc/lld/pitchJitter.cpp \\\n\tsrc/lld/pitchShs.cpp \\\n\tsrc/lld/pitchSmootherViterbi.cpp \\\n\tsrc/lld/tonefilt.cpp \\\n\tsrc/lld/tonespec.cpp \\\n\tsrc/lldcore/energy.cpp \\\n\tsrc/lldcore/intensity.cpp \\\n\tsrc/lldcore/melspec.cpp \\\n\tsrc/lldcore/mfcc.cpp \\\n\tsrc/lldcore/mzcr.cpp \\\n\tsrc/lldcore/pitchACF.cpp \\\n\tsrc/lldcore/pitchBase.cpp \\\n\tsrc/lldcore/pitchSmoother.cpp \\\n\tsrc/lldcore/plp.cpp \\\n\tsrc/lldcore/spectral.cpp \\\n\tsrc/other/bowProducer.cpp \\\n\tsrc/other/maxIndex.cpp \\\n\tsrc/other/valbasedSelector.cpp \\\n\tsrc/other/vectorConcat.cpp \\\n\tsrc/other/vectorOperation.cpp \\\n\tsrc/portaudio/portaudioDuplex.cpp \\\n\tsrc/portaudio/portaudioSink.cpp \\\n\tsrc/portaudio/portaudioSource.cpp \\\n\tsrc/portaudio/portaudioWavplayer.cpp \\\n        src/android/openslesSource.cpp \\\n        src/android/jniMessageInterface.cpp \\\n\tsrc/rnn/rnn.cpp \\\n\tsrc/rnn/rnnProcessor.cpp \\\n\tsrc/rnn/rnnSink.cpp \\\n\tsrc/rnn/rnnVad2.cpp \\\n\tsrc/smileutil/smileUtil.c \\\n\tsrc/smileutil/smileUtilSpline.c \\\n\tsrc/smileutil/zerosolve.cpp \\\n\tsrc/video/openCVSource.cpp\n\t\n\n\n  SMILE_SOURCES=$(SMILELIB_SOURCES)\n\n  SMILE_CPPFLAGS = -Isrc/include -Iprogsrc/include $(SEMAINEAPI_CPPFLAGS) $(PORTAUDIO_CPPFLAGS) $(OPENCV_CPPFLAGS) -ggdb $(PTHREAD_CFLAGS)\n  SMILE_LIBS =  $(PORTAUDIO_LDFLAGS) $(OPENCV_LDFLAGS) -lm $(SEMAINEAPI_LDFLAGS) $(PTHREAD_LIBS) $(DLIB)\n   \n  SMILExtract_SOURCES = progsrc/smilextract/SMILExtract.cpp \n  SMILExtract_CPPFLAGS = $(SMILE_CPPFLAGS)\n  SMILExtract_LDADD = $(SMILE_LIBS) -lopensmile\n\n  lib_LTLIBRARIES = libopensmile.la\n  libopensmile_la_SOURCES = $(SMILE_SOURCES)\n  libopensmile_la_CPPFLAGS = $(SMILE_CPPFLAGS)\n  libopensmile_la_LIBADD = $(SMILE_LIBS)\n  libopensmile_la_LDFLAGS = --no-undefined\n  \n\n\n# endif \n\n\n"
  },
  {
    "path": "NEWS",
    "content": "\nSee http://opensmile.audeering.com/ for current news.\n\n"
  },
  {
    "path": "README.md",
    "content": "# audEERING has published their own openSMILE github repo at [audEERING/openSMILE](https://github.com/audeering/opensmile) which is more updated.\nThis repo will be archived.\n\n-----\n\n## This repository is just a mirror of the openSMILE code. It'll be removed once the openSMILE team use Github to distribute openSMILE code. Responses to issues are not promised.\n\n\n  openSMILE \n   - open-source\n     Speech and Music Interpretation by Large-space Extraction -\n  Main authors: Florian Eyben, Felix Weninger, Martin Woellmer, Bjoern Schuller\n  Copyright (C) 2008-2013, Institute for Human-Machine Communication, \n                           Technische Universitaet Muenchen, Germany\n  Copyright (C) 2013-2015, audEERING UG (haftungsbeschraenkt)\n  Copyright (C) 2016,      audEERING GmbH\n \n  (C) audEERING GmbH\n  Gilching, Germany\n  http://www.audeeering.com/\n  All rights reserved. \n  \n  See file COPYING for your rights when using this software.\n  If you do not agree to these licensing terms,\n  your are not allowed to use this software and must destroy\n  all copies immediately.\n  \n\nAbout openSMILE:\n================\n\nopenSMILE is a complete and open-source toolkit for audio analysis, \nprocessing and classification especially targeted at speech and \nmusic applications, e.g. automatic speech recognition, speaker identification,\nemotion recognition, or beat tracking and chord detection.\n\nThe toolkit was first developed at the Institute for Human-Machine \nCommunication at the Technische Universitaet Muenchen in Munich, Germany.\nIt was started within the SEMAINE EU-FP7 research project.\nThe toolkit is now owned and maintained \nby audEERING GmbH, who provide intelligent\naudio analysis solutions, automatic speech emotion recognition,\nand paralinguistic speech analysis software packages as well as\nconsulting and development services on these topics.\n\nAn open-source version for private use, education, and research\nwill always be available, next to commercial versions with\nadditional features (such as more interface components) or commercial\nlicenses for the open-source version.\n\nDocumentation/Installing/Using:\n===============================\n\nopenSMILE is well documented in the openSMILE book, which can be \nfound in doc/openSMILE_book.pdf.\n\nFor quick-start information on how to compile openSMILE, \nsee the file INSTALL.\n\nDevelopers:\n===========\n\nPreliminary developer's documentation can be found in \"doc/developer\" \nand in the openSMILE book.\n\nInformation on how to write and compile run-time linkable plug-ins \nfor openSMILE, see the openSMILE book or take a look at the files \nin the \"plugindev\" directory, especially the README file.\n\nGetting more help:\n==================\n\nIf you encounter problems with openSMILE, and solve them yourself, \nplease tell us via e-mail (info@audeering.com), \nso we can update the documentation or fix the code!\n\nIf you cannot solve the problems yourself, please do also contact\ncontact us, so we can solve the problem together and make openSMILE\nbetter.\n\n\n\n\n\n"
  },
  {
    "path": "RELEASE_NOTES",
    "content": "\nopenSMILE 2.3 (beta)\n\nMajor new features:\n\n* Android JNI integration.  \nWhile version 2.2. did provide first support for compilation as static binary for Android,\nwe now offer integration into Apps via the JNI. An example project and a tutorial for \nAndroid Studio are provided which shows how to build a live audio analysis app that\nshows audio parameters in real-time in the App UI.\n\n* Configuration file interface updated\nCommandline options for audio input and data output formats have been standardised\nthrough modular config files. This allows all major standard\n\n* Batch feature extraction GUI for Windows and batch extraction scripts for Linux *\nThese make it easier for beginners to extract audio features from a collection of audio files.\n\n* Improved backwards compatibility *\nAll standard feature sets are verified to be backwards compatible to Version 2.2 and 2.1.\nThe original feature sets of openEAR are also backwards compatible with \nthe original openEAR models.\n\n* Updated Version of ComParE 2013-2015 baseline acoustic parameter set *\nSeveral optimisations to the feature extraction code were applied and\nan updated version of ComParE was released. It has the same features as \nthe previous version, but is now numerically optimised. It is referred to\nas ComParE_2016, as it is released in 2016. \nIt is not the Interspeech ComParE 2016 baseline feature set (this is still the 2013 one)!!\n\n* Lots of various fixes and improvements *\nWe've added many minor points, fixed bugs, and improved performance.\nE.g. we have improved the support for modulation spectra as functionals and optimized \nJitter computation through a better pitch period detection algorithm.\n\n"
  },
  {
    "path": "autogen.sh",
    "content": "#!/bin/bash\n\n# Copyright (C) 2008 Florian Eyben\n#  \n# This file is free software; as a special exception the author gives\n# unlimited permission to copy and/or distribute it, with or without \n# modifications, as long as this notice is preserved.\n# \n# This program is distributed in the hope that it will be useful, but\n# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the\n# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\nrm -f config.cache\necho \"- aclocal.\"\naclocal -I m4\necho \"- autoconf.\"\nautoconf\necho \"- autoheader.\"\nautoheader\necho \"- automake.\"\nautomake -a\n\n# on Mac libtoolize is called glibtoolize\nLIBTOOLIZE=libtoolize\nif [ `uname -s` = Darwin ]; then\n    LIBTOOLIZE=glibtoolize\nfi\necho \"- $LIBTOOLIZE\"\n$LIBTOOLIZE\n\nexit\n"
  },
  {
    "path": "buildAndroid.sh",
    "content": "#!/bin/sh\n\n# This file is part of openSMILE.\n#\n# Copyright (c) audEERING. All rights reserved.\n# See the file COPYING for details on license terms.\n\nSTATIC_BIN=\"no\";\nPwdd=`pwd`;\n\nif [ \"$STATIC_BIN\" = \"yes\" ]; then\n  STATIC_DEFINE=\"-D__STATIC_LINK\";\n  DYN_LIBS=\"\";\n  ENABLE_SHARED=\"no\";\nelse\n  DYN_LIBS=\"-llog -lOpenSLES\";\n  ENABLE_SHARED=\"yes\";\n  STATIC_DEFINE=\"\";\nfi\n\n##cross compiler variables\n./autogen.sh ;\n./autogen.sh ;\n\n## cross compiler variables\nplatform=android-21\n\n############## NOTE: Update the path to your Android NDK.\n##############       Version 10e is required!\nexport NDK=`realpath ~/android/ndk-r10e`;\n#########################################################\n\nexport CROSS_COMPILE=arm-linux-androideabi\nSTL_VERSION=4.8\n\nexport NDK_TOOLCHAIN=${NDK}/toolchains/${CROSS_COMPILE}-4.9/prebuilt/linux-x86_64/bin\nexport CC=${NDK_TOOLCHAIN}/${CROSS_COMPILE}-gcc\nexport CXX=${NDK_TOOLCHAIN}/${CROSS_COMPILE}-g++\nexport LD=${NDK_TOOLCHAIN}/${CROSS_COMPILE}-ld\nexport AR=${NDK_TOOLCHAIN}/${CROSS_COMPILE}-ar\nexport RANLIB=${NDK_TOOLCHAIN}/${CROSS_COMPILE}-ranlib\nexport STRIP=${NDK_TOOLCHAIN}/${CROSS_COMPILE}-strip\nexport ac_cv_func_malloc_0_nonnull=yes\nexport ac_cv_func_realloc_0_nonnull=yes\n\n##flags\nexport OPTIMISE=\"-fPIE -pie -ffast-math -ftree-vectorize -march=armv7-a -mthumb -mfloat-abi=softfp -mfpu=vfp -mfpu=neon -funsafe-math-optimizations\";\nexport LDFLAGS=\"-fPIE -pie -fexceptions -Wl,-rpath-link=${NDK}/platforms/${platform}/arch-arm/usr/lib -L${NDK}/platforms/${platform}/arch-arm/usr/lib -L${NDK}/sources/cxx-stl/gnu-libstdc++/${STL_VERSION}/libs/armeabi\"\nexport LDFLAGS_CORE=\"-fPIE -pie -fexceptions -L${NDK}/platforms/${platform}/arch-arm/usr/lib -L${NDK}/sources/cxx-stl/gnu-libstdc++/${STL_VERSION}/libs/armeabi\"\nexport SYSROOT=${NDK}/platforms/${platform}/arch-arm\nexport CXXFLAGS=\"-I${NDK}/platforms/${platform}/arch-arm/usr/include -I${NDK}/sources/cxx-stl/gnu-libstdc++/${STL_VERSION}/include -I${NDK}/sources/cxx-stl/gnu-libstdc++/${STL_VERSION}/libs/armeabi/include --sysroot=${SYSROOT} -g -O3 $OPTIMISE\"\nDEFINES=\"-DOPENSMILE_BUILD -DBUILD_LIBSVM -DBUILD_SVMSMO -DBUILD_RNN -DBUILD_WITHOUT_EXPERIMENTAL\"\n\nexport CPPFLAGS=\"--sysroot=${SYSROOT} -D__ANDROID__ ${DEFINES} -DHAVE_OPENSLES $STATIC_DEFINE\"\nexport CFLAGS=\"--sysroot=${SYSROOT} -nostdlib -g -O3 ${OPTIMISE}\"\n###add compiler options \n#export LIBS=\"-lc -lm -lgcc -lgnustl_shared -lsupc++ -llog -lOpenSLES\"\nexport LIBS=\"-lc -lm -lgcc -lgnustl_static -lsupc++ $DYN_LIBS\"\n\n##configure opensmile\nmkdir -p \"$Pwdd/inst/android\"\n./configure --enable-static --enable-shared=no --host=arm-linux-androideabi --target=arm-linux-androideabi LIBS=\"$LIBS\" --prefix=\"$Pwdd/inst/android\";\n\nif [ $? != 0 ]; then\n\techo \"failed to configure openSMILE!\";\n\texit -1;\nfi\n\nmake clean &&\nmake -j8 \nmake install\nif [ $? != 0 ]; then\n\techo \"failed to build openSMILE!\";\n\texit -1;\nfi\n\n# fully static binary:\nif [ \"$STATIC_BIN\" = \"yes\" ]; then\n  rm SMILExtract\n  $CXX $CXXFLAGS -o $Pwdd/inst/android/SMILExtract-static progsrc/smilextract/SMILExtract-SMILExtract.o .libs/libopensmile.a -static $LDFLAGS $LIBS\nfi\n####\n\nchmod 777 SMILExtract\nchmod 777 inst/android/bin/SMILExtract\n\necho \"\"\nif [ \"$STATIC_BIN\" = \"yes\" ]; then\n  echo \"build successfull. You can now use the inst/android/bin/SMILExtract-static binary for Android. For linking with Android project, use builds in inst/android/lib folder.\"\nelse\n  echo \"build successfull. You can now use the inst/android/bin/SMILExtract binary for Android. For linking with Android project, use builds in inst/android/lib folder.\"\nfi\necho \"\"\n\n"
  },
  {
    "path": "buildStandalone.sh",
    "content": "#!/bin/bash\n\n# This file is part of openSMILE.\n#\n# Copyright (c) audEERING. All rights reserved.\n# See the file COPYING for details on license terms.\n\n\nOPENCV_INST=\"\"\nINSTPREFIX=\"\"\nSTATIC_BIN=\"no\"\n\nwhile getopts \"o:p:h\" options; do\n\tcase $options in\n\to ) OPENCV_INST=\"$OPTARG\";;\n\tp ) INSTPREFIX=\"$OPTARG\";;\n\th ) echo \"Usage: $0 [-o <path_to_opencv>] [-p <inst_prefix>]\"; exit;;\n\tesac\ndone\n\nPwd=`pwd`;\nif [ \"$INSTPREFIX\" = \"\" ]; then\n  INSTPREFIX=\"$Pwd/inst\"\nfi\n\nif [ \"$OPENCV_INST\" != \"\" ]; then\n  OPENCV_OPT=\"--with-opencv=$OPENCV_INST\"\n  STATIC_BIN=\"no\"\nelse\n  OPENCV_OPT=\"--enable-static --enable-shared=no\"\n#  STATIC_BIN=\"yes\"\nfi\n\nrm SMILExtract 2> /dev/null\nchmod +x autogen.sh\n./autogen.sh ;\n./autogen.sh ;\nchmod +x configure\nmkdir inst 2> /dev/null\n##### DEBUG version:\n#export CXXFLAGS=\"-O0\"\n#export CFLAGS=\"-O0\"\n#export CPPFLAGS=\"-D_DEBUG -g -D__STATIC_LINK -DOPENSMILE_BUILD -DBUILD_SVMSMO -DBUILD_SVMSMO -DBUILD_LIBSVM -DBUILD_RNN -DBUILD_WITHOUT_EXPERIMENTAL\"\n#### non-debug flags:\nexport CXXFLAGS=\"-O2 -mfpmath=sse -msse2\"\nexport CFLAGS=\"-O2 -mfpmath=sse -msse2\"\nexport CPPFLAGS=\"-D__STATIC_LINK -DOPENSMILE_BUILD -DBUILD_SVMSMO -DBUILD_SVMSMO -DBUILD_LIBSVM -DBUILD_RNN -DBUILD_WITHOUT_EXPERIMENTAL\"\nexport LDFLAGS=\"-lrt -lm -lpthread -lc\"\n#####\n\necho ./configure --without-portaudio --prefix=$INSTPREFIX $OPENCV_OPT\n./configure --without-portaudio --prefix=$INSTPREFIX $OPENCV_OPT\nif [ $? != 0 ]; then\n  echo \"failed to configure openSMILE!\";\n  exit -1;\nfi\nchmod +x update_build_version.sh\n./update_build_version.sh\n\nmake clean &&\nmake -j8; make install \nif [ $? != 0 ]; then\n  echo \"failed to build or install openSMILE to '$INSTPREFIX'!\";\n  exit -1;\nfi\n\n# fully static binary:\nif [ \"$STATIC_BIN\" = \"yes\" ]; then\n  rm SMILExtract\n  g++ $CXXFLAGS -static -o SMILExtract progsrc/smilextract/SMILExtract-SMILExtract.o .libs/libopensmile.a $LDFLAGS \n  #-D__STDC_CONSTANT_MACROS \n  cp SMILExtract inst/bin/SMILExtract\nfi\n####\n\necho \"\"\necho \"build successfull. You can now use the inst/bin/SMILExtract binary.\"\necho \"\"\n\n"
  },
  {
    "path": "buildWithInstalledPortAudio.sh",
    "content": "#!/bin/sh\n\n# This file is part of openSMILE.\n#\n# Copyright (c) audEERING. All rights reserved.\n# See the file COPYING for details on license terms.\n\n#Usage buildPA.sh [install-prefix]\n# Default install prefix is $Pwd/inst\n\n# EXPERIMENTAL AND UNSUPPORTED!!!!   Update to latest build code in buildWithPortaudio.sh to make it work!\n\nPwd=`pwd`;\nif [ \"$1\" != \"\" ]; then\n  INSTPREFIX=$1;  \nelse\n  INSTPREFIX=\"$Pwd/inst\";\nfi\n\n\necho \"++++++++++++++ Compiling openSMILE....\"\n\n./autogen.sh ;\n./autogen.sh ;\nif [ $? != 0 ]; then\n  echo \"autogen.sh failed!\";\n  exit -1;\nfi\n\nmkdir inst\nexport CXXFLAGS=\"-O2 -mfpmath=sse -march=native\"\nexport CFLAGS=\"-O2 -mfpmath=sse -march=native\"\n#export CXXFLAGS=\"-O2 -mfpmath=sse -mtune=athlon64\"\n#export CFLAGS=\"-O2 -mfpmath=sse -mtune=athlon64\"\n#./configure --prefix=$Pwd/inst --enable-static --disable-shared &&\n./configure --prefix=$INSTPREFIX --with-portaudio=\"yes\" \nif [ $? != 0 ]; then\n  echo \"failed to configure openSMILE!\";\n  exit -1;\nfi\n\n\nmake clean &&\nmake -j8 ; make install \nif [ $? != 0 ]; then\n  echo \"failed to build or install openSMILE!\";\n  exit -1;\nfi\n\n\nmv $INSTPREFIX/bin/SMILExtract $INSTPREFIX/bin/SMILExtract.bin\necho \"#!/bin/sh\" > $INSTPREFIX/bin/SMILExtract\necho \"export LD_LIBRARY_PATH=\\\"`dirname \\$0`/../lib\\\" ; \\$0.bin \\$* \" >> $INSTPREFIX/bin/SMILExtract\nchmod +x $INSTPREFIX/bin/SMILExtract\n\n$INSTPREFIX/bin/SMILExtract -H cPortaudio 2> tmp\nTMP=`cat tmp | grep cPortaudio `;\nrm tmp\n\nif [ \"$TMP\" = \"\" ]; then\n  echo \"ERROR: PortAudio was not found on your system, please check if you have the development headers installed! If unsure, use the script buildWithPortAudio.sh! openSMILE was built, however without portaudio support!\";\nelse \n\necho \"\"\necho \"build successfull.\"\necho \"  You can now use the $Pwd/inst/bin/SMILExtract executable,\"\necho \"  and add $Pwd/inst/bin to your path.\"\necho \"\"\necho \"  Please note that $Pwd/inst/bin/SMILExtract is a wrapper script\"\necho \"  which sets up the library path and calls SMILExtract.bin\"\necho \"\"\n\n\nfi\n"
  },
  {
    "path": "buildWithJulius.sh",
    "content": "#!/bin/sh\n\n# This file is part of openSMILE.\n#\n# Copyright (c) audEERING. All rights reserved.\n# See the file COPYING for details on license terms.\n\n## set this to the path of your julius installation directory (which contains the lib/ and include sub-directories):\n\n## EXPERIMENTAL AND UNSUPPORTED!!!\n\nPwd=`pwd`;\nJuliusPath=\"$Pwd/thirdparty/inst\";\n\n\n\n\n./autogen.sh ;\n./autogen.sh ;\nmkdir inst\nexport CXXFLAGS=\"-O0 -mfpmath=sse -march=native\"\nexport CFLAGS=\"-O0 -mfpmath=sse -march=native\"\nexport CPPFLAGS=\"-I$JuliusPath/include -DHAVE_JULIUSLIB -DEXTERNAL_FV -D_DEBUG\"\nexport LDFLAGS=\"-L$JuliusPath/lib -ljulius -lsent\"\n\n./configure --prefix=$Pwd/inst --enable-static --disable-shared &&\nsh update_build_version.sh\nmake clean &&\nmake -j8 ; make install &&\n\necho \"\"\necho \"build successfull. You can now use the inst/bin/SMILExtract binary.\"\necho \"\"\n\n"
  },
  {
    "path": "buildWithPortAudio.sh",
    "content": "#!/bin/sh\n\n# This file is part of openSMILE.\n#\n# Copyright (c) audEERING. All rights reserved.\n# See the file COPYING for details on license terms.\n\n#Usage buildWithPortAudio.sh -p [install-prefix] -o [opencv path]\n# Default install prefix is $Pwd/inst\n\nOPENCV_INST=\"\"\nINSTPREFIX=\"\"\n\nwhile getopts \"o:p:\" options; do\n\tcase $options in\n\to ) OPENCV_INST=\"$OPTARG\";;\n\tp ) INSTPREFIX=\"$OPTARG\";;\n\t\\?) echo \"Usage: $0 [-o <path_to_opencv>] [-p <inst_prefix>]\";;\n\tesac\ndone\n\n\nPwd=`pwd`;\nif [ \"$INSTPREFIX\" = \"\" ]; then\n  INSTPREFIX=\"$Pwd/inst\"\nfi\n\nif [ \"$OPENCV_INST\" != \"\" ]; then\n\tOPENCV_OPT=\"--with-opencv=$OPENCV_INST\"\nfi\n\n\n\n\necho \"++++++++++++++ Compiling PortAudio....\"\n\ncd thirdparty ;\ntar -zxvf portaudio.tgz ;\ncd portaudio ;\n./configure --prefix=$INSTPREFIX  ;\nif [ $? != 0 ]; then\n  echo \"failed to configure PortAudio!\";\n  exit -1;\nfi\nmake ;\nif [ $? != 0 ]; then\n  echo \"failed to build PortAudio!\";\n  exit -1;\nfi\nmake install ;\nif [ $? != 0 ]; then\n  echo \"failed to install PortAudio to '$Pwd/inst'!\";\n  exit -1;\nfi\n\ncd $Pwd ;\n\necho \"++++++++++++++ Compiling openSMILE....\"\n\nrm SMILExtract 2> /dev/null\n./autogen.sh ;\n./autogen.sh ;\nif [ $? != 0 ]; then\n  echo \"autogen.sh failed!\";\n  exit -1;\nfi\n\nmkdir inst 2> /dev/null\nexport CXXFLAGS=\"-O2 -lrt -D__STDC_CONSTANT_MACROS\"\nexport CFLAGS=\"-O2\"\nexport CPPFLAGS=\"-DOPENSMILE_BUILD -DHAVE_PORTAUDIO -DBUILD_LIBSVM -DBUILD_SVMSMO -DBUILD_RNN -DBUILD_WITHOUT_EXPERIMENTAL\"\n\necho ./configure --prefix=$INSTPREFIX --with-portaudio=\"$INSTPREFIX\"  \"$OPENCV_OPT\"\n./configure --prefix=$INSTPREFIX --with-portaudio=\"$INSTPREFIX\" \"$OPENCV_OPT\"\n\nif [ $? != 0 ]; then\n  echo \"failed to configure openSMILE!\";\n  exit -1;\nfi\n\nsh update_build_version.sh\nmake clean &&\nmake -j8 ; make install \nif [ $? != 0 ]; then\n  echo \"failed to build or install openSMILE!\";\n  exit -1;\nfi\n\n\nmv $INSTPREFIX/bin/SMILExtract $INSTPREFIX/bin/SMILExtract.bin\necho \"#!/bin/sh\" > $INSTPREFIX/bin/SMILExtract\necho \"export LD_LIBRARY_PATH=\\\"\\`dirname \\$0\\`/../lib\\\" ; \\$0.bin \\$* \" >> $INSTPREFIX/bin/SMILExtract\nchmod +x $INSTPREFIX/bin/SMILExtract\n\n\necho \"\"\necho \"build successfull.\"\necho \"  You can now use the $Pwd/inst/bin/SMILExtract executable,\"\necho \"  and add $Pwd/inst/bin to your path.\"\necho \"\"\necho \"  Please note that $Pwd/inst/bin/SMILExtract is a wrapper script\"\necho \"  which sets up the library path and calls SMILExtract.bin\"\necho \"\"\n\n"
  },
  {
    "path": "config/ComParE_2016.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\r\n///////// > openSMILE configuration file for ComParE <               //////////////////\r\n/////////   updated version of ComParE 2013 set, numerical fixes     //////////////////\r\n/////////                                                            //////////////////\r\n///////// (c) 2014-2016 by audEERING,                                //////////////////\r\n/////////     All rights reserverd. See file COPYING for details.    //////////////////\r\n///////////////////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n\r\n;;;;;;; component list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[dataMemory].type=cDataMemory\r\nprintLevelStats=0\r\n\r\n\r\n;;;;;;;;;;;;;;;;;;;;;;;;;;;; main section ;;;;;;;;;;;;;;;;;;;;;;;;;;;\r\n\r\n\\{shared/standard_wave_input.conf.inc}\r\n\\{ComParE_2016_core.lld.conf.inc}\r\n\\{ComParE_2016_core.func.conf.inc}\r\n\r\n;;;;;;;;; prepare features for standard output module\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_lldconcat].type=cVectorConcat\r\ninstance[is13_llddeconcat].type=cVectorConcat\r\ninstance[is13_funcconcat].type=cVectorConcat\r\n\r\n[is13_lldconcat:cVectorConcat]\r\nreader.dmLevel = is13_lld_nzsmo;is13_lldA_smo;is13_lldB_smo\r\nwriter.dmLevel = lld\r\nincludeSingleElementFields = 1\r\n\r\n[is13_llddeconcat:cVectorConcat]\r\nreader.dmLevel = is13_lld_nzsmo_de;is13_lldA_smo_de;is13_lldB_smo_de\r\nwriter.dmLevel = lld_de\r\nincludeSingleElementFields = 1\r\n\r\n[is13_funcconcat:cVectorConcat]\r\nreader.dmLevel = is13_functionalsA;is13_functionalsB;is13_functionalsNz;is13_functionalsF0;is13_functionalsLLD;is13_functionalsDelta\r\nwriter.dmLevel = func\r\nincludeSingleElementFields = 1\r\n\r\n\\{shared/standard_data_output.conf.inc}\r\n\r\n"
  },
  {
    "path": "config/ComParE_2016_core.func.conf.inc",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\r\n///////// > openSMILE configuration file for ComParE <               //////////////////\r\n/////////                                                            //////////////////\r\n///////// (c) 2014 by audEERING                                      //////////////////\r\n/////////     All rights reserved. See file COPYING for details.     //////////////////\r\n///////////////////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n;;;;;;;;; functionals / statistics\r\n\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_functionalsA].type=cFunctionals\r\ninstance[is13_functionalsB].type=cFunctionals\r\ninstance[is13_functionalsF0].type=cFunctionals\r\ninstance[is13_functionalsNz].type=cFunctionals\r\n; shared functionals for LLD\r\ninstance[is13_functionalsLLD].type=cFunctionals\r\n; shared functionals for Delta LLD\r\ninstance[is13_functionalsDelta].type=cFunctionals\r\n\r\n\r\n; functionals for energy related lld\r\n[is13_functionalsA:cFunctionals]\r\nreader.dmLevel = is13_lldA_smo;is13_lldA_smo_de\r\nwriter.dmLevel = is13_functionalsA\r\n// nameAppend = \r\ncopyInputName = 1\r\n\\{\\cm[bufferModeRbConf]}\r\n\\{\\cm[frameModeFunctionalsConf{shared/FrameModeFunctionals.conf.inc}:path to included config to set frame mode for all functionals]}\r\nfunctionalsEnabled = Extremes ; Percentiles ; Moments ; Segments ; Times ;  Lpc\r\nExtremes.max = 0\r\nExtremes.min = 0\r\nExtremes.maxpos = 1\r\nExtremes.minpos = 1\r\nExtremes.maxameandist = 0\r\nExtremes.minameandist = 0\r\nSegments.maxNumSeg = 100\r\nSegments.segmentationAlgorithm = relTh\r\nSegments.thresholds = 0.25 ; 0.75\r\nSegments.ravgLng = 3\r\nSegments.numSegments = 0\r\nSegments.meanSegLen = 1\r\nSegments.maxSegLen = 1\r\nSegments.minSegLen = 1\r\nSegments.segLenStddev = 1\r\nSegments.norm = second\r\nMoments.variance = 0\r\nMoments.stddev = 1\r\nMoments.skewness = 1\r\nMoments.kurtosis = 1\r\nMoments.amean = 0\r\nMoments.doRatioLimit = 1\r\nPercentiles.quartiles = 1\r\nPercentiles.iqr = 1\r\nPercentiles.percentile[0] = 0.01\r\nPercentiles.percentile[1] = 0.99\r\nPercentiles.pctlrange[0] = 0-1\r\nPercentiles.interp = 1\r\nTimes.upleveltime25 = 1\r\nTimes.downleveltime25 = 0\r\nTimes.upleveltime50 = 1\r\nTimes.downleveltime50 = 0\r\nTimes.upleveltime75 = 1\r\nTimes.downleveltime75 = 0\r\nTimes.upleveltime90 = 1\r\nTimes.downleveltime90 = 0\r\nTimes.risetime = 1\r\nTimes.falltime = 0\r\nTimes.leftctime = 1\r\nTimes.rightctime = 0\r\nTimes.duration = 0\r\nTimes.buggySecNorm = 0\r\nTimes.norm = segment\r\nLpc.lpGain = 1\r\nLpc.lpc = 1\r\nLpc.firstCoeff = 0\r\nLpc.order = 5\r\nnonZeroFuncts = 0\r\nmasterTimeNorm = segment\r\n\r\n; functionals for spectrum related lld\r\n[is13_functionalsB:cFunctionals]\r\nreader.dmLevel = is13_lldB_smo;is13_lldB_smo_de\r\nwriter.dmLevel = is13_functionalsB\r\n// nameAppend = \r\ncopyInputName = 1\r\n\\{\\cm[bufferModeRbConf]}\r\n\\{\\cm[frameModeFunctionalsConf]}\r\nfunctionalsEnabled = Extremes ; Percentiles ; Moments ; Segments ; Times ;  Lpc\r\nExtremes.max = 0\r\nExtremes.min = 0\r\nExtremes.maxpos = 1\r\nExtremes.minpos = 1\r\nExtremes.maxameandist = 0\r\nExtremes.minameandist = 0\r\nSegments.maxNumSeg = 100\r\nSegments.segmentationAlgorithm = relTh\r\nSegments.thresholds = 0.25 ; 0.75\r\nSegments.rangeRelThreshold = 0.200000\r\nSegments.numSegments = 0\r\nSegments.meanSegLen = 1\r\nSegments.maxSegLen = 1\r\nSegments.minSegLen = 1\r\nSegments.segLenStddev = 1\r\nSegments.norm = second\r\nMoments.variance = 0\r\nMoments.stddev = 1\r\nMoments.skewness = 1\r\nMoments.kurtosis = 1\r\nMoments.amean = 0\r\nMoments.doRatioLimit = 1\r\nPercentiles.quartiles = 1\r\nPercentiles.iqr = 1\r\nPercentiles.percentile[0] = 0.01\r\nPercentiles.percentile[1] = 0.99\r\nPercentiles.pctlrange[0] = 0-1\r\nPercentiles.interp = 1\r\nTimes.upleveltime25 = 1\r\nTimes.downleveltime25 = 0\r\nTimes.upleveltime50 = 1\r\nTimes.downleveltime50 = 0\r\nTimes.upleveltime75 = 1\r\nTimes.downleveltime75 = 0\r\nTimes.upleveltime90 = 1\r\nTimes.downleveltime90 = 0\r\nTimes.risetime = 1\r\nTimes.falltime = 0\r\nTimes.leftctime = 1\r\nTimes.rightctime = 0\r\nTimes.duration = 0\r\nTimes.buggySecNorm = 0\r\nTimes.norm = segment\r\nLpc.lpGain = 1\r\nLpc.lpc = 1\r\nLpc.firstCoeff = 0\r\nLpc.order = 5\r\nnonZeroFuncts = 0\r\nmasterTimeNorm = segment\r\n\r\n; functionals for pitch onsets/offsets\r\n[is13_functionalsF0:cFunctionals]\r\nreader.dmLevel = is13_lld_f0_nzsmo\r\nwriter.dmLevel = is13_functionalsF0\r\n//nameAppend = ff0\r\ncopyInputName = 1\r\n\\{\\cm[bufferModeRbConf]}\r\n\\{\\cm[frameModeFunctionalsConf]}\r\nfunctionalsEnabled = Means ; Segments \r\nMeans.amean = 0\r\nMeans.absmean = 0\r\nMeans.qmean = 0\r\nMeans.nzamean = 0\r\nMeans.nzabsmean = 0\r\nMeans.nzqmean = 0\r\nMeans.nzgmean = 0\r\nMeans.nnz = 1\r\nMeans.norm = segment\r\nSegments.maxNumSeg = 100\r\nSegments.segmentationAlgorithm = nonX\r\nSegments.X = 0.0\r\nSegments.numSegments = 0\r\nSegments.meanSegLen = 1\r\nSegments.maxSegLen = 1\r\nSegments.minSegLen = 1\r\nSegments.segLenStddev = 1\r\nSegments.norm = second\r\nnonZeroFuncts = 0\r\nmasterTimeNorm = segment\r\n\r\n; functionals for pitch and vq related lld in voiced regions\r\n[is13_functionalsNz:cFunctionals]\r\nreader.dmLevel = is13_lld_nzsmo;is13_lld_nzsmo_de\r\nwriter.dmLevel = is13_functionalsNz\r\n// nameAppend = \r\ncopyInputName = 1\r\n\\{\\cm[bufferModeRbConf]}\r\n\\{\\cm[frameModeFunctionalsConf]}\r\nfunctionalsEnabled = Means ; Extremes ; Regression ; Percentiles ; Moments ; Times ; Lpc\r\nMeans.amean = 1\r\nMeans.posamean = 1\r\nMeans.absmean = 0\r\nMeans.qmean = 0\r\nMeans.rqmean = 1\r\nMeans.nzamean = 0\r\nMeans.nzabsmean = 0\r\nMeans.nzqmean = 0\r\nMeans.posrqmean = 0\r\nMeans.nzgmean = 0\r\nMeans.nnz = 0\r\nMeans.flatness = 1\r\nMeans.norm = frames\r\nExtremes.max = 0\r\nExtremes.min = 0\r\nExtremes.maxpos = 1\r\nExtremes.minpos = 1\r\nExtremes.maxameandist = 0\r\nExtremes.minameandist = 0\r\nMoments.variance = 0\r\nMoments.stddev = 1\r\nMoments.skewness = 1\r\nMoments.kurtosis = 1\r\nMoments.amean = 0\r\nMoments.doRatioLimit = 1\r\nRegression.linregc1 = 1\r\nRegression.linregc2 = 1\r\nRegression.linregerrA = 0\r\nRegression.linregerrQ = 1\r\nRegression.qregc1 = 1\r\nRegression.qregc2 = 1\r\nRegression.qregc3 = 1\r\nRegression.qregerrA = 0\r\nRegression.qregerrQ = 1\r\nRegression.oldBuggyQerr = 0\r\nRegression.centroid = 1\r\nRegression.centroidUseAbsValues = 1\r\nRegression.centroidRatioLimit = 1\r\nRegression.normRegCoeff = 0\r\nRegression.normInputs = 1\r\nRegression.doRatioLimit = 1\r\nPercentiles.quartiles = 1\r\nPercentiles.iqr = 1\r\nPercentiles.percentile[0] = 0.01\r\nPercentiles.percentile[1] = 0.99\r\nPercentiles.pctlrange[0] = 0-1\r\nPercentiles.interp = 1\r\nTimes.upleveltime25 = 1\r\nTimes.downleveltime25 = 0\r\nTimes.upleveltime50 = 1\r\nTimes.downleveltime50 = 0\r\nTimes.upleveltime75 = 1\r\nTimes.downleveltime75 = 0\r\nTimes.upleveltime90 = 1\r\nTimes.downleveltime90 = 0\r\nTimes.risetime = 1\r\nTimes.falltime = 0\r\nTimes.leftctime = 1\r\nTimes.rightctime = 0\r\nTimes.duration = 0\r\nTimes.buggySecNorm = 0\r\nTimes.norm = segment\r\nLpc.lpGain = 1\r\nLpc.lpc = 1\r\nLpc.firstCoeff = 0\r\nLpc.order = 5\r\nnonZeroFuncts = 1\r\nmasterTimeNorm = segment\r\n\r\n\r\n[is13_functionalsLLD:cFunctionals]\r\nreader.dmLevel = is13_lldA_smo;is13_lldB_smo\r\nwriter.dmLevel = is13_functionalsLLD\r\ncopyInputName = 1\r\n\\{\\cm[bufferModeRbConf]}\r\n\\{\\cm[frameModeFunctionalsConf]}\r\nfunctionalsEnabled = Means ; Peaks2 ; Regression\r\nMeans.amean = 1\r\nMeans.posamean = 0\r\nMeans.absmean = 0\r\nMeans.qmean = 0\r\nMeans.rqmean = 1\r\nMeans.nzamean = 0\r\nMeans.nzabsmean = 0\r\nMeans.nzqmean = 0\r\nMeans.posrqmean = 0\r\nMeans.nzgmean = 0\r\nMeans.nnz = 0\r\nMeans.flatness = 1\r\nMeans.norm = frames\r\nRegression.linregc1 = 1\r\nRegression.linregc2 = 1\r\nRegression.linregerrA = 0\r\nRegression.linregerrQ = 1\r\nRegression.qregc1 = 1\r\nRegression.qregc2 = 1\r\nRegression.qregc3 = 1\r\nRegression.qregerrA = 0\r\nRegression.qregerrQ = 1\r\nRegression.oldBuggyQerr = 0\r\nRegression.centroid = 1\r\nRegression.centroidUseAbsValues = 1\r\nRegression.centroidRatioLimit = 1\r\nRegression.normRegCoeff = 2\r\nRegression.normInputs = 1\r\nRegression.doRatioLimit = 1\r\nPeaks2.doRatioLimit = 1\r\nPeaks2.numPeaks = 0\r\nPeaks2.meanPeakDist = 1\r\nPeaks2.meanPeakDistDelta = 0\r\nPeaks2.peakDistStddev = 1\r\nPeaks2.peakRangeAbs = 1\r\nPeaks2.peakRangeRel = 1\r\nPeaks2.peakMeanAbs = 1\r\nPeaks2.peakMeanMeanDist = 1\r\nPeaks2.peakMeanRel = 1\r\nPeaks2.ptpAmpMeanAbs = 0\r\nPeaks2.ptpAmpMeanRel = 0\r\nPeaks2.ptpAmpStddevAbs = 0\r\nPeaks2.ptpAmpStddevRel = 0\r\nPeaks2.minRangeAbs = 0\r\nPeaks2.minRangeRel = 1\r\nPeaks2.minMeanAbs = 0\r\nPeaks2.minMeanMeanDist = 0\r\nPeaks2.minMeanRel = 0\r\nPeaks2.mtmAmpMeanAbs = 0\r\nPeaks2.mtmAmpMeanRel = 0\r\nPeaks2.mtmAmpStddevAbs = 0\r\nPeaks2.mtmAmpStddevRel = 0\r\nPeaks2.meanRisingSlope = 1\r\nPeaks2.maxRisingSlope = 0\r\nPeaks2.minRisingSlope = 0\r\nPeaks2.stddevRisingSlope = 1\r\nPeaks2.meanFallingSlope = 1\r\nPeaks2.maxFallingSlope = 0\r\nPeaks2.minFallingSlope = 0\r\nPeaks2.stddevFallingSlope = 1\r\nPeaks2.norm = seconds\r\nPeaks2.relThresh = 0.100000\r\nPeaks2.dynRelThresh = 0\r\n;Peaks2.posDbgOutp = minmax.txt\r\nPeaks2.posDbgAppend = 0\r\nPeaks2.consoleDbg = 0\r\n\r\n\r\n[is13_functionalsDelta:cFunctionals]\r\nreader.dmLevel = is13_lldA_smo_de;is13_lldB_smo_de\r\nwriter.dmLevel = is13_functionalsDelta\r\ncopyInputName = 1\r\n\\{\\cm[bufferModeRbConf]}\r\n\\{\\cm[frameModeFunctionalsConf]}\r\nfunctionalsEnabled = Means ; Peaks2\r\nMeans.amean = 0\r\nMeans.posamean = 1\r\nMeans.absmean = 0\r\nMeans.qmean = 0\r\nMeans.rqmean = 1\r\nMeans.nzamean = 0\r\nMeans.nzabsmean = 0\r\nMeans.nzqmean = 0\r\nMeans.posrqmean = 0\r\nMeans.nzgmean = 0\r\nMeans.nnz = 0\r\nMeans.flatness = 1\r\nMeans.norm = frames\r\nPeaks2.doRatioLimit = 1\r\nPeaks2.numPeaks = 0\r\nPeaks2.meanPeakDist = 1\r\nPeaks2.meanPeakDistDelta = 0\r\nPeaks2.peakDistStddev = 1\r\nPeaks2.peakRangeAbs = 1\r\nPeaks2.peakRangeRel = 1\r\nPeaks2.peakMeanAbs = 1\r\nPeaks2.peakMeanMeanDist = 1\r\nPeaks2.peakMeanRel = 1\r\nPeaks2.ptpAmpMeanAbs = 0\r\nPeaks2.ptpAmpMeanRel = 0\r\nPeaks2.ptpAmpStddevAbs = 0\r\nPeaks2.ptpAmpStddevRel = 0\r\nPeaks2.minRangeAbs = 0\r\nPeaks2.minRangeRel = 1\r\nPeaks2.minMeanAbs = 0\r\nPeaks2.minMeanMeanDist = 0\r\nPeaks2.minMeanRel = 0\r\nPeaks2.mtmAmpMeanAbs = 0\r\nPeaks2.mtmAmpMeanRel = 0\r\nPeaks2.mtmAmpStddevAbs = 0\r\nPeaks2.mtmAmpStddevRel = 0\r\nPeaks2.meanRisingSlope = 1\r\nPeaks2.maxRisingSlope = 0\r\nPeaks2.minRisingSlope = 0\r\nPeaks2.stddevRisingSlope = 1\r\nPeaks2.meanFallingSlope = 1\r\nPeaks2.maxFallingSlope = 0\r\nPeaks2.minFallingSlope = 0\r\nPeaks2.stddevFallingSlope = 1\r\nPeaks2.norm = seconds\r\nPeaks2.relThresh = 0.100000\r\nPeaks2.dynRelThresh = 0\r\n;Peaks2.posDbgOutp = minmax.txt\r\nPeaks2.posDbgAppend = 0\r\nPeaks2.consoleDbg = 0\r\n\r\n\r\n\r\n"
  },
  {
    "path": "config/ComParE_2016_core.lld.conf.inc",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\r\n///////// > openSMILE configuration file for ComParE <               //////////////////\r\n/////////                                                            //////////////////\r\n///////// (c) audEERING GmbH,                                        //////////////////\r\n/////////     All rights reserverd.                                  //////////////////\r\n///////////////////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_frame60].type=cFramer\r\ninstance[is13_win60].type=cWindower\r\ninstance[is13_fft60].type=cTransformFFT\r\ninstance[is13_fftmp60].type=cFFTmagphase\r\n\r\n[is13_frame60:cFramer]\r\nreader.dmLevel=wave\r\nwriter.dmLevel=is13_frame60\r\n\\{\\cm[bufferModeRbConf{shared/BufferModeRb.conf.inc}:path to included config to set the buffer mode for the standard ringbuffer levels]}\r\nframeSize = 0.060\r\nframeStep = 0.010\r\nframeCenterSpecial = left\r\n\r\n[is13_win60:cWindower]\r\nreader.dmLevel=is13_frame60\r\nwriter.dmLevel=is13_winG60\r\nwinFunc=gauss\r\ngain=1.0\r\nsigma=0.4\r\n\r\n[is13_fft60:cTransformFFT]\r\nreader.dmLevel=is13_winG60\r\nwriter.dmLevel=is13_fftcG60\r\nzeroPadSymmetric = 1\r\n\r\n[is13_fftmp60:cFFTmagphase]\r\nreader.dmLevel=is13_fftcG60\r\nwriter.dmLevel=is13_fftmagG60\r\n\r\n\r\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_frame25].type=cFramer\r\ninstance[is13_win25].type=cWindower\r\ninstance[is13_fft25].type=cTransformFFT\r\ninstance[is13_fftmp25].type=cFFTmagphase\r\n\r\n[is13_frame25:cFramer]\r\nreader.dmLevel=wave\r\nwriter.dmLevel=is13_frame25\r\n\\{\\cm[bufferModeRbConf]}\r\nframeSize = 0.020\r\nframeStep = 0.010\r\nframeCenterSpecial = left\r\n\r\n[is13_win25:cWindower]\r\nreader.dmLevel=is13_frame25\r\nwriter.dmLevel=is13_winH25\r\nwinFunc=hamming\r\n\r\n[is13_fft25:cTransformFFT]\r\nreader.dmLevel=is13_winH25\r\nwriter.dmLevel=is13_fftcH25\r\nzeroPadSymmetric = 1\r\n\r\n[is13_fftmp25:cFFTmagphase]\r\nreader.dmLevel=is13_fftcH25\r\nwriter.dmLevel=is13_fftmagH25\r\n\r\n\r\n\r\n;;;;;;;;;;;;;;;;;;;; HPS pitch\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_scale].type=cSpecScale\r\ninstance[is13_shs].type=cPitchShs\r\n\r\n[is13_scale:cSpecScale]\r\nreader.dmLevel=is13_fftmagG60\r\nwriter.dmLevel=is13_hpsG60\r\ncopyInputName = 1\r\nprocessArrayFields = 0\r\nscale=octave\r\nsourceScale = lin\r\ninterpMethod = spline\r\nminF = 25\r\nmaxF = -1\r\nnPointsTarget = 0\r\nspecSmooth = 1\r\nspecEnhance = 1\r\nauditoryWeighting = 1 \r\n\r\n[is13_shs:cPitchShs]\r\nreader.dmLevel=is13_hpsG60\r\nwriter.dmLevel=is13_pitchShsG60\r\n\\{\\cm[bufferModeRbLagConf{shared/BufferModeRbLag.conf.inc}:path to included config to set the buffer mode for levels which will be joint with Viterbi smoothed -lagged- F0]}\r\ncopyInputName = 1\r\nprocessArrayFields = 0\r\nmaxPitch = 620\r\nminPitch = 52\r\nnCandidates = 6\r\nscores = 1\r\nvoicing = 1\r\nF0C1 = 0\r\nvoicingC1 = 0\r\nF0raw = 1\r\nvoicingClip = 1\r\nvoicingCutoff = 0.700000\r\ninputFieldSearch = Mag_octScale\r\noctaveCorrection = 0\r\nnHarmonics = 15\r\ncompressionFactor = 0.850000\r\ngreedyPeakAlgo = 1\r\n\r\n;;;;; Pitch with Viterbi smoother\r\n[componentInstances:cComponentManager]\r\ninstance[is13_energy60].type=cEnergy\r\n\r\n[is13_energy60:cEnergy]\r\nreader.dmLevel=is13_winG60\r\nwriter.dmLevel=is13_e60\r\n ; This must be > than buffersize of viterbi smoother\r\n\\{\\cm[bufferModeRbLagConf]}\r\nrms=1\r\nlog=0\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_pitchSmoothViterbi].type=cPitchSmootherViterbi\r\n\r\n[is13_pitchSmoothViterbi:cPitchSmootherViterbi]\r\nreader.dmLevel=is13_pitchShsG60\r\nreader2.dmLevel=is13_pitchShsG60\r\nwriter.dmLevel=is13_pitchG60_viterbi\r\n\\{\\cm[bufferModeRbLagConf]}\r\ncopyInputName = 1\r\nbufferLength=30\r\nF0final = 1\r\nF0finalEnv = 0\r\nvoicingFinalClipped = 0\r\nvoicingFinalUnclipped = 1\r\nF0raw = 0\r\nvoicingC1 = 0\r\nvoicingClip = 0\r\nwTvv =10.0\r\nwTvvd= 5.0\r\nwTvuv=10.0\r\nwThr = 4.0\r\nwTuu = 0.0\r\nwLocal=2.0\r\nwRange=1.0\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_volmerge].type = cValbasedSelector\r\n\r\n[is13_volmerge:cValbasedSelector]\r\nreader.dmLevel = is13_e60;is13_pitchG60_viterbi\r\nwriter.dmLevel = is13_pitchG60\r\n\\{\\cm[bufferModeRbLagConf]}\r\nidx=0\r\nthreshold=0.001\r\nremoveIdx=1\r\nzeroVec=1\r\noutputVal=0.0\r\n\r\n;;;;;;;;;;;;;;;;;;; Voice Quality (VQ)\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_pitchJitter].type=cPitchJitter\r\n\r\n[is13_pitchJitter:cPitchJitter]\r\nreader.dmLevel = wave\r\nwriter.dmLevel = is13_jitterShimmer\r\n\\{\\cm[bufferModeRbLagConf]}\r\ncopyInputName = 1\r\nF0reader.dmLevel = is13_pitchG60\r\nF0field = F0final\r\nsearchRangeRel = 0.250000\r\njitterLocal = 1\r\njitterDDP = 1\r\njitterLocalEnv = 0\r\njitterDDPEnv = 0\r\nshimmerLocal = 1\r\nshimmerLocalEnv = 0\r\nonlyVoiced = 0\r\nlogHNR = 1\r\ninputMaxDelaySec = 2.0\r\n;periodLengths = 0\r\n;periodStarts = 0\r\nuseBrokenJitterThresh = 0\r\n\r\n;;;;;;;;;;;;;;;;;;;;; Energy / loudness\r\n\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_energy].type=cEnergy\r\ninstance[is13_melspec1].type=cMelspec\r\ninstance[is13_audspec].type=cPlp\r\ninstance[is13_audspecRasta].type=cPlp\r\ninstance[is13_audspecSum].type=cVectorOperation\r\ninstance[is13_audspecRastaSum].type=cVectorOperation\r\n\r\n[is13_energy:cEnergy]\r\nreader.dmLevel = is13_frame25\r\nwriter.dmLevel = is13_energy\r\nlog=0\r\nrms=1\r\n\r\n[is13_melspec1:cMelspec]\r\nreader.dmLevel=is13_fftmagH25\r\nwriter.dmLevel=is13_melspec1\r\n; htk compatible sample value scaling\r\nhtkcompatible = 0\r\nnBands = 26\r\n; use power spectrum instead of magnitude spectrum\r\nusePower = 1\r\nlofreq = 20\r\nhifreq = 8000\r\nspecScale = mel\r\nshowFbank = 0\r\n\r\n; perform auditory weighting of spectrum\r\n[is13_audspec:cPlp]\r\nreader.dmLevel=is13_melspec1\r\nwriter.dmLevel=is13_audspec\r\nfirstCC = 0\r\nlpOrder = 5\r\ncepLifter = 22\r\ncompression = 0.33\r\nhtkcompatible = 0 \r\ndoIDFT = 0\r\ndoLpToCeps = 0\r\ndoLP = 0\r\ndoInvLog = 0\r\ndoAud = 1\r\ndoLog = 0\r\nnewRASTA=0\r\nRASTA=0\r\n\r\n; perform RASTA style filtering of auditory spectra\r\n[is13_audspecRasta:cPlp]\r\nreader.dmLevel=is13_melspec1\r\nwriter.dmLevel=is13_audspecRasta\r\nnameAppend = Rfilt\r\nfirstCC = 0\r\nlpOrder = 5\r\ncepLifter = 22\r\ncompression = 0.33\r\nhtkcompatible = 0 \r\ndoIDFT = 0\r\ndoLpToCeps = 0\r\ndoLP = 0\r\ndoInvLog = 0\r\ndoAud = 1\r\ndoLog = 0\r\nnewRASTA=1\r\nRASTA=0\r\n\r\n[is13_audspecSum:cVectorOperation]\r\nreader.dmLevel = is13_audspec\r\nwriter.dmLevel = is13_audspecSum\r\n// nameAppend = \r\ncopyInputName = 1\r\nprocessArrayFields = 0\r\noperation = ll1\r\nnameBase = audspec\r\n\r\n[is13_audspecRastaSum:cVectorOperation]\r\nreader.dmLevel = is13_audspecRasta\r\nwriter.dmLevel = is13_audspecRastaSum\r\n// nameAppend = \r\ncopyInputName = 1\r\nprocessArrayFields = 0\r\noperation = ll1\r\nnameBase = audspecRasta\r\n\r\n;;;;;;;;;;;;;;; spectral\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_spectral].type=cSpectral\r\n\r\n\r\n[is13_spectral:cSpectral]\r\nreader.dmLevel=is13_fftmagH25\r\nwriter.dmLevel=is13_spectral\r\nbands[0]=250-650\r\nbands[1]=1000-4000\r\nrollOff[0] = 0.25\r\nrollOff[1] = 0.50\r\nrollOff[2] = 0.75\r\nrollOff[3] = 0.90\r\nflux=1\r\ncentroid=1\r\nmaxPos=0\r\nminPos=0\r\nentropy=1\r\nvariance=1\r\nskewness=1\r\nkurtosis=1\r\nslope=1\r\nharmonicity=1\r\nsharpness=1\r\n\r\n\r\n;;;;;;;;;;;;;;; mfcc\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_melspecMfcc].type=cMelspec\r\ninstance[is13_mfcc].type=cMfcc\r\n\r\n[is13_melspecMfcc:cMelspec]\r\nreader.dmLevel=is13_fftmagH25\r\nwriter.dmLevel=is13_melspecMfcc\r\ncopyInputName = 1\r\nprocessArrayFields = 1\r\n; htk compatible sample value scaling\r\nhtkcompatible = 1\r\nnBands = 26\r\n; use power spectrum instead of magnitude spectrum\r\nusePower = 1\r\nlofreq = 20\r\nhifreq = 8000\r\nspecScale = mel\r\ninverse = 0\r\n\r\n[is13_mfcc:cMfcc]\r\nreader.dmLevel=is13_melspecMfcc\r\nwriter.dmLevel=is13_mfcc1_12\r\ncopyInputName = 0\r\nprocessArrayFields = 1\r\nfirstMfcc = 1\r\nlastMfcc  = 14\r\ncepLifter = 22.0\r\nhtkcompatible = 1\r\n\r\n\r\n;;;;;;;;;;;;;;;;  zcr\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_mzcr].type=cMZcr\r\n\r\n[is13_mzcr:cMZcr]\r\nreader.dmLevel = is13_frame60\r\nwriter.dmLevel = is13_zcr\r\ncopyInputName = 1\r\nprocessArrayFields = 1\r\nzcr = 1\r\nmcr = 0\r\namax = 0\r\nmaxmin = 0\r\ndc = 0\r\n\r\n\r\n;;;;;;;;;;;;;;;;;;;; smoothing\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_smoNz].type=cContourSmoother\r\ninstance[is13_smoA].type=cContourSmoother\r\ninstance[is13_smoB].type=cContourSmoother\r\ninstance[is13_f0sel].type=cDataSelector\r\n\r\n[is13_smoNz:cContourSmoother]\r\nreader.dmLevel = is13_pitchG60;is13_jitterShimmer\r\nwriter.dmLevel = is13_lld_nzsmo\r\n\\{\\cm[bufferModeConf{shared/BufferMode.conf.inc}:path to included config to set the buffer mode for the levels before the functionals]}\r\nnameAppend = sma\r\ncopyInputName = 1\r\nnoPostEOIprocessing = 0\r\nsmaWin = 3\r\nnoZeroSma = 1\r\n\r\n[is13_f0sel:cDataSelector]\r\nreader.dmLevel = is13_lld_nzsmo\r\nwriter.dmLevel = is13_lld_f0_nzsmo\r\n\\{\\cm[bufferModeConf]}\r\nnameAppend = ff0\r\nselected = F0final_sma\r\n\r\n[is13_smoA:cContourSmoother]\r\nreader.dmLevel = is13_audspecSum;is13_audspecRastaSum;is13_energy;is13_zcr\r\nwriter.dmLevel = is13_lldA_smo\r\n\\{\\cm[bufferModeConf]}\r\nnameAppend = sma\r\ncopyInputName = 1\r\nnoPostEOIprocessing = 0\r\nsmaWin = 3\r\n\r\n[is13_smoB:cContourSmoother]\r\nreader.dmLevel = is13_audspecRasta;is13_spectral;is13_mfcc1_12\r\nwriter.dmLevel = is13_lldB_smo\r\n\\{\\cm[bufferModeConf]}\r\nnameAppend = sma\r\ncopyInputName = 1\r\nnoPostEOIprocessing = 0\r\nsmaWin = 3\r\n\r\n;;;;;;;;; deltas\r\n[componentInstances:cComponentManager]\r\ninstance[is13_deNz].type=cDeltaRegression\r\ninstance[is13_deA].type=cDeltaRegression\r\ninstance[is13_deB].type=cDeltaRegression\r\ninstance[is13_def0sel].type=cDeltaRegression\r\n\r\n[is13_deNz:cDeltaRegression]\r\nreader.dmLevel = is13_lld_nzsmo\r\nwriter.dmLevel = is13_lld_nzsmo_de\r\n\\{\\cm[bufferModeConf]}\r\nonlyInSegments = 1\r\nzeroSegBound = 1\r\n\r\n[is13_deA:cDeltaRegression]\r\nreader.dmLevel = is13_lldA_smo\r\nwriter.dmLevel = is13_lldA_smo_de\r\n\\{\\cm[bufferModeConf]}\r\n\r\n[is13_deB:cDeltaRegression]\r\nreader.dmLevel = is13_lldB_smo\r\nwriter.dmLevel = is13_lldB_smo_de\r\n\\{\\cm[bufferModeConf]}\r\n\r\n[is13_def0sel:cDeltaRegression]\r\nreader.dmLevel = is13_lld_f0_nzsmo\r\nwriter.dmLevel = is13_lld_f0_nzsmo_de\r\n\\{\\cm[bufferModeConf]}\r\nonlyInSegments = 1\r\nzeroSegBound = 1\r\n\r\n\r\n"
  },
  {
    "path": "config/IS09_emotion.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for IS09 emotion challenge< //////////////////\n/////////                                                            //////////////////\n///////// (c) 2014 by audEERING                                      //////////////////\n/////////     All rights reserved. See file COPYING for details.     //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n///////////////////////////////////////////////////////////////////////////////////////\n;\n; This section is always required in openSMILE configuration files\n;   it configures the componentManager and gives a list of all components which are to be loaded\n; The order in which the components are listed should match \n;   the order of the data flow for most efficient processing\n;\n///////////////////////////////////////////////////////////////////////////////////////\n[componentInstances:cComponentManager]\n ; this line configures the default data memory:\ninstance[dataMemory].type=cDataMemory\nprintLevelStats=0\nnThreads=1\n\n/////////////////////////////////////////////////////////////////////////////////////////////\n/////////////////////////   component configuration  ////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////////////////////\n; the following sections configure the components listed above\n; a help on configuration parameters can be obtained with \n;  SMILExtract -H\n; or\n;  SMILExtract -H configTypeName (= componentTypeName)\n/////////////////////////////////////////////////////////////////////////////////////////////\n\n\\{shared/standard_wave_input.conf.inc}\n\\{IS09_emotion_core.lld.conf.inc}\n\\{IS09_emotion_core.func.conf.inc}\n\n; TODO: alias levels in code: cVectorConcat (if 1:1 input (single level) to output mapping) \n;   registers an alias level instead of actually copying\n;   this maintains compatibility with old config files, but is more efficient in new code\n\n;;;;;;;;; prepare features for standard output module\n\n[componentInstances:cComponentManager]\ninstance[lldconcat].type=cVectorConcat\ninstance[llddeconcat].type=cVectorConcat\ninstance[funcconcat].type=cVectorConcat\n\n[lldconcat:cVectorConcat]\nreader.dmLevel = is09_lld\nwriter.dmLevel = lld\nincludeSingleElementFields = 1\n\n[llddeconcat:cVectorConcat]\nreader.dmLevel = is09_lld_de\nwriter.dmLevel = lld_de\nincludeSingleElementFields = 1\n\n[funcconcat:cVectorConcat]\nreader.dmLevel = is09_func\nwriter.dmLevel = func\nincludeSingleElementFields = 1\n\n\\{shared/standard_data_output.conf.inc}\n\n"
  },
  {
    "path": "config/IS09_emotion_core.func.conf.inc",
    "content": "\n///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for IS09 emotion challenge< //////////////////\n///////// > core features <                                          //////////////////\n///////// (c) 2014 by audEERING                                      //////////////////\n/////////     All rights reserved. See file COPYING for details.     //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n///////////////////////////////////////////////////////////////////////////////////////\n;\n; This section is always required in openSMILE configuration files\n;   it configures the componentManager and gives a list of all components which are to be loaded\n; The order in which the components are listed should match \n;   the order of the data flow for most efficient processing\n;\n///////////////////////////////////////////////////////////////////////////////////////\n[componentInstances:cComponentManager]\ninstance[is09_functL1].type=cFunctionals\n\n\n[is09_functL1:cFunctionals]\nreader.dmLevel=is09_lld;is09_lld_de\nwriter.dmLevel=is09_func\ncopyInputName = 1\n\\{\\cm[bufferModeRbConf]}\n\\{\\cm[frameModeFunctionalsConf{shared/FrameModeFunctionals.conf.inc}:path to included config to set frame mode for all functionals]}\nfunctionalsEnabled=Extremes;Regression;Moments\nExtremes.max = 1\nExtremes.min = 1\nExtremes.range = 1\nExtremes.maxpos = 1\nExtremes.minpos = 1\nExtremes.amean = 1\nExtremes.maxameandist = 0\nExtremes.minameandist = 0\n ; Note: the much better way to normalise the times of maxpos and minpos\n ; is 'turn', however for compatibility with old files the default 'frame'\n ; is kept here:\nExtremes.norm = frame\nRegression.linregc1 = 1\nRegression.linregc2 = 1\nRegression.linregerrA = 0\nRegression.linregerrQ = 1\nRegression.qregc1 = 0\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 0\nRegression.qregerrQ = 0\nRegression.centroid = 0\nRegression.oldBuggyQerr = 1\nRegression.normInputs = 0\nRegression.normRegCoeff = 0\nRegression.centroidRatioLimit = 0\nRegression.doRatioLimit = 0\nMoments.doRatioLimit = 0\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\n\n\n"
  },
  {
    "path": "config/IS09_emotion_core.lld.conf.inc",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for IS09 emotion challenge< //////////////////\n///////// > core features <                                          //////////////////\n///////// (c) 2014 by audEERING                                      //////////////////\n/////////     All rights reserved. See file COPYING for details.     //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n///////////////////////////////////////////////////////////////////////////////////////\n;\n; This section is always required in openSMILE configuration files\n;   it configures the componentManager and gives a list of all components which are to be loaded\n; The order in which the components are listed should match \n;   the order of the data flow for most efficient processing\n;\n///////////////////////////////////////////////////////////////////////////////////////\n[componentInstances:cComponentManager]\ninstance[is09_fr1].type=cFramer\ninstance[is09_pe2].type=cVectorPreemphasis\ninstance[is09_w1].type=cWindower\ninstance[is09_fft1].type=cTransformFFT\ninstance[is09_fftmp1].type=cFFTmagphase\ninstance[is09_mspec].type=cMelspec\ninstance[is09_mfcc].type=cMfcc\ninstance[is09_mzcr].type=cMZcr\ninstance[is09_acf].type=cAcf\ninstance[is09_cepstrum].type=cAcf\ninstance[is09_pitchACF].type=cPitchACF\ninstance[is09_energy].type=cEnergy\ninstance[is09_lld].type=cContourSmoother\ninstance[is09_delta1].type=cDeltaRegression\n\n/////////////////////////////////////////////////////////////////////////////////////////////\n/////////////////////////   component configuration  ////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////////////////////\n; the following sections configure the components listed above\n; a help on configuration parameters can be obtained with \n;  SMILExtract -H\n; or\n;  SMILExtract -H configTypeName (= componentTypeName)\n/////////////////////////////////////////////////////////////////////////////////////////////\n\n[is09_fr1:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=is09_frames\n\\{\\cm[bufferModeRbConf{shared/BufferModeRb.conf.inc}:path to included config to set the buffer mode for the standard ringbuffer levels]}\ncopyInputName = 1\nnoPostEOIprocessing = 1\nframeSize = 0.0250\nframeStep = 0.010\nframeMode = fixed\nframeCenterSpecial = left\n\n[is09_pe2:cVectorPreemphasis]\nreader.dmLevel=is09_frames\nwriter.dmLevel=is09_framespe\ncopyInputName = 1\nprocessArrayFields = 1\nk=0.97\nde = 0\n\n[is09_w1:cWindower]\nreader.dmLevel=is09_framespe\nwriter.dmLevel=is09_winframe\ncopyInputName = 1\nprocessArrayFields = 1\nwinFunc = ham\ngain = 1.0\noffset = 0\n\n  // ---- LLD -----\n\n[is09_fft1:cTransformFFT]\nreader.dmLevel=is09_winframe\nwriter.dmLevel=is09_fftc\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[is09_fftmp1:cFFTmagphase]\nreader.dmLevel=is09_fftc\nwriter.dmLevel=is09_fftmag\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\nmagnitude = 1\nphase = 0\n\n[is09_mspec:cMelspec]\nreader.dmLevel=is09_fftmag\nwriter.dmLevel=is09_mspec1\ncopyInputName = 1\nprocessArrayFields = 1\nhtkcompatible = 1\nnBands = 26\nusePower = 0\nlofreq = 0\nhifreq = 8000\ninverse = 0\nspecScale = mel\n\n[is09_mfcc:cMfcc]\nreader.dmLevel=is09_mspec1\nwriter.dmLevel=is09_mfcc1\ncopyInputName = 1\nprocessArrayFields = 1\nfirstMfcc = 1\nlastMfcc =  12\ncepLifter = 22.0\nhtkcompatible = 1\n\n\n[is09_acf:cAcf]\nreader.dmLevel=is09_fftmag\nwriter.dmLevel=is09_acf\nnameAppend = acf\ncopyInputName = 1\nprocessArrayFields = 1\nusePower = 1\ncepstrum = 0\n\n[is09_cepstrum:cAcf]\nreader.dmLevel=is09_fftmag\nwriter.dmLevel=is09_cepstrum\nnameAppend = acf\ncopyInputName = 1\nprocessArrayFields = 1\nusePower = 1\ncepstrum = 1\n\n[is09_pitchACF:cPitchACF]\n  ; the pitchACF component must ALWAYS read from acf AND cepstrum in the given order!\nreader.dmLevel=is09_acf;is09_cepstrum\nwriter.dmLevel=is09_pitch\ncopyInputName = 1\nprocessArrayFields=0\nmaxPitch = 500\nvoiceProb = 1\nvoiceQual = 0\nHNR = 0\nF0 = 1\nF0raw = 0\nF0env = 0\nvoicingCutoff = 0.550000\n\n[is09_energy:cEnergy]\nreader.dmLevel=is09_winframe\nwriter.dmLevel=is09_energy\nnameAppend=energy\nrms=1\nlog=0\n\n[is09_mzcr:cMZcr]\nreader.dmLevel=is09_frames\nwriter.dmLevel=is09_mzcr\ncopyInputName = 1\nprocessArrayFields = 1\nzcr = 1\namax = 0\nmcr = 0\nmaxmin = 0\ndc = 0\n\n[is09_lld:cContourSmoother]\nreader.dmLevel=is09_energy;is09_mfcc1;is09_mzcr;is09_pitch\nwriter.dmLevel=is09_lld\n\\{\\cm[bufferModeConf{shared/BufferMode.conf.inc}:path to included config to set buffer mode for all LLD that feed into functionals]}\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n// ---- delta regression of LLD ----\n[is09_delta1:cDeltaRegression]\nreader.dmLevel=is09_lld\nwriter.dmLevel=is09_lld_de\n\\{\\cm[bufferModeConf]}\nnameAppend = de\ncopyInputName = 1\nnoPostEOIprocessing = 0\ndeltawin=2\nblocksize=1\n\n"
  },
  {
    "path": "config/IS10_paraling.conf",
    "content": "\n///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for IS10 features <         //////////////////\n/////////                                                            //////////////////\n///////// (c) 2014 by audEERING                                      //////////////////\n/////////     All rights reserved. See file COPYING for details.     //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n// NOTE: This file is not compatible with old versions of openSMILE (< 2.1)\n// and will not give the same features (numerically) \n// as the original IS10 features.\n// It should be preferred in new studies / designes, however, as it contains\n// some minor fixes.\n// For compatible features, use the IS10_paraling_compat.conf\n\n//\n// Usage:\n// SMILExtract -C thisconfig.conf -I input.wav -O output.arff \n//\n \n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\n;; run single threaded (nThreads=1)\n; NOTE: a single thread is more efficient for processing small files, since multi-threaded processing involves more \n;       overhead during startup, which will make the system slower in the end\nnThreads=1\n;; do not show any internal dataMemory level settings \n; (if you want to see them set the value to 1, 2, 3, or 4, depending on the amount of detail you wish)\nprintLevelStats=0\n\n\n\\{shared/standard_wave_input.conf.inc}\n\\{IS10_paraling_core.lld.conf.inc}\n\\{IS10_paraling_core.func.conf.inc}\n\n;;;;;;;;; prepare features for standard output module\n\n[componentInstances:cComponentManager]\ninstance[lldconcat].type=cVectorConcat\ninstance[llddeconcat].type=cVectorConcat\ninstance[funcconcat].type=cVectorConcat\n\n[lldconcat:cVectorConcat]\nreader.dmLevel = is10_lld1;is10_lld2\nwriter.dmLevel = lld\nincludeSingleElementFields = 1\n\n[llddeconcat:cVectorConcat]\nreader.dmLevel = is10_lld1_de;is10_lld2_de\nwriter.dmLevel = lld_de\nincludeSingleElementFields = 1\n\n[funcconcat:cVectorConcat]\nreader.dmLevel = is10_funct;is10_functNz;is10_functOnsets\nwriter.dmLevel = func\nincludeSingleElementFields = 1\n\n\\{shared/standard_data_output.conf.inc}\n\n"
  },
  {
    "path": "config/IS10_paraling_compat.conf",
    "content": "\n///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for IS10 features <         //////////////////\n/////////                                                            //////////////////\n///////// (c) 2014 by audEERING                                      //////////////////\n/////////     All rights reserved. See file COPYING for details.     //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n// NOTE: This file is for version 2.1 and above and produces \n// numerically compatible output to the original IS10 set,\n// EXCEPT for Jitter/Shimmer, as some bugs have been fixed there \n// w/o maintaining backwards compatibility.\n\n// For new designs one should however use the IS10_paraling.conf which \n// returns incompatible, yet enhanced and fixed features.\n\n\n//\n// Usage:\n// SMILExtract -C thisconfig.conf -I input.wav -O output.arff \n//\n \n///////////////////////////////////////////////////////////////////////////////////////\n;\n; This section is always required in openSMILE configuration files\n;   it configures the componentManager and gives a list of all components which are to be loaded\n; The order in which the components are listed should match \n;   the order of the data flow for most efficient processing\n;\n///////////////////////////////////////////////////////////////////////////////////////\n[componentInstances:cComponentManager]\n ; this line configures the default data memory:\ninstance[dataMemory].type=cDataMemory\n ;;; wave file input\ninstance[waveIn].type=cWaveSource\n ;;; 40 ms frames features:\ninstance[fr40].type=cFramer\ninstance[w40].type=cWindower\ninstance[fft40].type=cTransformFFT\ninstance[fftmagphase40].type=cFFTmagphase\n ; SHS Pitch:\ninstance[scale].type=cSpecScale\ninstance[pitchShs].type=cPitchShs\ninstance[pitchSmooth].type=cPitchSmoother\ninstance[pitchJitter].type=cPitchJitter\ninstance[pitchSmooth2].type=cPitchSmoother\ninstance[res].type=cSpecResample\n\n ;;; 25 ms frames features:\ninstance[fr25].type=cFramer\ninstance[pe].type=cVectorPreemphasis\ninstance[win].type=cWindower\ninstance[fft].type=cTransformFFT\ninstance[fftmagphase].type=cFFTmagphase\n ; mfcc\ninstance[mspec].type=cMelspec\ninstance[mfcc].type=cMfcc\n ; log mel frequency bands (mfb)\ninstance[mspec2].type=cMelspec\ninstance[vo].type=cVectorOperation\ninstance[lpc].type=cLpc\n ; Line Spectral Frequencies\ninstance[lsp].type=cLsp\n ; Loudness (narrow-band approximation)\ninstance[intens].type=cIntensity\n ;;; all LLD concattenated and smoothed using a moving average filter\ninstance[lld].type=cContourSmoother\ninstance[lld2].type=cContourSmoother\n ; delta coefficients of LLD\ninstance[delta1].type=cDeltaRegression\ninstance[delta2].type=cDeltaRegression\n ;;; functionals over FULL input (e.g. turns)\ninstance[functL1].type=cFunctionals\ninstance[functL1nz].type=cFunctionals\ninstance[functOnsets].type=cFunctionals\n\n;; run single threaded (nThreads=1)\n; NOTE: a single thread is more efficient for processing small files, since multi-threaded processing involves more \n;       overhead during startup, which will make the system slower in the end\nnThreads=1\n;; do not show any internal dataMemory level settings \n; (if you want to see them set the value to 1, 2, 3, or 4, depending on the amount of detail you wish)\nprintLevelStats=0\n\n\n\n/////////////////////////////////////////////////////////////////////////////////////////////\n/////////////////////////   component configuration  ////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////////////////////\n; the following sections configure the components listed above\n; a help on configuration parameters can be obtained with \n;  SMILExtract -H\n; or\n;  SMILExtract -H configTypeName (= componentTypeName)\n/////////////////////////////////////////////////////////////////////////////////////////////\n\n[waveIn:cWaveSource]\n ; this sets the level this component writes to\n ; the level will be created by this component\n ; no other components may write to a level having the same name\nwriter.dmLevel=wave\n ; this defines a new commandline option \"-I\" or \"-inputfile\", which can be used to specify \n ; the filename on the commandline instead of having it \"hard-coded\" in the config file\nfilename=\\cm[inputfile(I){test.wav}:name of input file]\n ; mix stereo files down to mono for analysis\nmonoMixdown=1\n\n[fr40:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames40\nframeMode = fixed\nframeSize = 0.060\nframeStep = 0.010\nframeCenterSpecial = left\nnoPostEOIprocessing = 1\n\n[w40:cWindower]\nreader.dmLevel=frames40\nwriter.dmLevel=win40frame\nwinFunc = gauss\nsigma = 0.25\ngain = 1.0\n\n\n[fft40:cTransformFFT]\nreader.dmLevel=win40frame\nwriter.dmLevel=fftc40\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmagphase40:cFFTmagphase]\nreader.dmLevel=fftc40\nwriter.dmLevel=fftmag40\nmagnitude = 1\nphase = 0\n\n[scale:cSpecScale]\nreader.dmLevel=fftmag40\nwriter.dmLevel=hps\nscale=log\n ; octave scale\nlogScaleBase=2\nspecSmooth = 0\nauditoryWeighting = 0\nspecEnhance = 0\nminF = 25\nmaxF = -1\ninterpMethod = spline\n\n[pitchShs:cPitchShs]\nreader.dmLevel=hps\nwriter.dmLevel=pitchShs\nF0raw = 0\nvoicingClip = 0\nvoicingC1=0\nscores=1\nvoicing=1\nnCandidates = 3\noctaveCorrection = 0\ngreedyPeakAlgo = 0\ncompressionFactor = 0.85\nnHarmonics = 15\nvoicingCutoff = 0.75\nmaxPitch = 620\nminPitch = 52\n\n[pitchSmooth:cPitchSmoother]\nreader.dmLevel=pitchShs\nwriter.dmLevel=pitch\nF0raw = 0\nF0final = 0\nF0finalEnv = 1\nvoicingFinalUnclipped = 1\nmedianFilter0 = 0\npostSmoothingMethod = simple\n;simple\noctaveCorrection = 0\nwriter.levelconf.nT=10\n;writer.levelconf.noHang=2\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n[pitchSmooth2:cPitchSmoother]\nreader.dmLevel=pitchShs\nwriter.dmLevel=pitchF\nF0raw = 0\nF0final = 1\nF0finalEnv = 0\nvoicingFinalUnclipped = 0\nmedianFilter0 = 0\npostSmoothingMethod = simple\noctaveCorrection = 0\nwriter.levelconf.nT=10\n;writer.levelconf.noHang=2\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n ;;;; default (template) configuration section for component 'cPitchJitter' ;;;;\n[pitchJitter:cPitchJitter]\nreader.dmLevel = wave\nwriter.dmLevel = jitter\n// nameAppend =\ncopyInputName = 1\nF0reader.dmLevel = pitchF\nF0field = F0final\nsearchRangeRel = 0.250000\njitterLocal = 1\njitterDDP = 1\njitterLocalEnv = 0\njitterDDPEnv = 0\nshimmerLocal = 1\nshimmerLocalEnv = 0\nonlyVoiced = 0\n;periodLengths = 0\n;periodStarts = 0\ninputMaxDelaySec = 1\nusePeakToPeakPeriodLength = 0\nshimmerUseRmsAmplitude = 0\nminCC = 0.5\nminNumPeriods = 2\nuseBrokenJitterThresh = 1\n\n[fr25:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames\nframeSize = 0.025\nframeStep = 0.010\nframeCenterSpecial = left\n\n[pe:cVectorPreemphasis]\nreader.dmLevel=frames\nwriter.dmLevel=framespe\nk=0.97\n\n[win:cWindower]\nreader.dmLevel=framespe\nwriter.dmLevel=winframe\nwinFunc = ham\ngain = 1.0\n\n[fft:cTransformFFT]\nreader.dmLevel=winframe\nwriter.dmLevel=fftc\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmagphase:cFFTmagphase]\nreader.dmLevel=fftc\nwriter.dmLevel=fftmag\nmagnitude = 1\nphase = 0\n\n[mspec:cMelspec]\nreader.dmLevel=fftmag\nwriter.dmLevel=mspec1\nhtkcompatible = 0\nusePower = 1\nlofreq = 20\nhifreq = 8000\nnBands=26\nspecScale = mel\nbwMethod = lr\n\n[mfcc:cMfcc]\nreader.dmLevel = mspec1\nwriter.dmLevel = mfcc\nhtkcompatible = 0\nfirstMfcc=0\nlastMfcc=14\ncepLifter=22\ncopyInputName = 0\n\n[mspec2:cMelspec]\nreader.dmLevel=fftmag\nwriter.dmLevel=mspec2\nhtkcompatible = 0\nusePower = 1\nlofreq = 20\nhifreq = 6500\nnBands=8\nspecScale = mel\nbwMethod = lr\n\n[vo:cVectorOperation]\nreader.dmLevel=mspec2\nwriter.dmLevel=mspec2log\noperation = log\ncopyInputName = 0\nnameAppend=logMelFreqBand\n\n[res:cSpecResample]\nreader.dmLevel=fftc\nwriter.dmLevel=outpR\ntargetFs = 11000\n\n[lpc:cLpc]\n;reader.dmLevel=framespe\nreader.dmLevel=outpR\nwriter.dmLevel=lpc\np=8\nmethod = acf\nsaveLPCoeff = 1\nlpGain = 0\nsaveRefCoeff = 0\nresidual = 0\nforwardFilter = 0\nlpSpectrum = 0\n\n[lsp:cLsp]\nreader.dmLevel=lpc\nwriter.dmLevel=lsp\n\n[intens:cIntensity]\nreader.dmLevel=frames\nwriter.dmLevel=intens\nintensity=0\nloudness=1\n\n[lld:cContourSmoother]\nreader.dmLevel=intens;mfcc;mspec2log;lsp;pitch\nwriter.dmLevel=lld1\nbuffersize=1000\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nsmaWin = 3\n; this level must grow to hold ALL the LLD of the full input\n\n// ---- delta regression of LLD ----\n[delta1:cDeltaRegression]\nreader.dmLevel=lld1\nwriter.dmLevel=lld1_de\nbuffersize=1000\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\ndeltawin=2\nblocksize=1\n\n[lld2:cContourSmoother]\nreader.dmLevel=pitchF;jitter\nwriter.dmLevel=lld2\nbuffersize=1000\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n; this level must grow to hold ALL the LLD of the full input\nsmaWin = 3\nnoZeroSma = 0\n\n// ---- delta regression of LLD ----\n[delta2:cDeltaRegression]\nreader.dmLevel=lld2\nwriter.dmLevel=lld2_de\nbuffersize=1000\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\ndeltawin=2\nblocksize=1\n\n[functOnsets:cFunctionals]\nreader.dmLevel=pitchF\nwriter.dmLevel=functOnsets\n ; frameSize and frameStep = 0 => functionals over complete input\n ; (NOTE: buffersize of lld and lld_de levels must be large enough!!)\nframeMode = full\nframeSize = 0\nframeStep = 0\ncopyInputName=0\nfunctNameAppend=Turn\nfunctionalsEnabled=Onset;Times\n//noPostEOIprocessing = 0\nOnset.threshold = 0\n;Onset.thresholdOnset = 0\n;Onset.thresholdOffset = 0\nOnset.useAbsVal = 0\nOnset.onsetPos = 0\nOnset.offsetPos = 0\nOnset.numOnsets = 1\nOnset.numOffsets = 0\nOnset.norm = segment\nTimes.upleveltime25 = 0\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 0\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 0\nTimes.downleveltime90 = 0\nTimes.risetime = 0\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 1\nTimes.norm = second\n\n\n// statistical functionals\n[functL1:cFunctionals]\nreader.dmLevel=lld1;lld1_de\nwriter.dmLevel=funct\n ; frameSize and frameStep = 0 => functionals over complete input\n ; (NOTE: buffersize of lld and lld_de levels must be large enough!!)\nframeMode = full\nframeSize=0\nframeStep=0\nfunctionalsEnabled=Extremes;Regression;Moments;Percentiles;Times\nExtremes.max = 0\nExtremes.min = 0\nExtremes.range = 0\nExtremes.maxpos = 1\nExtremes.minpos = 1\nExtremes.amean = 1\nExtremes.maxameandist=0\nExtremes.minameandist=0\nExtremes.norm = frame\nRegression.linregc1 = 1\nRegression.linregc2 = 1\nRegression.linregerrA = 1\nRegression.linregerrQ = 1\nRegression.qregc1 = 0\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 0\nRegression.qregerrQ = 0\nRegression.centroid = 0\nRegression.oldBuggyQerr = 1\nRegression.normInputs = 0\nRegression.normRegCoeff = 0\nRegression.centroidRatioLimit = 0\nRegression.doRatioLimit = 0\nMoments.doRatioLimit = 0\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nPercentiles.quartiles = 1\nPercentiles.quartile1 = 0\nPercentiles.quartile2 = 0\nPercentiles.quartile3 = 0\nPercentiles.iqr = 1\nPercentiles.iqr12 = 0\nPercentiles.iqr23 = 0\nPercentiles.iqr13 = 0\nPercentiles.interp = 1\nPercentiles.percentile = 0.01;0.99\nPercentiles.pctlrange=0-1\nTimes.upleveltime25 = 0\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 0\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 1\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 0\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.norm = segment\nnonZeroFuncts = 0\n\n// statistical functionals\n[functL1nz:cFunctionals]\nreader.dmLevel=lld2;lld2_de\nwriter.dmLevel=functNz\n ; frameSize and frameStep = 0 => functionals over complete input\n ; (NOTE: buffersize of lld and lld_de levels must be large enough!!)\nframeMode=full\nframeSize=0\nframeStep=0\nfunctionalsEnabled=Extremes;Regression;Moments;Percentiles;Times\nExtremes.max = 0\nExtremes.min = 0\nExtremes.range = 0\nExtremes.maxpos = 1\nExtremes.minpos = 1\nExtremes.amean = 1\nExtremes.maxameandist=0\nExtremes.minameandist=0\nExtremes.norm = frame\nRegression.linregc1 = 1\nRegression.linregc2 = 1\nRegression.linregerrA = 1\nRegression.linregerrQ = 1\nRegression.qregc1 = 0\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 0\nRegression.qregerrQ = 0\nRegression.centroid = 0\nRegression.oldBuggyQerr = 1\nRegression.normInputs = 0\nRegression.normRegCoeff = 0\nRegression.centroidRatioLimit = 0\nRegression.doRatioLimit = 0\nMoments.doRatioLimit = 0\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nPercentiles.quartiles = 1\nPercentiles.quartile1 = 0\nPercentiles.quartile2 = 0\nPercentiles.quartile3 = 0\nPercentiles.iqr = 1\nPercentiles.iqr12 = 0\nPercentiles.iqr23 = 0\nPercentiles.iqr13 = 0\nPercentiles.interp = 1\nPercentiles.percentile = 0.99\n;Percentiles.pctlrange=0-1\nTimes.upleveltime25 = 0\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 0\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 1\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 0\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.norm = segment\nnonZeroFuncts=1\n\n;;;;;;;;; prepare features for standard output module\n\n[componentInstances:cComponentManager]\ninstance[lldconcat].type=cVectorConcat\ninstance[llddeconcat].type=cVectorConcat\ninstance[funcconcat].type=cVectorConcat\n\n[lldconcat:cVectorConcat]\nreader.dmLevel = lld1;lld2\nwriter.dmLevel = lld\nincludeSingleElementFields = 1\n\n[llddeconcat:cVectorConcat]\nreader.dmLevel = lld1_de;lld2_de\nwriter.dmLevel = lld_de\nincludeSingleElementFields = 1\n\n[funcconcat:cVectorConcat]\nreader.dmLevel = funct;functNz;functOnsets\nwriter.dmLevel = func\nincludeSingleElementFields = 1\n\n\\{shared/standard_data_output.conf.inc}\n\n\n\n//////---------------------- END -------------------------///////\n"
  },
  {
    "path": "config/IS10_paraling_core.func.conf.inc",
    "content": "\n///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for IS10 features <         //////////////////\n///////// > core features : functionals <                            //////////////////\n///////// (c) 2014 by audEERING                                      //////////////////\n/////////     All rights reserved. See file COPYING for details.     //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n// NOTE: This file is not compatible with old versions of openSMILE (< 2.1)\n// and will not give the same features (numerically) \n// as the original IS10 features.\n// It should be preferred in new studies / designes, however, as it contains\n// some minor fixes.\n// For compatible features, use the IS10_paraling_compat.conf\n\n[componentInstances:cComponentManager]\n ;;; functionals over FULL input (e.g. turns)\ninstance[is10_functOnsets].type=cFunctionals\ninstance[is10_functL1].type=cFunctionals\ninstance[is10_functL1nz].type=cFunctionals\n\n[is10_functOnsets:cFunctionals]\nreader.dmLevel=is10_pitchF\nwriter.dmLevel=is10_functOnsets\n\\{\\cm[bufferModeRbConf]}\n ; frameSize and frameStep = 0 => functionals over complete input\n ; (NOTE: buffersize of lld and lld_de levels must be large enough!!)\n\\{\\cm[frameModeFunctionalsConf{shared/FrameModeFunctionals.conf.inc}:path to included config to set frame mode for all functionals]}\ncopyInputName=0\nfunctNameAppend=Turn\nfunctionalsEnabled=Onset;Times\n//noPostEOIprocessing = 0\nOnset.threshold = 0\n;Onset.thresholdOnset = 0\n;Onset.thresholdOffset = 0\nOnset.useAbsVal = 0\nOnset.onsetPos = 0\nOnset.offsetPos = 0\nOnset.numOnsets = 0\nOnset.numOffsets = 0\nOnset.onsetRate = 1\nOnset.norm = segment\nTimes.upleveltime25 = 0\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 0\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 0\nTimes.downleveltime90 = 0\nTimes.risetime = 0\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 1\nTimes.norm = second\n\n// statistical functionals\n[is10_functL1:cFunctionals]\nreader.dmLevel=is10_lld1;is10_lld1_de\nwriter.dmLevel=is10_funct\n\\{\\cm[bufferModeRbConf]}\n ; frameSize and frameStep = 0 => functionals over complete input\n ; (NOTE: buffersize of lld and lld_de levels must be large enough!!)\n\\{\\cm[frameModeFunctionalsConf]}\nfunctionalsEnabled=Extremes;Regression;Moments;Percentiles;Times\nExtremes.max = 0\nExtremes.min = 0\nExtremes.range = 0\nExtremes.maxpos = 1\nExtremes.minpos = 1\nExtremes.amean = 1\nExtremes.maxameandist=0\nExtremes.minameandist=0\nExtremes.norm = frame\nRegression.linregc1 = 1\nRegression.linregc2 = 1\nRegression.linregerrA = 1\nRegression.linregerrQ = 1\nRegression.qregc1 = 0\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 0\nRegression.qregerrQ = 0\nRegression.centroid = 0\nRegression.oldBuggyQerr = 0\nRegression.normInputs = 0\nRegression.normRegCoeff = 0\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nPercentiles.quartiles = 1\nPercentiles.quartile1 = 0\nPercentiles.quartile2 = 0\nPercentiles.quartile3 = 0\nPercentiles.iqr = 1\nPercentiles.iqr12 = 0\nPercentiles.iqr23 = 0\nPercentiles.iqr13 = 0\nPercentiles.interp = 1\nPercentiles.percentile = 0.01;0.99\nPercentiles.pctlrange=0-1\nTimes.upleveltime25 = 0\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 0\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 1\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 0\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.norm = segment\nnonZeroFuncts = 0\n\n// statistical functionals\n[is10_functL1nz:cFunctionals]\nreader.dmLevel=is10_lld2;is10_lld2_de\nwriter.dmLevel=is10_functNz\n\\{\\cm[bufferModeRbConf]}\n ; frameSize and frameStep = 0 => functionals over complete input\n ; (NOTE: buffersize of lld and lld_de levels must be large enough!!)\n\\{\\cm[frameModeFunctionalsConf]}\nfunctionalsEnabled=Extremes;Regression;Moments;Percentiles;Times\nExtremes.max = 0\nExtremes.min = 0\nExtremes.range = 0\nExtremes.maxpos = 1\nExtremes.minpos = 1\nExtremes.amean = 1\nExtremes.maxameandist=0\nExtremes.minameandist=0\nExtremes.norm = frame\nRegression.linregc1 = 1\nRegression.linregc2 = 1\nRegression.linregerrA = 1\nRegression.linregerrQ = 1\nRegression.qregc1 = 0\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 0\nRegression.qregerrQ = 0\nRegression.centroid = 0\nRegression.oldBuggyQerr = 0\nRegression.normInputs = 0\nRegression.normRegCoeff = 0\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nPercentiles.quartiles = 1\nPercentiles.quartile1 = 0\nPercentiles.quartile2 = 0\nPercentiles.quartile3 = 0\nPercentiles.iqr = 1\nPercentiles.iqr12 = 0\nPercentiles.iqr23 = 0\nPercentiles.iqr13 = 0\nPercentiles.interp = 1\nPercentiles.percentile = 0.99\n;Percentiles.pctlrange=0-1\nTimes.upleveltime25 = 0\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 0\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 1\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 0\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.norm = segment\nnonZeroFuncts=1\n\n\n//////---------------------- END -------------------------///////\n"
  },
  {
    "path": "config/IS10_paraling_core.lld.conf.inc",
    "content": "\n///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for IS10 features <         //////////////////\n/////////                                                            //////////////////\n///////// (c) 2014 by audEERING                                      //////////////////\n/////////     All rights reserved. See file COPYING for details.     //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n// NOTE: This file is not compatible with old versions of openSMILE (< 2.1)\n// and will not give the same features (numerically) \n// as the original IS10 features.\n// It should be preferred in new studies / designes, however, as it contains\n// some minor fixes.\n// For compatible features, use the IS10_paraling_compat.conf\n\n[componentInstances:cComponentManager]\ninstance[is10_fr40].type=cFramer\n  ;; 40 ms frames features\ninstance[is10_w40].type=cWindower\ninstance[is10_fft40].type=cTransformFFT\ninstance[is10_fftmagphase40].type=cFFTmagphase\ninstance[is10_scale].type=cSpecScale\ninstance[is10_pitchShs].type=cPitchShs\ninstance[is10_pitchSmooth].type=cPitchSmoother\ninstance[is10_pitchJitter].type=cPitchJitter\ninstance[is10_pitchSmooth2].type=cPitchSmoother\ninstance[is10_res].type=cSpecResample\n ;;; 25 ms frames features:\ninstance[is10_fr25].type=cFramer\ninstance[is10_pe].type=cVectorPreemphasis\ninstance[is10_win].type=cWindower\ninstance[is10_fft].type=cTransformFFT\ninstance[is10_fftmagphase].type=cFFTmagphase\n ; mfcc\ninstance[is10_mspec].type=cMelspec\ninstance[is10_mfcc].type=cMfcc\n ; log mel frequency bands (mfb)\ninstance[is10_mspec2].type=cMelspec\ninstance[is10_vo].type=cVectorOperation\ninstance[is10_lpc].type=cLpc\n ; Line Spectral Frequencies\ninstance[is10_lsp].type=cLsp\n ; Loudness (narrow-band approximation)\ninstance[is10_intens].type=cIntensity\n ;;; all LLD concattenated and smoothed using a moving average filter\ninstance[is10_lld].type=cContourSmoother\ninstance[is10_lld2].type=cContourSmoother\n ; delta coefficients of LLD\ninstance[is10_delta1].type=cDeltaRegression\ninstance[is10_delta2].type=cDeltaRegression\n\n\n[is10_fr40:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=is10_frames40\n\\{\\cm[bufferModeRbConf{shared/BufferModeRb.conf.inc}:path to included config to set the buffer mode for the standard ringbuffer levels]}\nframeMode = fixed\nframeSize = 0.060\nframeStep = 0.010\nframeCenterSpecial = left\nnoPostEOIprocessing = 1\n\n[is10_w40:cWindower]\nreader.dmLevel=is10_frames40\nwriter.dmLevel=is10_win40frame\nwinFunc = gauss\nsigma = 0.25\ngain = 1.0\n\n[is10_fft40:cTransformFFT]\nreader.dmLevel=is10_win40frame\nwriter.dmLevel=is10_fftc40\n\n[is10_fftmagphase40:cFFTmagphase]\nreader.dmLevel=is10_fftc40\nwriter.dmLevel=is10_fftmag40\nmagnitude = 1\nphase = 0\n\n[is10_scale:cSpecScale]\nreader.dmLevel=is10_fftmag40\nwriter.dmLevel=is10_hps\nscale=octave\nsourceScale = lin\nspecSmooth = 0\nauditoryWeighting = 0\nspecEnhance = 0\nminF = 20\nmaxF = -1\nnPointsTarget = 0\nspecSmooth = 1\nspecEnhance = 1\nauditoryWeighting = 1\ninterpMethod = spline\n\n[is10_pitchShs:cPitchShs]\nreader.dmLevel=is10_hps\nwriter.dmLevel=is10_pitchShs\ninputFieldSearch = fftMag_octScale\nF0raw = 0\nvoicingClip = 0\nvoicingC1=0\nscores=1\nvoicing=1\nnCandidates = 6\noctaveCorrection = 0\ngreedyPeakAlgo = 1\ncompressionFactor = 0.85\nnHarmonics = 15\nvoicingCutoff = 0.70\nmaxPitch = 620\nminPitch = 52\n\n[is10_pitchSmooth:cPitchSmoother]\nreader.dmLevel=is10_pitchShs\nwriter.dmLevel=is10_pitch\nF0raw = 0\nF0final = 0\nF0finalEnv = 1\nvoicingFinalUnclipped = 1\nmedianFilter0 = 0\npostSmoothingMethod = simple\n;simple\noctaveCorrection = 0\nwriter.levelconf.nT=10\n;writer.levelconf.noHang=2\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n[is10_pitchSmooth2:cPitchSmoother]\nreader.dmLevel=is10_pitchShs\nwriter.dmLevel=is10_pitchF\nF0raw = 0\nF0final = 1\nF0finalEnv = 0\nvoicingFinalUnclipped = 0\nmedianFilter0 = 0\npostSmoothingMethod = simple\noctaveCorrection = 0\nwriter.levelconf.nT=10\n;writer.levelconf.noHang=2\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n ;;;; default (template) configuration section for component 'cPitchJitter' ;;;;\n[is10_pitchJitter:cPitchJitter]\nreader.dmLevel = wave\nwriter.dmLevel = is10_jitter\n\\{\\cm[bufferModeRbLagConf{shared/BufferModeRb.conf.inc}:path to included config to set the buffer mode for levels which will be joint with Viterbi smoothed -lagged- F0]}\ncopyInputName = 1\nF0reader.dmLevel = is10_pitchF\nF0field = F0final\nsearchRangeRel = 0.200000\njitterLocal = 1\njitterDDP = 1\njitterLocalEnv = 0\njitterDDPEnv = 0\nshimmerLocal = 1\nshimmerLocalEnv = 0\nonlyVoiced = 0\n;periodLengths = 0\n;periodStarts = 0\ninputMaxDelaySec = 1\nusePeakToPeakPeriodLength = 0\nshimmerUseRmsAmplitude = 0\nminCC = 0.5\nminNumPeriods = 2\n\n[is10_fr25:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=is10_frames\n\\{\\cm[bufferModeRbConf]}\nframeSize = 0.025\nframeStep = 0.010\nframeCenterSpecial = left\n\n[is10_pe:cVectorPreemphasis]\nreader.dmLevel=is10_frames\nwriter.dmLevel=is10_framespe\nk=0.97\n\n[is10_win:cWindower]\nreader.dmLevel=is10_framespe\nwriter.dmLevel=is10_winframe\nwinFunc = ham\ngain = 1.0\n\n[is10_fft:cTransformFFT]\nreader.dmLevel=is10_winframe\nwriter.dmLevel=is10_fftc\n\n[is10_fftmagphase:cFFTmagphase]\nreader.dmLevel=is10_fftc\nwriter.dmLevel=is10_fftmag\nmagnitude = 1\nphase = 0\n\n[is10_mspec:cMelspec]\nreader.dmLevel=is10_fftmag\nwriter.dmLevel=is10_mspec1\nhtkcompatible = 0\nusePower = 1\nlofreq = 20\nhifreq = 8000\nnBands=26\nspecScale = mel\nbwMethod = lr\n\n[is10_mfcc:cMfcc]\nreader.dmLevel = is10_mspec1\nwriter.dmLevel = is10_mfcc\nhtkcompatible = 0\nfirstMfcc=0\nlastMfcc=14\ncepLifter=22\ncopyInputName = 0\n\n[is10_mspec2:cMelspec]\nreader.dmLevel=is10_fftmag\nwriter.dmLevel=is10_mspec2\nhtkcompatible = 0\nusePower = 1\nlofreq = 20\nhifreq = 6500\nnBands=8\nspecScale = mel\nbwMethod = lr\n\n[is10_vo:cVectorOperation]\nreader.dmLevel=is10_mspec2\nwriter.dmLevel=is10_mspec2log\noperation = log\ncopyInputName = 0\nnameAppend=logMelFreqBand\n\n[is10_res:cSpecResample]\nreader.dmLevel=is10_fftc\nwriter.dmLevel=is10_outpR\ntargetFs = 11000\n\n[is10_lpc:cLpc]\n;reader.dmLevel=framespe\nreader.dmLevel=is10_outpR\nwriter.dmLevel=is10_lpc\np=8\nmethod = acf\nsaveLPCoeff = 1\nlpGain = 0\nsaveRefCoeff = 0\nresidual = 0\nforwardFilter = 0\nlpSpectrum = 0\n\n[is10_lsp:cLsp]\nreader.dmLevel=is10_lpc\nwriter.dmLevel=is10_lsp\n\n[is10_intens:cIntensity]\nreader.dmLevel=is10_frames\nwriter.dmLevel=is10_intens\nintensity=0\nloudness=1\n\n[is10_lld:cContourSmoother]\nreader.dmLevel=is10_intens;is10_mfcc;is10_mspec2log;is10_lsp;is10_pitch\nwriter.dmLevel=is10_lld1\n\\{\\cm[bufferModeConf{shared/BufferMode.conf.inc}:path to included config to set the buffer mode for the levels before the functionals]}\nsmaWin = 3\n; this level must grow to hold ALL the LLD of the full input\n\n// ---- delta regression of LLD ----\n[is10_delta1:cDeltaRegression]\nreader.dmLevel=is10_lld1\nwriter.dmLevel=is10_lld1_de\n\\{\\cm[bufferModeConf]}\ndeltawin=2\nblocksize=1\n\n[is10_lld2:cContourSmoother]\nreader.dmLevel=is10_pitchF;is10_jitter\nwriter.dmLevel=is10_lld2\n\\{\\cm[bufferModeConf]}\n; this level must grow to hold ALL the LLD of the full input\nsmaWin = 3\nnoZeroSma = 1\n\n// ---- delta regression of LLD ----\n[is10_delta2:cDeltaRegression]\nreader.dmLevel=is10_lld2\nwriter.dmLevel=is10_lld2_de\n\\{\\cm[bufferModeConf]}\ndeltawin=2\nblocksize=1\nonlyInSegments = 1\nzeroSegBound = 1\n\n\n//////---------------------- END -------------------------///////\n"
  },
  {
    "path": "config/IS11_speaker_state.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for IS11 features <         //////////////////\n/////////                                                            //////////////////\n///////// (c) 2014 by audEERING                                      //////////////////\n/////////     All rights reserved. See file COPYING for details.     //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n// \n// Usage:\n// SMILExtract -C IS11.conf -I input.wav -O output.arff\n// -- append features for input.wav to output.arff (create if necessary)\n//\n\n\n;;;;;;; component list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\nprintLevelStats=0\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;; main section ;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[waveIn].type=cWaveSource\n\n[waveIn:cWaveSource]\nwriter.dmLevel=wave\nfilename=\\cm[inputfile(I){test.wav}:name of input file]\nmonoMixdown=1\n\n;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[frame60].type=cFramer\ninstance[win60].type=cWindower\ninstance[fft60].type=cTransformFFT\ninstance[fftmp60].type=cFFTmagphase\n\n[frame60:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frame60\nframeSize = 0.060\nframeStep = 0.010\nframeCenterSpecial = left\n\n\n[win60:cWindower]\nreader.dmLevel=frame60\nwriter.dmLevel=winG60\nwinFunc=gauss\ngain=1.0\nsigma=0.4\n\n[fft60:cTransformFFT]\nreader.dmLevel=winG60\nwriter.dmLevel=fftcG60\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmp60:cFFTmagphase]\nreader.dmLevel=fftcG60\nwriter.dmLevel=fftmagG60\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[frame25].type=cFramer\ninstance[pe25].type=cVectorPreemphasis\ninstance[win25].type=cWindower\ninstance[fft25].type=cTransformFFT\ninstance[fftmp25].type=cFFTmagphase\n\n[frame25:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frame25\nframeSize = 0.020\nframeStep = 0.010\nframeCenterSpecial = left\n\n[pe25:cVectorPreemphasis]\nreader.dmLevel=frame25\nwriter.dmLevel=frame25pe\nk=0.97\nde=0\n\n[win25:cWindower]\nreader.dmLevel=frame25\nwriter.dmLevel=winH25\nwinFunc=hamming\n\n[fft25:cTransformFFT]\nreader.dmLevel=winH25\nwriter.dmLevel=fftcH25\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmp25:cFFTmagphase]\nreader.dmLevel=fftcH25\nwriter.dmLevel=fftmagH25\n\n\n\n;;;;;;;;;;;;;;;;;;;; HPS pitch\n\n[componentInstances:cComponentManager]\ninstance[scale].type=cSpecScale\ninstance[shs].type=cPitchShs\ninstance[pitchSmooth].type=cPitchSmoother\ninstance[pitchSmooth2].type=cPitchSmoother\n\n\n[scale:cSpecScale]\nreader.dmLevel=fftmagG60\nwriter.dmLevel=hpsG60\ncopyInputName = 1\nprocessArrayFields = 0\nscale=octave\nsourceScale = lin\n// logScaleBase = 2\n// logSourceScaleBase = 2\n// firstNote = 55\ninterpMethod = spline\nminF = 25\nmaxF = -1\nnPointsTarget = 0\nspecSmooth = 1\nspecEnhance = 1\nauditoryWeighting = 1 \n\n[shs:cPitchShs]\nreader.dmLevel=hpsG60\nwriter.dmLevel=pitchShsG60\ncopyInputName = 1\nprocessArrayFields = 0\nmaxPitch = 620\nminPitch = 52\nnCandidates = 4\nscores = 1\nvoicing = 1\nF0C1 = 0\nvoicingC1 = 0\nF0raw = 1\nvoicingClip = 1\nvoicingCutoff = 0.700000\ninputFieldSearch = Mag_octScale\noctaveCorrection = 0\nnHarmonics = 15\ncompressionFactor = 0.850000\n\n[pitchSmooth:cPitchSmoother]\nreader.dmLevel=pitchShsG60\nwriter.dmLevel=pitchG60\ncopyInputName = 1\nprocessArrayFields = 0\nmedianFilter0 = 0\npostSmoothing = 0\npostSmoothingMethod = simple\n ; note: octave correction is too agressive, thus we disable it..\noctaveCorrection = 0\nF0final = 1\nF0finalEnv = 0\nno0f0 = 0\nvoicingFinalClipped = 0\nvoicingFinalUnclipped = 1\nF0raw = 0\nvoicingC1 = 0\nvoicingClip = 0\n\n[pitchSmooth2:cPitchSmoother]\nreader.dmLevel=pitchShsG60\nwriter.dmLevel=pitchF\nF0raw = 0\nF0final = 1\nF0finalEnv = 0\nvoicingFinalUnclipped = 0\nmedianFilter0 = 0\npostSmoothingMethod = simple\noctaveCorrection = 0\n\n\n;;;;;;;;;;;;;;;;;;; VQ\n\n[componentInstances:cComponentManager]\n;instance[acf].type=cAcf\n;instance[hnr].type=cHnr\ninstance[pitchJitter].type=cPitchJitter\n\n\n[pitchJitter:cPitchJitter]\nreader.dmLevel = wave\nwriter.dmLevel = jitterShimmer\n// nameAppend =\ncopyInputName = 1\nF0reader.dmLevel = pitchF\nF0field = F0final\nsearchRangeRel = 0.250000\njitterLocal = 1\njitterDDP = 1\njitterLocalEnv = 0\njitterDDPEnv = 0\nshimmerLocal = 1\nshimmerLocalEnv = 0\nonlyVoiced = 0\n;periodLengths = 0\n;periodStarts = 0\nuseBrokenJitterThresh = 1\n\n;;;;;;;;;;;;;;;;;;;;; Energy / loudness\n\n\n[componentInstances:cComponentManager]\ninstance[energy].type=cEnergy\ninstance[melspec1].type=cMelspec\ninstance[audspec].type=cPlp\ninstance[audspecRasta].type=cPlp\ninstance[audspecSum].type=cVectorOperation\ninstance[audspecRastaSum].type=cVectorOperation\n\n\n[energy:cEnergy]\nreader.dmLevel = frame25\nwriter.dmLevel = energy\nlog=0\nrms=1\n\n\n[melspec1:cMelspec]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=melspec1\n; htk compatible sample value scaling\nhtkcompatible = 0\nnBands = 26\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 20\nhifreq = 8000\nspecScale = mel\n\n; perform auditory weighting of spectrum\n[audspec:cPlp]\nreader.dmLevel=melspec1\nwriter.dmLevel=audspec\nfirstCC = 0\nlpOrder = 5\ncepLifter = 22\ncompression = 0.33\nhtkcompatible = 0 \ndoIDFT = 0\ndoLpToCeps = 0\ndoLP = 0\ndoInvLog = 0\ndoAud = 1\ndoLog = 0\nnewRASTA=0\nRASTA=0\n\n; perform RASTA style filtering of auditory spectra\n[audspecRasta:cPlp]\nreader.dmLevel=melspec1\nwriter.dmLevel=audspecRasta\nnameAppend = Rfilt\nfirstCC = 0\nlpOrder = 5\ncepLifter = 22\ncompression = 0.33\nhtkcompatible = 0 \ndoIDFT = 0\ndoLpToCeps = 0\ndoLP = 0\ndoInvLog = 0\ndoAud = 1\ndoLog = 0\nnewRASTA=1\nRASTA=0\n\n[audspecSum:cVectorOperation]\nreader.dmLevel = audspec\nwriter.dmLevel = audspecSum\n// nameAppend = \ncopyInputName = 1\nprocessArrayFields = 0\noperation = ll1\nnameBase = audspec\n\n[audspecRastaSum:cVectorOperation]\nreader.dmLevel = audspecRasta\nwriter.dmLevel = audspecRastaSum\n// nameAppend = \ncopyInputName = 1\nprocessArrayFields = 0\noperation = ll1\nnameBase = audspecRasta\n\n;;;;;;;;;;;;;;; spectral\n\n[componentInstances:cComponentManager]\ninstance[spectral].type=cSpectral\n\n\n[spectral:cSpectral]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=spectral\nbands[0]=25-650\nbands[1]=1000-4000\nrollOff[0] = 0.25\nrollOff[1] = 0.50\nrollOff[2] = 0.75\nrollOff[3] = 0.90\nflux=1\ncentroid=0\nmaxPos=0\nminPos=0\nentropy=1\nvariance=1\nskewness=1\nkurtosis=1\nslope=1\n\n\n;;;;;;;;;;;;;;; mfcc\n\n[componentInstances:cComponentManager]\ninstance[melspecMfcc].type=cMelspec\ninstance[mfcc].type=cMfcc\n\n[melspecMfcc:cMelspec]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=melspecMfcc\ncopyInputName = 1\nprocessArrayFields = 1\n; htk compatible sample value scaling\nhtkcompatible = 1\nnBands = 26s\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 20\nhifreq = 8000\nspecScale = mel\ninverse = 0\n\n[mfcc:cMfcc]\nreader.dmLevel=melspecMfcc\nwriter.dmLevel=mfcc1_12\ncopyInputName = 1\nprocessArrayFields = 1\nfirstMfcc = 1\nlastMfcc  = 12\ncepLifter = 22.0\nhtkcompatible = 1\n\n\n;;;;;;;;;;;;;;;;  zcr\n\n[componentInstances:cComponentManager]\ninstance[mzcr].type=cMZcr\n\n[mzcr:cMZcr]\nreader.dmLevel = frame25\nwriter.dmLevel = zcr\ncopyInputName = 1\nprocessArrayFields = 1\nzcr = 1\nmcr = 0\namax = 0\nmaxmin = 0\ndc = 0\n\n\n\n;;;;;;;;;;;;;;;;;;;; smoothing\n\n[componentInstances:cComponentManager]\ninstance[smoNz].type=cContourSmoother\ninstance[smoA].type=cContourSmoother\ninstance[smoB].type=cContourSmoother\ninstance[f0sel].type=cDataSelector\n\n[smoNz:cContourSmoother]\nreader.dmLevel = pitchG60;jitterShimmer\nwriter.dmLevel = lld_nzsmo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\nnoZeroSma = 1\n\n[f0sel:cDataSelector]\nreader.dmLevel = lld_nzsmo\nwriter.dmLevel = lld_f0_nzsmo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = ff0\nselected = F0final_sma\n\n[smoA:cContourSmoother]\nreader.dmLevel = audspecSum;audspecRastaSum;energy;zcr\nwriter.dmLevel = lldA_smo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n[smoB:cContourSmoother]\nreader.dmLevel = audspecRasta;spectral;mfcc1_12\nwriter.dmLevel = lldB_smo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n;;;;;;;;; deltas\n[componentInstances:cComponentManager]\ninstance[deNz].type=cDeltaRegression\ninstance[deA].type=cDeltaRegression\ninstance[deB].type=cDeltaRegression\ninstance[def0sel].type=cDeltaRegression\n\n[deNz:cDeltaRegression]\nreader.dmLevel = lld_nzsmo\nwriter.dmLevel = lld_nzsmo_de\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n[deA:cDeltaRegression]\nreader.dmLevel = lldA_smo\nwriter.dmLevel = lldA_smo_de\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n[deB:cDeltaRegression]\nreader.dmLevel = lldB_smo\nwriter.dmLevel = lldB_smo_de\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n[def0sel:cDeltaRegression]\nreader.dmLevel = lld_f0_nzsmo\nwriter.dmLevel = lld_f0_nzsmo_de\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n;;;;;;;;; functionals / statistics\n\n\n[componentInstances:cComponentManager]\ninstance[functionalsA].type=cFunctionals\ninstance[functionalsB].type=cFunctionals\ninstance[functionalsF0].type=cFunctionals\ninstance[functionalsNz].type=cFunctionals\n\n\n; functionals for energy related lld\n[functionalsA:cFunctionals]\nreader.dmLevel = lldA_smo;lldA_smo_de\nwriter.dmLevel = functionalsA\n// nameAppend = \ncopyInputName = 1\nframeMode = full\nframeSize = 0\nframeStep = 0\nframeCenterSpecial = left\n\nfunctionalsEnabled = Percentiles ; Means ; Moments ; Peaks ; Segments ; Regression ; Times ;  Lpc\n\nMeans.amean = 1\nMeans.absmean = 0\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\n\nPeaks.numPeaks = 0\nPeaks.meanPeakDist = 1\nPeaks.peakMean = 1\nPeaks.peakMeanMeanDist = 1\nPeaks.peakDistStddev = 1\nPeaks.norm = second\n\nSegments.maxNumSeg = 100\nSegments.segmentationAlgorithm = relTh\nSegments.thresholds = 0.25\nSegments.numSegments = 0\nSegments.meanSegLen = 1\nSegments.maxSegLen = 1\nSegments.minSegLen = 1\nSegments.segLenStddev = 1\nSegments.norm = second\n\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nMoments.doRatioLimit = 0\n\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\n\nRegression.linregc1 = 1\nRegression.linregc2 = 0\nRegression.linregerrA = 0\nRegression.linregerrQ = 1\nRegression.qregc1 = 1\nRegression.qregc2 = 1\nRegression.qregc3 = 0\nRegression.qregerrA = 0\nRegression.qregerrQ = 1\nRegression.oldBuggyQerr = 0\nRegression.centroid = 1\nRegression.normRegCoeff = 0\nRegression.doRatioLimit = 0\nRegression.centroidRatioLimit = 0\nRegression.centroidUseAbsValues = 0\n\nTimes.upleveltime25 = 0\nTimes.downleveltime25 = 1\nTimes.upleveltime50 = 0\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 1\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.buggySecNorm = 0\nTimes.norm = segment\n\nLpc.lpGain = 1\nLpc.lpc = 1\nLpc.firstCoeff = 0\nLpc.order = 5\n\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n\n; functionals for spectrum related lld\n[functionalsB:cFunctionals]\nreader.dmLevel = lldB_smo;lldB_smo_de\nwriter.dmLevel = functionalsB\n// nameAppend = \ncopyInputName = 1\nframeMode = full\nframeSize = 0\nframeStep = 0\nframeCenterSpecial = left\n\nfunctionalsEnabled = Percentiles ; Means ; Moments ; Peaks ; Segments ; Regression ; Times ;  Lpc\n\nMeans.amean = 1\nMeans.absmean = 0\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\n\nPeaks.numPeaks = 0\nPeaks.meanPeakDist = 1\nPeaks.peakMean = 1\nPeaks.peakMeanMeanDist = 1\nPeaks.peakDistStddev = 1\nPeaks.norm = second\n\nSegments.maxNumSeg = 100\nSegments.segmentationAlgorithm = relTh\nSegments.thresholds = 0.25 ; 0.75\nSegments.rangeRelThreshold = 0.200000\nSegments.numSegments = 0\nSegments.meanSegLen = 1\nSegments.maxSegLen = 1\nSegments.minSegLen = 1\nSegments.segLenStddev = 1\nSegments.norm = second\n\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nMoments.doRatioLimit = 0\n\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\n\nRegression.linregc1 = 1\nRegression.linregc2 = 0\nRegression.linregerrA = 0\nRegression.linregerrQ = 1\nRegression.qregc1 = 1\nRegression.qregc2 = 1\nRegression.qregc3 = 0\nRegression.qregerrA = 0\nRegression.qregerrQ = 1\nRegression.oldBuggyQerr = 0\nRegression.centroid = 1\nRegression.normRegCoeff = 0\nRegression.doRatioLimit = 0\nRegression.centroidRatioLimit = 0\nRegression.centroidUseAbsValues = 0\n\nTimes.upleveltime25 = 0\nTimes.downleveltime25 = 1\nTimes.upleveltime50 = 0\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 1\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.buggySecNorm = 0\nTimes.norm = segment\n\nLpc.lpGain = 1\nLpc.lpc = 1\nLpc.firstCoeff = 0\nLpc.order = 5\n\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n\n; functionals for pitch onsets/offsets\n[functionalsF0:cFunctionals]\nreader.dmLevel = lld_f0_nzsmo;lld_f0_nzsmo_de\nwriter.dmLevel = functionalsF0\ncopyInputName = 1\nframeMode = full\nframeSize = 0\nframeStep = 0\nframeCenterSpecial = left\n\nfunctionalsEnabled = Means ; Segments ; Times\n\nMeans.amean = 0\nMeans.absmean = 0\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 1\nMeans.norm = segment\n\nSegments.maxNumSeg = 100\nSegments.segmentationAlgorithm = nonX\nSegments.X = 0.0\nSegments.numSegments = 0\nSegments.meanSegLen = 1\nSegments.maxSegLen = 1\nSegments.minSegLen = 1\nSegments.segLenStddev = 1\nSegments.norm = second\n\nTimes.upleveltime25 = 0\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 0\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 0\nTimes.downleveltime90 = 0\nTimes.risetime = 0\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 1\nTimes.buggySecNorm = 0\nTimes.norm = second\n\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n\n; functionals for pitch and vq related lld in voiced regions\n[functionalsNz:cFunctionals]\nreader.dmLevel = lld_nzsmo;lld_nzsmo_de\nwriter.dmLevel = functionalsNz\ncopyInputName = 1\nframeMode = full\nframeSize = 0\nframeStep = 0\nframeCenterSpecial = left\n\nfunctionalsEnabled = Percentiles ; Means ; Moments ; Peaks ; Regression ; Times ; Lpc\n\nMeans.amean = 1\nMeans.absmean = 0\nMeans.qmean = 1\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\n\nPeaks.numPeaks = 0\nPeaks.meanPeakDist = 1\nPeaks.peakMean = 1\nPeaks.peakMeanMeanDist = 1\nPeaks.peakDistStddev = 1\nPeaks.norm = second\n\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nMoments.doRatioLimit = 0\n\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\n\nRegression.linregc1 = 1\nRegression.linregc2 = 0\nRegression.linregerrA = 0\nRegression.linregerrQ = 1\nRegression.qregc1 = 1\nRegression.qregc2 = 1\nRegression.qregc3 = 0\nRegression.qregerrA = 0\nRegression.qregerrQ = 1\nRegression.oldBuggyQerr = 0\nRegression.centroid = 1\nRegression.normRegCoeff = 0\nRegression.centroidRatioLimit = 0\nRegression.centroidUseAbsValues = 0\nRegression.doRatioLimit = 0\n\nTimes.upleveltime25 = 0\nTimes.downleveltime25 = 1\nTimes.upleveltime50 = 0\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 1\nTimes.leftctime = 1\nTimes.rightctime = 1\nTimes.duration = 0\nTimes.buggySecNorm = 0\nTimes.norm = segment\n\nLpc.lpGain = 1\nLpc.lpc = 1\nLpc.firstCoeff = 0\nLpc.order = 5\n\nnonZeroFuncts = 1\nmasterTimeNorm = segment\n\n;;;;;;;;; prepare features for standard output module\n\n[componentInstances:cComponentManager]\ninstance[lldconcat].type=cVectorConcat\ninstance[llddeconcat].type=cVectorConcat\ninstance[funcconcat].type=cVectorConcat\n\n[lldconcat:cVectorConcat]\nreader.dmLevel = lld_nzsmo;lldA_smo;lldB_smo\nwriter.dmLevel = lld\nincludeSingleElementFields = 1\n\n[llddeconcat:cVectorConcat]\nreader.dmLevel = lld_nzsmo_de;lldA_smo_de;lldB_smo_de\nwriter.dmLevel = lld_de\nincludeSingleElementFields = 1\n\n[funcconcat:cVectorConcat]\nreader.dmLevel = functionalsA;functionalsB;functionalsNz;functionalsF0\nwriter.dmLevel = func\nincludeSingleElementFields = 1\n\n\\{shared/standard_data_output.conf.inc}\n\n\n"
  },
  {
    "path": "config/IS12_speaker_trait.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\r\n///////// > openSMILE configuration file for IS12 features <         //////////////////\r\n/////////                                                            //////////////////\r\n///////// (c) 2013-2016 by audEERING                                 //////////////////\r\n/////////     All rights reserved. See file COPYING for details.     //////////////////\r\n///////////////////////////////////////////////////////////////////////////////////////\r\n\r\n// This version is an updated version which contains some fixes\r\n// The feature are not compatible with the original IS12 features, but should\r\n// be preferred in new designes / studies.\r\n// Use IS12_speaker_trait_compat.conf for numerically compatible features\r\n\r\n\r\n;;;;;;; component list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[dataMemory].type=cDataMemory\r\nprintLevelStats=0\r\n\r\n\r\n;;;;;;;;;;;;;;;;;;;;;;;;;;;; main section ;;;;;;;;;;;;;;;;;;;;;;;;;;;\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[waveIn].type=cWaveSource\r\n\r\n[waveIn:cWaveSource]\r\nwriter.dmLevel=wave\r\nfilename=\\cm[inputfile(I){test.wav}:name of input file]\r\nmonoMixdown=1\r\n\r\n;;;;;;;;;;;;;;;;;;;;;;\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[frame60].type=cFramer\r\ninstance[win60].type=cWindower\r\ninstance[fft60].type=cTransformFFT\r\ninstance[fftmp60].type=cFFTmagphase\r\n\r\n[frame60:cFramer]\r\nreader.dmLevel=wave\r\nwriter.dmLevel=frame60\r\nframeSize = 0.060\r\nframeStep = 0.010\r\nframeCenterSpecial = left\r\n\r\n\r\n[win60:cWindower]\r\nreader.dmLevel=frame60\r\nwriter.dmLevel=winG60\r\nwinFunc=gauss\r\ngain=1.0\r\nsigma=0.4\r\n\r\n[fft60:cTransformFFT]\r\nreader.dmLevel=winG60\r\nwriter.dmLevel=fftcG60\r\n ; for compatibility with 2.2.0 and older versions\r\nzeroPadSymmetric = 0\r\n\r\n[fftmp60:cFFTmagphase]\r\nreader.dmLevel=fftcG60\r\nwriter.dmLevel=fftmagG60\r\n\r\n\r\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[frame25].type=cFramer\r\ninstance[pe25].type=cVectorPreemphasis\r\ninstance[win25].type=cWindower\r\ninstance[fft25].type=cTransformFFT\r\ninstance[fftmp25].type=cFFTmagphase\r\n\r\n[frame25:cFramer]\r\nreader.dmLevel=wave\r\nwriter.dmLevel=frame25\r\nframeSize = 0.020\r\nframeStep = 0.010\r\nframeCenterSpecial = left\r\n\r\n[pe25:cVectorPreemphasis]\r\nreader.dmLevel=frame25\r\nwriter.dmLevel=frame25pe\r\nk=0.97\r\nde=0\r\n\r\n[win25:cWindower]\r\nreader.dmLevel=frame25\r\nwriter.dmLevel=winH25\r\nwinFunc=hamming\r\n\r\n[fft25:cTransformFFT]\r\nreader.dmLevel=winH25\r\nwriter.dmLevel=fftcH25\r\n ; for compatibility with 2.2.0 and older versions\r\nzeroPadSymmetric = 0\r\n\r\n[fftmp25:cFFTmagphase]\r\nreader.dmLevel=fftcH25\r\nwriter.dmLevel=fftmagH25\r\n\r\n\r\n\r\n;;;;;;;;;;;;;;;;;;;; HPS pitch\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[scale].type=cSpecScale\r\ninstance[shs].type=cPitchShs\r\n\r\n[scale:cSpecScale]\r\nreader.dmLevel=fftmagG60\r\nwriter.dmLevel=hpsG60\r\ncopyInputName = 1\r\nprocessArrayFields = 0\r\nscale=octave\r\nsourceScale = lin\r\n// logScaleBase = 2\r\n// logSourceScaleBase = 2\r\n// firstNote = 55\r\ninterpMethod = spline\r\nminF = 25\r\nmaxF = -1\r\nnPointsTarget = 0\r\nspecSmooth = 1\r\nspecEnhance = 1\r\nauditoryWeighting = 1 \r\n\r\n[shs:cPitchShs]\r\nreader.dmLevel=hpsG60\r\nwriter.dmLevel=pitchShsG60\r\nwriter.levelconf.nT=100\r\ncopyInputName = 1\r\nprocessArrayFields = 0\r\nmaxPitch = 620\r\nminPitch = 52\r\nnCandidates = 4\r\nscores = 1\r\nvoicing = 1\r\nF0C1 = 0\r\nvoicingC1 = 0\r\nF0raw = 1\r\nvoicingClip = 1\r\nvoicingCutoff = 0.700000\r\ninputFieldSearch = Mag_octScale\r\noctaveCorrection = 0\r\nnHarmonics = 15\r\ncompressionFactor = 0.850000\r\n\r\n; TODO: Viterbi smoothing with volume clipping!\r\n;;;;; Pitch with Viterbi smoother\r\n[componentInstances:cComponentManager]\r\ninstance[energy60].type=cEnergy\r\n\r\n[energy60:cEnergy]\r\nreader.dmLevel=winG60\r\nwriter.dmLevel=e60\r\n ; This must be > than buffersize of viterbi smoother\r\nwriter.levelconf.nT=100\r\nrms=1\r\nlog=0\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[pitchSmoothViterbi].type=cPitchSmootherViterbi\r\n\r\n[pitchSmoothViterbi:cPitchSmootherViterbi]\r\nreader.dmLevel=pitchShsG60\r\nreader2.dmLevel=pitchShsG60\r\nwriter.dmLevel=pitchG60_viterbi\r\ncopyInputName = 1\r\nbufferLength=30\r\nF0final = 1\r\nF0finalEnv = 0\r\nvoicingFinalClipped = 0\r\nvoicingFinalUnclipped = 1\r\nF0raw = 0\r\nvoicingC1 = 0\r\nvoicingClip = 0\r\nwTvv=14.0\r\n;wTvv=10.0\r\nwTvuv=25.0\r\nwRange=2.0\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[volmerge].type = cValbasedSelector\r\n\r\n[volmerge:cValbasedSelector]\r\nreader.dmLevel = e60;pitchG60_viterbi\r\nwriter.dmLevel = pitchG60\r\nidx=0\r\nthreshold=0.005\r\nremoveIdx=1\r\nzeroVec=1\r\noutputVal=0.0\r\n\r\n\r\n;;;;;;;;;;;;;;;;;;;;; Energy / loudness\r\n\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[energy].type=cEnergy\r\ninstance[melspec1].type=cMelspec\r\ninstance[audspec].type=cPlp\r\ninstance[audspecRasta].type=cPlp\r\ninstance[audspecSum].type=cVectorOperation\r\ninstance[audspecRastaSum].type=cVectorOperation\r\n\r\n\r\n[energy:cEnergy]\r\nreader.dmLevel = frame25\r\nwriter.dmLevel = energy\r\nlog=0\r\nrms=1\r\n\r\n\r\n[melspec1:cMelspec]\r\nreader.dmLevel=fftmagH25\r\nwriter.dmLevel=melspec1\r\n; htk compatible sample value scaling\r\nhtkcompatible = 0\r\nnBands = 26\r\n; use power spectrum instead of magnitude spectrum\r\nusePower = 1\r\nlofreq = 20\r\nhifreq = 8000\r\nspecScale = mel\r\n\r\n; perform auditory weighting of spectrum\r\n[audspec:cPlp]\r\nreader.dmLevel=melspec1\r\nwriter.dmLevel=audspec\r\nfirstCC = 0\r\nlpOrder = 5\r\ncepLifter = 22\r\ncompression = 0.33\r\nhtkcompatible = 0 \r\ndoIDFT = 0\r\ndoLpToCeps = 0\r\ndoLP = 0\r\ndoInvLog = 0\r\ndoAud = 1\r\ndoLog = 0\r\nnewRASTA=0\r\nRASTA=0\r\n\r\n; perform RASTA style filtering of auditory spectra\r\n[audspecRasta:cPlp]\r\nreader.dmLevel=melspec1\r\nwriter.dmLevel=audspecRasta\r\nnameAppend = Rfilt\r\nfirstCC = 0\r\nlpOrder = 5\r\ncepLifter = 22\r\ncompression = 0.33\r\nhtkcompatible = 0 \r\ndoIDFT = 0\r\ndoLpToCeps = 0\r\ndoLP = 0\r\ndoInvLog = 0\r\ndoAud = 1\r\ndoLog = 0\r\nnewRASTA=1\r\nRASTA=0\r\n\r\n[audspecSum:cVectorOperation]\r\nreader.dmLevel = audspec\r\nwriter.dmLevel = audspecSum\r\n// nameAppend = \r\ncopyInputName = 1\r\nprocessArrayFields = 0\r\noperation = ll1\r\nnameBase = audspec\r\n\r\n[audspecRastaSum:cVectorOperation]\r\nreader.dmLevel = audspecRasta\r\nwriter.dmLevel = audspecRastaSum\r\n// nameAppend = \r\ncopyInputName = 1\r\nprocessArrayFields = 0\r\noperation = ll1\r\nnameBase = audspecRasta\r\n\r\n;;;;;;;;;;;;;;; spectral\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[spectral].type=cSpectral\r\n\r\n\r\n[spectral:cSpectral]\r\nreader.dmLevel=fftmagH25\r\nwriter.dmLevel=spectral\r\nbands[0]=250-650\r\nbands[1]=1000-4000\r\nrollOff[0] = 0.25\r\nrollOff[1] = 0.50\r\nrollOff[2] = 0.75\r\nrollOff[3] = 0.90\r\nflux=1\r\ncentroid=0\r\nmaxPos=0\r\nminPos=0\r\nentropy=1\r\nvariance=1\r\nskewness=1\r\nkurtosis=1\r\nslope=1\r\nharmonicity=1\r\nsharpness=1\r\n\r\n\r\n;;;;;;;;;;;;;;; mfcc\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[melspecMfcc].type=cMelspec\r\ninstance[mfcc].type=cMfcc\r\n\r\n[melspecMfcc:cMelspec]\r\nreader.dmLevel=fftmagH25\r\nwriter.dmLevel=melspecMfcc\r\ncopyInputName = 1\r\nprocessArrayFields = 1\r\n; htk compatible sample value scaling\r\nhtkcompatible = 1\r\nnBands = 26s\r\n; use power spectrum instead of magnitude spectrum\r\nusePower = 1\r\nlofreq = 20\r\nhifreq = 8000\r\nspecScale = mel\r\ninverse = 0\r\n\r\n[mfcc:cMfcc]\r\nreader.dmLevel=melspecMfcc\r\nwriter.dmLevel=mfcc1_12\r\ncopyInputName = 1\r\nprocessArrayFields = 1\r\nfirstMfcc = 1\r\nlastMfcc  = 14\r\ncepLifter = 22.0\r\nhtkcompatible = 1\r\n\r\n\r\n;;;;;;;;;;;;;;;;  zcr\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[mzcr].type=cMZcr\r\n\r\n[mzcr:cMZcr]\r\nreader.dmLevel = frame25\r\nwriter.dmLevel = zcr\r\ncopyInputName = 1\r\nprocessArrayFields = 1\r\nzcr = 1\r\nmcr = 0\r\namax = 0\r\nmaxmin = 0\r\ndc = 0\r\n\r\n\r\n;;;;;;;;;;;;;;;;; rasta-plp ?\r\n\r\n;;;;;;;;;;;;;;;;;;;; smoothing\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[smoNz].type=cContourSmoother\r\ninstance[smoA].type=cContourSmoother\r\ninstance[smoB].type=cContourSmoother\r\ninstance[f0sel].type=cDataSelector\r\n\r\n[smoNz:cContourSmoother]\r\nreader.dmLevel = pitchG60\r\nwriter.dmLevel = lld_nzsmo\r\nwriter.levelconf.isRb=0\r\nwriter.levelconf.growDyn=1\r\nnameAppend = sma\r\ncopyInputName = 1\r\nnoPostEOIprocessing = 0\r\nsmaWin = 3\r\nnoZeroSma = 1\r\n\r\n[f0sel:cDataSelector]\r\nreader.dmLevel = lld_nzsmo\r\nwriter.dmLevel = lld_f0_nzsmo\r\nwriter.levelconf.isRb=0\r\nwriter.levelconf.growDyn=1\r\nnameAppend = ff0\r\nselected = F0final_sma\r\n\r\n[smoA:cContourSmoother]\r\nreader.dmLevel = audspecSum;audspecRastaSum;energy;zcr\r\nwriter.dmLevel = lldA_smo\r\nwriter.levelconf.isRb=0\r\nwriter.levelconf.growDyn=1\r\nnameAppend = sma\r\ncopyInputName = 1\r\nnoPostEOIprocessing = 0\r\nsmaWin = 3\r\n\r\n[smoB:cContourSmoother]\r\nreader.dmLevel = audspecRasta;spectral;mfcc1_12\r\nwriter.dmLevel = lldB_smo\r\nwriter.levelconf.isRb=0\r\nwriter.levelconf.growDyn=1\r\nnameAppend = sma\r\ncopyInputName = 1\r\nnoPostEOIprocessing = 0\r\nsmaWin = 3\r\n\r\n;;;;;;;;; deltas\r\n[componentInstances:cComponentManager]\r\ninstance[deNz].type=cDeltaRegression\r\ninstance[deA].type=cDeltaRegression\r\ninstance[deB].type=cDeltaRegression\r\ninstance[def0sel].type=cDeltaRegression\r\n\r\n[deNz:cDeltaRegression]\r\nreader.dmLevel = lld_nzsmo\r\nwriter.dmLevel = lld_nzsmo_de\r\nwriter.levelconf.isRb=0\r\nwriter.levelconf.growDyn=1\r\nonlyInSegments = 1\r\n\r\n[deA:cDeltaRegression]\r\nreader.dmLevel = lldA_smo\r\nwriter.dmLevel = lldA_smo_de\r\nwriter.levelconf.isRb=0\r\nwriter.levelconf.growDyn=1\r\n\r\n[deB:cDeltaRegression]\r\nreader.dmLevel = lldB_smo\r\nwriter.dmLevel = lldB_smo_de\r\nwriter.levelconf.isRb=0\r\nwriter.levelconf.growDyn=1\r\n\r\n[def0sel:cDeltaRegression]\r\nreader.dmLevel = lld_f0_nzsmo\r\nwriter.dmLevel = lld_f0_nzsmo_de\r\nwriter.levelconf.isRb=0\r\nwriter.levelconf.growDyn=1\r\n\r\n;;;;;;;;; functionals / statistics\r\n\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[functionalsA].type=cFunctionals\r\ninstance[functionalsB].type=cFunctionals\r\ninstance[functionalsF0].type=cFunctionals\r\ninstance[functionalsNz].type=cFunctionals\r\n\r\n; shared functionals for LLD\r\ninstance[functionalsLLD].type=cFunctionals\r\n\r\n; shared functionals for Delta LLD\r\ninstance[functionalsDelta].type=cFunctionals\r\n\r\n\r\n; functionals for energy related lld\r\n[functionalsA:cFunctionals]\r\nreader.dmLevel = lldA_smo;lldA_smo_de\r\nwriter.dmLevel = functionalsA\r\n// nameAppend = \r\ncopyInputName = 1\r\nframeMode = full\r\nframeSize = 0\r\nframeStep = 0\r\nframeCenterSpecial = left\r\n\r\nfunctionalsEnabled = Extremes ; Percentiles ; Moments ; Segments ; Times ;  Lpc\r\n\r\nExtremes.max = 0\r\nExtremes.min = 0\r\nExtremes.maxpos = 1\r\nExtremes.minpos = 1\r\nExtremes.maxameandist = 0\r\nExtremes.minameandist = 0\r\nExtremes.range = 1\r\nExtremes.norm = segment\r\n\r\nSegments.maxNumSeg = 100\r\nSegments.segmentationAlgorithm = relTh\r\nSegments.thresholds = 0.25\r\nSegments.numSegments = 0\r\nSegments.meanSegLen = 1\r\nSegments.maxSegLen = 1\r\nSegments.minSegLen = 1\r\nSegments.segLenStddev = 1\r\nSegments.norm = second\r\n\r\nMoments.variance = 0\r\nMoments.stddev = 1\r\nMoments.skewness = 1\r\nMoments.kurtosis = 1\r\nMoments.amean = 0\r\nMoments.doRatioLimit = 0\r\n\r\nPercentiles.quartiles = 1\r\nPercentiles.iqr = 1\r\nPercentiles.percentile[0] = 0.01\r\nPercentiles.percentile[1] = 0.99\r\nPercentiles.pctlrange[0] = 0-1\r\nPercentiles.interp = 1\r\n\r\nTimes.upleveltime25 = 1\r\nTimes.downleveltime25 = 1\r\nTimes.upleveltime50 = 1\r\nTimes.downleveltime50 = 1\r\nTimes.upleveltime75 = 1\r\nTimes.downleveltime75 = 1\r\nTimes.upleveltime90 = 1\r\nTimes.downleveltime90 = 1\r\nTimes.risetime = 1\r\nTimes.falltime = 1\r\nTimes.leftctime = 0\r\nTimes.rightctime = 0\r\nTimes.duration = 0\r\nTimes.buggySecNorm = 0\r\nTimes.norm = segment\r\n\r\nLpc.lpGain = 1\r\nLpc.lpc = 1\r\nLpc.firstCoeff = 0\r\nLpc.order = 5\r\n\r\nnonZeroFuncts = 0\r\nmasterTimeNorm = segment\r\n\r\n\r\n\r\n; functionals for spectrum related lld\r\n[functionalsB:cFunctionals]\r\nreader.dmLevel = lldB_smo;lldB_smo_de\r\nwriter.dmLevel = functionalsB\r\n// nameAppend = \r\ncopyInputName = 1\r\nframeMode = full\r\nframeSize = 0\r\nframeStep = 0\r\nframeCenterSpecial = left\r\n\r\nfunctionalsEnabled = Extremes ; Percentiles ; Moments ; Segments ; Times ;  Lpc\r\n\r\nExtremes.max = 0\r\nExtremes.min = 0\r\nExtremes.maxpos = 1\r\nExtremes.minpos = 1\r\nExtremes.maxameandist = 0\r\nExtremes.minameandist = 0\r\n\r\nSegments.maxNumSeg = 100\r\nSegments.segmentationAlgorithm = relTh\r\nSegments.thresholds = 0.25 ; 0.75\r\nSegments.rangeRelThreshold = 0.200000\r\nSegments.numSegments = 0\r\nSegments.meanSegLen = 1\r\nSegments.maxSegLen = 1\r\nSegments.minSegLen = 1\r\nSegments.segLenStddev = 1\r\nSegments.norm = second\r\n\r\nMoments.variance = 0\r\nMoments.stddev = 1\r\nMoments.skewness = 1\r\nMoments.kurtosis = 1\r\nMoments.amean = 0\r\nMoments.doRatioLimit = 0\r\n\r\nPercentiles.quartiles = 1\r\nPercentiles.iqr = 1\r\nPercentiles.percentile[0] = 0.01\r\nPercentiles.percentile[1] = 0.99\r\nPercentiles.pctlrange[0] = 0-1\r\nPercentiles.interp = 1\r\n\r\nTimes.upleveltime25 = 1\r\nTimes.downleveltime25 = 1\r\nTimes.upleveltime50 = 1\r\nTimes.downleveltime50 = 1\r\nTimes.upleveltime75 = 1\r\nTimes.downleveltime75 = 1\r\nTimes.upleveltime90 = 1\r\nTimes.downleveltime90 = 1\r\nTimes.risetime = 1\r\nTimes.falltime = 1\r\nTimes.leftctime = 0\r\nTimes.rightctime = 0\r\nTimes.duration = 0\r\nTimes.buggySecNorm = 0\r\nTimes.norm = segment\r\n\r\nLpc.lpGain = 1\r\nLpc.lpc = 1\r\nLpc.firstCoeff = 0\r\nLpc.order = 5\r\n\r\nnonZeroFuncts = 0\r\nmasterTimeNorm = segment\r\n\r\n\r\n\r\n; functionals for pitch onsets/offsets\r\n[functionalsF0:cFunctionals]\r\nreader.dmLevel = lld_f0_nzsmo\r\nwriter.dmLevel = functionalsF0\r\n//nameAppend = ff0\r\ncopyInputName = 1\r\nframeMode = full\r\nframeSize = 0\r\nframeStep = 0\r\nframeCenterSpecial = left\r\n\r\nfunctionalsEnabled = Means ; Segments ; Times\r\n\r\nMeans.amean = 0\r\nMeans.absmean = 0\r\nMeans.qmean = 0\r\nMeans.nzamean = 0\r\nMeans.nzabsmean = 0\r\nMeans.nzqmean = 0\r\nMeans.nzgmean = 0\r\nMeans.nnz = 1\r\nMeans.norm = segment\r\n\r\nSegments.maxNumSeg = 100\r\nSegments.segmentationAlgorithm = nonX\r\nSegments.X = 0.0\r\nSegments.numSegments = 0\r\nSegments.meanSegLen = 1\r\nSegments.maxSegLen = 1\r\nSegments.minSegLen = 1\r\nSegments.segLenStddev = 1\r\nSegments.norm = second\r\n\r\nTimes.upleveltime25 = 0\r\nTimes.downleveltime25 = 0\r\nTimes.upleveltime50 = 0\r\nTimes.downleveltime50 = 0\r\nTimes.upleveltime75 = 0\r\nTimes.downleveltime75 = 0\r\nTimes.upleveltime90 = 0\r\nTimes.downleveltime90 = 0\r\nTimes.risetime = 0\r\nTimes.falltime = 0\r\nTimes.leftctime = 0\r\nTimes.rightctime = 0\r\nTimes.duration = 0\r\nTimes.buggySecNorm = 0\r\nTimes.norm = second\r\n\r\nnonZeroFuncts = 0\r\nmasterTimeNorm = segment\r\n\r\n\r\n\r\n; functionals for pitch and vq related lld in voiced regions\r\n[functionalsNz:cFunctionals]\r\nreader.dmLevel = lld_nzsmo;lld_nzsmo_de\r\nwriter.dmLevel = functionalsNz\r\n// nameAppend = \r\ncopyInputName = 1\r\nframeMode = full\r\nframeSize = 0\r\nframeStep = 0\r\nframeCenterSpecial = left\r\n\r\nfunctionalsEnabled = Extremes ; Percentiles ; Moments ; Times ; Lpc\r\n\r\n\r\nExtremes.max = 0\r\nExtremes.min = 0\r\nExtremes.maxpos = 1\r\nExtremes.minpos = 1\r\nExtremes.maxameandist = 0\r\nExtremes.minameandist = 0\r\nExtremes.range = 1\r\n\r\nMoments.variance = 0\r\nMoments.stddev = 1\r\nMoments.skewness = 1\r\nMoments.kurtosis = 1\r\nMoments.amean = 0\r\nMoments.doRatioLimit = 0\r\n\r\nPercentiles.quartiles = 1\r\nPercentiles.iqr = 1\r\nPercentiles.percentile[0] = 0.01\r\nPercentiles.percentile[1] = 0.99\r\nPercentiles.pctlrange[0] = 0-1\r\nPercentiles.interp = 1\r\n\r\nTimes.upleveltime25 = 1\r\nTimes.downleveltime25 = 1\r\nTimes.upleveltime50 = 1\r\nTimes.downleveltime50 = 1\r\nTimes.upleveltime75 = 1\r\nTimes.downleveltime75 = 1\r\nTimes.upleveltime90 = 1\r\nTimes.downleveltime90 = 1\r\nTimes.risetime = 1\r\nTimes.falltime = 1\r\nTimes.leftctime = 1\r\nTimes.rightctime = 1\r\nTimes.duration = 0\r\nTimes.buggySecNorm = 0\r\nTimes.norm = segment\r\n\r\nLpc.lpGain = 1\r\nLpc.lpc = 1\r\nLpc.firstCoeff = 0\r\nLpc.order = 5\r\n\r\nnonZeroFuncts = 1\r\nmasterTimeNorm = segment\r\n\r\n\r\n\r\n[functionalsLLD:cFunctionals]\r\nreader.dmLevel = lldA_smo;lldB_smo;lld_nzsmo\r\nwriter.dmLevel = functionalsLLD\r\n\r\ncopyInputName = 1\r\nframeMode = full\r\nframeSize = 0\r\nframeStep = 0\r\nframeCenterSpecial = left\r\n\r\nfunctionalsEnabled = Means ; Peaks2 ; Regression\r\n\r\nMeans.amean = 1\r\nMeans.posamean = 0\r\nMeans.absmean = 0\r\nMeans.qmean = 0\r\nMeans.rqmean = 1\r\nMeans.nzamean = 0\r\nMeans.nzabsmean = 0\r\nMeans.nzqmean = 0\r\nMeans.posrqmean = 0\r\nMeans.nzgmean = 0\r\nMeans.nnz = 0\r\nMeans.flatness = 1\r\nMeans.norm = frames\r\n\r\nRegression.linregc1 = 1\r\nRegression.linregc2 = 1\r\nRegression.linregerrA = 0\r\nRegression.linregerrQ = 1\r\nRegression.qregc1 = 1\r\nRegression.qregc2 = 1\r\nRegression.qregc3 = 1\r\nRegression.qregerrA = 0\r\nRegression.qregerrQ = 1\r\nRegression.oldBuggyQerr = 0\r\nRegression.centroid = 1\r\nRegression.normRegCoeff = 0\r\nRegression.centroidRatioLimit = 0\r\nRegression.centroidUseAbsValues = 0\r\nRegression.doRatioLimit = 0\r\n\r\nPeaks2.doRatioLimit = 0\r\nPeaks2.numPeaks = 0\r\nPeaks2.meanPeakDist = 1\r\nPeaks2.meanPeakDistDelta = 0\r\nPeaks2.peakDistStddev = 1\r\nPeaks2.peakRangeAbs = 1\r\nPeaks2.peakRangeRel = 1\r\nPeaks2.peakMeanAbs = 1\r\nPeaks2.peakMeanMeanDist = 1\r\nPeaks2.peakMeanRel = 1\r\nPeaks2.ptpAmpMeanAbs = 0\r\nPeaks2.ptpAmpMeanRel = 0\r\nPeaks2.ptpAmpStddevAbs = 0\r\nPeaks2.ptpAmpStddevRel = 0\r\nPeaks2.minRangeAbs = 0\r\nPeaks2.minRangeRel = 1\r\nPeaks2.minMeanAbs = 0\r\nPeaks2.minMeanMeanDist = 0\r\nPeaks2.minMeanRel = 0\r\nPeaks2.mtmAmpMeanAbs = 0\r\nPeaks2.mtmAmpMeanRel = 0\r\nPeaks2.mtmAmpStddevAbs = 0\r\nPeaks2.mtmAmpStddevRel = 0\r\nPeaks2.meanRisingSlope = 1\r\nPeaks2.maxRisingSlope = 0\r\nPeaks2.minRisingSlope = 0\r\nPeaks2.stddevRisingSlope = 1\r\nPeaks2.meanFallingSlope = 1\r\nPeaks2.maxFallingSlope = 0\r\nPeaks2.minFallingSlope = 0\r\nPeaks2.stddevFallingSlope = 1\r\nPeaks2.norm = seconds\r\nPeaks2.relThresh = 0.100000\r\nPeaks2.dynRelThresh = 0\r\n;Peaks2.posDbgOutp = minmax.txt\r\nPeaks2.posDbgAppend = 0\r\nPeaks2.consoleDbg = 0\r\n\r\n\r\n[functionalsDelta:cFunctionals]\r\nreader.dmLevel = lldA_smo_de;lldB_smo_de;lld_nzsmo_de\r\nwriter.dmLevel = functionalsDelta\r\n\r\ncopyInputName = 1\r\nframeMode = full\r\nframeSize = 0\r\nframeStep = 0\r\nframeCenterSpecial = left\r\n\r\nfunctionalsEnabled = Means\r\n\r\nMeans.amean = 0\r\nMeans.posamean = 1\r\nMeans.absmean = 0\r\nMeans.qmean = 0\r\nMeans.rqmean = 1\r\nMeans.nzamean = 0\r\nMeans.nzabsmean = 0\r\nMeans.nzqmean = 0\r\nMeans.posrqmean = 0\r\nMeans.nzgmean = 0\r\nMeans.nnz = 0\r\nMeans.flatness = 1\r\nMeans.norm = frames\r\n\r\n;;;;;;;;; prepare features for standard output module\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[lldconcat].type=cVectorConcat\r\ninstance[llddeconcat].type=cVectorConcat\r\ninstance[funcconcat].type=cVectorConcat\r\n\r\n[lldconcat:cVectorConcat]\r\nreader.dmLevel = lld_nzsmo;lldA_smo;lldB_smo\r\nwriter.dmLevel = lld\r\nincludeSingleElementFields = 1\r\n\r\n[llddeconcat:cVectorConcat]\r\nreader.dmLevel = lld_nzsmo_de;lldA_smo_de;lldB_smo_de\r\nwriter.dmLevel = lld_de\r\nincludeSingleElementFields = 1\r\n\r\n[funcconcat:cVectorConcat]\r\nreader.dmLevel = functionalsA;functionalsB;functionalsNz;functionalsF0;functionalsLLD;functionalsDelta\r\nwriter.dmLevel = func\r\nincludeSingleElementFields = 1\r\n\r\n\\{shared/standard_data_output.conf.inc}\r\n\r\n\r\n\r\n"
  },
  {
    "path": "config/IS12_speaker_trait_compat.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\r\n///////// > openSMILE configuration file for IS12 challenge <        //////////////////\r\n/////////   This file produces backwards compatible features         //////////////////\r\n/////////   (to version 1.x) with openSMILE version 2.1              //////////////////\r\n/////////                                                            //////////////////\r\n///////// (c) 2013-2016 by audEERING                                 //////////////////\r\n/////////     All rights reserved. See file COPYING for details.     //////////////////\r\n///////////////////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n\r\n\r\n;;;;;;; component list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[dataMemory].type=cDataMemory\r\nprintLevelStats=0\r\n\r\n\r\n;;;;;;;;;;;;;;;;;;;;;;;;;;;; main section ;;;;;;;;;;;;;;;;;;;;;;;;;;;\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[waveIn].type=cWaveSource\r\n\r\n[waveIn:cWaveSource]\r\nwriter.dmLevel=wave\r\nfilename=\\cm[inputfile(I){test.wav}:name of input file]\r\nmonoMixdown=1\r\n\r\n;;;;;;;;;;;;;;;;;;;;;;\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[frame60].type=cFramer\r\ninstance[win60].type=cWindower\r\ninstance[fft60].type=cTransformFFT\r\ninstance[fftmp60].type=cFFTmagphase\r\n\r\n[frame60:cFramer]\r\nreader.dmLevel=wave\r\nwriter.dmLevel=frame60\r\nframeSize = 0.060\r\nframeStep = 0.010\r\nframeCenterSpecial = left\r\n\r\n\r\n[win60:cWindower]\r\nreader.dmLevel=frame60\r\nwriter.dmLevel=winG60\r\nwinFunc=gauss\r\ngain=1.0\r\nsigma=0.4\r\n\r\n[fft60:cTransformFFT]\r\nreader.dmLevel=winG60\r\nwriter.dmLevel=fftcG60\r\n ; for compatibility with 2.2.0 and older versions\r\nzeroPadSymmetric = 0\r\n\r\n[fftmp60:cFFTmagphase]\r\nreader.dmLevel=fftcG60\r\nwriter.dmLevel=fftmagG60\r\n\r\n\r\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[frame25].type=cFramer\r\ninstance[pe25].type=cVectorPreemphasis\r\ninstance[win25].type=cWindower\r\ninstance[fft25].type=cTransformFFT\r\ninstance[fftmp25].type=cFFTmagphase\r\n\r\n[frame25:cFramer]\r\nreader.dmLevel=wave\r\nwriter.dmLevel=frame25\r\nframeSize = 0.020\r\nframeStep = 0.010\r\nframeCenterSpecial = left\r\n\r\n[pe25:cVectorPreemphasis]\r\nreader.dmLevel=frame25\r\nwriter.dmLevel=frame25pe\r\nk=0.97\r\nde=0\r\n\r\n[win25:cWindower]\r\nreader.dmLevel=frame25\r\nwriter.dmLevel=winH25\r\nwinFunc=hamming\r\n\r\n[fft25:cTransformFFT]\r\nreader.dmLevel=winH25\r\nwriter.dmLevel=fftcH25\r\n ; for compatibility with 2.2.0 and older versions\r\nzeroPadSymmetric = 0\r\n\r\n[fftmp25:cFFTmagphase]\r\nreader.dmLevel=fftcH25\r\nwriter.dmLevel=fftmagH25\r\n\r\n\r\n\r\n;;;;;;;;;;;;;;;;;;;; HPS pitch\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[scale].type=cSpecScale\r\ninstance[shs].type=cPitchShs\r\ninstance[pitchSmooth].type=cPitchSmoother\r\ninstance[pitchSmooth2].type=cPitchSmoother\r\n\r\n\r\n[scale:cSpecScale]\r\nreader.dmLevel=fftmagG60\r\nwriter.dmLevel=hpsG60\r\ncopyInputName = 1\r\nprocessArrayFields = 0\r\nscale=octave\r\nsourceScale = lin\r\n// logScaleBase = 2\r\n// logSourceScaleBase = 2\r\n// firstNote = 55\r\ninterpMethod = spline\r\nminF = 25\r\nmaxF = -1\r\nnPointsTarget = 0\r\nspecSmooth = 1\r\nspecEnhance = 1\r\nauditoryWeighting = 1 \r\n\r\n[shs:cPitchShs]\r\nreader.dmLevel=hpsG60\r\nwriter.dmLevel=pitchShsG60\r\ncopyInputName = 1\r\nprocessArrayFields = 0\r\nmaxPitch = 620\r\nminPitch = 52\r\nnCandidates = 4\r\nscores = 1\r\nvoicing = 1\r\nF0C1 = 0\r\nvoicingC1 = 0\r\nF0raw = 1\r\nvoicingClip = 1\r\nvoicingCutoff = 0.700000\r\ninputFieldSearch = Mag_octScale\r\noctaveCorrection = 0\r\nnHarmonics = 15\r\ncompressionFactor = 0.850000\r\n\r\n[pitchSmooth:cPitchSmoother]\r\nreader.dmLevel=pitchShsG60\r\nwriter.dmLevel=pitchG60\r\ncopyInputName = 1\r\nprocessArrayFields = 0\r\nmedianFilter0 = 0\r\npostSmoothing = 0\r\npostSmoothingMethod = simple\r\n ; note: octave correction is too agressive, thus we disable it..\r\noctaveCorrection = 0\r\nF0final = 1\r\nF0finalEnv = 0\r\nno0f0 = 0\r\nvoicingFinalClipped = 0\r\nvoicingFinalUnclipped = 1\r\nF0raw = 0\r\nvoicingC1 = 0\r\nvoicingClip = 0\r\n\r\n[pitchSmooth2:cPitchSmoother]\r\nreader.dmLevel=pitchShsG60\r\nwriter.dmLevel=pitchF\r\nF0raw = 0\r\nF0final = 1\r\nF0finalEnv = 0\r\nvoicingFinalUnclipped = 0\r\nmedianFilter0 = 0\r\npostSmoothingMethod = simple\r\noctaveCorrection = 0\r\n\r\n\r\n;;;;;;;;;;;;;;;;;;; VQ\r\n\r\n[componentInstances:cComponentManager]\r\n;instance[acf].type=cAcf\r\n;instance[hnr].type=cHnr\r\ninstance[pitchJitter].type=cPitchJitter\r\n\r\n\r\n;[acf:cAcf]\r\n;reader.dmLevel=fftmagG60\r\n;writer.dmLevel=acfG60\r\n\r\n\r\n;[hnr:cHnr]\r\n;reader.dmLevel=pitchShsG60;acfG60\r\n;writer.dmLevel=hnr\r\n;hnrAvg = 1\r\n;hnr1 = 1\r\n;hnr2 \r\n;hnr3\r\n;hnr4\r\n;hnr5\r\n\r\n[pitchJitter:cPitchJitter]\r\nreader.dmLevel = wave\r\nwriter.dmLevel = jitterShimmer\r\n// nameAppend =\r\ncopyInputName = 1\r\n; is pitchF really necessary, or can we use pitchG60 ?\r\nF0reader.dmLevel = pitchF\r\nF0field = F0final\r\nsearchRangeRel = 0.250000\r\njitterLocal = 1\r\njitterDDP = 1\r\njitterLocalEnv = 0\r\njitterDDPEnv = 0\r\nshimmerLocal = 1\r\nshimmerLocalEnv = 0\r\nonlyVoiced = 0\r\nlogHNR = 1\r\n;periodLengths = 0\r\n;periodStarts = 0\r\nuseBrokenJitterThresh = 1\r\n\r\n;;;;;;;;;;;;;;;;;;;;; Energy / loudness\r\n\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[energy].type=cEnergy\r\ninstance[melspec1].type=cMelspec\r\ninstance[audspec].type=cPlp\r\ninstance[audspecRasta].type=cPlp\r\ninstance[audspecSum].type=cVectorOperation\r\ninstance[audspecRastaSum].type=cVectorOperation\r\n\r\n\r\n[energy:cEnergy]\r\nreader.dmLevel = frame25\r\nwriter.dmLevel = energy\r\nlog=0\r\nrms=1\r\n\r\n\r\n[melspec1:cMelspec]\r\nreader.dmLevel=fftmagH25\r\nwriter.dmLevel=melspec1\r\n; htk compatible sample value scaling\r\nhtkcompatible = 0\r\nnBands = 26\r\n; use power spectrum instead of magnitude spectrum\r\nusePower = 1\r\nlofreq = 20\r\nhifreq = 8000\r\nspecScale = mel\r\n\r\n; perform auditory weighting of spectrum\r\n[audspec:cPlp]\r\nreader.dmLevel=melspec1\r\nwriter.dmLevel=audspec\r\nfirstCC = 0\r\nlpOrder = 5\r\ncepLifter = 22\r\ncompression = 0.33\r\nhtkcompatible = 0 \r\ndoIDFT = 0\r\ndoLpToCeps = 0\r\ndoLP = 0\r\ndoInvLog = 0\r\ndoAud = 1\r\ndoLog = 0\r\nnewRASTA=0\r\nRASTA=0\r\n\r\n; perform RASTA style filtering of auditory spectra\r\n[audspecRasta:cPlp]\r\nreader.dmLevel=melspec1\r\nwriter.dmLevel=audspecRasta\r\nnameAppend = Rfilt\r\nfirstCC = 0\r\nlpOrder = 5\r\ncepLifter = 22\r\ncompression = 0.33\r\nhtkcompatible = 0 \r\ndoIDFT = 0\r\ndoLpToCeps = 0\r\ndoLP = 0\r\ndoInvLog = 0\r\ndoAud = 1\r\ndoLog = 0\r\nnewRASTA=1\r\nRASTA=0\r\n\r\n[audspecSum:cVectorOperation]\r\nreader.dmLevel = audspec\r\nwriter.dmLevel = audspecSum\r\n// nameAppend = \r\ncopyInputName = 1\r\nprocessArrayFields = 0\r\noperation = ll1\r\nnameBase = audspec\r\n\r\n[audspecRastaSum:cVectorOperation]\r\nreader.dmLevel = audspecRasta\r\nwriter.dmLevel = audspecRastaSum\r\n// nameAppend = \r\ncopyInputName = 1\r\nprocessArrayFields = 0\r\noperation = ll1\r\nnameBase = audspecRasta\r\n\r\n;;;;;;;;;;;;;;; spectral\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[spectral].type=cSpectral\r\n\r\n\r\n[spectral:cSpectral]\r\nreader.dmLevel=fftmagH25\r\nwriter.dmLevel=spectral\r\nbands[0]=250-650\r\nbands[1]=1000-4000\r\nrollOff[0] = 0.25\r\nrollOff[1] = 0.50\r\nrollOff[2] = 0.75\r\nrollOff[3] = 0.90\r\nflux=1\r\ncentroid=0\r\nmaxPos=0\r\nminPos=0\r\nentropy=1\r\nvariance=1\r\nskewness=1\r\nkurtosis=1\r\nslope=1\r\nharmonicity=1\r\nsharpness=1\r\n\r\n\r\n;;;;;;;;;;;;;;; mfcc\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[melspecMfcc].type=cMelspec\r\ninstance[mfcc].type=cMfcc\r\n\r\n[melspecMfcc:cMelspec]\r\nreader.dmLevel=fftmagH25\r\nwriter.dmLevel=melspecMfcc\r\ncopyInputName = 1\r\nprocessArrayFields = 1\r\n; htk compatible sample value scaling\r\nhtkcompatible = 1\r\nnBands = 26s\r\n; use power spectrum instead of magnitude spectrum\r\nusePower = 1\r\nlofreq = 20\r\nhifreq = 8000\r\nspecScale = mel\r\ninverse = 0\r\n\r\n[mfcc:cMfcc]\r\nreader.dmLevel=melspecMfcc\r\nwriter.dmLevel=mfcc1_12\r\ncopyInputName = 1\r\nprocessArrayFields = 1\r\nfirstMfcc = 1\r\nlastMfcc  = 14\r\ncepLifter = 22.0\r\nhtkcompatible = 1\r\n\r\n\r\n;;;;;;;;;;;;;;;;  zcr\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[mzcr].type=cMZcr\r\n\r\n[mzcr:cMZcr]\r\nreader.dmLevel = frame25\r\nwriter.dmLevel = zcr\r\ncopyInputName = 1\r\nprocessArrayFields = 1\r\nzcr = 1\r\nmcr = 0\r\namax = 0\r\nmaxmin = 0\r\ndc = 0\r\n\r\n\r\n;;;;;;;;;;;;;;;;; rasta-plp ?\r\n\r\n;;;;;;;;;;;;;;;;;;;; smoothing\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[smoNz].type=cContourSmoother\r\ninstance[smoA].type=cContourSmoother\r\ninstance[smoB].type=cContourSmoother\r\ninstance[f0sel].type=cDataSelector\r\n\r\n[smoNz:cContourSmoother]\r\nreader.dmLevel = pitchG60;jitterShimmer\r\nwriter.dmLevel = lld_nzsmo\r\nwriter.levelconf.isRb=0\r\nwriter.levelconf.growDyn=1\r\nnameAppend = sma\r\ncopyInputName = 1\r\nnoPostEOIprocessing = 0\r\nsmaWin = 3\r\nnoZeroSma = 1\r\n\r\n[f0sel:cDataSelector]\r\nreader.dmLevel = lld_nzsmo\r\nwriter.dmLevel = lld_f0_nzsmo\r\nwriter.levelconf.isRb=0\r\nwriter.levelconf.growDyn=1\r\nnameAppend = ff0\r\nselected = F0final_sma\r\n\r\n[smoA:cContourSmoother]\r\nreader.dmLevel = audspecSum;audspecRastaSum;energy;zcr\r\nwriter.dmLevel = lldA_smo\r\nwriter.levelconf.isRb=0\r\nwriter.levelconf.growDyn=1\r\nnameAppend = sma\r\ncopyInputName = 1\r\nnoPostEOIprocessing = 0\r\nsmaWin = 3\r\n\r\n[smoB:cContourSmoother]\r\nreader.dmLevel = audspecRasta;spectral;mfcc1_12\r\nwriter.dmLevel = lldB_smo\r\nwriter.levelconf.isRb=0\r\nwriter.levelconf.growDyn=1\r\nnameAppend = sma\r\ncopyInputName = 1\r\nnoPostEOIprocessing = 0\r\nsmaWin = 3\r\n\r\n;;;;;;;;; deltas\r\n[componentInstances:cComponentManager]\r\ninstance[deNz].type=cDeltaRegression\r\ninstance[deA].type=cDeltaRegression\r\ninstance[deB].type=cDeltaRegression\r\ninstance[def0sel].type=cDeltaRegression\r\n\r\n[deNz:cDeltaRegression]\r\nreader.dmLevel = lld_nzsmo\r\nwriter.dmLevel = lld_nzsmo_de\r\nwriter.levelconf.isRb=0\r\nwriter.levelconf.growDyn=1\r\n\r\n[deA:cDeltaRegression]\r\nreader.dmLevel = lldA_smo\r\nwriter.dmLevel = lldA_smo_de\r\nwriter.levelconf.isRb=0\r\nwriter.levelconf.growDyn=1\r\n\r\n[deB:cDeltaRegression]\r\nreader.dmLevel = lldB_smo\r\nwriter.dmLevel = lldB_smo_de\r\nwriter.levelconf.isRb=0\r\nwriter.levelconf.growDyn=1\r\n\r\n[def0sel:cDeltaRegression]\r\nreader.dmLevel = lld_f0_nzsmo\r\nwriter.dmLevel = lld_f0_nzsmo_de\r\nwriter.levelconf.isRb=0\r\nwriter.levelconf.growDyn=1\r\n\r\n;;;;;;;;; functionals / statistics\r\n\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[functionalsA].type=cFunctionals\r\ninstance[functionalsB].type=cFunctionals\r\ninstance[functionalsF0].type=cFunctionals\r\ninstance[functionalsNz].type=cFunctionals\r\n\r\n; shared functionals for LLD\r\ninstance[functionalsLLD].type=cFunctionals\r\n\r\n; shared functionals for Delta LLD\r\ninstance[functionalsDelta].type=cFunctionals\r\n\r\n\r\n; functionals for energy related lld\r\n[functionalsA:cFunctionals]\r\nreader.dmLevel = lldA_smo;lldA_smo_de\r\nwriter.dmLevel = functionalsA\r\n// nameAppend = \r\ncopyInputName = 1\r\nframeMode = full\r\nframeSize = 0\r\nframeStep = 0\r\nframeCenterSpecial = left\r\n\r\nfunctionalsEnabled = Extremes ; Percentiles ; Moments ; Segments ; Times ;  Lpc\r\n\r\nExtremes.max = 0\r\nExtremes.min = 0\r\nExtremes.maxpos = 1\r\nExtremes.minpos = 1\r\nExtremes.maxameandist = 0\r\nExtremes.minameandist = 0\r\n\r\nSegments.maxNumSeg = 100\r\nSegments.segmentationAlgorithm = relTh\r\nSegments.thresholds = 0.25\r\nSegments.numSegments = 0\r\nSegments.meanSegLen = 1\r\nSegments.maxSegLen = 1\r\nSegments.minSegLen = 1\r\nSegments.segLenStddev = 1\r\nSegments.norm = second\r\n\r\nMoments.doRatioLimit = 0\r\nMoments.variance = 0\r\nMoments.stddev = 1\r\nMoments.skewness = 1\r\nMoments.kurtosis = 1\r\nMoments.amean = 0\r\n\r\nPercentiles.quartiles = 1\r\nPercentiles.iqr = 1\r\nPercentiles.percentile[0] = 0.01\r\nPercentiles.percentile[1] = 0.99\r\nPercentiles.pctlrange[0] = 0-1\r\nPercentiles.interp = 1\r\n\r\nTimes.upleveltime25 = 1\r\nTimes.downleveltime25 = 1\r\nTimes.upleveltime50 = 1\r\nTimes.downleveltime50 = 1\r\nTimes.upleveltime75 = 1\r\nTimes.downleveltime75 = 1\r\nTimes.upleveltime90 = 1\r\nTimes.downleveltime90 = 1\r\nTimes.risetime = 1\r\nTimes.falltime = 1\r\nTimes.leftctime = 0\r\nTimes.rightctime = 0\r\nTimes.duration = 0\r\nTimes.buggySecNorm = 0\r\nTimes.norm = segment\r\n\r\nLpc.lpGain = 1\r\nLpc.lpc = 1\r\nLpc.firstCoeff = 0\r\nLpc.order = 5\r\n\r\nnonZeroFuncts = 0\r\nmasterTimeNorm = segment\r\n\r\n\r\n\r\n; functionals for spectrum related lld\r\n[functionalsB:cFunctionals]\r\nreader.dmLevel = lldB_smo;lldB_smo_de\r\nwriter.dmLevel = functionalsB\r\n// nameAppend = \r\ncopyInputName = 1\r\nframeMode = full\r\nframeSize = 0\r\nframeStep = 0\r\nframeCenterSpecial = left\r\n\r\nfunctionalsEnabled = Extremes ; Percentiles ; Moments ; Segments ; Times ;  Lpc\r\n\r\nExtremes.max = 0\r\nExtremes.min = 0\r\nExtremes.maxpos = 1\r\nExtremes.minpos = 1\r\nExtremes.maxameandist = 0\r\nExtremes.minameandist = 0\r\n\r\nSegments.maxNumSeg = 100\r\nSegments.segmentationAlgorithm = relTh\r\nSegments.thresholds = 0.25 ; 0.75\r\nSegments.rangeRelThreshold = 0.200000\r\nSegments.numSegments = 0\r\nSegments.meanSegLen = 1\r\nSegments.maxSegLen = 1\r\nSegments.minSegLen = 1\r\nSegments.segLenStddev = 1\r\nSegments.norm = second\r\n\r\nMoments.doRatioLimit = 0\r\nMoments.variance = 0\r\nMoments.stddev = 1\r\nMoments.skewness = 1\r\nMoments.kurtosis = 1\r\nMoments.amean = 0\r\n\r\nPercentiles.quartiles = 1\r\nPercentiles.iqr = 1\r\nPercentiles.percentile[0] = 0.01\r\nPercentiles.percentile[1] = 0.99\r\nPercentiles.pctlrange[0] = 0-1\r\nPercentiles.interp = 1\r\n\r\nTimes.upleveltime25 = 1\r\nTimes.downleveltime25 = 1\r\nTimes.upleveltime50 = 1\r\nTimes.downleveltime50 = 1\r\nTimes.upleveltime75 = 1\r\nTimes.downleveltime75 = 1\r\nTimes.upleveltime90 = 1\r\nTimes.downleveltime90 = 1\r\nTimes.risetime = 1\r\nTimes.falltime = 1\r\nTimes.leftctime = 0\r\nTimes.rightctime = 0\r\nTimes.duration = 0\r\nTimes.buggySecNorm = 0\r\nTimes.norm = segment\r\n\r\nLpc.lpGain = 1\r\nLpc.lpc = 1\r\nLpc.firstCoeff = 0\r\nLpc.order = 5\r\n\r\nnonZeroFuncts = 0\r\nmasterTimeNorm = segment\r\n\r\n\r\n\r\n; functionals for pitch onsets/offsets\r\n[functionalsF0:cFunctionals]\r\nreader.dmLevel = lld_f0_nzsmo\r\nwriter.dmLevel = functionalsF0\r\n//nameAppend = ff0\r\ncopyInputName = 1\r\nframeMode = full\r\nframeSize = 0\r\nframeStep = 0\r\nframeCenterSpecial = left\r\n\r\nfunctionalsEnabled = Means ; Segments ; Times\r\n\r\nMeans.amean = 0\r\nMeans.absmean = 0\r\nMeans.qmean = 0\r\nMeans.nzamean = 0\r\nMeans.nzabsmean = 0\r\nMeans.nzqmean = 0\r\nMeans.nzgmean = 0\r\nMeans.nnz = 1\r\nMeans.norm = segment\r\n\r\nSegments.maxNumSeg = 100\r\nSegments.segmentationAlgorithm = nonX\r\nSegments.X = 0.0\r\nSegments.numSegments = 0\r\nSegments.meanSegLen = 1\r\nSegments.maxSegLen = 1\r\nSegments.minSegLen = 1\r\nSegments.segLenStddev = 1\r\nSegments.norm = second\r\n\r\nTimes.upleveltime25 = 0\r\nTimes.downleveltime25 = 0\r\nTimes.upleveltime50 = 0\r\nTimes.downleveltime50 = 0\r\nTimes.upleveltime75 = 0\r\nTimes.downleveltime75 = 0\r\nTimes.upleveltime90 = 0\r\nTimes.downleveltime90 = 0\r\nTimes.risetime = 0\r\nTimes.falltime = 0\r\nTimes.leftctime = 0\r\nTimes.rightctime = 0\r\nTimes.duration = 0\r\nTimes.buggySecNorm = 0\r\nTimes.norm = second\r\n\r\nnonZeroFuncts = 0\r\nmasterTimeNorm = segment\r\n\r\n\r\n\r\n; functionals for pitch and vq related lld in voiced regions\r\n[functionalsNz:cFunctionals]\r\nreader.dmLevel = lld_nzsmo;lld_nzsmo_de\r\nwriter.dmLevel = functionalsNz\r\n// nameAppend = \r\ncopyInputName = 1\r\nframeMode = full\r\nframeSize = 0\r\nframeStep = 0\r\nframeCenterSpecial = left\r\n\r\nfunctionalsEnabled = Extremes ; Percentiles ; Moments ; Times ; Lpc\r\n\r\n\r\nExtremes.max = 0\r\nExtremes.min = 0\r\nExtremes.maxpos = 1\r\nExtremes.minpos = 1\r\nExtremes.maxameandist = 0\r\nExtremes.minameandist = 0\r\n\r\nMoments.doRatioLimit = 0\r\nMoments.variance = 0\r\nMoments.stddev = 1\r\nMoments.skewness = 1\r\nMoments.kurtosis = 1\r\nMoments.amean = 0\r\n\r\nPercentiles.quartiles = 1\r\nPercentiles.iqr = 1\r\nPercentiles.percentile[0] = 0.01\r\nPercentiles.percentile[1] = 0.99\r\nPercentiles.pctlrange[0] = 0-1\r\nPercentiles.interp = 1\r\n\r\nTimes.upleveltime25 = 1\r\nTimes.downleveltime25 = 1\r\nTimes.upleveltime50 = 1\r\nTimes.downleveltime50 = 1\r\nTimes.upleveltime75 = 1\r\nTimes.downleveltime75 = 1\r\nTimes.upleveltime90 = 1\r\nTimes.downleveltime90 = 1\r\nTimes.risetime = 1\r\nTimes.falltime = 1\r\nTimes.leftctime = 1\r\nTimes.rightctime = 1\r\nTimes.duration = 0\r\nTimes.buggySecNorm = 0\r\nTimes.norm = segment\r\n\r\nLpc.lpGain = 1\r\nLpc.lpc = 1\r\nLpc.firstCoeff = 0\r\nLpc.order = 5\r\n\r\nnonZeroFuncts = 1\r\nmasterTimeNorm = segment\r\n\r\n\r\n\r\n[functionalsLLD:cFunctionals]\r\nreader.dmLevel = lldA_smo;lldB_smo;lld_nzsmo\r\nwriter.dmLevel = functionalsLLD\r\n\r\ncopyInputName = 1\r\nframeMode = full\r\nframeSize = 0\r\nframeStep = 0\r\nframeCenterSpecial = left\r\n\r\nfunctionalsEnabled = Means ; Peaks2 ; Regression\r\n\r\nMeans.amean = 1\r\nMeans.posamean = 0\r\nMeans.absmean = 0\r\nMeans.qmean = 0\r\nMeans.rqmean = 1\r\nMeans.nzamean = 0\r\nMeans.nzabsmean = 0\r\nMeans.nzqmean = 0\r\nMeans.posrqmean = 0\r\nMeans.nzgmean = 0\r\nMeans.nnz = 0\r\nMeans.flatness = 1\r\nMeans.norm = frames\r\n\r\nRegression.centroidUseAbsValues = 0\r\nRegression.centroidRatioLimit = 0\r\nRegression.doRatioLimit = 0\r\nRegression.linregc1 = 1\r\nRegression.linregc2 = 1\r\nRegression.linregerrA = 0\r\nRegression.linregerrQ = 1\r\nRegression.qregc1 = 1\r\nRegression.qregc2 = 1\r\nRegression.qregc3 = 1\r\nRegression.qregerrA = 0\r\nRegression.qregerrQ = 1\r\nRegression.oldBuggyQerr = 0\r\nRegression.centroid = 1\r\nRegression.normRegCoeff = 0\r\n\r\nPeaks2.doRatioLimit = 0\r\nPeaks2.numPeaks = 0\r\nPeaks2.meanPeakDist = 1\r\nPeaks2.meanPeakDistDelta = 0\r\nPeaks2.peakDistStddev = 1\r\nPeaks2.peakRangeAbs = 1\r\nPeaks2.peakRangeRel = 1\r\nPeaks2.peakMeanAbs = 1\r\nPeaks2.peakMeanMeanDist = 1\r\nPeaks2.peakMeanRel = 1\r\nPeaks2.ptpAmpMeanAbs = 0\r\nPeaks2.ptpAmpMeanRel = 0\r\nPeaks2.ptpAmpStddevAbs = 0\r\nPeaks2.ptpAmpStddevRel = 0\r\nPeaks2.minRangeAbs = 0\r\nPeaks2.minRangeRel = 1\r\nPeaks2.minMeanAbs = 0\r\nPeaks2.minMeanMeanDist = 0\r\nPeaks2.minMeanRel = 0\r\nPeaks2.mtmAmpMeanAbs = 0\r\nPeaks2.mtmAmpMeanRel = 0\r\nPeaks2.mtmAmpStddevAbs = 0\r\nPeaks2.mtmAmpStddevRel = 0\r\nPeaks2.meanRisingSlope = 1\r\nPeaks2.maxRisingSlope = 0\r\nPeaks2.minRisingSlope = 0\r\nPeaks2.stddevRisingSlope = 1\r\nPeaks2.meanFallingSlope = 1\r\nPeaks2.maxFallingSlope = 0\r\nPeaks2.minFallingSlope = 0\r\nPeaks2.stddevFallingSlope = 1\r\nPeaks2.norm = seconds\r\nPeaks2.relThresh = 0.100000\r\nPeaks2.dynRelThresh = 0\r\n;Peaks2.posDbgOutp = minmax.txt\r\nPeaks2.posDbgAppend = 0\r\nPeaks2.consoleDbg = 0\r\n\r\n\r\n[functionalsDelta:cFunctionals]\r\nreader.dmLevel = lldA_smo_de;lldB_smo_de;lld_nzsmo_de\r\nwriter.dmLevel = functionalsDelta\r\n\r\ncopyInputName = 1\r\nframeMode = full\r\nframeSize = 0\r\nframeStep = 0\r\nframeCenterSpecial = left\r\n\r\nfunctionalsEnabled = Means\r\n\r\nMeans.amean = 0\r\nMeans.posamean = 1\r\nMeans.absmean = 0\r\nMeans.qmean = 0\r\nMeans.rqmean = 1\r\nMeans.nzamean = 0\r\nMeans.nzabsmean = 0\r\nMeans.nzqmean = 0\r\nMeans.posrqmean = 0\r\nMeans.nzgmean = 0\r\nMeans.nnz = 0\r\nMeans.flatness = 1\r\nMeans.norm = frames\r\n\r\n;;;;;;;;; prepare features for standard output module\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[lldconcat].type=cVectorConcat\r\ninstance[llddeconcat].type=cVectorConcat\r\ninstance[funcconcat].type=cVectorConcat\r\n\r\n[lldconcat:cVectorConcat]\r\nreader.dmLevel = lld_nzsmo;lldA_smo;lldB_smo\r\nwriter.dmLevel = lld\r\nincludeSingleElementFields = 1\r\n\r\n[llddeconcat:cVectorConcat]\r\nreader.dmLevel = lld_nzsmo_de;lldA_smo_de;lldB_smo_de\r\nwriter.dmLevel = lld_de\r\nincludeSingleElementFields = 1\r\n\r\n[funcconcat:cVectorConcat]\r\nreader.dmLevel = functionalsA;functionalsB;functionalsNz;functionalsF0;functionalsLLD;functionalsDelta\r\nwriter.dmLevel = func\r\nincludeSingleElementFields = 1\r\n\r\n\\{shared/standard_data_output.conf.inc}\r\n\r\n\r\n\r\n"
  },
  {
    "path": "config/IS13_ComParE.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\r\n///////// > openSMILE configuration file for ComParE <               //////////////////\r\n/////////                                                            //////////////////\r\n///////// (c) 2014 by audEERING                                      //////////////////\r\n/////////     All rights reserved. See file COPYING for details.     //////////////////\r\n///////////////////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n\r\n;;;;;;; component list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[dataMemory].type=cDataMemory\r\nprintLevelStats=0\r\n\r\n\r\n;;;;;;;;;;;;;;;;;;;;;;;;;;;; main section ;;;;;;;;;;;;;;;;;;;;;;;;;;;\r\n\r\n\\{shared/standard_wave_input.conf.inc}\r\n\\{IS13_ComParE_core.lld.conf.inc}\r\n\\{IS13_ComParE_core.func.conf.inc}\r\n\r\n;;;;;;;;; prepare features for standard output module\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_lldconcat].type=cVectorConcat\r\ninstance[is13_llddeconcat].type=cVectorConcat\r\ninstance[is13_funcconcat].type=cVectorConcat\r\n\r\n[is13_lldconcat:cVectorConcat]\r\nreader.dmLevel = is13_lld_nzsmo;is13_lldA_smo;is13_lldB_smo\r\nwriter.dmLevel = lld\r\nincludeSingleElementFields = 1\r\n\r\n[is13_llddeconcat:cVectorConcat]\r\nreader.dmLevel = is13_lld_nzsmo_de;is13_lldA_smo_de;is13_lldB_smo_de\r\nwriter.dmLevel = lld_de\r\nincludeSingleElementFields = 1\r\n\r\n[is13_funcconcat:cVectorConcat]\r\nreader.dmLevel = is13_functionalsA;is13_functionalsB;is13_functionalsNz;is13_functionalsF0;is13_functionalsLLD;is13_functionalsDelta\r\nwriter.dmLevel = func\r\nincludeSingleElementFields = 1\r\n\r\n\\{shared/standard_data_output.conf.inc}\r\n\r\n"
  },
  {
    "path": "config/IS13_ComParE_Voc.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for ComParE vocalistions <  //////////////////\n/////////                                                            //////////////////\n///////// (c) 2014 by audEERING                                      //////////////////\n/////////     All rights reserved. See file COPYING for details.     //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\ninstance[waveIn].type=cWaveSource\ninstance[fr1].type=cFramer\ninstance[pe2].type=cVectorPreemphasis\ninstance[w1].type=cWindower\ninstance[fft1].type=cTransformFFT\ninstance[fftmp1].type=cFFTmagphase\ninstance[acf].type=cAcf\ninstance[cepstrum].type=cAcf\ninstance[pitchACF].type=cPitchACF\ninstance[mspec].type=cMelspec\ninstance[mfcc].type=cMfcc\ninstance[energy].type=cEnergy\ninstance[mzcr].type=cMZcr\ninstance[cms].type=cFullinputMean\ninstance[cmsD].type=cFullinputMean\ninstance[cmsA].type=cFullinputMean\ninstance[vc1].type=cVectorConcat\ninstance[delta1].type=cDeltaRegression\ninstance[delta2].type=cDeltaRegression\ninstance[delta1e].type=cDeltaRegression\ninstance[delta2e].type=cDeltaRegression\ninstance[deltapitch].type=cDeltaRegression\ninstance[deltazcr].type=cDeltaRegression\ninstance[framestacking].type=cFunctionals\ninstance[arffout].type=cArffSink\nnThreads=1\nprintLevelStats=0\n\n[waveIn:cWaveSource]\nwriter.dmLevel=wave\nfilename=\\cm[inputfile(I){test.wav}:name of input file]\n;buffersize=16000\nmonoMixdown=1\n\n[fr1:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=outp\nframeSize = 0.0250\nframeStep = 0.010\nframeCenterSpecial = left\n\n[pe2:cVectorPreemphasis]\nreader.dmLevel=outp\nwriter.dmLevel=output\nk=0.97\n\n\n[w1:cWindower]\nreader.dmLevel=output\nwriter.dmLevel=winoutput\nwinFunc = ham\ngain = 1.0\n\n[fft1:cTransformFFT]\nreader.dmLevel=winoutput\nwriter.dmLevel=fftc1\n\n[fftmp1:cFFTmagphase]\nreader.dmLevel=fftc1\nwriter.dmLevel=fft1\n\n[acf:cAcf]\nreader.dmLevel=fft1\nwriter.dmLevel=acf\nnameAppend = acf\ncopyInputName = 1\nprocessArrayFields = 1\nusePower = 1\ncepstrum = 0\n\n[cepstrum:cAcf]\nreader.dmLevel=fft1\nwriter.dmLevel=cepstrum\nnameAppend = acf\ncopyInputName = 1\nprocessArrayFields = 1\nusePower = 1\ncepstrum = 1\n\n[pitchACF:cPitchACF]\n  ; the pitchACF component must ALWAYS read from acf AND cepstrum in the given order!\nreader.dmLevel=acf;cepstrum\nwriter.dmLevel=pitch\nwriter.levelconf.growDyn=1\nwriter.levelconf.isRb=0\ncopyInputName = 1\nprocessArrayFields = 0\nmaxPitch = 500\nvoiceProb = 1\nvoiceQual = 0\nHNR = 1\nF0 = 1\nF0raw = 0\nF0env = 0\nvoicingCutoff = 0.550000\n\n[mspec:cMelspec]\nreader.dmLevel=fft1\nwriter.dmLevel=mspec1\nhtkcompatible = 1\nnBands = 26\nusePower = 1\nlofreq = 0\nhifreq = 8000\n\n[mfcc:cMfcc]\nreader.dmLevel=mspec1\nwriter.dmLevel=mfcc1\nwriter.levelconf.growDyn=1\nwriter.levelconf.isRb=0\nbuffersize=1000\nfirstMfcc = 1\nlastMfcc =  12\nhtkcompatible = 1\n\n[cms:cFullinputMean]\nreader.dmLevel=mfcc1\nwriter.dmLevel=mfcc1m\nmultiLoopMode=1\n\n[cmsD:cFullinputMean]\nreader.dmLevel=mfcc1de\nwriter.dmLevel=mfcc1dem\nmultiLoopMode=1\n\n[cmsA:cFullinputMean]\nreader.dmLevel=mfcc1dede\nwriter.dmLevel=mfcc1dedem\nmultiLoopMode=1\n\n\n[vc1:cVectorConcat]\nreader.dmLevel=mfcc1m;energy;mfcc1dem;energyDe;mfcc1dedem;energyDede\nwriter.dmLevel=ft0\nprocessArrayFields=0\n\n[delta1:cDeltaRegression]\nreader.dmLevel=mfcc1\nwriter.dmLevel=mfcc1de\ndeltawin=2\nblocksize=1\n\n[delta2:cDeltaRegression]\nreader.dmLevel=mfcc1de\nwriter.dmLevel=mfcc1dede\ndeltawin=2\nblocksize=1\n\n[delta1e:cDeltaRegression]\nreader.dmLevel=energy\nwriter.dmLevel=energyDe\ndeltawin=2\nblocksize=1\n\n[delta2e:cDeltaRegression]\nreader.dmLevel=energyDe\nwriter.dmLevel=energyDede\ndeltawin=2\nblocksize=1\n\n[deltapitch:cDeltaRegression]\nreader.dmLevel=pitch\nwriter.dmLevel=pitchde\ndeltawin=2\nblocksize=1\nonlyInSegments=1\nzeroSegBound=1\n\n[deltazcr:cDeltaRegression]\nreader.dmLevel=zcr\nwriter.dmLevel=zcrde\ndeltawin=2\nblocksize=1\n\n[energy:cEnergy]\nreader.dmLevel=outp\nwriter.dmLevel=energy\nwriter.levelconf.growDyn=1\nwriter.levelconf.isRb=0\nbuffersize=1000\nhtkcompatible=1\n\n[mzcr:cMZcr]\nreader.dmLevel=outp\nwriter.dmLevel=zcr\nwriter.levelconf.growDyn=1\nwriter.levelconf.isRb=0\ncopyInputName = 1\nprocessArrayFields = 1\nzcr = 1\namax = 0\nmcr = 0\nmaxmin = 0\ndc = 0\n\n[framestacking:cFunctionals]\nreader.dmLevel = mfcc1m;energy;mfcc1dem;energyDe;mfcc1dedem;energyDede;pitch;pitchde;zcr;zcrde\n;ft0\nwriter.dmLevel = fts\n;frameCenterSpecial = mid\nframeCenterFrames = \\cm[stackC{2}:frame center]\nframeSizeFrames = \\cm[stack(S){5}:number of frames to stack]\nframeStepFrames = 1\nfunctionalsEnabled = Moments\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 0\nMoments.kurtosis = 0\nMoments.amean = 1\nnoPostEOIprocessing = 0\n\n[arffout:cArffSink]\nrelation = COMPARE2013_Vocalisations\n;instanceBase=\\cm[instName{file}:instance name]\ninstanceName=\\cm[instName{file}:instance name]\nreader.dmLevel=mfcc1m;energy;mfcc1dem;energyDe;mfcc1dedem;energyDede;pitch;pitchde;zcr;zcrde;fts\n;reader.dmLevel=fts\nfilename=\\cm[output(O){mfcc.arff}:name of MFCC output filename (ARFF format)]\nframeIndex = 1\nframeTime = 0\nappend = 1\nclass[0].type = { garbage, laughter, filler }\n; default class\ntarget[0].all = garbage\ntarget[0].instance = \\cm[frameClasses(T){garbage}:list of class labels for frames]\n\n"
  },
  {
    "path": "config/IS13_ComParE_core.func.conf.inc",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\r\n///////// > openSMILE configuration file for ComParE <               //////////////////\r\n/////////                                                            //////////////////\r\n///////// (c) 2014 by audEERING                                      //////////////////\r\n/////////     All rights reserved. See file COPYING for details.     //////////////////\r\n///////////////////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n;;;;;;;;; functionals / statistics\r\n\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_functionalsA].type=cFunctionals\r\ninstance[is13_functionalsB].type=cFunctionals\r\ninstance[is13_functionalsF0].type=cFunctionals\r\ninstance[is13_functionalsNz].type=cFunctionals\r\n; shared functionals for LLD\r\ninstance[is13_functionalsLLD].type=cFunctionals\r\n; shared functionals for Delta LLD\r\ninstance[is13_functionalsDelta].type=cFunctionals\r\n\r\n\r\n; functionals for energy related lld\r\n[is13_functionalsA:cFunctionals]\r\nreader.dmLevel = is13_lldA_smo;is13_lldA_smo_de\r\nwriter.dmLevel = is13_functionalsA\r\n// nameAppend = \r\ncopyInputName = 1\r\n\\{\\cm[bufferModeRbConf]}\r\n\\{\\cm[frameModeFunctionalsConf{shared/FrameModeFunctionals.conf.inc}:path to included config to set frame mode for all functionals]}\r\nfunctionalsEnabled = Extremes ; Percentiles ; Moments ; Segments ; Times ;  Lpc\r\nExtremes.max = 0\r\nExtremes.min = 0\r\nExtremes.maxpos = 1\r\nExtremes.minpos = 1\r\nExtremes.maxameandist = 0\r\nExtremes.minameandist = 0\r\nSegments.maxNumSeg = 100\r\nSegments.segmentationAlgorithm = relTh\r\nSegments.thresholds = 0.25 ; 0.75\r\nSegments.ravgLng = 3\r\nSegments.numSegments = 0\r\nSegments.meanSegLen = 1\r\nSegments.maxSegLen = 1\r\nSegments.minSegLen = 1\r\nSegments.segLenStddev = 1\r\nSegments.norm = second\r\nMoments.doRatioLimit = 0\r\nMoments.variance = 0\r\nMoments.stddev = 1\r\nMoments.skewness = 1\r\nMoments.kurtosis = 1\r\nMoments.amean = 0\r\nPercentiles.quartiles = 1\r\nPercentiles.iqr = 1\r\nPercentiles.percentile[0] = 0.01\r\nPercentiles.percentile[1] = 0.99\r\nPercentiles.pctlrange[0] = 0-1\r\nPercentiles.interp = 1\r\nTimes.upleveltime25 = 1\r\nTimes.downleveltime25 = 0\r\nTimes.upleveltime50 = 1\r\nTimes.downleveltime50 = 0\r\nTimes.upleveltime75 = 1\r\nTimes.downleveltime75 = 0\r\nTimes.upleveltime90 = 1\r\nTimes.downleveltime90 = 0\r\nTimes.risetime = 1\r\nTimes.falltime = 0\r\nTimes.leftctime = 1\r\nTimes.rightctime = 0\r\nTimes.duration = 0\r\nTimes.buggySecNorm = 0\r\nTimes.norm = segment\r\nLpc.lpGain = 1\r\nLpc.lpc = 1\r\nLpc.firstCoeff = 0\r\nLpc.order = 5\r\nnonZeroFuncts = 0\r\nmasterTimeNorm = segment\r\n\r\n; functionals for spectrum related lld\r\n[is13_functionalsB:cFunctionals]\r\nreader.dmLevel = is13_lldB_smo;is13_lldB_smo_de\r\nwriter.dmLevel = is13_functionalsB\r\n// nameAppend = \r\ncopyInputName = 1\r\n\\{\\cm[bufferModeRbConf]}\r\n\\{\\cm[frameModeFunctionalsConf]}\r\nfunctionalsEnabled = Extremes ; Percentiles ; Moments ; Segments ; Times ;  Lpc\r\nExtremes.max = 0\r\nExtremes.min = 0\r\nExtremes.maxpos = 1\r\nExtremes.minpos = 1\r\nExtremes.maxameandist = 0\r\nExtremes.minameandist = 0\r\nSegments.maxNumSeg = 100\r\nSegments.segmentationAlgorithm = relTh\r\nSegments.thresholds = 0.25 ; 0.75\r\nSegments.rangeRelThreshold = 0.200000\r\nSegments.numSegments = 0\r\nSegments.meanSegLen = 1\r\nSegments.maxSegLen = 1\r\nSegments.minSegLen = 1\r\nSegments.segLenStddev = 1\r\nSegments.norm = second\r\nMoments.doRatioLimit = 0\r\nMoments.variance = 0\r\nMoments.stddev = 1\r\nMoments.skewness = 1\r\nMoments.kurtosis = 1\r\nMoments.amean = 0\r\nPercentiles.quartiles = 1\r\nPercentiles.iqr = 1\r\nPercentiles.percentile[0] = 0.01\r\nPercentiles.percentile[1] = 0.99\r\nPercentiles.pctlrange[0] = 0-1\r\nPercentiles.interp = 1\r\nTimes.upleveltime25 = 1\r\nTimes.downleveltime25 = 0\r\nTimes.upleveltime50 = 1\r\nTimes.downleveltime50 = 0\r\nTimes.upleveltime75 = 1\r\nTimes.downleveltime75 = 0\r\nTimes.upleveltime90 = 1\r\nTimes.downleveltime90 = 0\r\nTimes.risetime = 1\r\nTimes.falltime = 0\r\nTimes.leftctime = 1\r\nTimes.rightctime = 0\r\nTimes.duration = 0\r\nTimes.buggySecNorm = 0\r\nTimes.norm = segment\r\nLpc.lpGain = 1\r\nLpc.lpc = 1\r\nLpc.firstCoeff = 0\r\nLpc.order = 5\r\nnonZeroFuncts = 0\r\nmasterTimeNorm = segment\r\n\r\n; functionals for pitch onsets/offsets\r\n[is13_functionalsF0:cFunctionals]\r\nreader.dmLevel = is13_lld_f0_nzsmo\r\nwriter.dmLevel = is13_functionalsF0\r\n//nameAppend = ff0\r\ncopyInputName = 1\r\n\\{\\cm[bufferModeRbConf]}\r\n\\{\\cm[frameModeFunctionalsConf]}\r\nfunctionalsEnabled = Means ; Segments \r\nMeans.amean = 0\r\nMeans.absmean = 0\r\nMeans.qmean = 0\r\nMeans.nzamean = 0\r\nMeans.nzabsmean = 0\r\nMeans.nzqmean = 0\r\nMeans.nzgmean = 0\r\nMeans.nnz = 1\r\nMeans.norm = segment\r\nSegments.maxNumSeg = 100\r\nSegments.segmentationAlgorithm = nonX\r\nSegments.X = 0.0\r\nSegments.numSegments = 0\r\nSegments.meanSegLen = 1\r\nSegments.maxSegLen = 1\r\nSegments.minSegLen = 1\r\nSegments.segLenStddev = 1\r\nSegments.norm = second\r\nnonZeroFuncts = 0\r\nmasterTimeNorm = segment\r\n\r\n; functionals for pitch and vq related lld in voiced regions\r\n[is13_functionalsNz:cFunctionals]\r\nreader.dmLevel = is13_lld_nzsmo;is13_lld_nzsmo_de\r\nwriter.dmLevel = is13_functionalsNz\r\n// nameAppend = \r\ncopyInputName = 1\r\n\\{\\cm[bufferModeRbConf]}\r\n\\{\\cm[frameModeFunctionalsConf]}\r\nfunctionalsEnabled = Means ; Extremes ; Regression ; Percentiles ; Moments ; Times ; Lpc\r\nMeans.amean = 1\r\nMeans.posamean = 1\r\nMeans.absmean = 0\r\nMeans.qmean = 0\r\nMeans.rqmean = 1\r\nMeans.nzamean = 0\r\nMeans.nzabsmean = 0\r\nMeans.nzqmean = 0\r\nMeans.posrqmean = 0\r\nMeans.nzgmean = 0\r\nMeans.nnz = 0\r\nMeans.flatness = 1\r\nMeans.norm = frames\r\nExtremes.max = 0\r\nExtremes.min = 0\r\nExtremes.maxpos = 1\r\nExtremes.minpos = 1\r\nExtremes.maxameandist = 0\r\nExtremes.minameandist = 0\r\nMoments.doRatioLimit = 0\r\nMoments.variance = 0\r\nMoments.stddev = 1\r\nMoments.skewness = 1\r\nMoments.kurtosis = 1\r\nMoments.amean = 0\r\nRegression.centroidUseAbsValues = 0\r\nRegression.centroidRatioLimit = 0\r\nRegression.doRatioLimit = 0\r\nRegression.linregc1 = 1\r\nRegression.linregc2 = 1\r\nRegression.linregerrA = 0\r\nRegression.linregerrQ = 1\r\nRegression.qregc1 = 1\r\nRegression.qregc2 = 1\r\nRegression.qregc3 = 1\r\nRegression.qregerrA = 0\r\nRegression.qregerrQ = 1\r\nRegression.oldBuggyQerr = 0\r\nRegression.centroid = 1\r\nRegression.normRegCoeff = 0\r\nPercentiles.quartiles = 1\r\nPercentiles.iqr = 1\r\nPercentiles.percentile[0] = 0.01\r\nPercentiles.percentile[1] = 0.99\r\nPercentiles.pctlrange[0] = 0-1\r\nPercentiles.interp = 1\r\nTimes.upleveltime25 = 1\r\nTimes.downleveltime25 = 0\r\nTimes.upleveltime50 = 1\r\nTimes.downleveltime50 = 0\r\nTimes.upleveltime75 = 1\r\nTimes.downleveltime75 = 0\r\nTimes.upleveltime90 = 1\r\nTimes.downleveltime90 = 0\r\nTimes.risetime = 1\r\nTimes.falltime = 0\r\nTimes.leftctime = 1\r\nTimes.rightctime = 0\r\nTimes.duration = 0\r\nTimes.buggySecNorm = 0\r\nTimes.norm = segment\r\nLpc.lpGain = 1\r\nLpc.lpc = 1\r\nLpc.firstCoeff = 0\r\nLpc.order = 5\r\nnonZeroFuncts = 1\r\nmasterTimeNorm = segment\r\n\r\n\r\n[is13_functionalsLLD:cFunctionals]\r\nreader.dmLevel = is13_lldA_smo;is13_lldB_smo\r\nwriter.dmLevel = is13_functionalsLLD\r\ncopyInputName = 1\r\n\\{\\cm[bufferModeRbConf]}\r\n\\{\\cm[frameModeFunctionalsConf]}\r\nfunctionalsEnabled = Means ; Peaks2 ; Regression\r\nMeans.amean = 1\r\nMeans.posamean = 0\r\nMeans.absmean = 0\r\nMeans.qmean = 0\r\nMeans.rqmean = 1\r\nMeans.nzamean = 0\r\nMeans.nzabsmean = 0\r\nMeans.nzqmean = 0\r\nMeans.posrqmean = 0\r\nMeans.nzgmean = 0\r\nMeans.nnz = 0\r\nMeans.flatness = 1\r\nMeans.norm = frames\r\nRegression.centroidUseAbsValues = 0\r\nRegression.centroidRatioLimit = 0\r\nRegression.doRatioLimit = 0\r\nRegression.linregc1 = 1\r\nRegression.linregc2 = 1\r\nRegression.linregerrA = 0\r\nRegression.linregerrQ = 1\r\nRegression.qregc1 = 1\r\nRegression.qregc2 = 1\r\nRegression.qregc3 = 1\r\nRegression.qregerrA = 0\r\nRegression.qregerrQ = 1\r\nRegression.oldBuggyQerr = 0\r\nRegression.centroid = 1\r\nRegression.normRegCoeff = 0\r\nPeaks2.doRatioLimit = 0\r\nPeaks2.numPeaks = 0\r\nPeaks2.meanPeakDist = 1\r\nPeaks2.meanPeakDistDelta = 0\r\nPeaks2.peakDistStddev = 1\r\nPeaks2.peakRangeAbs = 1\r\nPeaks2.peakRangeRel = 1\r\nPeaks2.peakMeanAbs = 1\r\nPeaks2.peakMeanMeanDist = 1\r\nPeaks2.peakMeanRel = 1\r\nPeaks2.ptpAmpMeanAbs = 0\r\nPeaks2.ptpAmpMeanRel = 0\r\nPeaks2.ptpAmpStddevAbs = 0\r\nPeaks2.ptpAmpStddevRel = 0\r\nPeaks2.minRangeAbs = 0\r\nPeaks2.minRangeRel = 1\r\nPeaks2.minMeanAbs = 0\r\nPeaks2.minMeanMeanDist = 0\r\nPeaks2.minMeanRel = 0\r\nPeaks2.mtmAmpMeanAbs = 0\r\nPeaks2.mtmAmpMeanRel = 0\r\nPeaks2.mtmAmpStddevAbs = 0\r\nPeaks2.mtmAmpStddevRel = 0\r\nPeaks2.meanRisingSlope = 1\r\nPeaks2.maxRisingSlope = 0\r\nPeaks2.minRisingSlope = 0\r\nPeaks2.stddevRisingSlope = 1\r\nPeaks2.meanFallingSlope = 1\r\nPeaks2.maxFallingSlope = 0\r\nPeaks2.minFallingSlope = 0\r\nPeaks2.stddevFallingSlope = 1\r\nPeaks2.norm = seconds\r\nPeaks2.relThresh = 0.100000\r\nPeaks2.dynRelThresh = 0\r\n;Peaks2.posDbgOutp = minmax.txt\r\nPeaks2.posDbgAppend = 0\r\nPeaks2.consoleDbg = 0\r\n\r\n\r\n[is13_functionalsDelta:cFunctionals]\r\nreader.dmLevel = is13_lldA_smo_de;is13_lldB_smo_de\r\nwriter.dmLevel = is13_functionalsDelta\r\ncopyInputName = 1\r\n\\{\\cm[bufferModeRbConf]}\r\n\\{\\cm[frameModeFunctionalsConf]}\r\nfunctionalsEnabled = Means ; Peaks2\r\nMeans.amean = 0\r\nMeans.posamean = 1\r\nMeans.absmean = 0\r\nMeans.qmean = 0\r\nMeans.rqmean = 1\r\nMeans.nzamean = 0\r\nMeans.nzabsmean = 0\r\nMeans.nzqmean = 0\r\nMeans.posrqmean = 0\r\nMeans.nzgmean = 0\r\nMeans.nnz = 0\r\nMeans.flatness = 1\r\nMeans.norm = frames\r\nPeaks2.doRatioLimit = 0\r\nPeaks2.numPeaks = 0\r\nPeaks2.meanPeakDist = 1\r\nPeaks2.meanPeakDistDelta = 0\r\nPeaks2.peakDistStddev = 1\r\nPeaks2.peakRangeAbs = 1\r\nPeaks2.peakRangeRel = 1\r\nPeaks2.peakMeanAbs = 1\r\nPeaks2.peakMeanMeanDist = 1\r\nPeaks2.peakMeanRel = 1\r\nPeaks2.ptpAmpMeanAbs = 0\r\nPeaks2.ptpAmpMeanRel = 0\r\nPeaks2.ptpAmpStddevAbs = 0\r\nPeaks2.ptpAmpStddevRel = 0\r\nPeaks2.minRangeAbs = 0\r\nPeaks2.minRangeRel = 1\r\nPeaks2.minMeanAbs = 0\r\nPeaks2.minMeanMeanDist = 0\r\nPeaks2.minMeanRel = 0\r\nPeaks2.mtmAmpMeanAbs = 0\r\nPeaks2.mtmAmpMeanRel = 0\r\nPeaks2.mtmAmpStddevAbs = 0\r\nPeaks2.mtmAmpStddevRel = 0\r\nPeaks2.meanRisingSlope = 1\r\nPeaks2.maxRisingSlope = 0\r\nPeaks2.minRisingSlope = 0\r\nPeaks2.stddevRisingSlope = 1\r\nPeaks2.meanFallingSlope = 1\r\nPeaks2.maxFallingSlope = 0\r\nPeaks2.minFallingSlope = 0\r\nPeaks2.stddevFallingSlope = 1\r\nPeaks2.norm = seconds\r\nPeaks2.relThresh = 0.100000\r\nPeaks2.dynRelThresh = 0\r\n;Peaks2.posDbgOutp = minmax.txt\r\nPeaks2.posDbgAppend = 0\r\nPeaks2.consoleDbg = 0\r\n\r\n\r\n\r\n"
  },
  {
    "path": "config/IS13_ComParE_core.lld.conf.inc",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\r\n///////// > openSMILE configuration file for ComParE <               //////////////////\r\n/////////                                                            //////////////////\r\n///////// (c) 2014 by audEERING                                      //////////////////\r\n/////////     All rights reserved. See file COPYING for details.     //////////////////\r\n///////////////////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_frame60].type=cFramer\r\ninstance[is13_win60].type=cWindower\r\ninstance[is13_fft60].type=cTransformFFT\r\ninstance[is13_fftmp60].type=cFFTmagphase\r\n\r\n[is13_frame60:cFramer]\r\nreader.dmLevel=wave\r\nwriter.dmLevel=is13_frame60\r\n\\{\\cm[bufferModeRbConf{shared/BufferModeRb.conf.inc}:path to included config to set the buffer mode for the standard ringbuffer levels]}\r\nframeSize = 0.060\r\nframeStep = 0.010\r\nframeCenterSpecial = left\r\n\r\n[is13_win60:cWindower]\r\nreader.dmLevel=is13_frame60\r\nwriter.dmLevel=is13_winG60\r\nwinFunc=gauss\r\ngain=1.0\r\nsigma=0.4\r\n\r\n[is13_fft60:cTransformFFT]\r\nreader.dmLevel=is13_winG60\r\nwriter.dmLevel=is13_fftcG60\r\n ; for compatibility with 2.2.0 and older versions\r\nzeroPadSymmetric = 0\r\n\r\n[is13_fftmp60:cFFTmagphase]\r\nreader.dmLevel=is13_fftcG60\r\nwriter.dmLevel=is13_fftmagG60\r\n\r\n\r\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_frame25].type=cFramer\r\ninstance[is13_win25].type=cWindower\r\ninstance[is13_fft25].type=cTransformFFT\r\ninstance[is13_fftmp25].type=cFFTmagphase\r\n\r\n[is13_frame25:cFramer]\r\nreader.dmLevel=wave\r\nwriter.dmLevel=is13_frame25\r\n\\{\\cm[bufferModeRbConf]}\r\nframeSize = 0.020\r\nframeStep = 0.010\r\nframeCenterSpecial = left\r\n\r\n[is13_win25:cWindower]\r\nreader.dmLevel=is13_frame25\r\nwriter.dmLevel=is13_winH25\r\nwinFunc=hamming\r\n\r\n[is13_fft25:cTransformFFT]\r\nreader.dmLevel=is13_winH25\r\nwriter.dmLevel=is13_fftcH25\r\n ; for compatibility with 2.2.0 and older versions\r\nzeroPadSymmetric = 0\r\n\r\n[is13_fftmp25:cFFTmagphase]\r\nreader.dmLevel=is13_fftcH25\r\nwriter.dmLevel=is13_fftmagH25\r\n\r\n\r\n\r\n;;;;;;;;;;;;;;;;;;;; HPS pitch\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_scale].type=cSpecScale\r\ninstance[is13_shs].type=cPitchShs\r\n\r\n[is13_scale:cSpecScale]\r\nreader.dmLevel=is13_fftmagG60\r\nwriter.dmLevel=is13_hpsG60\r\ncopyInputName = 1\r\nprocessArrayFields = 0\r\nscale=octave\r\nsourceScale = lin\r\ninterpMethod = spline\r\nminF = 25\r\nmaxF = -1\r\nnPointsTarget = 0\r\nspecSmooth = 1\r\nspecEnhance = 1\r\nauditoryWeighting = 1 \r\n\r\n[is13_shs:cPitchShs]\r\nreader.dmLevel=is13_hpsG60\r\nwriter.dmLevel=is13_pitchShsG60\r\n\\{\\cm[bufferModeRbLagConf{shared/BufferModeRbLag.conf.inc}:path to included config to set the buffer mode for levels which will be joint with Viterbi smoothed -lagged- F0]}\r\ncopyInputName = 1\r\nprocessArrayFields = 0\r\nmaxPitch = 620\r\nminPitch = 52\r\nnCandidates = 6\r\nscores = 1\r\nvoicing = 1\r\nF0C1 = 0\r\nvoicingC1 = 0\r\nF0raw = 1\r\nvoicingClip = 1\r\nvoicingCutoff = 0.700000\r\ninputFieldSearch = Mag_octScale\r\noctaveCorrection = 0\r\nnHarmonics = 15\r\ncompressionFactor = 0.850000\r\ngreedyPeakAlgo = 1\r\n\r\n;;;;; Pitch with Viterbi smoother\r\n[componentInstances:cComponentManager]\r\ninstance[is13_energy60].type=cEnergy\r\n\r\n[is13_energy60:cEnergy]\r\nreader.dmLevel=is13_winG60\r\nwriter.dmLevel=is13_e60\r\n ; This must be > than buffersize of viterbi smoother\r\n\\{\\cm[bufferModeRbLagConf]}\r\nrms=1\r\nlog=0\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_pitchSmoothViterbi].type=cPitchSmootherViterbi\r\n\r\n[is13_pitchSmoothViterbi:cPitchSmootherViterbi]\r\nreader.dmLevel=is13_pitchShsG60\r\nreader2.dmLevel=is13_pitchShsG60\r\nwriter.dmLevel=is13_pitchG60_viterbi\r\n\\{\\cm[bufferModeRbLagConf]}\r\ncopyInputName = 1\r\nbufferLength=30\r\nF0final = 1\r\nF0finalEnv = 0\r\nvoicingFinalClipped = 0\r\nvoicingFinalUnclipped = 1\r\nF0raw = 0\r\nvoicingC1 = 0\r\nvoicingClip = 0\r\nwTvv =10.0\r\nwTvvd= 5.0\r\nwTvuv=10.0\r\nwThr = 4.0\r\nwTuu = 0.0\r\nwLocal=2.0\r\nwRange=1.0\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_volmerge].type = cValbasedSelector\r\n\r\n[is13_volmerge:cValbasedSelector]\r\nreader.dmLevel = is13_e60;is13_pitchG60_viterbi\r\nwriter.dmLevel = is13_pitchG60\r\n\\{\\cm[bufferModeRbLagConf]}\r\nidx=0\r\nthreshold=0.001\r\nremoveIdx=1\r\nzeroVec=1\r\noutputVal=0.0\r\n\r\n;;;;;;;;;;;;;;;;;;; Voice Quality (VQ)\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_pitchJitter].type=cPitchJitter\r\n\r\n[is13_pitchJitter:cPitchJitter]\r\nreader.dmLevel = wave\r\nwriter.dmLevel = is13_jitterShimmer\r\n\\{\\cm[bufferModeRbLagConf]}\r\ncopyInputName = 1\r\nF0reader.dmLevel = is13_pitchG60\r\nF0field = F0final\r\nsearchRangeRel = 0.250000\r\njitterLocal = 1\r\njitterDDP = 1\r\njitterLocalEnv = 0\r\njitterDDPEnv = 0\r\nshimmerLocal = 1\r\nshimmerLocalEnv = 0\r\nonlyVoiced = 0\r\nlogHNR = 1\r\ninputMaxDelaySec = 2.0\r\n;periodLengths = 0\r\n;periodStarts = 0\r\nuseBrokenJitterThresh = 1\r\n\r\n;;;;;;;;;;;;;;;;;;;;; Energy / loudness\r\n\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_energy].type=cEnergy\r\ninstance[is13_melspec1].type=cMelspec\r\ninstance[is13_audspec].type=cPlp\r\ninstance[is13_audspecRasta].type=cPlp\r\ninstance[is13_audspecSum].type=cVectorOperation\r\ninstance[is13_audspecRastaSum].type=cVectorOperation\r\n\r\n[is13_energy:cEnergy]\r\nreader.dmLevel = is13_frame25\r\nwriter.dmLevel = is13_energy\r\nlog=0\r\nrms=1\r\n; Enable this only for if quadratic energy is needed, otherwise it breaks ComParE feature set compatibility!!\r\n;  energy2=1\r\n\r\n[is13_melspec1:cMelspec]\r\nreader.dmLevel=is13_fftmagH25\r\nwriter.dmLevel=is13_melspec1\r\n; htk compatible sample value scaling\r\nhtkcompatible = 0\r\nnBands = 26\r\n; use power spectrum instead of magnitude spectrum\r\nusePower = 1\r\nlofreq = 20\r\nhifreq = 8000\r\nspecScale = mel\r\nshowFbank = 0\r\n\r\n; perform auditory weighting of spectrum\r\n[is13_audspec:cPlp]\r\nreader.dmLevel=is13_melspec1\r\nwriter.dmLevel=is13_audspec\r\nfirstCC = 0\r\nlpOrder = 5\r\ncepLifter = 22\r\ncompression = 0.33\r\nhtkcompatible = 0 \r\ndoIDFT = 0\r\ndoLpToCeps = 0\r\ndoLP = 0\r\ndoInvLog = 0\r\ndoAud = 1\r\ndoLog = 0\r\nnewRASTA=0\r\nRASTA=0\r\n\r\n; perform RASTA style filtering of auditory spectra\r\n[is13_audspecRasta:cPlp]\r\nreader.dmLevel=is13_melspec1\r\nwriter.dmLevel=is13_audspecRasta\r\nnameAppend = Rfilt\r\nfirstCC = 0\r\nlpOrder = 5\r\ncepLifter = 22\r\ncompression = 0.33\r\nhtkcompatible = 0 \r\ndoIDFT = 0\r\ndoLpToCeps = 0\r\ndoLP = 0\r\ndoInvLog = 0\r\ndoAud = 1\r\ndoLog = 0\r\nnewRASTA=1\r\nRASTA=0\r\n\r\n[is13_audspecSum:cVectorOperation]\r\nreader.dmLevel = is13_audspec\r\nwriter.dmLevel = is13_audspecSum\r\n// nameAppend = \r\ncopyInputName = 1\r\nprocessArrayFields = 0\r\noperation = ll1\r\nnameBase = audspec\r\n\r\n[is13_audspecRastaSum:cVectorOperation]\r\nreader.dmLevel = is13_audspecRasta\r\nwriter.dmLevel = is13_audspecRastaSum\r\n// nameAppend = \r\ncopyInputName = 1\r\nprocessArrayFields = 0\r\noperation = ll1\r\nnameBase = audspecRasta\r\n\r\n;;;;;;;;;;;;;;; spectral\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_spectral].type=cSpectral\r\n\r\n\r\n[is13_spectral:cSpectral]\r\nreader.dmLevel=is13_fftmagH25\r\nwriter.dmLevel=is13_spectral\r\nbands[0]=250-650\r\nbands[1]=1000-4000\r\nrollOff[0] = 0.25\r\nrollOff[1] = 0.50\r\nrollOff[2] = 0.75\r\nrollOff[3] = 0.90\r\nflux=1\r\ncentroid=1\r\nmaxPos=0\r\nminPos=0\r\nentropy=1\r\nvariance=1\r\nskewness=1\r\nkurtosis=1\r\nslope=1\r\nharmonicity=1\r\nsharpness=1\r\n\r\n\r\n;;;;;;;;;;;;;;; mfcc\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_melspecMfcc].type=cMelspec\r\ninstance[is13_mfcc].type=cMfcc\r\n\r\n[is13_melspecMfcc:cMelspec]\r\nreader.dmLevel=is13_fftmagH25\r\nwriter.dmLevel=is13_melspecMfcc\r\ncopyInputName = 1\r\nprocessArrayFields = 1\r\n; htk compatible sample value scaling\r\nhtkcompatible = 1\r\nnBands = 26\r\n; use power spectrum instead of magnitude spectrum\r\nusePower = 1\r\nlofreq = 20\r\nhifreq = 8000\r\nspecScale = mel\r\ninverse = 0\r\n\r\n[is13_mfcc:cMfcc]\r\nreader.dmLevel=is13_melspecMfcc\r\nwriter.dmLevel=is13_mfcc1_12\r\ncopyInputName = 0\r\nprocessArrayFields = 1\r\nfirstMfcc = 1\r\nlastMfcc  = 14\r\ncepLifter = 22.0\r\nhtkcompatible = 1\r\n\r\n\r\n;;;;;;;;;;;;;;;;  zcr\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_mzcr].type=cMZcr\r\n\r\n[is13_mzcr:cMZcr]\r\nreader.dmLevel = is13_frame60\r\nwriter.dmLevel = is13_zcr\r\ncopyInputName = 1\r\nprocessArrayFields = 1\r\nzcr = 1\r\nmcr = 0\r\namax = 0\r\nmaxmin = 0\r\ndc = 0\r\n\r\n\r\n;;;;;;;;;;;;;;;;;;;; smoothing\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[is13_smoNz].type=cContourSmoother\r\ninstance[is13_smoA].type=cContourSmoother\r\ninstance[is13_smoB].type=cContourSmoother\r\ninstance[is13_f0sel].type=cDataSelector\r\n\r\n[is13_smoNz:cContourSmoother]\r\nreader.dmLevel = is13_pitchG60;is13_jitterShimmer\r\nwriter.dmLevel = is13_lld_nzsmo\r\n\\{\\cm[bufferModeConf{shared/BufferMode.conf.inc}:path to included config to set the buffer mode for the levels before the functionals]}\r\nnameAppend = sma\r\ncopyInputName = 1\r\nnoPostEOIprocessing = 0\r\nsmaWin = 3\r\nnoZeroSma = 1\r\n\r\n[is13_f0sel:cDataSelector]\r\nreader.dmLevel = is13_lld_nzsmo\r\nwriter.dmLevel = is13_lld_f0_nzsmo\r\n\\{\\cm[bufferModeConf]}\r\nnameAppend = ff0\r\nselected = F0final_sma\r\n\r\n[is13_smoA:cContourSmoother]\r\nreader.dmLevel = is13_audspecSum;is13_audspecRastaSum;is13_energy;is13_zcr\r\nwriter.dmLevel = is13_lldA_smo\r\n\\{\\cm[bufferModeConf]}\r\nnameAppend = sma\r\ncopyInputName = 1\r\nnoPostEOIprocessing = 0\r\nsmaWin = 3\r\n\r\n[is13_smoB:cContourSmoother]\r\nreader.dmLevel = is13_audspecRasta;is13_spectral;is13_mfcc1_12\r\nwriter.dmLevel = is13_lldB_smo\r\n\\{\\cm[bufferModeConf]}\r\nnameAppend = sma\r\ncopyInputName = 1\r\nnoPostEOIprocessing = 0\r\nsmaWin = 3\r\n\r\n;;;;;;;;; deltas\r\n[componentInstances:cComponentManager]\r\ninstance[is13_deNz].type=cDeltaRegression\r\ninstance[is13_deA].type=cDeltaRegression\r\ninstance[is13_deB].type=cDeltaRegression\r\ninstance[is13_def0sel].type=cDeltaRegression\r\n\r\n[is13_deNz:cDeltaRegression]\r\nreader.dmLevel = is13_lld_nzsmo\r\nwriter.dmLevel = is13_lld_nzsmo_de\r\n\\{\\cm[bufferModeConf]}\r\nonlyInSegments = 1\r\nzeroSegBound = 1\r\n\r\n[is13_deA:cDeltaRegression]\r\nreader.dmLevel = is13_lldA_smo\r\nwriter.dmLevel = is13_lldA_smo_de\r\n\\{\\cm[bufferModeConf]}\r\n\r\n[is13_deB:cDeltaRegression]\r\nreader.dmLevel = is13_lldB_smo\r\nwriter.dmLevel = is13_lldB_smo_de\r\n\\{\\cm[bufferModeConf]}\r\n\r\n[is13_def0sel:cDeltaRegression]\r\nreader.dmLevel = is13_lld_f0_nzsmo\r\nwriter.dmLevel = is13_lld_f0_nzsmo_de\r\n\\{\\cm[bufferModeConf]}\r\nonlyInSegments = 1\r\nzeroSegBound = 1\r\n\r\n\r\n"
  },
  {
    "path": "config/MFCC12_0_D_A.conf",
    "content": "\n///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file to extract MFCC features <  //////////////////\n/////////   HTK target kind: MFCC_0_D_A, numCeps=12                  //////////////////\n/////////                                                            //////////////////\n///////// (c) 2013-2016 audEERING.                                   //////////////////\n/////////     All rights reserverd. See file COPYING for details.    //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\n///////////////////////////////////////////////////////////////////////////////////////\n;\n; This section is always required in openSMILE configuration files\n;   it configures the componentManager and gives a list of all components which are to be loaded\n; The order in which the components are listed should match \n;   the order of the data flow for most efficient processing\n;\n///////////////////////////////////////////////////////////////////////////////////////\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\n\n\\{shared/standard_wave_input.conf.inc}\n\n[componentInstances:cComponentManager]\n ; audio framer\ninstance[frame].type=cFramer\n ; speech pre-emphasis (on a per frame basis as HTK does it)\ninstance[pe].type=cVectorPreemphasis\n ; apply a window function to pre-emphasised frames\ninstance[win].type=cWindower\n ; transform to the frequency domain using FFT\ninstance[fft].type=cTransformFFT\n ; compute magnitude of the complex fft from the previous component\ninstance[fftmag].type=cFFTmagphase\n ; compute Mel-bands from magnitude spectrum\ninstance[melspec].type=cMelspec\n ; compute MFCC from Mel-band spectrum\ninstance[mfcc].type=cMfcc\n ; compute delta coefficients from mfcc and energy\ninstance[delta].type=cDeltaRegression\n ; compute acceleration coefficients from delta coefficients of mfcc and energy\ninstance[accel].type=cDeltaRegression\n\n; run single threaded (nThreads=1)\n; NOTE: a single thread is more efficient for processing small files, since multi-threaded processing involves more \n;       overhead during startup, which will make the system slower in the end\nnThreads=1\n; do not show any internal dataMemory level settings \n; (if you want to see them set the value to 1, 2, 3, or 4, depending on the amount of detail you wish)\nprintLevelStats=0\n\n\n/////////////////////////////////////////////////////////////////////////////////////////////\n/////////////////////////   component configuration  ////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////////////////////\n; the following sections configure the components listed above\n; a help on configuration parameters can be obtained with \n;  SMILExtract -H\n; or\n;  SMILExtract -H configTypeName (= componentTypeName)\n/////////////////////////////////////////////////////////////////////////////////////////////\n\n[frame:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames\nnoPostEOIprocessing = 1\ncopyInputName = 1\nframeSize = 0.0250\nframeStep = 0.010\nframeMode = fixed\nframeCenterSpecial = left\n\n[pe:cVectorPreemphasis]\nreader.dmLevel=frames\nwriter.dmLevel=framespe\nk = 0.97\nde = 0\n\n[win:cWindower]\nreader.dmLevel=framespe\nwriter.dmLevel=winframes\ncopyInputName = 1\nprocessArrayFields = 1\n ; hamming window\nwinFunc = ham\n ; no gain, no offset\ngain = 1.0\noffset = 0\n\n[fft:cTransformFFT]\nreader.dmLevel=winframes\nwriter.dmLevel=fft\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmag:cFFTmagphase]\nreader.dmLevel=fft\nwriter.dmLevel=fftmag\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\nmagnitude = 1\nphase = 0\n\n[melspec:cMelspec]\nreader.dmLevel=fftmag\nwriter.dmLevel=melspec\ncopyInputName = 1\nprocessArrayFields = 1\n; htk compatible sample value scaling\nhtkcompatible = 1\nnBands = 26\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 0\nhifreq = 8000\nspecScale = mel\ninverse = 0\n\n[mfcc:cMfcc]\nreader.dmLevel=melspec\nwriter.dmLevel=ft0\ncopyInputName = 1\nprocessArrayFields = 1\nfirstMfcc = 0\nlastMfcc  = 12\ncepLifter = 22.0\nhtkcompatible = 1\n\n\n[delta:cDeltaRegression]\nreader.dmLevel=ft0\nwriter.dmLevel=ft0de\nnameAppend = de\ncopyInputName = 1\nnoPostEOIprocessing = 0\ndeltawin=2\nblocksize=1\n\n[accel:cDeltaRegression]\nreader.dmLevel=ft0de\nwriter.dmLevel=ft0dede\nnameAppend = de\ncopyInputName = 1\nnoPostEOIprocessing = 0\ndeltawin=2\nblocksize=1\n\n  //////////////////////////////////////////////////////////////////////\n ///////////////////  data output configuration  //////////////////////\n//////////////////////////////////////////////////////////////////////\n\n[componentInstances:cComponentManager]\ninstance[audspec_lldconcat].type=cVectorConcat\n\n[audspec_lldconcat:cVectorConcat]\nreader.dmLevel = ft0;ft0de;ft0dede\nwriter.dmLevel = lld\nincludeSingleElementFields = 1\n\n\\{shared/standard_data_output_lldonly.conf.inc}\n\n//////---------------------- END -------------------------///////\n\n"
  },
  {
    "path": "config/MFCC12_0_D_A_Z.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file to extract MFCC features <  //////////////////\n/////////   HTK target kind: MFCC_0_D_A_Z, numCeps=12                //////////////////\n/////////                                                            //////////////////\n/////////  * written 2009 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) audEERING UG (haftungsbeschränkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\n///////////////////////////////////////////////////////////////////////////////////////\n;\n; This section is always required in openSMILE configuration files\n;   it configures the componentManager and gives a list of all components which are to be loaded\n; The order in which the components are listed should match \n;   the order of the data flow for most efficient processing\n;\n///////////////////////////////////////////////////////////////////////////////////////\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\n ; wave file input\ninstance[waveIn].type=cWaveSource\n ; audio framer\ninstance[frame].type=cFramer\n ; speech pre-emphasis (on a per frame basis as HTK does it)\ninstance[pe].type=cVectorPreemphasis\n ; apply a window function to pre-emphasised frames\ninstance[win].type=cWindower\n ; transform to the frequency domain using FFT\ninstance[fft].type=cTransformFFT\n ; compute magnitude of the complex fft from the previous component\ninstance[fftmag].type=cFFTmagphase\n ; compute Mel-bands from magnitude spectrum\ninstance[melspec].type=cMelspec\n ; compute MFCC from Mel-band spectrum\ninstance[mfcc].type=cMfcc\n ; \"cepstral\" mean subtraction of mfcc, delta, and accel coefficients\ninstance[cms].type=cFullinputMean\n ; delta and accel of MFCC\ninstance[delta1].type=cDeltaRegression\ninstance[delta2].type=cDeltaRegression\n ; write the result to an HTK parameter file\ninstance[htkout].type=cHtkSink\n\n; run single threaded (nThreads=1)\n; NOTE: a single thread is more efficient for processing small files, since multi-threaded processing involves more \n;       overhead during startup, which will make the system slower in the end\nnThreads=1\n; do not show any internal dataMemory level settings \n; (if you want to see them set the value to 1, 2, 3, or 4, depending on the amount of detail you wish)\nprintLevelStats=0\n\n\n/////////////////////////////////////////////////////////////////////////////////////////////\n/////////////////////////   component configuration  ////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////////////////////\n; the following sections configure the components listed above\n; a help on configuration parameters can be obtained with \n;  SMILExtract -H\n; or\n;  SMILExtract -H configTypeName (= componentTypeName)\n/////////////////////////////////////////////////////////////////////////////////////////////\n\n[waveIn:cWaveSource]\n ; this sets the level this component writes to\n ; the level will be created by this component\n ; no other components may write to a level having the same name\nwriter.dmLevel=wave\n ; this defines a new commandline option \"-I\" or \"-inputfile\", which can be used to specify \n ; the filename on the commandline instead of having it \"hard-coded\" in the config file\nfilename=\\cm[inputfile(I){test.wav}:name of input file]\n ; mix stereo files down to mono for analysis\nmonoMixdown=1\n\n[frame:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames\nnoPostEOIprocessing = 1\ncopyInputName = 1\nframeSize = 0.0250\nframeStep = 0.010\nframeMode = fixed\nframeCenterSpecial = left\n\n[pe:cVectorPreemphasis]\nreader.dmLevel=frames\nwriter.dmLevel=framespe\nk=0.97\nde = 0\n\n[win:cWindower]\nreader.dmLevel=framespe\nwriter.dmLevel=winframes\ncopyInputName = 1\nprocessArrayFields = 1\n ; hamming window\nwinFunc = ham\n ; no gain\ngain = 1.0\noffset = 0\n\n[fft:cTransformFFT]\nreader.dmLevel=winframes\nwriter.dmLevel=fft\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\n\n[fftmag:cFFTmagphase]\nreader.dmLevel=fft\nwriter.dmLevel=fftmag\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\nmagnitude = 1\nphase = 0\n\n[melspec:cMelspec]\nreader.dmLevel=fftmag\nwriter.dmLevel=melspec\ncopyInputName = 1\nprocessArrayFields = 1\n; htk compatible sample value scaling\nhtkcompatible = 1\nnBands = 26\n; use power spectrum instead of magnitude spectrum\nusePower = 0\nlofreq = 0\nhifreq = 8000\nspecScale = mel\ninverse = 0\n\n[mfcc:cMfcc]\nreader.dmLevel=melspec\nwriter.dmLevel=mfcc\nwriter.levelconf.growDyn=1\nwriter.levelconf.isRb=0\nbuffersize=1000\ncopyInputName = 1\nprocessArrayFields = 1\nfirstMfcc = 0\nlastMfcc  = 12\ncepLifter = 22.0\nhtkcompatible = 1\n\n[delta1:cDeltaRegression]\nreader.dmLevel=mfcc\nwriter.dmLevel=mfccD\nwriter.levelconf.growDyn=1\nwriter.levelconf.isRb=0\nbuffersize=1000\nnameAppend = de\ncopyInputName = 1\nnoPostEOIprocessing = 0\ndeltawin=2\nblocksize=1\n\n[delta2:cDeltaRegression]\nreader.dmLevel=mfccD\nwriter.dmLevel=mfccA\nwriter.levelconf.growDyn=1\nwriter.levelconf.isRb=0\nbuffersize=1000\nnameAppend = de\ncopyInputName = 1\nnoPostEOIprocessing = 0\ndeltawin=2\nblocksize=1\n\n[cms:cFullinputMean]\nreader.dmLevel=mfcc\nwriter.dmLevel=mfccM\n\n  //////////////////////////////////////////////////////////////////////\n ///////////////////  data output configuration  //////////////////////\n//////////////////////////////////////////////////////////////////////\n\n; the HTK sink writes data in HTK parameter format\n[htkout:cHtkSink]\n ; data from the following dataMemory levels in concattenated\n ; to form the output vectors\nreader.dmLevel=mfccM;mfccD;mfccA\n ; this again defines a commandline option for the output file (see waveIn)\nfilename=\\cm[output(O){mfcc.htk}:name of MFCC output filename (HTK format)]\nappend=0\n ; MFCC_0_D_A_Z = 6+256+512+2048+8192 = 2886\nparmKind=11014\n\n\n\n\n\n"
  },
  {
    "path": "config/MFCC12_E_D_A.conf",
    "content": "\n///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file to extract MFCC features <  //////////////////\n/////////   HTK target kind: MFCC_E_D_A, numCeps=12                  //////////////////\n/////////                                                            //////////////////\n/////////  * written 2009 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) audEERING UG (haftungsbeschrnkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\n///////////////////////////////////////////////////////////////////////////////////////\n;\n; This section is always required in openSMILE configuration files\n;   it configures the componentManager and gives a list of all components which are to be loaded\n; The order in which the components are listed should match \n;   the order of the data flow for most efficient processing\n;\n///////////////////////////////////////////////////////////////////////////////////////\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\n\n\\{shared/standard_wave_input.conf.inc}\n\n[componentInstances:cComponentManager]\n ; audio framer\ninstance[frame].type=cFramer\n ; speech pre-emphasis (on a per frame basis as HTK does it)\ninstance[pe].type=cVectorPreemphasis\n ; apply a window function to pre-emphasised frames\ninstance[win].type=cWindower\n ; transform to the frequency domain using FFT\ninstance[fft].type=cTransformFFT\n ; compute magnitude of the complex fft from the previous component\ninstance[fftmag].type=cFFTmagphase\n ; compute Mel-bands from magnitude spectrum\ninstance[melspec].type=cMelspec\n ; compute MFCC from Mel-band spectrum\ninstance[mfcc].type=cMfcc\n ; compute log-energy from raw signal frames \n ; (not windowed, not pre-emphasised: that's the way HTK does it)\ninstance[energy].type=cEnergy\n ; concat mfcc and energy, so we can compute delta and acceleration \n ; coefficients of both features at the same tim\ninstance[cat].type=cVectorConcat\n ; compute delta coefficients from mfcc and energy\ninstance[delta].type=cDeltaRegression\n ; compute acceleration coefficients from delta coefficients of mfcc and energy\ninstance[accel].type=cDeltaRegression\n\n; run single threaded (nThreads=1)\n; NOTE: a single thread is more efficient for processing small files, since multi-threaded processing involves more \n;       overhead during startup, which will make the system slower in the end\nnThreads=1\n; do not show any internal dataMemory level settings \n; (if you want to see them set the value to 1, 2, 3, or 4, depending on the amount of detail you wish)\nprintLevelStats=0\n\n\n/////////////////////////////////////////////////////////////////////////////////////////////\n/////////////////////////   component configuration  ////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////////////////////\n; the following sections configure the components listed above\n; a help on configuration parameters can be obtained with \n;  SMILExtract -H\n; or\n;  SMILExtract -H configTypeName (= componentTypeName)\n/////////////////////////////////////////////////////////////////////////////////////////////\n\n[frame:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames\nnoPostEOIprocessing = 1\ncopyInputName = 1\nframeSize = 0.0250\nframeStep = 0.010\nframeMode = fixed\nframeCenterSpecial = left\n\n[pe:cVectorPreemphasis]\nreader.dmLevel=frames\nwriter.dmLevel=framespe\nk = 0.97\nde = 0\n\n[win:cWindower]\nreader.dmLevel=framespe\nwriter.dmLevel=winframes\ncopyInputName = 1\nprocessArrayFields = 1\n ; hamming window\nwinFunc = ham\n ; no gain, no offset\ngain = 1.0\noffset = 0\n\n[fft:cTransformFFT]\nreader.dmLevel=winframes\nwriter.dmLevel=fft\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmag:cFFTmagphase]\nreader.dmLevel=fft\nwriter.dmLevel=fftmag\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\nmagnitude = 1\nphase = 0\n\n[melspec:cMelspec]\nreader.dmLevel=fftmag\nwriter.dmLevel=melspec\ncopyInputName = 1\nprocessArrayFields = 1\n; htk compatible sample value scaling\nhtkcompatible = 1\nnBands = 26\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 0\nhifreq = 8000\nspecScale = mel\ninverse = 0\n\n[mfcc:cMfcc]\nreader.dmLevel=melspec\nwriter.dmLevel=mfcc\ncopyInputName = 1\nprocessArrayFields = 1\nfirstMfcc = 1\nlastMfcc  = 12\ncepLifter = 22.0\nhtkcompatible = 1\n\n[energy:cEnergy]\nreader.dmLevel=frames\nwriter.dmLevel=energy\nnameAppend = energy\ncopyInputName = 1\nprocessArrayFields = 0\nhtkcompatible=1\nrms = 0\nlog = 1\n\n\n[cat:cVectorConcat]\nreader.dmLevel=mfcc;energy\nwriter.dmLevel=ft0\ncopyInputName = 1\nprocessArrayFields = 0\n\n[delta:cDeltaRegression]\nreader.dmLevel=ft0\nwriter.dmLevel=ft0de\nnameAppend = de\ncopyInputName = 1\nnoPostEOIprocessing = 0\ndeltawin=2\nblocksize=1\n\n[accel:cDeltaRegression]\nreader.dmLevel=ft0de\nwriter.dmLevel=ft0dede\nnameAppend = de\ncopyInputName = 1\nnoPostEOIprocessing = 0\ndeltawin=2\nblocksize=1\n\n  //////////////////////////////////////////////////////////////////////\n ///////////////////  data output configuration  //////////////////////\n//////////////////////////////////////////////////////////////////////\n\n[componentInstances:cComponentManager]\ninstance[audspec_lldconcat].type=cVectorConcat\n\n[audspec_lldconcat:cVectorConcat]\nreader.dmLevel = ft0;ft0de;ft0dede\nwriter.dmLevel = lld\nincludeSingleElementFields = 1\n\n; NOTE: this sets parmKind to USER (9), and not the correct MFCC value.\n\\{shared/standard_data_output_lldonly.conf.inc}\n\n/* old HTK output with correct parmKind\n; the HTK sink writes data in HTK parameter format\n[htkout:cHtkSink]\n ; data from the following dataMemory levels in concattenated\nreader.dmLevel=ft0;ft0de;ft0dede\n ; this again defines a commandline option for the output file (see waveIn)\nfilename=\\cm[output(O){mfcc.htk}:name of MFCC output filename (HTK format)]\nappend = 0\n ; MFCC_E_D_A  6+64+256+512 = 838\nparmKind = 838\n*/\n\n//////---------------------- END -------------------------///////\n\n"
  },
  {
    "path": "config/MFCC12_E_D_A_Z.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file to extract MFCC features <  //////////////////\n/////////   HTK target kind: MFCC_E_D_A_Z, numCeps=12                //////////////////\n/////////                                                            //////////////////\n/////////  * written 2009 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) audEERING UG (haftungsbeschrnkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\n///////////////////////////////////////////////////////////////////////////////////////\n;\n; This section is always required in openSMILE configuration files\n;   it configures the componentManager and gives a list of all components which are to be loaded\n; The order in which the components are listed should match \n;   the order of the data flow for most efficient processing\n;\n///////////////////////////////////////////////////////////////////////////////////////\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\n ; wave file input\ninstance[waveIn].type=cWaveSource\n ; audio framer\ninstance[frame].type=cFramer\n ; speech pre-emphasis (on a per frame basis as HTK does it)\ninstance[pe].type=cVectorPreemphasis\n ; apply a window function to pre-emphasised frames\ninstance[win].type=cWindower\n ; transform to the frequency domain using FFT\ninstance[fft].type=cTransformFFT\n ; compute magnitude of the complex fft from the previous component\ninstance[fftmag].type=cFFTmagphase\n ; compute Mel-bands from magnitude spectrum\ninstance[melspec].type=cMelspec\n ; compute MFCC from Mel-band spectrum\ninstance[mfcc].type=cMfcc\n ; compute log-energy from raw signal frames \n ; (not windowed, not pre-emphasised: that's the way HTK does it)\ninstance[energy].type=cEnergy\n ; \"cepstral\" mean subtraction of mfcc, delta, and accel coefficients\ninstance[cms].type=cFullinputMean\n ; delta and accel of MFCC\ninstance[delta1].type=cDeltaRegression\ninstance[delta2].type=cDeltaRegression\n ; delta and accel of the energy\ninstance[delta1e].type=cDeltaRegression\ninstance[delta2e].type=cDeltaRegression\n ; write the result to an HTK parameter file\ninstance[htkout].type=cHtkSink\n\n; run single threaded (nThreads=1)\n; NOTE: a single thread is more efficient for processing small files, since multi-threaded processing involves more \n;       overhead during startup, which will make the system slower in the end\nnThreads=1\n; do not show any internal dataMemory level settings \n; (if you want to see them set the value to 1, 2, 3, or 4, depending on the amount of detail you wish)\nprintLevelStats=0\n\n\n/////////////////////////////////////////////////////////////////////////////////////////////\n/////////////////////////   component configuration  ////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////////////////////\n; the following sections configure the components listed above\n; a help on configuration parameters can be obtained with \n;  SMILExtract -H\n; or\n;  SMILExtract -H configTypeName (= componentTypeName)\n/////////////////////////////////////////////////////////////////////////////////////////////\n\n[waveIn:cWaveSource]\n ; this sets the level this component writes to\n ; the level will be created by this component\n ; no other components may write to a level having the same name\nwriter.dmLevel=wave\n ; this defines a new commandline option \"-I\" or \"-inputfile\", which can be used to specify \n ; the filename on the commandline instead of having it \"hard-coded\" in the config file\nfilename=\\cm[inputfile(I){test.wav}:name of input file]\n ; mix stereo files down to mono for analysis\nmonoMixdown=1\n\n[frame:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames\nnoPostEOIprocessing = 1\ncopyInputName = 1\nframeSize = 0.0250\nframeStep = 0.010\nframeMode = fixed\nframeCenterSpecial = left\n\n[pe:cVectorPreemphasis]\nreader.dmLevel=frames\nwriter.dmLevel=framespe\nk=0.97\nde = 0\n\n[win:cWindower]\nreader.dmLevel=framespe\nwriter.dmLevel=winframes\ncopyInputName = 1\nprocessArrayFields = 1\n ; hamming window\nwinFunc = ham\n ; no gain\ngain = 1.0\noffset = 0\n\n[fft:cTransformFFT]\nreader.dmLevel=winframes\nwriter.dmLevel=fft\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\n\n[fftmag:cFFTmagphase]\nreader.dmLevel=fft\nwriter.dmLevel=fftmag\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\nmagnitude = 1\nphase = 0\n\n[melspec:cMelspec]\nreader.dmLevel=fftmag\nwriter.dmLevel=melspec\ncopyInputName = 1\nprocessArrayFields = 1\n; htk compatible sample value scaling\nhtkcompatible = 1\nnBands = 26\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 0\nhifreq = 8000\nspecScale = mel\ninverse = 0\n\n[mfcc:cMfcc]\nreader.dmLevel=melspec\nwriter.dmLevel=mfcc\nwriter.levelconf.growDyn=1\nwriter.levelconf.isRb=0\nbuffersize=1000\ncopyInputName = 1\nprocessArrayFields = 1\nfirstMfcc = 1\nlastMfcc  = 12\ncepLifter = 22.0\nhtkcompatible = 1\n\n[delta1:cDeltaRegression]\nreader.dmLevel=mfcc\nwriter.dmLevel=mfccD\nwriter.levelconf.growDyn=1\nwriter.levelconf.isRb=0\nbuffersize=1000\nnameAppend = de\ncopyInputName = 1\nnoPostEOIprocessing = 0\ndeltawin=2\nblocksize=1\n\n[delta2:cDeltaRegression]\nreader.dmLevel=mfccD\nwriter.dmLevel=mfccA\nwriter.levelconf.growDyn=1\nwriter.levelconf.isRb=0\nbuffersize=1000\nnameAppend = de\ncopyInputName = 1\nnoPostEOIprocessing = 0\ndeltawin=2\nblocksize=1\n\n[cms:cFullinputMean]\nreader.dmLevel=mfcc\nwriter.dmLevel=mfccM\n\n\n\n[energy:cEnergy]\nreader.dmLevel=frames\nwriter.dmLevel=energy\nwriter.levelconf.growDyn=1\nwriter.levelconf.isRb=0\nbuffersize=1000\ncopyInputName = 1\nprocessArrayFields = 0\nhtkcompatible=1\nrms = 0\nlog = 1\n\n[delta1e:cDeltaRegression]\nreader.dmLevel=energy\nwriter.dmLevel=energyD\nnameAppend = de\ncopyInputName = 1\nnoPostEOIprocessing = 0\ndeltawin=2\nblocksize=1\n\n[delta2e:cDeltaRegression]\nreader.dmLevel=energyD\nwriter.dmLevel=energyA\nnameAppend = de\ncopyInputName = 1\nnoPostEOIprocessing = 0\ndeltawin=2\nblocksize=1\n\n\n  //////////////////////////////////////////////////////////////////////\n ///////////////////  data output configuration  //////////////////////\n//////////////////////////////////////////////////////////////////////\n\n; the HTK sink writes data in HTK parameter format\n[htkout:cHtkSink]\n ; data from the following dataMemory levels in concattenated\n ; to form the output vectors\nreader.dmLevel=mfccM;energy;mfccD;energyD;mfccA;energyA\n ; this again defines a commandline option for the output file (see waveIn)\nfilename=\\cm[output(O){mfcc.htk}:name of MFCC output filename (HTK format)]\nappend=0\n ; MFCC_E_D_A_Z = 6+64+256+512+2048 = 2886\nparmKind=2886\n\n\n\n\n\n"
  },
  {
    "path": "config/PLP_0_D_A.conf",
    "content": "\n///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file to extract PLP features <   //////////////////\n/////////   HTK target kind: PLP_0_D_A, numCeps=5                    //////////////////\n/////////                                                            //////////////////\n/////////  * written 2010 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) audEERING UG (haftungsbeschränkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\n///////////////////////////////////////////////////////////////////////////////////////\n;\n; This section is always required in openSMILE configuration files\n;   it configures the componentManager and gives a list of all components which are to be loaded\n; The order in which the components are listed should match \n;   the order of the data flow for most efficient processing\n;\n///////////////////////////////////////////////////////////////////////////////////////\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\n\n\\{shared/standard_wave_input.conf.inc}\n\n[componentInstances:cComponentManager]\n ; audio framer\ninstance[frame].type=cFramer\n ; speech pre-emphasis (on a per frame basis as HTK does it)\ninstance[pe].type=cVectorPreemphasis\n ; apply a window function to pre-emphasised frames\ninstance[win].type=cWindower\n ; transform to the frequency domain using FFT\ninstance[fft].type=cTransformFFT\n ; compute magnitude of the complex fft from the previous component\ninstance[fftmag].type=cFFTmagphase\n ; compute critical-bands from magnitude spectrum\ninstance[melspec].type=cMelspec\n ; compute PLP from critical-band spectrum\ninstance[plp].type=cPlp\n ; compute delta coefficients from mfcc and energy\ninstance[delta].type=cDeltaRegression\n ; compute acceleration coefficients from delta coefficients of mfcc and energy\ninstance[accel].type=cDeltaRegression\n\n; run single threaded (nThreads=1)\n; NOTE: a single thread is more efficient for processing small files, since multi-threaded processing involves more \n;       overhead during startup, which will make the system slower in the end\nnThreads=1\n; do not show any internal dataMemory level settings \n; (if you want to see them set the value to 1, 2, 3, or 4, depending on the amount of detail you wish)\nprintLevelStats=0\n\n\n/////////////////////////////////////////////////////////////////////////////////////////////\n/////////////////////////   component configuration  ////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////////////////////\n; the following sections configure the components listed above\n; a help on configuration parameters can be obtained with \n;  SMILExtract -H\n; or\n;  SMILExtract -H configTypeName (= componentTypeName)\n/////////////////////////////////////////////////////////////////////////////////////////////\n\n[frame:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames\nframeSize = 0.0250\nframeStep = 0.010\nframeMode = fixed\nframeCenterSpecial = left\n\n[pe:cVectorPreemphasis]\nreader.dmLevel=frames\nwriter.dmLevel=framespe\nk=0.97\nde=0\n\n[win:cWindower]\nreader.dmLevel=framespe\nwriter.dmLevel=winframes\n ; hamming window\nwinFunc = ham\n ; no gain\ngain = 1.0\noffset = 0\n\n[fft:cTransformFFT]\nreader.dmLevel=winframes\nwriter.dmLevel=fft\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmag:cFFTmagphase]\nreader.dmLevel=fft\nwriter.dmLevel=fftmag\n\n[melspec:cMelspec]\nreader.dmLevel=fftmag\nwriter.dmLevel=melspec\n; htk compatible sample value scaling\nhtkcompatible = 1\nnBands = 26\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 0\nhifreq = 8000\nspecScale = mel\n\n[plp:cPlp]\nreader.dmLevel=melspec\nwriter.dmLevel=plp\nfirstCC = 0\n;lastCC  = 12\nlpOrder = 5\ncepLifter = 22\ncompression = 0.33\nhtkcompatible = 1 \ndoIDFT = 1\ndoLpToCeps = 1\ndoLP = 1\ndoInvLog = 0\ndoAud = 1\ndoLog = 0\n\n[delta:cDeltaRegression]\nreader.dmLevel=plp\nwriter.dmLevel=plpde\ndeltawin=2\nblocksize=1\n\n[accel:cDeltaRegression]\nreader.dmLevel=plpde\nwriter.dmLevel=plpdede\ndeltawin=2\nblocksize=1\n\n  //////////////////////////////////////////////////////////////////////\n ///////////////////  data output configuration  //////////////////////\n//////////////////////////////////////////////////////////////////////\n\n[componentInstances:cComponentManager]\ninstance[audspec_lldconcat].type=cVectorConcat\n\n[audspec_lldconcat:cVectorConcat]\nreader.dmLevel = plp;plpde;plpdede\nwriter.dmLevel = lld\nincludeSingleElementFields = 1\n\n; NOTE: this sets parmKind to USER (9), and not the correct PLP value.\n\\{shared/standard_data_output_lldonly.conf.inc}\n\n/* old HTK output with correct parmKind\n; the HTK sink writes data in HTK parameter format\n[htkout:cHtkSink]\n ; data from the following dataMemory levels in concattenated\nreader.dmLevel=plp;plpde;plpdede\n ; this again defines a commandline option for the output file (see waveIn)\nfilename=\\cm[output(O){mfcc.htk}:name of MFCC output filename (HTK format)]\nappend=0\n ; PLP_0_D_A  = 11 + 256 + 512 + 8192 = 8971\nparmKind=8971\n*/\n\n//////---------------------- END -------------------------///////\n\n"
  },
  {
    "path": "config/PLP_0_D_A_Z.conf",
    "content": "\n///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file to extract PLP features <   //////////////////\n/////////   HTK target kind: PLP_0_D_A_Z, numCeps=5                  //////////////////\n/////////                                                            //////////////////\n/////////  * written 2010 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) audEERING UG (haftungsbeschränkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\n///////////////////////////////////////////////////////////////////////////////////////\n;\n; This section is always required in openSMILE configuration files\n;   it configures the componentManager and gives a list of all components which are to be loaded\n; The order in which the components are listed should match \n;   the order of the data flow for most efficient processing\n;\n///////////////////////////////////////////////////////////////////////////////////////\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\n ; wave file input\ninstance[waveIn].type=cWaveSource\n ; audio framer\ninstance[frame].type=cFramer\n ; speech pre-emphasis (on a per frame basis as HTK does it)\ninstance[pe].type=cVectorPreemphasis\n ; apply a window function to pre-emphasised frames\ninstance[win].type=cWindower\n ; transform to the frequency domain using FFT\ninstance[fft].type=cTransformFFT\n ; compute magnitude of the complex fft from the previous component\ninstance[fftmag].type=cFFTmagphase\n ; compute critical-bands from magnitude spectrum\ninstance[melspec].type=cMelspec\n ; compute PLP from critical-band spectrum\ninstance[plp].type=cPlp\ninstance[cms].type = cFullinputMean\n ; compute delta coefficients from mfcc and energy\ninstance[delta].type=cDeltaRegression\n ; compute acceleration coefficients from delta coefficients of mfcc and energy\ninstance[accel].type=cDeltaRegression\n ; write the result to an HTK parameter file\ninstance[htkout].type=cHtkSink\n\n; run single threaded (nThreads=1)\n; NOTE: a single thread is more efficient for processing small files, since multi-threaded processing involves more \n;       overhead during startup, which will make the system slower in the end\nnThreads=1\n; do not show any internal dataMemory level settings \n; (if you want to see them set the value to 1, 2, 3, or 4, depending on the amount of detail you wish)\nprintLevelStats=0\n\n\n/////////////////////////////////////////////////////////////////////////////////////////////\n/////////////////////////   component configuration  ////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////////////////////\n; the following sections configure the components listed above\n; a help on configuration parameters can be obtained with \n;  SMILExtract -H\n; or\n;  SMILExtract -H configTypeName (= componentTypeName)\n/////////////////////////////////////////////////////////////////////////////////////////////\n\n[waveIn:cWaveSource]\n ; this sets the level this component writes to\n ; the level will be created by this component\n ; no other components may write to a level having the same name\nwriter.dmLevel=wave\n ; this defines a new commandline option \"-I\" or \"-inputfile\", which can be used to specify \n ; the filename on the commandline instead of having it \"hard-coded\" in the config file\nfilename=\\cm[inputfile(I){test.wav}:name of input file]\n ; mix stereo files down to mono for analysis\nmonoMixdown=1\n\n[frame:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames\nframeSize = 0.0250\nframeStep = 0.010\nframeMode = fixed\nframeCenterSpecial = left\n\n[pe:cVectorPreemphasis]\nreader.dmLevel=frames\nwriter.dmLevel=framespe\nk=0.97\nde=0\n\n[win:cWindower]\nreader.dmLevel=framespe\nwriter.dmLevel=winframes\n ; hamming window\nwinFunc = ham\n ; no gain\ngain = 1.0\noffset = 0\n\n[fft:cTransformFFT]\nreader.dmLevel=winframes\nwriter.dmLevel=fft\n\n[fftmag:cFFTmagphase]\nreader.dmLevel=fft\nwriter.dmLevel=fftmag\n\n[melspec:cMelspec]\nreader.dmLevel=fftmag\nwriter.dmLevel=melspec\n; htk compatible sample value scaling\nhtkcompatible = 1\nnBands = 26\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 0\nhifreq = 8000\nspecScale = mel\n\n[plp:cPlp]\nreader.dmLevel=melspec\nwriter.dmLevel=plp\n ; configure level to store full input (required for off-line CMS)\nwriter.levelconf.growDyn=1\nwriter.levelconf.isRb=0\n ; initial buffersize, will grow if needed:\nbuffersize=1000\n\nfirstCC = 0\nlpOrder = 5\ncepLifter = 22\ncompression = 0.33\nhtkcompatible = 1 \ndoIDFT = 1\ndoLpToCeps = 1\ndoLP = 1\ndoInvLog = 0\ndoAud = 1\ndoLog = 0\n\n[cms:cFullinputMean]\nreader.dmLevel=plp\nwriter.dmLevel=plpM\n\n[delta:cDeltaRegression]\nreader.dmLevel=plp\nwriter.dmLevel=plpde\ndeltawin=2\nblocksize=1\n\n[accel:cDeltaRegression]\nreader.dmLevel=plpde\nwriter.dmLevel=plpdede\ndeltawin=2\nblocksize=1\n\n  //////////////////////////////////////////////////////////////////////\n ///////////////////  data output configuration  //////////////////////\n//////////////////////////////////////////////////////////////////////\n\n; the HTK sink writes data in HTK parameter format\n[htkout:cHtkSink]\n ; data from the following dataMemory levels in concattenated\nreader.dmLevel=plpM;plpde;plpdede\n ; this again defines a commandline option for the output file (see waveIn)\nfilename=\\cm[output(O){mfcc.htk}:name of MFCC output filename (HTK format)]\nappend=0\n ; PLP_0_D_A_Z  = 11 + 256 + 512 + 8192 + 2048 = 11019\nparmKind=11019\n\n//////---------------------- END -------------------------///////\n\n"
  },
  {
    "path": "config/PLP_E_D_A.conf",
    "content": "\n///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file to extract PLP features <   //////////////////\n/////////   HTK target kind: PLP_E_D_A, numCeps=5                    //////////////////\n/////////                                                            //////////////////\n/////////  * written 2010 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) audEERING UG (haftungsbeschränkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\n///////////////////////////////////////////////////////////////////////////////////////\n;\n; This section is always required in openSMILE configuration files\n;   it configures the componentManager and gives a list of all components which are to be loaded\n; The order in which the components are listed should match \n;   the order of the data flow for most efficient processing\n;\n///////////////////////////////////////////////////////////////////////////////////////\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\n\n\\{shared/standard_wave_input.conf.inc}\n\n[componentInstances:cComponentManager]\n ; audio framer\ninstance[frame].type=cFramer\n ; speech pre-emphasis (on a per frame basis as HTK does it)\ninstance[pe].type=cVectorPreemphasis\n ; apply a window function to pre-emphasised frames\ninstance[win].type=cWindower\n ; transform to the frequency domain using FFT\ninstance[fft].type=cTransformFFT\n ; compute magnitude of the complex fft from the previous component\ninstance[fftmag].type=cFFTmagphase\n ; compute critical-bands from magnitude spectrum\ninstance[melspec].type=cMelspec\n ; compute PLP from critical-band spectrum\ninstance[plp].type=cPlp\n ; compute log-energy from raw signal frames \n ; (not windowed, not pre-emphasised: that's the way HTK does it)\ninstance[energy].type=cEnergy\n ; concat mfcc and energy, so we can compute delta and acceleration \n ; coefficients of both features at the same tim\ninstance[cat].type=cVectorConcat\n ; compute delta coefficients from mfcc and energy\ninstance[delta].type=cDeltaRegression\n ; compute acceleration coefficients from delta coefficients of mfcc and energy\ninstance[accel].type=cDeltaRegression\n\n; run single threaded (nThreads=1)\n; NOTE: a single thread is more efficient for processing small files, since multi-threaded processing involves more \n;       overhead during startup, which will make the system slower in the end\nnThreads=1\n; do not show any internal dataMemory level settings \n; (if you want to see them set the value to 1, 2, 3, or 4, depending on the amount of detail you wish)\nprintLevelStats=0\n\n\n/////////////////////////////////////////////////////////////////////////////////////////////\n/////////////////////////   component configuration  ////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////////////////////\n; the following sections configure the components listed above\n; a help on configuration parameters can be obtained with \n;  SMILExtract -H\n; or\n;  SMILExtract -H configTypeName (= componentTypeName)\n/////////////////////////////////////////////////////////////////////////////////////////////\n\n[frame:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames\nframeSize = 0.0250\nframeStep = 0.010\nframeMode = fixed\nframeCenterSpecial = left\n\n[pe:cVectorPreemphasis]\nreader.dmLevel=frames\nwriter.dmLevel=framespe\nk=0.97\nde=0\n\n[win:cWindower]\nreader.dmLevel=framespe\nwriter.dmLevel=winframes\n ; hamming window\nwinFunc = ham\n ; no gain\ngain = 1.0\noffset = 0\n\n[fft:cTransformFFT]\nreader.dmLevel=winframes\nwriter.dmLevel=fft\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmag:cFFTmagphase]\nreader.dmLevel=fft\nwriter.dmLevel=fftmag\n\n[melspec:cMelspec]\nreader.dmLevel=fftmag\nwriter.dmLevel=melspec\n; htk compatible sample value scaling\nhtkcompatible = 1\nnBands = 26\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 0\nhifreq = 8000\nspecScale = mel\n\n[plp:cPlp]\nreader.dmLevel=melspec\nwriter.dmLevel=plp\nfirstCC = 1\nlpOrder = 5\ncepLifter = 22\ncompression = 0.33\nhtkcompatible = 1 \ndoIDFT = 1\ndoLpToCeps = 1\ndoLP = 1\ndoInvLog = 0\ndoAud = 1\ndoLog = 0\n\n[energy:cEnergy]\nreader.dmLevel=frames\nwriter.dmLevel=energy\nhtkcompatible=1\nrms = 0\nlog = 1\n\n[cat:cVectorConcat]\nreader.dmLevel=plp;energy\nwriter.dmLevel=ft0\nprocessArrayFields=0\n\n[delta:cDeltaRegression]\nreader.dmLevel=ft0\nwriter.dmLevel=ft0de\ndeltawin=2\nblocksize=1\n\n[accel:cDeltaRegression]\nreader.dmLevel=ft0de\nwriter.dmLevel=ft0dede\ndeltawin=2\nblocksize=1\n\n  //////////////////////////////////////////////////////////////////////\n ///////////////////  data output configuration  //////////////////////\n//////////////////////////////////////////////////////////////////////\n\n[componentInstances:cComponentManager]\ninstance[audspec_lldconcat].type=cVectorConcat\n\n[audspec_lldconcat:cVectorConcat]\nreader.dmLevel = ft0;ft0de;ft0dede\nwriter.dmLevel = lld\nincludeSingleElementFields = 1\n\n; NOTE: this sets parmKind to USER (9), and not the correct PLP value.\n\\{shared/standard_data_output_lldonly.conf.inc}\n\n/* old HTK output with correct parmKind\n[htkout:cHtkSink]\n ; data from the following dataMemory levels in concattenated\nreader.dmLevel=ft0;ft0de;ft0dede\n ; this again defines a commandline option for the output file (see waveIn)\nfilename=\\cm[output(O){mfcc.htk}:name of MFCC output filename (HTK format)]\nappend=0\n ; PLP_0_D_A  = 11 + 256 + 512 + 8192 = 8971\nparmKind=8971\n*/\n\n//////---------------------- END -------------------------///////\n\n"
  },
  {
    "path": "config/PLP_E_D_A_Z.conf",
    "content": "\n///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file to extract PLP features <   //////////////////\n/////////   HTK target kind: PLP_E_D_A_Z, numCeps=5                  //////////////////\n/////////                                                            //////////////////\n/////////  * written 2010 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) audEERING UG (haftungsbeschränkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\n///////////////////////////////////////////////////////////////////////////////////////\n;\n; This section is always required in openSMILE configuration files\n;   it configures the componentManager and gives a list of all components which are to be loaded\n; The order in which the components are listed should match \n;   the order of the data flow for most efficient processing\n;\n///////////////////////////////////////////////////////////////////////////////////////\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\n ; wave file input\ninstance[waveIn].type=cWaveSource\n ; audio framer\ninstance[frame].type=cFramer\n ; speech pre-emphasis (on a per frame basis as HTK does it)\ninstance[pe].type=cVectorPreemphasis\n ; apply a window function to pre-emphasised frames\ninstance[win].type=cWindower\n ; transform to the frequency domain using FFT\ninstance[fft].type=cTransformFFT\n ; compute magnitude of the complex fft from the previous component\ninstance[fftmag].type=cFFTmagphase\n ; compute critical-bands from magnitude spectrum\ninstance[melspec].type=cMelspec\n ; compute PLP from critical-band spectrum\ninstance[plp].type=cPlp\ninstance[cms].type=cFullinputMean\n ; compute log-energy from raw signal frames \n ; (not windowed, not pre-emphasised: that's the way HTK does it)\ninstance[energy].type=cEnergy\n ; concat mfcc and energy, so we can compute delta and acceleration \n ; coefficients of both features at the same tim\ninstance[cat].type=cVectorConcat\n ; compute delta coefficients from mfcc and energy\ninstance[delta].type=cDeltaRegression\n ; compute acceleration coefficients from delta coefficients of mfcc and energy\ninstance[accel].type=cDeltaRegression\n ; write the result to an HTK parameter file\ninstance[htkout].type=cHtkSink\n\n; run single threaded (nThreads=1)\n; NOTE: a single thread is more efficient for processing small files, since multi-threaded processing involves more \n;       overhead during startup, which will make the system slower in the end\nnThreads=1\n; do not show any internal dataMemory level settings \n; (if you want to see them set the value to 1, 2, 3, or 4, depending on the amount of detail you wish)\nprintLevelStats=0\n\n\n/////////////////////////////////////////////////////////////////////////////////////////////\n/////////////////////////   component configuration  ////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////////////////////\n; the following sections configure the components listed above\n; a help on configuration parameters can be obtained with \n;  SMILExtract -H\n; or\n;  SMILExtract -H configTypeName (= componentTypeName)\n/////////////////////////////////////////////////////////////////////////////////////////////\n\n[waveIn:cWaveSource]\n ; this sets the level this component writes to\n ; the level will be created by this component\n ; no other components may write to a level having the same name\nwriter.dmLevel=wave\n ; this defines a new commandline option \"-I\" or \"-inputfile\", which can be used to specify \n ; the filename on the commandline instead of having it \"hard-coded\" in the config file\nfilename=\\cm[inputfile(I){test.wav}:name of input file]\n ; mix stereo files down to mono for analysis\nmonoMixdown=1\n\n[frame:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames\nframeSize = 0.0250\nframeStep = 0.010\nframeMode = fixed\nframeCenterSpecial = left\n\n[pe:cVectorPreemphasis]\nreader.dmLevel=frames\nwriter.dmLevel=framespe\nk=0.97\nde=0\n\n[win:cWindower]\nreader.dmLevel=framespe\nwriter.dmLevel=winframes\n ; hamming window\nwinFunc = ham\n ; no gain\ngain = 1.0\noffset = 0\n\n[fft:cTransformFFT]\nreader.dmLevel=winframes\nwriter.dmLevel=fft\n\n[fftmag:cFFTmagphase]\nreader.dmLevel=fft\nwriter.dmLevel=fftmag\n\n[melspec:cMelspec]\nreader.dmLevel=fftmag\nwriter.dmLevel=melspec\n; htk compatible sample value scaling\nhtkcompatible = 1\nnBands = 26\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 0\nhifreq = 8000\nspecScale = mel\n\n[plp:cPlp]\nreader.dmLevel=melspec\nwriter.dmLevel=plp\nwriter.levelconf.growDyn=1\nwriter.levelconf.isRb=0\nbuffersize=1000\nfirstCC = 1\nlpOrder = 5\ncepLifter = 22\ncompression = 0.33\nhtkcompatible = 1 \ndoIDFT = 1\ndoLpToCeps = 1\ndoLP = 1\ndoInvLog = 0\ndoAud = 1\ndoLog = 0\n\n[cms:cFullinputMean]\nreader.dmLevel=plp\nwriter.dmLevel=plpM\n\n[energy:cEnergy]\nreader.dmLevel=frames\nwriter.dmLevel=energy\nwriter.levelconf.growDyn=1\nwriter.levelconf.isRb=0\nbuffersize=1000\nhtkcompatible=1\nrms = 0\nlog = 1\n\n[cat:cVectorConcat]\nreader.dmLevel=plp;energy\nwriter.dmLevel=ft0\nprocessArrayFields=0\n\n[delta:cDeltaRegression]\nreader.dmLevel=ft0\nwriter.dmLevel=ft0de\ndeltawin=2\nblocksize=1\n\n[accel:cDeltaRegression]\nreader.dmLevel=ft0de\nwriter.dmLevel=ft0dede\ndeltawin=2\nblocksize=1\n\n  //////////////////////////////////////////////////////////////////////\n ///////////////////  data output configuration  //////////////////////\n//////////////////////////////////////////////////////////////////////\n\n; the HTK sink writes data in HTK parameter format\n[htkout:cHtkSink]\n ; data from the following dataMemory levels in concattenated\nreader.dmLevel=plpM;energy;ft0de;ft0dede\n ; this again defines a commandline option for the output file (see waveIn)\nfilename=\\cm[output(O){mfcc.htk}:name of MFCC output filename (HTK format)]\nappend=0\n ; PLP_0_D_A  = 11 + 256 + 512 + 8192 = 8971\nparmKind=8971\n\n//////---------------------- END -------------------------///////\n\n"
  },
  {
    "path": "config/arff_targets.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n/////////     openSMILE arff targets generic config file             //////////////////\n///////// (c) audEERING UG (haftungsbeschränkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n// IMPORTANT: This file is obsoleted by arff_targets.conf.inc !!\n// It contains old examples, but should only be used as reference\n\n//\n// configuration of commandline options for target classes in an ARFF file\n// (cArffSink)\n//\n\n\n// this is an example of a numeric class attribute\n// you specify the numeric class label on the command-line by:\n//  -label1 1.2345\n// if you do not have labels, you can omit the -label1 option\n// the default value \"0.0\" will be assigned to all instances\nclass[0].name = class\nclass[0].type = numeric\ntarget[0].all = \\cm[class{0.0}:instance numeric class label]\n\n// this is an example of a nominal class attribute\n// you specify the class label on the command-line by:\n//  -label1 class1\n// if you do not have labels, you can omit the -label2 option\n// the default value \"0.0\" will be assigned to all instances.\n// NOTE: if you are using only a nominal class label (i.e. no\n// numeric class attribute), change class[1] to class[0], etc.\n/*\nclass[1].name = class\nclass[1].type = {class1,class2,class3,unknown}\ntarget[1].all = \\cm[label2{unknown}:instance nominal class label]\n*/\n\n// This is an example of adding a string, e.g. lyrics or transcribed spoken text\n// Use on the command-line as:\n// -words \"this is a sentence...\"\n// OR: -w \"this is a sentence...\"\n/*\nclass[2].name = words\nclass[2].type = string\ntarget[2].all = \\cm[words(w){empty}:transcribed text]\n*/\n\n"
  },
  {
    "path": "config/audiovisual/arff_targets_age.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// audio+video features for multi-modal speaker trait recog.  /////////////////\n/////////                                                            //////////////////\n///////// (c) audEERING UG (haftungsbeschränkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n//\n// configuration of commandline options for target classes in an ARFF file\n// (cArffSink)\n//\n\n//\n// Working example: Feature extraction for estimating \n//   age, gender and ethnicity from web-videos\n//\n\nclass[0].name = age\nclass[0].type = {adult, young}\ntarget[0].all = \\cm[age(a){?}:age of speaker (young/adult)]\n\nclass[1].name = gender\nclass[1].type = {f, m}\ntarget[1].all = \\cm[gender(g){?}:gender of speaker (m/f)]\n\nclass[2].name = ethnicity\nclass[2].type = {black_asian, white}\ntarget[2].all = \\cm[ethnicity(e){?}:ethnicity of speaker (white/black_asian)]\n"
  },
  {
    "path": "config/audiovisual/audio.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// audio features for multi-modal speaker trait detection     /////////////////\n/////////                                                            //////////////////\n///////// (c) audEERING UG (haftungsbeschränkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n ;===== component manager configuration (= list of enabled components!) =====\n\n[componentInstances:cComponentManager]\n // this line configures the default data memory:\ninstance[dataMemory].type = cDataMemory\n// AUDIO\ninstance[waveIn].type=cWaveSource\n ;;; 40 ms frames features:\ninstance[fr40].type=cFramer\ninstance[w40].type=cWindower\ninstance[fft40].type=cTransformFFT\ninstance[fftmagphase40].type=cFFTmagphase\n ; SHS Pitch:\ninstance[scale].type=cSpecScale\ninstance[pitchShs].type=cPitchShs\ninstance[pitchSmooth].type=cPitchSmoother\ninstance[pitchJitter].type=cPitchJitter\ninstance[pitchSmooth2].type=cPitchSmoother\ninstance[res].type=cSpecResample\n\n ;;; 25 ms frames features:\ninstance[fr25].type=cFramer\ninstance[pe].type=cVectorPreemphasis\ninstance[win].type=cWindower\ninstance[fft].type=cTransformFFT\ninstance[fftmagphase].type=cFFTmagphase\n ; mfcc\ninstance[mspec].type=cMelspec\ninstance[mfcc].type=cMfcc\n ; log mel frequency bands (mfb)\ninstance[mspec2].type=cMelspec\ninstance[vo].type=cVectorOperation\ninstance[lpc].type=cLpc\n ; Line Spectral Frequencies\ninstance[lsp].type=cLsp\n ; Loudness (narrow-band approximation)\ninstance[intens].type=cIntensity\n ;;; all LLD concattenated and smoothed using a moving average filter\ninstance[lld].type=cContourSmoother\ninstance[lld2].type=cContourSmoother\n ; delta coefficients of LLD\ninstance[delta1].type=cDeltaRegression\ninstance[delta2].type=cDeltaRegression\n ;;; functionals over FULL input (e.g. turns)\ninstance[functL1].type=cFunctionals\ninstance[functL1nz].type=cFunctionals\n\n ;;; write/append ONE instance to a Weka ARFF file\ninstance[arffsink].type=cArffSink\n\n // Here you can control the amount of detail displayed for the data memory\n // level configuration. 0 is no information at all, 5 is maximum detail.\nprintLevelStats = 6\n // You can set the number of parallel threads (experimental):\nnThreads = 1\n\n// ============= component configuration sections begin here ==============\n\n// AUDIO PART\n\n[waveIn:cWaveSource]\n ; this sets the level this component writes to\n ; the level will be created by this component\n ; no other components may write to a level having the same name\nwriter.dmLevel=wave\n ; this defines a new commandline option \"-I\" or \"-inputfile\", which can be used to specify \n ; the filename on the commandline instead of having it \"hard-coded\" in the config file\nfilename=\\cm[inputfile(A){test.wav}:name of input file]\n ; mix stereo files down to mono for analysis\nmonoMixdown=1\n\n[fr40:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames40\nframeSize = 0.060\nframeStep = 0.010\nframeCenterSpecial = left\n\n[w40:cWindower]\nreader.dmLevel=frames40\nwriter.dmLevel=win40frame\nwinFunc = gauss\nsigma=0.25\ngain = 1.0\n\n\n[fft40:cTransformFFT]\nreader.dmLevel=win40frame\nwriter.dmLevel=fftc40\n\n[fftmagphase40:cFFTmagphase]\nreader.dmLevel=fftc40\nwriter.dmLevel=fftmag40\n\n\n[scale:cSpecScale]\nreader.dmLevel=fftmag40\nwriter.dmLevel=hps\nscale=log\n ; octave scale\nlogScaleBase=2\n\n[pitchShs:cPitchShs]\nreader.dmLevel=hps\nwriter.dmLevel=pitchShs\nF0raw = 0\nvoicingClip = 0\nvoicingC1=0\nscores=1\nvoicing=1\nnCandidates=3\noctaveCorrection=0\n\n[pitchSmooth:cPitchSmoother]\nreader.dmLevel=pitchShs\nwriter.dmLevel=pitch\nF0raw = 0\nF0final = 0\nF0finalEnv = 1\nvoicingFinalUnclipped = 1\nmedianFilter0 = 0\npostSmoothingMethod = simple\n;simple\noctaveCorrection = 0\nwriter.levelconf.nT=10\n;writer.levelconf.noHang=2\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n[csvsink:cCsvSink]\nreader.dmLevel=pitch;pitchA\nfilename=pitchdbg.csv\n\n[pitchSmooth2:cPitchSmoother]\nreader.dmLevel=pitchShs\nwriter.dmLevel=pitchF\nF0raw = 0\nF0final = 1\nF0finalEnv = 0\nvoicingFinalUnclipped = 0\nmedianFilter0 = 0\npostSmoothingMethod = simple\noctaveCorrection = 0\nwriter.levelconf.nT=10\n;writer.levelconf.noHang=2\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n ;;;; default (template) configuration section for component 'cPitchJitter' ;;;;\n[pitchJitter:cPitchJitter]\nreader.dmLevel = wave\nwriter.dmLevel = jitter\n// nameAppend =\ncopyInputName = 1\nF0reader.dmLevel = pitchF\nF0field = F0final\nsearchRangeRel = 0.250000\njitterLocal = 1\njitterDDP = 1\njitterLocalEnv = 0\njitterDDPEnv = 0\nshimmerLocal = 1\nshimmerLocalEnv = 0\nonlyVoiced = 0\n;periodLengths = 0\n;periodStarts = 0\n\n\n[fr25:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames\nframeSize = 0.025\nframeStep = 0.010\nframeCenterSpecial = left\n\n[pe:cVectorPreemphasis]\nreader.dmLevel=frames\nwriter.dmLevel=framespe\nk=0.97\n\n[win:cWindower]\nreader.dmLevel=framespe\nwriter.dmLevel=winframe\nwinFunc = ham\ngain = 1.0\n\n[fft:cTransformFFT]\nreader.dmLevel=winframe\nwriter.dmLevel=fftc\n\n[fftmagphase:cFFTmagphase]\nreader.dmLevel=fftc\nwriter.dmLevel=fftmag\n\n[mspec:cMelspec]\nreader.dmLevel=fftmag\nwriter.dmLevel=mspec1\nhtkcompatible = 0\nusePower = 1\nlofreq = 20\nhifreq = 8000\nnBands=26\n\n[mfcc:cMfcc]\nreader.dmLevel = mspec1\nwriter.dmLevel = mfcc\nhtkcompatible = 0\nfirstMfcc=0\nlastMfcc=14\ncepLifter=22\n\n[mspec2:cMelspec]\nreader.dmLevel=fftmag\nwriter.dmLevel=mspec2\nhtkcompatible = 0\nusePower = 1\nlofreq = 20\nhifreq = 6500\nnBands=8\n\n[vo:cVectorOperation]\nreader.dmLevel=mspec2\nwriter.dmLevel=mspec2log\noperation = log\ncopyInputName = 0\nnameAppend=logMelFreqBand\n\n[res:cSpecResample]\nreader.dmLevel=fftc\nwriter.dmLevel=outpR\ntargetFs = 11000\n\n[lpc:cLpc]\n;reader.dmLevel=framespe\nreader.dmLevel=outpR\nwriter.dmLevel=lpc\np=8\nmethod = acf\nsaveLPCoeff = 1\nlpGain = 0\nsaveRefCoeff = 0\nresidual = 0\nforwardFilter = 0\nlpSpectrum = 0\n\n[lsp:cLsp]\nreader.dmLevel=lpc\nwriter.dmLevel=lsp\n\n[intens:cIntensity]\nreader.dmLevel=frames\nwriter.dmLevel=intens\nintensity=0\nloudness=1\n\n[mzcr:cMZcr]\nreader.dmLevel=frames\nwriter.dmLevel=mzcr\nzcr=1\namax=0\nmcr=0\nmaxmin=0\ndc=0\n\n[lld:cContourSmoother]\nreader.dmLevel=intens;mfcc;mspec2log;lsp;pitch\nwriter.dmLevel=lld\nbuffersize=1000\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nsmaWin = 3\n; this level must grow to hold ALL the LLD of the full input\n\n// ---- delta regression of LLD ----\n[delta1:cDeltaRegression]\nreader.dmLevel=lld\nwriter.dmLevel=lld_de\nbuffersize=1000\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\ndeltawin=2\nblocksize=1\n\n[lld2:cContourSmoother]\nreader.dmLevel=pitchF;jitter\nwriter.dmLevel=lld2\nbuffersize=1000\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n; this level must grow to hold ALL the LLD of the full input\n\n// ---- delta regression of LLD ----\n[delta2:cDeltaRegression]\nreader.dmLevel=lld2\nwriter.dmLevel=lld2_de\nbuffersize=1000\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\ndeltawin=2\nblocksize=1\n\n// statistical functionals\n[functL1:cFunctionals]\nreader.dmLevel=lld;lld_de\nwriter.dmLevel=func\n ; frameSize and frameStep = 0 => functionals over complete input\n ; (NOTE: buffersize of lld and lld_de levels must be large enough!!)\nframeMode = fixed\nframeSizeFrames = 500\n; was 25\nframeStepFrames = 200\n; was 10\nframeCenterSpecial = left\nfunctionalsEnabled=Extremes;Regression;Moments;Percentiles;Times\nExtremes.max = 0\nExtremes.min = 0\nExtremes.range = 0\nExtremes.maxpos = 1\nExtremes.minpos = 1\nExtremes.amean = 1\nExtremes.maxameandist=0\nExtremes.minameandist=0\nRegression.linregc1 = 1\nRegression.linregc2 = 1\nRegression.linregerrA = 1\nRegression.linregerrQ = 1\nRegression.qregc1 = 0\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 0\nRegression.qregerrQ = 0\nRegression.centroid = 0\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nPercentiles.quartiles = 1\nPercentiles.quartile1 = 0\nPercentiles.quartile2 = 0\nPercentiles.quartile3 = 0\nPercentiles.iqr = 1\nPercentiles.iqr12 = 0\nPercentiles.iqr23 = 0\nPercentiles.iqr13 = 0\nPercentiles.interp = 1\nPercentiles.percentile = 0.01;0.99\nPercentiles.pctlrange=0-1\nTimes.upleveltime25 = 0\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 0\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 1\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 0\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.norm = turn\n\n// statistical functionals\n[functL1nz:cFunctionals]\nreader.dmLevel=lld2;lld2_de\nwriter.dmLevel=funcNz\n ; frameSize and frameStep = 0 => functionals over complete input\n ; (NOTE: buffersize of lld and lld_de levels must be large enough!!)\nframeMode = fixed\nframeSizeFrames = 500\nframeStepFrames = 200\nframeCenterSpecial = left\nfunctionalsEnabled=Extremes;Regression;Moments;Percentiles;Times\nExtremes.max = 0\nExtremes.min = 0\nExtremes.range = 0\nExtremes.maxpos = 1\nExtremes.minpos = 1\nExtremes.amean = 1\nExtremes.maxameandist=0\nExtremes.minameandist=0\nExtremes.norm = frame\nRegression.linregc1 = 1\nRegression.linregc2 = 1\nRegression.linregerrA = 1\nRegression.linregerrQ = 1\nRegression.qregc1 = 0\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 0\nRegression.qregerrQ = 0\nRegression.centroid = 0\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nPercentiles.quartiles = 1\nPercentiles.quartile1 = 0\nPercentiles.quartile2 = 0\nPercentiles.quartile3 = 0\nPercentiles.iqr = 1\nPercentiles.iqr12 = 0\nPercentiles.iqr23 = 0\nPercentiles.iqr13 = 0\nPercentiles.interp = 1\nPercentiles.percentile = 0.99\n;Percentiles.pctlrange=0-1\nTimes.upleveltime25 = 0\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 0\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 1\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 0\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.norm = turn\nnonZeroFuncts=1\n\n[arffsink:cArffSink]\nreader.dmLevel=func;funcNz\n ; do not print \"frameNumber\" attribute to ARFF file\nframeIndex=1\nframeTime=0\n ; name of output file as commandline option\nfilename=\\cm[arffout(P){output.arff}:name of WEKA Arff output file]\n ; name of @relation in the ARFF file\nrelation=\\cm[corpus{Audio}:corpus name, arff relation]\n ; name of the current instance (usually file name of input wave file)\ninstanceName=\\cm[instname(N){noname}:name of arff instance]\n\\{arff_targets_age.conf}\n\n ; append to an existing file, so multiple calls of SMILExtract on different\n ; input files append to the same output ARFF file\nappend=1\n \n\n// ################### END OF openSMILE CONFIG FILE ######################\n\n"
  },
  {
    "path": "config/audiovisual/audiovideo.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// audio+video features for multi-modal speaker trait recog.  /////////////////\n/////////                                                            //////////////////\n///////// (c) audEERING UG (haftungsbeschränkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n ;===== component manager configuration (= list of enabled components!) =====\n\n[componentInstances:cComponentManager]\n // this line configures the default data memory:\ninstance[dataMemory].type = cDataMemory\n// VIDEO\ninstance[openCVSource].type = cOpenCVSource\ninstance[mean].type=cFunctionals\ninstance[arffOutput].type=cArffSink\n// AUDIO\ninstance[waveIn].type=cWaveSource\n ;;; 40 ms frames features:\ninstance[fr40].type=cFramer\ninstance[w40].type=cWindower\ninstance[fft40].type=cTransformFFT\ninstance[fftmagphase40].type=cFFTmagphase\n ; SHS Pitch:\ninstance[scale].type=cSpecScale\ninstance[pitchShs].type=cPitchShs\ninstance[pitchSmooth].type=cPitchSmoother\ninstance[pitchJitter].type=cPitchJitter\ninstance[pitchSmooth2].type=cPitchSmoother\ninstance[res].type=cSpecResample\n\n ;;; 25 ms frames features:\ninstance[fr25].type=cFramer\ninstance[pe].type=cVectorPreemphasis\ninstance[win].type=cWindower\ninstance[fft].type=cTransformFFT\ninstance[fftmagphase].type=cFFTmagphase\n ; mfcc\ninstance[mspec].type=cMelspec\ninstance[mfcc].type=cMfcc\n ; log mel frequency bands (mfb)\ninstance[mspec2].type=cMelspec\ninstance[vo].type=cVectorOperation\ninstance[lpc].type=cLpc\n ; Line Spectral Frequencies\ninstance[lsp].type=cLsp\n ; Loudness (narrow-band approximation)\ninstance[intens].type=cIntensity\n ;;; all LLD concattenated and smoothed using a moving average filter\ninstance[lld].type=cContourSmoother\ninstance[lld2].type=cContourSmoother\n ; delta coefficients of LLD\ninstance[delta1].type=cDeltaRegression\ninstance[delta2].type=cDeltaRegression\n ;;; functionals over FULL input (e.g. turns)\ninstance[functL1].type=cFunctionals\ninstance[functL1nz].type=cFunctionals\n\n ;;; write/append ONE instance to a Weka ARFF file\ninstance[arffsink].type=cArffSink\n\n // Here you can control the amount of detail displayed for the data memory\n // level configuration. 0 is no information at all, 5 is maximum detail.\nprintLevelStats = 6\n // You can set the number of parallel threads (experimental):\nnThreads = 1\n\n// ============= component configuration sections begin here ==============\n\n[openCVSource:cOpenCVSource]\nwriter.dmLevel = videofeatures\ndisplay = 1\nvideoSource = FILE\nfilename = \\cm[videofile(V){test.avi}:name of input file]\nface_cascade_path = /home/iaa2/workstud/grf/OpenCV/OpenCV-2.3.1/inst/share/OpenCV/lbpcascades/lbpcascade_frontalface.xml\neyes_cascade_path = /home/iaa2/workstud/grf/OpenCV/OpenCV-2.3.1/inst/share/OpenCV/haarcascades/haarcascade_eye_tree_eyeglasses.xml\nextract_face = 1\nextract_hsv_histogram = 0\nextract_hsv_histogram = 1\nextract_optical_flow = 0\ninclude_face_features = 0\nignore_invalid_frames = 1\nface_width = 60\nlbp_uniformpatterns = 0\nhsv_histogram_h_bins = 30\nhsv_histogram_s_bins = 30\nhsv_histogram_v_bins = 20\nnormalize_histograms = 1\nof_histogram_bins = 20\nof_histogram_max_flow = 0.2\nof_histogram_downsample = 0.3\n\n[mean:cFunctionals]\nreader.dmLevel = videofeatures\nwriter.dmLevel = videomean\ncopyInputName = 1\nframeMode = fixed\nframeSizeFrames = 150\nframeStepFrames = 60\nframeCenterSpecial = left\nfunctionalsEnabled = Means\nMeans.amean = 1\nMeans.posamean = 0\nMeans.absmean = 0\nMeans.rqmean = 0\nMeans.flatness = 0\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\nnonZeroFuncts = 1\n\n[arffOutput:cArffSink]\nreader.dmLevel= videomean\nnumber=0\ntimestamp=0\nfilename=\\cm[arffout(O){output_video.arff}:name of WEKA Arff output file]\nrelation=\\cm[corpus{Video}:corpus name, arff relation]\ninstanceName=\\cm[instname(N){lbp}:name of arff instance]\n;\\{arff_targets_age.conf}\n\nappend=1\n\n// AUDIO PART\n\n[waveIn:cWaveSource]\n ; this sets the level this component writes to\n ; the level will be created by this component\n ; no other components may write to a level having the same name\nwriter.dmLevel=wave\n ; this defines a new commandline option \"-I\" or \"-inputfile\", which can be used to specify \n ; the filename on the commandline instead of having it \"hard-coded\" in the config file\nfilename=\\cm[audiofile(A){test.wav}:name of input file]\n ; mix stereo files down to mono for analysis\nmonoMixdown=1\n\n[fr40:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames40\nframeSize = 0.060\nframeStep = 0.010\nframeCenterSpecial = left\n\n[w40:cWindower]\nreader.dmLevel=frames40\nwriter.dmLevel=win40frame\nwinFunc = gauss\nsigma=0.25\ngain = 1.0\n\n\n[fft40:cTransformFFT]\nreader.dmLevel=win40frame\nwriter.dmLevel=fftc40\n\n[fftmagphase40:cFFTmagphase]\nreader.dmLevel=fftc40\nwriter.dmLevel=fftmag40\n\n\n[scale:cSpecScale]\nreader.dmLevel=fftmag40\nwriter.dmLevel=hps\nscale=log\n ; octave scale\nlogScaleBase=2\n\n[pitchShs:cPitchShs]\nreader.dmLevel=hps\nwriter.dmLevel=pitchShs\nF0raw = 0\nvoicingClip = 0\nvoicingC1=0\nscores=1\nvoicing=1\nnCandidates=3\noctaveCorrection=0\n\n[pitchSmooth:cPitchSmoother]\nreader.dmLevel=pitchShs\nwriter.dmLevel=pitch\nF0raw = 0\nF0final = 0\nF0finalEnv = 1\nvoicingFinalUnclipped = 1\nmedianFilter0 = 0\npostSmoothingMethod = simple\n;simple\noctaveCorrection = 0\nwriter.levelconf.nT=10\n;writer.levelconf.noHang=2\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n[csvsink:cCsvSink]\nreader.dmLevel=pitch;pitchA\nfilename=pitchdbg.csv\n\n[pitchSmooth2:cPitchSmoother]\nreader.dmLevel=pitchShs\nwriter.dmLevel=pitchF\nF0raw = 0\nF0final = 1\nF0finalEnv = 0\nvoicingFinalUnclipped = 0\nmedianFilter0 = 0\npostSmoothingMethod = simple\noctaveCorrection = 0\nwriter.levelconf.nT=10\n;writer.levelconf.noHang=2\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n ;;;; default (template) configuration section for component 'cPitchJitter' ;;;;\n[pitchJitter:cPitchJitter]\nreader.dmLevel = wave\nwriter.dmLevel = jitter\n// nameAppend =\ncopyInputName = 1\nF0reader.dmLevel = pitchF\nF0field = F0final\nsearchRangeRel = 0.250000\njitterLocal = 1\njitterDDP = 1\njitterLocalEnv = 0\njitterDDPEnv = 0\nshimmerLocal = 1\nshimmerLocalEnv = 0\nonlyVoiced = 0\n;periodLengths = 0\n;periodStarts = 0\n\n\n[fr25:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames\nframeSize = 0.025\nframeStep = 0.010\nframeCenterSpecial = left\n\n[pe:cVectorPreemphasis]\nreader.dmLevel=frames\nwriter.dmLevel=framespe\nk=0.97\n\n[win:cWindower]\nreader.dmLevel=framespe\nwriter.dmLevel=winframe\nwinFunc = ham\ngain = 1.0\n\n[fft:cTransformFFT]\nreader.dmLevel=winframe\nwriter.dmLevel=fftc\n\n[fftmagphase:cFFTmagphase]\nreader.dmLevel=fftc\nwriter.dmLevel=fftmag\n\n[mspec:cMelspec]\nreader.dmLevel=fftmag\nwriter.dmLevel=mspec1\nhtkcompatible = 0\nusePower = 1\nlofreq = 20\nhifreq = 8000\nnBands=26\n\n[mfcc:cMfcc]\nreader.dmLevel = mspec1\nwriter.dmLevel = mfcc\nhtkcompatible = 0\nfirstMfcc=0\nlastMfcc=14\ncepLifter=22\n\n[mspec2:cMelspec]\nreader.dmLevel=fftmag\nwriter.dmLevel=mspec2\nhtkcompatible = 0\nusePower = 1\nlofreq = 20\nhifreq = 6500\nnBands=8\n\n[vo:cVectorOperation]\nreader.dmLevel=mspec2\nwriter.dmLevel=mspec2log\noperation = log\ncopyInputName = 0\nnameAppend=logMelFreqBand\n\n[res:cSpecResample]\nreader.dmLevel=fftc\nwriter.dmLevel=outpR\ntargetFs = 11000\n\n[lpc:cLpc]\n;reader.dmLevel=framespe\nreader.dmLevel=outpR\nwriter.dmLevel=lpc\np=8\nmethod = acf\nsaveLPCoeff = 1\nlpGain = 0\nsaveRefCoeff = 0\nresidual = 0\nforwardFilter = 0\nlpSpectrum = 0\n\n[lsp:cLsp]\nreader.dmLevel=lpc\nwriter.dmLevel=lsp\n\n[intens:cIntensity]\nreader.dmLevel=frames\nwriter.dmLevel=intens\nintensity=0\nloudness=1\n\n[mzcr:cMZcr]\nreader.dmLevel=frames\nwriter.dmLevel=mzcr\nzcr=1\namax=0\nmcr=0\nmaxmin=0\ndc=0\n\n[lld:cContourSmoother]\nreader.dmLevel=intens;mfcc;mspec2log;lsp;pitch\nwriter.dmLevel=lld\nbuffersize=1000\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nsmaWin = 3\n; this level must grow to hold ALL the LLD of the full input\n\n// ---- delta regression of LLD ----\n[delta1:cDeltaRegression]\nreader.dmLevel=lld\nwriter.dmLevel=lld_de\nbuffersize=1000\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\ndeltawin=2\nblocksize=1\n\n[lld2:cContourSmoother]\nreader.dmLevel=pitchF;jitter\nwriter.dmLevel=lld2\nbuffersize=1000\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n; this level must grow to hold ALL the LLD of the full input\n\n// ---- delta regression of LLD ----\n[delta2:cDeltaRegression]\nreader.dmLevel=lld2\nwriter.dmLevel=lld2_de\nbuffersize=1000\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\ndeltawin=2\nblocksize=1\n\n// statistical functionals\n[functL1:cFunctionals]\nreader.dmLevel=lld;lld_de\nwriter.dmLevel=func\n ; frameSize and frameStep = 0 => functionals over complete input\n ; (NOTE: buffersize of lld and lld_de levels must be large enough!!)\nframeMode = fixed\nframeSizeFrames = 500\nframeStepFrames = 200\nframeCenterSpecial = left\nfunctionalsEnabled=Extremes;Regression;Moments;Percentiles;Times\nExtremes.max = 0\nExtremes.min = 0\nExtremes.range = 0\nExtremes.maxpos = 1\nExtremes.minpos = 1\nExtremes.amean = 1\nExtremes.maxameandist=0\nExtremes.minameandist=0\nRegression.linregc1 = 1\nRegression.linregc2 = 1\nRegression.linregerrA = 1\nRegression.linregerrQ = 1\nRegression.qregc1 = 0\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 0\nRegression.qregerrQ = 0\nRegression.centroid = 0\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nPercentiles.quartiles = 1\nPercentiles.quartile1 = 0\nPercentiles.quartile2 = 0\nPercentiles.quartile3 = 0\nPercentiles.iqr = 1\nPercentiles.iqr12 = 0\nPercentiles.iqr23 = 0\nPercentiles.iqr13 = 0\nPercentiles.interp = 1\nPercentiles.percentile = 0.01;0.99\nPercentiles.pctlrange=0-1\nTimes.upleveltime25 = 0\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 0\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 1\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 0\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.norm = turn\n\n// statistical functionals\n[functL1nz:cFunctionals]\nreader.dmLevel=lld2;lld2_de\nwriter.dmLevel=funcNz\n ; frameSize and frameStep = 0 => functionals over complete input\n ; (NOTE: buffersize of lld and lld_de levels must be large enough!!)\nframeMode = fixed\nframeSizeFrames = 500\nframeStepFrames = 200\nframeCenterSpecial = left\nfunctionalsEnabled=Extremes;Regression;Moments;Percentiles;Times\nExtremes.max = 0\nExtremes.min = 0\nExtremes.range = 0\nExtremes.maxpos = 1\nExtremes.minpos = 1\nExtremes.amean = 1\nExtremes.maxameandist=0\nExtremes.minameandist=0\nExtremes.norm = frame\nRegression.linregc1 = 1\nRegression.linregc2 = 1\nRegression.linregerrA = 1\nRegression.linregerrQ = 1\nRegression.qregc1 = 0\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 0\nRegression.qregerrQ = 0\nRegression.centroid = 0\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nPercentiles.quartiles = 1\nPercentiles.quartile1 = 0\nPercentiles.quartile2 = 0\nPercentiles.quartile3 = 0\nPercentiles.iqr = 1\nPercentiles.iqr12 = 0\nPercentiles.iqr23 = 0\nPercentiles.iqr13 = 0\nPercentiles.interp = 1\nPercentiles.percentile = 0.99\n;Percentiles.pctlrange=0-1\nTimes.upleveltime25 = 0\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 0\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 1\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 0\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.norm = turn\nnonZeroFuncts=1\n\n[arffsink:cArffSink]\nreader.dmLevel=func;funcNz\n ; do not print \"frameNumber\" attribute to ARFF file\nframeIndex=0\nframeTime=0\n ; name of output file as commandline option\nfilename=\\cm[arffout(P){output.arff}:name of WEKA Arff output file]\n ; name of @relation in the ARFF file\nrelation=\\cm[corpus{Audio}:corpus name, arff relation]\n ; name of the current instance (usually file name of input wave file)\ninstanceName=\\cm[instname(N){noname}:name of arff instance]\n\\{arff_targets_age.conf}\n\n ; append to an existing file, so multiple calls of SMILExtract on different\n ; input files append to the same output ARFF file\nappend=1\n \n\n// ################### END OF openSMILE CONFIG FILE ######################\n\n"
  },
  {
    "path": "config/audiovisual/video.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openCV video features with openSMILE <                   //////////////////\n/////////                                                            //////////////////\n///////// (c) audEERING UG (haftungsbeschränkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n ;===== component manager configuration (= list of enabled components!) =====\n\n[componentInstances:cComponentManager]\ninstance[dataMemory].type = cDataMemory\n// VIDEO\ninstance[openCVSource].type = cOpenCVSource\ninstance[mean].type=cFunctionals\ninstance[arffOutput].type=cArffSink\n\n // Here you can control the amount of detail displayed for the data memory\n // level configuration. 0 is no information at all, 5 is maximum detail.\nprintLevelStats = 6\n // You can set the number of parallel threads (experimental):\nnThreads = 1\n\n// ============= component configuration sections begin here ==============\n\n[openCVSource:cOpenCVSource]\nwriter.dmLevel = videofeatures\ndisplay = 1\nvideoSource = FILE\nfilename = \\cm[videofile(V){test.avi}:name of input file]\nface_cascade_path = /home/iaa2/workstud/grf/OpenCV/OpenCV-2.3.1/inst/share/OpenCV/lbpcascades/lbpcascade_frontalface.xml\neyes_cascade_path = /home/iaa2/workstud/grf/OpenCV/OpenCV-2.3.1/inst/share/OpenCV/haarcascades/haarcascade_eye_tree_eyeglasses.xml\nextract_face = 1\nextract_hsv_histogram = 0\nextract_hsv_histogram = 1\nextract_optical_flow = 0\ninclude_face_features = 0\nignore_invalid_frames = 1\nface_width = 60\nlbp_uniformpatterns = 0\nhsv_histogram_h_bins = 30\nhsv_histogram_s_bins = 30\nhsv_histogram_v_bins = 20\nnormalize_histograms = 1\nof_histogram_bins = 20\nof_histogram_max_flow = 0.2\nof_histogram_downsample = 0.3\n\n[mean:cFunctionals]\nreader.dmLevel = videofeatures\nwriter.dmLevel = mean\ncopyInputName = 1\nframeMode = fixed\nframeSizeFrames = 150\nframeStepFrames = 60\nframeCenterSpecial = left\nfunctionalsEnabled = Means\nMeans.amean = 1\nMeans.posamean = 0\nMeans.absmean = 0\nMeans.rqmean = 0\nMeans.flatness = 0\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\nnonZeroFuncts = 1\n\n[arffOutput:cArffSink]\nreader.dmLevel= mean\nnumber=1\ntimestamp=0\nfilename=\\cm[arffout(O){output_video.arff}:name of WEKA Arff output file]\nrelation=\\cm[corpus{Video}:corpus name, arff relation]\ninstanceName=\\cm[instname(N){lbp}:name of arff instance]\n\\{arff_targets_age.conf}\nappend=1\n\n// ################### END OF openSMILE CONFIG FILE ######################\n\n"
  },
  {
    "path": "config/audspec.conf",
    "content": "\n///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file to extract a pseudo         //////////////////\n/////////   auditory spectrum: 26 mel-band spectrum with equal       //////////////////\n/////////   loudness weighting, delta and acceleration coefficients  //////////////////\n/////////                                                            //////////////////\n///////// (c) 2013-2016 audEERING.                                   //////////////////\n/////////     All rights reserverd. See file COPYING for details.    //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n///////////////////////////////////////////////////////////////////////////////////////\n;\n; This section is always required in openSMILE configuration files\n;   it configures the componentManager and gives a list of all components which are to be loaded\n; The order in which the components are listed should match \n;   the order of the data flow for most efficient processing\n;\n///////////////////////////////////////////////////////////////////////////////////////\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\n\n\\{shared/standard_wave_input.conf.inc}\n\n[componentInstances:cComponentManager]\n ; audio framer\ninstance[audspec_frame].type=cFramer\n ; speech pre-emphasis (on a per frame basis as HTK does it)\ninstance[audspec_pe].type=cVectorPreemphasis\n ; apply a window function to pre-emphasised frames\ninstance[audspec_win].type=cWindower\n ; transform to the frequency domain using FFT\ninstance[audspec_fft].type=cTransformFFT\n ; compute magnitude of the complex fft from the previous component\ninstance[audspec_fftmag].type=cFFTmagphase\n ; compute critical-bands from magnitude spectrum\ninstance[audspec_melspec].type=cMelspec\n ; compute PLP from critical-band spectrum\ninstance[audspec_plp].type=cPlp\n ; compute delta coefficients from mfcc and energy\ninstance[audspec_delta].type=cDeltaRegression\n ; compute acceleration coefficients from delta coefficients of mfcc and energy\ninstance[audspec_accel].type=cDeltaRegression\n\n\n; run single threaded (nThreads=1)\n; NOTE: a single thread is more efficient for processing small files, since multi-threaded processing involves more \n;       overhead during startup, which will make the system slower in the end\nnThreads=1\n; do not show any internal dataMemory level settings \n; (if you want to see them set the value to 1, 2, 3, or 4, depending on the amount of detail you wish)\nprintLevelStats=0\n\n\n/////////////////////////////////////////////////////////////////////////////////////////////\n/////////////////////////   component configuration  ////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////////////////////\n; the following sections configure the components listed above\n; a help on configuration parameters can be obtained with \n;  SMILExtract -H\n; or\n;  SMILExtract -H configTypeName (= componentTypeName)\n/////////////////////////////////////////////////////////////////////////////////////////////\n\n[audspec_frame:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames\nframeSize = 0.0250\nframeStep = 0.010\nframeMode = fixed\nframeCenterSpecial = left\n\n[audspec_pe:cVectorPreemphasis]\nreader.dmLevel=frames\nwriter.dmLevel=framespe\nk=0.97\nde=0\n\n[audspec_win:cWindower]\nreader.dmLevel=framespe\nwriter.dmLevel=winframes\n ; hamming window\nwinFunc = ham\n ; no gain\ngain = 1.0\noffset = 0\n\n[audspec_fft:cTransformFFT]\nreader.dmLevel=winframes\nwriter.dmLevel=fft\n\n[audspec_fftmag:cFFTmagphase]\nreader.dmLevel=fft\nwriter.dmLevel=fftmag\n\n[audspec_melspec:cMelspec]\nreader.dmLevel=fftmag\nwriter.dmLevel=melspec\n; htk compatible sample value scaling\nhtkcompatible = 1\nnBands = 26\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 0\nhifreq = 8000\nspecScale = mel\n\n[audspec_plp:cPlp]\nreader.dmLevel=melspec\nwriter.dmLevel=plp\nfirstCC = 0\nlpOrder = 5\ncepLifter = 22\ncompression = 0.33\nhtkcompatible = 1 \ndoIDFT = 0\ndoLpToCeps = 0\ndoLP = 0\ndoInvLog = 0\ndoAud = 1\ndoLog = 0\n\n[audspec_delta:cDeltaRegression]\nreader.dmLevel=plp\nwriter.dmLevel=plpde\ndeltawin=2\nblocksize=1\n\n[audspec_accel:cDeltaRegression]\nreader.dmLevel=plpde\nwriter.dmLevel=plpdede\ndeltawin=2\nblocksize=1\n\n[componentInstances:cComponentManager]\ninstance[audspec_lldconcat].type=cVectorConcat\n\n[audspec_lldconcat:cVectorConcat]\nreader.dmLevel = plp;plpde;plpdede\nwriter.dmLevel = lld\nincludeSingleElementFields = 1\n\n  //////////////////////////////////////////////////////////////////////\n ///////////////////  data output configuration  //////////////////////\n//////////////////////////////////////////////////////////////////////\n\n\\{shared/standard_data_output_lldonly.conf.inc}\n\n//////---------------------- END -------------------------///////\n\n"
  },
  {
    "path": "config/audspec_compat.conf",
    "content": "\n///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file to extract a pseudo         //////////////////\n/////////   auditory spectrum: 26 mel-band spectrum with equal       //////////////////\n/////////   loudness weighting, delta and acceleration coefficients  //////////////////\n////////    This file produces compatible results with 2.1 and 2.2.  //////////////////\n/////////                                                            //////////////////\n///////// (c) 2013-2016 audEERING.                                   //////////////////\n/////////     All rights reserverd. See file COPYING for details.    //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n// Default output (-O) is to HTK format\n// Optional output (if -outputcsv set on commandline) is CSV output (including header line)\n\n///////////////////////////////////////////////////////////////////////////////////////\n;\n; This section is always required in openSMILE configuration files\n;   it configures the componentManager and gives a list of all components which are to be loaded\n; The order in which the components are listed should match \n;   the order of the data flow for most efficient processing\n;\n///////////////////////////////////////////////////////////////////////////////////////\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\n ; wave file input\ninstance[waveIn].type=cWaveSource\n ; audio framer\ninstance[frame].type=cFramer\n ; speech pre-emphasis (on a per frame basis as HTK does it)\ninstance[pe].type=cVectorPreemphasis\n ; apply a window function to pre-emphasised frames\ninstance[win].type=cWindower\n ; transform to the frequency domain using FFT\ninstance[fft].type=cTransformFFT\n ; compute magnitude of the complex fft from the previous component\ninstance[fftmag].type=cFFTmagphase\n ; compute critical-bands from magnitude spectrum\ninstance[melspec].type=cMelspec\n ; compute PLP from critical-band spectrum\ninstance[plp].type=cPlp\n ; compute delta coefficients from mfcc and energy\ninstance[delta].type=cDeltaRegression\n ; compute acceleration coefficients from delta coefficients of mfcc and energy\ninstance[accel].type=cDeltaRegression\n\n\n; run single threaded (nThreads=1)\n; NOTE: a single thread is more efficient for processing small files, since multi-threaded processing involves more \n;       overhead during startup, which will make the system slower in the end\nnThreads=1\n; do not show any internal dataMemory level settings \n; (if you want to see them set the value to 1, 2, 3, or 4, depending on the amount of detail you wish)\nprintLevelStats=0\n\n\n/////////////////////////////////////////////////////////////////////////////////////////////\n/////////////////////////   component configuration  ////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////////////////////\n; the following sections configure the components listed above\n; a help on configuration parameters can be obtained with \n;  SMILExtract -H\n; or\n;  SMILExtract -H configTypeName (= componentTypeName)\n/////////////////////////////////////////////////////////////////////////////////////////////\n\n[waveIn:cWaveSource]\n ; this sets the level this component writes to\n ; the level will be created by this component\n ; no other components may write to a level having the same name\nwriter.dmLevel=wave\n ; this defines a new commandline option \"-I\" or \"-inputfile\", which can be used to specify \n ; the filename on the commandline instead of having it \"hard-coded\" in the config file\nfilename=\\cm[inputfile(I){test.wav}:name of input file]\n ; mix stereo files down to mono for analysis\nmonoMixdown=1\n\n[frame:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames\nframeSize = 0.0250\nframeStep = 0.010\nframeMode = fixed\nframeCenterSpecial = left\n\n[pe:cVectorPreemphasis]\nreader.dmLevel=frames\nwriter.dmLevel=framespe\nk=0.97\nde=0\n\n[win:cWindower]\nreader.dmLevel=framespe\nwriter.dmLevel=winframes\n ; hamming window\nwinFunc = ham\n ; no gain\ngain = 1.0\noffset = 0\n\n[fft:cTransformFFT]\nreader.dmLevel=winframes\nwriter.dmLevel=fft\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmag:cFFTmagphase]\nreader.dmLevel=fft\nwriter.dmLevel=fftmag\n\n[melspec:cMelspec]\nreader.dmLevel=fftmag\nwriter.dmLevel=melspec\n; htk compatible sample value scaling\nhtkcompatible = 1\nnBands = 26\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 0\nhifreq = 8000\nspecScale = mel\n\n[plp:cPlp]\nreader.dmLevel=melspec\nwriter.dmLevel=plp\nfirstCC = 0\nlpOrder = 5\ncepLifter = 22\ncompression = 0.33\nhtkcompatible = 1 \ndoIDFT = 0\ndoLpToCeps = 0\ndoLP = 0\ndoInvLog = 0\ndoAud = 1\ndoLog = 0\n\n[delta:cDeltaRegression]\nreader.dmLevel=plp\nwriter.dmLevel=plpde\ndeltawin=2\nblocksize=1\n\n[accel:cDeltaRegression]\nreader.dmLevel=plpde\nwriter.dmLevel=plpdede\ndeltawin=2\nblocksize=1\n\n[componentInstances:cComponentManager]\ninstance[audspec_lldconcat].type=cVectorConcat\n\n[audspec_lldconcat:cVectorConcat]\nreader.dmLevel = plp;plpde;plpdede\nwriter.dmLevel = lld\nincludeSingleElementFields = 1\n\n  //////////////////////////////////////////////////////////////////////\n ///////////////////  data output configuration  //////////////////////\n//////////////////////////////////////////////////////////////////////\n\n\\{shared/standard_data_output_lldonly.conf.inc}\n\n//////---------------------- END -------------------------///////\n\n\n"
  },
  {
    "path": "config/avec2011.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file                             //////////////////\n/////////   for AVEC 2011 challenge <                                //////////////////\n/////////                                                            //////////////////\n///////// (c) 2013-2016 audEERING.                                   //////////////////\n/////////     All rights reserverd. See file COPYING for details.    //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\n;;;;;;; component list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\nprintLevelStats=0\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;; main section ;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n\\{shared/standard_wave_input.conf.inc}\n\n;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[frame60].type=cFramer\ninstance[win60].type=cWindower\ninstance[fft60].type=cTransformFFT\ninstance[fftmp60].type=cFFTmagphase\n\n[frame60:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frame60\nframeSize = 0.060\nframeStep = 0.010\nframeCenterSpecial = left\n\n\n[win60:cWindower]\nreader.dmLevel=frame60\nwriter.dmLevel=winG60\nwinFunc=gauss\ngain=1.0\nsigma=0.4\n\n[fft60:cTransformFFT]\nreader.dmLevel=winG60\nwriter.dmLevel=fftcG60\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmp60:cFFTmagphase]\nreader.dmLevel=fftcG60\nwriter.dmLevel=fftmagG60\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[frame25].type=cFramer\ninstance[pe25].type=cVectorPreemphasis\ninstance[win25].type=cWindower\ninstance[fft25].type=cTransformFFT\ninstance[fftmp25].type=cFFTmagphase\n\n[frame25:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frame25\nframeSize = 0.025\nframeStep = 0.010\nframeCenterSpecial = left\n\n[pe25:cVectorPreemphasis]\nreader.dmLevel=frame25\nwriter.dmLevel=frame25pe\nk=0.97\nde=0\n\n[win25:cWindower]\nreader.dmLevel=frame25\nwriter.dmLevel=winH25\nwinFunc=hamming\n\n[fft25:cTransformFFT]\nreader.dmLevel=winH25\nwriter.dmLevel=fftcH25\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmp25:cFFTmagphase]\nreader.dmLevel=fftcH25\nwriter.dmLevel=fftmagH25\n\n\n\n;;;;;;;;;;;;;;;;;;;; HPS pitch\n\n[componentInstances:cComponentManager]\ninstance[scale].type=cSpecScale\ninstance[shs].type=cPitchShs\ninstance[pitchSmooth].type=cPitchSmootherViterbi\ninstance[energy60].type=cEnergy\ninstance[volmerge].type=cValbasedSelector\n\n[energy60:cEnergy]\nreader.dmLevel=winG60\nwriter.dmLevel=e60\nrms=1\nlog=0\nwriter.levelconf.nT=200\n\n\n[scale:cSpecScale]\nreader.dmLevel=fftmagG60\nwriter.dmLevel=hpsG60\ncopyInputName = 1\nprocessArrayFields = 0\nscale=octave\nsourceScale = lin\n// logScaleBase = 2\n// logSourceScaleBase = 2\n// firstNote = 55\ninterpMethod = spline\nminF = 20\nmaxF = -1\nnPointsTarget = 0\nspecSmooth = 1\nspecEnhance = 1\nauditoryWeighting = 1 \n\n[shs:cPitchShs]\nreader.dmLevel=hpsG60\nwriter.dmLevel=pitchShsG60\ncopyInputName = 1\nprocessArrayFields = 0\nmaxPitch = 620\nminPitch = 42\nnCandidates = 6\nscores = 1\nvoicing = 1\nF0C1 = 0\nvoicingC1 = 0\nF0raw = 1\nvoicingClip = 1\nvoicingCutoff = 0.700000\ninputFieldSearch = Mag_octScale\noctaveCorrection = 0\nnHarmonics = 15\ncompressionFactor = 0.850000\ngreedyPeakAlgo = 1\n\n[pitchSmooth:cPitchSmootherViterbi]\nreader.dmLevel=pitchShsG60\nreader2.dmLevel=pitchShsG60\nwriter.dmLevel=pitchG60a\ncopyInputName = 1\nbufferLength=90\nF0final = 1\nF0finalEnv = 0\nvoicingFinalClipped = 0\nvoicingFinalUnclipped = 1\nF0raw = 0\nvoicingC1 = 0\nvoicingClip = 0\nwTvv =10.0\nwTvvd= 5.0\nwTvuv=10.0\nwThr = 4.0\nwTuu = 0.0\nwLocal=2.0\nwRange=1.0\n\n// SHS/Viterbi pitch algo does strange things at very low amplitudes, so we filter these out \n[volmerge:cValbasedSelector]\nreader.dmLevel = e60;pitchG60a\nwriter.dmLevel = pitchG60\nidx=0\nthreshold=0.0008\nremoveIdx=1\nzeroVec=1\noutputVal=0.0\n\n\n;;;;;;;;;;;;;;;;;;; VQ\n\n[componentInstances:cComponentManager]\ninstance[pitchJitter].type=cPitchJitter\n\n\n[pitchJitter:cPitchJitter]\nreader.dmLevel = wave\nwriter.dmLevel = jitterShimmer\n// nameAppend =\ncopyInputName = 1\n; is pitchF really necessary, or can we use pitchG60 ?\nF0reader.dmLevel = pitchG60\nF0field = F0final\nsearchRangeRel = 0.250000\njitterLocal = 1\njitterDDP = 1\njitterLocalEnv = 0\njitterDDPEnv = 0\nshimmerLocal = 1\nshimmerLocalEnv = 0\nonlyVoiced = 0\nlogHNR = 1\n;periodLengths = 0\n;periodStarts = 0\nuseBrokenJitterThresh = 1\n\n;;;;;;;;;;;;;;;;;;;;; Energy / loudness\n\n\n[componentInstances:cComponentManager]\ninstance[melspec1].type=cMelspec\ninstance[audspec].type=cPlp\ninstance[audspecSum].type=cVectorOperation\n\n\n[melspec1:cMelspec]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=melspec1\n; htk compatible sample value scaling\nhtkcompatible = 0\nnBands = 26\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 20\nhifreq = 8000\nspecScale = bark\n\n; perform auditory weighting of spectrum\n[audspec:cPlp]\nreader.dmLevel=melspec1\nwriter.dmLevel=audspec\nfirstCC = 0\nlpOrder = 5\ncepLifter = 22\ncompression = 0.33\nhtkcompatible = 0 \ndoIDFT = 0\ndoLpToCeps = 0\ndoLP = 0\ndoInvLog = 0\ndoAud = 1\ndoLog = 0\nnewRASTA=0\nRASTA=0\n\n[audspecSum:cVectorOperation]\nreader.dmLevel = audspec\nwriter.dmLevel = audspecSum\n// nameAppend = \ncopyInputName = 1\nprocessArrayFields = 0\noperation = ll1\nnameBase = audspec\n\n;;;;;;;;;;;;;;; spectral\n\n[componentInstances:cComponentManager]\ninstance[spectral].type=cSpectral\n\n\n[spectral:cSpectral]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=spectral\nbands[0]=250-650\nbands[1]=1000-4000\nrollOff[0] = 0.25\nrollOff[1] = 0.50\nrollOff[2] = 0.75\nrollOff[3] = 0.90\nflux=1\ncentroid=0\nmaxPos=0\nminPos=0\nentropy=1\nvariance=1\nskewness=1\nkurtosis=1\nslope=0\nsharpness = 1\ntonality = 0\nharmonicity = 1\nflatness = 0\n\n\n;;;;;;;;;;;;;;; mfcc\n\n[componentInstances:cComponentManager]\ninstance[melspecMfcc].type=cMelspec\ninstance[mfcc].type=cMfcc\n\n[melspecMfcc:cMelspec]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=melspecMfcc\ncopyInputName = 1\nprocessArrayFields = 1\n; htk compatible sample value scaling\nhtkcompatible = 1\nnBands = 26\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 20\nhifreq = 8000\nspecScale = mel\ninverse = 0\n\n[mfcc:cMfcc]\nreader.dmLevel=melspecMfcc\nwriter.dmLevel=mfcc1_12\ncopyInputName = 1\nprocessArrayFields = 1\nfirstMfcc = 1\nlastMfcc  = 10\ncepLifter = 22.0\nhtkcompatible = 1\n\n\n;;;;;;;;;;;;;;;;  zcr\n\n[componentInstances:cComponentManager]\ninstance[mzcr].type=cMZcr\n\n[mzcr:cMZcr]\nreader.dmLevel = frame25\nwriter.dmLevel = zcr\ncopyInputName = 1\nprocessArrayFields = 1\nzcr = 1\nmcr = 0\namax = 0\nmaxmin = 0\ndc = 0\n\n\n;;;;;;;;;;;;;;;;;;;; smoothing and selection\n\n[componentInstances:cComponentManager]\ninstance[smoNz].type=cContourSmoother\ninstance[smoA].type=cContourSmoother\ninstance[smoB].type=cContourSmoother\ninstance[f0sel].type=cDataSelector\ninstance[f0psel].type=cDataSelector\n\n[smoNz:cContourSmoother]\nreader.dmLevel = pitchG60;jitterShimmer\nwriter.dmLevel = lld_nzsmo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\nnoZeroSma = 1\n\n[f0sel:cDataSelector]\nreader.dmLevel = lld_nzsmo\nwriter.dmLevel = lld_f0v_nzsmo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = f0v\nselected = F0final_sma\n\n[f0psel:cDataSelector]\nreader.dmLevel = lld_nzsmo\nwriter.dmLevel = lld_f0p_nzsmo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = f0p\nselected = F0final_sma\n\n\n[smoA:cContourSmoother]\nreader.dmLevel = audspecSum;zcr\nwriter.dmLevel = lldA_smo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n[smoB:cContourSmoother]\nreader.dmLevel = spectral;mfcc1_12\nwriter.dmLevel = lldB_smo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n;;;;;;;;; deltas\n[componentInstances:cComponentManager]\ninstance[deNz].type=cDeltaRegression\ninstance[deA].type=cDeltaRegression\ninstance[deB].type=cDeltaRegression\n\n[deNz:cDeltaRegression]\nreader.dmLevel = lld_nzsmo\nwriter.dmLevel = lld_nzsmo_de\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n; TODO?  delta with zero segments removed...\n\n[deA:cDeltaRegression]\nreader.dmLevel = lldA_smo\nwriter.dmLevel = lldA_smo_de\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n[deB:cDeltaRegression]\nreader.dmLevel = lldB_smo\nwriter.dmLevel = lldB_smo_de\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n;;;;;;;;; functionals / statistics\n\n\n[componentInstances:cComponentManager]\ninstance[functionalsA].type=cFunctionals\ninstance[functionalsAde].type=cFunctionals\ninstance[functionalsF0v].type=cFunctionals\ninstance[functionalsF0p].type=cFunctionals\ninstance[functionalsNz].type=cFunctionals\ninstance[functionalsNzDe].type=cFunctionals\n\n; functionals for energy and spectral related lld\n[functionalsA:cFunctionals]\nreader.dmLevel = lldA_smo;lldB_smo\nwriter.dmLevel = functionalsA\n// nameAppend = \ncopyInputName = 1\nframeMode = full\nframeSize = 0\nframeStep = 0\nframeCenterSpecial = left\n\nfunctionalsEnabled = Percentiles ; Means ; Moments ; Peaks2 ; Segments ; Regression ; Times ; Lpc\n\nMeans.amean = 1\nMeans.absmean = 0\nMeans.rqmean = 1\nMeans.flatness = 1\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\n\nPeaks2.doRatioLimit = 0\nPeaks2.numPeaks = 0\nPeaks2.meanPeakDist = 1\nPeaks2.meanPeakDistDelta = 0\nPeaks2.peakDistStddev = 1\nPeaks2.peakRangeAbs = 0\nPeaks2.peakRangeRel = 1\nPeaks2.peakMeanAbs = 0\nPeaks2.peakMeanMeanDist = 0\nPeaks2.peakMeanRel = 1\nPeaks2.ptpAmpMeanAbs = 0\nPeaks2.ptpAmpMeanRel = 0\nPeaks2.ptpAmpStddevAbs = 0\nPeaks2.ptpAmpStddevRel = 0\nPeaks2.minRangeAbs = 0\nPeaks2.minRangeRel = 1\nPeaks2.minMeanAbs = 0\nPeaks2.minMeanMeanDist = 0\nPeaks2.minMeanRel = 0\nPeaks2.mtmAmpMeanAbs = 0\nPeaks2.mtmAmpMeanRel = 0\nPeaks2.mtmAmpStddevAbs = 0\nPeaks2.mtmAmpStddevRel = 0\nPeaks2.meanRisingSlope = 1\nPeaks2.maxRisingSlope = 0\nPeaks2.minRisingSlope = 0\nPeaks2.stddevRisingSlope = 1\nPeaks2.meanFallingSlope = 1\nPeaks2.maxFallingSlope = 0\nPeaks2.minFallingSlope = 0\nPeaks2.stddevFallingSlope = 1\nPeaks2.norm = seconds\nPeaks2.relThresh = 0.100000\nPeaks2.dynRelThresh = 0\n;Peaks2.posDbgOutp = minmax.txt\nPeaks2.posDbgAppend = 0\nPeaks2.consoleDbg = 0\n\nSegments.maxNumSeg = 100\nSegments.segmentationAlgorithm = NArelTh\nSegments.thresholds = 0.25\nSegments.rangeRelThreshold = 0.200000\nSegments.numSegments = 0\nSegments.meanSegLen = 1\nSegments.maxSegLen = 1\nSegments.minSegLen = 1\nSegments.segLenStddev = 1\nSegments.norm = second\n\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nMoments.doRatioLimit = 0\n\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\n\nRegression.linregc1 = 1\nRegression.linregc2 = 0\nRegression.linregerrA = 1\nRegression.linregerrQ = 0\nRegression.qregc1 = 1\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 1\nRegression.qregerrQ = 0\nRegression.oldBuggyQerr = 0\nRegression.centroid = 0\nRegression.normRegCoeff = 1\nRegression.normInputs = 1\nRegression.doRatioLimit = 0\nRegression.centroidRatioLimit = 0\nRegression.centroidUseAbsValues = 0\n\nTimes.upleveltime25 = 1\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 1\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.buggySecNorm = 0\nTimes.norm = segment\n\nLpc.lpGain = 1\nLpc.lpc = 1\nLpc.firstCoeff = 0\nLpc.order = 5\n\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n; functionals for energy and spectral related lld\n[functionalsAde:cFunctionals]\nreader.dmLevel = lldA_smo_de;lldB_smo_de\nwriter.dmLevel = functionalsAde\n// nameAppend = \ncopyInputName = 1\nframeMode = full\nframeSize = 0\nframeStep = 0\nframeCenterSpecial = left\n\nfunctionalsEnabled = Percentiles ; Means ; Moments ; Segments ; Times \nMeans.amean = 0\nMeans.posamean = 1\nMeans.absmean = 0\nMeans.rqmean = 1\nMeans.flatness = 1\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\n\nSegments.maxNumSeg = 100\nSegments.segmentationAlgorithm = chX\nSegments.X = 0.0\nSegments.numSegments = 0\nSegments.meanSegLen = 1\nSegments.maxSegLen = 1\nSegments.minSegLen = 1\nSegments.segLenStddev = 1\nSegments.norm = second\n\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nMoments.doRatioLimit = 0\n\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\n\nTimes.upleveltime25 = 1\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 1\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.buggySecNorm = 0\nTimes.norm = segment\n\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n\n\n; functionals for pitch onsets/offsets (voiced)\n[functionalsF0v:cFunctionals]\nreader.dmLevel = lld_f0v_nzsmo\n  ;lld_f0_nzsmo_de\nwriter.dmLevel = functionalsF0v\n//nameAppend = ff0\ncopyInputName = 1\nframeMode = full\nframeSize = 0\nframeStep = 0\nframeCenterSpecial = left\n\nfunctionalsEnabled = Means ; Segments\n\nMeans.amean = 0\nMeans.absmean = 0\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 1\nMeans.norm = segment\n\nSegments.maxNumSeg = 100\nSegments.segmentationAlgorithm = nonX\nSegments.X = 0.0\nSegments.numSegments = 0\nSegments.meanSegLen = 1\nSegments.maxSegLen = 1\nSegments.minSegLen = 1\nSegments.segLenStddev = 1\nSegments.norm = second\n\n\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n; functionals for pitch onsets (pauses)\n[functionalsF0p:cFunctionals]\nreader.dmLevel = lld_f0p_nzsmo\nwriter.dmLevel = functionalsF0p\n//nameAppend = pauses\ncopyInputName = 0\nframeMode = full\n\nframeCenterSpecial = left\nfunctionalsEnabled = Means ; Segments\nMeans.amean = 0\nMeans.posamean = 0\nMeans.absmean = 0\nMeans.qmean = 0\nMeans.rqmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 1\nMeans.flatness = 0\nMeans.norm = segment\n\nSegments.maxNumSeg = 100\nSegments.segmentationAlgorithm = eqX\nSegments.X = 0.0\nSegments.numSegments = 0\nSegments.meanSegLen = 1\nSegments.maxSegLen = 1\nSegments.minSegLen = 1\nSegments.segLenStddev = 1\nSegments.norm = second\n\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n\n; functionals for pitch and vq related lld in voiced regions\n[functionalsNz:cFunctionals]\nreader.dmLevel = lld_nzsmo\nwriter.dmLevel = functionalsNz\n// nameAppend = \ncopyInputName = 1\nframeMode = full\nframeSize = 0\nframeStep = 0\nframeCenterSpecial = left\n\nfunctionalsEnabled = Percentiles ; Means ; Moments ; Peaks2 ; Regression ; Times \n\nMeans.amean = 1\nMeans.absmean = 0\nMeans.rqmean = 1\nMeans.qmean = 0\nMeans.flatness = 1\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\n\nPeaks2.doRatioLimit = 0\nPeaks2.numPeaks = 0\nPeaks2.meanPeakDist = 1\nPeaks2.meanPeakDistDelta = 0\nPeaks2.peakDistStddev = 1\nPeaks2.peakRangeAbs = 0\nPeaks2.peakRangeRel = 1\nPeaks2.peakMeanAbs = 0\nPeaks2.peakMeanMeanDist = 0\nPeaks2.peakMeanRel = 1\nPeaks2.ptpAmpMeanAbs = 0\nPeaks2.ptpAmpMeanRel = 0\nPeaks2.ptpAmpStddevAbs = 0\nPeaks2.ptpAmpStddevRel = 0\nPeaks2.minRangeAbs = 0\nPeaks2.minRangeRel = 1\nPeaks2.minMeanAbs = 0\nPeaks2.minMeanMeanDist = 0\nPeaks2.minMeanRel = 0\nPeaks2.mtmAmpMeanAbs = 0\nPeaks2.mtmAmpMeanRel = 0\nPeaks2.mtmAmpStddevAbs = 0\nPeaks2.mtmAmpStddevRel = 0\nPeaks2.meanRisingSlope = 1\nPeaks2.maxRisingSlope = 0\nPeaks2.minRisingSlope = 0\nPeaks2.stddevRisingSlope = 1\nPeaks2.meanFallingSlope = 1\nPeaks2.maxFallingSlope = 0\nPeaks2.minFallingSlope = 0\nPeaks2.stddevFallingSlope = 1\nPeaks2.norm = seconds\nPeaks2.relThresh = 0.100000\nPeaks2.dynRelThresh = 0\n;Peaks2.posDbgOutp = minmax.txt\nPeaks2.posDbgAppend = 0\nPeaks2.consoleDbg = 0\n\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nMoments.doRatioLimit = 0\n\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\n\nRegression.linregc1 = 1\nRegression.linregc2 = 0\nRegression.linregerrA = 1\nRegression.linregerrQ = 0\nRegression.qregc1 = 1\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 1\nRegression.qregerrQ = 0\nRegression.oldBuggyQerr = 0\nRegression.centroid = 0\nRegression.normRegCoeff = 1\nRegression.normInputs = 1\nRegression.doRatioLimit = 0\nRegression.centroidRatioLimit = 0\nRegression.centroidUseAbsValues = 0\n\nTimes.upleveltime25 = 1\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 1\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.buggySecNorm = 0\nTimes.norm = segment\n\nLpc.lpGain = 1\nLpc.lpc = 1\nLpc.firstCoeff = 0\nLpc.order = 5\n\nnonZeroFuncts = 1\nmasterTimeNorm = segment\n\n\n; functionals for pitch and vq related lld in voiced regions\n[functionalsNzDe:cFunctionals]\nreader.dmLevel = lld_nzsmo_de\nwriter.dmLevel = functionalsNzDe\n// nameAppend = \ncopyInputName = 1\nframeMode = full\nframeSize = 0\nframeStep = 0\nframeCenterSpecial = left\n\nfunctionalsEnabled = Percentiles ; Means ; Moments ; Times \n\nMeans.amean = 0\nMeans.posamean = 1\nMeans.absmean = 0\nMeans.rqmean = 1\nMeans.qmean = 0\nMeans.flatness = 1\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\n\n\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nMoments.doRatioLimit = 0\n\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\n\nTimes.upleveltime25 = 1\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 1\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.buggySecNorm = 0\nTimes.norm = segment\n\nLpc.lpGain = 1\nLpc.lpc = 1\nLpc.firstCoeff = 0\nLpc.order = 5\n\nnonZeroFuncts = 1\nmasterTimeNorm = segment\n\n\n;;;;;;;;; output all features....\n\n[componentInstances:cComponentManager]\ninstance[arffsink].type=cArffSink\n\n[arffsink:cArffSink]\nreader.dmLevel=functionalsA;functionalsNz;functionalsAde;functionalsNzDe;functionalsF0v;functionalsF0p\nfilename=\\cm[output(O){default.arff}:output arff file for feature data]\nappend=1\nframeIndex=0\nframeTime=0\nrelation=avec2011\ninstanceName=\\cm[instname{unlabelled}:name of file which will be saved in arff file]\n ; name of class label\nclass[0].name = emotion\n ; list of nominal classes OR \"numeric\"\nclass[0].type = \\cm[classes{0,1,2,3}:all classes for arff file attribute]\n ; the class label or value for the current instance\ntarget[0].all = \\cm[classlabel(a){0}:instance class label]\n ; append to an existing file, so multiple calls of SMILExtract on different\n ; input files append to the same output ARFF file\n\n\n"
  },
  {
    "path": "config/avec2012.readme",
    "content": "\nNOTE:\n\nAll AVEC 2012 config files and extractor scripts are in ../scripts/avec2012/avec2012_*.conf\n(or old name, avec2011_*.conf in older versions)\n\nFor standard full segment features (as the other challenges), use avec2011_full.conf\nNOTE: it requires ../scripts/avec2012/labels.inc for the 4 dimensional avec label options\n\n"
  },
  {
    "path": "config/avec2013.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file                             //////////////////\n/////////   for AVEC 2013                                            //////////////////\n/////////   based on avec2011.conf                                   //////////////////\n/////////  * written 2013 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) 2013-2016 by audEERING.                                //////////////////\n/////////     All rights reserved. See file COPYING for details.     //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\\{avec2013_lld_core.conf.inc}\n\\{avec2013_functionals_core.conf.inc}\n\n;;;;;;;;; output all features....\n\n[componentInstances:cComponentManager]\ninstance[avec2013_lldconcat].type=cVectorConcat\ninstance[avec2013_llddeconcat].type=cVectorConcat\ninstance[avec2013_funcconcat].type=cVectorConcat\n\n[avec2013_lldconcat:cVectorConcat]\nreader.dmLevel = lldA_smo;lldB_smo;lld_nzsmo\nwriter.dmLevel = lld\nincludeSingleElementFields = 1\n\n[avec2013_llddeconcat:cVectorConcat]\nreader.dmLevel = lldA_smo_de;lldB_smo_de;lld_nzsmo_de\nwriter.dmLevel = lld_de\nincludeSingleElementFields = 1\n\n[avec2013_funcconcat:cVectorConcat]\nreader.dmLevel = functionalsDur;functionalsA;functionalsNz;functionalsAde;functionalsNzDe;functionalsF0v;functionalsF0p\nwriter.dmLevel = func\nincludeSingleElementFields = 1\n\n\\{shared/standard_data_output.conf.inc}\n\n \n\n\n"
  },
  {
    "path": "config/avec2013_functionals_core.conf.inc",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file                             //////////////////\n/////////   for AVEC 2013                                            //////////////////\n/////////   based on avec2011.conf                                   //////////////////\n/////////  * written 2013 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) 2013-2016 by audEERING.                                //////////////////\n/////////     All rights reserved. See file COPYING for details.     //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\n;;;;;;;;; functionals / statistics\n\n\n[componentInstances:cComponentManager]\ninstance[functionalsA].type=cFunctionals\ninstance[functionalsAde].type=cFunctionals\ninstance[functionalsF0v].type=cFunctionals\ninstance[functionalsF0p].type=cFunctionals\ninstance[functionalsNz].type=cFunctionals\ninstance[functionalsNzDe].type=cFunctionals\ninstance[functionalsDur].type=cFunctionals\n\n; functionals for energy and spectral related lld\n[functionalsA:cFunctionals]\nreader.dmLevel = lldA_smo;lldB_smo\nwriter.dmLevel = functionalsA\n// nameAppend = \ncopyInputName = 1\n\\{\\cm[frameModeConf{avec2013_functionals_frame_mode.conf.inc}:functionals frame mode config]}\n\nfunctionalsEnabled = Percentiles ; Means ; Moments ; Peaks2 ; Segments ; Regression ; Times ; Lpc\n\nMeans.amean = 1\nMeans.absmean = 0\nMeans.rqmean = 1\nMeans.flatness = 1\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\n\nPeaks2.doRatioLimit = 0\nPeaks2.numPeaks = 0\nPeaks2.meanPeakDist = 1\nPeaks2.meanPeakDistDelta = 0\nPeaks2.peakDistStddev = 1\nPeaks2.peakRangeAbs = 0\nPeaks2.peakRangeRel = 1\nPeaks2.peakMeanAbs = 0\nPeaks2.peakMeanMeanDist = 0\nPeaks2.peakMeanRel = 1\nPeaks2.ptpAmpMeanAbs = 0\nPeaks2.ptpAmpMeanRel = 0\nPeaks2.ptpAmpStddevAbs = 0\nPeaks2.ptpAmpStddevRel = 0\nPeaks2.minRangeAbs = 0\nPeaks2.minRangeRel = 1\nPeaks2.minMeanAbs = 0\nPeaks2.minMeanMeanDist = 0\nPeaks2.minMeanRel = 0\nPeaks2.mtmAmpMeanAbs = 0\nPeaks2.mtmAmpMeanRel = 0\nPeaks2.mtmAmpStddevAbs = 0\nPeaks2.mtmAmpStddevRel = 0\nPeaks2.meanRisingSlope = 1\nPeaks2.maxRisingSlope = 0\nPeaks2.minRisingSlope = 0\nPeaks2.stddevRisingSlope = 1\nPeaks2.meanFallingSlope = 1\nPeaks2.maxFallingSlope = 0\nPeaks2.minFallingSlope = 0\nPeaks2.stddevFallingSlope = 1\nPeaks2.norm = seconds\nPeaks2.relThresh = 0.100000\nPeaks2.dynRelThresh = 0\n;Peaks2.posDbgOutp = minmax.txt\nPeaks2.posDbgAppend = 0\nPeaks2.consoleDbg = 0\n\nSegments.maxNumSeg = 100\nSegments.segmentationAlgorithm = NArelTh\nSegments.thresholds = 0.25\nSegments.rangeRelThreshold = 0.200000\nSegments.numSegments = 0\nSegments.meanSegLen = 1\nSegments.maxSegLen = 1\nSegments.minSegLen = 1\nSegments.segLenStddev = 1\nSegments.norm = second\n\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nMoments.doRatioLimit = 0\n\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\n\nRegression.centroidUseAbsValues = 0\nRegression.centroidRatioLimit = 0\nRegression.doRatioLimit = 0\nRegression.linregc1 = 1\nRegression.linregc2 = 0\nRegression.linregerrA = 1\nRegression.linregerrQ = 0\nRegression.qregc1 = 1\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 1\nRegression.qregerrQ = 0\nRegression.oldBuggyQerr = 0\nRegression.centroid = 0\nRegression.normRegCoeff = 1\nRegression.normInputs = 1\n\nTimes.upleveltime25 = 1\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 1\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.buggySecNorm = 0\nTimes.norm = segment\n\nLpc.lpGain = 1\nLpc.lpc = 1\nLpc.firstCoeff = 0\nLpc.order = 5\n\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n; functionals for energy and spectral related lld (deltas)\n[functionalsAde:cFunctionals]\nreader.dmLevel = lldA_smo_de;lldB_smo_de\nwriter.dmLevel = functionalsAde\n// nameAppend = \ncopyInputName = 1\n\\{\\cm[frameModeConf]}\n\nfunctionalsEnabled = Percentiles ; Means ; Moments ; Times \nMeans.amean = 0\nMeans.posamean = 1\nMeans.absmean = 0\nMeans.rqmean = 1\nMeans.flatness = 1\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\n\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nMoments.doRatioLimit = 0\n\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\n\nTimes.upleveltime25 = 1\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 1\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.buggySecNorm = 0\nTimes.norm = segment\n\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n\n\n; functionals for voiced segments and pitch onsets\n[functionalsF0v:cFunctionals]\nreader.dmLevel = lld_f0v_nzsmo\n  ;lld_f0_nzsmo_de\nwriter.dmLevel = functionalsF0v\n//nameAppend = ff0\ncopyInputName = 1\n\\{\\cm[frameModeConf]}\nfunctionalsEnabled = Means ; Segments\nMeans.amean = 0\nMeans.absmean = 0\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 1\nMeans.norm = segment\nSegments.maxNumSeg = 999\nSegments.segmentationAlgorithm = nonX\nSegments.X = 0.0\nSegments.numSegments = 0\nSegments.meanSegLen = 1\nSegments.maxSegLen = 1\nSegments.minSegLen = 1\nSegments.segLenStddev = 1\nSegments.norm = second\nOnset.threshold = 1\nOnset.onsetRate = 1\nOnset.norm = second\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n; functionals for unvoiced segments\n[functionalsF0p:cFunctionals]\nreader.dmLevel = lld_f0p_nzsmo\nwriter.dmLevel = functionalsF0p\n//nameAppend = pauses\ncopyInputName = 0\n\\{\\cm[frameModeConf]}\nframeCenterSpecial = left\nfunctionalsEnabled = Segments\nSegments.maxNumSeg = 999\nSegments.segmentationAlgorithm = eqX\nSegments.X = 0.0\nSegments.numSegments = 0\nSegments.meanSegLen = 1\nSegments.maxSegLen = 1\nSegments.minSegLen = 1\nSegments.segLenStddev = 1\nSegments.norm = second\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n\n; functionals for pitch and vq related lld in voiced regions\n[functionalsNz:cFunctionals]\nreader.dmLevel = lld_nzsmo\nwriter.dmLevel = functionalsNz\n// nameAppend = \ncopyInputName = 1\n\\{\\cm[frameModeConf]}\nfunctionalsEnabled = Percentiles ; Means ; Moments ; Peaks2 ; Regression ; Times \nMeans.amean = 1\nMeans.absmean = 0\nMeans.rqmean = 1\nMeans.qmean = 0\nMeans.flatness = 1\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\nPeaks2.doRatioLimit = 0\nPeaks2.numPeaks = 0\nPeaks2.meanPeakDist = 1\nPeaks2.meanPeakDistDelta = 0\nPeaks2.peakDistStddev = 1\nPeaks2.peakRangeAbs = 0\nPeaks2.peakRangeRel = 1\nPeaks2.peakMeanAbs = 0\nPeaks2.peakMeanMeanDist = 0\nPeaks2.peakMeanRel = 1\nPeaks2.ptpAmpMeanAbs = 0\nPeaks2.ptpAmpMeanRel = 0\nPeaks2.ptpAmpStddevAbs = 0\nPeaks2.ptpAmpStddevRel = 0\nPeaks2.minRangeAbs = 0\nPeaks2.minRangeRel = 1\nPeaks2.minMeanAbs = 0\nPeaks2.minMeanMeanDist = 0\nPeaks2.minMeanRel = 0\nPeaks2.mtmAmpMeanAbs = 0\nPeaks2.mtmAmpMeanRel = 0\nPeaks2.mtmAmpStddevAbs = 0\nPeaks2.mtmAmpStddevRel = 0\nPeaks2.meanRisingSlope = 1\nPeaks2.maxRisingSlope = 0\nPeaks2.minRisingSlope = 0\nPeaks2.stddevRisingSlope = 1\nPeaks2.meanFallingSlope = 1\nPeaks2.maxFallingSlope = 0\nPeaks2.minFallingSlope = 0\nPeaks2.stddevFallingSlope = 1\nPeaks2.norm = seconds\nPeaks2.relThresh = 0.100000\nPeaks2.dynRelThresh = 0\n;Peaks2.posDbgOutp = minmax.txt\nPeaks2.posDbgAppend = 0\nPeaks2.consoleDbg = 0\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\nRegression.centroidUseAbsValues = 0\nRegression.centroidRatioLimit = 0\nRegression.doRatioLimit = 0\nRegression.linregc1 = 1\nRegression.linregc2 = 0\nRegression.linregerrA = 1\nRegression.linregerrQ = 0\nRegression.qregc1 = 1\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 1\nRegression.qregerrQ = 0\nRegression.oldBuggyQerr = 0\nRegression.centroid = 0\nRegression.normRegCoeff = 1\nRegression.normInputs = 1\nTimes.upleveltime25 = 1\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 1\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.buggySecNorm = 0\nTimes.norm = segment\nLpc.lpGain = 1\nLpc.lpc = 1\nLpc.firstCoeff = 0\nLpc.order = 5\nnonZeroFuncts = 1\nmasterTimeNorm = segment\n\n\n; functionals for pitch and vq related lld in voiced regions (deltas)\n[functionalsNzDe:cFunctionals]\nreader.dmLevel = lld_nzsmo_de\nwriter.dmLevel = functionalsNzDe\n// nameAppend = \ncopyInputName = 1\n\\{\\cm[frameModeConf]}\nfunctionalsEnabled = Percentiles ; Means ; Moments ; Times \nMeans.amean = 0\nMeans.posamean = 1\nMeans.absmean = 0\nMeans.rqmean = 1\nMeans.qmean = 0\nMeans.flatness = 1\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\nTimes.upleveltime25 = 1\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 1\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.buggySecNorm = 0\nTimes.norm = segment\nLpc.lpGain = 1\nLpc.lpc = 1\nLpc.firstCoeff = 0\nLpc.order = 5\nnonZeroFuncts = 1\nmasterTimeNorm = segment\n\n\n; functionals for input segment duration\n[functionalsDur:cFunctionals]\nreader.dmLevel = lld_f0v_nzsmo\nwriter.dmLevel = functionalsDur\n// nameAppend =\ncopyInputName = 1\n\\{\\cm[frameModeConf]}\nnoPostEOIprocessing=0\nfunctionalsEnabled = Times\nTimes.upleveltime25 = 0\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 0\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 0\nTimes.downleveltime90 = 0\nTimes.risetime = 0\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 1\nTimes.buggySecNorm = 0\nTimes.norm = second\nnonZeroFuncts = 0\nmasterTimeNorm = second\n\n\n\n\n\n"
  },
  {
    "path": "config/avec2013_functionals_frame_mode.conf.inc",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file                             //////////////////\n/////////   for AVEC 2013                                            //////////////////\n/////////   based on avec2011.conf                                   //////////////////\n/////////  * written 2013 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) 2014 by audEERING UG (limited)                         //////////////////\n/////////     All rights reserved                                    //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\nframeMode = full\nframeSize = 0\nframeStep = 0\nframeCenterSpecial = left\n\n"
  },
  {
    "path": "config/avec2013_lld_core.conf.inc",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file                             //////////////////\n/////////   for AVEC 2013                                            //////////////////\n/////////   based on avec2011.conf                                   //////////////////\n/////////  * written 2013 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) 2014 by audEERING UG (limited)                         //////////////////\n/////////     All rights reserved                                    //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\n;;;;;;; component list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\nprintLevelStats=0\n\n\\{shared/standard_wave_input.conf.inc}\n\n;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[frame60].type=cFramer\ninstance[win60].type=cWindower\ninstance[fft60].type=cTransformFFT\ninstance[fftmp60].type=cFFTmagphase\n\n[frame60:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frame60\nframeSize = 0.060\nframeStep = 0.010\nframeCenterSpecial = left\n\n\n[win60:cWindower]\nreader.dmLevel=frame60\nwriter.dmLevel=winG60\nwinFunc=gauss\ngain=1.0\nsigma=0.4\n\n[fft60:cTransformFFT]\nreader.dmLevel=winG60\nwriter.dmLevel=fftcG60\nzeroPadSymmetric = 0\n\n[fftmp60:cFFTmagphase]\nreader.dmLevel=fftcG60\nwriter.dmLevel=fftmagG60\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[frame25].type=cFramer\ninstance[pe25].type=cVectorPreemphasis\ninstance[win25].type=cWindower\ninstance[fft25].type=cTransformFFT\ninstance[fftmp25].type=cFFTmagphase\n\n[frame25:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frame25\nframeSize = 0.025\nframeStep = 0.010\nframeCenterSpecial = left\n\n[pe25:cVectorPreemphasis]\nreader.dmLevel=frame25\nwriter.dmLevel=frame25pe\nk=0.97\nde=0\n\n[win25:cWindower]\nreader.dmLevel=frame25\nwriter.dmLevel=winH25\nwinFunc=hamming\n\n[fft25:cTransformFFT]\nreader.dmLevel=winH25\nwriter.dmLevel=fftcH25\nzeroPadSymmetric = 0\n\n[fftmp25:cFFTmagphase]\nreader.dmLevel=fftcH25\nwriter.dmLevel=fftmagH25\n\n;;;;;;;;;;;;;;;;;;;; HPS pitch\n\n[componentInstances:cComponentManager]\ninstance[scale].type=cSpecScale\ninstance[shs].type=cPitchShs\ninstance[pitchSmooth].type=cPitchSmootherViterbi\ninstance[energy60].type=cEnergy\ninstance[volmerge].type=cValbasedSelector\n\n[energy60:cEnergy]\nreader.dmLevel=winG60\nwriter.dmLevel=e60\nrms=1\nlog=0\nwriter.levelconf.nT=200\n\n\n[scale:cSpecScale]\nreader.dmLevel=fftmagG60\nwriter.dmLevel=hpsG60\ncopyInputName = 1\nprocessArrayFields = 0\nscale=octave\nsourceScale = lin\n// logScaleBase = 2\n// logSourceScaleBase = 2\n// firstNote = 55\ninterpMethod = spline\nminF = 20\nmaxF = -1\nnPointsTarget = 0\nspecSmooth = 1\nspecEnhance = 1\nauditoryWeighting = 1 \n\n[shs:cPitchShs]\nreader.dmLevel=hpsG60\nwriter.dmLevel=pitchShsG60\ncopyInputName = 1\nprocessArrayFields = 0\nmaxPitch = 620\nminPitch = 42\nnCandidates = 6\nscores = 1\nvoicing = 1\nF0C1 = 0\nvoicingC1 = 0\nF0raw = 1\nvoicingClip = 1\nvoicingCutoff = 0.700000\ninputFieldSearch = Mag_octScale\noctaveCorrection = 0\nnHarmonics = 15\ncompressionFactor = 0.850000\ngreedyPeakAlgo = 1\n\n[pitchSmooth:cPitchSmootherViterbi]\nreader.dmLevel=pitchShsG60\nreader2.dmLevel=pitchShsG60\nwriter.dmLevel=pitchG60a\ncopyInputName = 1\nbufferLength=90\nF0final = 1\nF0finalEnv = 0\nvoicingFinalClipped = 0\nvoicingFinalUnclipped = 1\nF0raw = 0\nvoicingC1 = 0\nvoicingClip = 0\nwTvv =10.0\nwTvvd= 5.0\nwTvuv=10.0\nwThr = 4.0\nwTuu = 0.0\nwLocal=2.0\nwRange=1.0\n\n// SHS/Viterbi pitch algo does strange things at very low amplitudes, so we filter these out \n[volmerge:cValbasedSelector]\nreader.dmLevel = e60;pitchG60a\nwriter.dmLevel = pitchG60\nidx=0\nthreshold=0.0008\nremoveIdx=1\nzeroVec=1\noutputVal=0.0\n\n\n;;;;;;;;;;;;;;;;;;; VQ\n\n[componentInstances:cComponentManager]\ninstance[pitchJitter].type=cPitchJitter\n\n\n[pitchJitter:cPitchJitter]\nreader.dmLevel = wave\nwriter.dmLevel = jitterShimmer\n// nameAppend =\ncopyInputName = 1\n; is pitchF really necessary, or can we use pitchG60 ?\nF0reader.dmLevel = pitchG60\nF0field = F0final\nsearchRangeRel = 0.250000\njitterLocal = 1\njitterDDP = 1\njitterLocalEnv = 0\njitterDDPEnv = 0\nshimmerLocal = 1\nshimmerLocalEnv = 0\nonlyVoiced = 0\nlogHNR = 1\ninputMaxDelaySec = 2.0\n;periodLengths = 0\n;periodStarts = 0\nuseBrokenJitterThresh = 1\n\n;;;;;;;;;;;;;;;;;;;;; Energy / loudness\n\n\n[componentInstances:cComponentManager]\ninstance[melspec1].type=cMelspec\ninstance[audspec].type=cPlp\ninstance[audspecSum].type=cVectorOperation\n\n\n[melspec1:cMelspec]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=melspec1\n; htk compatible sample value scaling\nhtkcompatible = 0\nnBands = 26\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 20\nhifreq = 8000\nspecScale = bark\n\n; perform auditory weighting of spectrum\n[audspec:cPlp]\nreader.dmLevel=melspec1\nwriter.dmLevel=audspec\nfirstCC = 0\nlpOrder = 5\ncepLifter = 22\ncompression = 0.33\nhtkcompatible = 0 \ndoIDFT = 0\ndoLpToCeps = 0\ndoLP = 0\ndoInvLog = 0\ndoAud = 1\ndoLog = 0\nnewRASTA=0\nRASTA=0\n\n[audspecSum:cVectorOperation]\nreader.dmLevel = audspec\nwriter.dmLevel = audspecSum\n// nameAppend = \ncopyInputName = 1\nprocessArrayFields = 0\noperation = ll1\nnameBase = audspec\n\n;;;;;;;;;;;;;;; spectral\n\n[componentInstances:cComponentManager]\ninstance[spectral].type=cSpectral\n\n\n[spectral:cSpectral]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=spectral\nbands[0]=250-650\nbands[1]=1000-4000\nrollOff[0] = 0.25\nrollOff[1] = 0.50\nrollOff[2] = 0.75\nrollOff[3] = 0.90\nflux=1\ncentroid=0\nmaxPos=0\nminPos=0\nentropy=1\nvariance=1\nskewness=1\nkurtosis=1\nslope=0\nsharpness = 1\ntonality = 0\nharmonicity = 1\nflatness = 1\n\n\n;;;;;;;;;;;;;;; mfcc\n\n[componentInstances:cComponentManager]\ninstance[melspecMfcc].type=cMelspec\ninstance[mfcc].type=cMfcc\n\n[melspecMfcc:cMelspec]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=melspecMfcc\ncopyInputName = 1\nprocessArrayFields = 1\n; htk compatible sample value scaling\nhtkcompatible = 1\nnBands = 26\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 20\nhifreq = 8000\nspecScale = mel\ninverse = 0\n\n[mfcc:cMfcc]\nreader.dmLevel=melspecMfcc\nwriter.dmLevel=mfcc1_12\ncopyInputName = 1\nprocessArrayFields = 1\nfirstMfcc = 1\nlastMfcc  = 16\ncepLifter = 22.0\nhtkcompatible = 1\n\n\n;;;;;;;;;;;;;;;;  zcr\n\n[componentInstances:cComponentManager]\ninstance[mzcr].type=cMZcr\n\n[mzcr:cMZcr]\nreader.dmLevel = frame25\nwriter.dmLevel = zcr\ncopyInputName = 1\nprocessArrayFields = 1\nzcr = 1\nmcr = 0\namax = 0\nmaxmin = 0\ndc = 0\n\n\n;;;;;;;;;;;;;;;;;;;; smoothing and selection\n\n[componentInstances:cComponentManager]\ninstance[smoNz].type=cContourSmoother\ninstance[smoA].type=cContourSmoother\ninstance[smoB].type=cContourSmoother\ninstance[f0sel].type=cDataSelector\ninstance[f0psel].type=cDataSelector\n\n[smoNz:cContourSmoother]\nreader.dmLevel = pitchG60;jitterShimmer\nwriter.dmLevel = lld_nzsmo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\nnoZeroSma = 1\n\n[f0sel:cDataSelector]\nreader.dmLevel = lld_nzsmo\nwriter.dmLevel = lld_f0v_nzsmo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = f0v\nselected = F0final_sma\n\n[f0psel:cDataSelector]\nreader.dmLevel = lld_nzsmo\nwriter.dmLevel = lld_f0p_nzsmo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = f0p\nselected = F0final_sma\n\n\n[smoA:cContourSmoother]\nreader.dmLevel = audspecSum;zcr\nwriter.dmLevel = lldA_smo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n[smoB:cContourSmoother]\nreader.dmLevel = spectral;mfcc1_12\nwriter.dmLevel = lldB_smo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n;;;;;;;;; deltas\n[componentInstances:cComponentManager]\ninstance[deNz].type=cDeltaRegression\ninstance[deA].type=cDeltaRegression\ninstance[deB].type=cDeltaRegression\n\n[deNz:cDeltaRegression]\nreader.dmLevel = lld_nzsmo\nwriter.dmLevel = lld_nzsmo_de\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nonlyInSegments = 1\nzeroSegBound = 1\n; TODO?  delta with zero segments removed...\n\n[deA:cDeltaRegression]\nreader.dmLevel = lldA_smo\nwriter.dmLevel = lldA_smo_de\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n[deB:cDeltaRegression]\nreader.dmLevel = lldB_smo\nwriter.dmLevel = lldB_smo_de\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n\n\n; OUTPUTS: lldA_smo;lldA_smo_de;lldB_smo;lldB_smo_de;lld_nzsmo;lld_nzsmo_de\n;  optional for pitch functionals: lld_f0v_smo;lld_f0p_smo\n\n"
  },
  {
    "path": "config/avec2014.readme",
    "content": "For AVEC2014, use the avec2013* config files. \n\nAVEC2014 uses the same audio feature set as AVEC2013!\n\n"
  },
  {
    "path": "config/chroma_fft.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for Chroma features <       //////////////////\n/////////   Chroma features computed over 64ms frames, Gauss window  //////////////////\n/////////   6 octaves from 55.0 Hz (first note)                      //////////////////\n/////////   Output: 12 chroma features in a CSV file                 //////////////////\n/////////                                                            //////////////////\n///////// (c) audEERING UG (haftungsbeschränkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n ;===== component manager configuration (= list of enabled components!) =====\n\n[componentInstances:cComponentManager]\ninstance[dataMemory].type = cDataMemory\ninstance[waveSource].type = cWaveSource\ninstance[framer].type = cFramer\ninstance[windower].type = cWindower\ninstance[transformFFT].type = cTransformFFT\ninstance[fFTmagphase].type = cFFTmagphase\ninstance[tonespec].type = cTonespec\ninstance[chroma].type = cChroma\ninstance[csvSink].type = cCsvSink\n // Here you can control the amount of detail displayed for the data memory\n // level configuration. 0 is no information at all, 5 is maximum detail.\nprintLevelStats = 0\n // You can set the number of parallel threads (experimental):\nnThreads = 1\n\n// ============= component configuration sections begin here ==============\n\n[waveSource:cWaveSource]\nwriter.dmLevel = wave\nfilename = \\cm[inputfile(I){input.wav}:name of input wave file]\nmonoMixdown = 1\nstart = 0\nend = -1\nendrel = 0\nnoHeader = 0\n \n[framer:cFramer]\nreader.dmLevel = wave\nwriter.dmLevel = frames\n// nameAppend = \ncopyInputName = 1\nframeMode = fixed\n// frameListFile = \n// frameList = \nframeSize = 0.064000\nframeStep = 0.010000\nframeCenterSpecial = left\nnoPostEOIprocessing = 1\n \n[windower:cWindower]\nreader.dmLevel = frames\nwriter.dmLevel = winframes\n// nameAppend = \ncopyInputName = 1\nprocessArrayFields = 1\ngain = 1\noffset = 0\nwinFunc = Gau\nsigma = 0.400000\n \n[transformFFT:cTransformFFT]\nreader.dmLevel = winframes\nwriter.dmLevel = fftc\n// nameAppend = \ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\n \n[fFTmagphase:cFFTmagphase]\nreader.dmLevel = fftc\nwriter.dmLevel = fftmag\n// nameAppend = \ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\nmagnitude = 1\nphase = 0\n \n[tonespec:cTonespec]\nreader.dmLevel = fftmag\nwriter.dmLevel = tonespec\nnameAppend = note\ncopyInputName = 1\nprocessArrayFields = 0\nnOctaves = 6\nfirstNote = 55\nfilterType = gau\nusePower = 1\ndbA = 1\n \n[chroma:cChroma]\nreader.dmLevel = tonespec\nwriter.dmLevel = chroma\nnameAppend = chroma\ncopyInputName = 0\nprocessArrayFields = 0\noctaveSize = 12\n \n[csvSink:cCsvSink]\nreader.dmLevel = chroma\nfilename = \\cm[outputfile(O){chroma.csv}:name of output CSV file for chroma features]\ndelimChar = ;\nappend = 0\ntimestamp = 0\nnumber = 0\nprintHeader = 0\n\n\n// ################### END OF openSMILE CONFIG FILE ######################\n\n"
  },
  {
    "path": "config/chroma_filt.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for Chroma features <       //////////////////\n/////////   Chroma features computed via sine tone filter bank       //////////////////\n/////////   6 octaves from 55.0 Hz (first note)                      //////////////////\n/////////   Output: 12 chroma features in a CSV file                 //////////////////\n/////////                                                            //////////////////\n///////// (c) audEERING UG (haftungsbeschränkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n ;===== component manager configuration (= list of enabled components!) =====\n\n[componentInstances:cComponentManager]\ninstance[dataMemory].type = cDataMemory\ninstance[waveSource].type = cWaveSource\ninstance[tonefilt].type = cTonefilt\ninstance[chroma].type = cChroma\ninstance[csvSink].type = cCsvSink\n // Here you can control the amount of detail displayed for the data memory\n // level configuration. 0 is no information at all, 5 is maximum detail.\nprintLevelStats = 1\n // You can set the number of parallel threads (experimental):\nnThreads = 1\n\n// ============= component configuration sections begin here ==============\n\n[waveSource:cWaveSource]\nwriter.dmLevel = wave\nfilename = \\cm[inputfile(I){input.wav}:name of wave input file]\nmonoMixdown = 1\nstart = 0\nend = -1\nendrel = 0\nnoHeader = 0\n \n[tonefilt:cTonefilt]\nreader.dmLevel = wave\nwriter.dmLevel = tonespec\nnameAppend = tonefilt\ncopyInputName = 1\nnNotes = 72\nfirstNote = 55\ndecayF0 = 0.999900\ndecayFN = 0.999000\noutputPeriod = 0.0100\n \n[chroma:cChroma]\nreader.dmLevel = tonespec\nwriter.dmLevel = chroma\nnameAppend = chroma\ncopyInputName = 0\nprocessArrayFields = 1\noctaveSize = 12\n \n[csvSink:cCsvSink]\nreader.dmLevel = chroma\nfilename = \\cm[outputfile(O){chroma.csv}:output CSV file for chroma features]\ndelimChar = ;\nappend = 0\ntimestamp = 0\nnumber = 0\nprintHeader = 0\n \n// ################### END OF openSMILE CONFIG FILE ######################\n\n"
  },
  {
    "path": "config/demo/audioplayer.conf",
    "content": "\n ///////////////////////////////////////////////////////////////////////////\n  //  openSMILE configuration example for a simple WAVE player //\n ///////////////////////////////////////////////////////////////////////////\n\n ;===== component manager configuration (= list of enabled components!) =====\n\n[componentInstances:cComponentManager]\n // this line configures the default data memory:\ninstance[dataMemory].type = cDataMemory\ninstance[waveSource].type = cWaveSource\ninstance[portaudioSink].type = cPortaudioSink\n // Here you can control the amount of detail displayed for the data memory\n  // level configuration. 0 is no information at all, 5 is maximum detail.\nprintLevelStats = 1\n // You can set the number of parallel threads (experimental):\nnThreads = 1\n\n// ============= component configuration sections begin here ==============\n\n\n  ;;;; default (template) configuration section for component 'cWaveSource' ;;;;\n[waveSource:cWaveSource]\nwriter.dmLevel = wave\nperiod = 0\nfilename = \\cm[inputfile(I){input.wav}:name of wave (PCM) input file]\nmonoMixdown = 0\nstart = 0\nend = -1\nendrel = 0\nnoHeader = 0\nblocksize_sec=0.1 \n\n  ;;;; default (template) configuration section for component 'cPortaudioSink' ;;;;\n[portaudioSink:cPortaudioSink]\nreader.dmLevel = wave\nmonoMixdown = 0\ndevice = -1\nlistDevices = 0\nsampleRate = 0\naudioBuffersize_sec = 0.20000\n \n\n// ################### END OF openSMILE CONFIG FILE ######################\n\n"
  },
  {
    "path": "config/demo/audiorecorder.conf",
    "content": "\n ///////////////////////////////////////////////////////////////////////////\n  // openSMILE configuration example for a simple wave (PCM) recorder //\n ///////////////////////////////////////////////////////////////////////////\n\n ;===== component manager configuration (= list of enabled components!) =====\n\n[componentInstances:cComponentManager]\n // this line configures the default data memory:\ninstance[dataMemory].type = cDataMemory\ninstance[portaudioSource].type = cPortaudioSource\ninstance[waveSink].type = cWaveSink\n // Here you can control the amount of detail displayed for the data memory\n  // level configuration. 0 is no information at all, 5 is maximum detail.\nprintLevelStats = 1\n // You can set the number of parallel threads (experimental):\nnThreads = 1\n\n// ============= component configuration sections begin here ==============\n\n\n  ;;;; default (template) configuration section for component 'cPortaudioSource' ;;;;\n[portaudioSource:cPortaudioSource]\nwriter.dmLevel = wave\nmonoMixdown = 0\n ; -1 is the default device\ndevice = \\cm[device{-1}:portaudio device to use for recording, see -listDevices option]\nlistDevices = \\cm[listDevices{0}:add -listDevices 1 to the command-line to see a list available of portaudio devices]\nsampleRate = \\cm[sampleRate{44100}:set the sampling rate in Hz for recording]\nchannels = \\cm[channels{2}:set the number of audio channels to record]\nnBits = 16\naudioBuffersize_sec = 0.050000\n \n\n  ;;;; default (template) configuration section for component 'cWaveSink' ;;;;\n[waveSink:cWaveSink]\nreader.dmLevel = wave\nblocksize=500\nfilename = \\cm[outputfile(O){output.wav}:name of output wave file]\nsampleFormat = 16bit\n \n\n// ################### END OF openSMILE CONFIG FILE ######################\n\n"
  },
  {
    "path": "config/demo/demo1_energy.conf",
    "content": "\n ///////////////////////////////////////////////////////////////////////////\n // openSMILE configuration file \"demo1\"\t\t\t\t  //\n ///////////////////////////////////////////////////////////////////////////\n\n ;===== component manager configuration (= list of enabled components!) =====\n\n[componentInstances:cComponentManager]\n // this line configures the default data memory:\ninstance[dataMemory].type = cDataMemory\ninstance[waveSource].type = cWaveSource\ninstance[framer].type = cFramer\ninstance[energy].type = cEnergy\ninstance[csvSink].type = cCsvSink\n // Here you can control the amount of detail displayed for the data memory\n // level configuration. 0 is no information at all, 5 is maximum detail.\nprintLevelStats = 1\n // You can set the number of parallel threads (experimental):\nnThreads = 1\n\n// ============= component configuration sections begin here ==============\n\n\n  ;;;; default (template) configuration section for component 'cWaveSource' ;;;;\n[waveSource:cWaveSource]\nwriter.dmLevel = wave\nperiod = 0\n; filename = input.wav\nfilename = \\cm[inputfile(I){input.wav}:file name of the input wave file]\nmonoMixdown = 1 \n\n  ;;;; default (template) configuration section for component 'cFramer' ;;;;\n[framer:cFramer]\nreader.dmLevel = wave\nwriter.dmLevel = waveframes\ncopyInputName = 1\nframeMode = fixed\nframeSize = 0.025000\nframeStep = 0.010000\nframeCenterSpecial = left\nnoPostEOIprocessing = 1\n\n  ;;;; default (template) configuration section for component 'cEnergy' ;;;;\n[energy:cEnergy]\nreader.dmLevel = waveframes\nwriter.dmLevel = energy\nnameAppend = energy\ncopyInputName = 1\nprocessArrayFields = 0\nhtkcompatible = 0\nrms = 0\nlog = 1\n \n\n  ;;;; default (template) configuration section for component 'cCsvSink' ;;;;\n[csvSink:cCsvSink]\nreader.dmLevel = energy\n; filename = myenergy.csv\nfilename = \\cm[outputfile(O){output.csv}:file name of the output CSV file]\ndelimChar = ;\nappend = 0\ntimestamp = 1\nnumber = 1\nprintHeader = 1\n \n\n// ################### END OF openSMILE CONFIG FILE ######################\n\n"
  },
  {
    "path": "config/demo/signalGenerator.conf",
    "content": "\n ///////////////////////////////////////////////////////////////////////////\n // openSMILE example configuration file for the signal generator         //\n ///////////////////////////////////////////////////////////////////////////\n\n ;===== component manager configuration (= list of enabled components!) =====\n\n[componentInstances:cComponentManager]\n // this line configures the default data memory:\ninstance[dataMemory].type = cDataMemory\ninstance[signalGenerator].type = cSignalGenerator\ninstance[waveSink].type = cWaveSink\n // Here you can control the amount of detail displayed for the data memory\n  // level configuration. 0 is no information at all, 5 is maximum detail.\nprintLevelStats = 1\n // You can set the number of parallel threads (experimental):\nnThreads = 1\n\n// ============= component configuration sections begin here ==============\n\n\n  ;;;; default (template) configuration section for component 'cSignalGenerator' ;;;;\n[signalGenerator:cSignalGenerator]\nwriter.dmLevel = sig\n ; 16 kHz wave files\nperiod = 0.0000625\n ; 44.1 kHz wave files\n;period = 2.2675736961451247165532879818594e-5\n ; 1 channel...\nnFields = 1\n ; sine wave   (use 'white' for Gaussian white noise)\nsignalType = sine\nrandSeed = 1\nscale = 1\nconst = 0\nfrequency = 440\nphase = 0\nlength = 3\n \n\n  ;;;; default (template) configuration section for component 'cWaveSink' ;;;;\n[waveSink:cWaveSink]\nreader.dmLevel = sig\nfilename = output.wav\nsampleFormat = 16bit\n \n\n// ################### END OF openSMILE CONFIG FILE ######################\n\n"
  },
  {
    "path": "config/emo_large.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for emotion features <      //////////////////\n/////////   large set of 6552 features, 1st level functionals        //////////////////\n/////////   of low-level descriptors such as MFCC, Pitch, LSP, ...   //////////////////\n/////////                                                            //////////////////\n/////////   (56 LLD + 56 delta) * 39 functionals                     //////////////////\n/////////                                                            //////////////////\n/////////  * written 2009 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) audEERING UG (haftungsbeschränkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n// NOTE: This file is no longer compatible with the old openEAR version.\n// The ISxx sets should be preferred or the emobase set.\n\n///////////////////////////////////////////////////////////////////////////////////////\n;\n; This section is always required in openSMILE configuration files\n;   it configures the componentManager and gives a list of all components which are to be loaded\n; The order in which the components are listed should match\n;   the order of the data flow for most efficient processing\n;\n///////////////////////////////////////////////////////////////////////////////////////\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\ninstance[waveIn].type=cWaveSource\ninstance[fr1].type=cFramer\ninstance[pe2].type=cVectorPreemphasis\ninstance[w1].type=cWindower\ninstance[fft1].type=cTransformFFT\ninstance[fftmp1].type=cFFTmagphase\ninstance[mspec].type=cMelspec\ninstance[mfcc].type=cMfcc\ninstance[mzcr].type=cMZcr\ninstance[acf].type=cAcf\ninstance[cepstrum].type=cAcf\ninstance[pitchACF].type=cPitchACF\ninstance[energy].type=cEnergy\ninstance[spectral].type=cSpectral\ninstance[lld].type=cContourSmoother\ninstance[delta1].type=cDeltaRegression\ninstance[delta2].type=cDeltaRegression\ninstance[functL1].type=cFunctionals\ninstance[arffsink].type=cArffSink\nprintLevelStats=0\nnThreads=1\n\n\n/////////////////////////////////////////////////////////////////////////////////////////////\n/////////////////////////   component configuration  ////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////////////////////\n; the following sections configure the components listed above\n; a help on configuration parameters can be obtained with\n;  SMILExtract -H\n; or\n;  SMILExtract -H configTypeName (= componentTypeName)\n/////////////////////////////////////////////////////////////////////////////////////////////\n[waveIn:cWaveSource]\nwriter.dmLevel=wave\nfilename=\\cm[inputfile(I){test.wav}:name of input file]\nmonoMixdown=1\n\n[fr1:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames\nnoPostEOIprocessing = 1\ncopyInputName = 1\nframeSize = 0.0250\nframeStep = 0.010\nframeMode = fixed\nframeCenterSpecial = center\nbuffersize = 1000\n\n[pe2:cVectorPreemphasis]\nreader.dmLevel=frames\nwriter.dmLevel=framespe\nk = 0.97\nde = 0\n\n[w1:cWindower]\nreader.dmLevel=framespe\nwriter.dmLevel=winframe\ncopyInputName = 1\nprocessArrayFields = 1\nwinFunc = ham\ngain = 1.0\noffset = 0\n\n  // ---- LLD -----\n\n[fft1:cTransformFFT]\nreader.dmLevel=winframe\nwriter.dmLevel=fftc\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmp1:cFFTmagphase]\nreader.dmLevel=fftc\nwriter.dmLevel=fftmag\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\nmagnitude = 1\nphase = 0\n\n[mspec:cMelspec]\nnameAppend=melspec\nreader.dmLevel=fftmag\nwriter.dmLevel=mspec1\ncopyInputName = 1\nprocessArrayFields = 1\nhtkcompatible = 1\nusePower = 0\nnBands = 26\nlofreq = 0\nhifreq = 8000\nusePower = 0\ninverse = 0\nspecScale = mel\n\n[mfcc:cMfcc]\nreader.dmLevel=mspec1\nwriter.dmLevel=mfcc1\ncopyInputName = 0\nprocessArrayFields = 1\nfirstMfcc = 0\nlastMfcc =  12\ncepLifter = 22.0\nhtkcompatible = 1\n\n\n[acf:cAcf]\nreader.dmLevel=fftmag\nwriter.dmLevel=acf\nnameAppend = acf\ncopyInputName = 1\nprocessArrayFields = 1\nusePower = 1\ncepstrum = 0\nacfCepsNormOutput = 0\n\n[cepstrum:cAcf]\nreader.dmLevel=fftmag\nwriter.dmLevel=cepstrum\nnameAppend = acf\ncopyInputName = 1\nprocessArrayFields = 1\nusePower = 1\ncepstrum = 1\nacfCepsNormOutput = 0\noldCompatCepstrum = 1\nabsCepstrum = 1\n\n[pitchACF:cPitchACF]\n  ; the pitchACF component must ALWAYS read from acf AND cepstrum in the given order!\nreader.dmLevel=acf;cepstrum\nwriter.dmLevel=pitch\ncopyInputName = 1\nprocessArrayFields = 0\nmaxPitch = 500\nvoiceProb = 1\nvoiceQual = 0\nHNR = 0\nF0 = 1\nF0raw = 0\nF0env = 1\nvoicingCutoff = 0.550000\n\n[energy:cEnergy]\nreader.dmLevel=winframe\nwriter.dmLevel=energy\nnameAppend=energy\ncopyInputName = 1\nprocessArrayFields = 0\nhtkcompatible = 0\nrms=0\nlog=1\n\n[mzcr:cMZcr]\nreader.dmLevel=frames\nwriter.dmLevel=mzcr\ncopyInputName = 1\nprocessArrayFields = 1\nzcr = 1\namax = 0\nmcr = 0\nmaxmin = 0\ndc = 0\n\n[spectral:cSpectral]\nreader.dmLevel=fftmag\nwriter.dmLevel=spectral\ncopyInputName = 1\nprocessArrayFields = 1\nsquareInput = 1\nbands[0]=0-250\nbands[1]=0-650\nbands[2]=250-650\nbands[3]=1000-4000\n;;;bands[4]=3010-9123\nrollOff[0] = 0.25\nrollOff[1] = 0.50\nrollOff[2] = 0.75\nrollOff[3] = 0.90\n; buggyRollOff = 1\n; set the above for compatibility with older releases\nflux = 1\ncentroid = 1\nmaxPos = 1\nminPos = 1\nentropy = 0\n\n[lld:cContourSmoother]\nreader.dmLevel=energy;mfcc1;mspec1;mzcr;pitch;spectral\nwriter.dmLevel=lld\nwriter.levelconf.nT=10\n;writer.levelconf.noHang=2\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n;processArrayFields=0\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n  // ---- delta regression of LLD ----\n\n[delta1:cDeltaRegression]\nreader.dmLevel=lld\nwriter.dmLevel=lld_de\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = de\ncopyInputName = 1\nnoPostEOIprocessing = 0\ndeltawin=2\nblocksize=1\n\n[delta2:cDeltaRegression]\nreader.dmLevel=lld_de\nwriter.dmLevel=lld_dede\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = de\ncopyInputName = 1\nnoPostEOIprocessing = 0\ndeltawin=2\nblocksize=1\n\n\n[functL1:cFunctionals]\nreader.dmLevel=lld;lld_de;lld_dede\nwriter.dmLevel=func\ncopyInputName = 1\nframeMode = full\n ; frameSize and frameStep = 0 => functionals over complete input\n ; (NOTE: buffersize of lld and lld_de levels must be large enough!!)\nframeSize=0\nframeStep=0\nframeCenterSpecial = left\nnoPostEOIprocessing = 0\nfunctionalsEnabled=Extremes;Regression;Moments;Percentiles;Crossings;Peaks;Means\nExtremes.max = 0\nExtremes.min = 0\nExtremes.range = 1\nExtremes.maxpos = 1\nExtremes.minpos = 1\nExtremes.amean = 0\nExtremes.maxameandist = 1\nExtremes.minameandist = 1\nExtremes.norm = frame\nRegression.linregc1 = 1\nRegression.linregc2 = 1\nRegression.linregerrA = 1\nRegression.linregerrQ = 1\nRegression.qregc1 = 1\nRegression.qregc2 = 1\nRegression.qregc3 = 1\nRegression.qregerrA = 1\nRegression.qregerrQ = 1\nRegression.centroid = 1\nRegression.oldBuggyQerr = 1\nRegression.normInputs = 0\nRegression.normRegCoeff = 0\nRegression.doRatioLimit = 0\nRegression.centroidRatioLimit = 0\nMoments.doRatioLimit = 0\nMoments.variance = 1\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nPercentiles.quartiles = 1\nPercentiles.quartile1 = 0\nPercentiles.quartile2 = 0\nPercentiles.quartile3 = 0\nPercentiles.iqr = 1\nPercentiles.iqr12 = 0\nPercentiles.iqr23 = 0\nPercentiles.iqr13 = 0\nPercentiles.interp = 1\nPercentiles.percentile[0] = 0.95\nPercentiles.percentile[1] = 0.98\nCrossings.zcr = 1\nCrossings.mcr = 0\nCrossings.amean = 0\nPeaks.numPeaks = 1\nPeaks.meanPeakDist = 1\nPeaks.peakMean = 1\nPeaks.peakMeanMeanDist = 1\nPeaks.overlapFlag = 1\nMeans.amean = 1\nMeans.absmean = 1\nMeans.qmean = 1\nMeans.nzamean = 0\nMeans.nzabsmean = 1\nMeans.nzqmean = 1\nMeans.nzgmean = 1\nMeans.nnz = 1\n\n\n\n\n  //////////////////////////////////////////////////////////////////////\n ///////////////////  data output configuration  //////////////////////\n//////////////////////////////////////////////////////////////////////\n\n// ----- you might need to customise the arff output to suit your needs: ------\n\n[arffsink:cArffSink]\nreader.dmLevel=func\n ; do not print \"frameIndex\" attribute to ARFF file\nframeIndex=0\nframeTime=1\n ; name of output file as commandline option\nfilename=\\cm[arffout(O){output.arff}:name of WEKA Arff output file]\n ; name of @relation in the ARFF file\nrelation=\\cm[corpus{SMILEfeatures}:corpus name, arff relation]\n\n ; name of the current instance (usually file name of input wave file)\ninstanceName=\\cm[instname(N){noname}:name of arff instance]\n ;; use this line instead of the above to always set the instance name to the \n ;; name of the input wave file\n ;instanceName=\\cm[inputfile]\n\n;; name of class label\nclass[0].name = emotion\n ; list of nominal classes OR \"numeric\"\nclass[0].type = \\cm[classes{unknown}:all classes for arff file attribute]\n ; the class label or value for the current instance\ntarget[0].all = \\cm[classlabel(a){unknown}:instance class label]\n ; append to an existing file, so multiple calls of SMILExtract on different\n ; input files append to the same output ARFF file\nappend=1\n\n\n//////---------------------- END -------------------------///////\n\n\n"
  },
  {
    "path": "config/emobase.conf",
    "content": "\n///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for live emotion recognition < ///////////////\n/////////   base set of 988 features, 1st level functionals          //////////////////\n/////////   of low-level descriptors such as MFCC, Pitch, LSP, ...   //////////////////\n/////////                                                            //////////////////\n/////////  * written 2009 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) 2014 audEERING UG (haftungsbeschrnkt),                //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n//  Modified version:\n//   - compatibility of newest 2.1 openSMILE code with openEAR 0.1.0 models\n\n\n///////////////////////////////////////////////////////////////////////////////////////\n;\n; This section is always required in openSMILE configuration files\n;   it configures the componentManager and gives a list of all components which are to be loaded\n; The order in which the components are listed should match \n;   the order of the data flow for most efficient processing\n;\n///////////////////////////////////////////////////////////////////////////////////////\n[componentInstances:cComponentManager]\n ;this line configures the default data memory:\ninstance[dataMemory].type=cDataMemory\ninstance[waveIn].type=cWaveSource\ninstance[fr25].type=cFramer\n ;;; 40 ms frames features:\ninstance[fr40].type=cFramer\ninstance[w40].type=cWindower\ninstance[fft40].type=cTransformFFT\ninstance[fftmagphase40].type=cFFTmagphase\ninstance[acf40].type=cAcf\ninstance[cepstrum40].type=cAcf\n ; Pitch...\ninstance[pitchACF].type=cPitchACF\n ;;; 25 ms frames features:\ninstance[pe].type=cVectorPreemphasis\ninstance[win].type=cWindower\ninstance[fft].type=cTransformFFT\ninstance[fftmagphase].type=cFFTmagphase\ninstance[mspec].type=cMelspec\n ; MFCC\ninstance[mfcc].type=cMfcc\ninstance[lpc].type=cLpc\n ; Line Spectral Frequencies\ninstance[lsp].type=cLsp\n ; Zero-Crossings\ninstance[mzcr].type=cMZcr\n ; Intensity and Loudness (narrow-band approximation)\ninstance[intens].type=cIntensity\n ;;; all LLD concattenated and smoothed using a moving average filter\ninstance[lld].type=cContourSmoother\n ; delta coefficients of LLD\ninstance[delta1].type=cDeltaRegression\n ;;; functionals over FULL input (e.g. turns)\ninstance[functL1].type=cFunctionals\n ;;; write instances to a Weka ARFF file (comment out to disable)\ninstance[arffsink].type=cArffSink\n ;;; live classification of emotion (comment out lines to disable them):\n;; run single threaded (nThreads=1)\n; NOTE: a single thread is more efficient for processing small files, since multi-threaded processing involves more \n;       overhead during startup, which will make the system slower in the end\nnThreads=1\n;; do not show any internal dataMemory level settings \n; (if you want to see them set the value to 1, 2, 3, or 4, depending on the amount of detail you wish)\nprintLevelStats=0\n\n\n/////////////////////////////////////////////////////////////////////////////////////////////\n/////////////////////////   component configuration  ////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////////////////////\n; the following sections configure the components listed above\n; a help on configuration parameters can be obtained with \n;  SMILExtract -H\n; or\n;  SMILExtract -H configTypeName (= componentTypeName)\n/////////////////////////////////////////////////////////////////////////////////////////////\n\n[waveIn:cWaveSource]\n ; this sets the level this component writes to\n ; the level will be created by this component\n ; no other components may write to a level having the same name\nwriter.dmLevel=wave\n ; this defines a new commandline option \"-I\" or \"-inputfile\", which can be used to specify \n ; the filename on the commandline instead of having it \"hard-coded\" in the config file\nfilename=\\cm[inputfile(I){test.wav}:name of input file]\n ; mix stereo files down to mono for analysis\nmonoMixdown = 1\nproperTimestamps = 1\nstart = 0.0\nend = -1\n\n[fr40:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames40\nframeSize = 0.040\nframeStep = 0.010\nframeMode = fixed\nframeCenterSpecial = center\n\n[w40:cWindower]\nreader.dmLevel=frames40\nwriter.dmLevel=win40frame\ncopyInputName = 1\nprocessArrayFields = 1\nwinFunc = ham\ngain = 1.0\noffset = 0\n\n[fft40:cTransformFFT]\nreader.dmLevel=win40frame\nwriter.dmLevel=fftc40\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmagphase40:cFFTmagphase]\nreader.dmLevel=fftc40\nwriter.dmLevel=fftmag40\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\nmagnitude = 1\nphase = 0\n\n[acf40:cAcf]\nreader.dmLevel=fftmag40\nwriter.dmLevel=acf40\nnameAppend = acf\ncopyInputName = 1\nprocessArrayFields = 1\nusePower = 1\ncepstrum = 0\nacfCepsNormOutput = 0\n\n[cepstrum40:cAcf]\nreader.dmLevel=fftmag40\nwriter.dmLevel=cepstrum40\nnameAppend = acf\ncopyInputName = 1\nprocessArrayFields = 1\nusePower = 1\ncepstrum = 1\nacfCepsNormOutput = 0\noldCompatCepstrum = 1\nabsCepstrum = 1\n\n[pitchACF:cPitchACF]\n  ; the pitchACF component must ALWAYS read from acf AND cepstrum in the given order!\nreader.dmLevel=acf40;cepstrum40\nwriter.dmLevel=pitch\nprocessArrayFields=0\nmaxPitch = 500\nvoiceProb = 1\nvoiceQual = 0\nHNR = 0\nF0 = 1\nF0raw = 0\nF0env = 1\nvoicingCutoff = 0.550000\n\n[fr25:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames\nframeSize = 0.025\nframeStep = 0.010\nframeMode = fixed\nframeCenterSpecial = center\n\n\n[pe:cVectorPreemphasis]\nreader.dmLevel=frames\nwriter.dmLevel=framespe\ncopyInputName = 1\nprocessArrayFields = 1\nk=0.97\n\n[win:cWindower]\nreader.dmLevel=framespe\nwriter.dmLevel=winframe\ncopyInputName = 1\nprocessArrayFields = 1\nwinFunc = ham\ngain = 1.0\noffset = 0\n\n[fft:cTransformFFT]\nreader.dmLevel=winframe\nwriter.dmLevel=fftc\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmagphase:cFFTmagphase]\nreader.dmLevel=fftc\nwriter.dmLevel=fftmag\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\nmagnitude = 1\nphase = 0\n\n[mspec:cMelspec]\nreader.dmLevel=fftmag\nwriter.dmLevel=mspec1\ncopyInputName = 1\nprocessArrayFields = 1\nhtkcompatible = 1\nnBands = 26\nlofreq = 0\nhifreq = 8000\nusePower = 1\ninverse = 0\nspecScale = mel\n\n[mfcc:cMfcc]\nreader.dmLevel=mspec1\nwriter.dmLevel=mfcc1\ncopyInputName = 0\nprocessArrayFields = 1\nfirstMfcc = 1\nlastMfcc =  12\ncepLifter = 22.0\nhtkcompatible = 1\n\n[lpc:cLpc]\nreader.dmLevel=framespe\nwriter.dmLevel=lpc\ncopyInputName = 1\nprocessArrayFields = 1\nmethod = acf\np = 8\nsaveLPCoeff = 1\nlpGain = 0\nsaveRefCoeff = 0\nresidual = 0\nforwardFilter = 0\nlpSpectrum = 0\n\n[lsp:cLsp]\nreader.dmLevel=lpc\nwriter.dmLevel=lsp\ncopyInputName = 1\nprocessArrayFields = 0\n\n[intens:cIntensity]\nreader.dmLevel=frames\nwriter.dmLevel=intens\ncopyInputName = 1\nprocessArrayFields = 1\nintensity=1\nloudness =1\n\n[mzcr:cMZcr]\nreader.dmLevel=frames\nwriter.dmLevel=mzcr\ncopyInputName = 1\nprocessArrayFields = 1\nzcr = 1\namax = 0\nmcr = 0\nmaxmin = 0\ndc = 0\n\n[lld:cContourSmoother]\nreader.dmLevel=intens;mfcc1;lsp;mzcr;pitch\nwriter.dmLevel=lld\nwriter.levelconf.nT = 2500\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n\n// ---- delta regression of LLD ----\n[delta1:cDeltaRegression]\nreader.dmLevel=lld\nwriter.dmLevel=lld_de\nblocksize=1\nwriter.levelconf.nT = 2500\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = de\ncopyInputName = 1\nnoPostEOIprocessing = 0\ndeltawin=2\n\n\n// statistical functionals\n[functL1:cFunctionals]\nreader.dmLevel=lld;lld_de\nwriter.dmLevel=func\ncopyInputName = 1\n ; frameMode = var will enable the functionals component to listen for messages from the turn detector\nframeMode = full\nfunctionalsEnabled=Extremes;Regression;Moments;Percentiles\nExtremes.max = 1\nExtremes.min = 1\nExtremes.range = 1\nExtremes.maxpos = 1\nExtremes.minpos = 1\nExtremes.amean = 1\nExtremes.maxameandist = 0\nExtremes.minameandist = 0\n ; Note: the much better way to normalise the times of maxpos and minpos\n ; is 'turn', however for compatibility with old files the default 'frame' \n ; is kept here:\nExtremes.norm = frame\nRegression.linregc1 = 1\nRegression.linregc2 = 1\nRegression.linregerrA = 1\nRegression.linregerrQ = 1\nRegression.qregc1 = 0\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 0\nRegression.qregerrQ = 0\nRegression.centroid = 0\nRegression.doRatioLimit = 0\nRegression.centroidRatioLimit = 0\n\nMoments.doRatioLimit = 0\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\n\n  //////////////////////////////////////////////////////////////////////\n ///////////////////  data output configuration  //////////////////////\n//////////////////////////////////////////////////////////////////////\n\n// ----- you can use this to save the features extracted  ------\n[arffsink:cArffSink]\nreader.dmLevel=func\n ; do not print \"frameNumber\" attribute to ARFF file\nnumber=0\n ; name of output file as commandline option\nfilename=\\cm[arffout(O){output.arff}:name of WEKA Arff output file]\n ; name of @relation in the ARFF file\nrelation=\\cm[corpus{SMILEfeaturesLive}:corpus name, arff relation]\n ; base name of the current instance, turn number will be appended\ninstanceBase=liveturn\n ; name of class label\nclass[0].name = emotion\n ; list of nominal classes OR \"numeric\"\nclass[0].type = \\cm[classes{unknown}:all classes for arff file attribute]\n ; the class label or value for the current instance\ntarget[0].all = \\cm[classlabel{unassigned}:instance class label]\n ; ** NOTE: theoretically the classified class label could be assigned here, however this would require \n ; ** saving the class label along with the frame in the dataMemory\n ; ** or sending this meta-data via a message (including frame number)\n ; ** neither solution is currently implemented.... :-(\n ;\nappend=0\n\n//////---------------------- END -------------------------///////\n"
  },
  {
    "path": "config/emobase2010.conf",
    "content": "\n///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for emotion features <      //////////////////\n/////////   Based on INTERSPEECH 2010 paralinguistics challenge      //////////////////\n/////////   Pitch, Loudness, Jitter, MFCC, MFB, LSP and functionals  //////////////////\n/////////                                                            //////////////////\n/////////   1582 1st level functionals:                              //////////////////\n/////////     (34 LLD + 34 delta) * 21 functionals                   //////////////////\n/////////     +(4 LLD + 4 delta) * 19 functionals                    //////////////////\n/////////     + 1 x Num. pitch onsets (pseudo syllables)             //////////////////\n/////////     + 1 x turn duration in seconds                         //////////////////\n/////////                                                            //////////////////\n///////// (c) audEERING UG (haftungsbeschrnkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n//\n// Usage:\n// SMILExtract -C thisconfig.conf -I input.wav -O output.arff \n//\n \n///////////////////////////////////////////////////////////////////////////////////////\n;\n; This section is always required in openSMILE configuration files\n;   it configures the componentManager and gives a list of all components which are to be loaded\n; The order in which the components are listed should match \n;   the order of the data flow for most efficient processing\n;\n///////////////////////////////////////////////////////////////////////////////////////\n[componentInstances:cComponentManager]\n ; this line configures the default data memory:\ninstance[dataMemory].type=cDataMemory\n ;;; wave file input\ninstance[waveIn].type=cWaveSource\n ;;; 40 ms frames features:\ninstance[fr40].type=cFramer\ninstance[w40].type=cWindower\ninstance[fft40].type=cTransformFFT\ninstance[fftmagphase40].type=cFFTmagphase\n ; SHS Pitch:\ninstance[scale].type=cSpecScale\ninstance[pitchShs].type=cPitchShs\ninstance[pitchSmooth].type=cPitchSmoother\ninstance[pitchJitter].type=cPitchJitter\ninstance[pitchSmooth2].type=cPitchSmoother\ninstance[res].type=cSpecResample\n\n ;;; 25 ms frames features:\ninstance[fr25].type=cFramer\ninstance[pe].type=cVectorPreemphasis\ninstance[win].type=cWindower\ninstance[fft].type=cTransformFFT\ninstance[fftmagphase].type=cFFTmagphase\n ; mfcc\ninstance[mspec].type=cMelspec\ninstance[mfcc].type=cMfcc\n ; log mel frequency bands (mfb)\ninstance[mspec2].type=cMelspec\ninstance[vo].type=cVectorOperation\ninstance[lpc].type=cLpc\n ; Line Spectral Frequencies\ninstance[lsp].type=cLsp\n ; Loudness (narrow-band approximation)\ninstance[intens].type=cIntensity\n ;;; all LLD concattenated and smoothed using a moving average filter\ninstance[lld].type=cContourSmoother\ninstance[lld2].type=cContourSmoother\n ; delta coefficients of LLD\ninstance[delta1].type=cDeltaRegression\ninstance[delta2].type=cDeltaRegression\n ;;; functionals over FULL input (e.g. turns)\ninstance[functL1].type=cFunctionals\ninstance[functL1nz].type=cFunctionals\ninstance[functOnsets].type=cFunctionals\n ;;; write/append ONE instance to a Weka ARFF file\ninstance[arffsink].type=cArffSink\n\n;; run single threaded (nThreads=1)\n; NOTE: a single thread is more efficient for processing small files, since multi-threaded processing involves more \n;       overhead during startup, which will make the system slower in the end\nnThreads=1\n;; do not show any internal dataMemory level settings \n; (if you want to see them set the value to 1, 2, 3, or 4, depending on the amount of detail you wish)\nprintLevelStats=0\n\n\n\n/////////////////////////////////////////////////////////////////////////////////////////////\n/////////////////////////   component configuration  ////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////////////////////\n; the following sections configure the components listed above\n; a help on configuration parameters can be obtained with \n;  SMILExtract -H\n; or\n;  SMILExtract -H configTypeName (= componentTypeName)\n/////////////////////////////////////////////////////////////////////////////////////////////\n\n[waveIn:cWaveSource]\n ; this sets the level this component writes to\n ; the level will be created by this component\n ; no other components may write to a level having the same name\nwriter.dmLevel=wave\n ; this defines a new commandline option \"-I\" or \"-inputfile\", which can be used to specify \n ; the filename on the commandline instead of having it \"hard-coded\" in the config file\nfilename=\\cm[inputfile(I){test.wav}:name of input file]\n ; mix stereo files down to mono for analysis\nmonoMixdown=1\n\n[fr40:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames40\nframeSize = 0.060\nframeStep = 0.010\nframeCenterSpecial = left\n\n[w40:cWindower]\nreader.dmLevel=frames40\nwriter.dmLevel=win40frame\nwinFunc = gauss\nsigma=0.25\ngain = 1.0\n\n\n[fft40:cTransformFFT]\nreader.dmLevel=win40frame\nwriter.dmLevel=fftc40\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmagphase40:cFFTmagphase]\nreader.dmLevel=fftc40\nwriter.dmLevel=fftmag40\n\n\n[scale:cSpecScale]\nreader.dmLevel=fftmag40\nwriter.dmLevel=hps\nscale=log\n ; octave scale\nlogScaleBase=2\n\n[pitchShs:cPitchShs]\nreader.dmLevel=hps\nwriter.dmLevel=pitchShs\nF0raw = 0\nvoicingClip = 0\nvoicingC1=0\nscores=1\nvoicing=1\nnCandidates=3\noctaveCorrection=0\n\n[pitchSmooth:cPitchSmoother]\nreader.dmLevel=pitchShs\nwriter.dmLevel=pitch\nF0raw = 0\nF0final = 0\nF0finalEnv = 1\nvoicingFinalUnclipped = 1\nmedianFilter0 = 0\npostSmoothingMethod = simple\n;simple\noctaveCorrection = 0\nwriter.levelconf.nT=10\n;writer.levelconf.noHang=2\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n[pitchSmooth2:cPitchSmoother]\nreader.dmLevel=pitchShs\nwriter.dmLevel=pitchF\nF0raw = 0\nF0final = 1\nF0finalEnv = 0\nvoicingFinalUnclipped = 0\nmedianFilter0 = 0\npostSmoothingMethod = simple\noctaveCorrection = 0\nwriter.levelconf.nT=10\n;writer.levelconf.noHang=2\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n ;;;; default (template) configuration section for component 'cPitchJitter' ;;;;\n[pitchJitter:cPitchJitter]\nreader.dmLevel = wave\nwriter.dmLevel = jitter\n// nameAppend =\ncopyInputName = 1\nF0reader.dmLevel = pitchF\nF0field = F0final\nsearchRangeRel = 0.250000\njitterLocal = 1\njitterDDP = 1\njitterLocalEnv = 0\njitterDDPEnv = 0\nshimmerLocal = 1\nshimmerLocalEnv = 0\nonlyVoiced = 0\n;periodLengths = 0\n;periodStarts = 0\n\n\n[fr25:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames\nframeSize = 0.025\nframeStep = 0.010\nframeCenterSpecial = left\n\n[pe:cVectorPreemphasis]\nreader.dmLevel=frames\nwriter.dmLevel=framespe\nk=0.97\n\n[win:cWindower]\nreader.dmLevel=framespe\nwriter.dmLevel=winframe\nwinFunc = ham\ngain = 1.0\n\n[fft:cTransformFFT]\nreader.dmLevel=winframe\nwriter.dmLevel=fftc\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmagphase:cFFTmagphase]\nreader.dmLevel=fftc\nwriter.dmLevel=fftmag\n\n[mspec:cMelspec]\nreader.dmLevel=fftmag\nwriter.dmLevel=mspec1\nhtkcompatible = 0\nusePower = 1\nlofreq = 20\nhifreq = 8000\nnBands=26\n\n[mfcc:cMfcc]\nreader.dmLevel = mspec1\nwriter.dmLevel = mfcc\nhtkcompatible = 0\nfirstMfcc=0\nlastMfcc=14\ncepLifter=22\n\n[mspec2:cMelspec]\nreader.dmLevel=fftmag\nwriter.dmLevel=mspec2\nhtkcompatible = 0\nusePower = 1\nlofreq = 20\nhifreq = 6500\nnBands=8\n\n[vo:cVectorOperation]\nreader.dmLevel=mspec2\nwriter.dmLevel=mspec2log\noperation = log\ncopyInputName = 0\nnameAppend=logMelFreqBand\n\n[res:cSpecResample]\nreader.dmLevel=fftc\nwriter.dmLevel=outpR\ntargetFs = 11000\n\n[lpc:cLpc]\n;reader.dmLevel=framespe\nreader.dmLevel=outpR\nwriter.dmLevel=lpc\np=8\nmethod = acf\nsaveLPCoeff = 1\nlpGain = 0\nsaveRefCoeff = 0\nresidual = 0\nforwardFilter = 0\nlpSpectrum = 0\n\n[lsp:cLsp]\nreader.dmLevel=lpc\nwriter.dmLevel=lsp\n\n[intens:cIntensity]\nreader.dmLevel=frames\nwriter.dmLevel=intens\nintensity=0\nloudness=1\n\n[mzcr:cMZcr]\nreader.dmLevel=frames\nwriter.dmLevel=mzcr\nzcr=1\namax=0\nmcr=0\nmaxmin=0\ndc=0\n\n[lld:cContourSmoother]\nreader.dmLevel=intens;mfcc;mspec2log;lsp;pitch\nwriter.dmLevel=lld\nbuffersize=1000\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nsmaWin = 3\n; this level must grow to hold ALL the LLD of the full input\n\n// ---- delta regression of LLD ----\n[delta1:cDeltaRegression]\nreader.dmLevel=lld\nwriter.dmLevel=lld_de\nbuffersize=1000\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\ndeltawin=2\nblocksize=1\n\n[lld2:cContourSmoother]\nreader.dmLevel=pitchF;jitter\nwriter.dmLevel=lld2\nbuffersize=1000\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n; this level must grow to hold ALL the LLD of the full input\n\n// ---- delta regression of LLD ----\n[delta2:cDeltaRegression]\nreader.dmLevel=lld2\nwriter.dmLevel=lld2_de\nbuffersize=1000\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\ndeltawin=2\nblocksize=1\n\n[functOnsets:cFunctionals]\nreader.dmLevel=pitchF\nwriter.dmLevel=functOnsets\n ; frameSize and frameStep = 0 => functionals over complete input\n ; (NOTE: buffersize of lld and lld_de levels must be large enough!!)\nframeMode = full\n//frameSize = 0\n//frameStep = 0\ncopyInputName=0\nfunctNameAppend=Turn\nfunctionalsEnabled=Onset;Times\n//noPostEOIprocessing = 0\nOnset.threshold = 0\n;Onset.thresholdOnset = 0\n;Onset.thresholdOffset = 0\nOnset.useAbsVal = 0\nOnset.onsetPos = 0\nOnset.offsetPos = 0\nOnset.numOnsets = 1\nOnset.numOffsets = 0\nTimes.upleveltime25 = 0\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 0\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 0\nTimes.downleveltime90 = 0\nTimes.risetime = 0\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 1\nTimes.norm = second\n\n\n// statistical functionals\n[functL1:cFunctionals]\nreader.dmLevel=lld;lld_de\nwriter.dmLevel=func\n ; frameSize and frameStep = 0 => functionals over complete input\n ; (NOTE: buffersize of lld and lld_de levels must be large enough!!)\nframeMode = full\nframeSize=0\nframeStep=0\nfunctionalsEnabled=Extremes;Regression;Moments;Percentiles;Times\nExtremes.max = 0\nExtremes.min = 0\nExtremes.range = 0\nExtremes.maxpos = 1\nExtremes.minpos = 1\nExtremes.amean = 1\nExtremes.maxameandist=0\nExtremes.minameandist=0\nExtremes.norm=segment\nRegression.linregc1 = 1\nRegression.linregc2 = 1\nRegression.linregerrA = 1\nRegression.linregerrQ = 1\nRegression.qregc1 = 0\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 0\nRegression.qregerrQ = 0\nRegression.centroid = 0\nRegression.doRatioLimit = 0\nRegression.centroidRatioLimit = 0\nMoments.doRatioLimit = 0\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nPercentiles.quartiles = 1\nPercentiles.quartile1 = 0\nPercentiles.quartile2 = 0\nPercentiles.quartile3 = 0\nPercentiles.iqr = 1\nPercentiles.iqr12 = 0\nPercentiles.iqr23 = 0\nPercentiles.iqr13 = 0\nPercentiles.interp = 1\nPercentiles.percentile = 0.01;0.99\nPercentiles.pctlrange=0-1\nTimes.upleveltime25 = 0\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 0\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 1\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 0\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.norm = turn\n\n// statistical functionals\n[functL1nz:cFunctionals]\nreader.dmLevel=lld2;lld2_de\nwriter.dmLevel=funcNz\n ; frameSize and frameStep = 0 => functionals over complete input\n ; (NOTE: buffersize of lld and lld_de levels must be large enough!!)\nframeSize=0\nframeStep=0\nfunctionalsEnabled=Extremes;Regression;Moments;Percentiles;Times\nExtremes.max = 0\nExtremes.min = 0\nExtremes.range = 0\nExtremes.maxpos = 1\nExtremes.minpos = 1\nExtremes.amean = 1\nExtremes.maxameandist=0\nExtremes.minameandist=0\nExtremes.norm = segment\nRegression.linregc1 = 1\nRegression.linregc2 = 1\nRegression.linregerrA = 1\nRegression.linregerrQ = 1\nRegression.qregc1 = 0\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 0\nRegression.qregerrQ = 0\nRegression.centroid = 0\nRegression.doRatioLimit = 0\nRegression.centroidRatioLimit = 0\nMoments.doRatioLimit = 0\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nPercentiles.quartiles = 1\nPercentiles.quartile1 = 0\nPercentiles.quartile2 = 0\nPercentiles.quartile3 = 0\nPercentiles.iqr = 1\nPercentiles.iqr12 = 0\nPercentiles.iqr23 = 0\nPercentiles.iqr13 = 0\nPercentiles.interp = 1\nPercentiles.percentile = 0.99\n;Percentiles.pctlrange=0-1\nTimes.upleveltime25 = 0\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 0\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 1\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 0\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.norm = segment\nnonZeroFuncts=1\n\n  //////////////////////////////////////////////////////////////////////\n ///////////////////  data output configuration  //////////////////////\n//////////////////////////////////////////////////////////////////////\n\n// ----- you might need to customise the arff output to suit your needs: ------\n\n[arffsink:cArffSink]\nreader.dmLevel=func;funcNz;functOnsets\n ; do not print \"frameNumber\" attribute to ARFF file\nframeIndex=0\nframeTime=0\n ; name of output file as commandline option\nfilename=\\cm[arffout(O){output.arff}:name of WEKA Arff output file]\n ; name of @relation in the ARFF file\nrelation=\\cm[corpus{SMILEfeatures}:corpus name, arff relation]\n ; name of the current instance (usually file name of input wave file)\ninstanceName=\\cm[instname(N){noname}:name of arff instance]\n\n ; this includes the file 'arff_targets.conf' which configures\n ; the target classes (ground truths) which are added to the ARFF file\n ; based on command-line options\n\\{arff_targets.conf}\n\n ; append to an existing file, so multiple calls of SMILExtract on different\n ; input files append to the same output ARFF file\nappend=1\n\n\n//////---------------------- END -------------------------///////\n"
  },
  {
    "path": "config/emobase_live4.conf",
    "content": "\n///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for live emotion recognition < ///////////////\n/////////   base set of 988 features, 1st level functionals          //////////////////\n/////////   of low-level descriptors such as MFCC, Pitch, LSP, ...   //////////////////\n/////////                                                            //////////////////\n/////////  * written 2009 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) 2014 audEERING UG (haftungsbeschrnkt),                //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n///////////////////////////////////////////////////////////////////////////////////////\n;\n; This section is always required in openSMILE configuration files\n;   it configures the componentManager and gives a list of all components which are to be loaded\n; The order in which the components are listed should match \n;   the order of the data flow for most efficient processing\n;\n///////////////////////////////////////////////////////////////////////////////////////\n[componentInstances:cComponentManager]\n ;this line configures the default data memory:\ninstance[dataMemory].type=cDataMemory\n ;;; PortAudio live sound card input\ninstance[waveIn].type=cPortaudioSource\ninstance[fr25].type=cFramer\n ;; VAD (energy-based)\ninstance[energy].type=cEnergy\ninstance[turn].type=cTurnDetector\n ;;; 40 ms frames features:\ninstance[fr40].type=cFramer\ninstance[w40].type=cWindower\ninstance[fft40].type=cTransformFFT\ninstance[fftmagphase40].type=cFFTmagphase\ninstance[acf40].type=cAcf\ninstance[cepstrum40].type=cAcf\n ; Pitch...\ninstance[pitchACF].type=cPitchACF\n ;;; 25 ms frames features:\ninstance[pe].type=cVectorPreemphasis\ninstance[win].type=cWindower\ninstance[fft].type=cTransformFFT\ninstance[fftmagphase].type=cFFTmagphase\ninstance[mspec].type=cMelspec\n ; MFCC\ninstance[mfcc].type=cMfcc\ninstance[lpc].type=cLpc\n ; Line Spectral Frequencies\ninstance[lsp].type=cLsp\n ; Zero-Crossings\ninstance[mzcr].type=cMZcr\n ; Intensity and Loudness (narrow-band approximation)\ninstance[intens].type=cIntensity\n ;;; all LLD concattenated and smoothed using a moving average filter\ninstance[lld].type=cContourSmoother\n ; delta coefficients of LLD\ninstance[delta1].type=cDeltaRegression\n ;;; functionals over FULL input (e.g. turns)\ninstance[functL1].type=cFunctionals\n ;;; write instances to a Weka ARFF file (comment out to disable)\ninstance[arffsink].type=cArffSink\n ;;; save recorded and segmented turn to a wave file (remove comment to enable)\n;instance[turnDump].type=cWaveSinkCut\n ;;; live classification of emotion (comment out lines to disable them):\ninstance[arousal].type=cLibsvmLiveSink\ninstance[valence].type=cLibsvmLiveSink\ninstance[emodbEmotion].type=cLibsvmLiveSink\ninstance[abcAffect].type=cLibsvmLiveSink\ninstance[avicInterest].type=cLibsvmLiveSink\n\n;; run single threaded (nThreads=1)\n; NOTE: a single thread is more efficient for processing small files, since multi-threaded processing involves more \n;       overhead during startup, which will make the system slower in the end\nnThreads=1\n;; do not show any internal dataMemory level settings \n; (if you want to see them set the value to 1, 2, 3, or 4, depending on the amount of detail you wish)\nprintLevelStats=0\n\n\n/////////////////////////////////////////////////////////////////////////////////////////////\n/////////////////////////   component configuration  ////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////////////////////\n; the following sections configure the components listed above\n; a help on configuration parameters can be obtained with \n;  SMILExtract -H\n; or\n;  SMILExtract -H configTypeName (= componentTypeName)\n/////////////////////////////////////////////////////////////////////////////////////////////\n\n[waveIn:cPortaudioSource]\n ; this sets the level this component writes to\n ; the level will be created by this component\n ; no other components may write to a level having the same name\nwriter.dmLevel=wave\n ; this sets the portaudio recording device, leave commented out to use the default device\ndevice = \\cm[device{-1}:portaudio device number to record from]\n ; uncomment the following line to obtain a list of available devices when you call\n ;   SMILExtract -C config/emobase_live4.conf\n ; after displaying the device list, SMILExtract will exit. \n ; Thus, for normal operation you have to comment the line out again\nlistDevices=\\cm[listdevices{0}:list devices]\n ; record in mono\nchannels = 1\n ; we want to record audio in 16kHz from the audio device\n ; Note that some audio devices do not support this sample rate,\n ; if this is the case, try a different device, or use a resampling component\n ; (which is not yet integrated in a working version...)\nsampleRate = 16000\n ; size of chunks returned by PortAudio (the latency is >= this value)\naudioBuffersize_sec = 0.16\n ; the buffersize of the pcm data ringbuffer (don't make this too small, or you might loose data, \n ;  if your system load is low to normal, this size also does not affect the latency. \n ;  Only during high load this buffersize is an upper limit for the latency.)\nbuffersize_sec=2.0\n\n[fr40:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames40\nframeSize = 0.040\nframeStep = 0.010\nframeMode = fixed\nframeCenterSpecial = center\n\n[w40:cWindower]\nreader.dmLevel=frames40\nwriter.dmLevel=win40frame\ncopyInputName = 1\nprocessArrayFields = 1\nwinFunc = ham\ngain = 1.0\noffset = 0\n\n[fft40:cTransformFFT]\nreader.dmLevel=win40frame\nwriter.dmLevel=fftc40\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmagphase40:cFFTmagphase]\nreader.dmLevel=fftc40\nwriter.dmLevel=fftmag40\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\nmagnitude = 1\nphase = 0\n\n[acf40:cAcf]\nreader.dmLevel=fftmag40\nwriter.dmLevel=acf40\nnameAppend = acf\ncopyInputName = 1\nprocessArrayFields = 1\nusePower = 1\ncepstrum = 0\nacfCepsNormOutput = 0\n\n[cepstrum40:cAcf]\nreader.dmLevel=fftmag40\nwriter.dmLevel=cepstrum40\nnameAppend = acf\ncopyInputName = 1\nprocessArrayFields = 1\nusePower = 1\ncepstrum = 1\nacfCepsNormOutput = 0\noldCompatCepstrum = 1\nabsCepstrum = 1\n\n[pitchACF:cPitchACF]\n  ; the pitchACF component must ALWAYS read from acf AND cepstrum in the given order!\nreader.dmLevel=acf40;cepstrum40\nwriter.dmLevel=pitch\nprocessArrayFields=0\nmaxPitch = 500\nvoiceProb = 1\nvoiceQual = 0\nHNR = 0\nF0 = 1\nF0raw = 0\nF0env = 1\nvoicingCutoff = 0.550000\n\n[fr25:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames\nframeSize = 0.025\nframeStep = 0.010\nframeMode = fixed\nframeCenterSpecial = center\n\n\n[pe:cVectorPreemphasis]\nreader.dmLevel=frames\nwriter.dmLevel=framespe\ncopyInputName = 1\nprocessArrayFields = 1\nk=0.97\n\n[win:cWindower]\nreader.dmLevel=framespe\nwriter.dmLevel=winframe\ncopyInputName = 1\nprocessArrayFields = 1\nwinFunc = ham\ngain = 1.0\noffset = 0\n\n[fft:cTransformFFT]\nreader.dmLevel=winframe\nwriter.dmLevel=fftc\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmagphase:cFFTmagphase]\nreader.dmLevel=fftc\nwriter.dmLevel=fftmag\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\nmagnitude = 1\nphase = 0\n\n[mspec:cMelspec]\nreader.dmLevel=fftmag\nwriter.dmLevel=mspec1\ncopyInputName = 1\nprocessArrayFields = 1\nhtkcompatible = 1\nnBands = 26\nlofreq = 0\nhifreq = 8000\nusePower = 1\ninverse = 0\nspecScale = mel\n\n[mfcc:cMfcc]\nreader.dmLevel=mspec1\nwriter.dmLevel=mfcc1\ncopyInputName = 0\nprocessArrayFields = 1\nfirstMfcc = 1\nlastMfcc =  12\ncepLifter = 22.0\nhtkcompatible = 1\n\n[lpc:cLpc]\nreader.dmLevel=framespe\nwriter.dmLevel=lpc\ncopyInputName = 1\nprocessArrayFields = 1\nmethod = acf\np = 8\nsaveLPCoeff = 1\nlpGain = 0\nsaveRefCoeff = 0\nresidual = 0\nforwardFilter = 0\nlpSpectrum = 0\n\n[lsp:cLsp]\nreader.dmLevel=lpc\nwriter.dmLevel=lsp\ncopyInputName = 1\nprocessArrayFields = 0\n\n[intens:cIntensity]\nreader.dmLevel=frames\nwriter.dmLevel=intens\ncopyInputName = 1\nprocessArrayFields = 1\nintensity=1\nloudness =1\n\n[mzcr:cMZcr]\nreader.dmLevel=frames\nwriter.dmLevel=mzcr\ncopyInputName = 1\nprocessArrayFields = 1\nzcr = 1\namax = 0\nmcr = 0\nmaxmin = 0\ndc = 0\n\n[lld:cContourSmoother]\nreader.dmLevel=intens;mfcc1;lsp;mzcr;pitch\nwriter.dmLevel=lld\nwriter.levelconf.nT = 2500\nwriter.levelconf.isRb=1\nwriter.levelconf.growDyn=0\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n\n// ---- delta regression of LLD ----\n[delta1:cDeltaRegression]\nreader.dmLevel=lld\nwriter.dmLevel=lld_de\nblocksize=1\nwriter.levelconf.nT = 2500\nwriter.levelconf.isRb=1\nwriter.levelconf.growDyn=0\nnameAppend = de\ncopyInputName = 1\nnoPostEOIprocessing = 0\ndeltawin=2\n\n[energy:cEnergy]\nreader.dmLevel=winframe\nwriter.dmLevel=energy\nrms=1\nlog=0\n\n// the voice activity detection (turn detector)\n[turn:cTurnDetector]\nreader.dmLevel=energy\nwriter.dmLevel=isTurn\n ; overwrite data in output level, if it has not been read and level is full\n ; we must set this here, since the level isTurn is a dead-end in our configuration\nwriter.levelconf.noHang=1\n ; send a message to the functionals component at turn end\nmessageRecp = functL1\n ; send turn start / turn end event messages to the debug turn wave file output component\neventRecp = turnDump\n  ;; you may not increase this over the writer.levelconf.nT value of the lld and lld_de levels!\n  ;; so by default not more than 24!\nmaxTurnLength = 12\nmaxTurnLengthGrace = 3\nidx = 0\nnPost = 30\nnPre = 10\nuseRMS = 1\n ; disable auto adjustment of VAD threshold, this does not work well yet.\nautoThreshold = 0\n ; instead, set the threshold manually to a default value.\n ; this derived from the RMS energy from normalised sample values (0..1)\n ; --> !!!!! you might need to adjust this value depending on your recording setup !!!!!!! <-------------------\nthreshold = 0.0015\n ; --> !!!!! you might need to adjust this value depending on your recording setup !!!!!!! <-------------------\n\n\n// statistical functionals\n[functL1:cFunctionals]\nreader.dmLevel=lld;lld_de\nwriter.dmLevel=func\ncopyInputName = 1\n ; frameMode = var will enable the functionals component to listen for messages from the turn detector\nframeMode = var\nfunctionalsEnabled=Extremes;Regression;Moments;Percentiles\nExtremes.max = 1\nExtremes.min = 1\nExtremes.range = 1\nExtremes.maxpos = 1\nExtremes.minpos = 1\nExtremes.amean = 1\nExtremes.maxameandist = 0\nExtremes.minameandist = 0\n ; Note: the much better way to normalise the times of maxpos and minpos\n ; is 'turn', however for compatibility with old files the default 'frame' \n ; is kept here:\nExtremes.norm = frame\nRegression.linregc1 = 1\nRegression.linregc2 = 1\nRegression.linregerrA = 1\nRegression.linregerrQ = 1\nRegression.qregc1 = 0\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 0\nRegression.qregerrQ = 0\nRegression.centroid = 0\nRegression.doRatioLimit = 0\nRegression.centroidRatioLimit = 0\nMoments.doRatioLimit = 0\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\n\n  //////////////////////////////////////////////////////////////////////\n ///////////////////  data output configuration  //////////////////////\n//////////////////////////////////////////////////////////////////////\n\n// output recorded and segmented turns as wave files for debugging purposes\n// if you do not want this output, then you can disable this component\n[turnDump:cWaveSinkCut]\nreader.dmLevel = frames\n\n// ----- you can use this to save the features extracted  ------\n[arffsink:cArffSink]\nreader.dmLevel=func\n ; do not print \"frameNumber\" attribute to ARFF file\nnumber=0\n ; name of output file as commandline option\nfilename=\\cm[arffout(O){output.arff}:name of WEKA Arff output file]\n ; name of @relation in the ARFF file\nrelation=\\cm[corpus{SMILEfeaturesLive}:corpus name, arff relation]\n ; base name of the current instance, turn number will be appended\ninstanceBase=liveturn\n ; name of class label\nclass[0].name = emotion\n ; list of nominal classes OR \"numeric\"\nclass[0].type = \\cm[classes{unknown}:all classes for arff file attribute]\n ; the class label or value for the current instance\ntarget[0].all = \\cm[classlabel{unassigned}:instance class label]\n ; ** NOTE: theoretically the classified class label could be assigned here, however this would require \n ; ** saving the class label along with the frame in the dataMemory\n ; ** or sending this meta-data via a message (including frame number)\n ; ** neither solution is currently implemented.... :-(\n ;\nappend=0\n\n// LibSVM dataSink for live classification of extracted features\n// continuous arousal from QUB-SAL corpus\n[arousal:cLibsvmLiveSink]\nreader.dmLevel=func\n; model file to use\nmodel=models/emo/sal_aro.emobase.model\n; scale file to use\nscale=models/emo/sal_aro.emobase.scale\n;; you could use the following line to send the classification result to a custom component\n ;resultRecp=emmaSender\n ;resultMessageName=arousal\n;; print result to console window\nprintResult=1\nforceScale = 0\n\n// LibSVM dataSink for live classification of extracted features\n// continuous valence from QUB-SAL corpus\n[valence:cLibsvmLiveSink]\nreader.dmLevel=func\n; model file to use\nmodel=models/emo/sal_val.emobase.model\n; scale file to use\nscale=models/emo/sal_val.emobase.scale\n;; you could use the following line to send the classification result to a custom component\n ;resultRecp=emmaSender\n ;resultMessageName=valence\n;; print result to console window\nprintResult=1\nforceScale = 0\n\n// LibSVM dataSink for live classification of extracted features\n// Emotion from Berlin Speech Emotion Database (EMO-DB) \n[emodbEmotion:cLibsvmLiveSink]\nreader.dmLevel=func\n; model file to use\nmodel=models/emo/emodb.emobase.model\n; scale file to use\nscale=models/emo/emodb.emobase.scale\n; class names:\nclasses=models/emo/emodb.emobase.classes\n;; you could use the following line to send the classification result to a custom component\n ;resultRecp=emmaSender\n ;resultMessageName=arousal\n;; print result to console window\nprintResult=1\n ; also display per-class probabilities (of SVM models)\npredictProbability=1\nforceScale = 0\n\n// LibSVM dataSink for live classification of extracted features\n// Affective state from TUM Airplane Behaviour Corpus (ABC)\n[abcAffect:cLibsvmLiveSink]\nreader.dmLevel=func\n; model file to use\nmodel=models/emo/abc.emobase.model\n; scale file to use\nscale=models/emo/abc.emobase.scale\n; class names:\nclasses=models/emo/abc.emobase.classes\n;; you could use the following line to send the classification result to a custom component\n ;resultRecp=emmaSender\n ;resultMessageName=arousal\n;; print result to console window\nprintResult=1\n ; also display per-class probabilities (of SVM models)\npredictProbability=1\nforceScale = 0\n\n// LibSVM dataSink for live classification of extracted features\n// Interest level from TUM Audiovisual Interest Corpus (AVIC)\n[avicInterest:cLibsvmLiveSink]\nreader.dmLevel=func\n; model file to use\nmodel=models/emo/avic.emobase.model\n; scale file to use\nscale=models/emo/avic.emobase.scale\n; class names:\nclasses=models/emo/avic.emobase.classes\n;; you could use the following line to send the classification result to a custom component\n ;resultRecp=emmaSender\n ;resultMessageName=arousal\n;; print result to console window\nprintResult=1\n ; also display per-class probabilities (of SVM models)\npredictProbability=1\nforceScale = 0\n\n\n//////---------------------- END -------------------------///////\n"
  },
  {
    "path": "config/emobase_live4_batch.conf",
    "content": "\n///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for live emotion recognition < ///////////////\n/////////   base set of 988 features, 1st level functionals          //////////////////\n/////////   of low-level descriptors such as MFCC, Pitch, LSP, ...   //////////////////\n/////////                                                            //////////////////\n/////////  * written 2009 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) 2014 audEERING UG (haftungsbeschrnkt),                //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n//  Modified version:\n//   - compatibility of newest 2.1 openSMILE code with openEAR 0.1.0 models\n//   - for batch processing, including speech activity detector for automatic sub-segmentation\n//     (see '*_batch_single.conf' for a version without this detector)\n\n\n///////////////////////////////////////////////////////////////////////////////////////\n;\n; This section is always required in openSMILE configuration files\n;   it configures the componentManager and gives a list of all components which are to be loaded\n; The order in which the components are listed should match \n;   the order of the data flow for most efficient processing\n;\n///////////////////////////////////////////////////////////////////////////////////////\n[componentInstances:cComponentManager]\n ;this line configures the default data memory:\ninstance[dataMemory].type=cDataMemory\ninstance[waveIn].type=cWaveSource\ninstance[fr25].type=cFramer\n ;; VAD (energy-based)\ninstance[energy].type=cEnergy\ninstance[turn].type=cTurnDetector\n ;;; 40 ms frames features:\ninstance[fr40].type=cFramer\ninstance[w40].type=cWindower\ninstance[fft40].type=cTransformFFT\ninstance[fftmagphase40].type=cFFTmagphase\ninstance[acf40].type=cAcf\ninstance[cepstrum40].type=cAcf\n ; Pitch...\ninstance[pitchACF].type=cPitchACF\n ;;; 25 ms frames features:\ninstance[pe].type=cVectorPreemphasis\ninstance[win].type=cWindower\ninstance[fft].type=cTransformFFT\ninstance[fftmagphase].type=cFFTmagphase\ninstance[mspec].type=cMelspec\n ; MFCC\ninstance[mfcc].type=cMfcc\ninstance[lpc].type=cLpc\n ; Line Spectral Frequencies\ninstance[lsp].type=cLsp\n ; Zero-Crossings\ninstance[mzcr].type=cMZcr\n ; Intensity and Loudness (narrow-band approximation)\ninstance[intens].type=cIntensity\n ;;; all LLD concattenated and smoothed using a moving average filter\ninstance[lld].type=cContourSmoother\n ; delta coefficients of LLD\ninstance[delta1].type=cDeltaRegression\n ;;; functionals over FULL input (e.g. turns)\ninstance[functL1].type=cFunctionals\n ;;; write instances to a Weka ARFF file (comment out to disable)\ninstance[arffsink].type=cArffSink\n ;;; save recorded and segmented turn to a wave file (remove comment to enable)\n;instance[turnDump].type=cWaveSinkCut\n ;;; live classification of emotion (comment out lines to disable them):\ninstance[arousal].type=cLibsvmLiveSink\ninstance[valence].type=cLibsvmLiveSink\ninstance[emodbEmotion].type=cLibsvmLiveSink\ninstance[abcAffect].type=cLibsvmLiveSink\ninstance[avicInterest].type=cLibsvmLiveSink\n\n;; run single threaded (nThreads=1)\n; NOTE: a single thread is more efficient for processing small files, since multi-threaded processing involves more \n;       overhead during startup, which will make the system slower in the end\nnThreads=1\n;; do not show any internal dataMemory level settings \n; (if you want to see them set the value to 1, 2, 3, or 4, depending on the amount of detail you wish)\nprintLevelStats=0\n\n\n/////////////////////////////////////////////////////////////////////////////////////////////\n/////////////////////////   component configuration  ////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////////////////////\n; the following sections configure the components listed above\n; a help on configuration parameters can be obtained with \n;  SMILExtract -H\n; or\n;  SMILExtract -H configTypeName (= componentTypeName)\n/////////////////////////////////////////////////////////////////////////////////////////////\n\n[waveIn:cWaveSource]\n ; this sets the level this component writes to\n ; the level will be created by this component\n ; no other components may write to a level having the same name\nwriter.dmLevel=wave\n ; this defines a new commandline option \"-I\" or \"-inputfile\", which can be used to specify \n ; the filename on the commandline instead of having it \"hard-coded\" in the config file\nfilename=\\cm[inputfile(I){test.wav}:name of input file]\n ; mix stereo files down to mono for analysis\nmonoMixdown = 1\nproperTimestamps = 1\n\n[fr40:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames40\nframeSize = 0.040\nframeStep = 0.010\nframeMode = fixed\nframeCenterSpecial = center\n\n[w40:cWindower]\nreader.dmLevel=frames40\nwriter.dmLevel=win40frame\ncopyInputName = 1\nprocessArrayFields = 1\nwinFunc = ham\ngain = 1.0\noffset = 0\n\n[fft40:cTransformFFT]\nreader.dmLevel=win40frame\nwriter.dmLevel=fftc40\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmagphase40:cFFTmagphase]\nreader.dmLevel=fftc40\nwriter.dmLevel=fftmag40\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\nmagnitude = 1\nphase = 0\n\n[acf40:cAcf]\nreader.dmLevel=fftmag40\nwriter.dmLevel=acf40\nnameAppend = acf\ncopyInputName = 1\nprocessArrayFields = 1\nusePower = 1\ncepstrum = 0\nacfCepsNormOutput = 0\n\n[cepstrum40:cAcf]\nreader.dmLevel=fftmag40\nwriter.dmLevel=cepstrum40\nnameAppend = acf\ncopyInputName = 1\nprocessArrayFields = 1\nusePower = 1\ncepstrum = 1\nacfCepsNormOutput = 0\noldCompatCepstrum = 1\nabsCepstrum = 1\n\n[pitchACF:cPitchACF]\n  ; the pitchACF component must ALWAYS read from acf AND cepstrum in the given order!\nreader.dmLevel=acf40;cepstrum40\nwriter.dmLevel=pitch\nprocessArrayFields=0\nmaxPitch = 500\nvoiceProb = 1\nvoiceQual = 0\nHNR = 0\nF0 = 1\nF0raw = 0\nF0env = 1\nvoicingCutoff = 0.550000\n\n[fr25:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames\nframeSize = 0.025\nframeStep = 0.010\nframeMode = fixed\nframeCenterSpecial = center\n\n\n[pe:cVectorPreemphasis]\nreader.dmLevel=frames\nwriter.dmLevel=framespe\ncopyInputName = 1\nprocessArrayFields = 1\nk=0.97\n\n[win:cWindower]\nreader.dmLevel=framespe\nwriter.dmLevel=winframe\ncopyInputName = 1\nprocessArrayFields = 1\nwinFunc = ham\ngain = 1.0\noffset = 0\n\n[fft:cTransformFFT]\nreader.dmLevel=winframe\nwriter.dmLevel=fftc\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmagphase:cFFTmagphase]\nreader.dmLevel=fftc\nwriter.dmLevel=fftmag\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\nmagnitude = 1\nphase = 0\n\n[mspec:cMelspec]\nreader.dmLevel=fftmag\nwriter.dmLevel=mspec1\ncopyInputName = 1\nprocessArrayFields = 1\nhtkcompatible = 1\nnBands = 26\nlofreq = 0\nhifreq = 8000\nusePower = 1\ninverse = 0\nspecScale = mel\n\n[mfcc:cMfcc]\nreader.dmLevel=mspec1\nwriter.dmLevel=mfcc1\ncopyInputName = 0\nprocessArrayFields = 1\nfirstMfcc = 1\nlastMfcc =  12\ncepLifter = 22.0\nhtkcompatible = 1\n\n[lpc:cLpc]\nreader.dmLevel=framespe\nwriter.dmLevel=lpc\ncopyInputName = 1\nprocessArrayFields = 1\nmethod = acf\np = 8\nsaveLPCoeff = 1\nlpGain = 0\nsaveRefCoeff = 0\nresidual = 0\nforwardFilter = 0\nlpSpectrum = 0\n\n[lsp:cLsp]\nreader.dmLevel=lpc\nwriter.dmLevel=lsp\ncopyInputName = 1\nprocessArrayFields = 0\n\n[intens:cIntensity]\nreader.dmLevel=frames\nwriter.dmLevel=intens\ncopyInputName = 1\nprocessArrayFields = 1\nintensity=1\nloudness =1\n\n[mzcr:cMZcr]\nreader.dmLevel=frames\nwriter.dmLevel=mzcr\ncopyInputName = 1\nprocessArrayFields = 1\nzcr = 1\namax = 0\nmcr = 0\nmaxmin = 0\ndc = 0\n\n[lld:cContourSmoother]\nreader.dmLevel=intens;mfcc1;lsp;mzcr;pitch\nwriter.dmLevel=lld\nwriter.levelconf.nT = 2500\nwriter.levelconf.isRb=1\nwriter.levelconf.growDyn=0\nwriter.levelconf.noHang = 2\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n\n// ---- delta regression of LLD ----\n[delta1:cDeltaRegression]\nreader.dmLevel=lld\nwriter.dmLevel=lld_de\nblocksize=1\nwriter.levelconf.nT = 2500\nwriter.levelconf.isRb=1\nwriter.levelconf.growDyn=0\nwriter.levelconf.noHang = 2\nnameAppend = de\ncopyInputName = 1\nnoPostEOIprocessing = 0\ndeltawin=2\n\n[energy:cEnergy]\nreader.dmLevel=winframe\nwriter.dmLevel=energy\nrms=1\nlog=0\n\n// the voice activity detection (turn detector)\n[turn:cTurnDetector]\nreader.dmLevel=energy\nwriter.dmLevel=isTurn\n ; overwrite data in output level, if it has not been read and level is full\n ; we must set this here, since the level isTurn is a dead-end in our configuration\nwriter.levelconf.noHang=1\n ; send a message to the functionals component at turn end\nmessageRecp = functL1\n ; send turn start / turn end event messages to the debug turn wave file output component\neventRecp = turnDump\n  ;; you may not increase this over the writer.levelconf.nT value of the lld and lld_de levels!\n  ;; so by default not more than 24!\nmaxTurnLength = 12\nmaxTurnLengthGrace = 3\nidx = 0\nnPost = 30\nnPre = 10\nuseRMS = 1\n ; disable auto adjustment of VAD threshold, this does not work well yet.\nautoThreshold = 0\n ; instead, set the threshold manually to a default value.\n ; this derived from the RMS energy from normalised sample values (0..1)\n ; --> !!!!! you might need to adjust this value depending on your recording setup !!!!!!! <-------------------\nthreshold = 0.0015\n ; --> !!!!! you might need to adjust this value depending on your recording setup !!!!!!! <-------------------\n\n\n// statistical functionals\n[functL1:cFunctionals]\nreader.dmLevel=lld;lld_de\nwriter.dmLevel=func\ncopyInputName = 1\n ; frameMode = var will enable the functionals component to listen for messages from the turn detector\nframeMode = var\nfunctionalsEnabled=Extremes;Regression;Moments;Percentiles\nExtremes.max = 1\nExtremes.min = 1\nExtremes.range = 1\nExtremes.maxpos = 1\nExtremes.minpos = 1\nExtremes.amean = 1\nExtremes.maxameandist = 0\nExtremes.minameandist = 0\n ; Note: the much better way to normalise the times of maxpos and minpos\n ; is 'turn', however for compatibility with old files the default 'frame' \n ; is kept here:\nExtremes.norm = frame\nRegression.linregc1 = 1\nRegression.linregc2 = 1\nRegression.linregerrA = 1\nRegression.linregerrQ = 1\nRegression.qregc1 = 0\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 0\nRegression.qregerrQ = 0\nRegression.centroid = 0\nRegression.doRatioLimit = 0\nRegression.centroidRatioLimit = 0\nMoments.doRatioLimit = 0\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\n\n  //////////////////////////////////////////////////////////////////////\n ///////////////////  data output configuration  //////////////////////\n//////////////////////////////////////////////////////////////////////\n\n// output recorded and segmented turns as wave files for debugging purposes\n// if you do not want this output, then you can disable this component\n[turnDump:cWaveSinkCut]\nreader.dmLevel = frames\n\n// ----- you can use this to save the features extracted  ------\n[arffsink:cArffSink]\nreader.dmLevel=func\n ; do not print \"frameNumber\" attribute to ARFF file\nnumber=0\n ; name of output file as commandline option\nfilename=\\cm[arffout(O){output.arff}:name of WEKA Arff output file]\n ; name of @relation in the ARFF file\nrelation=\\cm[corpus{SMILEfeaturesLive}:corpus name, arff relation]\n ; base name of the current instance, turn number will be appended\ninstanceBase=liveturn\n ; name of class label\nclass[0].name = emotion\n ; list of nominal classes OR \"numeric\"\nclass[0].type = \\cm[classes{unknown}:all classes for arff file attribute]\n ; the class label or value for the current instance\ntarget[0].all = \\cm[classlabel{unassigned}:instance class label]\n ; ** NOTE: theoretically the classified class label could be assigned here, however this would require \n ; ** saving the class label along with the frame in the dataMemory\n ; ** or sending this meta-data via a message (including frame number)\n ; ** neither solution is currently implemented.... :-(\n ;\nappend=0\n\n// LibSVM dataSink for live classification of extracted features\n// continuous arousal from QUB-SAL corpus\n[arousal:cLibsvmLiveSink]\nreader.dmLevel=func\n; model file to use\nmodel=models/emo/sal_aro.emobase.model\n; scale file to use\nscale=models/emo/sal_aro.emobase.scale\n;; you could use the following line to send the classification result to a custom component\n ;resultRecp=emmaSender\n ;resultMessageName=arousal\n;; print result to console window\nprintResult=0\nprintParseableResult = 1\nforceScale = 0\n\n// LibSVM dataSink for live classification of extracted features\n// continuous valence from QUB-SAL corpus\n[valence:cLibsvmLiveSink]\nreader.dmLevel=func\n; model file to use\nmodel=models/emo/sal_val.emobase.model\n; scale file to use\nscale=models/emo/sal_val.emobase.scale\n;; you could use the following line to send the classification result to a custom component\n ;resultRecp=emmaSender\n ;resultMessageName=valence\n;; print result to console window\nprintResult=0\nprintParseableResult = 1\nforceScale = 0\n\n// LibSVM dataSink for live classification of extracted features\n// Emotion from Berlin Speech Emotion Database (EMO-DB) \n[emodbEmotion:cLibsvmLiveSink]\nreader.dmLevel=func\n; model file to use\nmodel=models/emo/emodb.emobase.model\n; scale file to use\nscale=models/emo/emodb.emobase.scale\n; class names:\nclasses=models/emo/emodb.emobase.classes\n;; you could use the following line to send the classification result to a custom component\n ;resultRecp=emmaSender\n ;resultMessageName=arousal\n;; print result to console window\nprintResult=0\nprintParseableResult = 1\n ; also display per-class probabilities (of SVM models)\npredictProbability=1\nforceScale = 0\n\n// LibSVM dataSink for live classification of extracted features\n// Affective state from TUM Airplane Behaviour Corpus (ABC)\n[abcAffect:cLibsvmLiveSink]\nreader.dmLevel=func\n; model file to use\nmodel=models/emo/abc.emobase.model\n; scale file to use\nscale=models/emo/abc.emobase.scale\n; class names:\nclasses=models/emo/abc.emobase.classes\n;; you could use the following line to send the classification result to a custom component\n ;resultRecp=emmaSender\n ;resultMessageName=arousal\n;; print result to console window\nprintResult=0\nprintParseableResult = 1\n ; also display per-class probabilities (of SVM models)\npredictProbability=1\nforceScale = 0\n\n// LibSVM dataSink for live classification of extracted features\n// Interest level from TUM Audiovisual Interest Corpus (AVIC)\n[avicInterest:cLibsvmLiveSink]\nreader.dmLevel=func\n; model file to use\nmodel=models/emo/avic.emobase.model\n; scale file to use\nscale=models/emo/avic.emobase.scale\n; class names:\nclasses=models/emo/avic.emobase.classes\n;; you could use the following line to send the classification result to a custom component\n ;resultRecp=emmaSender\n ;resultMessageName=arousal\n;; print result to console window\nprintResult=0\nprintParseableResult = 1\n ; also display per-class probabilities (of SVM models)\npredictProbability=1\nforceScale = 0\n\n\n//////---------------------- END -------------------------///////\n"
  },
  {
    "path": "config/emobase_live4_batch_single.conf",
    "content": "\n///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for live emotion recognition < ///////////////\n/////////   base set of 988 features, 1st level functionals          //////////////////\n/////////   of low-level descriptors such as MFCC, Pitch, LSP, ...   //////////////////\n/////////                                                            //////////////////\n/////////  * written 2009 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) 2014 audEERING UG (haftungsbeschrnkt),                //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n//  Modified version:\n//   - compatibility of newest 2.1 openSMILE code with openEAR 0.1.0 models\n//   - for batch processing, without speech activity detector\n//   - processes the whole input as single segment \n\n\n///////////////////////////////////////////////////////////////////////////////////////\n;\n; This section is always required in openSMILE configuration files\n;   it configures the componentManager and gives a list of all components which are to be loaded\n; The order in which the components are listed should match \n;   the order of the data flow for most efficient processing\n;\n///////////////////////////////////////////////////////////////////////////////////////\n[componentInstances:cComponentManager]\n ;this line configures the default data memory:\ninstance[dataMemory].type=cDataMemory\ninstance[waveIn].type=cWaveSource\ninstance[fr25].type=cFramer\n ;;; 40 ms frames features:\ninstance[fr40].type=cFramer\ninstance[w40].type=cWindower\ninstance[fft40].type=cTransformFFT\ninstance[fftmagphase40].type=cFFTmagphase\ninstance[acf40].type=cAcf\ninstance[cepstrum40].type=cAcf\n ; Pitch...\ninstance[pitchACF].type=cPitchACF\n ;;; 25 ms frames features:\ninstance[pe].type=cVectorPreemphasis\ninstance[win].type=cWindower\ninstance[fft].type=cTransformFFT\ninstance[fftmagphase].type=cFFTmagphase\ninstance[mspec].type=cMelspec\n ; MFCC\ninstance[mfcc].type=cMfcc\ninstance[lpc].type=cLpc\n ; Line Spectral Frequencies\ninstance[lsp].type=cLsp\n ; Zero-Crossings\ninstance[mzcr].type=cMZcr\n ; Intensity and Loudness (narrow-band approximation)\ninstance[intens].type=cIntensity\n ;;; all LLD concattenated and smoothed using a moving average filter\ninstance[lld].type=cContourSmoother\n ; delta coefficients of LLD\ninstance[delta1].type=cDeltaRegression\n ;;; functionals over FULL input (e.g. turns)\ninstance[functL1].type=cFunctionals\n ;;; write instances to a Weka ARFF file (comment out to disable)\ninstance[arffsink].type=cArffSink\n ;;; save recorded and segmented turn to a wave file (remove comment to enable)\n;instance[turnDump].type=cWaveSinkCut\n ;;; live classification of emotion (comment out lines to disable them):\ninstance[arousal].type=cLibsvmLiveSink\ninstance[valence].type=cLibsvmLiveSink\ninstance[emodbEmotion].type=cLibsvmLiveSink\ninstance[abcAffect].type=cLibsvmLiveSink\ninstance[avicInterest].type=cLibsvmLiveSink\n;; run single threaded (nThreads=1)\n; NOTE: a single thread is more efficient for processing small files, since multi-threaded processing involves more \n;       overhead during startup, which will make the system slower in the end\nnThreads=1\n;; do not show any internal dataMemory level settings \n; (if you want to see them set the value to 1, 2, 3, or 4, depending on the amount of detail you wish)\nprintLevelStats=0\n\n/////////////////////////////////////////////////////////////////////////////////////////////\n/////////////////////////   component configuration  ////////////////////////////////////////\n/////////////////////////////////////////////////////////////////////////////////////////////\n; the following sections configure the components listed above\n; a help on configuration parameters can be obtained with \n;  SMILExtract -H\n; or\n;  SMILExtract -H configTypeName (= componentTypeName)\n/////////////////////////////////////////////////////////////////////////////////////////////\n\n[waveIn:cWaveSource]\n ; this sets the level this component writes to\n ; the level will be created by this component\n ; no other components may write to a level having the same name\nwriter.dmLevel=wave\n ; this defines a new commandline option \"-I\" or \"-inputfile\", which can be used to specify \n ; the filename on the commandline instead of having it \"hard-coded\" in the config file\nfilename=\\cm[inputfile(I){test.wav}:name of input file]\n ; mix stereo files down to mono for analysis\nmonoMixdown = 1\nproperTimestamps = 1\nstart = 0.0\nend = -1\n\n[fr40:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames40\nframeSize = 0.040\nframeStep = 0.010\nframeMode = fixed\nframeCenterSpecial = center\n\n[w40:cWindower]\nreader.dmLevel=frames40\nwriter.dmLevel=win40frame\ncopyInputName = 1\nprocessArrayFields = 1\nwinFunc = ham\ngain = 1.0\noffset = 0\n\n[fft40:cTransformFFT]\nreader.dmLevel=win40frame\nwriter.dmLevel=fftc40\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmagphase40:cFFTmagphase]\nreader.dmLevel=fftc40\nwriter.dmLevel=fftmag40\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\nmagnitude = 1\nphase = 0\n\n[acf40:cAcf]\nreader.dmLevel=fftmag40\nwriter.dmLevel=acf40\nnameAppend = acf\ncopyInputName = 1\nprocessArrayFields = 1\nusePower = 1\ncepstrum = 0\nacfCepsNormOutput = 0\n\n[cepstrum40:cAcf]\nreader.dmLevel=fftmag40\nwriter.dmLevel=cepstrum40\nnameAppend = acf\ncopyInputName = 1\nprocessArrayFields = 1\nusePower = 1\ncepstrum = 1\nacfCepsNormOutput = 0\noldCompatCepstrum = 1\nabsCepstrum = 1\n\n[pitchACF:cPitchACF]\n  ; the pitchACF component must ALWAYS read from acf AND cepstrum in the given order!\nreader.dmLevel=acf40;cepstrum40\nwriter.dmLevel=pitch\nprocessArrayFields=0\nmaxPitch = 500\nvoiceProb = 1\nvoiceQual = 0\nHNR = 0\nF0 = 1\nF0raw = 0\nF0env = 1\nvoicingCutoff = 0.550000\n\n[fr25:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames\nframeSize = 0.025\nframeStep = 0.010\nframeMode = fixed\nframeCenterSpecial = center\n\n\n[pe:cVectorPreemphasis]\nreader.dmLevel=frames\nwriter.dmLevel=framespe\ncopyInputName = 1\nprocessArrayFields = 1\nk=0.97\n\n[win:cWindower]\nreader.dmLevel=framespe\nwriter.dmLevel=winframe\ncopyInputName = 1\nprocessArrayFields = 1\nwinFunc = ham\ngain = 1.0\noffset = 0\n\n[fft:cTransformFFT]\nreader.dmLevel=winframe\nwriter.dmLevel=fftc\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmagphase:cFFTmagphase]\nreader.dmLevel=fftc\nwriter.dmLevel=fftmag\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\nmagnitude = 1\nphase = 0\n\n[mspec:cMelspec]\nreader.dmLevel=fftmag\nwriter.dmLevel=mspec1\ncopyInputName = 1\nprocessArrayFields = 1\nhtkcompatible = 1\nnBands = 26\nlofreq = 0\nhifreq = 8000\nusePower = 1\ninverse = 0\nspecScale = mel\n\n[mfcc:cMfcc]\nreader.dmLevel=mspec1\nwriter.dmLevel=mfcc1\ncopyInputName = 0\nprocessArrayFields = 1\nfirstMfcc = 1\nlastMfcc =  12\ncepLifter = 22.0\nhtkcompatible = 1\n\n[lpc:cLpc]\nreader.dmLevel=framespe\nwriter.dmLevel=lpc\ncopyInputName = 1\nprocessArrayFields = 1\nmethod = acf\np = 8\nsaveLPCoeff = 1\nlpGain = 0\nsaveRefCoeff = 0\nresidual = 0\nforwardFilter = 0\nlpSpectrum = 0\n\n[lsp:cLsp]\nreader.dmLevel=lpc\nwriter.dmLevel=lsp\ncopyInputName = 1\nprocessArrayFields = 0\n\n[intens:cIntensity]\nreader.dmLevel=frames\nwriter.dmLevel=intens\ncopyInputName = 1\nprocessArrayFields = 1\nintensity=1\nloudness =1\n\n[mzcr:cMZcr]\nreader.dmLevel=frames\nwriter.dmLevel=mzcr\ncopyInputName = 1\nprocessArrayFields = 1\nzcr = 1\namax = 0\nmcr = 0\nmaxmin = 0\ndc = 0\n\n[lld:cContourSmoother]\nreader.dmLevel=intens;mfcc1;lsp;mzcr;pitch\nwriter.dmLevel=lld\nwriter.levelconf.nT = 2500\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n\n// ---- delta regression of LLD ----\n[delta1:cDeltaRegression]\nreader.dmLevel=lld\nwriter.dmLevel=lld_de\nblocksize=1\nwriter.levelconf.nT = 2500\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = de\ncopyInputName = 1\nnoPostEOIprocessing = 0\ndeltawin=2\n\n\n// statistical functionals\n[functL1:cFunctionals]\nreader.dmLevel=lld;lld_de\nwriter.dmLevel=func\ncopyInputName = 1\n ; frameMode = var will enable the functionals component to listen for messages from the turn detector\nframeMode = full\nfunctionalsEnabled=Extremes;Regression;Moments;Percentiles\nExtremes.max = 1\nExtremes.min = 1\nExtremes.range = 1\nExtremes.maxpos = 1\nExtremes.minpos = 1\nExtremes.amean = 1\nExtremes.maxameandist = 0\nExtremes.minameandist = 0\n ; Note: the much better way to normalise the times of maxpos and minpos\n ; is 'turn', however for compatibility with old files the default 'frame' \n ; is kept here:\nExtremes.norm = frame\nRegression.linregc1 = 1\nRegression.linregc2 = 1\nRegression.linregerrA = 1\nRegression.linregerrQ = 1\nRegression.qregc1 = 0\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 0\nRegression.qregerrQ = 0\nRegression.centroid = 0\nRegression.doRatioLimit = 0\nRegression.centroidRatioLimit = 0\nMoments.doRatioLimit = 0\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\n\n  //////////////////////////////////////////////////////////////////////\n ///////////////////  data output configuration  //////////////////////\n//////////////////////////////////////////////////////////////////////\n\n// output recorded and segmented turns as wave files for debugging purposes\n// if you do not want this output, then you can disable this component\n[turnDump:cWaveSinkCut]\nreader.dmLevel = frames\n\n// ----- you can use this to save the features extracted  ------\n[arffsink:cArffSink]\nreader.dmLevel=func\n ; do not print \"frameNumber\" attribute to ARFF file\nnumber=0\n ; name of output file as commandline option\nfilename=\\cm[arffout(O){output.arff}:name of WEKA Arff output file]\n ; name of @relation in the ARFF file\nrelation=\\cm[corpus{SMILEfeaturesLive}:corpus name, arff relation]\n ; base name of the current instance, turn number will be appended\ninstanceBase=liveturn\n ; name of class label\nclass[0].name = emotion\n ; list of nominal classes OR \"numeric\"\nclass[0].type = \\cm[classes{unknown}:all classes for arff file attribute]\n ; the class label or value for the current instance\ntarget[0].all = \\cm[classlabel{unassigned}:instance class label]\n ; ** NOTE: theoretically the classified class label could be assigned here, however this would require \n ; ** saving the class label along with the frame in the dataMemory\n ; ** or sending this meta-data via a message (including frame number)\n ; ** neither solution is currently implemented.... :-(\n ;\nappend=0\n\n// LibSVM dataSink for live classification of extracted features\n// continuous arousal from QUB-SAL corpus\n[arousal:cLibsvmLiveSink]\nreader.dmLevel=func\n; model file to use\nmodel=models/emo/sal_aro.emobase.model\n; scale file to use\nscale=models/emo/sal_aro.emobase.scale\n;; you could use the following line to send the classification result to a custom component\n ;resultRecp=emmaSender\nmodelResultName[0]=arousal\n;; print result to console window\nprintResult=0\nprintParseableResult=1\nforceScale = 0\n\n// LibSVM dataSink for live classification of extracted features\n// continuous valence from QUB-SAL corpus\n[valence:cLibsvmLiveSink]\nreader.dmLevel=func\n; model file to use\nmodel=models/emo/sal_val.emobase.model\n; scale file to use\nscale=models/emo/sal_val.emobase.scale\n;; you could use the following line to send the classification result to a custom component\n ;resultRecp=emmaSender\nmodelResultName[0]=valence\n;; print result to console window\nprintResult=0\nprintParseableResult=1\nforceScale = 0\n\n// LibSVM dataSink for live classification of extracted features\n// Emotion from Berlin Speech Emotion Database (EMO-DB) \n[emodbEmotion:cLibsvmLiveSink]\nreader.dmLevel=func\n; model file to use\nmodel=models/emo/emodb.emobase.model\n; scale file to use\nscale=models/emo/emodb.emobase.scale\n; class names:\nclasses=models/emo/emodb.emobase.classes\n;; you could use the following line to send the classification result to a custom component\n ;resultRecp=emmaSender\nmodelResultName[0]=emodb_emotion\n;; print result to console window\nprintResult=0\nprintParseableResult = 1\n ; also display per-class probabilities (of SVM models)\npredictProbability=1\nforceScale = 0\n\n// LibSVM dataSink for live classification of extracted features\n// Affective state from TUM Airplane Behaviour Corpus (ABC)\n[abcAffect:cLibsvmLiveSink]\nreader.dmLevel=func\n; model file to use\nmodel=models/emo/abc.emobase.model\n; scale file to use\nscale=models/emo/abc.emobase.scale\n; class names:\nclasses=models/emo/abc.emobase.classes\n;; you could use the following line to send the classification result to a custom component\n ;resultRecp=emmaSender\nmodelResultName[0]=abc_affect\n;; print result to console window\nprintResult=0\nprintParseableResult = 1\n ; also display per-class probabilities (of SVM models)\npredictProbability=1\nforceScale = 0\n\n// LibSVM dataSink for live classification of extracted features\n// Interest level from TUM Audiovisual Interest Corpus (AVIC)\n[avicInterest:cLibsvmLiveSink]\nreader.dmLevel=func\n; model file to use\nmodel=models/emo/avic.emobase.model\n; scale file to use\nscale=models/emo/avic.emobase.scale\n; class names:\nclasses=models/emo/avic.emobase.classes\n;; you could use the following line to send the classification result to a custom component\n ;resultRecp=emmaSender\nmodelResultName[0]=interest\n;; print result to console window\nprintResult = 0\nprintParseableResult=1\n ; also display per-class probabilities (of SVM models)\npredictProbability=1\nforceScale = 0\n\n\n//////---------------------- END -------------------------///////\n"
  },
  {
    "path": "config/gemaps/GeMAPSv01a.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\r\n///////// > openSMILE configuration file, Geneva feature set <       //////////////////\r\n/////////                                                            //////////////////\r\n///////// (c) 2014 by audEERING                                      //////////////////\r\n/////////     All rights reserved. See file COPYING for details.     //////////////////\r\n///////////////////////////////////////////////////////////////////////////////////////\r\n\r\n;;;;;;; component list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[dataMemory].type=cDataMemory\r\nprintLevelStats=0\r\n\r\n;;;;;;;;;;;;;;;;;;;;;;;;;;;; main section ;;;;;;;;;;;;;;;;;;;;;;;;;;;\r\n\r\n\\{../shared/standard_wave_input.conf.inc}\r\n\\{GeMAPSv01a_core.lld.conf.inc}\r\n\\{GeMAPSv01a_core.func.conf.inc}\r\n\r\n;;;;;;;; prepare for standard data output ;;;;;;;;;;;;;;;;;;;;;\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[lldconcat].type=cVectorConcat\r\ninstance[llddeconcat].type=cVectorConcat\r\ninstance[funcconcat].type=cVectorConcat\r\n\r\n[lldconcat:cVectorConcat]\r\nreader.dmLevel = gemapsv01a_lldsetE_smo\r\nwriter.dmLevel = lld\r\nincludeSingleElementFields = 1\r\n\r\n[llddeconcat:cVectorConcat]\r\nreader.dmLevel = gemapsv01a_lldsetF_smo\r\nwriter.dmLevel = lld_de\r\nincludeSingleElementFields = 1\r\n\r\n[funcconcat:cVectorConcat]\r\nreader.dmLevel = gemapsv01a_functionalsF0;gemapsv01a_functionalsLoudness;gemapsv01a_functionalsMeanStddevVoiced;gemapsv01a_functionalsMeanSpectralUnvoiced;gemapsv01a_temporalSet\r\nwriter.dmLevel = func\r\nincludeSingleElementFields = 1\r\n\r\n\\{../shared/standard_data_output.conf.inc}\r\n\r\n\r\n"
  },
  {
    "path": "config/gemaps/GeMAPSv01a_core.func.conf.inc",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\r\n///////// > openSMILE configuration file, Geneva feature set <       //////////////////\r\n/////////                                                            //////////////////\r\n///////// (c) 2014 by audEERING                                      //////////////////\r\n/////////     All rights reserved. See file COPYING for details.     //////////////////\r\n///////////////////////////////////////////////////////////////////////////////////////\r\n\r\n;;;;;;;;;;;;;;;; temporal statistics: ;;;;;;;;;;;;;;;;;;;;;;\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[gemapsv01a_smoF0].type=cContourSmoother\r\ninstance[gemapsv01a_smoLoudness].type=cContourSmoother\r\ninstance[gemapsv01a_temporalF0].type=cFunctionals\r\ninstance[gemapsv01a_temporalF0p].type=cFunctionals\r\ninstance[gemapsv01a_temporalLoudness].type=cFunctionals\r\ninstance[gemapsv01a_temporalSetNames].type=cDataSelector\r\n\r\n;;smoothing ;;\r\n[gemapsv01a_smoF0:cContourSmoother]\r\nreader.dmLevel = gemapsv01a_lld_single_logF0\r\nwriter.dmLevel = gemapsv01a_lld_single_logF0_smo\r\n\\{\\cm[bufferModeConf]}\r\ncopyInputName = 1\r\nnameAppend = sma3nz\r\nnoPostEOIprocessing = 0\r\nsmaWin = 3\r\nnoZeroSma = 1\r\n\r\n[gemapsv01a_smoLoudness:cContourSmoother]\r\nreader.dmLevel = gemapsv01a_loudness\r\nwriter.dmLevel = gemapsv01a_loudness_smo\r\n\\{\\cm[bufferModeConf]}\r\nnameAppend = sma3\r\ncopyInputName = 1\r\nnoPostEOIprocessing = 0\r\nsmaWin = 3\r\nnoZeroSma = 0\r\n\r\n; functionals for pitch onsets/offsets\r\n[gemapsv01a_temporalF0:cFunctionals]\r\nreader.dmLevel = gemapsv01a_lld_single_logF0_smo\r\nwriter.dmLevel = gemapsv01a_temporalF0\r\n\\{\\cm[bufferModeRbConf]}\r\n//nameAppend = ff0\r\ncopyInputName = 1\r\n\\{\\cm[frameModeFunctionalsConf{../shared/FrameModeFunctionals.conf.inc}:path to included config to set frame mode for all functionals]}\r\nfunctionalsEnabled = Segments \r\nSegments.maxNumSeg = 1000\r\nSegments.segmentationAlgorithm = nonX\r\nSegments.X = 0.0\r\nSegments.numSegments = 1\r\nSegments.meanSegLen = 1\r\nSegments.maxSegLen = 0\r\nSegments.minSegLen = 0\r\nSegments.segLenStddev = 1\r\nSegments.norm = second\r\nnonZeroFuncts = 0\r\nmasterTimeNorm = second\r\n\r\n// TODO: this is only unvoiced segments, combine with energy / loudness for true pauses!\r\n; functionals for pitch onsets/offsets\r\n[gemapsv01a_temporalF0p:cFunctionals]\r\nreader.dmLevel = gemapsv01a_lld_single_logF0_smo\r\nwriter.dmLevel = gemapsv01a_temporalF0pause\r\n\\{\\cm[bufferModeRbConf]}\r\ncopyInputName = 0\r\nfunctNameAppend = f0pause\r\n\\{\\cm[frameModeFunctionalsConf]}\r\nfunctionalsEnabled = Segments \r\nSegments.maxNumSeg = 1000\r\nSegments.segmentationAlgorithm = eqX\r\nSegments.X = 0.0\r\nSegments.numSegments = 0\r\nSegments.meanSegLen = 1\r\nSegments.maxSegLen = 0\r\nSegments.minSegLen = 0\r\nSegments.segLenStddev = 1\r\nSegments.norm = second\r\nnonZeroFuncts = 0\r\nmasterTimeNorm = second\r\n\r\n; functionals for pitch onsets/offsets\r\n[gemapsv01a_temporalLoudness:cFunctionals]\r\nreader.dmLevel = gemapsv01a_loudness_smo\r\nwriter.dmLevel = gemapsv01a_temporalLoudness\r\n\\{\\cm[bufferModeRbConf]}\r\n//nameAppend = ff0\r\ncopyInputName = 1\r\n\\{\\cm[frameModeFunctionalsConf]}\r\nfunctionalsEnabled = Peaks2 \r\nPeaks2.numPeaks = 1\r\nPeaks2.meanPeakDist = 0\r\nPeaks2.meanPeakDistDelta = 0\r\nPeaks2.peakDistStddev = 0\r\nPeaks2.peakRangeAbs = 0\r\nPeaks2.peakRangeRel = 0\r\nPeaks2.peakMeanAbs = 0\r\nPeaks2.peakMeanMeanDist = 0\r\nPeaks2.peakMeanRel = 0\r\nPeaks2.ptpAmpMeanAbs = 0\r\nPeaks2.ptpAmpMeanRel = 0\r\nPeaks2.ptpAmpStddevAbs = 0\r\nPeaks2.ptpAmpStddevRel = 0\r\nPeaks2.minRangeAbs = 0\r\nPeaks2.minRangeRel = 0\r\nPeaks2.minMeanAbs = 0\r\nPeaks2.minMeanMeanDist = 0\r\nPeaks2.minMeanRel = 0\r\nPeaks2.mtmAmpMeanAbs = 0\r\nPeaks2.mtmAmpMeanRel = 0\r\nPeaks2.mtmAmpStddevAbs = 0\r\nPeaks2.mtmAmpStddevRel = 0\r\nPeaks2.meanRisingSlope = 0\r\nPeaks2.maxRisingSlope = 0\r\nPeaks2.minRisingSlope = 0\r\nPeaks2.stddevRisingSlope = 0\r\nPeaks2.meanFallingSlope = 0\r\nPeaks2.maxFallingSlope = 0\r\nPeaks2.minFallingSlope = 0\r\nPeaks2.stddevFallingSlope = 0\r\nPeaks2.norm = seconds\r\nPeaks2.relThresh = 0.100000\r\nPeaks2.dynRelThresh = 0\r\n;Peaks2.posDbgOutp = minmax.txt\r\nPeaks2.posDbgAppend = 0\r\nPeaks2.consoleDbg = 0\r\nnonZeroFuncts = 0\r\nmasterTimeNorm = second\r\n\r\n;;;;;;;;;;;;;;;;;; filtering and renaming of names ;;;;;;;;;;;\r\n\r\n[gemapsv01a_temporalSetNames:cDataSelector]\r\nreader.dmLevel = gemapsv01a_temporalLoudness;gemapsv01a_temporalF0;gemapsv01a_temporalF0pause\r\nwriter.dmLevel = gemapsv01a_temporalSet\r\n\\{\\cm[bufferModeRbConf]}\r\nselected = loudness_sma3_numPeaks;F0semitoneFrom27.5Hz_sma3nz_numSegments;F0semitoneFrom27.5Hz_sma3nz_meanSegLen;F0semitoneFrom27.5Hz_sma3nz_segLenStddev;F0semitoneFrom27.5Hz_sma3nz__f0pause_meanSegLen;F0semitoneFrom27.5Hz_sma3nz__f0pause_segLenStddev\r\nnewNames = loudnessPeaksPerSec;VoicedSegmentsPerSec;MeanVoicedSegmentLengthSec;StddevVoicedSegmentLengthSec;MeanUnvoicedSegmentLength;StddevUnvoicedSegmentLength\r\n\r\n;;;;;;;;;;;;;;;;;;;;; functionals / summaries ;;;;;;;;;;;;;;;\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[gemapsv01a_functionalsF0].type=cFunctionals\r\ninstance[gemapsv01a_functionalsLoudness].type=cFunctionals\r\ninstance[gemapsv01a_functionalsMeanSpectralUV].type=cFunctionals\r\ninstance[gemapsv01a_functionalsMVRVoiced].type=cFunctionals\r\n\r\n[gemapsv01a_functionalsF0:cFunctionals]\r\nreader.dmLevel = gemapsv01a_lld_single_logF0_smo\r\nwriter.dmLevel = gemapsv01a_functionalsF0\r\n\\{\\cm[bufferModeRbConf]}\r\ncopyInputName = 1\r\n\\{\\cm[frameModeFunctionalsConf]}\r\nfunctionalsEnabled = Moments ; Percentiles ; Peaks2\r\nMoments.variance = 0\r\nMoments.stddev = 0\r\nMoments.stddevNorm = 2\r\nMoments.skewness = 0\r\nMoments.kurtosis = 0\r\nMoments.amean = 1\r\nMoments.doRatioLimit = 0\r\nPercentiles.quartiles = 0\r\nPercentiles.iqr = 0\r\nPercentiles.percentile[0] = 0.20\r\nPercentiles.percentile[1] = 0.50\r\nPercentiles.percentile[2] = 0.80\r\nPercentiles.pctlrange[0] = 0-2\r\nPercentiles.interp = 1\r\nPeaks2.doRatioLimit = 0\r\nPeaks2.numPeaks = 0\r\nPeaks2.meanPeakDist = 0\r\nPeaks2.meanPeakDistDelta = 0\r\nPeaks2.peakDistStddev = 0\r\nPeaks2.peakRangeAbs = 0\r\nPeaks2.peakRangeRel = 0\r\nPeaks2.peakMeanAbs = 0\r\nPeaks2.peakMeanMeanDist = 0\r\nPeaks2.peakMeanRel = 0\r\nPeaks2.ptpAmpMeanAbs = 0\r\nPeaks2.ptpAmpMeanRel = 0\r\nPeaks2.ptpAmpStddevAbs = 0\r\nPeaks2.ptpAmpStddevRel = 0\r\nPeaks2.minRangeAbs = 0\r\nPeaks2.minRangeRel = 0\r\nPeaks2.minMeanAbs = 0\r\nPeaks2.minMeanMeanDist = 0\r\nPeaks2.minMeanRel = 0\r\nPeaks2.mtmAmpMeanAbs = 0\r\nPeaks2.mtmAmpMeanRel = 0\r\nPeaks2.mtmAmpStddevAbs = 0\r\nPeaks2.mtmAmpStddevRel = 0\r\nPeaks2.meanRisingSlope = 1\r\nPeaks2.maxRisingSlope = 0\r\nPeaks2.minRisingSlope = 0\r\nPeaks2.stddevRisingSlope = 1\r\nPeaks2.meanFallingSlope = 1\r\nPeaks2.maxFallingSlope = 0\r\nPeaks2.minFallingSlope = 0\r\nPeaks2.stddevFallingSlope = 1\r\nPeaks2.norm = seconds\r\nPeaks2.relThresh = 0.100000\r\nPeaks2.dynRelThresh = 0\r\n;Peaks2.posDbgOutp = minmax.txt\r\nPeaks2.posDbgAppend = 0\r\nPeaks2.consoleDbg = 0\r\nnonZeroFuncts = 1\r\nmasterTimeNorm = segment\r\n\r\n[gemapsv01a_functionalsLoudness:cFunctionals]\r\nreader.dmLevel = gemapsv01a_loudness_smo\r\nwriter.dmLevel = gemapsv01a_functionalsLoudness\r\n\\{\\cm[bufferModeRbConf]}\r\ncopyInputName = 1\r\n\\{\\cm[frameModeFunctionalsConf]}\r\nfunctionalsEnabled = Moments ; Percentiles ; Peaks2\r\nMoments.variance = 0\r\nMoments.stddev = 0\r\nMoments.stddevNorm = 2\r\nMoments.skewness = 0\r\nMoments.kurtosis = 0\r\nMoments.amean = 1\r\nMoments.doRatioLimit = 0\r\nPercentiles.quartiles = 0\r\nPercentiles.iqr = 0\r\nPercentiles.percentile[0] = 0.20\r\nPercentiles.percentile[1] = 0.50\r\nPercentiles.percentile[2] = 0.80\r\nPercentiles.pctlrange[0] = 0-2\r\nPercentiles.interp = 1\r\nPeaks2.doRatioLimit = 0\r\nPeaks2.numPeaks = 0\r\nPeaks2.meanPeakDist = 0\r\nPeaks2.meanPeakDistDelta = 0\r\nPeaks2.peakDistStddev = 0\r\nPeaks2.peakRangeAbs = 0\r\nPeaks2.peakRangeRel = 0\r\nPeaks2.peakMeanAbs = 0\r\nPeaks2.peakMeanMeanDist = 0\r\nPeaks2.peakMeanRel = 0\r\nPeaks2.ptpAmpMeanAbs = 0\r\nPeaks2.ptpAmpMeanRel = 0\r\nPeaks2.ptpAmpStddevAbs = 0\r\nPeaks2.ptpAmpStddevRel = 0\r\nPeaks2.minRangeAbs = 0\r\nPeaks2.minRangeRel = 0\r\nPeaks2.minMeanAbs = 0\r\nPeaks2.minMeanMeanDist = 0\r\nPeaks2.minMeanRel = 0\r\nPeaks2.mtmAmpMeanAbs = 0\r\nPeaks2.mtmAmpMeanRel = 0\r\nPeaks2.mtmAmpStddevAbs = 0\r\nPeaks2.mtmAmpStddevRel = 0\r\nPeaks2.meanRisingSlope = 1\r\nPeaks2.maxRisingSlope = 0\r\nPeaks2.minRisingSlope = 0\r\nPeaks2.stddevRisingSlope = 1\r\nPeaks2.meanFallingSlope = 1\r\nPeaks2.maxFallingSlope = 0\r\nPeaks2.minFallingSlope = 0\r\nPeaks2.stddevFallingSlope = 1\r\nPeaks2.norm = seconds\r\nPeaks2.relThresh = 0.100000\r\nPeaks2.dynRelThresh = 0\r\n;Peaks2.posDbgOutp = minmax.txt\r\nPeaks2.posDbgAppend = 0\r\nPeaks2.consoleDbg = 0\r\nnonZeroFuncts = 0\r\nmasterTimeNorm = segment\r\n\r\n[gemapsv01a_functionalsMeanSpectralUV:cFunctionals]\r\nreader.dmLevel = gemapsv01a_lldSetSpectralZ_smo\r\nwriter.dmLevel = gemapsv01a_functionalsMeanSpectralUnvoiced\r\n\\{\\cm[bufferModeRbConf]}\r\ncopyInputName = 1\r\n\\{\\cm[frameModeFunctionalsConf]}\r\nfunctionalsEnabled = Moments\r\nMoments.variance = 0\r\nMoments.stddev = 0\r\nMoments.stddevNorm = 0\r\nMoments.skewness = 0\r\nMoments.kurtosis = 0\r\nMoments.amean = 1\r\nMoments.doRatioLimit = 0\r\nnonZeroFuncts = 1\r\nmasterTimeNorm = segment\r\n\r\n[gemapsv01a_functionalsMVRVoiced:cFunctionals]\r\nreader.dmLevel = gemapsv01a_lldSetNoF0AndLoudnessNz_smo;gemapsv01a_lldSetSpectralNz_smo;\r\nwriter.dmLevel = gemapsv01a_functionalsMeanStddevVoiced\r\n\\{\\cm[bufferModeRbConf]}\r\ncopyInputName = 1\r\n\\{\\cm[frameModeFunctionalsConf]}\r\nfunctionalsEnabled = Moments\r\nMoments.variance = 0\r\nMoments.stddev = 0\r\nMoments.stddevNorm = 2\r\nMoments.skewness = 0\r\nMoments.kurtosis = 0\r\nMoments.amean = 1\r\nMoments.doRatioLimit = 0\r\nnonZeroFuncts = 1\r\nmasterTimeNorm = segment\r\n\r\n\r\n\r\n"
  },
  {
    "path": "config/gemaps/GeMAPSv01a_core.lld.conf.inc",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\r\n///////// > openSMILE configuration file, Geneva feature set <       //////////////////\r\n/////////                                                            //////////////////\r\n///////// (c) 2014 by audEERING                                      //////////////////\r\n/////////     All rights reserved. See file COPYING for details.     //////////////////\r\n///////////////////////////////////////////////////////////////////////////////////////\r\n\r\n;;;;;;;;;;;;;;;;;;;;;;\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[gemapsv01a_frame60].type=cFramer\r\ninstance[gemapsv01a_win60].type=cWindower\r\ninstance[gemapsv01a_fft60].type=cTransformFFT\r\ninstance[gemapsv01a_fftmp60].type=cFFTmagphase\r\n\r\n[gemapsv01a_frame60:cFramer]\r\nreader.dmLevel=wave\r\nwriter.dmLevel=gemapsv01a_frame60\r\n\\{\\cm[bufferModeRbConf{../shared/BufferModeRb.conf.inc}:path to included config to set the buffer mode for the standard ringbuffer levels]}\r\nframeSize = 0.060\r\nframeStep = 0.010\r\nframeCenterSpecial = left\r\n\r\n[gemapsv01a_win60:cWindower]\r\nreader.dmLevel=gemapsv01a_frame60\r\nwriter.dmLevel=gemapsv01a_winG60\r\nwinFunc=gauss\r\ngain=1.0\r\nsigma=0.4\r\n\r\n[gemapsv01a_fft60:cTransformFFT]\r\nreader.dmLevel=gemapsv01a_winG60\r\nwriter.dmLevel=gemapsv01a_fftcG60\r\n ; for compatibility with 2.2.0 and older versions\r\nzeroPadSymmetric = 0\r\n\r\n[gemapsv01a_fftmp60:cFFTmagphase]\r\nreader.dmLevel=gemapsv01a_fftcG60\r\nwriter.dmLevel=gemapsv01a_fftmagG60\r\n\\{\\cm[bufferModeRbLagConf{../shared/BufferModeRbLag.conf.inc}:path to included config to set the buffer mode for levels which will be joint with Viterbi smoothed -lagged- F0]}\r\n\r\n\r\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[gemapsv01a_frame25].type=cFramer\r\ninstance[gemapsv01a_win25].type=cWindower\r\ninstance[gemapsv01a_fft25].type=cTransformFFT\r\ninstance[gemapsv01a_fftmp25].type=cFFTmagphase\r\n\r\n[gemapsv01a_frame25:cFramer]\r\nreader.dmLevel=wave\r\nwriter.dmLevel=gemapsv01a_frame25\r\n\\{\\cm[bufferModeRbConf]}\r\nframeSize = 0.020\r\nframeStep = 0.010\r\nframeCenterSpecial = left\r\n\r\n[gemapsv01a_win25:cWindower]\r\nreader.dmLevel=gemapsv01a_frame25\r\nwriter.dmLevel=gemapsv01a_winH25\r\nwinFunc=hamming\r\n\r\n[gemapsv01a_fft25:cTransformFFT]\r\nreader.dmLevel=gemapsv01a_winH25\r\nwriter.dmLevel=gemapsv01a_fftcH25\r\n ; for compatibility with 2.2.0 and older versions\r\nzeroPadSymmetric = 0\r\n\r\n[gemapsv01a_fftmp25:cFFTmagphase]\r\nreader.dmLevel=gemapsv01a_fftcH25\r\nwriter.dmLevel=gemapsv01a_fftmagH25\r\n;;; CHECK!!!!!!!\r\n;writer.levelconf.growDyn = 1\r\n;writer.levelconf.isRb = 0\r\n\r\n\r\n;;;;;;;;;;;;;;;;;;;; HPS pitch\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[gemapsv01a_scale].type=cSpecScale\r\ninstance[gemapsv01a_shs].type=cPitchShs\r\n\r\n[gemapsv01a_scale:cSpecScale]\r\nreader.dmLevel=gemapsv01a_fftmagG60\r\nwriter.dmLevel=gemapsv01a_hpsG60\r\n\\{\\cm[bufferModeRbConf]}\r\ncopyInputName = 1\r\nprocessArrayFields = 0\r\nscale=octave\r\nsourceScale = lin\r\ninterpMethod = spline\r\nminF = 25\r\nmaxF = -1\r\nnPointsTarget = 0\r\nspecSmooth = 1\r\nspecEnhance = 1\r\nauditoryWeighting = 1 \r\n\r\n[gemapsv01a_shs:cPitchShs]\r\nreader.dmLevel=gemapsv01a_hpsG60\r\nwriter.dmLevel=gemapsv01a_pitchShsG60\r\n\\{\\cm[bufferModeRbLagConf]}\r\ncopyInputName = 1\r\nprocessArrayFields = 0\r\nmaxPitch = 1000\r\nminPitch = 55\r\nnCandidates = 6\r\nscores = 1\r\nvoicing = 1\r\nF0C1 = 0\r\nvoicingC1 = 0\r\nF0raw = 1\r\nvoicingClip = 1\r\nvoicingCutoff = 0.700000\r\ninputFieldSearch = Mag_octScale\r\noctaveCorrection = 0\r\nnHarmonics = 15\r\ncompressionFactor = 0.850000\r\ngreedyPeakAlgo = 1\r\n\r\n;;;;; Pitch with Viterbi smoother\r\n[componentInstances:cComponentManager]\r\ninstance[gemapsv01a_energy60].type=cEnergy\r\n\r\n[gemapsv01a_energy60:cEnergy]\r\nreader.dmLevel=gemapsv01a_winG60\r\nwriter.dmLevel=gemapsv01a_e60\r\n ; This must be > than buffersize of viterbi smoother\r\n ; writer.levelconf.nT=100\r\n\\{\\cm[bufferModeRbLagConf]}\r\nrms=1\r\nlog=0\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[gemapsv01a_pitchSmoothViterbi].type=cPitchSmootherViterbi\r\n\r\n[gemapsv01a_pitchSmoothViterbi:cPitchSmootherViterbi]\r\nreader.dmLevel=gemapsv01a_pitchShsG60\r\nreader2.dmLevel=gemapsv01a_pitchShsG60\r\nwriter.dmLevel=gemapsv01a_logPitchRaw\r\ncopyInputName = 1\r\nbufferLength=40\r\nF0final = 1\r\nF0finalLog = 1\r\nF0finalEnv = 0\r\nvoicingFinalClipped = 0\r\nvoicingFinalUnclipped = 1\r\nF0raw = 0\r\nvoicingC1 = 0\r\nvoicingClip = 0\r\nwTvv =10.0\r\nwTvvd= 5.0\r\nwTvuv=10.0\r\nwThr = 4.0\r\nwTuu = 0.0\r\nwLocal=2.0\r\nwRange=1.0\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[gemapsv01a_volmerge].type = cValbasedSelector\r\n\r\n[gemapsv01a_volmerge:cValbasedSelector]\r\nreader.dmLevel = gemapsv01a_e60;gemapsv01a_logPitchRaw\r\nwriter.dmLevel = gemapsv01a_logPitch\r\n\\{\\cm[bufferModeRbLagConf]}\r\nidx=0\r\nthreshold=0.001\r\nremoveIdx=1\r\nzeroVec=1\r\noutputVal=0.0\r\n\r\n;;;;;;;;;;;;;;;;;;; Voice Quality (VQ)\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[gemapsv01a_pitchJitter].type=cPitchJitter\r\n\r\n[gemapsv01a_pitchJitter:cPitchJitter]\r\nreader.dmLevel = wave\r\nwriter.dmLevel = gemapsv01a_jitterShimmer\r\n\\{\\cm[bufferModeRbLagConf]}\r\ncopyInputName = 1\r\nF0reader.dmLevel = gemapsv01a_logPitch\r\nF0field = F0final\r\nsearchRangeRel = 0.100000\r\njitterLocal = 1\r\njitterDDP = 0\r\njitterLocalEnv = 0\r\njitterDDPEnv = 0\r\nshimmerLocal = 0\r\nshimmerLocalDB = 1\r\nshimmerLocalEnv = 0\r\nonlyVoiced = 0\r\nlogHNR = 0\r\n ; This must be larger than the viterbi pitch smoother lag\r\ninputMaxDelaySec = 2.5\r\nminNumPeriods = 2\r\nminCC = 0.5\r\nuseBrokenJitterThresh = 1\r\n\r\n;;;;;;;;;;;;;;;;;;;;; Energy / loudness\r\n\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[gemapsv01a_melspec1].type=cMelspec\r\ninstance[gemapsv01a_audspec].type=cPlp\r\ninstance[gemapsv01a_audspecSum].type=cVectorOperation\r\n\r\n[gemapsv01a_melspec1:cMelspec]\r\nreader.dmLevel=gemapsv01a_fftmagH25\r\nwriter.dmLevel=gemapsv01a_melspec1\r\n; htk compatible sample value scaling\r\nhtkcompatible = 0\r\nnBands = 26\r\n; use power spectrum instead of magnitude spectrum\r\nusePower = 1\r\nlofreq = 20\r\nhifreq = 8000\r\nspecScale = mel\r\nshowFbank = 0\r\n\r\n; perform auditory weighting of spectrum\r\n[gemapsv01a_audspec:cPlp]\r\nreader.dmLevel=gemapsv01a_melspec1\r\nwriter.dmLevel=gemapsv01a_audspec\r\nfirstCC = 0\r\nlpOrder = 5\r\ncepLifter = 22\r\ncompression = 0.33\r\nhtkcompatible = 0 \r\ndoIDFT = 0\r\ndoLpToCeps = 0\r\ndoLP = 0\r\ndoInvLog = 0\r\ndoAud = 1\r\ndoLog = 0\r\nnewRASTA=0\r\nRASTA=0\r\n\r\n[gemapsv01a_audspecSum:cVectorOperation]\r\nreader.dmLevel = gemapsv01a_audspec\r\nwriter.dmLevel = gemapsv01a_loudness\r\n; This must be larger than the F0 viterbi buffer length\r\n; since audspecSum and F0 envelope are joint later!\r\n\\{\\cm[bufferModeRbLagConf]}\r\nnameAppend = loudness\r\ncopyInputName = 0\r\nprocessArrayFields = 0\r\noperation = ll1\r\nnameBase = loudness\r\n\r\n;;;;;;;;;;;;;; Formants ;;;;;;;;;;;;;;;;;;;;;;\r\n[componentInstances:cComponentManager]\r\ninstance[gemapsv01a_resampLpc].type=cSpecResample\r\ninstance[gemapsv01a_lpc].type=cLpc\r\ninstance[gemapsv01a_formantLpc].type=cFormantLpc\r\n\r\n[gemapsv01a_resampLpc:cSpecResample]\r\n// use fftcG60 ?  H25 has faster resampling\r\nreader.dmLevel=gemapsv01a_fftcH25 \r\nwriter.dmLevel=gemapsv01a_outpR\r\ntargetFs = 11000\r\n\r\n[gemapsv01a_lpc:cLpc]\r\nreader.dmLevel=gemapsv01a_outpR\r\nwriter.dmLevel=gemapsv01a_lpc\r\np=11\r\nmethod=acf\r\nlpGain=0\r\nsaveLPCoeff=1\r\nresidual=0\r\nforwardFilter=0\r\nlpSpectrum=0\r\n\r\n[gemapsv01a_formantLpc:cFormantLpc]\r\nreader.dmLevel=gemapsv01a_lpc\r\nwriter.dmLevel=gemapsv01a_formants\r\n\\{\\cm[bufferModeRbLagConf]}\r\nsaveIntensity=0\r\nsaveBandwidths=1\r\nmaxF=5500.0\r\nminF=50.0\r\nnFormants=5\r\nuseLpSpec=0\r\nmedianFilter=0\r\noctaveCorrection=0\r\n\r\n;;;;;;;;;;;;; Harmonics ;;;;;;;;;;;;;;;;;;;;\r\n[componentInstances:cComponentManager]\r\ninstance[gemapsv01a_harmonics].type = cHarmonics\r\n\r\n  ;;;; default (template) configuration section for component 'cHarmonics' ;;;;\r\n[gemapsv01a_harmonics:cHarmonics]\r\nreader.dmLevel = gemapsv01a_logPitch;gemapsv01a_formants;gemapsv01a_fftmagG60\r\nwriter.dmLevel = gemapsv01a_harmonics\r\n\\{\\cm[bufferModeRbLagConf]}\r\ncopyInputName = 0\r\nprocessArrayFields = 0\r\nincludeSingleElementFields = 1\r\npreserveFieldNames = 0\r\nformantFrequencyFieldName = formantFreqLpc\r\nformantFrequencyFieldNameIsFull = 1\r\nformantBandwidthFieldName = formantBandwidthLpc\r\nformantBandwidthFieldNameIsFull = 1\r\nf0ElementName = F0final\r\nf0ElementNameIsFull = 1\r\nmagSpecFieldName = pcm_fftMag\r\nmagSpecFieldNameIsFull = 1\r\nnHarmonics = 100\r\nharmonicDifferences = H1-H2;H1-A3\r\nharmonicDifferencesLog = 1\r\nnHarmonicMagnitudes = 0\r\nfirstHarmonicMagnitude = 1\r\noutputLogRelMagnitudes = 1\r\nformantAmplitudes=1\r\nformantAmplitudesLogRel = 1\r\nformantAmplitudesStart = 1\r\nformantAmplitudesEnd = 3\r\ncomputeAcfHnrLogdB = 1\r\n\r\n;;;;;;;;;;;;;;; spectral\r\n[componentInstances:cComponentManager]\r\ninstance[gemapsv01a_logSpectral].type=cSpectral\r\n\r\n[gemapsv01a_logSpectral:cSpectral]\r\nreader.dmLevel=gemapsv01a_fftmagH25\r\nwriter.dmLevel=gemapsv01a_logSpectral\r\n\\{\\cm[bufferModeRbLagConf]}\r\nflux = 0\r\ncentroid = 0\r\nmaxPos=0\r\nminPos=0\r\nentropy = 0\r\nflatness = 0\r\nharmonicity = 0\r\nsharpness = 0\r\nvariance=0\r\nskewness=0\r\nkurtosis=0\r\nalphaRatio = 1\r\nhammarbergIndex = 1\r\nslope = 0\r\nslopes[0] = 0-500\r\nslopes[1] = 500-1500\r\n  ; NOTE: added this to sync with eGeMAPS set, should have no effect.\r\nnormBandEnergies = 1\r\nsquareInput = 1\r\nuseLogSpectrum = 1\r\nfreqRange = 0-5000\r\noldSlopeScale = 0\r\n\r\n;;;;;;;;;;;; collecting, filtering, and renaming ;;;;;;;;;;;;;;;;,\r\n\r\n/*\r\nlogSpectral     Hammarberg, AlphaRatio, spectralSlope  0-500, 500-1500\r\nharmonics   H1-H2, H1-A3, HNRlog\r\nlogPitch    F0finalLog\r\njitterShimmer   jitterLocal, shimmerLocal\r\nloudness\r\nformants   F1-3 freq, F1 bandw (check!)\r\nharmonics  F1-3 level relative\r\n*/\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[gemapsv01a_lldSetSelectorE].type=cDataSelector\r\ninstance[gemapsv01a_lldSetSelectorF].type=cDataSelector\r\ninstance[gemapsv01a_lldSetSelectorLogF0].type=cDataSelector\r\ninstance[gemapsv01a_formantVoiced].type = cValbasedSelector\r\ninstance[gemapsv01a_lldSetSelectorNoF0LoudnNz].type = cDataSelector\r\ninstance[gemapsv01a_logSpectralVoiced].type = cValbasedSelector\r\ninstance[gemapsv01a_logSpectralUnvoiced].type = cValbasedSelector\r\ninstance[gemapsv01a_lldSetSelectorSpectralNz].type=cDataSelector\r\ninstance[gemapsv01a_lldSetSelectorSpectralZ].type=cDataSelector\r\n\r\n[gemapsv01a_lldSetSelectorE:cDataSelector]\r\nreader.dmLevel = gemapsv01a_loudness;gemapsv01a_logSpectral\r\nwriter.dmLevel = gemapsv01a_lldsetE\r\n\\{\\cm[bufferModeRbConf]}\r\nselected = loudness;pcm_fftMag_alphaRatioDB;pcm_fftMag_hammarbergIndexDB;pcm_fftMag_logSpectralSlopeOfBand0-500;pcm_fftMag_logSpectralSlopeOfBand500-1500\r\nnewNames = Loudness;alphaRatio;hammarbergIndex;slope0-500;slope500-1500\r\n\r\n[gemapsv01a_lldSetSelectorF:cDataSelector]\r\nreader.dmLevel = gemapsv01a_logPitch;gemapsv01a_jitterShimmer;gemapsv01a_harmonics;gemapsv01a_formants\r\nwriter.dmLevel = gemapsv01a_lldsetF\r\n\\{\\cm[bufferModeRbConf]}\r\nselected = F0finalLog;jitterLocal;shimmerLocalDB;HarmonicsToNoiseRatioACFLogdB;HarmonicDifferenceLogRelH1-H2;HarmonicDifferenceLogRelH1-A3;formantFreqLpc[1];formantBandwidthLpc[1];FormantAmplitudeByMaxHarmonicLogRelF0[1];formantFreqLpc[2];FormantAmplitudeByMaxHarmonicLogRelF0[2];formantFreqLpc[3];FormantAmplitudeByMaxHarmonicLogRelF0[3]\r\nnewNames = F0semitoneFrom27.5Hz;jitterLocal;shimmerLocaldB;HNRdBACF;logRelF0-H1-H2;logRelF0-H1-A3;F1frequency;F1bandwidth;F1amplitudeLogRelF0;F2frequency;F2amplitudeLogRelF0;F3frequency;F3amplitudeLogRelF0\r\n\r\n[gemapsv01a_lldSetSelectorLogF0:cDataSelector]\r\nreader.dmLevel = gemapsv01a_logPitch\r\nwriter.dmLevel = gemapsv01a_lld_single_logF0\r\n\\{\\cm[bufferModeRbConf]}\r\nselected = F0finalLog\r\nnewNames = F0semitoneFrom27.5Hz\r\n\r\n// select only formants where F0 > 0 for functionals\r\n// (in LLD csv we output all of them..!)\r\n[gemapsv01a_formantVoiced:cValbasedSelector]\r\nreader.dmLevel = gemapsv01a_lld_single_logF0;gemapsv01a_formants\r\nwriter.dmLevel = gemapsv01a_formantsNz\r\n\\{\\cm[bufferModeRbLagConf]}\r\nidx=0\r\nthreshold=0.000001\r\nremoveIdx=1\r\nzeroVec=1\r\noutputVal=0.0\r\n\r\n[gemapsv01a_lldSetSelectorNoF0LoudnNz:cDataSelector]\r\nreader.dmLevel = gemapsv01a_jitterShimmer;gemapsv01a_harmonics;gemapsv01a_formantsNz\r\nwriter.dmLevel = gemapsv01a_lldSetNoF0AndLoudnessNz\r\n\\{\\cm[bufferModeRbConf]}\r\nselected = jitterLocal;shimmerLocalDB;HarmonicsToNoiseRatioACFLogdB;HarmonicDifferenceLogRelH1-H2;HarmonicDifferenceLogRelH1-A3;formantFreqLpc[1];formantBandwidthLpc[1];FormantAmplitudeByMaxHarmonicLogRelF0[1];formantFreqLpc[2];FormantAmplitudeByMaxHarmonicLogRelF0[2];formantFreqLpc[3];FormantAmplitudeByMaxHarmonicLogRelF0[3]\r\nnewNames = jitterLocal;shimmerLocaldB;HNRdBACF;logRelF0-H1-H2;logRelF0-H1-A3;F1frequency;F1bandwidth;F1amplitudeLogRelF0;F2frequency;F2amplitudeLogRelF0;F3frequency;F3amplitudeLogRelF0\r\n\r\n// select logspectral for voiced sounds\r\n[gemapsv01a_logSpectralVoiced:cValbasedSelector]\r\nreader.dmLevel = gemapsv01a_lld_single_logF0;gemapsv01a_logSpectral\r\nwriter.dmLevel = gemapsv01a_logSpectralVoiced\r\n\\{\\cm[bufferModeRbLagConf]}\r\nidx=0\r\nthreshold=0.000001\r\nremoveIdx=1\r\nzeroVec=1\r\noutputVal=0.0\r\n\r\n// select logspectral for voiced sounds\r\n[gemapsv01a_logSpectralUnvoiced:cValbasedSelector]\r\nreader.dmLevel = gemapsv01a_lld_single_logF0;gemapsv01a_logSpectral\r\nwriter.dmLevel = gemapsv01a_logSpectralUnvoiced\r\n\\{\\cm[bufferModeRbLagConf]}\r\nidx=0\r\ninvert = 1\r\nthreshold = 0.000001\r\nremoveIdx=1\r\nzeroVec=1\r\noutputVal=0.0\r\n\r\n[gemapsv01a_lldSetSelectorSpectralNz:cDataSelector]\r\nreader.dmLevel = gemapsv01a_logSpectralVoiced\r\nwriter.dmLevel = gemapsv01a_lldSetSpectralNz\r\n\\{\\cm[bufferModeRbConf]}\r\nselected = pcm_fftMag_alphaRatioDB;pcm_fftMag_hammarbergIndexDB;pcm_fftMag_logSpectralSlopeOfBand0-500;pcm_fftMag_logSpectralSlopeOfBand500-1500\r\nnewNames = alphaRatioV;hammarbergIndexV;slopeV0-500;slopeV500-1500\r\n\r\n[gemapsv01a_lldSetSelectorSpectralZ:cDataSelector]\r\nreader.dmLevel = gemapsv01a_logSpectralUnvoiced\r\nwriter.dmLevel = gemapsv01a_lldSetSpectralZ\r\n\\{\\cm[bufferModeRbConf]}\r\nselected = pcm_fftMag_alphaRatioDB;pcm_fftMag_hammarbergIndexDB;pcm_fftMag_logSpectralSlopeOfBand0-500;pcm_fftMag_logSpectralSlopeOfBand500-1500\r\nnewNames = alphaRatioUV;hammarbergIndexUV;slopeUV0-500;slopeUV500-1500\r\n\r\n\r\n;;;;;;;;;;;;;;;;  smoothing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r\n[componentInstances:cComponentManager]\r\ninstance[gemapsv01a_smoFnz].type=cContourSmoother\r\ninstance[gemapsv01a_smoE].type=cContourSmoother\r\ninstance[gemapsv01a_smoNoF0andLoudnNz].type=cContourSmoother\r\ninstance[gemapsv01a_smoSpectralZ].type=cContourSmoother\r\ninstance[gemapsv01a_smoSpectralNz].type=cContourSmoother\r\n\r\n[gemapsv01a_smoFnz:cContourSmoother]\r\nreader.dmLevel = gemapsv01a_lldsetF\r\nwriter.dmLevel = gemapsv01a_lldsetF_smo\r\nnameAppend = sma3nz\r\ncopyInputName = 1\r\nnoPostEOIprocessing = 0\r\nsmaWin = 3\r\nnoZeroSma = 1\r\n\r\n[gemapsv01a_smoE:cContourSmoother]\r\nreader.dmLevel = gemapsv01a_lldsetE\r\nwriter.dmLevel = gemapsv01a_lldsetE_smo\r\nnameAppend = sma3\r\ncopyInputName = 1\r\nnoPostEOIprocessing = 0\r\nsmaWin = 3\r\nnoZeroSma = 0\r\n\r\n[gemapsv01a_smoNoF0andLoudnNz:cContourSmoother]\r\nreader.dmLevel = gemapsv01a_lldSetNoF0AndLoudnessNz\r\nwriter.dmLevel = gemapsv01a_lldSetNoF0AndLoudnessNz_smo\r\n\\{\\cm[bufferModeConf{../shared/BufferMode.conf.inc}:path to included config to set the buffer mode for the levels before the functionals]}\r\nnameAppend = sma3nz\r\ncopyInputName = 1\r\nnoPostEOIprocessing = 0\r\nsmaWin = 3\r\nnoZeroSma = 1\r\n\r\n[gemapsv01a_smoSpectralZ:cContourSmoother]\r\nreader.dmLevel = gemapsv01a_lldSetSpectralZ\r\nwriter.dmLevel = gemapsv01a_lldSetSpectralZ_smo\r\n\\{\\cm[bufferModeConf]}\r\nnameAppend = sma3nz\r\ncopyInputName = 1\r\nnoPostEOIprocessing = 0\r\nsmaWin = 3\r\n; non-zero SMA is ok here, as it is inverted with 0's for the voiced parts\r\nnoZeroSma = 1\r\n\r\n[gemapsv01a_smoSpectralNz:cContourSmoother]\r\nreader.dmLevel = gemapsv01a_lldSetSpectralNz\r\nwriter.dmLevel = gemapsv01a_lldSetSpectralNz_smo\r\n\\{\\cm[bufferModeConf]}\r\nnameAppend = sma3nz\r\ncopyInputName = 1\r\nnoPostEOIprocessing = 0\r\nsmaWin = 3\r\nnoZeroSma = 1\r\n\r\n\r\n\r\n\r\n\r\n\r\n"
  },
  {
    "path": "config/gemaps/eGeMAPSv01a.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\r\n///////// > openSMILE configuration file, Geneva feature set <       //////////////////\r\n/////////                                                            //////////////////\r\n///////// (c) 2014 by audEERING                                      //////////////////\r\n/////////     All rights reserved. See file COPYING for details.     //////////////////\r\n///////////////////////////////////////////////////////////////////////////////////////\r\n\r\n;;;;;;; component list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[dataMemory].type=cDataMemory\r\nprintLevelStats=0\r\n\r\n;;;;;;;;;;;;;;;;;;;;;;;;;;;; main section ;;;;;;;;;;;;;;;;;;;;;;;;;;;\r\n\r\n\\{../shared/standard_wave_input.conf.inc}\r\n\\{GeMAPSv01a_core.lld.conf.inc}\r\n\\{eGeMAPSv01a_core.lld.conf.inc}\r\n\\{GeMAPSv01a_core.func.conf.inc}\r\n\\{eGeMAPSv01a_core.func.conf.inc}\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[lldconcat].type=cVectorConcat\r\ninstance[llddeconcat].type=cVectorConcat\r\ninstance[funcconcat].type=cVectorConcat\r\n\r\n[lldconcat:cVectorConcat]\r\nreader.dmLevel = egemapsv01a_lldsetE_smo\r\nwriter.dmLevel = lld\r\nincludeSingleElementFields = 1\r\n\r\n[llddeconcat:cVectorConcat]\r\nreader.dmLevel = gemapsv01a_lldsetF_smo\r\nwriter.dmLevel = lld_de\r\nincludeSingleElementFields = 1\r\n\r\n[funcconcat:cVectorConcat]\r\nreader.dmLevel = gemapsv01a_functionalsF0;gemapsv01a_functionalsLoudness;egemapsv01a_functionalsMeanStddevZ;egemapsv01a_functionalsMeanStddevVoiced;egemapsv01a_functionalsMeanUnvoiced;gemapsv01a_temporalSet;egemapsv01a_leq\r\nwriter.dmLevel = func\r\nincludeSingleElementFields = 1\r\n\r\n\\{../shared/standard_data_output.conf.inc}\r\n\r\n"
  },
  {
    "path": "config/gemaps/eGeMAPSv01a_core.func.conf.inc",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\r\n///////// > openSMILE configuration file, Geneva feature set <       //////////////////\r\n/////////                                                            //////////////////\r\n///////// (c) 2014 by audEERING                                      //////////////////\r\n/////////     All rights reserved. See file COPYING for details.     //////////////////\r\n///////////////////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[egemapsv01a_leqLin].type= cFunctionals\r\ninstance[egemapsv01a_leq].type = cVectorOperation\r\n\r\n;; LEq\r\n[egemapsv01a_leqLin:cFunctionals]\r\nreader.dmLevel = egemapsv01a_energyRMS\r\nwriter.dmLevel = egemapsv01a_leqLin\r\n// nameAppend =\r\npreserveFields = 1\r\n\\{\\cm[bufferModeRbConf]}\r\ncopyInputName = 1\r\n\\{\\cm[frameModeFunctionalsConf]}\r\nnoPostEOIprocessing = 0\r\nfunctionalsEnabled = Means\r\nMeans.amean = 1\r\nMeans.posamean = 0\r\nMeans.absmean = 0\r\nMeans.qmean = 0\r\nMeans.nzamean = 0\r\nMeans.nzabsmean = 0\r\nMeans.nzqmean = 0\r\nMeans.nzgmean = 0\r\nMeans.nnz = 0\r\n\r\n[egemapsv01a_leq:cVectorOperation]\r\nreader.dmLevel = egemapsv01a_leqLin\r\nwriter.dmLevel = egemapsv01a_leq\r\nnameBase = equivalentSoundLevel\r\ncopyInputName = 1\r\nprocessArrayFields = 0\r\noperation = dBp\r\nappendOperationToName = 1\r\n\r\n\r\n\r\n;;;;;;;;;;;;;;;;;;;;; functionals / summaries ;;;;;;;;;;;;;;;\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[egemapsv01a_functionalsMVR].type=cFunctionals\r\ninstance[egemapsv01a_functionalsMeanUV].type=cFunctionals\r\ninstance[egemapsv01a_functionalsMVRVoiced].type = cFunctionals\r\n\r\n[egemapsv01a_functionalsMVR:cFunctionals]\r\nreader.dmLevel = egemapsv01a_lldSetNoF0AndLoudnessZ_smo\r\nwriter.dmLevel = egemapsv01a_functionalsMeanStddevZ\r\n\\{\\cm[bufferModeRbConf]}\r\ncopyInputName = 1\r\n\\{\\cm[frameModeFunctionalsConf]}\r\nfunctionalsEnabled = Moments\r\nMoments.variance = 0\r\nMoments.stddev = 0\r\nMoments.stddevNorm = 2\r\nMoments.skewness = 0\r\nMoments.kurtosis = 0\r\nMoments.amean = 1\r\nnonZeroFuncts = 0\r\nmasterTimeNorm = segment\r\n\r\n[egemapsv01a_functionalsMeanUV:cFunctionals]\r\nreader.dmLevel = egemapsv01a_lldSetSpectralZ_smo\r\nwriter.dmLevel = egemapsv01a_functionalsMeanUnvoiced\r\n\\{\\cm[bufferModeRbConf]}\r\ncopyInputName = 1\r\n\\{\\cm[frameModeFunctionalsConf]}\r\nfunctionalsEnabled = Moments\r\nMoments.variance = 0\r\nMoments.stddev = 0\r\nMoments.stddevNorm = 0\r\nMoments.skewness = 0\r\nMoments.kurtosis = 0\r\nMoments.amean = 1\r\nnonZeroFuncts = 1\r\nmasterTimeNorm = segment\r\n\r\n[egemapsv01a_functionalsMVRVoiced:cFunctionals]\r\nreader.dmLevel = egemapsv01a_lldSetNoF0AndLoudnessNz_smo;egemapsv01a_lldSetSpectralNz_smo\r\nwriter.dmLevel = egemapsv01a_functionalsMeanStddevVoiced\r\n\\{\\cm[bufferModeRbConf]}\r\ncopyInputName = 1\r\n\\{\\cm[frameModeFunctionalsConf]}\r\nfunctionalsEnabled = Moments\r\nMoments.variance = 0\r\nMoments.stddev = 0\r\nMoments.stddevNorm = 2\r\nMoments.skewness = 0\r\nMoments.kurtosis = 0\r\nMoments.amean = 1\r\nnonZeroFuncts = 1\r\nmasterTimeNorm = segment\r\n\r\n\r\n"
  },
  {
    "path": "config/gemaps/eGeMAPSv01a_core.lld.conf.inc",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\r\n///////// > openSMILE configuration file, Geneva feature set <       //////////////////\r\n/////////                                                            //////////////////\r\n///////// (c) 2014 by audEERING                                      //////////////////\r\n/////////     All rights reserved. See file COPYING for details.     //////////////////\r\n///////////////////////////////////////////////////////////////////////////////////////\r\n\r\n;; for LEq\r\n[componentInstances:cComponentManager]\r\ninstance[egemapsv01a_energyRMS].type=cEnergy\r\n\r\n[egemapsv01a_energyRMS:cEnergy]\r\nreader.dmLevel = gemapsv01a_frame25\r\nwriter.dmLevel = egemapsv01a_energyRMS\r\n\\{\\cm[bufferModeConf]}\r\nhtkcompatible = 0\r\nrms = 0\r\nenergy2 = 1\r\nlog = 0\r\n\r\n\r\n;;;;;;;;;;;;;;; spectral\r\n[componentInstances:cComponentManager]\r\ninstance[egemapsv01a_logSpectral_flux].type=cSpectral\r\n\r\n[egemapsv01a_logSpectral_flux:cSpectral]\r\nreader.dmLevel=gemapsv01a_fftmagH25\r\nwriter.dmLevel=egemapsv01a_logSpectral_flux\r\n\\{\\cm[bufferModeRbLagConf]}\r\nflux = 1\r\ncentroid = 0\r\nmaxPos=0\r\nminPos=0\r\nentropy = 0\r\nflatness = 0\r\nharmonicity = 0\r\nsharpness = 0\r\nvariance=0\r\nskewness=0\r\nkurtosis=0\r\nalphaRatio = 0\r\nhammarbergIndex = 0\r\nslope = 0\r\nnormBandEnergies = 1\r\nsquareInput = 1\r\nuseLogSpectrum = 1\r\nfreqRange = 0-5000\r\noldSlopeScale = 0\r\n\r\n;;;;;;;;;; cepstral ;;;;;;;;;;;;;;;;;;;\r\n[componentInstances:cComponentManager]\r\ninstance[egemapsv01a_melspecMfcc].type=cMelspec\r\ninstance[egemapsv01a_mfcc].type=cMfcc\r\n\r\n[egemapsv01a_melspecMfcc:cMelspec]\r\nreader.dmLevel=gemapsv01a_fftmagH25\r\nwriter.dmLevel=egemapsv01a_melspecMfcc\r\ncopyInputName = 1\r\nprocessArrayFields = 1\r\n; htk compatible sample value scaling\r\nhtkcompatible = 1\r\nnBands = 26\r\n; use power spectrum instead of magnitude spectrum\r\nusePower = 1\r\nlofreq = 20\r\nhifreq = 8000\r\nspecScale = mel\r\ninverse = 0\r\n\r\n[egemapsv01a_mfcc:cMfcc]\r\nreader.dmLevel=egemapsv01a_melspecMfcc\r\nwriter.dmLevel=egemapsv01a_mfcc\r\n\\{\\cm[bufferModeRbLagConf]}\r\ncopyInputName = 0\r\nprocessArrayFields = 1\r\nfirstMfcc = 1\r\nlastMfcc  = 4\r\ncepLifter = 22.0\r\nhtkcompatible = 1\r\n\r\n\r\n;;;;;;;;;;;; collecting, filtering, and renaming ;;;;;;;;;;;;;;;;,\r\n\r\n/*\r\nlogSpectral     Hammarberg, AlphaRatio, spectralSlope  0-500, 500-1500\r\nharmonics   H1-H2, H1-A3, HNRlog\r\nlogPitch    F0finalLog\r\njitterShimmer   jitterLocal, shimmerLocal\r\nloudness\r\nformants   F1-3 freq, F1 bandw (check!)\r\nharmonics  F1-3 level relative\r\n*/\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[egemapsv01a_lldSetSelectorE].type=cDataSelector\r\ninstance[egemapsv01a_lldSetSelectorNoF0LoudnZ].type=cDataSelector\r\ninstance[egemapsv01a_lldSetSelectorNoF0LoudnNz].type = cDataSelector\r\ninstance[egemapsv01a_logSpectralVoiced].type = cValbasedSelector\r\ninstance[egemapsv01a_logSpectralUnvoiced].type = cValbasedSelector\r\ninstance[egemapsv01a_lldSetSelectorSpectralNz].type=cDataSelector\r\ninstance[egemapsv01a_lldSetSelectorSpectralZ].type=cDataSelector\r\n\r\n[egemapsv01a_lldSetSelectorE:cDataSelector]\r\nreader.dmLevel = gemapsv01a_loudness;gemapsv01a_logSpectral;egemapsv01a_logSpectral_flux;egemapsv01a_mfcc\r\nwriter.dmLevel = egemapsv01a_lldsetE\r\n\\{\\cm[bufferModeRbConf]}\r\nselected = loudness;pcm_fftMag_alphaRatioDB;pcm_fftMag_hammarbergIndexDB;pcm_fftMag_logSpectralSlopeOfBand0-500;pcm_fftMag_logSpectralSlopeOfBand500-1500;pcm_fftMag_spectralFlux;mfcc[1];mfcc[2];mfcc[3];mfcc[4]\r\nnewNames = Loudness;alphaRatio;hammarbergIndex;slope0-500;slope500-1500;spectralFlux;mfcc1;mfcc2;mfcc3;mfcc4\r\n\r\n[gemapsv01a_lldSetSelectorNoF0LoudnNz:cDataSelector]\r\nreader.dmLevel = gemapsv01a_jitterShimmer;gemapsv01a_harmonics;gemapsv01a_formantsNz\r\nwriter.dmLevel = gemapsv01a_lldSetNoF0AndLoudnessNz\r\n\\{\\cm[bufferModeRbConf]}\r\nselected = jitterLocal;shimmerLocalDB;HarmonicsToNoiseRatioACFLogdB;HarmonicDifferenceLogRelH1-H2;HarmonicDifferenceLogRelH1-A3;formantFreqLpc[1];formantBandwidthLpc[1];FormantAmplitudeByMaxHarmonicLogRelF0[1];formantFreqLpc[2];FormantAmplitudeByMaxHarmonicLogRelF0[2];formantFreqLpc[3];FormantAmplitudeByMaxHarmonicLogRelF0[3]\r\nnewNames = jitterLocal;shimmerLocaldB;HNRdBACF;logRelF0-H1-H2;logRelF0-H1-A3;F1frequency;F1bandwidth;F1amplitudeLogRelF0;F2frequency;F2amplitudeLogRelF0;F3frequency;F3amplitudeLogRelF0\r\n\r\n\r\n[egemapsv01a_lldSetSelectorNoF0LoudnZ:cDataSelector]\r\n ; gemapsv01a_logSpectral\r\nreader.dmLevel = egemapsv01a_logSpectral_flux;egemapsv01a_mfcc\r\nwriter.dmLevel = egemapsv01a_lldSetNoF0AndLoudnessZ\r\n\\{\\cm[bufferModeRbConf]}\r\nselected = pcm_fftMag_spectralFlux;mfcc[1];mfcc[2];mfcc[3];mfcc[4]\r\nnewNames = spectralFlux;mfcc1;mfcc2;mfcc3;mfcc4\r\n\r\n[egemapsv01a_lldSetSelectorNoF0LoudnNz:cDataSelector]\r\nreader.dmLevel = gemapsv01a_jitterShimmer;gemapsv01a_harmonics;gemapsv01a_formantsNz\r\nwriter.dmLevel = egemapsv01a_lldSetNoF0AndLoudnessNz\r\n\\{\\cm[bufferModeRbConf]}\r\nselected = jitterLocal;shimmerLocalDB;HarmonicsToNoiseRatioACFLogdB;HarmonicDifferenceLogRelH1-H2;HarmonicDifferenceLogRelH1-A3;formantFreqLpc[1];formantBandwidthLpc[1];FormantAmplitudeByMaxHarmonicLogRelF0[1];formantFreqLpc[2];formantBandwidthLpc[2];FormantAmplitudeByMaxHarmonicLogRelF0[2];formantFreqLpc[3];formantBandwidthLpc[3];FormantAmplitudeByMaxHarmonicLogRelF0[3]\r\nnewNames = jitterLocal;shimmerLocaldB;HNRdBACF;logRelF0-H1-H2;logRelF0-H1-A3;F1frequency;F1bandwidth;F1amplitudeLogRelF0;F2frequency;F2bandwidth;F2amplitudeLogRelF0;F3frequency;F3bandwidth;F3amplitudeLogRelF0\r\n\r\n// select logspectral and mfcc for voiced sounds\r\n[egemapsv01a_logSpectralVoiced:cValbasedSelector]\r\nreader.dmLevel = gemapsv01a_lld_single_logF0;gemapsv01a_logSpectral;egemapsv01a_logSpectral_flux;egemapsv01a_mfcc\r\nwriter.dmLevel = egemapsv01a_logSpectralVoiced\r\n\\{\\cm[bufferModeRbLagConf]}\r\nidx=0\r\nthreshold=0.000001\r\nremoveIdx=1\r\nzeroVec=1\r\noutputVal=0.0\r\n\r\n// select logspectral and mfcc for voiced sounds\r\n[egemapsv01a_logSpectralUnvoiced:cValbasedSelector]\r\nreader.dmLevel = gemapsv01a_lld_single_logF0;gemapsv01a_logSpectral;egemapsv01a_logSpectral_flux\r\nwriter.dmLevel = egemapsv01a_logSpectralUnvoiced\r\n\\{\\cm[bufferModeRbLagConf]}\r\nidx=0\r\ninvert = 1\r\nthreshold = 0.000001\r\nremoveIdx=1\r\nzeroVec=1\r\noutputVal=0.0\r\n\r\n[egemapsv01a_lldSetSelectorSpectralNz:cDataSelector]\r\nreader.dmLevel = egemapsv01a_logSpectralVoiced\r\nwriter.dmLevel = egemapsv01a_lldSetSpectralNz\r\n\\{\\cm[bufferModeRbConf]}\r\nselected = pcm_fftMag_alphaRatioDB;pcm_fftMag_hammarbergIndexDB;pcm_fftMag_logSpectralSlopeOfBand0-500;pcm_fftMag_logSpectralSlopeOfBand500-1500;pcm_fftMag_spectralFlux;mfcc[1];mfcc[2];mfcc[3];mfcc[4]\r\nnewNames = alphaRatioV;hammarbergIndexV;slopeV0-500;slopeV500-1500;spectralFluxV;mfcc1V;mfcc2V;mfcc3V;mfcc4V\r\n\r\n[egemapsv01a_lldSetSelectorSpectralZ:cDataSelector]\r\nreader.dmLevel = egemapsv01a_logSpectralUnvoiced\r\nwriter.dmLevel = egemapsv01a_lldSetSpectralZ\r\n\\{\\cm[bufferModeRbConf]}\r\nselected = pcm_fftMag_alphaRatioDB;pcm_fftMag_hammarbergIndexDB;pcm_fftMag_logSpectralSlopeOfBand0-500;pcm_fftMag_logSpectralSlopeOfBand500-1500;pcm_fftMag_spectralFlux\r\nnewNames = alphaRatioUV;hammarbergIndexUV;slopeUV0-500;slopeUV500-1500;spectralFluxUV\r\n\r\n\r\n;;;;;;;;;;;;;;;;  smoothing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r\n[componentInstances:cComponentManager]\r\ninstance[egemapsv01a_smoE].type=cContourSmoother\r\ninstance[egemapsv01a_smoNoFLZ].type=cContourSmoother\r\ninstance[egemapsv01a_smoNoF0andLoudnNz].type=cContourSmoother\r\ninstance[egemapsv01a_smoSpectralZ].type=cContourSmoother\r\ninstance[egemapsv01a_smoSpectralNz].type=cContourSmoother\r\n\r\n[egemapsv01a_smoE:cContourSmoother]\r\nreader.dmLevel = egemapsv01a_lldsetE\r\nwriter.dmLevel = egemapsv01a_lldsetE_smo\r\nnameAppend = sma3\r\ncopyInputName = 1\r\nnoPostEOIprocessing = 0\r\nsmaWin = 3\r\nnoZeroSma = 0\r\n\r\n[egemapsv01a_smoNoFLZ:cContourSmoother]\r\nreader.dmLevel = egemapsv01a_lldSetNoF0AndLoudnessZ\r\nwriter.dmLevel = egemapsv01a_lldSetNoF0AndLoudnessZ_smo\r\n\\{\\cm[bufferModeConf]}\r\nnameAppend = sma3\r\ncopyInputName = 1\r\nnoPostEOIprocessing = 0\r\nsmaWin = 3\r\nnoZeroSma = 0\r\n\r\n[egemapsv01a_smoNoF0andLoudnNz:cContourSmoother]\r\nreader.dmLevel = egemapsv01a_lldSetNoF0AndLoudnessNz\r\nwriter.dmLevel = egemapsv01a_lldSetNoF0AndLoudnessNz_smo\r\n\\{\\cm[bufferModeConf]}\r\nnameAppend = sma3nz\r\ncopyInputName = 1\r\nnoPostEOIprocessing = 0\r\nsmaWin = 3\r\nnoZeroSma = 1\r\n\r\n[egemapsv01a_smoSpectralZ:cContourSmoother]\r\nreader.dmLevel = egemapsv01a_lldSetSpectralZ\r\nwriter.dmLevel = egemapsv01a_lldSetSpectralZ_smo\r\n\\{\\cm[bufferModeConf]}\r\nnameAppend = sma3nz\r\ncopyInputName = 1\r\nnoPostEOIprocessing = 0\r\nsmaWin = 3\r\n; non-zero SMA is ok here, as it is inverted with 0's for the voiced parts\r\nnoZeroSma = 1\r\n\r\n[egemapsv01a_smoSpectralNz:cContourSmoother]\r\nreader.dmLevel = egemapsv01a_lldSetSpectralNz\r\nwriter.dmLevel = egemapsv01a_lldSetSpectralNz_smo\r\n\\{\\cm[bufferModeConf]}\r\nnameAppend = sma3nz\r\ncopyInputName = 1\r\nnoPostEOIprocessing = 0\r\nsmaWin = 3\r\nnoZeroSma = 1\r\n"
  },
  {
    "path": "config/gui/visgui.conf",
    "content": "\n;;;;; all the components we require are listed here:\n[componentInstances:cComponentManager]\n // this line configures the default data memory:\ninstance[dataMemory].type=cDataMemory\ninstance[liveIn].type=cPortaudioSource\ninstance[fr1].type=cFramer\ninstance[energy].type=cEnergy\n;instance[gui].type = cSimpleVisualiserGUI\ninstance[gui2].type = cSimpleVisualiserGUI\n\nprintLevelStats=6\nnThreads=1\n\n\n;;;;;;;;;;;;;;;;; below the config sections for the components start ;;;;;;;;;\n\n[liveIn:cPortaudioSource]\nwriter.dmLevel=wave\n; audio buffersize must be > then buffersize of framer to avoid 100% cpu hog\n;audioBuffersize = 2500\nsampleRate=16000\nmonoMixdown=1\n\n\n/////////\n\n\n[fr1:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames\nbuffersize_sec=1.0\nframeSize = 0.0250\nframeStep = 0.010\n\n\n[energy:cEnergy]\nreader.dmLevel=frames\nwriter.dmLevel=energy\nbuffersize_sec=1.0\nnameAppend=energy\nrms=1\nlog=1\n;escaleLog = 0.1\nhtkcompatible=0\n\n\n\n[gui:cSimpleVisualiserGUI]\nreader.dmLevel=energy\naction=movingplot\ninputs=RMSenergy\ninputScale=200.0\ninputOffset=0.0\n\n[gui2:cSimpleVisualiserGUI]\nreader.dmLevel=energy\naction=movingplot\ninputs=LOGenergy\ninputScale=10.0\ninputOffset=10.0\n\n"
  },
  {
    "path": "config/gui/visgui_cepstr.conf",
    "content": "\n;;;;; all the components we require are listed here:\n[componentInstances:cComponentManager]\n // this line configures the default data memory:\ninstance[dataMemory].type=cDataMemory\ninstance[liveIn].type=cPortaudioSource\ninstance[energy].type=cEnergy\ninstance[frame].type=cFramer\ninstance[int].type=cIntensity\ninstance[win].type=cWindower\ninstance[fft].type=cTransformFFT\ninstance[fftmp].type=cFFTmagphase\ninstance[cep].type=cAcf\ninstance[vectorOperation].type=cVectorOperation\ninstance[gui2].type = cSimpleVisualiserGUI\n\n\nprintLevelStats=6\nnThreads=1\n;execDebug=1\n\n\n;;;;;;;;;;;;;;;;; below the config sections for the components start ;;;;;;;;;\n\n[liveIn:cPortaudioSource]\nwriter.dmLevel=wave\n; audio buffersize must be > then buffersize of framer to avoid 100% cpu hog\n;audioBuffersize = 2500\nsampleRate=16000\nmonoMixdown=1\n\n\n/////////\n\n[energy:cEnergy]\nreader.dmLevel=outp\nwriter.dmLevel=energy\nbuffersize_sec=1.0\nnameAppend=energy\nrms=1\nlog=1\n;escaleLog = 0.1\nhtkcompatible=0\n\n\n\n[frame:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=outp\nframeSize = 0.030\nframeStep = 0.020\nframeCenterSpecial = left\n\n[int:cIntensity]\nreader.dmLevel = outp\nwriter.dmLevel = intens\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 1\nintensity = 0\nloudness = 1\n\n[win:cWindower]\nreader.dmLevel=outp\nwriter.dmLevel=win\nwinFunc=gauss\ngain=1.0\nsigma=0.4\n\n[fft:cTransformFFT]\nreader.dmLevel=win\nwriter.dmLevel=fftc\n\n[fftmp:cFFTmagphase]\nreader.dmLevel=fftc\nwriter.dmLevel=fftmag\nnameAppend = fftspec\n\n[cep:cAcf]\nreader.dmLevel=fftmag\nwriter.dmLevel=cepstrum\ncepstrum=1\n\n\n[vectorOperation:cVectorOperation]\nreader.dmLevel = cepstrum\nwriter.dmLevel = logcepstrum\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 1\noperation = exp\nparam1 = 1\nparam2 = 1\nlogfloor = 0.0000001\npowOnlyPos = 0\n\n[gui2:cSimpleVisualiserGUI]\nreader.dmLevel=cepstrum\nmatMultiplier = 1\naction=movingMatplot\nfullVectorAsInput = 1\ninputscaleFullinput = 2\ninputoffsetFullinput = 0.0\n\n"
  },
  {
    "path": "config/gui/visgui_chroma.conf",
    "content": "\n;;;;; all the components we require are listed here:\n[componentInstances:cComponentManager]\n // this line configures the default data memory:\ninstance[dataMemory].type=cDataMemory\ninstance[liveIn].type=cPortaudioSource\ninstance[frame].type=cFramer\ninstance[win].type=cWindower\ninstance[fft].type=cTransformFFT\ninstance[fftmp].type=cFFTmagphase\ninstance[tonespec].type = cTonespec\ninstance[chroma].type = cChroma\ninstance[gui2].type = cSimpleVisualiserGUI\n\n\nprintLevelStats=6\nnThreads=1\n;execDebug=1\n\n\n;;;;;;;;;;;;;;;;; below the config sections for the components start ;;;;;;;;;\n\n[liveIn:cPortaudioSource]\nwriter.dmLevel=wave\n; audio buffersize must be > then buffersize of framer to avoid 100% cpu hog\n;audioBuffersize = 2500\nsampleRate=16000\nmonoMixdown=1\n\n\n/////////\n\n\n[frame:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=outp\nframeSize = 0.064\nframeStep = 0.010\nframeCenterSpecial = left\n\n[win:cWindower]\nreader.dmLevel=outp\nwriter.dmLevel=win\nwinFunc=gauss\ngain=1.0\nsigma=0.4\n\n[fft:cTransformFFT]\nreader.dmLevel=win\nwriter.dmLevel=fftc\n\n[fftmp:cFFTmagphase]\nreader.dmLevel=fftc\nwriter.dmLevel=fftmag\nnameAppend = fftspec\n\n  ;;;; default (template) configuration section for component 'cTonespec' ;;;;\n[tonespec:cTonespec]\nreader.dmLevel = fftmag\nwriter.dmLevel = tonespec\nnameAppend = note\ncopyInputName = 1\nprocessArrayFields = 0\nnOctaves = 6\nfirstNote = 55\nfilterType = gau\nusePower = 1\ndbA = 1\n \n\n  ;;;; default (template) configuration section for component 'cChroma' ;;;;\n[chroma:cChroma]\nreader.dmLevel = tonespec\nwriter.dmLevel = chroma\nnameAppend = chroma\ncopyInputName = 0\nprocessArrayFields = 0\noctaveSize = 12\n \n[gui2:cSimpleVisualiserGUI]\nreader.dmLevel=chroma\nmatMultiplier = 20\naction=movingMatplot\nfullVectorAsInput = 1\ninputscaleFullinput = 300\ninputoffsetFullinput = 0.0\n\n"
  },
  {
    "path": "config/gui/visgui_melspec.conf",
    "content": "\n;;;;; all the components we require are listed here:\n[componentInstances:cComponentManager]\n // this line configures the default data memory:\ninstance[dataMemory].type=cDataMemory\ninstance[liveIn].type=cPortaudioSource\ninstance[energy].type=cEnergy\ninstance[frame].type=cFramer\ninstance[int].type=cIntensity\ninstance[win].type=cWindower\ninstance[fft].type=cTransformFFT\ninstance[fftmp].type=cFFTmagphase\ninstance[scale].type=cSpecScale\ninstance[melspec].type = cMelspec\ninstance[gui2].type = cSimpleVisualiserGUI\n\n\nprintLevelStats=6\nnThreads=1\n;execDebug=1\n\n\n;;;;;;;;;;;;;;;;; below the config sections for the components start ;;;;;;;;;\n\n[liveIn:cPortaudioSource]\nwriter.dmLevel=wave\n; audio buffersize must be > then buffersize of framer to avoid 100% cpu hog\n;audioBuffersize = 2500\nsampleRate=16000\nmonoMixdown=1\n\n\n/////////\n\n[energy:cEnergy]\nreader.dmLevel=outp\nwriter.dmLevel=energy\nbuffersize_sec=1.0\nnameAppend=energy\nrms=1\nlog=1\n;escaleLog = 0.1\nhtkcompatible=0\n\n\n\n[frame:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=outp\nframeSize = 0.030\nframeStep = 0.020\nframeCenterSpecial = left\n\n[int:cIntensity]\nreader.dmLevel = outp\nwriter.dmLevel = intens\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 1\nintensity = 0\nloudness = 1\n\n[win:cWindower]\nreader.dmLevel=outp\nwriter.dmLevel=win\nwinFunc=gauss\ngain=1.0\nsigma=0.4\n\n[fft:cTransformFFT]\nreader.dmLevel=win\nwriter.dmLevel=fftc\n\n[fftmp:cFFTmagphase]\nreader.dmLevel=fftc\nwriter.dmLevel=fftmag\nnameAppend = fftspec\n\n[scale:cSpecScale]\nreader.dmLevel=fftmag\nwriter.dmLevel=hps\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 0\nscale=oct\nsourceScale = lin\n// logScaleBase = 2\n// logSourceScaleBase = 2\n// firstNote = 55\ninterpMethod = spline\nminF = 25\nmaxF = -1\nnPointsTarget = 0\nspecSmooth = 1\nspecEnhance = 1\nauditoryWeighting = 1 \n\n[melspec:cMelspec]\nreader.dmLevel = fftmag\nwriter.dmLevel = mel\nnameAppend = melspec\ncopyInputName = 1\nprocessArrayFields = 1\nnBands = 26\nlofreq = 20\nhifreq = 8000\nusePower = 1\nhtkcompatible = 0\nspecScale = mel\n\n[mfcc:cMfcc]\nreader.dmLevel = mel\nwriter.dmLevel = mfcc\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 1\nfirstMfcc = 1\nlastMfcc = 21\nmelfloor = 0.000000\ncepLifter = 22\nhtkcompatible = 0\n\n[smo:cContourSmoother]\nreader.dmLevel = pitch;intens\nwriter.dmLevel = smo\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n[gui2:cSimpleVisualiserGUI]\nreader.dmLevel=mel\nmatMultiplier = 10\naction=movingMatplot\nfullVectorAsInput = 1\ninputscaleFullinput = 5\ninputoffsetFullinput = 0.0\n\n"
  },
  {
    "path": "config/gui/visgui_mfcc.conf",
    "content": "\n;;;;; all the components we require are listed here:\n[componentInstances:cComponentManager]\n // this line configures the default data memory:\ninstance[dataMemory].type=cDataMemory\ninstance[liveIn].type=cPortaudioSource\ninstance[energy].type=cEnergy\ninstance[frame].type=cFramer\ninstance[int].type=cIntensity\ninstance[win].type=cWindower\ninstance[fft].type=cTransformFFT\ninstance[fftmp].type=cFFTmagphase\ninstance[scale].type=cSpecScale\ninstance[melspec].type = cMelspec\ninstance[mfcc].type = cMfcc\ninstance[gui2].type = cSimpleVisualiserGUI\n\n\nprintLevelStats=6\nnThreads=1\n;execDebug=1\n\n\n;;;;;;;;;;;;;;;;; below the config sections for the components start ;;;;;;;;;\n\n[liveIn:cPortaudioSource]\nwriter.dmLevel=wave\n; audio buffersize must be > then buffersize of framer to avoid 100% cpu hog\n;audioBuffersize = 2500\nsampleRate=16000\nmonoMixdown=1\n\n\n/////////\n\n[energy:cEnergy]\nreader.dmLevel=outp\nwriter.dmLevel=energy\nbuffersize_sec=1.0\nnameAppend=energy\nrms=1\nlog=1\n;escaleLog = 0.1\nhtkcompatible=0\n\n\n\n[frame:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=outp\nframeSize = 0.030\nframeStep = 0.020\nframeCenterSpecial = left\n\n[int:cIntensity]\nreader.dmLevel = outp\nwriter.dmLevel = intens\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 1\nintensity = 0\nloudness = 1\n\n[win:cWindower]\nreader.dmLevel=outp\nwriter.dmLevel=win\nwinFunc=gauss\ngain=1.0\nsigma=0.4\n\n[fft:cTransformFFT]\nreader.dmLevel=win\nwriter.dmLevel=fftc\n\n[fftmp:cFFTmagphase]\nreader.dmLevel=fftc\nwriter.dmLevel=fftmag\nnameAppend = fftspec\n\n[scale:cSpecScale]\nreader.dmLevel=fftmag\nwriter.dmLevel=hps\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 0\nscale=oct\nsourceScale = lin\n// logScaleBase = 2\n// logSourceScaleBase = 2\n// firstNote = 55\ninterpMethod = spline\nminF = 25\nmaxF = -1\nnPointsTarget = 0\nspecSmooth = 1\nspecEnhance = 1\nauditoryWeighting = 1 \n\n[melspec:cMelspec]\nreader.dmLevel = fftmag\nwriter.dmLevel = mel\nnameAppend = melspec\ncopyInputName = 1\nprocessArrayFields = 1\nnBands = 26\nlofreq = 20\nhifreq = 8000\nusePower = 1\nhtkcompatible = 0\nspecScale = mel\n\n[mfcc:cMfcc]\nreader.dmLevel = mel\nwriter.dmLevel = mfcc\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 1\nfirstMfcc = 1\nlastMfcc = 21\nmelfloor = 0.000000\ncepLifter = 22\nhtkcompatible = 0\n\n[smo:cContourSmoother]\nreader.dmLevel = pitch;intens\nwriter.dmLevel = smo\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n[gui2:cSimpleVisualiserGUI]\nreader.dmLevel=mfcc\nmatMultiplier = 10\naction=movingMatplot\nfullVectorAsInput = 1\ninputscaleFullinput = 5\ninputoffsetFullinput = 10.0\n\n"
  },
  {
    "path": "config/gui/visgui_pitch.conf",
    "content": "\n;;;;; all the components we require are listed here:\n[componentInstances:cComponentManager]\n // this line configures the default data memory:\ninstance[dataMemory].type=cDataMemory\ninstance[liveIn].type=cPortaudioSource\n/*\ninstance[fr1].type=cFramer\n*/\ninstance[energy].type=cEnergy\ninstance[frame].type=cFramer\ninstance[int].type=cIntensity\ninstance[win].type=cWindower\ninstance[fft].type=cTransformFFT\ninstance[fftmp].type=cFFTmagphase\ninstance[scale].type=cSpecScale\ninstance[shs].type=cPitchShs\ninstance[smooth].type=cPitchSmoother\ninstance[smo].type=cContourSmoother\n\ninstance[gui2].type = cSimpleVisualiserGUI\n\nprintLevelStats=6\nnThreads=1\n;execDebug=1\n\n\n;;;;;;;;;;;;;;;;; below the config sections for the components start ;;;;;;;;;\n\n[liveIn:cPortaudioSource]\nwriter.dmLevel=wave\n; audio buffersize must be > then buffersize of framer to avoid 100% cpu hog\n;audioBuffersize = 2500\nsampleRate=16000\nmonoMixdown=1\n\n\n/////////\n\n/*\n[fr1:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames\nbuffersize_sec=1.0\nframeSize = 0.0250\nframeStep = 0.010\n\n*/\n[energy:cEnergy]\nreader.dmLevel=outp\nwriter.dmLevel=energy\nbuffersize_sec=1.0\nnameAppend=energy\nrms=1\nlog=1\n;escaleLog = 0.1\nhtkcompatible=0\n\n\n\n[frame:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=outp\nframeSize = 0.070\nframeStep = 0.010\nframeCenterSpecial = left\n\n[int:cIntensity]\nreader.dmLevel = outp\nwriter.dmLevel = intens\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 1\nintensity = 0\nloudness = 1\n\n[win:cWindower]\nreader.dmLevel=outp\nwriter.dmLevel=win\nwinFunc=gauss\ngain=1.0\nsigma=0.4\n\n[fft:cTransformFFT]\nreader.dmLevel=win\nwriter.dmLevel=fftc\n\n[fftmp:cFFTmagphase]\nreader.dmLevel=fftc\nwriter.dmLevel=fftmag\n\n[scale:cSpecScale]\nreader.dmLevel=fftmag\nwriter.dmLevel=hps\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 0\nscale=octave\nsourceScale = lin\n// logScaleBase = 2\n// logSourceScaleBase = 2\n// firstNote = 55\ninterpMethod = spline\nminF = 25\nmaxF = -1\nnPointsTarget = 0\nspecSmooth = 1\nspecEnhance = 1\nauditoryWeighting = 1 \n\n[shs:cPitchShs]\nreader.dmLevel=hps\nwriter.dmLevel=pitchShs\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 0\nmaxPitch = 400\nminPitch = 52\nnCandidates = 6\nscores = 1\nvoicing = 1\nF0C1 = 0\nvoicingC1 = 0\nF0raw = 1\nvoicingClip = 1\nvoicingCutoff = 0.75000\ninputFieldSearch = Mag_octScale\noctaveCorrection = 0\nnHarmonics = 15\ncompressionFactor = 0.850000\n\n[smooth:cPitchSmoother]\nreader.dmLevel=pitchShs\nwriter.dmLevel=pitch\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 0\nmedianFilter0 = 0\npostSmoothing = 0\npostSmoothingMethod = simple\n ; note: octave correction is too agressive, thus we disable it..\noctaveCorrection = 0\nF0final = 1\nF0finalEnv = 0\nno0f0 = 0\nvoicingFinalClipped = 0\nvoicingFinalUnclipped = 1\nF0raw = 0\nvoicingC1 = 0\nvoicingClip = 0\n\n[smo:cContourSmoother]\nreader.dmLevel = pitch;intens\nwriter.dmLevel = smo\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n[gui2:cSimpleVisualiserGUI]\nreader.dmLevel=smo;energy\n;reader.dmLevel=fftmag\naction=moving2dplot\n;action=movingMatplot\n;fullVectorAsInput = 1\ninputs=F0final_sma;LOGenergy\n;inputscaleFullinput = 125.0\n;inputoffsetFullinput = 0.0\ninputScale=0.5;20\ninputOffset=0.0;12.0\ninputColours=blue;red\n\n"
  },
  {
    "path": "config/gui/visgui_pitch_funct.conf",
    "content": "\n;;;;; all the components we require are listed here:\n[componentInstances:cComponentManager]\n // this line configures the default data memory:\ninstance[dataMemory].type=cDataMemory\ninstance[liveIn].type=cPortaudioSource\n/*\ninstance[fr1].type=cFramer\n*/\ninstance[energy].type=cEnergy\ninstance[frame].type=cFramer\ninstance[int].type=cIntensity\ninstance[win].type=cWindower\ninstance[fft].type=cTransformFFT\ninstance[fftmp].type=cFFTmagphase\ninstance[scale].type=cSpecScale\ninstance[shs].type=cPitchShs\ninstance[smooth].type=cPitchSmoother\ninstance[smo].type=cContourSmoother\n\ninstance[gui2].type = cSimpleVisualiserGUI\n\nprintLevelStats=6\nnThreads=1\n;execDebug=1\n\n\n;;;;;;;;;;;;;;;;; below the config sections for the components start ;;;;;;;;;\n\n[liveIn:cPortaudioSource]\nwriter.dmLevel=wave\n; audio buffersize must be > then buffersize of framer to avoid 100% cpu hog\n;audioBuffersize = 2500\nsampleRate=16000\nmonoMixdown=1\n\n\n/////////\n\n/*\n[fr1:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frames\nbuffersize_sec=1.0\nframeSize = 0.0250\nframeStep = 0.010\n\n*/\n[energy:cEnergy]\nreader.dmLevel=outp\nwriter.dmLevel=energy\nbuffersize_sec=1.0\nnameAppend=energy\nrms=1\nlog=1\n;escaleLog = 0.1\nhtkcompatible=0\n\n\n\n[frame:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=outp\nframeSize = 0.070\nframeStep = 0.010\nframeCenterSpecial = left\n\n[int:cIntensity]\nreader.dmLevel = outp\nwriter.dmLevel = intens\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 1\nintensity = 0\nloudness = 1\n\n[win:cWindower]\nreader.dmLevel=outp\nwriter.dmLevel=win\nwinFunc=gauss\ngain=1.0\nsigma=0.4\n\n[fft:cTransformFFT]\nreader.dmLevel=win\nwriter.dmLevel=fftc\n\n[fftmp:cFFTmagphase]\nreader.dmLevel=fftc\nwriter.dmLevel=fftmag\n\n[scale:cSpecScale]\nreader.dmLevel=fftmag\nwriter.dmLevel=hps\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 0\nscale=octave\nsourceScale = lin\n// logScaleBase = 2\n// logSourceScaleBase = 2\n// firstNote = 55\ninterpMethod = spline\nminF = 25\nmaxF = -1\nnPointsTarget = 0\nspecSmooth = 1\nspecEnhance = 1\nauditoryWeighting = 1 \n\n[shs:cPitchShs]\nreader.dmLevel=hps\nwriter.dmLevel=pitchShs\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 0\nmaxPitch = 400\nminPitch = 52\nnCandidates = 6\nscores = 1\nvoicing = 1\nF0C1 = 0\nvoicingC1 = 0\nF0raw = 1\nvoicingClip = 1\nvoicingCutoff = 0.75000\ninputFieldSearch = Mag_octScale\noctaveCorrection = 0\nnHarmonics = 15\ncompressionFactor = 0.850000\n\n[smooth:cPitchSmoother]\nreader.dmLevel=pitchShs\nwriter.dmLevel=pitch\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 0\nmedianFilter0 = 0\npostSmoothing = 0\npostSmoothingMethod = simple\n ; note: octave correction is too agressive, thus we disable it..\noctaveCorrection = 0\nF0final = 1\nF0finalEnv = 0\nno0f0 = 0\nvoicingFinalClipped = 0\nvoicingFinalUnclipped = 1\nF0raw = 0\nvoicingC1 = 0\nvoicingClip = 0\n\n[smo:cContourSmoother]\nreader.dmLevel = pitch;intens\nwriter.dmLevel = smo\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n[gui2:cSimpleVisualiserGUI]\nreader.dmLevel=smo;energy\n;reader.dmLevel=fftmag\naction=moving2dplot\n;action=movingMatplot\n;fullVectorAsInput = 1\ninputs=F0final_sma;LOGenergy\n;inputscaleFullinput = 125.0\n;inputoffsetFullinput = 0.0\ninputScale=0.5;20\ninputOffset=0.0;12.0\ninputColours=blue;red\n\n"
  },
  {
    "path": "config/gui/visgui_semitone.conf",
    "content": "\n;;;;; all the components we require are listed here:\n[componentInstances:cComponentManager]\n // this line configures the default data memory:\ninstance[dataMemory].type=cDataMemory\ninstance[liveIn].type=cPortaudioSource\ninstance[frame].type=cFramer\ninstance[win].type=cWindower\ninstance[fft].type=cTransformFFT\ninstance[fftmp].type=cFFTmagphase\ninstance[tonespec].type = cTonespec\ninstance[chroma].type = cChroma\ninstance[gui2].type = cSimpleVisualiserGUI\n\n\nprintLevelStats=6\nnThreads=1\n;execDebug=1\n\n\n;;;;;;;;;;;;;;;;; below the config sections for the components start ;;;;;;;;;\n\n[liveIn:cPortaudioSource]\nwriter.dmLevel=wave\n; audio buffersize must be > then buffersize of framer to avoid 100% cpu hog\n;audioBuffersize = 2500\nsampleRate=16000\nmonoMixdown=1\n\n\n/////////\n\n\n[frame:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=outp\nframeSize = 0.064\nframeStep = 0.010\nframeCenterSpecial = left\n\n[win:cWindower]\nreader.dmLevel=outp\nwriter.dmLevel=win\nwinFunc=gauss\ngain=1.0\nsigma=0.4\n\n[fft:cTransformFFT]\nreader.dmLevel=win\nwriter.dmLevel=fftc\n\n[fftmp:cFFTmagphase]\nreader.dmLevel=fftc\nwriter.dmLevel=fftmag\nnameAppend = fftspec\n\n  ;;;; default (template) configuration section for component 'cTonespec' ;;;;\n[tonespec:cTonespec]\nreader.dmLevel = fftmag\nwriter.dmLevel = tonespec\nnameAppend = note\ncopyInputName = 1\nprocessArrayFields = 0\nnOctaves = 6\nfirstNote = 55\nfilterType = gau\nusePower = 1\ndbA = 1\n \n\n  ;;;; default (template) configuration section for component 'cChroma' ;;;;\n[chroma:cChroma]\nreader.dmLevel = tonespec\nwriter.dmLevel = chroma\nnameAppend = chroma\ncopyInputName = 0\nprocessArrayFields = 0\noctaveSize = 12\n \n[gui2:cSimpleVisualiserGUI]\nreader.dmLevel=tonespec\nmatMultiplier = 4\naction=movingMatplot\nfullVectorAsInput = 1\ninputscaleFullinput = 40\ninputoffsetFullinput = 0.0\n\n"
  },
  {
    "path": "config/gui/visgui_spect.conf",
    "content": "\n;;;;; all the components we require are listed here:\n[componentInstances:cComponentManager]\n // this line configures the default data memory:\ninstance[dataMemory].type=cDataMemory\ninstance[liveIn].type=cPortaudioSource\ninstance[energy].type=cEnergy\ninstance[frame].type=cFramer\ninstance[int].type=cIntensity\ninstance[win].type=cWindower\ninstance[fft].type=cTransformFFT\ninstance[fftmp].type=cFFTmagphase\n\ninstance[gui2].type = cSimpleVisualiserGUI\n\n\nprintLevelStats=6\nnThreads=1\n;execDebug=1\n\n\n;;;;;;;;;;;;;;;;; below the config sections for the components start ;;;;;;;;;\n\n[liveIn:cPortaudioSource]\nwriter.dmLevel=wave\n; audio buffersize must be > then buffersize of framer to avoid 100% cpu hog\n;audioBuffersize = 2500\nsampleRate=16000\nmonoMixdown=1\n\n\n/////////\n\n[energy:cEnergy]\nreader.dmLevel=outp\nwriter.dmLevel=energy\nbuffersize_sec=1.0\nnameAppend=energy\nrms=1\nlog=1\n;escaleLog = 0.1\nhtkcompatible=0\n\n\n\n[frame:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=outp\nframeSize = 0.030\nframeStep = 0.020\nframeCenterSpecial = left\n\n[int:cIntensity]\nreader.dmLevel = outp\nwriter.dmLevel = intens\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 1\nintensity = 0\nloudness = 1\n\n[win:cWindower]\nreader.dmLevel=outp\nwriter.dmLevel=win\nwinFunc=gauss\ngain=1.0\nsigma=0.4\n\n[fft:cTransformFFT]\nreader.dmLevel=win\nwriter.dmLevel=fftc\n\n[fftmp:cFFTmagphase]\nreader.dmLevel=fftc\nwriter.dmLevel=fftmag\nnameAppend = fftspec\n\n[scale:cSpecScale]\nreader.dmLevel=fftmag\nwriter.dmLevel=hps\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 0\nscale=oct\nsourceScale = lin\n// logScaleBase = 2\n// logSourceScaleBase = 2\n// firstNote = 55\ninterpMethod = spline\nminF = 25\nmaxF = -1\nnPointsTarget = 0\nspecSmooth = 1\nspecEnhance = 1\nauditoryWeighting = 1 \n\n[melspec:cMelspec]\nreader.dmLevel = fftmag\nwriter.dmLevel = mel\nnameAppend = melspec\ncopyInputName = 1\nprocessArrayFields = 1\nnBands = 26\nlofreq = 20\nhifreq = 8000\nusePower = 1\nhtkcompatible = 0\nspecScale = mel\n\n[mfcc:cMfcc]\nreader.dmLevel = mel\nwriter.dmLevel = mfcc\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 1\nfirstMfcc = 1\nlastMfcc = 21\nmelfloor = 0.000000\ncepLifter = 22\nhtkcompatible = 0\n\n[smo:cContourSmoother]\nreader.dmLevel = pitch;intens\nwriter.dmLevel = smo\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n[gui2:cSimpleVisualiserGUI]\nreader.dmLevel=fftmag\nmatMultiplier = 1\naction=movingMatplot\nfullVectorAsInput = 1\ninputscaleFullinput = 80\ninputoffsetFullinput = 0.0\n\n"
  },
  {
    "path": "config/list_audio_devices.conf",
    "content": "\n ///////////////////////////////////////////////////////////////////////////\n  // openSMILE configuration example for listing audio devices //\n ///////////////////////////////////////////////////////////////////////////\n\n\n[componentInstances:cComponentManager]\ninstance[dataMemory].type = cDataMemory\ninstance[portaudioSource].type = cPortaudioSource\nprintLevelStats = 0\nnThreads = 1\n\n[portaudioSource:cPortaudioSource]\nwriter.dmLevel = wave\nmonoMixdown = 0\n ; -1 is the default device\ndevice = \\cm[device{-1}:portaudio device to use for recording, see -listDevices option]\nlistDevices = 1\nsampleRate = \\cm[sampleRate{44100}:set the sampling rate in Hz for recording]\nchannels = \\cm[channels{2}:set the number of audio channels to record]\nnBits = 16\naudioBuffersize_sec = 0.050000\n \n\n\n"
  },
  {
    "path": "config/liveProsodyAcf.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for speech prosody features //////////////////\n/////////   pitch and loudness                                       //////////////////\n/////////                                                            //////////////////\n/////////  * written 2010 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) audEERING UG (haftungsbeschränkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n// This file is not fully up to date and might not work properly.\n// Stay tuned for updates.\n\n;;;;;;; component list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\ninstance[waveIn].type=cPortaudioSource\ninstance[frame].type=cFramer\ninstance[int].type=cIntensity\ninstance[win].type=cWindower\ninstance[fft].type=cTransformFFT\ninstance[fftmp].type=cFFTmagphase\ninstance[scale].type=cSpecScale\ninstance[shs].type=cPitchShs\ninstance[smooth].type=cPitchSmoother\ninstance[smo].type=cContourSmoother\ninstance[csvsink].type=cCsvSink\nprintLevelStats=6\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;; main section ;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[waveIn:cPortaudioSource]\nwriter.dmLevel=wave\nmonoMixdown = 0\n ; -1 is the default device, set listDevices=1 to see a device list\ndevice = -1\nlistDevices = 0\nsampleRate = 16000\n ; if your soundcard only supports stereo (2-channel) recording, \n ; use channels=2 and set monoMixdown=1\nchannels = 1\nnBits = 16\naudioBuffersize_sec = 0.050000\n\n[frame:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=outp\nframeSize = 0.050\nframeStep = 0.010\nframeCenterSpecial = left\n\n[int:cIntensity]\nreader.dmLevel = outp\nwriter.dmLevel = intens\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 1\nintensity = 0\nloudness = 1\n\n[win:cWindower]\nreader.dmLevel=outp\nwriter.dmLevel=win\nwinFunc=gauss\ngain=1.0\nsigma=0.4\n\n[fft:cTransformFFT]\nreader.dmLevel=win\nwriter.dmLevel=fftc\n\n[fftmp:cFFTmagphase]\nreader.dmLevel=fftc\nwriter.dmLevel=fftmag\n\n[scale:cSpecScale]\nreader.dmLevel=fftmag\nwriter.dmLevel=hps\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 0\nscale=octave\nsourceScale = lin\n// logScaleBase = 2\n// logSourceScaleBase = 2\n// firstNote = 55\ninterpMethod = spline\nminF = 25\nmaxF = -1\nnPointsTarget = 0\nspecSmooth = 1\nspecEnhance = 1\nauditoryWeighting = 1 \n\n[shs:cPitchShs]\nreader.dmLevel=hps\nwriter.dmLevel=pitchShs\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 0\nmaxPitch = 620\nminPitch = 52\nnCandidates = 4\nscores = 1\nvoicing = 1\nF0C1 = 0\nvoicingC1 = 0\nF0raw = 1\nvoicingClip = 1\nvoicingCutoff = 0.700000\ninputFieldSearch = Mag_logScale\noctaveCorrection = 0\nnHarmonics = 15\ncompressionFactor = 0.850000\n\n[smooth:cPitchSmoother]\nreader.dmLevel=pitchShs\nwriter.dmLevel=pitch\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 0\nmedianFilter0 = 0\npostSmoothing = 0\npostSmoothingMethod = simple\n ; note: octave correction is too agressive, thus we disable it..\noctaveCorrection = 0\nF0final = 1\nF0finalEnv = 0\nno0f0 = 0\nvoicingFinalClipped = 0\nvoicingFinalUnclipped = 1\nF0raw = 0\nvoicingC1 = 0\nvoicingClip = 0\n\n[smo:cContourSmoother]\nreader.dmLevel = pitch;intens\nwriter.dmLevel = smo\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n[csvsink:cCsvSink]\nreader.dmLevel=smo\nfilename=\\cm[output(O){prosody.csv}:output csv file for pitch data]\nappend=0\n\n"
  },
  {
    "path": "config/mediaeval2012_tum_affect/MediaEval_Audio_IS12based_subwin2.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for MediaEval 2012 TUM contrib. //////////////\n/////////                                                            //////////////////\n/////////  * written 2012 by Felix Weninger, Florian Eyben *         //////////////////\n/////////                                                            //////////////////\n///////// (c) audEERING UG (haftungsbeschränkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\n\n;;;;;;; component list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\nprintLevelStats=0\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;; main section ;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[waveIn].type=cWaveSource\n\n[waveIn:cWaveSource]\nwriter.dmLevel=wave\nfilename=\\cm[inputfile(I){test.wav}:name of input file]\nmonoMixdown=1\nstart=\\cm[start(S){0}:segment start in seconds]\nend=\\cm[end(E){-1}:segment end in seconds, -1 for end]\n\n\n;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[frame60].type=cFramer\ninstance[win60].type=cWindower\ninstance[fft60].type=cTransformFFT\ninstance[fftmp60].type=cFFTmagphase\n\n[frame60:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frame60\nframeSize = 0.060\nframeStep = 0.010\nframeCenterSpecial = left\n\n\n[win60:cWindower]\nreader.dmLevel=frame60\nwriter.dmLevel=winG60\nwinFunc=gauss\ngain=1.0\nsigma=0.4\n\n[fft60:cTransformFFT]\nreader.dmLevel=winG60\nwriter.dmLevel=fftcG60\n\n[fftmp60:cFFTmagphase]\nreader.dmLevel=fftcG60\nwriter.dmLevel=fftmagG60\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[frame25].type=cFramer\ninstance[pe25].type=cVectorPreemphasis\ninstance[win25].type=cWindower\ninstance[fft25].type=cTransformFFT\ninstance[fftmp25].type=cFFTmagphase\n\n[frame25:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frame25\nframeSize = 0.025\nframeStep = 0.005\nframeCenterSpecial = left\n\n[pe25:cVectorPreemphasis]\nreader.dmLevel=frame25\nwriter.dmLevel=frame25pe\nk=0.97\nde=0\n\n[win25:cWindower]\nreader.dmLevel=frame25\nwriter.dmLevel=winH25\nwinFunc=hamming\n\n[fft25:cTransformFFT]\nreader.dmLevel=winH25\nwriter.dmLevel=fftcH25\n\n[fftmp25:cFFTmagphase]\nreader.dmLevel=fftcH25\nwriter.dmLevel=fftmagH25\n\n\n\n;;;;;;;;;;;;;;;;;;;;; Energy / loudness\n\n\n[componentInstances:cComponentManager]\ninstance[energy].type=cEnergy\ninstance[melspec1].type=cMelspec\ninstance[audspec].type=cPlp\ninstance[audspecRasta].type=cPlp\ninstance[audspecSum].type=cVectorOperation\ninstance[audspecRastaSum].type=cVectorOperation\n\n\n[energy:cEnergy]\nreader.dmLevel = frame25\nwriter.dmLevel = energy\nlog=1\nrms=0\n\n\n[melspec1:cMelspec]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=melspec1\n; htk compatible sample value scaling\nhtkcompatible = 0\nnBands = 28\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 20\nhifreq = 16000\nspecScale = mel\n\n; perform auditory weighting of spectrum\n[audspec:cPlp]\nreader.dmLevel=melspec1\nwriter.dmLevel=audspec\nfirstCC = 0\nlpOrder = 5\ncepLifter = 22\ncompression = 0.33\nhtkcompatible = 0 \ndoIDFT = 0\ndoLpToCeps = 0\ndoLP = 0\ndoInvLog = 0\ndoAud = 1\ndoLog = 0\nnewRASTA=0\nRASTA=0\n\n; perform RASTA style filtering of auditory spectra\n[audspecRasta:cPlp]\nreader.dmLevel=melspec1\nwriter.dmLevel=audspecRasta\nnameAppend = Rfilt\nfirstCC = 0\nlpOrder = 5\ncepLifter = 22\ncompression = 0.33\nhtkcompatible = 0 \ndoIDFT = 0\ndoLpToCeps = 0\ndoLP = 0\ndoInvLog = 0\ndoAud = 1\ndoLog = 0\nnewRASTA=1\nRASTA=0\n\n[audspecSum:cVectorOperation]\nreader.dmLevel = audspec\nwriter.dmLevel = audspecSum\n// nameAppend = \ncopyInputName = 1\nprocessArrayFields = 0\noperation = ll1\nnameBase = audspec\n\n[audspecRastaSum:cVectorOperation]\nreader.dmLevel = audspecRasta\nwriter.dmLevel = audspecRastaSum\n// nameAppend = \ncopyInputName = 1\nprocessArrayFields = 0\noperation = ll1\nnameBase = audspecRasta\n\n;;;;;;;;;;;;;;; spectral\n\n[componentInstances:cComponentManager]\ninstance[spectral].type=cSpectral\n\n\n[spectral:cSpectral]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=spectral\nbands[0]=40-150\nbands[1]=250-650\nbands[2]=1000-4000\nbands[3]=5000-15000\nrollOff[0] = 0.25\nrollOff[1] = 0.50\nrollOff[2] = 0.75\nrollOff[3] = 0.90\nflux=1\ncentroid=1\nmaxPos=0\nminPos=0\nentropy=1\nvariance=1\nskewness=1\nkurtosis=1\nslope=1\nharmonicity=1\nsharpness=1\n\n\n;;;;;;;;;;;;;;; mfcc\n\n[componentInstances:cComponentManager]\ninstance[melspecMfcc].type=cMelspec\ninstance[mfcc].type=cMfcc\n\n[melspecMfcc:cMelspec]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=melspecMfcc\ncopyInputName = 1\nprocessArrayFields = 1\n; htk compatible sample value scaling\nhtkcompatible = 1\nnBands = 28\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 20\nhifreq = 16000\nspecScale = mel\ninverse = 0\n\n[mfcc:cMfcc]\nreader.dmLevel=melspecMfcc\nwriter.dmLevel=mfcc1_12\ncopyInputName = 1\nprocessArrayFields = 1\nfirstMfcc = 1\nlastMfcc  = 16\ncepLifter = 22.0\nhtkcompatible = 1\n\n\n;;;;;;;;;;;;;;;;  zcr\n\n[componentInstances:cComponentManager]\ninstance[mzcr].type=cMZcr\n\n[mzcr:cMZcr]\nreader.dmLevel = frame25\nwriter.dmLevel = zcr\ncopyInputName = 1\nprocessArrayFields = 1\nzcr = 1\nmcr = 0\namax = 0\nmaxmin = 0\ndc = 0\n\n\n;;;;;;;;;;;;;;;;;;;; smoothing\n\n[componentInstances:cComponentManager]\ninstance[smoA].type=cContourSmoother\ninstance[smoB].type=cContourSmoother\n\n[smoA:cContourSmoother]\nreader.dmLevel = audspecSum;audspecRastaSum;energy;zcr\nwriter.dmLevel = lldA_smo\nbuffersize_sec = 16.0\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n[smoB:cContourSmoother]\nreader.dmLevel = spectral;mfcc1_12\nwriter.dmLevel = lldB_smo\nbuffersize_sec = 16.0\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n;;;;;;;;; deltas\n[componentInstances:cComponentManager]\ninstance[deA].type=cDeltaRegression\ninstance[deB].type=cDeltaRegression\n\n[deA:cDeltaRegression]\nreader.dmLevel = lldA_smo\nwriter.dmLevel = lldA_smo_de\nbuffersize_sec = 16.0\n\n[deB:cDeltaRegression]\nreader.dmLevel = lldB_smo\nwriter.dmLevel = lldB_smo_de\nbuffersize_sec = 16.0\n\n;;;;;;;;; functionals / statistics\n\n\n[componentInstances:cComponentManager]\ninstance[functionalsA].type=cFunctionals\n;instance[functionalsB].type=cFunctionals\n\n; functionals for energy related lld\n[functionalsA:cFunctionals]\nreader.dmLevel = lldA_smo;lldA_smo_de;lldB_smo;lldB_smo_de\nwriter.dmLevel = functionalsA\n// nameAppend = \ncopyInputName = 1\n;frameMode = full\n;; TODO: debug, what happens when allowLastFrameIncomplete = 0 ... !\nallowLastFrameIncomplete = 1\nframeSize = 2.0\nframeStep = 2.0\nframeCenterSpecial = left\nnoPostEOIprocessing = 0\n\nfunctionalsEnabled = Means ; Extremes ; Peaks2 ; Regression ; Percentiles ; Moments ; Times ;  Lpc\n\nMeans.amean = 1\nMeans.rqmean = 1\nMeans.absmean = 0\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.flatness = 1\nMeans.norm = segment\n\nExtremes.max = 0\nExtremes.min = 0\nExtremes.maxpos = 1\nExtremes.minpos = 1\nExtremes.maxameandist = 0\nExtremes.minameandist = 0\n\nRegression.linregc1 = 1\nRegression.linregc2 = 1\nRegression.linregerrA = 0\nRegression.linregerrQ = 1\nRegression.qregc1 = 1\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 0\nRegression.qregerrQ = 1\nRegression.oldBuggyQerr = 0\nRegression.centroid = 1\nRegression.normRegCoeff = 0\n\nPeaks2.numPeaks = 0\nPeaks2.meanPeakDist = 1\nPeaks2.meanPeakDistDelta = 0\nPeaks2.peakDistStddev = 1\nPeaks2.peakRangeAbs = 1\nPeaks2.peakRangeRel = 1\nPeaks2.peakMeanAbs = 1\nPeaks2.peakMeanMeanDist = 1\nPeaks2.peakMeanRel = 1\nPeaks2.ptpAmpMeanAbs = 0\nPeaks2.ptpAmpMeanRel = 0\nPeaks2.ptpAmpStddevAbs = 0\nPeaks2.ptpAmpStddevRel = 0\nPeaks2.minRangeAbs = 0\nPeaks2.minRangeRel = 1\nPeaks2.minMeanAbs = 0\nPeaks2.minMeanMeanDist = 0\nPeaks2.minMeanRel = 0\nPeaks2.mtmAmpMeanAbs = 0\nPeaks2.mtmAmpMeanRel = 0\nPeaks2.mtmAmpStddevAbs = 0\nPeaks2.mtmAmpStddevRel = 0\nPeaks2.meanRisingSlope = 1\nPeaks2.maxRisingSlope = 1\nPeaks2.minRisingSlope = 1\nPeaks2.stddevRisingSlope = 1\nPeaks2.meanFallingSlope = 1\nPeaks2.maxFallingSlope = 1\nPeaks2.minFallingSlope = 1\nPeaks2.stddevFallingSlope = 1\nPeaks2.norm = seconds\nPeaks2.relThresh = 0.100000\nPeaks2.dynRelThresh = 0\n;Peaks2.posDbgOutp = minmax.txt\nPeaks2.posDbgAppend = 0\nPeaks2.consoleDbg = 0\nPeaks2.noClearPeakList = 0\n\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\n\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\n\nTimes.upleveltime25 = 0\nTimes.downleveltime25 = 1\nTimes.upleveltime50 = 0\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 1\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 1\nTimes.buggySecNorm = 0\nTimes.norm = segment\n\nLpc.lpGain = 1\nLpc.lpc = 1\nLpc.firstCoeff = 0\nLpc.order = 5\n\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n\n\n\n;;;;;;;;; output all features....\n\n[componentInstances:cComponentManager]\ninstance[arffsink].type=cArffSink\n\n[arffsink:cArffSink]\nreader.dmLevel=functionalsA\nfilename=\\cm[output(O){output.arff}:output arff file for feature data]\nappend=1\nframeIndex=1\nframeTime=0\nrelation=MediaEval_FT\ninstanceName=\\cm[instName{null}:instance name]\n\\{arff_targets.conf}\n\n"
  },
  {
    "path": "config/mediaeval2012_tum_affect/MediaEval_Audio_IS12based_subwin2_step0.5.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for MediaEval 2012 TUM contrib. //////////////\n/////////                                                            //////////////////\n/////////  * written 2012 by Felix Weninger, Florian Eyben *         //////////////////\n/////////                                                            //////////////////\n///////// (c) audEERING UG (haftungsbeschränkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\n\n;;;;;;; component list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\nprintLevelStats=0\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;; main section ;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[waveIn].type=cWaveSource\n\n[waveIn:cWaveSource]\nwriter.dmLevel=wave\nfilename=\\cm[inputfile(I){test.wav}:name of input file]\nmonoMixdown=1\nstart=\\cm[start(S){0}:segment start in seconds]\nend=\\cm[end(E){-1}:segment end in seconds, -1 for end]\n\n\n;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[frame60].type=cFramer\ninstance[win60].type=cWindower\ninstance[fft60].type=cTransformFFT\ninstance[fftmp60].type=cFFTmagphase\n\n[frame60:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frame60\nframeSize = 0.060\nframeStep = 0.010\nframeCenterSpecial = left\n\n\n[win60:cWindower]\nreader.dmLevel=frame60\nwriter.dmLevel=winG60\nwinFunc=gauss\ngain=1.0\nsigma=0.4\n\n[fft60:cTransformFFT]\nreader.dmLevel=winG60\nwriter.dmLevel=fftcG60\n\n[fftmp60:cFFTmagphase]\nreader.dmLevel=fftcG60\nwriter.dmLevel=fftmagG60\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[frame25].type=cFramer\ninstance[pe25].type=cVectorPreemphasis\ninstance[win25].type=cWindower\ninstance[fft25].type=cTransformFFT\ninstance[fftmp25].type=cFFTmagphase\n\n[frame25:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frame25\nframeSize = 0.025\nframeStep = 0.005\nframeCenterSpecial = left\n\n[pe25:cVectorPreemphasis]\nreader.dmLevel=frame25\nwriter.dmLevel=frame25pe\nk=0.97\nde=0\n\n[win25:cWindower]\nreader.dmLevel=frame25\nwriter.dmLevel=winH25\nwinFunc=hamming\n\n[fft25:cTransformFFT]\nreader.dmLevel=winH25\nwriter.dmLevel=fftcH25\n\n[fftmp25:cFFTmagphase]\nreader.dmLevel=fftcH25\nwriter.dmLevel=fftmagH25\n\n\n\n;;;;;;;;;;;;;;;;;;;;; Energy / loudness\n\n\n[componentInstances:cComponentManager]\ninstance[energy].type=cEnergy\ninstance[melspec1].type=cMelspec\ninstance[audspec].type=cPlp\ninstance[audspecRasta].type=cPlp\ninstance[audspecSum].type=cVectorOperation\ninstance[audspecRastaSum].type=cVectorOperation\n\n\n[energy:cEnergy]\nreader.dmLevel = frame25\nwriter.dmLevel = energy\nlog=1\nrms=0\n\n\n[melspec1:cMelspec]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=melspec1\n; htk compatible sample value scaling\nhtkcompatible = 0\nnBands = 28\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 20\nhifreq = 16000\nspecScale = mel\n\n; perform auditory weighting of spectrum\n[audspec:cPlp]\nreader.dmLevel=melspec1\nwriter.dmLevel=audspec\nfirstCC = 0\nlpOrder = 5\ncepLifter = 22\ncompression = 0.33\nhtkcompatible = 0 \ndoIDFT = 0\ndoLpToCeps = 0\ndoLP = 0\ndoInvLog = 0\ndoAud = 1\ndoLog = 0\nnewRASTA=0\nRASTA=0\n\n; perform RASTA style filtering of auditory spectra\n[audspecRasta:cPlp]\nreader.dmLevel=melspec1\nwriter.dmLevel=audspecRasta\nnameAppend = Rfilt\nfirstCC = 0\nlpOrder = 5\ncepLifter = 22\ncompression = 0.33\nhtkcompatible = 0 \ndoIDFT = 0\ndoLpToCeps = 0\ndoLP = 0\ndoInvLog = 0\ndoAud = 1\ndoLog = 0\nnewRASTA=1\nRASTA=0\n\n[audspecSum:cVectorOperation]\nreader.dmLevel = audspec\nwriter.dmLevel = audspecSum\n// nameAppend = \ncopyInputName = 1\nprocessArrayFields = 0\noperation = ll1\nnameBase = audspec\n\n[audspecRastaSum:cVectorOperation]\nreader.dmLevel = audspecRasta\nwriter.dmLevel = audspecRastaSum\n// nameAppend = \ncopyInputName = 1\nprocessArrayFields = 0\noperation = ll1\nnameBase = audspecRasta\n\n;;;;;;;;;;;;;;; spectral\n\n[componentInstances:cComponentManager]\ninstance[spectral].type=cSpectral\n\n\n[spectral:cSpectral]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=spectral\nbands[0]=40-150\nbands[1]=250-650\nbands[2]=1000-4000\nbands[3]=5000-15000\nrollOff[0] = 0.25\nrollOff[1] = 0.50\nrollOff[2] = 0.75\nrollOff[3] = 0.90\nflux=1\ncentroid=1\nmaxPos=0\nminPos=0\nentropy=1\nvariance=1\nskewness=1\nkurtosis=1\nslope=1\nharmonicity=1\nsharpness=1\n\n\n;;;;;;;;;;;;;;; mfcc\n\n[componentInstances:cComponentManager]\ninstance[melspecMfcc].type=cMelspec\ninstance[mfcc].type=cMfcc\n\n[melspecMfcc:cMelspec]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=melspecMfcc\ncopyInputName = 1\nprocessArrayFields = 1\n; htk compatible sample value scaling\nhtkcompatible = 1\nnBands = 28\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 20\nhifreq = 16000\nspecScale = mel\ninverse = 0\n\n[mfcc:cMfcc]\nreader.dmLevel=melspecMfcc\nwriter.dmLevel=mfcc1_12\ncopyInputName = 1\nprocessArrayFields = 1\nfirstMfcc = 1\nlastMfcc  = 16\ncepLifter = 22.0\nhtkcompatible = 1\n\n\n;;;;;;;;;;;;;;;;  zcr\n\n[componentInstances:cComponentManager]\ninstance[mzcr].type=cMZcr\n\n[mzcr:cMZcr]\nreader.dmLevel = frame25\nwriter.dmLevel = zcr\ncopyInputName = 1\nprocessArrayFields = 1\nzcr = 1\nmcr = 0\namax = 0\nmaxmin = 0\ndc = 0\n\n\n;;;;;;;;;;;;;;;;;;;; smoothing\n\n[componentInstances:cComponentManager]\ninstance[smoA].type=cContourSmoother\ninstance[smoB].type=cContourSmoother\n\n[smoA:cContourSmoother]\nreader.dmLevel = audspecSum;audspecRastaSum;energy;zcr\nwriter.dmLevel = lldA_smo\nbuffersize_sec = 16.0\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n[smoB:cContourSmoother]\nreader.dmLevel = spectral;mfcc1_12\nwriter.dmLevel = lldB_smo\nbuffersize_sec = 16.0\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n;;;;;;;;; deltas\n[componentInstances:cComponentManager]\ninstance[deA].type=cDeltaRegression\ninstance[deB].type=cDeltaRegression\n\n[deA:cDeltaRegression]\nreader.dmLevel = lldA_smo\nwriter.dmLevel = lldA_smo_de\nbuffersize_sec = 16.0\n\n[deB:cDeltaRegression]\nreader.dmLevel = lldB_smo\nwriter.dmLevel = lldB_smo_de\nbuffersize_sec = 16.0\n\n;;;;;;;;; functionals / statistics\n\n\n[componentInstances:cComponentManager]\ninstance[functionalsA].type=cFunctionals\n;instance[functionalsB].type=cFunctionals\n\n; functionals for energy related lld\n[functionalsA:cFunctionals]\nreader.dmLevel = lldA_smo;lldA_smo_de;lldB_smo;lldB_smo_de\nwriter.dmLevel = functionalsA\n// nameAppend = \ncopyInputName = 1\n;frameMode = full\n;; TODO: debug, what happens when allowLastFrameIncomplete = 0 ... !\nallowLastFrameIncomplete = 1\nframeSize = 2.0\nframeStep = 0.5\nframeCenterSpecial = left\nnoPostEOIprocessing = 0\n\nfunctionalsEnabled = Means ; Extremes ; Peaks2 ; Regression ; Percentiles ; Moments ; Times ;  Lpc\n\nMeans.amean = 1\nMeans.rqmean = 1\nMeans.absmean = 0\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.flatness = 1\nMeans.norm = segment\n\nExtremes.max = 0\nExtremes.min = 0\nExtremes.maxpos = 1\nExtremes.minpos = 1\nExtremes.maxameandist = 0\nExtremes.minameandist = 0\n\nRegression.linregc1 = 1\nRegression.linregc2 = 1\nRegression.linregerrA = 0\nRegression.linregerrQ = 1\nRegression.qregc1 = 1\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 0\nRegression.qregerrQ = 1\nRegression.oldBuggyQerr = 0\nRegression.centroid = 1\nRegression.normRegCoeff = 0\n\nPeaks2.numPeaks = 0\nPeaks2.meanPeakDist = 1\nPeaks2.meanPeakDistDelta = 0\nPeaks2.peakDistStddev = 1\nPeaks2.peakRangeAbs = 1\nPeaks2.peakRangeRel = 1\nPeaks2.peakMeanAbs = 1\nPeaks2.peakMeanMeanDist = 1\nPeaks2.peakMeanRel = 1\nPeaks2.ptpAmpMeanAbs = 0\nPeaks2.ptpAmpMeanRel = 0\nPeaks2.ptpAmpStddevAbs = 0\nPeaks2.ptpAmpStddevRel = 0\nPeaks2.minRangeAbs = 0\nPeaks2.minRangeRel = 1\nPeaks2.minMeanAbs = 0\nPeaks2.minMeanMeanDist = 0\nPeaks2.minMeanRel = 0\nPeaks2.mtmAmpMeanAbs = 0\nPeaks2.mtmAmpMeanRel = 0\nPeaks2.mtmAmpStddevAbs = 0\nPeaks2.mtmAmpStddevRel = 0\nPeaks2.meanRisingSlope = 1\nPeaks2.maxRisingSlope = 1\nPeaks2.minRisingSlope = 1\nPeaks2.stddevRisingSlope = 1\nPeaks2.meanFallingSlope = 1\nPeaks2.maxFallingSlope = 1\nPeaks2.minFallingSlope = 1\nPeaks2.stddevFallingSlope = 1\nPeaks2.norm = seconds\nPeaks2.relThresh = 0.100000\nPeaks2.dynRelThresh = 0\n;Peaks2.posDbgOutp = minmax.txt\nPeaks2.posDbgAppend = 0\nPeaks2.consoleDbg = 0\nPeaks2.noClearPeakList = 0\n\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\n\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\n\nTimes.upleveltime25 = 0\nTimes.downleveltime25 = 1\nTimes.upleveltime50 = 0\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 1\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 1\nTimes.buggySecNorm = 0\nTimes.norm = segment\n\nLpc.lpGain = 1\nLpc.lpc = 1\nLpc.firstCoeff = 0\nLpc.order = 5\n\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n\n\n\n;;;;;;;;; output all features....\n\n[componentInstances:cComponentManager]\ninstance[arffsink].type=cArffSink\n;instance[dbg].type=cArffSink\n\n[arffsink:cArffSink]\n;reader.dmLevel=lld_nzsmo;lldA_smo;lldB_smo\nreader.dmLevel=functionalsA\nfilename=\\cm[output(O){output.arff}:output arff file for feature data]\nappend=1\nframeIndex=1\nframeTime=0\nrelation=MediaEval_FT\ninstanceName=\\cm[instName{null}:instance name]\n\\{arff_targets.conf}\n\n"
  },
  {
    "path": "config/mediaeval2012_tum_affect/MediaEval_VideoFunctionals.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for MediaEval 2012 TUM contrib. //////////////\n/////////                                                            //////////////////\n/////////  * written 2012 by Felix Weninger, Florian Eyben *         //////////////////\n/////////                                                            //////////////////\n///////// (c) audEERING UG (haftungsbeschränkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n// Summarizes externally extracted video features\n\n;;;;;;; component list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\nprintLevelStats=0\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;; main section ;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[csvIn].type=cCsvSource\ninstance[dsel].type=cDataSelector\n\n[csvIn:cCsvSource]\nwriter.dmLevel=lld0\nwriter.levelconf.isRb = 0\nwriter.levelconf.growDyn = 1\nwriter.levelconf.T = 0.04\nfilename=\\cm[inputfile(I){test.csv}:name of input file]\nstart=\\cm[start(S){1}:start line]\nend=\\cm[end(E){-1}:end line]\n\n[dsel:cDataSelector]\nreader.dmLevel = lld0\nwriter.dmLevel = lld\n// nameAppend = \ncopyInputName = 1\n// selFile = \n// selected[] = \nselectedRange[0] = 2-$\n// newNames[] = \nelementMode = 1\ndummyMode = 0\n\n;;;;;;;;; deltas\n[componentInstances:cComponentManager]\ninstance[deA].type=cDeltaRegression\n\n[deA:cDeltaRegression]\nreader.dmLevel = lld\nwriter.dmLevel = lld_de\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n;;;;;;;;; functionals / statistics\n\n\n[componentInstances:cComponentManager]\ninstance[functionalsA].type=cFunctionals\n\n; functionals for energy related lld\n[functionalsA:cFunctionals]\nreader.dmLevel = lld;lld_de\nwriter.dmLevel = functionals\n// nameAppend = \ncopyInputName = 1\nframeMode = full\nframeSize = 0\nframeStep = 0\nframeCenterSpecial = left\n\nfunctionalsEnabled = Means; Peaks2 ; Percentiles ; Moments \n\nMeans.amean = 1\nMeans.rqmean = 1\nMeans.absmean = 0\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.flatness = 1\nMeans.norm = segment\n\nPeaks2.numPeaks = 0\nPeaks2.meanPeakDist = 0\nPeaks2.meanPeakDistDelta = 0\nPeaks2.peakDistStddev = 0\nPeaks2.peakRangeAbs = 0\nPeaks2.peakRangeRel = 0\nPeaks2.peakMeanAbs = 1\nPeaks2.peakMeanMeanDist = 0\nPeaks2.peakMeanRel = 0\nPeaks2.ptpAmpMeanAbs = 0\nPeaks2.ptpAmpMeanRel = 0\nPeaks2.ptpAmpStddevAbs = 0\nPeaks2.ptpAmpStddevRel = 0\nPeaks2.minRangeAbs = 0\nPeaks2.minRangeRel = 0\nPeaks2.minMeanAbs = 1\nPeaks2.minMeanMeanDist = 0\nPeaks2.minMeanRel = 0\nPeaks2.mtmAmpMeanAbs = 0\nPeaks2.mtmAmpMeanRel = 0\nPeaks2.mtmAmpStddevAbs = 0\nPeaks2.mtmAmpStddevRel = 0\nPeaks2.meanRisingSlope = 1\nPeaks2.maxRisingSlope = 1\nPeaks2.minRisingSlope = 1\nPeaks2.stddevRisingSlope = 0\nPeaks2.meanFallingSlope = 1\nPeaks2.maxFallingSlope = 1\nPeaks2.minFallingSlope = 1\nPeaks2.stddevFallingSlope = 0\nPeaks2.norm = seconds\nPeaks2.relThresh = 0.100000\nPeaks2.dynRelThresh = 0\n;Peaks2.posDbgOutp = minmax.txt\nPeaks2.posDbgAppend = 0\nPeaks2.consoleDbg = 0\n\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 0\nMoments.kurtosis = 0\nMoments.amean = 0\n\nPercentiles.quartiles = 0\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\n\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n\n\n\n;;;;;;;;; output all features....\n\n[componentInstances:cComponentManager]\ninstance[arffsink].type=cArffSink\n\n[arffsink:cArffSink]\nreader.dmLevel=functionals\nfilename=\\cm[output(O){output.arff}:output arff file for feature data]\nappend=1\nframeIndex=0\nframeTime=0\nrelation=MediaEval_FT_VideoNico1\ninstanceName=\\cm[instName{null}:instance name]\n\\{arff_targets.conf}\n\n"
  },
  {
    "path": "config/mediaeval2012_tum_affect/MediaEval_VideoFunctionals_subwin.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for MediaEval 2012 TUM contrib. //////////////\n/////////                                                            //////////////////\n/////////  * written 2012 by Felix Weninger, Florian Eyben *         //////////////////\n/////////                                                            //////////////////\n///////// (c) audEERING UG (haftungsbeschränkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n// Summarizes externally extracted video features\n\n\n;;;;;;; component list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\nprintLevelStats=0\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;; main section ;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[csvIn].type=cCsvSource\n\n[csvIn:cCsvSource]\nwriter.dmLevel=lld\nwriter.levelconf.isRb = 0\nwriter.levelconf.growDyn = 1\nwriter.levelconf.T = 0.04\nfilename=\\cm[inputfile(I){test.csv}:name of input file]\nstart=\\cm[start(S){1}:start line]\nend=\\cm[end(E){-1}:end line]\n\n;;;;;;;;; deltas\n[componentInstances:cComponentManager]\ninstance[deA].type=cDeltaRegression\n\n[deA:cDeltaRegression]\nreader.dmLevel = lld\nwriter.dmLevel = lld_de\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n;;;;;;;;; functionals / statistics\n\n\n[componentInstances:cComponentManager]\ninstance[functionalsA].type=cFunctionals\n\n; functionals for energy related lld\n[functionalsA:cFunctionals]\nreader.dmLevel = lld;lld_de\nwriter.dmLevel = functionals\n// nameAppend = \ncopyInputName = 1\nframeMode = full\nframeSize = 4.0\nframeStep = 4.0\nframeCenterSpecial = left\nnoPostEOIprocessing = 0\nallowLastFrameIncomplete = 1\n\nfunctionalsEnabled = Means ; Extremes ; Peaks2 ; Regression ; Percentiles ; Moments ; Times ;  Lpc\n\nMeans.amean = 1\nMeans.rqmean = 1\nMeans.absmean = 0\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.flatness = 1\nMeans.norm = segment\n\nExtremes.max = 0\nExtremes.min = 0\nExtremes.maxpos = 1\nExtremes.minpos = 1\nExtremes.maxameandist = 0\nExtremes.minameandist = 0\n\nRegression.linregc1 = 1\nRegression.linregc2 = 1\nRegression.linregerrA = 0\nRegression.linregerrQ = 1\nRegression.qregc1 = 1\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 0\nRegression.qregerrQ = 1\nRegression.oldBuggyQerr = 0\nRegression.centroid = 1\nRegression.normRegCoeff = 0\n\nPeaks2.numPeaks = 0\nPeaks2.meanPeakDist = 1\nPeaks2.meanPeakDistDelta = 0\nPeaks2.peakDistStddev = 1\nPeaks2.peakRangeAbs = 1\nPeaks2.peakRangeRel = 1\nPeaks2.peakMeanAbs = 1\nPeaks2.peakMeanMeanDist = 1\nPeaks2.peakMeanRel = 1\nPeaks2.ptpAmpMeanAbs = 0\nPeaks2.ptpAmpMeanRel = 0\nPeaks2.ptpAmpStddevAbs = 0\nPeaks2.ptpAmpStddevRel = 0\nPeaks2.minRangeAbs = 0\nPeaks2.minRangeRel = 1\nPeaks2.minMeanAbs = 0\nPeaks2.minMeanMeanDist = 0\nPeaks2.minMeanRel = 0\nPeaks2.mtmAmpMeanAbs = 0\nPeaks2.mtmAmpMeanRel = 0\nPeaks2.mtmAmpStddevAbs = 0\nPeaks2.mtmAmpStddevRel = 0\nPeaks2.meanRisingSlope = 1\nPeaks2.maxRisingSlope = 1\nPeaks2.minRisingSlope = 1\nPeaks2.stddevRisingSlope = 1\nPeaks2.meanFallingSlope = 1\nPeaks2.maxFallingSlope = 1\nPeaks2.minFallingSlope = 1\nPeaks2.stddevFallingSlope = 1\nPeaks2.norm = seconds\nPeaks2.relThresh = 0.100000\nPeaks2.dynRelThresh = 0\n;Peaks2.posDbgOutp = minmax.txt\nPeaks2.posDbgAppend = 0\nPeaks2.consoleDbg = 0\n\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\n\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\n\nTimes.upleveltime25 = 0\nTimes.downleveltime25 = 1\nTimes.upleveltime50 = 0\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 1\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 1\nTimes.buggySecNorm = 0\nTimes.norm = segment\n\nLpc.lpGain = 1\nLpc.lpc = 1\nLpc.firstCoeff = 0\nLpc.order = 5\n\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n\n\n\n;;;;;;;;; output all features....\n\n[componentInstances:cComponentManager]\ninstance[arffsink].type=cArffSink\n\n[arffsink:cArffSink]\nreader.dmLevel=functionals\nfilename=\\cm[output(O){output.arff}:output arff file for feature data]\nappend=1\nframeIndex=1\nframeTime=0\nrelation=MediaEval_FT\ninstanceName=\\cm[instName{null}:instance name]\n\\{arff_targets.conf}\n\n"
  },
  {
    "path": "config/prosodyAcf.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for speech prosody features //////////////////\n/////////   pitch (ACF) and intensity                                //////////////////\n/////////                                                            //////////////////\n///////// (c) 2013-2016 audEERING.                                   //////////////////\n/////////     All rights reserverd. See file COPYING for details.    //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n;;;;;;; component list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\n\n\\{shared/standard_wave_input.conf.inc}\n\n[componentInstances:cComponentManager]\ninstance[frame].type=cFramer\ninstance[int].type=cIntensity\ninstance[win].type=cWindower\ninstance[fft].type=cTransformFFT\ninstance[fftmp].type=cFFTmagphase\ninstance[acf].type=cAcf\ninstance[cep].type=cAcf\ninstance[pitch].type=cPitchACF\ninstance[smo].type=cContourSmoother\nprintLevelStats=6\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;; main section ;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[frame:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=outp\nframeSize = 0.050\nframeStep = 0.010\nframeCenterSpecial = left\n\n[int:cIntensity]\nreader.dmLevel = outp\nwriter.dmLevel = intens\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 1\nintensity = 0\nloudness = 1\n\n[win:cWindower]\nreader.dmLevel=outp\nwriter.dmLevel=win\nwinFunc=gauss\ngain=1.0\nsigma=0.4\n\n[fft:cTransformFFT]\nreader.dmLevel=win\nwriter.dmLevel=fftc\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmp:cFFTmagphase]\nreader.dmLevel=fftc\nwriter.dmLevel=fftmag\n\n[acf:cAcf]\nreader.dmLevel=fftmag\nwriter.dmLevel=acf\n\n[cep:cAcf]\nreader.dmLevel=fftmag\nwriter.dmLevel=cepstrum\ncepstrum=1\n\n[pitch:cPitchACF]\nreader.dmLevel = acf;cepstrum\nwriter.dmLevel = pitch\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 0\nmaxPitch = 500\nvoiceProb = 1\nvoiceQual = 0\nHNR = 0\nF0 = 1\nF0raw = 0\nF0env = 0\nvoicingCutoff = 0.550000\n\n[smo:cContourSmoother]\nreader.dmLevel = pitch;intens\nwriter.dmLevel = lld\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n\\{shared/standard_data_output_lldonly.conf.inc}\n\n"
  },
  {
    "path": "config/prosodyShs.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for speech prosody features //////////////////\n/////////   pitch and intensity                                      //////////////////\n/////////                                                            //////////////////\n///////// (c) 2014-2016 audEERING.                                   //////////////////\n/////////     All rights reserverd. See file COPYING for details.    //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n;;;;;;; component list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\n\n\\{shared/standard_wave_input.conf.inc}\n\n[componentInstances:cComponentManager]\ninstance[frame].type=cFramer\ninstance[int].type=cIntensity\ninstance[win].type=cWindower\ninstance[fft].type=cTransformFFT\ninstance[fftmp].type=cFFTmagphase\ninstance[scale].type=cSpecScale\ninstance[shs].type=cPitchShs\ninstance[smooth].type=cPitchSmoother\ninstance[smo].type=cContourSmoother\nprintLevelStats=6\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;; main section ;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[frame:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=outp\nframeSize = 0.050\nframeStep = 0.010\nframeCenterSpecial = left\n\n[int:cIntensity]\nreader.dmLevel = outp\nwriter.dmLevel = intens\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 1\nintensity = 0\nloudness = 1\n\n[win:cWindower]\nreader.dmLevel=outp\nwriter.dmLevel=win\nwinFunc=gauss\ngain=1.0\nsigma=0.4\n\n[fft:cTransformFFT]\nreader.dmLevel=win\nwriter.dmLevel=fftc\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmp:cFFTmagphase]\nreader.dmLevel=fftc\nwriter.dmLevel=fftmag\n\n[scale:cSpecScale]\nreader.dmLevel=fftmag\nwriter.dmLevel=hps\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 0\nscale=octave\nsourceScale = lin\n// logScaleBase = 2\n// logSourceScaleBase = 2\n// firstNote = 55\ninterpMethod = spline\nminF = 25\nmaxF = -1\nnPointsTarget = 0\nspecSmooth = 1\nspecEnhance = 1\nauditoryWeighting = 1 \n\n[shs:cPitchShs]\nreader.dmLevel=hps\nwriter.dmLevel=pitchShs\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 0\nmaxPitch = 620\nminPitch = 52\nnCandidates = 4\nscores = 1\nvoicing = 1\nF0C1 = 0\nvoicingC1 = 0\nF0raw = 1\nvoicingClip = 1\nvoicingCutoff = 0.700000\ninputFieldSearch = Mag_logScale\noctaveCorrection = 0\nnHarmonics = 15\ncompressionFactor = 0.850000\n\n[smooth:cPitchSmoother]\nreader.dmLevel=pitchShs\nwriter.dmLevel=pitch\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 0\nmedianFilter0 = 0\npostSmoothing = 0\npostSmoothingMethod = simple\n ; note: octave correction is too agressive, thus we disable it..\noctaveCorrection = 0\nF0final = 1\nF0finalEnv = 0\nno0f0 = 0\nvoicingFinalClipped = 0\nvoicingFinalUnclipped = 1\nF0raw = 0\nvoicingC1 = 0\nvoicingClip = 0\n\n[smo:cContourSmoother]\nreader.dmLevel = pitch;intens\nwriter.dmLevel = lld\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n\\{shared/standard_data_output_lldonly.conf.inc}\n\n"
  },
  {
    "path": "config/prosodyShsViterbiLoudness.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for speech prosody features //////////////////\n/////////   pitch and loudness                                       //////////////////\n/////////                                                            //////////////////\n///////// (c) 2014-2016 audEERING.                                   //////////////////\n/////////     All rights reserverd. See file COPYING for details.    //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n// === Newest version of prosody features: === \n//\n// Includes viterbi-smoothed SHS pitch\n// Loudness via simple auditory band model\n// HNR based on F0 harmonics and other spectral peaks\n\n// Supports both summarised features (over full input) with -O option (ARFF format)\n// and LLDs with -lld option  (disabled by default if option is not given)\n\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\ninstance[waveIn].type=cWaveSource\nprintLevelStats=0\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;; Wave input ;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[waveIn:cWaveSource]\nwriter.dmLevel=wave\nfilename=\\cm[inputfile(I){test.wav}:name of input file]\nmonoMixdown=1\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LOUDNESS ;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[frame25].type=cFramer\ninstance[win25].type=cWindower\ninstance[fft25].type=cTransformFFT\ninstance[fftmp25].type=cFFTmagphase\n\n[frame25:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frame25\nframeSize = 0.020\nframeStep = 0.010\nframeCenterSpecial = left\n\n[win25:cWindower]\nreader.dmLevel=frame25\nwriter.dmLevel=winH25\nwinFunc=hamming\n\n[fft25:cTransformFFT]\nreader.dmLevel=winH25\nwriter.dmLevel=fftcH25\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmp25:cFFTmagphase]\nreader.dmLevel=fftcH25\nwriter.dmLevel=fftmagH25\n\n[componentInstances:cComponentManager]\ninstance[melspec1].type=cMelspec\ninstance[audspec].type=cPlp\ninstance[audspecSum].type=cVectorOperation\n\n[melspec1:cMelspec]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=melspec1\n; htk compatible sample value scaling\nhtkcompatible = 0\nnBands = 26\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 20\nhifreq = 8000\nspecScale = mel\nshowFbank = 0\n\n; perform auditory weighting of spectrum\n[audspec:cPlp]\nreader.dmLevel=melspec1\nwriter.dmLevel=audspec\nfirstCC = 0\nlpOrder = 5\ncepLifter = 22\ncompression = 0.33\nhtkcompatible = 0 \ndoIDFT = 0\ndoLpToCeps = 0\ndoLP = 0\ndoInvLog = 0\ndoAud = 1\ndoLog = 0\nnewRASTA=0\nRASTA=0\n\n[audspecSum:cVectorOperation]\nreader.dmLevel = audspec\nwriter.dmLevel = loudness\nwriter.levelconf.growDyn = 0\nwriter.levelconf.isRb = 1\n; This must be > than buffersize of viterbi smoother\nwriter.levelconf.nT = 200\nnameAppend = loudness\ncopyInputName = 0\nprocessArrayFields = 0\noperation = ll1\nnameBase = loudness\n\n;;;;;;;;;;;;;;;;;; F0, SHS, Viterbi smoothed ;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;;;;;;;;;;;;;;;;; From 55 ms windows at 10 ms rate ;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[frame].type=cFramer\ninstance[win].type=cWindower\ninstance[fft].type=cTransformFFT\ninstance[fftmp].type=cFFTmagphase\ninstance[scale].type=cSpecScale\ninstance[shs].type=cPitchShs\ninstance[pitchSmooth].type=cPitchSmootherViterbi\ninstance[harmonics].type = cHarmonics\n\n[frame:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=outp\nframeSize = 0.055\nframeStep = 0.010\nframeCenterSpecial = left\n\n[win:cWindower]\nreader.dmLevel=outp\nwriter.dmLevel=win\nwinFunc=gauss\ngain=1.0\nsigma=0.4\n\n[fft:cTransformFFT]\nreader.dmLevel=win\nwriter.dmLevel=fftc\n ; for compatibility with 2.2.0 and older versions\nzeroPadSymmetric = 0\n\n[fftmp:cFFTmagphase]\nreader.dmLevel=fftc\nwriter.dmLevel=fftmag\n; greater than pitch smoother max. lag\nwriter.levelconf.nT = 200\n\n[scale:cSpecScale]\nreader.dmLevel=fftmag\nwriter.levelconf.nT = 3\nwriter.dmLevel=hps\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 0\nscale=octave\nsourceScale = lin\n// logScaleBase = 2\n// logSourceScaleBase = 2\n// firstNote = 55\ninterpMethod = spline\nminF = 25\nmaxF = -1\nnPointsTarget = 0\nspecSmooth = 1\nspecEnhance = 1\nauditoryWeighting = 1 \n\n[shs:cPitchShs]\nreader.dmLevel=hps\nwriter.dmLevel=pitchShs\n// nameAppend =\ncopyInputName = 1\nprocessArrayFields = 0\nmaxPitch = 620\nminPitch = 52\nnCandidates = 4\nscores = 1\nvoicing = 1\nF0C1 = 0\nvoicingC1 = 0\nF0raw = 1\nvoicingClip = 0\nvoicingCutoff = 0.700000\ngreedyPeakAlgo = 1\ninputFieldSearch = Mag_octScale\noctaveCorrection = 0\nnHarmonics = 15\ncompressionFactor = 0.850000\nlfCut = 0\n\n[pitchSmooth:cPitchSmootherViterbi]\nreader.dmLevel=pitchShs\nreader2.dmLevel=pitchShs\nwriter.dmLevel=pitchG60\ncopyInputName = 1\nbufferLength=90\nF0final = 1\nF0finalLog = 1\nF0finalEnv = 0\nvoicingFinalClipped = 0\nvoicingFinalUnclipped = 1\nF0raw = 0\nvoicingC1 = 0\nvoicingClip = 0\nwTvv =10.0\nwTvvd= 5.0\nwTvuv=10.0\nwThr = 4.0\nwTuu = 0.0\nwLocal=2.0\nwRange=1.0\n\n;;;;;;;;;;;; NEW HNR\n[harmonics:cHarmonics]\nreader.dmLevel = fftmag;pitchG60\nwriter.dmLevel = harmonics\nwriter.levelconf.growDyn = 0\nwriter.levelconf.isRb = 1\n; This must be > than buffersize of viterbi smoother\nwriter.levelconf.nT = 200\nnHarmonics = 10\nf0ElementName = F0final\nmagSpecFieldName = pcm_fftMag\ncomputeAcfHnrLogdB = 1\n\n;;;;;;;;;;;;;;; PITCH POST PROCCESSING\n;;;;;;;;;;;;;;; AND SMOOTHING OF LLD\n[componentInstances:cComponentManager]\ninstance[energy60].type=cEnergy\ninstance[volmerge].type = cValbasedSelector\ninstance[smo].type = cContourSmoother\ninstance[smoNz].type = cContourSmoother\n\n[energy60:cEnergy]\nreader.dmLevel=win\nwriter.dmLevel=e60\nrms=1\nlog=0\nwriter.levelconf.nT=200\n\n[volmerge:cValbasedSelector]\nreader.dmLevel = e60;pitchG60\nwriter.dmLevel = pitch\nidx=0\nthreshold=0.0008\nremoveIdx=1\nzeroVec=1\noutputVal=0.0\n\n[smo:cContourSmoother]\nreader.dmLevel = loudness\nwriter.dmLevel = smo\nwriter.levelconf.growDyn = 1\nwriter.levelconf.isRb = 0\nwriter.levelconf.nT = 1000\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\nnoZeroSma = 0\n\n[smoNz:cContourSmoother]\nreader.dmLevel = pitch;harmonics\nwriter.dmLevel = smoNz\nwriter.levelconf.growDyn = 1\nwriter.levelconf.isRb = 0\nwriter.levelconf.nT = 1000\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\nnoZeroSma = 1\n\n;;;;;;;;;;;;;;;;;; SUMMARIES over full input ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[functionalsNz].type = cFunctionals\ninstance[functionals].type = cFunctionals\n\n[functionals:cFunctionals]\nreader.dmLevel = smo\nwriter.dmLevel = stats\nframeMode = full\nfunctionalsEnabled = Moments;Regression;Percentiles\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 0\nMoments.kurtosis = 0\nMoments.amean = 1\nMoments.stddevNorm = 0\nMoments.doRatioLimit = 0\nRegression.linregc1 = 1\nRegression.linregc2 = 0\nRegression.linregerrA = 0\nRegression.linregerrQ = 0\nRegression.qregc1 = 0\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 0\nRegression.qregerrQ = 0\nRegression.centroid = 1\nRegression.centroidNorm = segment\nRegression.oldBuggyQerr = 0\nRegression.centroidUseAbsValues = 0\nRegression.centroidRatioLimit = 0\nRegression.doRatioLimit = 0\nPercentiles.quartiles = 0\nPercentiles.iqr = 0\nPercentiles.percentile[0] = 0.1\nPercentiles.percentile[1] = 0.9\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\nnonZeroFuncts = 0\n\n[functionalsNz:cFunctionals]\nreader.dmLevel = smoNz\nwriter.dmLevel = statsNz\nframeMode = full\nfunctionalsEnabled = Moments;Regression;Percentiles\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 0\nMoments.kurtosis = 0\nMoments.amean = 1\nMoments.stddevNorm = 0\nMoments.doRatioLimit = 0\nRegression.linregc1 = 1\nRegression.linregc2 = 0\nRegression.linregerrA = 0\nRegression.linregerrQ = 0\nRegression.qregc1 = 0\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 0\nRegression.qregerrQ = 0\nRegression.centroid = 1\nRegression.centroidNorm = segment\nRegression.oldBuggyQerr = 0\nRegression.centroidUseAbsValues = 0\nRegression.centroidRatioLimit = 0\nRegression.doRatioLimit = 0\nPercentiles.quartiles = 0\nPercentiles.iqr = 0\nPercentiles.percentile[0] = 0.1\nPercentiles.percentile[1] = 0.9\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\nnonZeroFuncts = 1\n\n\n;;;;;;;;;;;;;;;; DATA OUTPUT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n[componentInstances:cComponentManager]\ninstance[prosody_lldconcat].type=cVectorConcat\ninstance[prosody_llddeconcat].type=cVectorConcat\ninstance[prosody_funcconcat].type=cVectorConcat\n\n[prosody_lldconcat:cVectorConcat]\nreader.dmLevel = smo\nwriter.dmLevel = lld\nincludeSingleElementFields = 1\n\n[prosody_llddeconcat:cVectorConcat]\nreader.dmLevel = smoNz\nwriter.dmLevel = lld_de\nincludeSingleElementFields = 1\n\n[prosody_funcconcat:cVectorConcat]\nreader.dmLevel = statsNz;stats\nwriter.dmLevel = func\nincludeSingleElementFields = 1\n\n\\{shared/standard_data_output.conf.inc}\n\n\n"
  },
  {
    "path": "config/shared/BufferMode.conf.inc",
    "content": "writer.levelconf.growDyn = 1\nwriter.levelconf.isRb = 0\nwriter.levelconf.nT = 1000\n"
  },
  {
    "path": "config/shared/BufferModeLive.conf.inc",
    "content": "writer.levelconf.growDyn = 0\nwriter.levelconf.isRb = 1\n;; must be > turndetector maxlength + grace\nwriter.levelconf.nT = 1500\nwriter.levelconf.noHang = 2\n"
  },
  {
    "path": "config/shared/BufferModeRb.conf.inc",
    "content": "writer.levelconf.growDyn = 0\nwriter.levelconf.isRb = 1\nwriter.levelconf.nT = 5\n; writer.levelconf.nT = 3\n\n"
  },
  {
    "path": "config/shared/BufferModeRbLag.conf.inc",
    "content": "writer.levelconf.growDyn = 0\nwriter.levelconf.isRb = 1\n; This must be > than buffersize of viterbi smoother\nwriter.levelconf.nT = 150\n\n\n"
  },
  {
    "path": "config/shared/FrameModeFunctionals.conf.inc",
    "content": "\n;; set this to override the previously included BufferModeRb.conf.inc (in GeMAPS sets only) for the functionals\n;; or (in all other sets), define the RbConf here to save memory on the functionals levels:\n;writer.levelconf.growDyn = 0\n;writer.levelconf.isRb = 1\n;writer.levelconf.nT = 5\n\nframeMode = full\nframeSize = 0\nframeStep = 0\nframeCenterSpecial = left\n\n"
  },
  {
    "path": "config/shared/FrameModeFunctionalsLive.conf.inc",
    "content": "\n;; set this to override the previously included BufferModeRb.conf.inc (in GeMAPS sets only) for the functionals\n;; or (in all other sets), define the RbConf here to save memory on the functionals levels:\n;writer.levelconf.growDyn = 0\n;writer.levelconf.isRb = 1\n;writer.levelconf.nT = 5\n\nframeMode = var\nframeCenterSpecial = left\n\n"
  },
  {
    "path": "config/shared/arff_targets.conf.inc",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n/////////     openSMILE arff targets generic config file             //////////////////\n///////// (c) audEERING UG (haftungsbeschränkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n//\n// configuration of commandline options for target classes in an ARFF file\n// (cArffSink)\n//\n// change this file to match your labels!\n//\n\nclass[0].name = class\n// use this for a nominal label (discrete classes)\n// class[0].type = {classA,classB,classC}  \nclass[0].type = \\cm[classtype{numeric}:type of labelA, either numeric or a list of comma separated classes in curly brackets]\ntarget[0].all = \\cm[class{?}:string value for labelA]\n\n/*\nclass[1].name = labelB\nclass[0].type = \\cm[labelBtype{numeric}:type of labelB, either numeric or a list of comma separated classes in curly brackets]\ntarget[1].all = \\cm[labelB{0.0}:numeric value for labelB]\n// you can add as many labels here as you want\n*/\n\n"
  },
  {
    "path": "config/shared/standard_data_output.conf.inc",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for data output <           //////////////////\n/////////                                                            //////////////////\n///////// (c) 2014-2016 audEERING,                                   //////////////////\n/////////     All rights reserverd. See file COPYING for details     //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n/*\n   This file can be included as data output file for standard feature\n   extraction configuration files. It provides commandline options\n   for the batch extraction GUI, and supports LLD and Functionals (summaries)\n   saving.\n\n   It requires the main extrator configuration file to provide the following\n   data memory levels:  lld, lld_de, and func\n */\n\n;;;;;;;;; output LLD features to CSV ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[lldsink].type=cCsvSink\ninstance[lldhtksink].type=cHtkSink\ninstance[lldarffsink].type=cArffSink\ninstance[arffsink].type=cArffSink\ninstance[csvsink].type=cCsvSink\ninstance[htksink].type=cHtkSink\n\n[lldsink:cCsvSink]\nreader.dmLevel = lld;lld_de\nfilename=\\cm[lldcsvoutput(D){?}:output csv file for LLD, disabled by default ?, only written if filename given]\ninstanceName=\\cm[instname(N){unknown}:instance name]\nappend = \\cm[appendcsvlld{0}:set to 1 to append to the LLD output csv file, default is not to append]\ntimestamp = \\cm[timestampcsvlld{1}:set to 0 to suppress timestamp column, default is 1, i.e. to show timestamp in second column]\nnumber = 0\nprintHeader = \\cm[headercsvlld{1}:set to 0 to suppress header line with feature names, default is 1, i.e. to show header line]\nerrorOnNoOutput = 1\n\n[lldhtksink:cHtkSink]\nreader.dmLevel = lld;lld_de\nfilename=\\cm[lldhtkoutput{?}:output HTK binary file for LLD, disabled by default ?, only written if filename given]\nappend = \\cm[appendhtklld{0}:set to 1 to append to the LLD output htk file, default is not to append]\n  ; this is broken for HTK sink...\nerrorOnNoOutput = 0  \nparmKind = 9\n\n[lldarffsink:cArffSink]\nreader.dmLevel = lld;lld_de\nframeIndex = 0\nframeTime = \\cm[timestamparfflld{1}:set to 0 to suppress timestamp column, default is 1, i.e. to show timestamp in second column]\nfilename=\\cm[lldarffoutput{?}:name of WEKA Arff output file, set to a valid filename to enable this output sink]\nrelation=\\cm[relation{openSMILE_features}:arff relation attribute, feature set name and/or corpus name]\ninstanceName=\\cm[instname]\n ;; use this line instead of the above to always set the instance name to the\n ;; name of the input wave file\n ;instanceName=\\cm[inputfile]\n\\{\\cm[lldarfftargetsfile{arff_targets.conf.inc}:name of arff targets include file]}\nappend=\\cm[appendarfflld{1}:set to 0 to disable appending to an existing arff parameter summary file, given by the arffoutput option]\nerrorOnNoOutput = 1\n\n[arffsink:cArffSink]\nreader.dmLevel=func\nframeIndex = 0\nframeTime = \\cm[timestamparff{0}:set to 1 to include timestamp column, default is 0, i.e. to not save timestamp in second column]\nframeTimeAdd=\\cm[frameTimeAdd{0}:frame time offset -start of segment in seconds- used by avec2013]\nfilename=\\cm[output(O){?}:name of WEKA Arff output file, set to a valid filename to enable this output sink]\nrelation=\\cm[relation{openSMILE_features}:arff relation attribute, feature set name and/or corpus name]\ninstanceName=\\cm[instname]\n ;; use this line instead of the above to always set the instance name to the\n ;; name of the input wave file\n ;instanceName=\\cm[inputfile]\n\\{\\cm[arfftargetsfile{arff_targets.conf.inc}:name of arff targets include file]}\nappend=\\cm[appendarff{1}:set to 0 to disable appending to an existing arff parameter summary file, given by the arffoutput option]\nerrorOnNoOutput = 1\n\n[csvsink:cCsvSink]\nreader.dmLevel = func\nfilename=\\cm[csvoutput{?}:output CSV file for summarised parameters, set to a valid filename to enable this output sink, data is appended if file exists]\nappend=\\cm[appendcsv{1}:set to 0 to disable appending to an existing csv parameter summary file, given by the csvoutput option]\nframeIndex=0\nframeTime=\\cm[timestampcsv{1}:set to 0 to suppress timestamp column, default is 1, i.e. to show timestamp in second column]\ninstanceName=\\cm[instname]\nerrorOnNoOutput = 1\nprintHeader = \\cm[headercsv{1}:set to 0 to suppress header line with feature names, default is 1, i.e. to show header line]\n\n  ; TODO: output without a frame period does not work so that HTK (HList) can read it!\n[htksink:cHtkSink]\nreader.dmLevel = func\nfilename=\\cm[htkoutput{?}:output HTK file for summarised parameters, set to a valid filename to enable this output sink, no append by default, use -appendstatichtk option to enable]\nappend=\\cm[appendhtk{0}:set to 1 to enable appending to an existing HTK parameter summary file, given by the htkoutput option]\nparmKind = 9\n  ; this is broken for HTK sink...\nerrorOnNoOutput = 0\n ; avoid broken files which HTK cannot read for period approx. > 0.06 (int16 overflow)\nforcePeriod = 0.01\n\n"
  },
  {
    "path": "config/shared/standard_data_output_lldonly.conf.inc",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for data output <           //////////////////\n/////////                                                            //////////////////\n///////// (c) 2014-2016 audEERING,                                   //////////////////\n/////////     All rights reserverd. See file COPYING for details     //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n/*\n   This file can be included as data output file for standard feature\n   extraction configuration files. It provides commandline options\n   for the batch extraction GUI, and supports LLD and Functionals (summaries)\n   saving.\n\n   It requires the main extrator configuration file to provide the following\n   data memory levels:  lld  (including, if available lld_de)\n */\n\n;;;;;;;;; output LLD features to CSV ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[lldcsvsink].type=cCsvSink\ninstance[lldhtksink].type=cHtkSink\ninstance[lldarffsink].type=cArffSink\n\n[lldcsvsink:cCsvSink]\nreader.dmLevel = lld\nfilename=\\cm[csvoutput{?}:output csv file for LLD, disabled by default ?, only written if filename given]\ninstanceName=\\cm[instname(N){unknown}:instance name]\nappend = \\cm[appendcsv{0}:set to 1 to append to the LLD output csv file, default is not to append]\ntimestamp = \\cm[timestampcsv{1}:set to 0 to suppress timestamp column, default is 1, i.e. to show timestamp in second column] \nnumber = 0\nprintHeader = \\cm[headercsv{1}:set to 0 to suppress header line with feature names, default is 1, i.e. to show header line]\nerrorOnNoOutput = 1\n\n[lldhtksink:cHtkSink]\nreader.dmLevel = lld\nfilename=\\cm[output(O){output.htk}:output HTK binary file for LLD. Use ? as value to disable]\nappend = \\cm[appendhtk{0}:set to 1 to append to the LLD output htk file, default is not to append]\n; this is broken for HTK sink...:\nerrorOnNoOutput = 0  \nparmKind = 9\n\n[lldarffsink:cArffSink]\nreader.dmLevel = lld\nframeIndex = 0\nframeTime = \\cm[timestamparff{1}:set to 0 to suppress timestamp column, default is 1, i.e. to show timestamp in second column] \nfilename=\\cm[arffoutput{?}:name of WEKA Arff output file, set to a valid filename to enable this output sink]\nrelation=\\cm[relation{openSMILE_features}:arff relation attribute, feature set name and/or corpus name]\ninstanceName=\\cm[instname]\n ;; use this line instead of the above to always set the instance name to the\n ;; name of the input wave file\n ;instanceName=\\cm[inputfile]\n\\{\\cm[arfftargetsfile{arff_targets.conf.inc}:name of arff targets include file]}\nappend=\\cm[appendarff{1}:set to 0 to disable appending to an existing arff parameter summary file, given by the arffoutput option]\nerrorOnNoOutput = 1\n\n\n"
  },
  {
    "path": "config/shared/standard_wave_input.conf.inc",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file for wave input <            //////////////////\n/////////                                                            //////////////////\n///////// (c) audEERING GmbH,                                        //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\n[componentInstances:cComponentManager]\ninstance[waveIn].type=cWaveSource\n\n[waveIn:cWaveSource]\nwriter.dmLevel=wave\nbuffersize_sec = 5.0\nfilename=\\cm[inputfile(I){test.wav}:name of input file]\nstart=\\cm[start{0}:audio start position in seconds]\nend=\\cm[end{-1}:audio end position in seconds, -1 for end of file]\nmonoMixdown=1\noutFieldName = pcm\n\n"
  },
  {
    "path": "config/smileF0.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE config for SHS viterbi smoothed pitch <        //////////////////\n/////////                                                            //////////////////\n///////// (c) 2013-2016 audEERING.                                   //////////////////\n/////////     All rights reserverd. See file COPYING for details.    //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n//  output frame rate: 10ms\n//  analysis window length : 60ms, gaussian window\n\n\\{smileF0_base.conf}\n\n[componentInstances:cComponentManager]\ninstance[F0_lldconcat].type=cVectorConcat\n\n[F0_lldconcat:cVectorConcat]\nreader.dmLevel = F0\nwriter.dmLevel = lld\nincludeSingleElementFields = 1\n\n\\{shared/standard_data_output_lldonly.conf.inc}\n\n"
  },
  {
    "path": "config/smileF0_base.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE config for SHS viterbi smoothed pitch <        //////////////////\n/////////                                                            //////////////////\n///////// (c) 2013-2016 audEERING.                                   //////////////////\n/////////     All rights reserverd. See file COPYING for details.    //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n//  output frame rate: 10ms\n//  analysis window length : 60ms, gaussian window\n\n;;;;;;; component list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\nprintLevelStats=0\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;; main section ;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[waveIn].type=cWaveSource\n\n[waveIn:cWaveSource]\nwriter.dmLevel=wave\nfilename=\\cm[inputfile(I){test.wav}:name of input file]\nmonoMixdown=1\n\n;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[frame60].type=cFramer\ninstance[win60].type=cWindower\ninstance[fft60].type=cTransformFFT\ninstance[fftmp60].type=cFFTmagphase\ninstance[energy60].type=cEnergy\n\n[frame60:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frame60\nframeSize = 0.050\nframeStep = 0.010\nframeCenterSpecial = center\n\n\n[win60:cWindower]\nreader.dmLevel=frame60\nwriter.dmLevel=winG60\nwinFunc=gauss\ngain=1.0\nsigma=0.4\n\n[fft60:cTransformFFT]\nreader.dmLevel=winG60\nwriter.dmLevel=fftcG60\n\n[fftmp60:cFFTmagphase]\nreader.dmLevel=fftcG60\nwriter.dmLevel=fftmagG60\n\n[energy60:cEnergy]\nreader.dmLevel=winG60\nwriter.dmLevel=e60\nrms=1\nlog=0\nwriter.levelconf.nT=100\n\n[componentInstances:cComponentManager]\ninstance[scale].type=cSpecScale\ninstance[shs].type=cPitchShs\ninstance[pitchSmooth].type=cPitchSmootherViterbi\n;instance[shscsv].type = cCsvSink\n\n[scale:cSpecScale]\nreader.dmLevel=fftmagG60\nwriter.dmLevel=hpsG60\ncopyInputName = 1\nprocessArrayFields = 0\nscale=octave\nsourceScale = lin\n// logScaleBase = 2\n// logSourceScaleBase = 2\n// firstNote = 55\ninterpMethod = spline\nminF = 20\nmaxF = -1\nnPointsTarget = 0\nspecSmooth = 1\nspecEnhance = 1\nauditoryWeighting = 1 \n\n[shs:cPitchShs]\nreader.dmLevel=hpsG60\nwriter.dmLevel=pitchShsG60\nshsWriter.dmLevel = shsSpec\nshsSpectrumOutput = 0\ncopyInputName = 1\nprocessArrayFields = 0\nmaxPitch = 620\nminPitch = 42\nnCandidates = 6\nscores = 1\nvoicing = 1\nF0C1 = 0\nvoicingC1 = 0\nF0raw = 1\nvoicingClip = 1\nvoicingCutoff = 0.700000\ninputFieldSearch = Mag_octScale\noctaveCorrection = 0\nnHarmonics = 15\ncompressionFactor = 0.850000\ngreedyPeakAlgo = 1\n\n[shscsv:cCsvSink]\nreader.dmLevel = shsSpec;hpsG60\nfilename=shs.csv\nprintHeader = 0\ntimestamp = 0\nnumber = 0\nappend = 0\n\n[pitchSmooth:cPitchSmootherViterbi]\nreader.dmLevel=pitchShsG60\nreader2.dmLevel=pitchShsG60\nwriter.dmLevel=pitchG60\ncopyInputName = 1\nbufferLength=90\nF0final = 1\nF0finalEnv = 0\nvoicingFinalClipped = 0\nvoicingFinalUnclipped = 1\nF0raw = 0\nvoicingC1 = 0\nvoicingClip = 0\nwTvv =10.0\nwTvvd= 5.0\nwTvuv=10.0\nwThr = 4.0\nwTuu = 0.0\nwLocal=2.0\nwRange=1.0\n; old parameters for greedyPeakAlgo=0\n;wTvv=10.0\n;wTvuv=25.0\n;wRange=2.0\n\n[componentInstances:cComponentManager]\ninstance[smoF0].type=cContourSmoother\ninstance[f0Selector].type=cDataSelector\ninstance[volmerge].type = cValbasedSelector\ninstance[f0Selector2].type=cDataSelector\n\n[smoF0:cContourSmoother]\nreader.dmLevel = pitchG60\nwriter.dmLevel = pitchSmo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 2\nnoZeroSma = 1\n\n[f0Selector:cDataSelector]\nreader.dmLevel = pitchSmo\nwriter.dmLevel = F0a\n// nameAppend = \ncopyInputName = 1\n// selFile = \nselected[0] = F0final_sma\n// selectedRange[] = \n// newNames[] = \nelementMode = 1\n//dummyMode =1\n\n[volmerge:cValbasedSelector]\nreader.dmLevel = e60;F0a\nwriter.dmLevel = F0cl\nidx=0\nthreshold=0.0008\nremoveIdx=0\nzeroVec=1\noutputVal=0.0\n\n[f0Selector2:cDataSelector]\nreader.dmLevel = F0cl\nwriter.dmLevel = F0\n// nameAppend = \ncopyInputName = 1\n// selFile = \nselected[0] = F0final_sma\n// selectedRange[] = \n// newNames[] = \nelementMode = 1\n//dummyMode =1\n\n\n"
  },
  {
    "path": "config/smileF0_mean.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE config for SHS viterbi smoothed pitch <        //////////////////\n/////////                                                            //////////////////\n///////// (c) 2013-2016 audEERING.                                   //////////////////\n/////////     All rights reserverd. See file COPYING for details.    //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n//  output frame rate: 10ms\n//  analysis window length : 60ms, gaussian window\n\n\\{smileF0_base.conf}\n\n[componentInstances:cComponentManager]\ninstance[mean].type=cFunctionals\n\n[mean:cFunctionals]\nreader.dmLevel = F0\nwriter.dmLevel = F0mean\ncopyInputName = 1\nframeMode = full\nframeSize = 0\nframeStep = 0\nframeCenterSpecial = left\nfunctionalsEnabled = Means\nMeans.amean = 1\nMeans.posamean = 0\nMeans.absmean = 0\nMeans.rqmean = 0\nMeans.flatness = 0\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\nnonZeroFuncts = 1\n\n;;;;;;;;; output all features....\n\n[componentInstances:cComponentManager]\ninstance[csv].type=cCsvSink\n\n[csv:cCsvSink]\nreader.dmLevel=F0mean\nfilename=\\cm[output(O){pitch_mean.csv}:name of F0 output text file]\nappend=0\nprintHeader=0\nnumber=0\ntimestamp=0\n\n\n"
  },
  {
    "path": "configure.ac",
    "content": "\nAC_INIT(openSMILE,2.3.0)\nAC_CONFIG_SRCDIR([.])\nAM_INIT_AUTOMAKE\n\nAC_CONFIG_MACRO_DIR([m4])\n\nAC_PROG_CC\nAC_PROG_CXX\nLT_INIT\nAM_PROG_CC_C_O\n\nCHECK_HAVE_PORTAUDIO\nCHECK_HAVE_ANDROID\nCHECK_HAVE_OPENCV\nACX_PTHREAD\nCONFIGURE_TARGETS\n\nDLIB=\"-ldl\"\nif test x`uname | grep mingw` != x ; then\n#  AC_DEFINE([WIN32],[1], [Compile on MinGW32-Msys])\n  AC_DEFINE([__WINDOWS],[1], [Compile on MinGW32-Msys])\n  AC_DEFINE([__MINGW32],[1], [Compile on MinGW32-Msys])\n  AC_DEFINE([__MINGW],[1], [Compile on MinGW32-Msys])\n  DLIB=\"\"\nfi \n\nif test x`uname | grep MINGW` != x ; then\n#  AC_DEFINE([WIN32],[1], [Compile on MinGW32-Msys])\n  AC_DEFINE([__WINDOWS],[1], [Compile on MinGW32-Msys])\n  AC_DEFINE([__MINGW32],[1], [Compile on MinGW32-Msys])\n  AC_DEFINE([__MINGW],[1], [Compile on MinGW32-Msys])\n  AC_DEFINE([__HAVENT_GNULIBS],[1], [No getline implementation on Win])\n  DLIB=\"\"\nfi\n\nif test x`uname | grep Darwin` != x ; then\n  AC_DEFINE([__MACOS],[1], [Compile on Macs])\n  AC_DEFINE([__HAVENT_GNULIBS],[1], [No getline implementation on Mac])\nfi\n \nAC_SUBST(DLIB)\n\nAC_DEFINE([HAVE_AUTOCONF],[1],[Build with autoconf])\n\nAC_CONFIG_HEADERS(config.h)\nAC_CONFIG_FILES([Makefile])\nAC_OUTPUT\n\n"
  },
  {
    "path": "doc/components.txt",
    "content": "\nA not really up-to-date list of components can be found in the \n developer/classes.txt \nfile.\n\nFor more up-to-date information, use the on-line documentation implemented in the openSMILE binary:\n  ./SMILExtract -L displays a list of components currently available along with a brief description of each component.\n  ./SMILExtract -H displays the configuration options available for each component (the term config-type is used here. Each component has it's own config-type, which by convention has the same name as the component)\n  \n\n\n\n"
  },
  {
    "path": "doc/configfile.txt",
    "content": "Documentation of openSMILE config file format:\n==============================================\n\nThe default configuration file read by the current binary is 'smile.conf' in the current path.\nTo change the file use the commandline option '-C path/to/config.file'\n\nopenSMILE currently uses a simple, yet powerful, ini-style configuration file format.\nThe file allows to specify configuration for individual \"config instances\", which correspond to instances of actual components. The format is the following:\n\n[instancename:configType]     <-- this specifies the header for each instance\nvariable1 = value             <-- example of a string variable\nvariable2 = 7.8               <-- example of a \"numeric\" variable\nvariable3 = X                 <-- example of a \"char\" variable\nsubconf.var1 = myname         <-- example of a variable in a sub config type\nmyarr[0] = value0             <-- example of an array given explicitely\nmyarr[1] = value1\nanotherarr = value0;value1    <-- example of an implicitely given array \nnoarray = value0\\;value1      <-- use \\; to quote the array separator ';' \nstrArr[name1] = value1        <-- associative arrays with name=value pairs are also supported\nstrArr[name2]=value2\n// ....\n\nComments may be expressed by:\n  - prefixing a line with  ; // % or # \n  - multiline comments (c-style): \n    /*comment\n     blah\n    end of blah*/\n    NOTE /* */ comments must have the /* at the beginning of a line and the */ \n                                      at the end of a line (or in empty lines)\n  - end-of-line comments via //  (everything on a line after a // is ignored (including the //))\n    reader.dmLevel=inputlevel  // <- this is the level we read from\n\n  - Note: comments within a line by the c-style syntax /* */ are not yet supported!\n\nEach openSMILE component will automatically register it's config type, which contains all configuration for the specific component.\nThe configManager can print a complete help on all registered config types by calling the following function:\n  configManager.printTypeHelp(0);  // does not expand subtypes\n  configManager.printTypeHelp(1);  // expands all subtypes (i.e. redundant information is printed)\n\nIn the current openSMILE binary this list can be printed by giving the -H commandline option.\nThe get a template config section use the commandline option \n -configDflt type\nOR\n -configDflt type1,type2,...\n\n\n********************* enabling/disabling components ************************************\n\nThe components which will be run, can be specified by configuring the componentManager:\n\n[componentInstances:cComponentManager]     <-- this line must be exactly as printed here!\n; the data memory component must always be specified!\n; the default name is 'dataMemory'\n; if you also call you data memory instance 'dataMemory',\n; you will not have to specify the dmInstance variables for the readers of each other component!\ninstance[dataMemory].type=cDataMemory      <-- use the instance array to specify the\n;                                              instance names as array keys\n;                                              and the types by using the 'type' of the subtype\ninstance[source1].type=cExampleSource\n\nNOTE: for each component instance specified int the 'instance' array a configuration instance in the file MUST exist, even if it is empty, i.e. if you want to use only default values. In that case you need to specify only the header line [XXX:type]\n\n\n****************** including other config files ***************************************\n\nTo include config files into the main configuration file use the following syntax:\n\\{path/to/config.file}\n\nThis include command can be used anywhere, and simply copies the lines of the included file into the main file while loading the configfile line by line.\n\n\n****************** linking to commandline options *************************************\n\nopenSMILE allows to define new commandline options for the openSMILE binary directly in the configuration file. To do so, use the following syntax to set a value of a variable:\n\nexampleVariable = \\cm[longoption(shortoption){default}:description]\n\nNote, that either default and/or description are required to define a new option. If neither of the two is specified, the option will not be added to the commandline parser. Use this to reference option that were already added, i.e. if you want to use existing options or link to options you already defined in the config file:\n\nexampleVariable2 = \\cm[longoption(shortoption)]\n OR:\nexampleVariable2 = \\cm[longoption]\n\nshortoption, default, and description are optional parameters.\n\nNOTE: \\cm[...] must be the ONLY text specified as value, if used\n      We are working on supporting prefixing and appending text to the \\m[...] blocks,\n      but currently this is not yet in the code!\n\n\n****************** linking to other config instances or variables *********************\n\nThis is not yet supported, but may be supported soon.\nInstead of values you can then specify a reference to another variable (like $variablename).\nThis will help you to avoid having the same values in multiple spots in the file.\n\n\n"
  },
  {
    "path": "doc/developer/classes.txt",
    "content": "\n\ncCommandlineParser\ncSmileLogger\ncConfigManager\ncComponentManager\n\ncSmileComponent\n  cDataMemory\n  cDataReader\n  cDataWriter\n  cDataSource\n    exampleSource\n    waveSource\n  cDataSink\n    exampleSink\n    htkSink\n    datadumpSink\n    arffSink\n  cDataProcessor\n    (cWindowFramer)\n    cWinToVecProcessor\n      cFramer\n    cToneFilt\n    cVectorProcessor\n      cVectorConcat\n      cWindower\n      cTransformFFT\n      cFFTmagphase\n      cVectorPreemphasis\n      cMelspec\n      cMfcc\n      cDbA\n      cTonespec\n      cFunctionals\n    cWindowProcessor\n      [cFilter : TODO]\n      cPreemphasis\n      cDeltaRegression\n\n\nTODO:\n\ncFunctionals   (or multiple objects...)\ncChroma\ncCens\ncCombfilter\ncWghtDiff\ncResample\ncLowpass\ncHighpass\ncGlidingMean ?\ncAcf\ncAmdf\ncCepstrum\ncPitchACF\ncPitchHPS\ncPitchAMDFACF\ncPlp\ncLpc\ncFormants\n\nsupport multi-pass processing in future versions?? (off-line only...)\n\n\n"
  },
  {
    "path": "doc/developer/component_configuration.txt",
    "content": "\nopenSMILE has two major phases of operation: \n I) setup phase\nII) run-time phase\n\nDuring the \"setup phase\" the configuration file is read and all components are instanciated and configured. The components in this phase should check for any missing dependencies, try to open files, devices etc. They will also register configure their read-request to the dataMemory, which includes the configuration of the data fields they will output. It is also necessary to verify the input configuration of the levels the component reads from. Since this configuration may not be available since not all components have been configured, the configuration process consists of multiple iterations.\n\nThe exact process of the setup phase is described in the next section in more detail, including various refactoring functions provided by base component classes.\n\nDuring the run-time phase, the tick() method of each instanciated component is called in turn from an indefinite loop in the componentManager.\n\n--- component configuration process in detail ---\n\nopenSMILE components are subject to a multi step configuration process during the setup phase of openSMILE.\n\n\nThis process basically consits of two stages for all cSmileComponent descendant:\n[  0) the \"register\" stage ]\n  A) the \"configure\" stage ( implemented in myConfigureInstance(), called via configureInstance() )\n  B) the \"finalise\" stage ( implemented in myFinaliseInstance(), called via finaliseInstance() )\n\nSince most components will perform common tasks, such as configuring output data fields and validating or finding input data fields, various functions and refactoring hooks are provided by the cDataProcessor class (they are listed in the order they are called by cDataProcessor::myConfigureInstance):\n\nA) during the \"configure\" stage:\n ( the reader is configured [reader->configureInstance] )\n ( the reader is finalised [reader->finaliseInstance] )\n \n (reader->getConfig is called to get read level config)\n\n - configureReader():\n   return value > 1 indicates success,\n   return value == 0 indicates failure and will make myConfigureInstance() fail!\n\n - configureWriter(sDmLevelCfg &): \n     hook to change write level config (which at this stage is a clone of the read level config overwritten by the dataWriter levelconf config options) \n   return value > 1 indicates success,\n   return value == 0 indicates failure and will make myConfigureInstance() fail!\n\n (writer->setConfig is called to set level size, etc.)\n\n ( writer->configureInstance() is called )\n\nB) during the \"finalise\" stage:\n \n + the 'namesAreSet' variable defined as protected in cDataProcessor indicates\n   whether names for the output field have been set (i.e. the output field has\n   been configured)\n\n - dataProcessorCustomFinalise()\n    custom code.. \n    return value 0 = failure, else success \n      (i.e. continue with myFinaliseInstance code)\n \n IF 'namesAreSet' == FALSE (0):\n  - setupNewNames( <# read level fields> )\n    to be implemented by descendant class, default behaviour is: \"return 1;\"\n\n IF 'namesAreSet' == FALSE (0):\n THEN default action to set the output field names:\n for each input field\n  - setupNamesForField(index,name,#el)\n is called with the index, name, and number of elements of the input field\n followed by\n  - configureField(index,__N,#el)\n\n ( writer->finaliseInstance() is called )\n\n-- The default \"setupNamesForField(index,name,#el)\" calls \n   - addNameAppendField  \n     to append the 'nameAppend' string to the input field name\n       (if copyInputName==1)\n     to set the output field name to 'nameAppend' only (if copyInputName==0)\n\n\nMoreover the cDataProcessor class provides various helper functions, which are sorted by phases/stages at which they may be first called:\n\nI.A: (configure)\n\nI.A.configureReader:\n\n- findField()\n- findInputField()\n- getFrameSizeSec()\n- getBasePeriod()\n\nI.B: (finalise)\n\n- addNameAppendField()\n- addNameAppendFieldAuto()\n- configureField() ??\n\nII:\n\n- getInputFieldData()\n\n\n\nNext to these functions, the default dataReader (after and in I.A.configureReader) and dataWriter (after and in I.B.) interface is also available:\n\nWRITER:\n\n- addField()\n- setFieldInfo()\n\n\nREADER:\n\n- getLevelNf()\n- getFrameMetaInfo() ??\n\n\n\n\n"
  },
  {
    "path": "doc/developer/dataMemory.txt",
    "content": "\nTODO: complete description of dataMemory architecture\n\n- multiple levels (slots) for independent and asynchronous data\n\n- data types: INT and FLOAT\n\n- ring-buffer functionality for each level\n\n- automatic read/write indexing, fill status and waiting on read / writes\n\n\nData organisation in each level:\n\nNxT buffer matrix:\n( 'N' is the number of ELEMENTS in a frame for this level (i.e. total number of values) )\n\nHowever, the frame is primarily composed of FIELDS. Each field has a unique name (within a level) and can be a single value field (e.g. RMSenergy, etc.) or an array field, e.g. FFTmagnitude[0..N]. The number of fields is often referred to as 'Nf'.\n\nThe cVectorProcessor and cWindowProcessor components encapsulate processing of each field independently. E.g. the vector processor treats each array(!) field as a vector which will be processed individually. (see the vectorProcessor documentation for more details)\n\nThe windowProcessor processes each element(!) individually.\n\n"
  },
  {
    "path": "doc/developer/defines.txt",
    "content": "## pre processor switches:\n\n\n HAVE_NET\n\tbuild with socket interface and compile network components\n\n BUILD_NETVERSION\n \tbuild the remote controllable version of smilextract \n BUILD_NETSTANDALONE\n        build the standalone net source/sink components (which operate indepently of the other stuff)\n\n HAVE_PORTAUDIO\n\tlink to portaudio and build components for audio playback/recording on linux/windows/macOs\n HAVE_PORTAUDIO_V19\n\tuse new V19 API for portaudio (default)\n\n HAVE_SEMAINEAPI\n\tlink to SEMAINE API and build semaine components and semaine executable\n \n HAVE_JULIUSLIB\n\tlink to julius LVCSR engine, and build juliusSink component\n\n HAVE_SPEEXLIB\n\tlink to speex lib. and build vad and preprocessing (denoising) components\n\n HAVE_ATKLIB\n\tlink to ATK lib for ASR demo code. This also requires BUILD_OBSOLETE to be enabled\n\n HAVE_LIBSAMPLERATE\t\n\tlink to libsamplerate, and build resampling component\n\n BUILD_OSMIRDEMO\n\tbuild opensmile MIR demo components (former ADMIRE)\n\n BUILD_SVMSMO\n\tbuild the non-opensource SMO SVM decoder component\n\n BUILD_RNN\n\tbuild the lstm rnn components\n\n BUILD_OBSOLETE\n\tbuild obsolete components\n\n BUILD_WITHOUT_EXPERIMENTAL\n \tbuild no experimental components\n\n BUILD_WITHOUT_GPL3rdP\n\tbuild without code which is based on GPL thirdparty code\n\n BUILD_LIBSVM\n \tbuild libSVM code and classifier component\n\n BUILD_NMF\n        build non-opensource onlineNMF code (depends on openBlissart library)\n\n HAVE_GSL_ZSOLVE\n\ndeprecated:\n\n HAVE_ATKLIB\n"
  },
  {
    "path": "doc/developer/implementing_components.txt",
    "content": "HOWTO implement new openSMILE components:\n=========================================\n\nThis manual is under heavy construction.....\nIt only contains basic hints to get you started\n\n\nIn the source directory some examples for various component types are provided, which you should use as a starting point. These files contain some helpful documentation as comments in the source.\n\nTo create your new component from an existing component or an example source file use the perl scipt 'clonecomp.pl':\n>  perl clonecomp.pl <inputCompBase> <yourCompBase> <inputCompName> <yourCompName> \n\n(For a complete openSMILE class and component hierarchy, please refer to the file classes.txt)\n\nEach component is a descendant of cSmileComponent. This base class encapsulates all the functionality required for accessing the configuration data, managing the configuration and finalisation process of all components, and running components ('ticking'). See smile_component.txt (TODO!) for more information on cSmileComponent and the complete component architecture of openSMILE.\n\nGenerally speaking, there are three basic types of components used in openSMILE:\n \n 1. Data Sources  (cDataSource descendants, see exampleSource.hpp/cpp)\n   \n    A data source contains a writer sub-component (cDataWriter), which is responsible for writing data to exactly one level of the data memory (see cDataProcessor description below).\n    Implement a descendant of THIS component if you want to add a new input format, e.g. MP3 or feature file import (HTK, ARFF, etc.) \n\n 2. Data Processors (cDataProcessor descendants, see exampleProcessor.hpp/cpp)\n\n    A data processor contains both reader and writer components (cDataReader and cDataWriter). The general purpose of a data processor is to read data from the data memory (from one or more levels) and write data to one single level (NOTE: each writer has exclusive access to exactly on level, i.e. each level is written to by exactly one writer and thus by exactly one data processor or data source component).\n   THIS component is the one you most likely want to inherit if you want to implement new FEATURES.\n   Please also see below, for special kinds of data processors for common processing tasks!\n\n 3. Data Sinks (cDataSink descendants, see exampleSink.hpp/cpp)\n\n    A data sinks contains a reader sub-component (cDataReader), which is responsible for\n    the 'read' interface to a specific data memory level (or multiple levels)\n    Implement a descendant of THIS component, if you want to add support for more data output formats (e.g. sending data over a network, real-time visualisation of data via a GUI, etc.)\n\n\nSince the data processors are very general components, two special descendants have been implemented:\n\ncVectorProcessor:\n  This class allows an easy frame by frame processing of data (mostly processing of feature frames in the spectral domain). Input framesize can be different from the output framesize, thus it is very flexible. Algorithms such as signal window function, FFT, Mfcc, Chroma, etc. are implemented using cVectorProcessor as base. See exampleVectorProcessor.hpp/cpp for an example to start with.\n\ncWindowProcessor:\n  This class allows processing of signal windows (e.g. filters, functionals, etc.).\n  The main functionality provided, is automatic overlap of signal windows, i.e. for having access to past and future samples in a certain window, yet still offering the possibility of block processing for efficient algorithms. See preemphasis.cpp/hpp for an example.\n\ncWinToVecProcessor:\n  This class takes data from a signal window and produces a single value or vector of values (frame) for this window. You can specify an overlap (via frameStep and frameSize). This class is used for windowing the input wave-form signal, but can also be inherited for implementing data summaries (i.e. statistical functionals). See framer.cpp/hpp for an example implementation of a descendant class.\n\n\n\n"
  },
  {
    "path": "doc/developer/messages.txt",
    "content": "This file shall contain all messages various components send. So, if you add a component which sends a message (also as plugin), please add your message documentation to this file!\n\nYou must list the type (name) of the message, and the parameters that are send along with the message f[x] is a float value and i[x] is an int value. (DocTodo: string values, message names, etc.)\n\nComponent: cTurnDetector:\n=========================\n**Sends:**\n Message: type = turnStart  [sent when a turn start is detected]\n   - f[0] = nPre setting of turn Detector, i.e. the number of frames that the actual turn start is in the past, when the message is sent\n   - f[1] = vIdx start of turn (actual position, i.e. current - nPre)\n   - f[2] = period of turn detector's input level(s)\n   - userTime1 = smile time of actual turn start\n\n Message: type = turnEnd    [sent when a turn end is detected]\n   - f[0] = nPost setting of turn Detector, i.e. the number of frames that the actual turn end is in the past, when the message is sent\n   - f[1] = vIdx end of turn (actual position, i.e. current - nPost)\n   - f[2] = period of turn detector's input level(s)\n   - i[0] = forced turn end\n   - userTime1 = smile time of actual turn end\n\n Message: type = turnFrameTime  (former frameTime!)  \n          [ sent at turn end and inbetween in configurable intervals ]\n   - i[0] = isTurn end (1=message was sent at turn end, 0=message sent during turn)\n   - i[1] = 0=normal end / 1=forced turn end (max length) / 2=forced turn End (EOI)\n   - i[5] = custom chunk ID\n   - f[0] = actual vIdx start of turn\n   - f[1] = actual vIdx end of turn\n   - f[2] = actual start of turn in seconds (vTime)\n   - f[3] = actual end of turn in seconds (vTime)\n   - f[4] = period of turn detector's input level(s)\n   - userTime1 = smile time of actual turn start\n   - userTime2 = smile time of actual turn end\n\n Message: type = turnSpeakingStatus   [ sent always when voice activity starts/stops  ]\n   - i[0] = 1/0 voice activity true/false\n   - f[1] = vIdx of voice act. start/end (actual position)\n   - f[2] = period of turn detector's input level(s)\n   - userTime1 = smile time of actual voice activity start / end\n\nComponent: cLibSvmLiveSink:  (or maybe general classifier??)\n===========================\n**Sends:**\n  Message: type = classificationResult\n   - f[0] = result (either class index or regression target value)\n   - i[0] = number of classes (0 => regression)\n   - i[1] = isFInal flag\n   - i[2] = model index\n   - i[3] = mmm?\n   - i[5] = custom ID (from tmeta->metadata.ID ; i[5] in turnFrameTime message)\n   - custData * = pointer to a libsvm probEstim array (= double[nClasses])\n   - msgtext = name of target class (filled with NULL's, if regression problem)\n   - msgname = set by user field in config section of cLibSvmLiveSink\n   - userTime1 = smile time when first frame used for classification was initally (from source) written to data memory\n   - userTime2 = smile time when last frame used for classification was initally (from source) written to data memory\n\nComponent: cTumkwsjSink:  (general: keyword spotter)\n=========================\n**Sends:**\n  Message: type = asrKeywordOutput\n    - f[0] ...\n\n\nComponent: cWinToVecProcessor / cFramer / etc.\n==========================\n**Receives:**\n  Message: type = turnEnd\n  Message: type = turnFrameTime  (??)\n\n\nComponent: cJuliusSink\n==========================\n**Sends:**\n  Message: type = juliusResult\n\nMessage: type = textString  (sent to cBowProducer)\n\n\n"
  },
  {
    "path": "doc/knownBugs.txt",
    "content": "A current list of known bugs / issues in openSMILE:\n===================================================\n\n******************************************\n***** BUILD/COMPILE/INSTALL problems *****\n******************************************\n\n--------\nIf you get errors during ./configure, such as:\n  \"Makefile.in\" file not found!\nYou might have ignored the error message from ./autogen.sh:\n  configure.ac:11: required file `./ltmain.sh' not found\n\nRe-run ./autogen.sh a second time and run ./configure again to solve this.\n-------\n\n-------\nopenEAR live system:\n\nif the console based live recogniser doesn't start up, \n  check for error messages concerning \"listDevices\" \n  if you find some, open emobase_live4.conf and comment of the line\n   listDevices=1  !\n\nthe live system won't run in linux.\n - check if you have explicitely compiled with portaudio support!\n   the live system does not run without openSmile being compiled with portaudio support\n\n-------\n\n------\nusing cArffSource:\n\nPlease bear in mind that cArffSource reads only numeric/real attributes. If there are none in the arff file to read, you will get an error message.\n------\n\n------\nProblems with WAVE files:\n\nopenEAR should read all standard RIFF PCM files with linear (no ADPCM, etc.), uncompressed (!) WAVE data and no fancy extensions to the wave header. However, there might be an issue with big endian and little endian. No conversion is performed there. You should always create the wave file on the system on which you compile and run openEAR. If you use Intel systems only, then there should be no problem.\nI have attached a wave file, which works with openEAR. Usually any wave file that is created with sox or audacity does work. \nIf you still have trouble reading your wave files, please run SMILExtract with the additional parameters \"-l 4 -d\" and send us the file \"smile.log\". We would also appreciate to have a sample wave file, which is not working, so we can analyse the format.\n\n------\n\n\n"
  },
  {
    "path": "doc/logger.txt",
    "content": "Messages:\r\n\r\nSMILE_ERR(level,\"text....%i\",var1);\r\nSMILE_WRN\r\nSMILE_MSG\r\nSMILE_DBG\r\n\r\nExceptions:\r\n\r\nCOMP_ERR(\"text... variable %i\",var1);\r\n\r\n"
  },
  {
    "path": "ide/vs10/generalProps.props",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ImportGroup Label=\"PropertySheets\" />\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <PropertyGroup />\r\n  <ItemDefinitionGroup>\r\n    <ClCompile>\r\n      <AdditionalIncludeDirectories>..\\..\\src\\include;..\\..\\src\\svm;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>__VISTA;_WINDOWS;__WINDOWS;WIN32;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup />\r\n</Project>"
  },
  {
    "path": "ide/vs10/generalPropsDebug.props",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ImportGroup Label=\"PropertySheets\" />\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <PropertyGroup />\r\n  <ItemDefinitionGroup>\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup />\r\n</Project>"
  },
  {
    "path": "ide/vs10/generalPropsDll.props",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ImportGroup Label=\"PropertySheets\" />\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <PropertyGroup />\r\n  <ItemDefinitionGroup>\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>_USRDLL;OPENSMILELIB_EXPORTS;BUILDING_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup />\r\n</Project>"
  },
  {
    "path": "ide/vs10/generalPropsRelease.props",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ImportGroup Label=\"PropertySheets\" />\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <PropertyGroup />\r\n  <ItemDefinitionGroup>\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup />\r\n</Project>"
  },
  {
    "path": "ide/vs10/lstmRnn.props",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ImportGroup Label=\"PropertySheets\" />\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <PropertyGroup />\r\n  <ItemDefinitionGroup>\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>BUILD_RNN;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup />\r\n</Project>"
  },
  {
    "path": "ide/vs10/openSmile.sln",
    "content": "﻿\r\nMicrosoft Visual Studio Solution File, Format Version 11.00\r\n# Visual Studio 2010\r\nProject(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\") = \"Solution Items\", \"Solution Items\", \"{DB5A63BC-5D9D-4E15-AAC6-644414035980}\"\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"SMILExtract\", \"openSmile.vcxproj\", \"{264EDD6D-E130-4E30-9607-D6D74EF856B5}\"\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"openSmileLib\", \"openSmileLib.vcxproj\", \"{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{B2F72986-3DFF-4113-9346-DD4FD485C8B0} = {B2F72986-3DFF-4113-9346-DD4FD485C8B0}\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C} = {7361A0F8-87E5-4539-B912-880FE6FAA86C}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"openSmileLibPortaudio\", \"openSmileLibPortaudio.vcxproj\", \"{B2F72986-3DFF-4113-9346-DD4FD485C8B0}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99} = {0A18A071-125E-442F-AFF7-A3F68ABECF99}\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"portaudio\", \"..\\..\\thirdparty\\portaudio\\build\\msvc\\portaudio.vcxproj\", \"{0A18A071-125E-442F-AFF7-A3F68ABECF99}\"\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"openSmileLibClassif\", \"openSmileLibClassif.vcxproj\", \"{7361A0F8-87E5-4539-B912-880FE6FAA86C}\"\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"openSmileLibLibsvm\", \"openSmileLibLibsvm.vcxproj\", \"{17F673EA-8364-4B82-BC98-895CCD40D5F0}\"\r\nEndProject\r\nGlobal\r\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\r\n\t\tDebug|Win32 = Debug|Win32\r\n\t\tDebug|x64 = Debug|x64\r\n\t\tDebugOpenCV|Win32 = DebugOpenCV|Win32\r\n\t\tDebugOpenCV|x64 = DebugOpenCV|x64\r\n\t\tDebugPortaudio|Win32 = DebugPortaudio|Win32\r\n\t\tDebugPortaudio|x64 = DebugPortaudio|x64\r\n\t\tDebugPortaudioOpenCV|Win32 = DebugPortaudioOpenCV|Win32\r\n\t\tDebugPortaudioOpenCV|x64 = DebugPortaudioOpenCV|x64\r\n\t\tRelease|Win32 = Release|Win32\r\n\t\tRelease|x64 = Release|x64\r\n\t\tReleaseOpenCV|Win32 = ReleaseOpenCV|Win32\r\n\t\tReleaseOpenCV|x64 = ReleaseOpenCV|x64\r\n\t\tReleasePortaudio|Win32 = ReleasePortaudio|Win32\r\n\t\tReleasePortaudio|x64 = ReleasePortaudio|x64\r\n\t\tReleasePortaudioOpenCV|Win32 = ReleasePortaudioOpenCV|Win32\r\n\t\tReleasePortaudioOpenCV|x64 = ReleasePortaudioOpenCV|x64\r\n\tEndGlobalSection\r\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n\t\t{264EDD6D-E130-4E30-9607-D6D74EF856B5}.Debug|Win32.ActiveCfg = Debug|Win32\r\n\t\t{264EDD6D-E130-4E30-9607-D6D74EF856B5}.Debug|Win32.Build.0 = Debug|Win32\r\n\t\t{264EDD6D-E130-4E30-9607-D6D74EF856B5}.Debug|x64.ActiveCfg = Debug|Win32\r\n\t\t{264EDD6D-E130-4E30-9607-D6D74EF856B5}.DebugOpenCV|Win32.ActiveCfg = DebugOpenCV|Win32\r\n\t\t{264EDD6D-E130-4E30-9607-D6D74EF856B5}.DebugOpenCV|Win32.Build.0 = DebugOpenCV|Win32\r\n\t\t{264EDD6D-E130-4E30-9607-D6D74EF856B5}.DebugOpenCV|x64.ActiveCfg = DebugOpenCV|Win32\r\n\t\t{264EDD6D-E130-4E30-9607-D6D74EF856B5}.DebugPortaudio|Win32.ActiveCfg = DebugPortaudio|Win32\r\n\t\t{264EDD6D-E130-4E30-9607-D6D74EF856B5}.DebugPortaudio|Win32.Build.0 = DebugPortaudio|Win32\r\n\t\t{264EDD6D-E130-4E30-9607-D6D74EF856B5}.DebugPortaudio|x64.ActiveCfg = DebugPortaudio|Win32\r\n\t\t{264EDD6D-E130-4E30-9607-D6D74EF856B5}.DebugPortaudioOpenCV|Win32.ActiveCfg = DebugPortaudioOpenCV|Win32\r\n\t\t{264EDD6D-E130-4E30-9607-D6D74EF856B5}.DebugPortaudioOpenCV|Win32.Build.0 = DebugPortaudioOpenCV|Win32\r\n\t\t{264EDD6D-E130-4E30-9607-D6D74EF856B5}.DebugPortaudioOpenCV|x64.ActiveCfg = DebugPortaudioOpenCV|Win32\r\n\t\t{264EDD6D-E130-4E30-9607-D6D74EF856B5}.Release|Win32.ActiveCfg = Release|Win32\r\n\t\t{264EDD6D-E130-4E30-9607-D6D74EF856B5}.Release|Win32.Build.0 = Release|Win32\r\n\t\t{264EDD6D-E130-4E30-9607-D6D74EF856B5}.Release|x64.ActiveCfg = Release|Win32\r\n\t\t{264EDD6D-E130-4E30-9607-D6D74EF856B5}.ReleaseOpenCV|Win32.ActiveCfg = ReleaseOpenCV|Win32\r\n\t\t{264EDD6D-E130-4E30-9607-D6D74EF856B5}.ReleaseOpenCV|Win32.Build.0 = ReleaseOpenCV|Win32\r\n\t\t{264EDD6D-E130-4E30-9607-D6D74EF856B5}.ReleaseOpenCV|x64.ActiveCfg = ReleaseOpenCV|Win32\r\n\t\t{264EDD6D-E130-4E30-9607-D6D74EF856B5}.ReleasePortaudio|Win32.ActiveCfg = ReleasePortaudio|Win32\r\n\t\t{264EDD6D-E130-4E30-9607-D6D74EF856B5}.ReleasePortaudio|Win32.Build.0 = ReleasePortaudio|Win32\r\n\t\t{264EDD6D-E130-4E30-9607-D6D74EF856B5}.ReleasePortaudio|x64.ActiveCfg = ReleasePortaudio|Win32\r\n\t\t{264EDD6D-E130-4E30-9607-D6D74EF856B5}.ReleasePortaudioOpenCV|Win32.ActiveCfg = ReleasePortAudioOpenCV|Win32\r\n\t\t{264EDD6D-E130-4E30-9607-D6D74EF856B5}.ReleasePortaudioOpenCV|Win32.Build.0 = ReleasePortAudioOpenCV|Win32\r\n\t\t{264EDD6D-E130-4E30-9607-D6D74EF856B5}.ReleasePortaudioOpenCV|x64.ActiveCfg = ReleasePortAudioOpenCV|Win32\r\n\t\t{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}.Debug|Win32.ActiveCfg = Debug|Win32\r\n\t\t{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}.Debug|Win32.Build.0 = Debug|Win32\r\n\t\t{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}.Debug|x64.ActiveCfg = Debug|Win32\r\n\t\t{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}.DebugOpenCV|Win32.ActiveCfg = DebugOpenCV|Win32\r\n\t\t{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}.DebugOpenCV|Win32.Build.0 = DebugOpenCV|Win32\r\n\t\t{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}.DebugOpenCV|x64.ActiveCfg = DebugOpenCV|Win32\r\n\t\t{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}.DebugPortaudio|Win32.ActiveCfg = DebugPortaudio|Win32\r\n\t\t{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}.DebugPortaudio|Win32.Build.0 = DebugPortaudio|Win32\r\n\t\t{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}.DebugPortaudio|x64.ActiveCfg = DebugPortaudio|Win32\r\n\t\t{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}.DebugPortaudioOpenCV|Win32.ActiveCfg = DebugPortaudioOpenCV|Win32\r\n\t\t{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}.DebugPortaudioOpenCV|Win32.Build.0 = DebugPortaudioOpenCV|Win32\r\n\t\t{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}.DebugPortaudioOpenCV|x64.ActiveCfg = DebugPortaudioOpenCV|Win32\r\n\t\t{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}.Release|Win32.ActiveCfg = Release|Win32\r\n\t\t{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}.Release|Win32.Build.0 = Release|Win32\r\n\t\t{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}.Release|x64.ActiveCfg = Release|Win32\r\n\t\t{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}.ReleaseOpenCV|Win32.ActiveCfg = ReleaseOpenCV|Win32\r\n\t\t{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}.ReleaseOpenCV|Win32.Build.0 = ReleaseOpenCV|Win32\r\n\t\t{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}.ReleaseOpenCV|x64.ActiveCfg = ReleaseOpenCV|Win32\r\n\t\t{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}.ReleasePortaudio|Win32.ActiveCfg = ReleasePortaudio|Win32\r\n\t\t{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}.ReleasePortaudio|Win32.Build.0 = ReleasePortaudio|Win32\r\n\t\t{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}.ReleasePortaudio|x64.ActiveCfg = ReleasePortaudio|Win32\r\n\t\t{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}.ReleasePortaudioOpenCV|Win32.ActiveCfg = ReleasePortAudioOpenCV|Win32\r\n\t\t{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}.ReleasePortaudioOpenCV|Win32.Build.0 = ReleasePortAudioOpenCV|Win32\r\n\t\t{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}.ReleasePortaudioOpenCV|x64.ActiveCfg = ReleasePortAudioOpenCV|Win32\r\n\t\t{B2F72986-3DFF-4113-9346-DD4FD485C8B0}.Debug|Win32.ActiveCfg = Debug|Win32\r\n\t\t{B2F72986-3DFF-4113-9346-DD4FD485C8B0}.Debug|x64.ActiveCfg = Debug|Win32\r\n\t\t{B2F72986-3DFF-4113-9346-DD4FD485C8B0}.DebugOpenCV|Win32.ActiveCfg = DebugOpenCV|Win32\r\n\t\t{B2F72986-3DFF-4113-9346-DD4FD485C8B0}.DebugOpenCV|x64.ActiveCfg = DebugOpenCV|Win32\r\n\t\t{B2F72986-3DFF-4113-9346-DD4FD485C8B0}.DebugPortaudio|Win32.ActiveCfg = DebugPortaudio|Win32\r\n\t\t{B2F72986-3DFF-4113-9346-DD4FD485C8B0}.DebugPortaudio|Win32.Build.0 = DebugPortaudio|Win32\r\n\t\t{B2F72986-3DFF-4113-9346-DD4FD485C8B0}.DebugPortaudio|x64.ActiveCfg = Debug|Win32\r\n\t\t{B2F72986-3DFF-4113-9346-DD4FD485C8B0}.DebugPortaudioOpenCV|Win32.ActiveCfg = DebugPortaudioOpenCV|Win32\r\n\t\t{B2F72986-3DFF-4113-9346-DD4FD485C8B0}.DebugPortaudioOpenCV|Win32.Build.0 = DebugPortaudioOpenCV|Win32\r\n\t\t{B2F72986-3DFF-4113-9346-DD4FD485C8B0}.DebugPortaudioOpenCV|x64.ActiveCfg = DebugPortaudioOpenCV|Win32\r\n\t\t{B2F72986-3DFF-4113-9346-DD4FD485C8B0}.Release|Win32.ActiveCfg = Release|Win32\r\n\t\t{B2F72986-3DFF-4113-9346-DD4FD485C8B0}.Release|Win32.Build.0 = Release|Win32\r\n\t\t{B2F72986-3DFF-4113-9346-DD4FD485C8B0}.Release|x64.ActiveCfg = Release|Win32\r\n\t\t{B2F72986-3DFF-4113-9346-DD4FD485C8B0}.ReleaseOpenCV|Win32.ActiveCfg = ReleaseOpenCV|Win32\r\n\t\t{B2F72986-3DFF-4113-9346-DD4FD485C8B0}.ReleaseOpenCV|Win32.Build.0 = ReleaseOpenCV|Win32\r\n\t\t{B2F72986-3DFF-4113-9346-DD4FD485C8B0}.ReleaseOpenCV|x64.ActiveCfg = ReleaseOpenCV|Win32\r\n\t\t{B2F72986-3DFF-4113-9346-DD4FD485C8B0}.ReleasePortaudio|Win32.ActiveCfg = ReleasePortaudio|Win32\r\n\t\t{B2F72986-3DFF-4113-9346-DD4FD485C8B0}.ReleasePortaudio|Win32.Build.0 = ReleasePortaudio|Win32\r\n\t\t{B2F72986-3DFF-4113-9346-DD4FD485C8B0}.ReleasePortaudio|x64.ActiveCfg = Release|Win32\r\n\t\t{B2F72986-3DFF-4113-9346-DD4FD485C8B0}.ReleasePortaudioOpenCV|Win32.ActiveCfg = ReleasePortAudioOpenCV|Win32\r\n\t\t{B2F72986-3DFF-4113-9346-DD4FD485C8B0}.ReleasePortaudioOpenCV|Win32.Build.0 = ReleasePortAudioOpenCV|Win32\r\n\t\t{B2F72986-3DFF-4113-9346-DD4FD485C8B0}.ReleasePortaudioOpenCV|x64.ActiveCfg = ReleasePortAudioOpenCV|Win32\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|Win32.ActiveCfg = Debug|Win32\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.DebugOpenCV|Win32.ActiveCfg = Debug|x64\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.DebugOpenCV|x64.ActiveCfg = Debug|x64\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.DebugOpenCV|x64.Build.0 = Debug|x64\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.DebugPortaudio|Win32.ActiveCfg = Debug|Win32\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.DebugPortaudio|Win32.Build.0 = Debug|Win32\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.DebugPortaudio|x64.ActiveCfg = Debug|x64\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.DebugPortaudio|x64.Build.0 = Debug|x64\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.DebugPortaudioOpenCV|Win32.ActiveCfg = Debug|x64\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.DebugPortaudioOpenCV|x64.ActiveCfg = Debug|x64\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.DebugPortaudioOpenCV|x64.Build.0 = Debug|x64\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|Win32.ActiveCfg = Release|Win32\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|Win32.Build.0 = Release|Win32\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|x64.Build.0 = Release|x64\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.ReleaseOpenCV|Win32.ActiveCfg = Release|x64\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.ReleaseOpenCV|x64.ActiveCfg = Release|x64\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.ReleaseOpenCV|x64.Build.0 = Release|x64\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.ReleasePortaudio|Win32.ActiveCfg = Release|Win32\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.ReleasePortaudio|Win32.Build.0 = Release|Win32\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.ReleasePortaudio|x64.ActiveCfg = Release|x64\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.ReleasePortaudio|x64.Build.0 = Release|x64\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.ReleasePortaudioOpenCV|Win32.ActiveCfg = Release|x64\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.ReleasePortaudioOpenCV|x64.ActiveCfg = Release|x64\r\n\t\t{0A18A071-125E-442F-AFF7-A3F68ABECF99}.ReleasePortaudioOpenCV|x64.Build.0 = Release|x64\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C}.Debug|Win32.ActiveCfg = Debug|Win32\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C}.Debug|Win32.Build.0 = Debug|Win32\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C}.Debug|x64.ActiveCfg = Debug|Win32\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C}.DebugOpenCV|Win32.ActiveCfg = DebugOpenCV|Win32\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C}.DebugOpenCV|Win32.Build.0 = DebugOpenCV|Win32\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C}.DebugOpenCV|x64.ActiveCfg = DebugOpenCV|Win32\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C}.DebugPortaudio|Win32.ActiveCfg = Debug|Win32\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C}.DebugPortaudio|Win32.Build.0 = Debug|Win32\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C}.DebugPortaudio|x64.ActiveCfg = Debug|Win32\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C}.DebugPortaudioOpenCV|Win32.ActiveCfg = DebugPortaudioOpenCV|Win32\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C}.DebugPortaudioOpenCV|Win32.Build.0 = DebugPortaudioOpenCV|Win32\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C}.DebugPortaudioOpenCV|x64.ActiveCfg = DebugPortaudioOpenCV|Win32\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C}.Release|Win32.ActiveCfg = Release|Win32\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C}.Release|Win32.Build.0 = Release|Win32\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C}.Release|x64.ActiveCfg = Release|Win32\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C}.ReleaseOpenCV|Win32.ActiveCfg = ReleaseOpenCV|Win32\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C}.ReleaseOpenCV|Win32.Build.0 = ReleaseOpenCV|Win32\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C}.ReleaseOpenCV|x64.ActiveCfg = ReleaseOpenCV|Win32\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C}.ReleasePortaudio|Win32.ActiveCfg = Release|Win32\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C}.ReleasePortaudio|Win32.Build.0 = Release|Win32\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C}.ReleasePortaudio|x64.ActiveCfg = Release|Win32\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C}.ReleasePortaudioOpenCV|Win32.ActiveCfg = ReleasePortAudioOpenCV|Win32\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C}.ReleasePortaudioOpenCV|Win32.Build.0 = ReleasePortAudioOpenCV|Win32\r\n\t\t{7361A0F8-87E5-4539-B912-880FE6FAA86C}.ReleasePortaudioOpenCV|x64.ActiveCfg = ReleasePortAudioOpenCV|Win32\r\n\t\t{17F673EA-8364-4B82-BC98-895CCD40D5F0}.Debug|Win32.ActiveCfg = Debug|Win32\r\n\t\t{17F673EA-8364-4B82-BC98-895CCD40D5F0}.Debug|Win32.Build.0 = Debug|Win32\r\n\t\t{17F673EA-8364-4B82-BC98-895CCD40D5F0}.Debug|x64.ActiveCfg = Debug|Win32\r\n\t\t{17F673EA-8364-4B82-BC98-895CCD40D5F0}.DebugOpenCV|Win32.ActiveCfg = DebugOpenCV|Win32\r\n\t\t{17F673EA-8364-4B82-BC98-895CCD40D5F0}.DebugOpenCV|Win32.Build.0 = DebugOpenCV|Win32\r\n\t\t{17F673EA-8364-4B82-BC98-895CCD40D5F0}.DebugOpenCV|x64.ActiveCfg = DebugOpenCV|Win32\r\n\t\t{17F673EA-8364-4B82-BC98-895CCD40D5F0}.DebugPortaudio|Win32.ActiveCfg = Debug|Win32\r\n\t\t{17F673EA-8364-4B82-BC98-895CCD40D5F0}.DebugPortaudio|Win32.Build.0 = Debug|Win32\r\n\t\t{17F673EA-8364-4B82-BC98-895CCD40D5F0}.DebugPortaudio|x64.ActiveCfg = Debug|Win32\r\n\t\t{17F673EA-8364-4B82-BC98-895CCD40D5F0}.DebugPortaudioOpenCV|Win32.ActiveCfg = DebugPortaudioOpenCV|Win32\r\n\t\t{17F673EA-8364-4B82-BC98-895CCD40D5F0}.DebugPortaudioOpenCV|Win32.Build.0 = DebugPortaudioOpenCV|Win32\r\n\t\t{17F673EA-8364-4B82-BC98-895CCD40D5F0}.DebugPortaudioOpenCV|x64.ActiveCfg = DebugPortaudioOpenCV|Win32\r\n\t\t{17F673EA-8364-4B82-BC98-895CCD40D5F0}.Release|Win32.ActiveCfg = Release|Win32\r\n\t\t{17F673EA-8364-4B82-BC98-895CCD40D5F0}.Release|Win32.Build.0 = Release|Win32\r\n\t\t{17F673EA-8364-4B82-BC98-895CCD40D5F0}.Release|x64.ActiveCfg = Release|Win32\r\n\t\t{17F673EA-8364-4B82-BC98-895CCD40D5F0}.ReleaseOpenCV|Win32.ActiveCfg = ReleaseOpenCV|Win32\r\n\t\t{17F673EA-8364-4B82-BC98-895CCD40D5F0}.ReleaseOpenCV|Win32.Build.0 = ReleaseOpenCV|Win32\r\n\t\t{17F673EA-8364-4B82-BC98-895CCD40D5F0}.ReleaseOpenCV|x64.ActiveCfg = ReleaseOpenCV|Win32\r\n\t\t{17F673EA-8364-4B82-BC98-895CCD40D5F0}.ReleasePortaudio|Win32.ActiveCfg = Release|Win32\r\n\t\t{17F673EA-8364-4B82-BC98-895CCD40D5F0}.ReleasePortaudio|Win32.Build.0 = Release|Win32\r\n\t\t{17F673EA-8364-4B82-BC98-895CCD40D5F0}.ReleasePortaudio|x64.ActiveCfg = Release|Win32\r\n\t\t{17F673EA-8364-4B82-BC98-895CCD40D5F0}.ReleasePortaudioOpenCV|Win32.ActiveCfg = ReleasePortAudioOpenCV|Win32\r\n\t\t{17F673EA-8364-4B82-BC98-895CCD40D5F0}.ReleasePortaudioOpenCV|Win32.Build.0 = ReleasePortAudioOpenCV|Win32\r\n\t\t{17F673EA-8364-4B82-BC98-895CCD40D5F0}.ReleasePortaudioOpenCV|x64.ActiveCfg = ReleasePortAudioOpenCV|Win32\r\n\tEndGlobalSection\r\n\tGlobalSection(SolutionProperties) = preSolution\r\n\t\tHideSolutionNode = FALSE\r\n\tEndGlobalSection\r\nEndGlobal\r\n"
  },
  {
    "path": "ide/vs10/openSmile.vcproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"8,00\"\r\n\tName=\"openSmile\"\r\n\tProjectGUID=\"{264EDD6D-E130-4E30-9607-D6D74EF856B5}\"\r\n\tKeyword=\"Win32Proj\"\r\n\t>\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"\r\n\t\t/>\r\n\t</Platforms>\r\n\t<ToolFiles>\r\n\t</ToolFiles>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"Debug\"\r\n\t\t\tIntermediateDirectory=\"Debug\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"&quot;../../src&quot;;&quot;../..&quot;;&quot;../../svm&quot;\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_CONSOLE;__WINDOWS;_CRT_SECURE_NO_DEPRECATE\"\r\n\t\t\t\tMinimalRebuild=\"true\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"3\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"true\"\r\n\t\t\t\tDebugInformationFormat=\"4\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"openSmileLibDbg.lib\"\r\n\t\t\t\tOutputFile=\"..\\..\\SMILExtractDbg.exe\"\r\n\t\t\t\tLinkIncremental=\"2\"\r\n\t\t\t\tAdditionalLibraryDirectories=\"&quot;..\\..&quot;\"\r\n\t\t\t\tGenerateDebugInformation=\"true\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tTargetMachine=\"1\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"Release\"\r\n\t\t\tIntermediateDirectory=\"Release\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"&quot;../../src/include&quot;;&quot;../../progsrc/include&quot;;&quot;../..&quot;;&quot;../../src/svm&quot;\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_CONSOLE;__WINDOWS;_CRT_SECURE_NO_DEPRECATE\"\r\n\t\t\t\tExceptionHandling=\"2\"\r\n\t\t\t\tRuntimeLibrary=\"2\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"true\"\r\n\t\t\t\tDebugInformationFormat=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"openSmileLib.lib\"\r\n\t\t\t\tOutputFile=\"..\\..\\..\\msvcbuild\\SMILExtract.exe\"\r\n\t\t\t\tLinkIncremental=\"2\"\r\n\t\t\t\tAdditionalLibraryDirectories=\"&quot;..\\..&quot;\"\r\n\t\t\t\tGenerateDebugInformation=\"true\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tOptimizeReferences=\"2\"\r\n\t\t\t\tEnableCOMDATFolding=\"2\"\r\n\t\t\t\tTargetMachine=\"1\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"DebugPortaudio|Win32\"\r\n\t\t\tOutputDirectory=\"$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(ConfigurationName)\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"&quot;../../src&quot;;&quot;../..&quot;;&quot;../../svm&quot;\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_CONSOLE;__WINDOWS;_CRT_SECURE_NO_DEPRECATE\"\r\n\t\t\t\tMinimalRebuild=\"true\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"3\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"true\"\r\n\t\t\t\tDebugInformationFormat=\"4\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"openSmileLibDbg.lib\"\r\n\t\t\t\tOutputFile=\"..\\..\\SMILExtractDbg.exe\"\r\n\t\t\t\tLinkIncremental=\"2\"\r\n\t\t\t\tAdditionalLibraryDirectories=\"&quot;..\\..&quot;\"\r\n\t\t\t\tGenerateDebugInformation=\"true\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tTargetMachine=\"1\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"ReleasePortaudio|Win32\"\r\n\t\t\tOutputDirectory=\"$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(ConfigurationName)\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"&quot;../../src&quot;;&quot;../..&quot;;&quot;../../svm&quot;\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_CONSOLE;__WINDOWS;_CRT_SECURE_NO_DEPRECATE\"\r\n\t\t\t\tExceptionHandling=\"2\"\r\n\t\t\t\tRuntimeLibrary=\"2\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"true\"\r\n\t\t\t\tDebugInformationFormat=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"openSmileLib.lib\"\r\n\t\t\t\tOutputFile=\"..\\..\\SMILExtract.exe\"\r\n\t\t\t\tLinkIncremental=\"2\"\r\n\t\t\t\tAdditionalLibraryDirectories=\"&quot;..\\..&quot;\"\r\n\t\t\t\tGenerateDebugInformation=\"true\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tOptimizeReferences=\"2\"\r\n\t\t\t\tEnableCOMDATFolding=\"2\"\r\n\t\t\t\tTargetMachine=\"1\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"DebugNmf|Win32\"\r\n\t\t\tOutputDirectory=\"$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(ConfigurationName)\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"&quot;../../src&quot;;&quot;../..&quot;;&quot;../../svm&quot;\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_CONSOLE;__WINDOWS;_CRT_SECURE_NO_DEPRECATE\"\r\n\t\t\t\tMinimalRebuild=\"true\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"3\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"true\"\r\n\t\t\t\tDebugInformationFormat=\"4\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"openSmileLibDbg.lib\"\r\n\t\t\t\tOutputFile=\"..\\..\\SMILExtractDbg.exe\"\r\n\t\t\t\tLinkIncremental=\"2\"\r\n\t\t\t\tAdditionalLibraryDirectories=\"&quot;..\\..&quot;\"\r\n\t\t\t\tGenerateDebugInformation=\"true\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tTargetMachine=\"1\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"ReleaseNmf|Win32\"\r\n\t\t\tOutputDirectory=\"$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(ConfigurationName)\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"&quot;../../src&quot;;&quot;../..&quot;;&quot;../../svm&quot;\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_CONSOLE;__WINDOWS;_CRT_SECURE_NO_DEPRECATE\"\r\n\t\t\t\tExceptionHandling=\"2\"\r\n\t\t\t\tRuntimeLibrary=\"2\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"true\"\r\n\t\t\t\tDebugInformationFormat=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"openSmileLib.lib\"\r\n\t\t\t\tOutputFile=\"..\\..\\SMILExtract.exe\"\r\n\t\t\t\tLinkIncremental=\"2\"\r\n\t\t\t\tAdditionalLibraryDirectories=\"&quot;..\\..&quot;\"\r\n\t\t\t\tGenerateDebugInformation=\"true\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tOptimizeReferences=\"2\"\r\n\t\t\t\tEnableCOMDATFolding=\"2\"\r\n\t\t\t\tTargetMachine=\"1\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"ReleaseNet|Win32\"\r\n\t\t\tOutputDirectory=\"$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(ConfigurationName)\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"&quot;../../src/include&quot;;&quot;../../progsrc/include&quot;;&quot;../..&quot;;&quot;../../src/svm&quot;\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_CONSOLE;__WINDOWS;_CRT_SECURE_NO_DEPRECATE\"\r\n\t\t\t\tExceptionHandling=\"2\"\r\n\t\t\t\tRuntimeLibrary=\"2\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"true\"\r\n\t\t\t\tDebugInformationFormat=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"openSmileLib.lib\"\r\n\t\t\t\tOutputFile=\"..\\..\\SMILExtract.exe\"\r\n\t\t\t\tLinkIncremental=\"2\"\r\n\t\t\t\tAdditionalLibraryDirectories=\"&quot;..\\..&quot;\"\r\n\t\t\t\tGenerateDebugInformation=\"true\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tOptimizeReferences=\"2\"\r\n\t\t\t\tEnableCOMDATFolding=\"2\"\r\n\t\t\t\tTargetMachine=\"1\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc;xsd\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\"\r\n\t\t\t>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Resource Files\"\r\n\t\t\tFilter=\"rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx\"\r\n\t\t\tUniqueIdentifier=\"{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}\"\r\n\t\t\t>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\"\r\n\t\t\t>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\..\\progsrc\\smilextract\\SMILExtract.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "ide/vs10/openSmile.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"DebugOpenCV|Win32\">\r\n      <Configuration>DebugOpenCV</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"DebugPortaudioOpenCV|Win32\">\r\n      <Configuration>DebugPortaudioOpenCV</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"DebugPortaudio|Win32\">\r\n      <Configuration>DebugPortaudio</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Debug|Win32\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"ReleaseOpenCV|Win32\">\r\n      <Configuration>ReleaseOpenCV</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"ReleasePortAudioOpenCV|Win32\">\r\n      <Configuration>ReleasePortAudioOpenCV</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"ReleasePortaudio|Win32\">\r\n      <Configuration>ReleasePortaudio</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|Win32\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{264EDD6D-E130-4E30-9607-D6D74EF856B5}</ProjectGuid>\r\n    <Keyword>Win32Proj</Keyword>\r\n    <ProjectName>SMILExtract</ProjectName>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortaudio|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudio|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortaudio|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsRelease.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n    <Import Project=\"portaudio.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsRelease.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n    <Import Project=\"portaudio.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudio|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsDebug.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n    <Import Project=\"portaudio.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsDebug.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n    <Import Project=\"portaudio.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsRelease.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsRelease.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsDebug.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsDebug.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">$(Configuration)\\</OutDir>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\">$(Configuration)\\</OutDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">$(Configuration)\\</IntDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\">$(Configuration)\\</IntDir>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</LinkIncremental>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\">true</LinkIncremental>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">$(Configuration)\\</OutDir>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\">$(Configuration)\\</OutDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">$(Configuration)\\</IntDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\">$(Configuration)\\</IntDir>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">true</LinkIncremental>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\">true</LinkIncremental>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudio|Win32'\">$(Configuration)\\</OutDir>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\">$(Configuration)\\</OutDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudio|Win32'\">$(Configuration)\\</IntDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\">$(Configuration)\\</IntDir>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudio|Win32'\">true</LinkIncremental>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\">true</LinkIncremental>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortaudio|Win32'\">$(Configuration)\\</OutDir>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\">$(Configuration)\\</OutDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortaudio|Win32'\">$(Configuration)\\</IntDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\">$(Configuration)\\</IntDir>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortaudio|Win32'\">true</LinkIncremental>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\">true</LinkIncremental>\r\n    <TargetName Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudio|Win32'\">$(ProjectName)_$(Configuration)</TargetName>\r\n    <TargetName Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\">$(ProjectName)_$(Configuration)</TargetName>\r\n    <TargetName Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">$(ProjectName)_$(Configuration)</TargetName>\r\n    <TargetName Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\">$(ProjectName)_$(Configuration)</TargetName>\r\n    <TargetName Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortaudio|Win32'\">$(ProjectName)_$(Configuration)</TargetName>\r\n    <TargetName Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\">$(ProjectName)_$(Configuration)</TargetName>\r\n    <TargetName Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">$(ProjectName)_$(Configuration)</TargetName>\r\n    <TargetName Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\">$(ProjectName)_$(Configuration)</TargetName>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <ClCompile>\r\n      <Optimization>Disabled</Optimization>\r\n      <AdditionalIncludeDirectories>..\\..\\progsrc\\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <MinimalRebuild>true</MinimalRebuild>\r\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>..\\..\\..\\msvcbuild\\$(TargetName)$(TargetExt)</OutputFile>\r\n      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <SubSystem>Console</SubSystem>\r\n      <TargetMachine>MachineX86</TargetMachine>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\">\r\n    <ClCompile>\r\n      <Optimization>Disabled</Optimization>\r\n      <AdditionalIncludeDirectories>..\\..\\progsrc\\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <MinimalRebuild>true</MinimalRebuild>\r\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>..\\..\\..\\msvcbuild\\$(TargetName)$(TargetExt)</OutputFile>\r\n      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <SubSystem>Console</SubSystem>\r\n      <TargetMachine>MachineX86</TargetMachine>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <ClCompile>\r\n      <AdditionalIncludeDirectories>..\\..\\progsrc\\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <ExceptionHandling>Async</ExceptionHandling>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>..\\..\\..\\msvcbuild\\$(TargetName)$(TargetExt)</OutputFile>\r\n      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <SubSystem>Console</SubSystem>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <TargetMachine>MachineX86</TargetMachine>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\">\r\n    <ClCompile>\r\n      <AdditionalIncludeDirectories>..\\..\\progsrc\\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <ExceptionHandling>Async</ExceptionHandling>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>..\\..\\..\\msvcbuild\\$(TargetName)$(TargetExt)</OutputFile>\r\n      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <SubSystem>Console</SubSystem>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <TargetMachine>MachineX86</TargetMachine>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudio|Win32'\">\r\n    <ClCompile>\r\n      <Optimization>Disabled</Optimization>\r\n      <AdditionalIncludeDirectories>..\\..\\progsrc\\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <MinimalRebuild>true</MinimalRebuild>\r\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>..\\..\\..\\msvcbuild\\$(TargetName)$(TargetExt)</OutputFile>\r\n      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <SubSystem>Console</SubSystem>\r\n      <TargetMachine>MachineX86</TargetMachine>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\">\r\n    <ClCompile>\r\n      <Optimization>Disabled</Optimization>\r\n      <AdditionalIncludeDirectories>..\\..\\progsrc\\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <MinimalRebuild>true</MinimalRebuild>\r\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>..\\..\\..\\msvcbuild\\$(TargetName)$(TargetExt)</OutputFile>\r\n      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <SubSystem>Console</SubSystem>\r\n      <TargetMachine>MachineX86</TargetMachine>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortaudio|Win32'\">\r\n    <ClCompile>\r\n      <AdditionalIncludeDirectories>..\\..\\progsrc\\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <ExceptionHandling>Async</ExceptionHandling>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>..\\..\\..\\msvcbuild\\$(TargetName)$(TargetExt)</OutputFile>\r\n      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <SubSystem>Console</SubSystem>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <TargetMachine>MachineX86</TargetMachine>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\">\r\n    <ClCompile>\r\n      <AdditionalIncludeDirectories>..\\..\\progsrc\\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <ExceptionHandling>Async</ExceptionHandling>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>..\\..\\..\\msvcbuild\\$(TargetName)$(TargetExt)</OutputFile>\r\n      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <SubSystem>Console</SubSystem>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <TargetMachine>MachineX86</TargetMachine>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"..\\..\\progsrc\\smilextract\\SMILExtract.cpp\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ProjectReference Include=\"openSmileLib.vcxproj\">\r\n      <Project>{f5f2b328-e89c-4ed7-9a16-91e547f99e6e}</Project>\r\n      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>\r\n    </ProjectReference>\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n</Project>"
  },
  {
    "path": "ide/vs10/openSmileComponents.props",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ImportGroup Label=\"PropertySheets\" />\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <PropertyGroup />\r\n  <ItemDefinitionGroup>\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>BUILD_LIBSVM;BUILD_RNN;BUILD_NETSTANDALONE;BUILD_SVMSMO;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup />\r\n</Project>"
  },
  {
    "path": "ide/vs10/openSmileLib.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"DebugOpenCV|Win32\">\r\n      <Configuration>DebugOpenCV</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"DebugPortaudioOpenCV|Win32\">\r\n      <Configuration>DebugPortaudioOpenCV</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"DebugPortaudio|Win32\">\r\n      <Configuration>DebugPortaudio</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Debug|Win32\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"ReleaseOpenCV|Win32\">\r\n      <Configuration>ReleaseOpenCV</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"ReleasePortAudioOpenCV|Win32\">\r\n      <Configuration>ReleasePortAudioOpenCV</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"ReleasePortaudio|Win32\">\r\n      <Configuration>ReleasePortaudio</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|Win32\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{F5F2B328-E89C-4ED7-9A16-91E547F99E6E}</ProjectGuid>\r\n    <Keyword>Win32Proj</Keyword>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortaudio|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudio|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortaudio|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsRelease.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n    <Import Project=\"portaudio.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsRelease.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n    <Import Project=\"portaudio.props\" />\r\n    <Import Project=\"opencv.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudio|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsDebug.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n    <Import Project=\"portaudio.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsDebug.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n    <Import Project=\"portaudio.props\" />\r\n    <Import Project=\"opencv.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsRelease.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsRelease.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n    <Import Project=\"opencv.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsDebug.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsDebug.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n    <Import Project=\"opencv.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">$(Configuration)\\</OutDir>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\">$(Configuration)\\</OutDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">$(Configuration)\\</IntDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\">$(Configuration)\\</IntDir>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</LinkIncremental>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\">true</LinkIncremental>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">$(Configuration)\\</OutDir>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\">$(Configuration)\\</OutDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">$(Configuration)\\</IntDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\">$(Configuration)\\</IntDir>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">true</LinkIncremental>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\">true</LinkIncremental>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudio|Win32'\">$(Configuration)\\</OutDir>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\">$(Configuration)\\</OutDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudio|Win32'\">$(Configuration)\\</IntDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\">$(Configuration)\\</IntDir>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudio|Win32'\">true</LinkIncremental>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\">true</LinkIncremental>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortaudio|Win32'\">$(Configuration)\\</OutDir>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\">$(Configuration)\\</OutDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortaudio|Win32'\">$(Configuration)\\</IntDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\">$(Configuration)\\</IntDir>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortaudio|Win32'\">true</LinkIncremental>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\">true</LinkIncremental>\r\n    <TargetName Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">openSmileLib_$(Configuration)</TargetName>\r\n    <TargetName Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\">openSmileLib_$(Configuration)</TargetName>\r\n    <TargetName Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudio|Win32'\">openSmileLib_$(Configuration)</TargetName>\r\n    <TargetName Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\">openSmileLib_$(Configuration)</TargetName>\r\n    <TargetName Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortaudio|Win32'\">openSmileLib_$(Configuration)</TargetName>\r\n    <TargetName Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\">openSmileLib_$(Configuration)</TargetName>\r\n    <TargetName Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">openSmileLib_$(Configuration)</TargetName>\r\n    <TargetName Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\">openSmileLib_$(Configuration)</TargetName>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <ClCompile>\r\n      <Optimization>Disabled</Optimization>\r\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>BUILD_LIBSVM;HAVE_GSL_ZSOLVE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <MinimalRebuild>true</MinimalRebuild>\r\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Link>\r\n      <OutputFile>..\\..\\..\\msvcbuild\\$(TargetName)$(TargetExt)</OutputFile>\r\n      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <SubSystem>Windows</SubSystem>\r\n      <ImportLibrary>..\\..\\..\\msvcbuild\\openSmileLib_$(Configuration).lib</ImportLibrary>\r\n      <TargetMachine>MachineX86</TargetMachine>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\">\r\n    <ClCompile>\r\n      <Optimization>Disabled</Optimization>\r\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>BUILD_LIBSVM;HAVE_GSL_ZSOLVE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <MinimalRebuild>true</MinimalRebuild>\r\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Link>\r\n      <OutputFile>..\\..\\..\\msvcbuild\\$(TargetName)$(TargetExt)</OutputFile>\r\n      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <SubSystem>Windows</SubSystem>\r\n      <ImportLibrary>..\\..\\..\\msvcbuild\\openSmileLib_$(Configuration).lib</ImportLibrary>\r\n      <TargetMachine>MachineX86</TargetMachine>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <ClCompile>\r\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <ExceptionHandling>Async</ExceptionHandling>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Link>\r\n      <OutputFile>..\\..\\..\\msvcbuild\\$(TargetName)$(TargetExt)</OutputFile>\r\n      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <ImportLibrary>..\\..\\..\\msvcbuild\\openSmileLib_$(Configuration).lib</ImportLibrary>\r\n      <TargetMachine>MachineX86</TargetMachine>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\">\r\n    <ClCompile>\r\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <ExceptionHandling>Async</ExceptionHandling>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Link>\r\n      <OutputFile>..\\..\\..\\msvcbuild\\$(TargetName)$(TargetExt)</OutputFile>\r\n      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <ImportLibrary>..\\..\\..\\msvcbuild\\openSmileLib_$(Configuration).lib</ImportLibrary>\r\n      <TargetMachine>MachineX86</TargetMachine>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudio|Win32'\">\r\n    <ClCompile>\r\n      <Optimization>Disabled</Optimization>\r\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <MinimalRebuild>true</MinimalRebuild>\r\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>\r\n      <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>..\\..\\..\\msvcbuild\\$(TargetName)$(TargetExt)</OutputFile>\r\n      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <SubSystem>Windows</SubSystem>\r\n      <ImportLibrary>..\\..\\..\\msvcbuild\\openSmileLib_$(Configuration).lib</ImportLibrary>\r\n      <TargetMachine>MachineX86</TargetMachine>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\">\r\n    <ClCompile>\r\n      <Optimization>Disabled</Optimization>\r\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <MinimalRebuild>true</MinimalRebuild>\r\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>\r\n      <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>..\\..\\..\\msvcbuild\\$(TargetName)$(TargetExt)</OutputFile>\r\n      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <SubSystem>Windows</SubSystem>\r\n      <ImportLibrary>..\\..\\..\\msvcbuild\\openSmileLib_$(Configuration).lib</ImportLibrary>\r\n      <TargetMachine>MachineX86</TargetMachine>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortaudio|Win32'\">\r\n    <ClCompile>\r\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <ExceptionHandling>Async</ExceptionHandling>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>..\\..\\..\\msvcbuild\\$(TargetName)$(TargetExt)</OutputFile>\r\n      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <ImportLibrary>..\\..\\..\\msvcbuild\\openSmileLib_$(Configuration).lib</ImportLibrary>\r\n      <TargetMachine>MachineX86</TargetMachine>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\">\r\n    <ClCompile>\r\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <ExceptionHandling>Async</ExceptionHandling>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>..\\..\\..\\msvcbuild\\$(TargetName)$(TargetExt)</OutputFile>\r\n      <AdditionalLibraryDirectories>C:\\Users\\kir\\Documents\\open smile\\branches\\opensource2-acm2013\\thirdparty\\compiled\\dll;C:\\Users\\kir\\Documents\\open smile\\branches\\opensource2-acm2013\\thirdparty\\compiled\\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <SubSystem>Windows</SubSystem>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <ImportLibrary>..\\..\\..\\msvcbuild\\openSmileLib_$(Configuration).lib</ImportLibrary>\r\n      <TargetMachine>MachineX86</TargetMachine>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"..\\..\\src\\core\\svn_version.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\classifiers\\julius\\juliusSink.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\classifiers\\julius\\kwsjKresult.h\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\core\\commandlineParser.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\core\\componentList.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\core\\componentManager.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\core\\configManager.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\core\\dataMemory.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\core\\dataProcessor.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\core\\dataReader.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\core\\dataSelector.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\core\\dataSink.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\core\\dataSource.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\core\\dataWriter.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\core\\exceptions.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\core\\nullSink.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\core\\smileCommon.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\core\\smileComponent.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\core\\smileLogger.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\core\\smileTypes.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\core\\vecToWinProcessor.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\core\\vectorProcessor.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\core\\vectorTransform.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\core\\winToVecProcessor.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\core\\windowProcessor.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\dsp\\dbA.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\dsp\\signalGenerator.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\dsp\\smileResample.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\dsp\\specResample.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\dsp\\vadV1.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\dspcore\\acf.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\dspcore\\amdf.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\dspcore\\contourSmoother.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\dspcore\\deltaRegression.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\dspcore\\fftXg.h\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\dspcore\\fftmagphase.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\dspcore\\framer.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\dspcore\\fullinputMean.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\dspcore\\fullturnMean.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\dspcore\\monoMixdown.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\dspcore\\preemphasis.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\dspcore\\transformFft.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\dspcore\\turnDetector.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\dspcore\\vectorMVN.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\dspcore\\vectorPreemphasis.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\dspcore\\windower.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\examples\\exampleSink.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\examples\\exampleSource.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\functionals\\functionalComponent.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\functionals\\functionalCrossings.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\functionals\\functionalDCT.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\functionals\\functionalExtremes.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\functionals\\functionalLpc.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\functionals\\functionalMeans.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\functionals\\functionalMoments.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\functionals\\functionalOnset.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\functionals\\functionalPeaks.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\functionals\\functionalPeaks2.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\functionals\\functionalPercentiles.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\functionals\\functionalRegression.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\functionals\\functionalSamples.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\functionals\\functionalSegments.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\functionals\\functionalTimes.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\functionals\\functionals.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\lld\\harmonics.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\lld\\lsp.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\dsp\\specScale.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\io\\libsvmSink.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\iocore\\arffSink.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\iocore\\arffSource.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\iocore\\csvSink.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\iocore\\csvSource.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\iocore\\datadumpSink.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\iocore\\htkSink.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\iocore\\htkSource.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\iocore\\waveSink.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\iocore\\waveSinkCut.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\iocore\\waveSource.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\lld\\cens.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\lld\\chroma.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\lld\\formantLpc.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\lld\\formantSmoother.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\lld\\lpc.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\lld\\pitchDirection.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\lld\\pitchJitter.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\lld\\pitchShs.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\lld\\pitchSmootherViterbi.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\lld\\tonefilt.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\lld\\tonespec.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\lldcore\\energy.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\lldcore\\intensity.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\lldcore\\melspec.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\lldcore\\mfcc.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\lldcore\\mzcr.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\lldcore\\pitchACF.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\lldcore\\pitchBase.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\lldcore\\pitchSmoother.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\lldcore\\plp.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\lldcore\\spectral.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\other\\bowProducer.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\other\\maxIndex.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\other\\valbasedSelector.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\other\\vectorConcat.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\other\\vectorOperation.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\smileutil\\smileUtil.h\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\smileutil\\smileUtilSpline.h\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\smileutil\\zerosolve.h\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\video\\openCVSource.hpp\">\r\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</ExcludedFromBuild>\r\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudio|Win32'\">true</ExcludedFromBuild>\r\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">true</ExcludedFromBuild>\r\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortaudio|Win32'\">true</ExcludedFromBuild>\r\n    </ClInclude>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"..\\..\\src\\classifiers\\julius\\juliusSink.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\core\\commandlineParser.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\core\\componentManager.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\core\\configManager.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\core\\dataMemory.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\core\\dataProcessor.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\core\\dataReader.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\core\\dataSelector.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\core\\dataSink.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\core\\dataSource.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\core\\dataWriter.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\core\\exceptions.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\core\\nullSink.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\core\\smileCommon.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\core\\smileComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\core\\smileLogger.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\core\\vecToWinProcessor.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\core\\vectorProcessor.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\core\\vectorTransform.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\core\\winToVecProcessor.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\core\\windowProcessor.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\dsp\\dbA.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\dsp\\signalGenerator.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\dsp\\smileResample.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\dsp\\specResample.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\dsp\\vadV1.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\dspcore\\acf.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\dspcore\\amdf.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\dspcore\\contourSmoother.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\dspcore\\deltaRegression.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\dspcore\\fftmagphase.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\dspcore\\fftsg.c\" />\r\n    <ClCompile Include=\"..\\..\\src\\dspcore\\framer.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\dspcore\\fullinputMean.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\dspcore\\fullturnMean.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\dspcore\\monoMixdown.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\dspcore\\preemphasis.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\dspcore\\transformFft.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\dspcore\\turnDetector.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\dspcore\\vectorMVN.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\dspcore\\vectorPreemphasis.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\dspcore\\windower.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\examples\\exampleSink.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\examples\\exampleSource.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\functionals\\functionalComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\functionals\\functionalCrossings.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\functionals\\functionalDCT.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\functionals\\functionalExtremes.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\functionals\\functionalLpc.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\functionals\\functionalMeans.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\functionals\\functionalMoments.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\functionals\\functionalOnset.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\functionals\\functionalPeaks.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\functionals\\functionalPeaks2.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\functionals\\functionalPercentiles.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\functionals\\functionalRegression.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\functionals\\functionalSamples.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\functionals\\functionalSegments.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\functionals\\functionalTimes.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\functionals\\functionals.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\lld\\harmonics.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\lld\\lsp.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\dsp\\specScale.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\io\\libsvmSink.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\iocore\\arffSink.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\iocore\\arffSource.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\iocore\\csvSink.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\iocore\\csvSource.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\iocore\\datadumpSink.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\iocore\\htkSink.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\iocore\\htkSource.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\iocore\\waveSink.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\iocore\\waveSinkCut.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\iocore\\waveSource.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\lld\\cens.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\lld\\chroma.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\lld\\formantLpc.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\lld\\formantSmoother.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\lld\\lpc.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\lld\\pitchDirection.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\lld\\pitchJitter.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\lld\\pitchShs.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\lld\\pitchSmootherViterbi.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\lld\\tonefilt.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\lld\\tonespec.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\lldcore\\energy.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\lldcore\\intensity.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\lldcore\\melspec.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\lldcore\\mfcc.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\lldcore\\mzcr.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\lldcore\\pitchACF.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\lldcore\\pitchBase.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\lldcore\\pitchSmoother.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\lldcore\\plp.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\lldcore\\spectral.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\other\\bowProducer.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\other\\maxIndex.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\other\\valbasedSelector.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\other\\vectorConcat.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\other\\vectorOperation.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\smileutil\\smileUtil.c\" />\r\n    <ClCompile Include=\"..\\..\\src\\smileutil\\smileUtilSpline.c\" />\r\n    <ClCompile Include=\"..\\..\\src\\smileutil\\zerosolve.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\video\\openCVSource.cpp\">\r\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</ExcludedFromBuild>\r\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudio|Win32'\">true</ExcludedFromBuild>\r\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">true</ExcludedFromBuild>\r\n      <ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortaudio|Win32'\">true</ExcludedFromBuild>\r\n    </ClCompile>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ProjectReference Include=\"openSmileLibClassif.vcxproj\">\r\n      <Project>{7361a0f8-87e5-4539-b912-880fe6faa86c}</Project>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"openSmileLibLibsvm.vcxproj\">\r\n      <Project>{17f673ea-8364-4b82-bc98-895ccd40d5f0}</Project>\r\n    </ProjectReference>\r\n    <ProjectReference Include=\"openSmileLibPortaudio.vcxproj\">\r\n      <Project>{b2f72986-3dff-4113-9346-dd4fd485c8b0}</Project>\r\n    </ProjectReference>\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n</Project>"
  },
  {
    "path": "ide/vs10/openSmileLibClassif.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"DebugOpenCV|Win32\">\r\n      <Configuration>DebugOpenCV</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"DebugPortaudioOpenCV|Win32\">\r\n      <Configuration>DebugPortaudioOpenCV</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Debug|Win32\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"ReleaseOpenCV|Win32\">\r\n      <Configuration>ReleaseOpenCV</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"ReleasePortAudioOpenCV|Win32\">\r\n      <Configuration>ReleasePortAudioOpenCV</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|Win32\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{7361A0F8-87E5-4539-B912-880FE6FAA86C}</ProjectGuid>\r\n    <RootNamespace>openSmileLibClassif</RootNamespace>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n    <UseDebugLibraries>true</UseDebugLibraries>\r\n    <CharacterSet>MultiByte</CharacterSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n    <UseDebugLibraries>true</UseDebugLibraries>\r\n    <CharacterSet>MultiByte</CharacterSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n    <UseDebugLibraries>true</UseDebugLibraries>\r\n    <CharacterSet>MultiByte</CharacterSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n    <UseDebugLibraries>false</UseDebugLibraries>\r\n    <WholeProgramOptimization>true</WholeProgramOptimization>\r\n    <CharacterSet>MultiByte</CharacterSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n    <UseDebugLibraries>false</UseDebugLibraries>\r\n    <WholeProgramOptimization>true</WholeProgramOptimization>\r\n    <CharacterSet>MultiByte</CharacterSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n    <UseDebugLibraries>false</UseDebugLibraries>\r\n    <WholeProgramOptimization>true</WholeProgramOptimization>\r\n    <CharacterSet>MultiByte</CharacterSet>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsDebug.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsDebug.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsDebug.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsRelease.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsRelease.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsRelease.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <OutDir>$(Configuration)\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\">\r\n    <OutDir>$(Configuration)\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\">\r\n    <OutDir>$(Configuration)\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <OutDir>$(Configuration)\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\">\r\n    <OutDir>$(Configuration)\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\">\r\n    <OutDir>$(Configuration)\\</OutDir>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <ClCompile>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <Optimization>Disabled</Optimization>\r\n      <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <Link>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n    </Link>\r\n    <Lib>\r\n      <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>\r\n    </Lib>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\">\r\n    <ClCompile>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <Optimization>Disabled</Optimization>\r\n      <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <Link>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n    </Link>\r\n    <Lib>\r\n      <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>\r\n    </Lib>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\">\r\n    <ClCompile>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <Optimization>Disabled</Optimization>\r\n      <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <Link>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n    </Link>\r\n    <Lib>\r\n      <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>\r\n    </Lib>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <ClCompile>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <Optimization>MaxSpeed</Optimization>\r\n      <FunctionLevelLinking>true</FunctionLevelLinking>\r\n      <IntrinsicFunctions>true</IntrinsicFunctions>\r\n      <WholeProgramOptimization>false</WholeProgramOptimization>\r\n    </ClCompile>\r\n    <Link>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\">\r\n    <ClCompile>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <Optimization>MaxSpeed</Optimization>\r\n      <FunctionLevelLinking>true</FunctionLevelLinking>\r\n      <IntrinsicFunctions>true</IntrinsicFunctions>\r\n      <WholeProgramOptimization>false</WholeProgramOptimization>\r\n    </ClCompile>\r\n    <Link>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\">\r\n    <ClCompile>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <Optimization>MaxSpeed</Optimization>\r\n      <FunctionLevelLinking>true</FunctionLevelLinking>\r\n      <IntrinsicFunctions>true</IntrinsicFunctions>\r\n      <WholeProgramOptimization>false</WholeProgramOptimization>\r\n    </ClCompile>\r\n    <Link>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"..\\..\\src\\classifiers\\svmSink.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\rnn\\rnn.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\rnn\\rnnProcessor.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\rnn\\rnnSink.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\rnn\\rnnVad2.cpp\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"..\\..\\src\\include\\classifiers\\svmSink.hpp\" />\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n</Project>"
  },
  {
    "path": "ide/vs10/openSmileLibLibsvm.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"DebugOpenCV|Win32\">\r\n      <Configuration>DebugOpenCV</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"DebugPortaudioOpenCV|Win32\">\r\n      <Configuration>DebugPortaudioOpenCV</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Debug|Win32\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"ReleaseOpenCV|Win32\">\r\n      <Configuration>ReleaseOpenCV</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"ReleasePortAudioOpenCV|Win32\">\r\n      <Configuration>ReleasePortAudioOpenCV</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|Win32\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"..\\..\\src\\include\\classifiers\\libsvmliveSink.hpp\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"..\\..\\src\\classifiers\\libsvmliveSink.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\classifiers\\libsvm\\svm.cpp\" />\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{17F673EA-8364-4B82-BC98-895CCD40D5F0}</ProjectGuid>\r\n    <RootNamespace>openSmileLibLibsvm</RootNamespace>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n    <UseDebugLibraries>true</UseDebugLibraries>\r\n    <CharacterSet>MultiByte</CharacterSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n    <UseDebugLibraries>true</UseDebugLibraries>\r\n    <CharacterSet>MultiByte</CharacterSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n    <UseDebugLibraries>true</UseDebugLibraries>\r\n    <CharacterSet>MultiByte</CharacterSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n    <UseDebugLibraries>false</UseDebugLibraries>\r\n    <WholeProgramOptimization>true</WholeProgramOptimization>\r\n    <CharacterSet>MultiByte</CharacterSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n    <UseDebugLibraries>false</UseDebugLibraries>\r\n    <WholeProgramOptimization>true</WholeProgramOptimization>\r\n    <CharacterSet>MultiByte</CharacterSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n    <UseDebugLibraries>false</UseDebugLibraries>\r\n    <WholeProgramOptimization>true</WholeProgramOptimization>\r\n    <CharacterSet>MultiByte</CharacterSet>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsDebug.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsDebug.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsDebug.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsRelease.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsRelease.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsRelease.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"openSmileComponents.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <OutDir>$(Configuration)\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\">\r\n    <OutDir>$(Configuration)\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\">\r\n    <OutDir>$(Configuration)\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <OutDir>$(Configuration)\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\">\r\n    <OutDir>$(Configuration)\\</OutDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\">\r\n    <OutDir>$(Configuration)\\</OutDir>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <ClCompile>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <Optimization>Disabled</Optimization>\r\n      <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <Link>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n    </Link>\r\n    <Lib>\r\n      <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>\r\n    </Lib>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\">\r\n    <ClCompile>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <Optimization>Disabled</Optimization>\r\n      <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <Link>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n    </Link>\r\n    <Lib>\r\n      <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>\r\n    </Lib>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\">\r\n    <ClCompile>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <Optimization>Disabled</Optimization>\r\n      <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <Link>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n    </Link>\r\n    <Lib>\r\n      <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>\r\n    </Lib>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <ClCompile>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <Optimization>MaxSpeed</Optimization>\r\n      <FunctionLevelLinking>true</FunctionLevelLinking>\r\n      <IntrinsicFunctions>true</IntrinsicFunctions>\r\n      <WholeProgramOptimization>false</WholeProgramOptimization>\r\n    </ClCompile>\r\n    <Link>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\">\r\n    <ClCompile>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <Optimization>MaxSpeed</Optimization>\r\n      <FunctionLevelLinking>true</FunctionLevelLinking>\r\n      <IntrinsicFunctions>true</IntrinsicFunctions>\r\n      <WholeProgramOptimization>false</WholeProgramOptimization>\r\n    </ClCompile>\r\n    <Link>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\">\r\n    <ClCompile>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <Optimization>MaxSpeed</Optimization>\r\n      <FunctionLevelLinking>true</FunctionLevelLinking>\r\n      <IntrinsicFunctions>true</IntrinsicFunctions>\r\n      <WholeProgramOptimization>false</WholeProgramOptimization>\r\n    </ClCompile>\r\n    <Link>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n</Project>"
  },
  {
    "path": "ide/vs10/openSmileLibPortaudio.props",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup>\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>HAVE_PORTAUDIO;HAVE_PORTAUDIO_V19;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <Link>\r\n      <AdditionalDependencies>openSmileLibPortaudio.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n</Project>"
  },
  {
    "path": "ide/vs10/openSmileLibPortaudio.vcproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"8,00\"\r\n\tName=\"openSmileLibPortaudio\"\r\n\tProjectGUID=\"{B2F72986-3DFF-4113-9346-DD4FD485C8B0}\"\r\n\tRootNamespace=\"openSmileLibPortaudio\"\r\n\tKeyword=\"Win32Proj\"\r\n\t>\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"\r\n\t\t/>\r\n\t</Platforms>\r\n\t<ToolFiles>\r\n\t</ToolFiles>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(ConfigurationName)\"\r\n\t\t\tConfigurationType=\"4\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"&quot;..\\..\\src&quot;;&quot;..\\..&quot;\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_USRDLL;OPENSMILELIB_EXPORTS;__WINDOWS;BUILDING_DLL;_CRT_SECURE_NO_DEPRECATE\"\r\n\t\t\t\tMinimalRebuild=\"true\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"3\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"true\"\r\n\t\t\t\tDebugInformationFormat=\"4\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLibrarianTool\"\r\n\t\t\t\tOutputFile=\"Debug\\$(ProjectName).lib\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(ConfigurationName)\"\r\n\t\t\tConfigurationType=\"4\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"&quot;..\\..\\src&quot;;&quot;..\\..\\src\\include&quot;;&quot;..\\..\\..\\thirdparty\\portaudio\\include&quot;;&quot;..\\..&quot;\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_USRDLL;OPENSMILELIB_EXPORTS;__WINDOWS;BUILDING_DLL;_CRT_SECURE_NO_DEPRECATE\"\r\n\t\t\t\tExceptionHandling=\"2\"\r\n\t\t\t\tRuntimeLibrary=\"2\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"true\"\r\n\t\t\t\tDebugInformationFormat=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLibrarianTool\"\r\n\t\t\t\tOutputFile=\"Release\\$(ProjectName).lib\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"ReleaseNet|Win32\"\r\n\t\t\tOutputDirectory=\"$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(ConfigurationName)\"\r\n\t\t\tConfigurationType=\"4\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"&quot;..\\..\\src&quot;;&quot;..\\..\\src\\include&quot;;&quot;..\\..\\..\\thirdparty\\portaudio\\include&quot;;&quot;..\\..&quot;\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_USRDLL;OPENSMILELIB_EXPORTS;__WINDOWS;BUILDING_DLL;_CRT_SECURE_NO_DEPRECATE\"\r\n\t\t\t\tExceptionHandling=\"2\"\r\n\t\t\t\tRuntimeLibrary=\"2\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"true\"\r\n\t\t\t\tDebugInformationFormat=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLibrarianTool\"\r\n\t\t\t\tOutputFile=\"Release\\$(ProjectName).lib\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc;xsd\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\"\r\n\t\t\t>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\..\\src\\include\\portaudio\\portaudioDuplex.hpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\..\\src\\include\\portaudio\\portaudioSink.hpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\..\\src\\include\\portaudio\\portaudioSource.hpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\..\\src\\include\\portaudio\\portaudioWavplayer.hpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Resource Files\"\r\n\t\t\tFilter=\"rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx\"\r\n\t\t\tUniqueIdentifier=\"{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}\"\r\n\t\t\t>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\"\r\n\t\t\t>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\..\\src\\portaudio\\portaudioDuplex.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\..\\src\\portaudio\\portaudioSink.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\..\\src\\portaudio\\portaudioSource.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\..\\src\\portaudio\\portaudioWavplayer.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "ide/vs10/openSmileLibPortaudio.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"DebugOpenCV|Win32\">\r\n      <Configuration>DebugOpenCV</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"DebugPortaudioOpenCV|Win32\">\r\n      <Configuration>DebugPortaudioOpenCV</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"DebugPortaudio|Win32\">\r\n      <Configuration>DebugPortaudio</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Debug|Win32\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"ReleaseOpenCV|Win32\">\r\n      <Configuration>ReleaseOpenCV</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"ReleasePortAudioOpenCV|Win32\">\r\n      <Configuration>ReleasePortAudioOpenCV</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"ReleasePortaudio|Win32\">\r\n      <Configuration>ReleasePortaudio</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|Win32\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{B2F72986-3DFF-4113-9346-DD4FD485C8B0}</ProjectGuid>\r\n    <RootNamespace>openSmileLibPortaudio</RootNamespace>\r\n    <Keyword>Win32Proj</Keyword>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortaudio|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudio|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsRelease.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortaudio|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsRelease.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"portaudio.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsRelease.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"portaudio.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsRelease.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"portaudio.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsDebug.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudio|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsDebug.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"portaudio.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsDebug.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"portaudio.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"generalProps.props\" />\r\n    <Import Project=\"generalPropsDebug.props\" />\r\n    <Import Project=\"generalPropsDll.props\" />\r\n    <Import Project=\"portaudio.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">$(Configuration)\\</OutDir>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudio|Win32'\">$(Configuration)\\</OutDir>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\">$(Configuration)\\</OutDir>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\">$(Configuration)\\</OutDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">$(Configuration)\\</IntDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudio|Win32'\">$(Configuration)\\</IntDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\">$(Configuration)\\</IntDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\">$(Configuration)\\</IntDir>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">$(Configuration)\\</OutDir>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortaudio|Win32'\">$(Configuration)\\</OutDir>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\">$(Configuration)\\</OutDir>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\">$(Configuration)\\</OutDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">$(Configuration)\\</IntDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortaudio|Win32'\">$(Configuration)\\</IntDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\">$(Configuration)\\</IntDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\">$(Configuration)\\</IntDir>\r\n    <TargetName Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">$(ProjectName)</TargetName>\r\n    <TargetName Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudio|Win32'\">$(ProjectName)</TargetName>\r\n    <TargetName Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\">$(ProjectName)</TargetName>\r\n    <TargetName Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\">$(ProjectName)</TargetName>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <ClCompile>\r\n      <Optimization>Disabled</Optimization>\r\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <MinimalRebuild>true</MinimalRebuild>\r\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Lib>\r\n      <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>\r\n    </Lib>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudio|Win32'\">\r\n    <ClCompile>\r\n      <Optimization>Disabled</Optimization>\r\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <MinimalRebuild>true</MinimalRebuild>\r\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Lib>\r\n      <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>\r\n      <AdditionalDependencies>../../../msvcbuild/portaudio_x86Dbg.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n    </Lib>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugPortaudioOpenCV|Win32'\">\r\n    <ClCompile>\r\n      <Optimization>Disabled</Optimization>\r\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <MinimalRebuild>true</MinimalRebuild>\r\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Lib>\r\n      <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>\r\n    </Lib>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='DebugOpenCV|Win32'\">\r\n    <ClCompile>\r\n      <Optimization>Disabled</Optimization>\r\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <MinimalRebuild>true</MinimalRebuild>\r\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Lib>\r\n      <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>\r\n    </Lib>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <ClCompile>\r\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <ExceptionHandling>Async</ExceptionHandling>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Lib>\r\n      <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>\r\n    </Lib>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortaudio|Win32'\">\r\n    <ClCompile>\r\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <ExceptionHandling>Async</ExceptionHandling>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Lib>\r\n      <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>\r\n      <AdditionalDependencies>../../../msvcbuild/portaudio_x86.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n    </Lib>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleasePortAudioOpenCV|Win32'\">\r\n    <ClCompile>\r\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <ExceptionHandling>Async</ExceptionHandling>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Lib>\r\n      <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>\r\n    </Lib>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='ReleaseOpenCV|Win32'\">\r\n    <ClCompile>\r\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <ExceptionHandling>Async</ExceptionHandling>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Lib>\r\n      <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>\r\n    </Lib>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"..\\..\\src\\include\\portaudio\\portaudioDuplex.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\portaudio\\portaudioSink.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\portaudio\\portaudioSource.hpp\" />\r\n    <ClInclude Include=\"..\\..\\src\\include\\portaudio\\portaudioWavplayer.hpp\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"..\\..\\src\\portaudio\\portaudioDuplex.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\portaudio\\portaudioSink.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\portaudio\\portaudioSource.cpp\" />\r\n    <ClCompile Include=\"..\\..\\src\\portaudio\\portaudioWavplayer.cpp\" />\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n</Project>"
  },
  {
    "path": "ide/vs10/openSmileLibPortaudio.vsprops",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<VisualStudioPropertySheet\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"8.00\"\r\n\tName=\"openSmileLibPortaudio\"\r\n\t>\r\n\t<Tool\r\n\t\tName=\"VCCLCompilerTool\"\r\n\t\tPreprocessorDefinitions=\"HAVE_PORTAUDIO;HAVE_PORTAUDIO_V19\"\r\n\t/>\r\n\t<Tool\r\n\t\tName=\"VCLinkerTool\"\r\n\t\tAdditionalDependencies=\"openSmileLibPortaudio.lib\"\r\n\t/>\r\n</VisualStudioPropertySheet>\r\n"
  },
  {
    "path": "ide/vs10/openSmilePlugin.sln",
    "content": "﻿\r\nMicrosoft Visual Studio Solution File, Format Version 9.00\r\n# Visual C++ Express 2005\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"openSmilePlugin\", \"openSmilePlugin.vcproj\", \"{B00964AF-9DB6-4E8C-9437-8C4D57C4F4A0}\"\r\nEndProject\r\nGlobal\r\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\r\n\t\tDebug|Win32 = Debug|Win32\r\n\t\tRelease|Win32 = Release|Win32\r\n\tEndGlobalSection\r\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n\t\t{B00964AF-9DB6-4E8C-9437-8C4D57C4F4A0}.Debug|Win32.ActiveCfg = Debug|Win32\r\n\t\t{B00964AF-9DB6-4E8C-9437-8C4D57C4F4A0}.Debug|Win32.Build.0 = Debug|Win32\r\n\t\t{B00964AF-9DB6-4E8C-9437-8C4D57C4F4A0}.Release|Win32.ActiveCfg = Release|Win32\r\n\t\t{B00964AF-9DB6-4E8C-9437-8C4D57C4F4A0}.Release|Win32.Build.0 = Release|Win32\r\n\tEndGlobalSection\r\n\tGlobalSection(SolutionProperties) = preSolution\r\n\t\tHideSolutionNode = FALSE\r\n\tEndGlobalSection\r\nEndGlobal\r\n"
  },
  {
    "path": "ide/vs10/openSmilePlugin.vcproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"8,00\"\r\n\tName=\"openSmilePlugin\"\r\n\tProjectGUID=\"{B00964AF-9DB6-4E8C-9437-8C4D57C4F4A0}\"\r\n\tKeyword=\"Win32Proj\"\r\n\t>\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"\r\n\t\t/>\r\n\t</Platforms>\r\n\t<ToolFiles>\r\n\t</ToolFiles>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"Debug\"\r\n\t\t\tIntermediateDirectory=\"Debug\"\r\n\t\t\tConfigurationType=\"2\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"&quot;C:\\Program Files\\Microsoft Platform SDK\\Include&quot;;&quot;..\\..\\src&quot;;&quot;..\\..&quot;;&quot;..\\..\\plugindev&quot;\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_USRDLL;OPENSMILEPLUGIN_EXPORTS;__WINDOWS;SMILEPLUGIN\"\r\n\t\t\t\tMinimalRebuild=\"true\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"3\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"true\"\r\n\t\t\t\tDebugInformationFormat=\"4\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"openSmileLibPADbg.lib\"\r\n\t\t\t\tOutputFile=\"..\\..\\plugins\\$(ProjectName).dll\"\r\n\t\t\t\tLinkIncremental=\"2\"\r\n\t\t\t\tAdditionalLibraryDirectories=\"&quot;C:\\Program Files\\Microsoft Platform SDK\\Lib&quot;;&quot;..\\..&quot;\"\r\n\t\t\t\tGenerateDebugInformation=\"true\"\r\n\t\t\t\tSubSystem=\"2\"\r\n\t\t\t\tTargetMachine=\"1\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"Release\"\r\n\t\t\tIntermediateDirectory=\"Release\"\r\n\t\t\tConfigurationType=\"2\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;_USRDLL;OPENSMILEPLUGIN_EXPORTS;\"\r\n\t\t\t\tRuntimeLibrary=\"2\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"true\"\r\n\t\t\t\tDebugInformationFormat=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"openSmileLibPA.lib\"\r\n\t\t\t\tOutputFile=\"..\\..\\plugins\\$(ProjectName).dll\"\r\n\t\t\t\tLinkIncremental=\"2\"\r\n\t\t\t\tAdditionalLibraryDirectories=\"&quot;..\\..&quot;\"\r\n\t\t\t\tGenerateDebugInformation=\"true\"\r\n\t\t\t\tSubSystem=\"2\"\r\n\t\t\t\tOptimizeReferences=\"2\"\r\n\t\t\t\tEnableCOMDATFolding=\"2\"\r\n\t\t\t\tTargetMachine=\"1\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc;xsd\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\"\r\n\t\t\t>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\..\\plugindev\\plug_exampleSink.hpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Resource Files\"\r\n\t\t\tFilter=\"rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx\"\r\n\t\t\tUniqueIdentifier=\"{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}\"\r\n\t\t\t>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\"\r\n\t\t\t>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\..\\plugindev\\plug_exampleSink.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\..\\plugindev\\pluginMain.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "ide/vs10/openSmilePluginGUI.sln",
    "content": "﻿\r\nMicrosoft Visual Studio Solution File, Format Version 9.00\r\n# Visual Studio 2005\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"openSmilePluginGUI\", \"openSmilePluginGUI.vcproj\", \"{B00964AF-9DB6-4E8C-9437-8C4D57C4F4A0}\"\r\nEndProject\r\nGlobal\r\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\r\n\t\tDebug|Win32 = Debug|Win32\r\n\t\tRelease|Win32 = Release|Win32\r\n\tEndGlobalSection\r\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n\t\t{B00964AF-9DB6-4E8C-9437-8C4D57C4F4A0}.Debug|Win32.ActiveCfg = Debug|Win32\r\n\t\t{B00964AF-9DB6-4E8C-9437-8C4D57C4F4A0}.Debug|Win32.Build.0 = Debug|Win32\r\n\t\t{B00964AF-9DB6-4E8C-9437-8C4D57C4F4A0}.Release|Win32.ActiveCfg = Release|Win32\r\n\t\t{B00964AF-9DB6-4E8C-9437-8C4D57C4F4A0}.Release|Win32.Build.0 = Release|Win32\r\n\tEndGlobalSection\r\n\tGlobalSection(SolutionProperties) = preSolution\r\n\t\tHideSolutionNode = FALSE\r\n\tEndGlobalSection\r\nEndGlobal\r\n"
  },
  {
    "path": "ide/vs10/openSmilePluginGUI.vcproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"8,00\"\r\n\tName=\"openSmilePluginGUI\"\r\n\tProjectGUID=\"{B00964AF-9DB6-4E8C-9437-8C4D57C4F4A0}\"\r\n\tRootNamespace=\"openSmilePluginGUI\"\r\n\tKeyword=\"Win32Proj\"\r\n\t>\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"\r\n\t\t/>\r\n\t</Platforms>\r\n\t<ToolFiles>\r\n\t</ToolFiles>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"Debug\"\r\n\t\t\tIntermediateDirectory=\"Debug\"\r\n\t\t\tConfigurationType=\"2\"\r\n\t\t\tInheritedPropertySheets=\".\\wxWidgetsDbg.vsprops\"\r\n\t\t\tManagedExtensions=\"0\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"..\\..\\src;..\\..;..\\..\\plugindev\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS;_USRDLL;OPENSMILEPLUGIN_EXPORTS;__WINDOWS;SMILEPLUGIN\"\r\n\t\t\t\tMinimalRebuild=\"false\"\r\n\t\t\t\tBasicRuntimeChecks=\"0\"\r\n\t\t\t\tRuntimeLibrary=\"3\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"true\"\r\n\t\t\t\tDebugInformationFormat=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"openSmileLibPA.lib\"\r\n\t\t\t\tOutputFile=\"..\\..\\plugins\\$(ProjectName)Dbg.dll\"\r\n\t\t\t\tLinkIncremental=\"2\"\r\n\t\t\t\tAdditionalLibraryDirectories=\"&quot;C:\\Program Files\\Microsoft Platform SDK\\Lib&quot;;&quot;..\\..&quot;\"\r\n\t\t\t\tGenerateDebugInformation=\"true\"\r\n\t\t\t\tAssemblyDebug=\"1\"\r\n\t\t\t\tSubSystem=\"2\"\r\n\t\t\t\tTargetMachine=\"1\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"Release\"\r\n\t\t\tIntermediateDirectory=\"Release\"\r\n\t\t\tConfigurationType=\"2\"\r\n\t\t\tInheritedPropertySheets=\".\\wxWidgetsRelease.vsprops\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"..\\..\\src;..\\..;..\\..\\plugindev\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS;__WINDOWS;_USRDLL;OPENSMILEPLUGIN_EXPORTS;SMILEPLUGIN\"\r\n\t\t\t\tRuntimeLibrary=\"2\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"true\"\r\n\t\t\t\tDebugInformationFormat=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tAdditionalDependencies=\"openSmileLibPA.lib\"\r\n\t\t\t\tOutputFile=\"..\\..\\plugins\\$(ProjectName).dll\"\r\n\t\t\t\tLinkIncremental=\"2\"\r\n\t\t\t\tAdditionalLibraryDirectories=\"&quot;..\\..&quot;\"\r\n\t\t\t\tGenerateDebugInformation=\"true\"\r\n\t\t\t\tSubSystem=\"2\"\r\n\t\t\t\tOptimizeReferences=\"2\"\r\n\t\t\t\tEnableCOMDATFolding=\"2\"\r\n\t\t\t\tTargetMachine=\"1\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc;xsd\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\"\r\n\t\t\t>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\..\\plugindev\\exampleGuipluginSink.hpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Resource Files\"\r\n\t\t\tFilter=\"rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx\"\r\n\t\t\tUniqueIdentifier=\"{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}\"\r\n\t\t\t>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\"\r\n\t\t\t>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\..\\plugindev\\exampleGuipluginSink.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\..\\plugindev\\pluginGuiMain.cpp\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "ide/vs10/opencv.props",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ImportGroup Label=\"PropertySheets\" />\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <PropertyGroup>\r\n    <_PropertySheetDisplayName>opencv</_PropertySheetDisplayName>\r\n    <IncludePath>$(SolutionDir)..\\..\\..\\thirdparty\\compiled\\include;$(IncludePath)</IncludePath>\r\n    <LibraryPath>$(SolutionDir)..\\..\\..\\thirdparty\\compiled\\lib;$(LibraryPath)</LibraryPath>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup>\r\n    <ClCompile>\r\n      <AdditionalIncludeDirectories>..\\..\\..\\thirdparty\\compiled\\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>WINDOWS_COMPILE;HAVE_OPENCV;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <Lib>\r\n      <AdditionalDependencies>opencv_core245.lib;opencv_highgui245.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n    </Lib>\r\n    <Lib>\r\n      <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\r\n    </Lib>\r\n    <Link>\r\n      <AdditionalDependencies>opencv_calib3d245d.lib;opencv_contrib245d.lib;opencv_core245d.lib;opencv_features2d245d.lib;opencv_flann245d.lib;opencv_gpu245d.lib;opencv_haartraining_engined.lib;opencv_highgui245d.lib;opencv_imgproc245d.lib;opencv_legacy245d.lib;opencv_ml245d.lib;opencv_nonfree245d.lib;opencv_objdetect245d.lib;opencv_photo245d.lib;opencv_stitching245d.lib;opencv_ts245d.lib;opencv_video245d.lib;opencv_videostab245d.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup />\r\n</Project>"
  },
  {
    "path": "ide/vs10/portaudio.def",
    "content": "EXPORTS\n\n;\nPa_GetVersion                       @1\nPa_GetVersionText                   @2\nPa_GetErrorText                     @3                 \nPa_Initialize                       @4\nPa_Terminate                        @5\nPa_GetHostApiCount                  @6\nPa_GetDefaultHostApi                @7\nPa_GetHostApiInfo                   @8\nPa_HostApiTypeIdToHostApiIndex      @9\nPa_HostApiDeviceIndexToDeviceIndex  @10\nPa_GetLastHostErrorInfo             @11\nPa_GetDeviceCount                   @12\nPa_GetDefaultInputDevice            @13\nPa_GetDefaultOutputDevice           @14\nPa_GetDeviceInfo                    @15\nPa_IsFormatSupported                @16\nPa_OpenStream                       @17\nPa_OpenDefaultStream                @18\nPa_CloseStream                      @19\nPa_SetStreamFinishedCallback        @20\nPa_StartStream                      @21\nPa_StopStream                       @22\nPa_AbortStream                      @23\nPa_IsStreamStopped                  @24\nPa_IsStreamActive                   @25\nPa_GetStreamInfo                    @26\nPa_GetStreamTime                    @27\nPa_GetStreamCpuLoad                 @28\nPa_ReadStream                       @29\nPa_WriteStream                      @30\nPa_GetStreamReadAvailable           @31\nPa_GetStreamWriteAvailable          @32\nPa_GetSampleSize                    @33\nPa_Sleep                            @34\nPaUtil_InitializeX86PlainConverters @52\nPaUtil_SetDebugPrintFunction        @55"
  },
  {
    "path": "ide/vs10/portaudio.props",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ImportGroup Label=\"PropertySheets\" />\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <PropertyGroup />\r\n  <ItemDefinitionGroup>\r\n    <ClCompile>\r\n      <PreprocessorDefinitions>HAVE_PORTAUDIO;HAVE_PORTAUDIO_V19;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories>..\\..\\..\\thirdparty\\portaudio\\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n    </ClCompile>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup />\r\n</Project>"
  },
  {
    "path": "ide/vs10/portaudio.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|Win32\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Debug|x64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|Win32\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|x64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{0A18A071-125E-442F-AFF7-A3F68ABECF99}</ProjectGuid>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <UseOfMfc>false</UseOfMfc>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <UseOfMfc>false</UseOfMfc>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <UseOfMfc>false</UseOfMfc>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\r\n    <UseOfMfc>false</UseOfMfc>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">$(Platform)\\$(Configuration)\\</OutDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">$(Platform)\\$(Configuration)\\</IntDir>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">false</LinkIncremental>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">$(Platform)\\$(Configuration)\\</OutDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">$(Platform)\\$(Configuration)\\</IntDir>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">false</LinkIncremental>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">$(Platform)\\$(Configuration)\\</OutDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">$(Platform)\\$(Configuration)\\</IntDir>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</LinkIncremental>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">$(Platform)\\$(Configuration)\\</OutDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">$(Platform)\\$(Configuration)\\</IntDir>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">true</LinkIncremental>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <Midl>\r\n      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <MkTypLibCompatible>true</MkTypLibCompatible>\r\n      <SuppressStartupBanner>true</SuppressStartupBanner>\r\n      <TargetEnvironment>Win32</TargetEnvironment>\r\n      <TypeLibraryName>.\\Release_x86/portaudio.tlb</TypeLibraryName>\r\n      <HeaderFileName>\r\n      </HeaderFileName>\r\n    </Midl>\r\n    <ClCompile>\r\n      <Optimization>MaxSpeed</Optimization>\r\n      <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>\r\n      <AdditionalIncludeDirectories>..\\..\\src\\common;..\\..\\include;.\\;..\\..\\src\\os\\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>WIN32;NDEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PAWIN_USE_WDMKS_DEVICE_INFO;PA_NO_ASIO;PA_NO_DS;PA_NO_WASAPI;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <StringPooling>true</StringPooling>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <FunctionLevelLinking>true</FunctionLevelLinking>\r\n      <PrecompiledHeaderOutputFile>$(Platform)\\$(Configuration)/portaudio.pch</PrecompiledHeaderOutputFile>\r\n      <AssemblerListingLocation>$(Platform)\\$(Configuration)\\</AssemblerListingLocation>\r\n      <ObjectFileName>$(Platform)\\$(Configuration)\\</ObjectFileName>\r\n      <ProgramDataBaseFileName>$(Platform)\\$(Configuration)\\</ProgramDataBaseFileName>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <SuppressStartupBanner>true</SuppressStartupBanner>\r\n    </ClCompile>\r\n    <ResourceCompile>\r\n      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <Culture>0x0409</Culture>\r\n    </ResourceCompile>\r\n    <Link>\r\n      <AdditionalDependencies>ksuser.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>..\\..\\..\\..\\msvcbuild\\portaudio_x86.dll</OutputFile>\r\n      <SuppressStartupBanner>true</SuppressStartupBanner>\r\n      <ModuleDefinitionFile>.\\portaudio.def</ModuleDefinitionFile>\r\n      <ProgramDatabaseFile>$(Platform)\\$(Configuration)\\portaudio_x86.pdb</ProgramDatabaseFile>\r\n      <ImportLibrary>..\\..\\..\\..\\msvcbuild\\portaudio_x86.lib</ImportLibrary>\r\n      <TargetMachine>MachineX86</TargetMachine>\r\n    </Link>\r\n    <Bscmake>\r\n      <SuppressStartupBanner>true</SuppressStartupBanner>\r\n      <OutputFile>$(Platform)\\$(Configuration)\\portaudio.bsc</OutputFile>\r\n    </Bscmake>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <Midl>\r\n      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <MkTypLibCompatible>true</MkTypLibCompatible>\r\n      <SuppressStartupBanner>true</SuppressStartupBanner>\r\n      <TargetEnvironment>X64</TargetEnvironment>\r\n      <TypeLibraryName>.\\Release_x86/portaudio.tlb</TypeLibraryName>\r\n      <HeaderFileName>\r\n      </HeaderFileName>\r\n    </Midl>\r\n    <ClCompile>\r\n      <Optimization>MaxSpeed</Optimization>\r\n      <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>\r\n      <AdditionalIncludeDirectories>..\\..\\src\\common;..\\..\\include;.\\;..\\..\\src\\os\\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>WIN32;NDEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PAWIN_USE_WDMKS_DEVICE_INFO;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <StringPooling>true</StringPooling>\r\n      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>\r\n      <FunctionLevelLinking>true</FunctionLevelLinking>\r\n      <PrecompiledHeaderOutputFile>$(Platform)\\$(Configuration)\\portaudio.pch</PrecompiledHeaderOutputFile>\r\n      <AssemblerListingLocation>$(Platform)\\$(Configuration)\\</AssemblerListingLocation>\r\n      <ObjectFileName>$(Platform)\\$(Configuration)\\</ObjectFileName>\r\n      <ProgramDataBaseFileName>$(Platform)\\$(Configuration)\\</ProgramDataBaseFileName>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <SuppressStartupBanner>true</SuppressStartupBanner>\r\n    </ClCompile>\r\n    <ResourceCompile>\r\n      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <Culture>0x0409</Culture>\r\n    </ResourceCompile>\r\n    <Link>\r\n      <AdditionalDependencies>ksuser.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>$(Platform)\\$(Configuration)\\portaudio_x64.dll</OutputFile>\r\n      <SuppressStartupBanner>true</SuppressStartupBanner>\r\n      <ModuleDefinitionFile>.\\portaudio.def</ModuleDefinitionFile>\r\n      <ProgramDatabaseFile>$(Platform)\\$(Configuration)/portaudio_x64.pdb</ProgramDatabaseFile>\r\n      <ImportLibrary>$(Platform)\\$(Configuration)/portaudio_x64.lib</ImportLibrary>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n    </Link>\r\n    <Bscmake>\r\n      <SuppressStartupBanner>true</SuppressStartupBanner>\r\n      <OutputFile>$(Platform)\\$(Configuration)\\portaudio_x64.bsc</OutputFile>\r\n    </Bscmake>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <Midl>\r\n      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <MkTypLibCompatible>true</MkTypLibCompatible>\r\n      <SuppressStartupBanner>true</SuppressStartupBanner>\r\n      <TargetEnvironment>Win32</TargetEnvironment>\r\n      <TypeLibraryName>.\\Debug_x86/portaudio.tlb</TypeLibraryName>\r\n      <HeaderFileName>\r\n      </HeaderFileName>\r\n    </Midl>\r\n    <ClCompile>\r\n      <Optimization>Disabled</Optimization>\r\n      <AdditionalIncludeDirectories>..\\..\\src\\common;..\\..\\include;.\\;..\\..\\src\\os\\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>WIN32;_DEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PAWIN_USE_WDMKS_DEVICE_INFO;PA_NO_ASIO;PA_NO_DS;PA_NO_WASAPI;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <MinimalRebuild>true</MinimalRebuild>\r\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <PrecompiledHeaderOutputFile>$(Platform)\\$(Configuration)/portaudio.pch</PrecompiledHeaderOutputFile>\r\n      <AssemblerListingLocation>$(Platform)\\$(Configuration)\\</AssemblerListingLocation>\r\n      <ObjectFileName>$(Platform)\\$(Configuration)\\</ObjectFileName>\r\n      <ProgramDataBaseFileName>$(Platform)\\$(Configuration)\\</ProgramDataBaseFileName>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <SuppressStartupBanner>true</SuppressStartupBanner>\r\n      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>\r\n    </ClCompile>\r\n    <ResourceCompile>\r\n      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <Culture>0x0409</Culture>\r\n    </ResourceCompile>\r\n    <Link>\r\n      <AdditionalDependencies>ksuser.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>..\\..\\..\\..\\msvcbuild\\portaudio_x86Dbg.dll</OutputFile>\r\n      <SuppressStartupBanner>true</SuppressStartupBanner>\r\n      <ModuleDefinitionFile>.\\portaudio.def</ModuleDefinitionFile>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <ProgramDatabaseFile>$(Platform)\\$(Configuration)\\portaudio_x86.pdb</ProgramDatabaseFile>\r\n      <ImportLibrary>..\\..\\..\\..\\msvcbuild\\portaudio_x86Dbg.lib</ImportLibrary>\r\n      <TargetMachine>MachineX86</TargetMachine>\r\n    </Link>\r\n    <Bscmake>\r\n      <SuppressStartupBanner>true</SuppressStartupBanner>\r\n      <OutputFile>$(Platform)\\$(Configuration)\\portaudio.bsc</OutputFile>\r\n    </Bscmake>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <Midl>\r\n      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <MkTypLibCompatible>true</MkTypLibCompatible>\r\n      <SuppressStartupBanner>true</SuppressStartupBanner>\r\n      <TargetEnvironment>X64</TargetEnvironment>\r\n      <TypeLibraryName>.\\Debug_x86/portaudio.tlb</TypeLibraryName>\r\n      <HeaderFileName>\r\n      </HeaderFileName>\r\n    </Midl>\r\n    <ClCompile>\r\n      <Optimization>Disabled</Optimization>\r\n      <AdditionalIncludeDirectories>..\\..\\src\\common;..\\..\\include;.\\;..\\..\\src\\os\\win;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>WIN32;_DEBUG;_USRDLL;PA_ENABLE_DEBUG_OUTPUT;_CRT_SECURE_NO_DEPRECATE;PAWIN_USE_WDMKS_DEVICE_INFO;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <MinimalRebuild>true</MinimalRebuild>\r\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\r\n      <PrecompiledHeaderOutputFile>$(Platform)\\$(Configuration)\\portaudio.pch</PrecompiledHeaderOutputFile>\r\n      <AssemblerListingLocation>$(Platform)\\$(Configuration)\\</AssemblerListingLocation>\r\n      <ObjectFileName>$(Platform)\\$(Configuration)\\</ObjectFileName>\r\n      <ProgramDataBaseFileName>$(Platform)\\$(Configuration)\\</ProgramDataBaseFileName>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <SuppressStartupBanner>true</SuppressStartupBanner>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n    </ClCompile>\r\n    <ResourceCompile>\r\n      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <Culture>0x0409</Culture>\r\n    </ResourceCompile>\r\n    <Link>\r\n      <AdditionalDependencies>ksuser.lib;%(AdditionalDependencies)</AdditionalDependencies>\r\n      <OutputFile>$(Platform)\\$(Configuration)\\portaudio_x64.dll</OutputFile>\r\n      <SuppressStartupBanner>true</SuppressStartupBanner>\r\n      <ModuleDefinitionFile>.\\portaudio.def</ModuleDefinitionFile>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <ProgramDatabaseFile>$(Platform)\\$(Configuration)/portaudio_x64.pdb</ProgramDatabaseFile>\r\n      <ImportLibrary>$(Platform)\\$(Configuration)\\portaudio_x64.lib</ImportLibrary>\r\n      <TargetMachine>MachineX64</TargetMachine>\r\n    </Link>\r\n    <Bscmake>\r\n      <SuppressStartupBanner>true</SuppressStartupBanner>\r\n      <OutputFile>$(Platform)\\$(Configuration)/portaudio_x64.bsc</OutputFile>\r\n    </Bscmake>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"..\\..\\src\\common\\pa_allocation.c\">\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\src\\common\\pa_converters.c\">\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\src\\common\\pa_cpuload.c\">\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\src\\common\\pa_debugprint.c\">\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\src\\common\\pa_dither.c\">\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\src\\common\\pa_front.c\">\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\src\\common\\pa_process.c\">\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\src\\common\\pa_ringbuffer.c\">\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\src\\common\\pa_skeleton.c\">\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\src\\common\\pa_stream.c\">\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\src\\common\\pa_trace.c\">\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\src\\hostapi\\wmme\\pa_win_wmme.c\">\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\src\\os\\win\\pa_win_hostapis.c\">\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\src\\os\\win\\pa_win_util.c\">\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\src\\os\\win\\pa_win_waveformat.c\" />\r\n    <ClCompile Include=\"..\\..\\src\\os\\win\\pa_win_wdmks_utils.c\" />\r\n    <ClCompile Include=\"..\\..\\src\\os\\win\\pa_x86_plain_converters.c\">\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"portaudio.def\" />\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n</Project>"
  },
  {
    "path": "m4/android.m4",
    "content": "AC_DEFUN([CHECK_HAVE_ANDROID],\n[\n\tAC_CANONICAL_HOST\n\tdefine('ANDROID_LDFLAGS','-lOpenSLES')\n        case \"${host_os}\" in\n            *android*)\n                ANDROID_LDFLAGS=\"-lOpenSLES\"\n            ;;\n\t    *)\n\t\tANDROID_LDFLAGS=\"\"\n\t    ;;\n        esac\n\n\tAC_SUBST(ANDROID_LDFLAGS)\n])\n"
  },
  {
    "path": "m4/find_pthread.m4",
    "content": "# from http://autoconf-archive.cryp.to/acx_pthread.html\n#  Copyright © 2008 Steven G. Johnson <stevenj@alum.mit.edu>\n# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.\n# As a special exception, the respective Autoconf Macro's copyright owner gives unlimited permission to copy, distribute and modify the configure scripts that are the output of Autoconf when processing the Macro. You need not follow the terms of the GNU General Public License when using or distributing such scripts, even though portions of the text of the Macro appear in them. The GNU General Public License (GPL) does govern all other use of the material that constitutes the Autoconf Macro.\n# This special exception to the GPL applies to versions of the Autoconf Macro released by the Autoconf Macro Archive. When you make and distribute a modified version of the Autoconf Macro, you may extend this special exception to the GPL to apply to your modified version as well.\n\nAC_DEFUN([ACX_PTHREAD], [\nAC_REQUIRE([AC_CANONICAL_HOST])\nAC_LANG_SAVE\nAC_LANG_C\nacx_pthread_ok=no\n\n# We used to check for pthread.h first, but this fails if pthread.h\n# requires special compiler flags (e.g. on True64 or Sequent).\n# It gets checked for in the link test anyway.\n\n# First of all, check if the user has set any of the PTHREAD_LIBS,\n# etcetera environment variables, and if threads linking works using\n# them:\nif test x\"$PTHREAD_LIBS$PTHREAD_CFLAGS\" != x; then\n        save_CFLAGS=\"$CFLAGS\"\n        CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\n        save_LIBS=\"$LIBS\"\n        LIBS=\"$PTHREAD_LIBS $LIBS\"\n        AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])\n        AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)\n        AC_MSG_RESULT($acx_pthread_ok)\n        if test x\"$acx_pthread_ok\" = xno; then\n                PTHREAD_LIBS=\"\"\n                PTHREAD_CFLAGS=\"\"\n        fi\n        LIBS=\"$save_LIBS\"\n        CFLAGS=\"$save_CFLAGS\"\nfi\n\n# We must check for the threads library under a number of different\n# names; the ordering is very important because some systems\n# (e.g. DEC) have both -lpthread and -lpthreads, where one of the\n# libraries is broken (non-POSIX).\n\n# Create a list of thread flags to try.  Items starting with a \"-\" are\n# C compiler flags, and other items are library names, except for \"none\"\n# which indicates that we try without any flags at all, and \"pthread-config\"\n# which is a program returning the flags for the Pth emulation library.\n\nacx_pthread_flags=\"pthreads none -Kthread -kthread lthread pthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config\"\n# pthreadVCE2\n\n# The ordering *is* (sometimes) important.  Some notes on the\n# individual items follow:\n\n# pthreads: AIX (must check this before -lpthread)\n# none: in case threads are in libc; should be tried before -Kthread and\n#       other compiler flags to prevent continual compiler warnings\n# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)\n# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)\n# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)\n# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)\n# -pthreads: Solaris/gcc\n# -mthreads: Mingw32/gcc, Lynx/gcc\n# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it\n#      doesn't hurt to check since this sometimes defines pthreads too;\n#      also defines -D_REENTRANT)\n#      ... -mt is also the pthreads flag for HP/aCC\n# pthread: Linux, etcetera\n# --thread-safe: KAI C++\n# pthread-config: use pthread-config program (for GNU Pth library)\n\ncase \"${host_cpu}-${host_os}\" in\n        *solaris*)\n\n        # On Solaris (at least, for some versions), libc contains stubbed\n        # (non-functional) versions of the pthreads routines, so link-based\n        # tests will erroneously succeed.  (We need to link with -pthreads/-mt/\n        # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather\n        # a function called by this macro, so we could check for that, but\n        # who knows whether they'll stub that too in a future libc.)  So,\n        # we'll just look for -pthreads and -lpthread first:\n\n        acx_pthread_flags=\"-pthreads pthread -mt -pthread $acx_pthread_flags\"\n        ;;\nesac\n\nif test x\"$acx_pthread_ok\" = xno; then\nfor flag in $acx_pthread_flags; do\n\n        case $flag in\n                none)\n                AC_MSG_CHECKING([whether pthreads work without any flags])\n                ;;\n\n                -*)\n                AC_MSG_CHECKING([whether pthreads work with $flag])\n                PTHREAD_CFLAGS=\"$flag\"\n                ;;\n\n                pthread-config)\n                AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)\n                if test x\"$acx_pthread_config\" = xno; then continue; fi\n                PTHREAD_CFLAGS=\"`pthread-config --cflags`\"\n                PTHREAD_LIBS=\"`pthread-config --ldflags` `pthread-config --libs`\"\n                ;;\n\n                *)\n                AC_MSG_CHECKING([for the pthreads library -l$flag])\n                PTHREAD_LIBS=\"-l$flag\"\n                ;;\n        esac\n\n        save_LIBS=\"$LIBS\"\n        save_CFLAGS=\"$CFLAGS\"\n        LIBS=\"$PTHREAD_LIBS $LIBS\"\n        CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\n\n        # Check for various functions.  We must include pthread.h,\n        # since some functions may be macros.  (On the Sequent, we\n        # need a special flag -Kthread to make this header compile.)\n        # We check for pthread_join because it is in -lpthread on IRIX\n        # while pthread_create is in libc.  We check for pthread_attr_init\n        # due to DEC craziness with -lpthreads.  We check for\n        # pthread_cleanup_push because it is one of the few pthread\n        # functions on Solaris that doesn't have a non-functional libc stub.\n        # We try pthread_create on general principles.\n        AC_TRY_LINK([#include <pthread.h>],\n                    [pthread_t th; pthread_join(th, 0);\n                     pthread_attr_init(0); pthread_cleanup_push(0, 0);\n                     pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],\n                    [acx_pthread_ok=yes])\n\n        LIBS=\"$save_LIBS\"\n        CFLAGS=\"$save_CFLAGS\"\n\n        AC_MSG_RESULT($acx_pthread_ok)\n        if test \"x$acx_pthread_ok\" = xyes; then\n                break;\n        fi\n\n        PTHREAD_LIBS=\"\"\n        PTHREAD_CFLAGS=\"\"\ndone\nfi\n\n# Various other checks:\nif test \"x$acx_pthread_ok\" = xyes; then\n        save_LIBS=\"$LIBS\"\n        LIBS=\"$PTHREAD_LIBS $LIBS\"\n        save_CFLAGS=\"$CFLAGS\"\n        CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\n\n        # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.\n        AC_MSG_CHECKING([for joinable pthread attribute])\n        attr_name=unknown\n        for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do\n            AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],\n                        [attr_name=$attr; break])\n        done\n        AC_MSG_RESULT($attr_name)\n        if test \"$attr_name\" != PTHREAD_CREATE_JOINABLE; then\n            AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,\n                               [Define to necessary symbol if this constant\n                                uses a non-standard name on your system.])\n        fi\n\n        AC_MSG_CHECKING([if more special flags are required for pthreads])\n        flag=no\n        case \"${host_cpu}-${host_os}\" in\n            *-aix* | *-freebsd* | *-darwin*) flag=\"-D_THREAD_SAFE\";;\n            *solaris* | *-osf* | *-hpux*) flag=\"-D_REENTRANT\";;\n        esac\n        AC_MSG_RESULT(${flag})\n        if test \"x$flag\" != xno; then\n            PTHREAD_CFLAGS=\"$flag $PTHREAD_CFLAGS\"\n        fi\n\n        LIBS=\"$save_LIBS\"\n        CFLAGS=\"$save_CFLAGS\"\n\n        # More AIX lossage: must compile with xlc_r or cc_r\n        if test x\"$GCC\" != xyes; then\n          AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})\n        else\n          PTHREAD_CC=$CC\n        fi\nelse\n        PTHREAD_CC=\"$CC\"\nfi\n\n\nAC_SUBST([PTHREAD_LIBS])\nAC_SUBST([PTHREAD_CFLAGS])\nAC_SUBST([PTHREAD_CC])\n\n# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:\nif test x\"$acx_pthread_ok\" = xyes; then\n        ifelse([$1],,AC_DEFINE([HAVE_PTHREAD],1,[Define if you have POSIX threads libraries and header files.]),[$1])\n        :\nelse\n        acx_pthread_ok=no\n        $2\nfi\nAC_LANG_RESTORE\n])dnl ACX_PTHREAD\n\n\n"
  },
  {
    "path": "m4/opencv.m4",
    "content": "dnl  m4 macro to check for existance of OpenCV library\ndnl      originally written by Florian Eyben, 11/2008\ndnl\t amended by Florian Gross, 04/2013\ndnl\ndnl  usage:  CHECK_HAVE_OPENCV( [default path] )\ndnl  if no default path is given, the default is /usr\ndnl\ndnl  The following defines are set, if the library is found:\ndnl    #define HAVE_OPENCV 1 (OpenCV Version 2.2 or higher is required)\ndnl \ndnl  The following Makefile substitutions are added:\ndnl    OPENCV_CPPFLAGS  (for includes)\ndnl    OPENCV_LDFLAGS   (for libraries)\ndnl    OPENCV_ROOT      (points to the c++/ directory in the semaine folder)\ndnl\n\n\nAC_DEFUN([CHECK_HAVE_OPENCV],\n[\n   OPENCV='no'\n   OPENCV_ROOT=''\n   OPENCV_CPPFLAGS=''\n   OPENCV_LDFLAGS=''\n   have_opencv='no'\n\n   if test \"x$1\" = \"x\" ; then\n     DEFAULT='no'\n   else\n     DEFAULT=$1\n   fi\n\n   dnl Define the root directory for the OpenCV installation.\n   AC_ARG_WITH(opencv,\n               [  --with-opencv=<PATH> OpenCV installation dir. default=$DEFAULT],\n               OPENCV_ROOT=\"$withval\", OPENCV_ROOT=$DEFAULT)\n\n   if test \"x$OPENCV_ROOT\" != \"xno\" ; then\n      dnl Save these values in case they need to be restored later.\n      save_CFLAGS=\"$CFLAGS\"\n      save_CPPFLAGS=\"$CPPFLAGS\"\n      save_LDFLAGS=\"$LDFLAGS\"\n\n      dnl Add the user-specified OpenCV installation directory to these\n      dnl paths.  Ensure that /usr/include and /usr/lib are not included\n      dnl multiple times if $OPENCV_ROOT is \"/usr\".\n      if test \"x$OPENCV_ROOT\" != \"x/usr\" ; then\n         CPPFLAGS=\"$CPPFLAGS -I$OPENCV_ROOT/include\"\n         #CFLAGS=\"$CFLAGS -I$OPENCV_ROOT/include\"\n         cv_ldflags=\"-L$OPENCV_ROOT/lib\"\n         LDFLAGS=\"$cv_ldflags $LDFLAGS\"\n      fi\n\n      AC_LANG_PUSH([C++])\n      save_LIBS=\"$LIBS\"\n      AC_SEARCH_LIBS([cvNorm], [opencv_core opencv_imgproc opencv_ml opencv_video opencv_features2d], [AC_CHECK_HEADER([opencv2/video/video.hpp], [have_opencv='yes'])])\n      LIBS=\"$save_LIBS\"\n      AC_LANG_POP()\n\n\n      dnl If OpenCV API files were found, define this extra stuff that may\n      dnl be helpful in some Makefiles.\n      if test \"x$have_opencv\" = \"xyes\" ; then\ndnl   NOTE: pkg-config returns the wrong commandline in some cases, so we disable it!\ndnl         export PKG_CONFIG_PATH=\"$OPENCV_ROOT/lib/pkgconfig\"\ndnl\t OPENCV_LDFLAGS=`pkg-config --silence-errors --libs opencv`\ndnl\t OPENCV_CPPFLAGS=`pkg-config --silence-errors --cflags opencv`\ndnl echo \"OPCVCPP: $OPENCV_CPPFLAGS\";\ndnl OPENCV_CPPFLAGS=\"-I$OPENCV_ROOT/include\"\ndnl         unset PKG_CONFIG_PATH\n\t if test \"x$OPENCV_LDFLAGS\" = \"x\" ; then\n           OPENCV_LDFLAGS=\"-lopencv_core -lopencv_imgproc -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_objdetect -lopencv_highgui\";\n           if test \"x$OPENCV_ROOT\" != \"x/usr\" ; then\n             OPENCV_LDFLAGS=\"-L$OPENCV_ROOT/lib $OPENCV_LDFLAGS\"\n             OPENCV_CPPFLAGS=\"-I$OPENCV_ROOT/include\"\n           fi\n         fi\n         AC_DEFINE([HAVE_OPENCV],1,[Compile with OpenCV support])\n         OPENCV='yes'\n      else\n         AC_MSG_WARN([Compiling WITHOUT OpenCV support! You won't be able to extract video features.])\n      fi\n\n      dnl Restore all the variables now that we are done testing.\n      CFLAGS=\"$save_CFLAGS\"\n      CPPFLAGS=\"$save_CPPFLAGS\"\n      LDFLAGS=\"$save_LDFLAGS\"\n   fi\n\n   dnl Export all of the output vars for use by makefiles and configure script.\n   AC_SUBST(OPENCV_ROOT)\n   AC_SUBST(OPENCV_CPPFLAGS)\n   AC_SUBST(OPENCV_LDFLAGS)\n])\n"
  },
  {
    "path": "m4/portaudio.m4",
    "content": "dnl  m4 macro to check for existance of PortAudio library\ndnl      written by Florian Eyben, 11/2008\ndnl\ndnl  usage:  CHECK_HAVE_PORTAUDIO( [default path] )\ndnl  if no default path is given, the default is /usr\ndnl\ndnl  The following defines are set, if the library is found:\ndnl    #define HAVE_PORTAUDIO 1\ndnl    #define HAVE_PORTAUDIO_V19 1    (only if installed portaudio has newer V19 API)\ndnl \ndnl  The following Makefile substitutions are added:\ndnl    PORTAUDIO_CPPFLAGS  (for includes)\ndnl    PORTAUDIO_LDFLAGS   (for libraries)\ndnl    PORTAUDIO_ROOT      (points to the c++/ directory in the semaine folder)\ndnl\n\n\nAC_DEFUN([CHECK_HAVE_PORTAUDIO],\n[\n   PORTAUDIO='no'\n   PORTAUDIO_V19='no'\n   PORTAUDIO_ROOT=''\n   PORTAUDIO_CPPFLAGS=''\n   PORTAUDIO_LDFLAGS=''\n   have_portaudio='no'\n   have_portaudio_v19='no'\n\n   if test \"x$1\" = \"x\" ; then\n     DEFAULT='/usr'\n   else\n     DEFAULT=$1\n   fi\n\n   dnl Define the root directory for the PortAudio installation.\n   AC_ARG_WITH(portaudio,\n               [  --with-portaudio=<PATH> PortAudio installation dir. default=$1],\n               PORTAUDIO_ROOT=\"$withval\", PORTAUDIO_ROOT=$DEFAULT)\n\n   if test \"x$PORTAUDIO_ROOT\" != \"xno\" ; then\n      dnl Save these values in case they need to be restored later.\n      save_CFLAGS=\"$CFLAGS\"\n      save_CPPFLAGS=\"$CPPFLAGS\"\n      save_LDFLAGS=\"$LDFLAGS\"\n\n      dnl Add the user-specified PortAudio installation directory to these\n      dnl paths.  Ensure that /usr/include and /usr/lib are not included\n      dnl multiple times if $PORTAUDIO_ROOT is \"/usr\".\n      if test \"x$PORTAUDIO_ROOT\" != \"x/usr\" ; then\n         CPPFLAGS=\"$CPPFLAGS -I$PORTAUDIO_ROOT/include\"\n         #CFLAGS=\"$CFLAGS -I$PORTAUDIO_ROOT/include\"\n\n         if test -d \"$PORTAUDIO_ROOT/lib\" ; then\n            pa_ldflags=\"-L$PORTAUDIO_ROOT/lib\"\n         else\n            pa_ldflags=\"-L$PORTAUDIO_ROOT/lib\"\n         fi\n\n         LDFLAGS=\"$pa_ldflags $LDFLAGS\"\n      fi\n\n\n      save_LIBS=\"$LIBS\"\n      AC_CHECK_LIB([portaudio], [Pa_Initialize],\n            [AC_CHECK_HEADER([portaudio.h], [have_portaudio='yes'])])\n      AC_CHECK_LIB([portaudio], [Pa_GetHostApiCount], [have_portaudio_v19='yes'])\n      LIBS=\"$save_LIBS\"\n\n      dnl test if portaudio is latest version... i.e. has Pa_streamStatus\n      dnl TODO....\n\n      dnl If PortAudio API files were found, define this extra stuff that may\n      dnl be helpful in some Makefiles.\n      if test \"x$have_portaudio\" = \"xyes\" ; then\n         export PKG_CONFIG_PATH=\"$PORTAUDIO_ROOT:$PORTAUDIO_ROOT/include:$PORTAUDIO_ROOT/build\"\n\t PORTAUDIO_LDFLAGS=`pkg-config --silence-errors --libs portaudio-2.0`\n\t PORTAUDIO_CPPFLAGS=`pkg-config --silence-errors --cflags portaudio-2.0`\n#echo \"PACPP: $PORTAUDIO_CPPFLAGS\";\nPORTAUDIO_CPPFLAGS=\"-I$PORTAUDIO_ROOT/include\"\n         unset PKG_CONFIG_PATH\n\t if test \"x$PORTAUDIO_LDFLAGS\" = \"x\" ; then\n           PORTAUDIO_LDFLAGS=\"-lportaudio\";\n           if test \"x$PORTAUDIO_ROOT\" != \"x/usr\" ; then\n             PORTAUDIO_LDFLAGS=\"$PORTAUDIO_LDFLAGS -L$PORTAUDIO_ROOT/lib\"\n             PORTAUDIO_CPPFLAGS=\"-I$PORTAUDIO_ROOT/include\"\n           fi\n         fi\n         AC_DEFINE([HAVE_PORTAUDIO],1,[Compile with portaudio support])\n         if test \"x$have_portaudio_v19\" = \"xyes\" ; then\n           AC_DEFINE([HAVE_PORTAUDIO_V19],1,[Detected portaudio has newer V19 api])\n           PORTAUDIO_V19='yes'\n         fi\n         PORTAUDIO='yes'\n      else\n         AC_MSG_WARN([Compiling WITHOUT PortAudio support!! Sound recording will probably be broken!])\n      fi\n\n      dnl Restore all the variables now that we are done testing.\n      CFLAGS=\"$save_CFLAGS\"\n      CPPFLAGS=\"$save_CPPFLAGS\"\n      LDFLAGS=\"$save_LDFLAGS\"\n   fi\n\n   dnl Export all of the output vars for use by makefiles and configure script.\n   AC_SUBST(PORTAUDIO_ROOT)\n   AC_SUBST(PORTAUDIO_CPPFLAGS)\n   AC_SUBST(PORTAUDIO_LDFLAGS)\n])\n"
  },
  {
    "path": "m4/targets.m4",
    "content": "dnl m4 macro to configure smile build targets\ndnl   written by Florian Eyben, 11/2008\ndnl\ndnl Configured the targets to be build based on the --enable/--disable options \ndnl Further, disables those targets that cannot be built due to missing dependencies\ndnl\ndnl IMPORTANT: call this macro AFTER the library checks!\ndnl\n\nAC_DEFUN([CONFIGURE_TARGETS],\n[\n  dnl the defaults:\n  enable_liverec='yes'\n  build_smilextract='yes'\n\n  # program features::::\n\n  AC_ARG_ENABLE([liverec],[  --enable-liverec  enable live input feature.  default=yes],\n          enable_liverec=\"$enableval\", enable_liverec=\"$enable_liverec\")\n\n  if test x$enable_liverec = xyes; then\n    AC_DEFINE([WITH_LIVEREC],[1],[Support live input from soundcard/microphone])\n  fi\n \n  # build targets:::\n\n  AC_ARG_ENABLE([SMILExtract],[  --enable-SMILExtract  build standalone commandline feature extractor.  default=yes],\n           build_smilextract=\"$enableval\", build_featum=\"$build_smilextract\")\n\n  AM_CONDITIONAL([BUILD_SMILExtract],[test x$build_smilextract = xyes])\n\n])\n\n"
  },
  {
    "path": "plugindev/AUTHORS",
    "content": "Florian Eyben, Martin Woellmer, Bjoern Schuller\n"
  },
  {
    "path": "plugindev/COPYING",
    "content": "\n  openSMILE \n   - open-source\n     Speech and Music Interpretation by Large-space Extraction -\n\n  Main authors: Florian Eyben, Felix Weninger, Martin Woellmer, Bjoern Schuller\n\n  Copyright (c) audEERING GmbH, Gilching, Germany. All rights reserved. \n  http://www.audeeering.com/\n\n  Copyright (c) 2016,      audEERING GmbH\n  Copyright (c) 2013-2015, audEERING UG (haftungsbeschraenkt)\n  Copyright (c) 2008-2013, Institute for Human-Machine Communication, \n                           Technische Universitaet Muenchen, Germany\n \nLicensing terms & your rights\n=============================\n  \n********************************************************************** \n If you use openSMILE or any code from openSMILE in your research work,\n you are kindly asked to acknowledge the use of openSMILE in your \n publications. See the file CITING.txt for details.\n**********************************************************************\n\nThis audEERING Research License Agreement (license, license agreement, \nor agreement in the ongoing), is a legal agreement between you \nand audEERING GmbH, Gilching, Germany (audEERING or we in the following) \nfor the software or data identified above, which may include source code, \nand any associated materials, text or speech files, \nassociated media and \"online\" or electronic documentation \n(together, the \"Software\").  \n\nBy installing, copying, or otherwise using this Software, \nyou agree to be bound by the terms in this license. \nIf you do not agree, you may not install copy or use the Software. \nThe Software is protected by copyright and other intellectual \nproperty laws and is licensed, not sold.\n\nThis license grants you the following rights:\nA. You may use, copy, reproduce, and distribute this Software \n   for any non-commercial purpose, subject to the restrictions \n   set out below. Some purposes which can be non-commercial are teaching, \n   academic research, public demonstrations and personal experimentation \n   or personal home use. You may also distribute this Software with \n   books or other teaching materials, or publish the Software on websites, \n   that are intended to teach the use of the Software for academic or \n   other non-commercial purposes. \n   You may NOT use or distribute this Software or any derivative works \n   in any form for commercial purposes, except those outlined in (B). \n   Examples of commercial purposes are running business operations, \n   licensing, leasing, or selling the Software, distributing the \n   Software for use with commercial products (no matter whether free or paid), \n   using the Software in the creation or use of commercial products or any \n   other activity which purpose is to procure a commercial gain to you or \n   others (except for conditions set out in (B)).\nB. Further, you may use the software for commercial research, which meets\n   the following conditions: commercial research which is not directly\n   associated with product development and has the primary purpose of \n   publishing and sharing results with the academic world; pre-product \n   evaluations of algorithms and methods, as long as these evaluations\n   are more of an evaluatory, planning, and research nature than \n   of a product development nature. \n   Any further commercial use requires you to obtain a commercial\n   license or written approval from audEERING GmbH which grants\n   you extended usage rights for this software. In particular any direct \n   (software) or indirect (models, features extracted with the software)\n   use of the software, parts of the software, or derivatives in a \n   product (no matter whether free or paid), is not allowed without \n   an additional commercial license.\nC. If the software includes source code or data, you may create \n   derivative works of such portions of the software and distribute the \n   modified software for non-commercial purposes, as provided herein.\n   If you distribute the software or any derivative works of the Software, \n   you must distribute them under the same terms and conditions as in this\n   license, and you must not grant other rights to the software or \n   derivative works that are different from those provided by this \n   license agreement. \n   If you have created derivative works of the software, and distribute \n   such derivative works, you will cause the modified files to carry \n   prominent notices so that recipients know that they are not receiving \n   the original software. Such notices must state: \n   (i) that you have altered the software; \n   and (ii) the date of any changes as well as your name.\n\nIn return for the above rights, you agree to:\n1. That you will not remove any copyright or other notices (authors \n   and citing information, for example) from the software.\n2. That if any of the software is in binary format, you will not attempt \n   to modify such portions of the software, or to reverse engineer or \n   decompile them, except and only to the extent authorized by applicable \n   law. \n3. That the copyright holders (audEERING) are granted back, \n   without any restrictions or limitations, a non-exclusive, perpetual, \n   irrevocable, royalty-free, assignable and sub-licensable license, \n   to reproduce, publicly perform or display, install, use, modify, post, \n   distribute, make and have made, sell and transfer your modifications \n   to and/or derivative works of the software source code or data, \n   for any purpose.  \n4. That any feedback about the software provided by you to us is voluntarily \n   given, and audEERING shall be free to use the feedback \n   as they see fit without obligation or restriction of any kind, \n   even if the feedback is designated by you as confidential. \n\n5. THAT THE SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. \n   THIS MEANS NO EXPRESS, IMPLIED OR STATUTORY WARRANTY, INCLUDING \n   WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A \n   PARTICULAR PURPOSE, ANY WARRANTY AGAINST INTERFERENCE WITH YOUR \n   ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE OR NON-INFRINGEMENT.\n   THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL ANY OF YOUR \n   PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS DISCLAIMER ON \n   WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n   \n6. THAT NEITHER AUDEERING NOR ANY AUTHOR OR CONTRIBUTOR TO THE \n   SOFTWARE WILL BE LIABLE FOR ANY DAMAGES RELATED TO THE SOFTWARE OR THIS \n   LICENSE, INCLUDING DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL \n   DAMAGES, TO THE MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL \n   THEORY IT IS BASED ON. ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY \n   ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n   \n7. That we have no duty of reasonable care or lack of negligence, \n   and we are not obligated to (and will not) provide technical support for \n   the Software.\n8. That if you breach this license agreement or if you sue anyone over \n   patents that you think may apply to or read on the software or anyone's \n   use of the software, this license agreement (and your license and rights \n   obtained herein) terminate automatically. Upon any such termination, \n   you shall destroy all of your copies of the software immediately.  \n   Sections 3, 4, 5, 6, 7, 10 and 11 of this license agreement shall survive \n   any termination of this license agreement.\n9. That the patent rights, if any, granted to you in this license agreement \n   only apply to the software, not to any derivative works you make.\n10.That the software may be subject to European export or import laws or such \n   laws in other places. You agree to comply with all such laws and regulations \n   that may apply to the software after the delivery of the software to you.\n11.That all rights not expressly granted to you in this license agreement \n   are reserved by audEERING.\n12.That this license agreement shall be construed and controlled by the laws \n   of the Federal Republic of Germany, without regard to conflicts of law. \n   If any provision of this license agreement shall be deemed unenforceable \n   or contrary to law, the rest of this license agreement shall remain in \n   full effect and interpreted in an enforceable manner that most closely \n   captures the intent of the original language. \n\n\nCommerical license options\n==========================\n \nFor commercial and other licensing options, \nplease contact us at audEERING via E-mail: \n   info@audeering.com \n\n\nThird-party contributions and dependencies\n==========================================\n\nopenSMILE contains third-party contributions from the Speex codec package \n(in the cLsp component), which are distributed unter the following terms:\n-----------------------------------------------------------------------\nCopyright 2002-2008     Xiph.org Foundation\nCopyright 2002-2008     Jean-Marc Valin\nCopyright 2005-2007     Analog Devices Inc.\nCopyright 2005-2008     Commonwealth Scientific and Industrial Research\n                        Organisation (CSIRO)\nCopyright 1993, 2002, 2006 David Rowe\nCopyright 2003          EpicGames\nCopyright 1992-1994     Jutta Degener, Carsten Bormann\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n\n- Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n\n- Redistributions in binary form must reproduce the above copyright\nnotice, this list of conditions and the following disclaimer in the\ndocumentation and/or other materials provided with the distribution.\n\n- Neither the name of the Xiph.org Foundation nor the names of its\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR\nCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\nEXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\nPROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\nPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n-----------------------------------------------------------------------\n\nopenSMILE uses rapidjson to read RNN files in json format.\nRapidjson can be obtained from: https://code.google.com/p/rapidjson/\nIt is distributed under the MIT license and included with openSMILE\nin src/include/rapidjson\nIt is distributed under these terms:\n-----------------------------------------\nCopyright (C) 2011 Milo Yip\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n-----------------------------------------\n\n\nopenSMILE uses LibSVM (by Chih-Chung Chang and Chih-Jen Lin) for \nclassification tasks. It is distributed with openSMILE and is\n included in the src/classifiers/libsvm/ directory.\nSee the COPYRIGHT file in that directory for details on license terms\n of LivSVM.\n\nPortAudio is required for live recording from sound card and for \nthe SEMAINE components.\nYou can get the latest version from: http://www.portaudio.com\nHowever, we cannot guarantee compatibility with the latest versions.\nA snapshot of portaudio that is known to work with openSMILE\nis included in thirdparty/portaudio.tgz.\nCopyright and licensing information for portaudio is also contained\nin the .tgz package.\n\nOptionally, openSMILE can be linked against the SEMAINE API \nand the Julius LVCSR engine, enabling an interface to the \nSEMAINE system and a keyword spotter component. \nSee http://www.semaine-project.eu/ for details on running the \nSEMAINE system.\nOnly the older versions of openSMILE (1.0.1) are officially \nsupported to be build with the SEMAINE system.\nFor recent developments, check out the status of the ARIA VALUSPA\nEU-project: http://aria-agent.eu/\n\n\n\n"
  },
  {
    "path": "plugindev/ChangeLog",
    "content": "\n"
  },
  {
    "path": "plugindev/ClassifierResultGUI.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample dataSink:\nreads data from data memory and outputs it to console/logfile (via smileLogger)\nthis component is also useful for debugging\n\n*/\n\n\n#include <classifierResultGUI.hpp>\n\n#define MODULE \"cClassifierResultGUI\"\n\n\nSMILECOMPONENT_STATICS(cClassifierResultGUI)\n\nSMILECOMPONENT_REGCOMP(cClassifierResultGUI)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CCLASSIFIERRESULTGUI;\n  sdescription = COMPONENT_DESCRIPTION_CCLASSIFIERRESULTGUI;\n\n  // we inherit cDataSink configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSink\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"classes\",\"names of classification classes\",(const char *)NULL,ARRAY_TYPE);\n    ct->setField(\"regression\",\"names of regression targets\",(const char *)NULL,ARRAY_TYPE);\n\n    ct->setField(\"images\",\"The names of the image files to load for each class (array).\",(const char *)NULL,ARRAY_TYPE);\n    //ct->setField(\"showRegval\",\"Show a regression value computed from the confidences (if showRegval=2), or which was received via the smileMessage (showRegval=1), or not at all (showRegval=0).\",0);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cClassifierResultGUI);\n}\n\n\n//SMILECOMPONENT_CREATE(cClassifierResultGUI)\ncSmileComponent * cClassifierResultGUI::create(const char*_instname) { \n  cSmileComponent *c = new cClassifierResultGUI(_instname); \n  if (c!=NULL) c->setComponentInfo(sconfman,COMPONENT_NAME_CCLASSIFIERRESULTGUI,COMPONENT_DESCRIPTION_CCLASSIFIERRESULTGUI); \n  return c; \n}\n\n//--- wx ---\n\n\n\n/*\nenum\n{\n    ID_Quit = 1,\n    ID_About,\n};\n\nBEGIN_EVENT_TABLE(MyFrame, wxFrame)\n    EVT_MENU(ID_Quit,  MyFrame::OnQuit)\n    EVT_MENU(ID_About, MyFrame::OnAbout)\nEND_EVENT_TABLE()\n*/\n\n\n\nwxMultiImagePanel::wxMultiImagePanel(wxFrame* parent,  int _nClasses, int nRegr) :\nwxPanel(parent), nClasses(_nClasses), image(NULL), confidence(NULL), clsName(NULL), regressionValue(NULL), regressionText(NULL), nRegression(nRegr)\n{\n    // load the file... ideally add a check to see if loading was successful\n    //image.LoadFile(file, format);\n  if (nClasses > 0) {\n    image = new wxBitmap[nClasses];\n    confidence = new float[nClasses];\n    clsName = (const char **)calloc(1,sizeof(const char*)*nClasses);\n  }\n  if (nRegr > 0) {\n    regressionValue = new float[nRegression];\n    regressionText =  (const char **)calloc(1,sizeof(const char*)*nRegression);\n  }\n}\n \nvoid wxMultiImagePanel::loadClassImage(int clsIdx, const char *clsname, wxString file, wxBitmapType format)\n{\n  if (image != NULL && clsIdx >= 0 && clsIdx < nClasses) {\n    image[clsIdx].LoadFile(file, format);\n  }\n  if (clsName != NULL && clsIdx >= 0 && clsIdx < nClasses) {\n    clsName[clsIdx] = clsname;\n  }\n}\n\n/*\n * Called by the system of by wxWidgets when the panel needs\n * to be redrawn. You can also trigger this call by\n * calling Refresh()/Update().\n */\n \nvoid wxMultiImagePanel::paintEvent(wxPaintEvent & evt)\n{\n    // depending on your system you may need to look at double-buffered dcs\n    wxPaintDC dc(this);\n    render(dc);\n}\n \n/*\n * Alternatively, you can use a clientDC to paint on the panel\n * at any time. Using this generally does not free you from\n * catching paint events, since it is possible that e.g. the window\n * manager throws away your drawing when the window comes to the\n * background, and expects you will redraw it when the window comes\n * back (by sending a paint event).\n */\nvoid wxMultiImagePanel::paintNow()\n{\n    // depending on your system you may need to look at double-buffered dcs\n    wxClientDC dc(this);\n    render(dc);\n}\n \n// render a simple meter gauge (vertical)\n// val = 0..100 (percentage of filling)\nvoid wxMultiImagePanel::renderGauge(wxDC&  dc, int x, int y, int w, int h, int val, const char * label, const char *col)\n{\n  dc.SetPen(wxPen(wxColour(\"black\")));\n  dc.SetBrush(wxBrush(wxColour(\"white\")));\n  dc.DrawRectangle(x,y,w,h);\n  int fill=0;\n  fill = (int)(((float)val / 100.0) * (float)w);\n  if (fill >= w) fill = w-1;\n  if (fill > 1) {\n    dc.DrawLine(x+fill,y+1,x+fill,y+h-1);\n    dc.SetBrush(wxBrush(wxColour(col)));\n    dc.FloodFill(x+2,y+2,wxColour(\"black\"),wxFLOOD_BORDER);\n    dc.SetPen(wxPen(wxColour(col)));\n    dc.DrawLine(x+fill,y+1,x+fill,y+h-1);\n  } else if  (fill == 1) {\n    dc.SetPen(wxPen(wxColour(col)));\n    dc.DrawLine(x+fill,y+1,x+fill,y+h-1);\n  }\n\n  if (label != NULL) {\n    dc.DrawText(label,x+w+10,y);\n  }\n}\n\n/*\n * Here we do the actual rendering. I put it in a separate\n * method so that it can work no matter what type of DC\n * (e.g. wxPaintDC or wxClientDC) is used.\n */\nvoid wxMultiImagePanel::render(wxDC&  dc)\n{\n  int imgX = 50;\n  int imgY = 70;\n  int imgW = 200;\n  int imgH = 200;\n\n  // position (upper left) of first gauge.\n  int regGaugeX = 50;\n  int regGaugeY = imgY+imgH+50;\n  int gaugeW = 100;\n  int gaugeH = 20;\n  int gaugeSpace = 5;\n\n  // position (upper left) of first gauge.\n  int confGaugeX = 50+imgW+25;\n  int confGaugeY = imgY+50;\n \n\n  dc.Clear();\n\n  //regressison value\n  if (nRegression > 0) {\n    int i;\n    dc.DrawText(\"Regression result(s):\",regGaugeX,regGaugeY-25);\n    for (i=0; i<nRegression; i++) {\n      renderGauge(dc, regGaugeX, regGaugeY+(gaugeH+gaugeSpace)*i, gaugeW, gaugeH, regressionValue[i], regressionText[i]);\n    }\n  }\n\n  // class confidence gauges\n  float ctr=0.0;\n  if (nClasses > 0) {\n    int i;\n    dc.DrawText(\"Class confidences:\",confGaugeX,confGaugeY-25);\n    for (i=0; i<nClasses; i++) {\n      renderGauge(dc, confGaugeX, confGaugeY+(gaugeH+gaugeSpace)*i, gaugeW, gaugeH, (int)(confidence[i]*100.0), clsName[i]);\n      ctr += confidence[i]*(float)(i+1);\n    }\n    ctr -= 1.0;\n    ctr /= 2.0;\n  }\n\n  int _classActive = classActive;\n  /// make this configurable!\n  _classActive = (int)floor(ctr*(float)nClasses);\n  //// \n  if (nClasses > 0 && _classActive >= 0 && _classActive < nClasses && image != NULL) {\n    dc.DrawBitmap( image[_classActive], imgX, imgY, false );\n    if (clsName != NULL) {\n      dc.DrawText(\"Classification result:\", imgX,imgY-40);\n      dc.DrawText(clsName[_classActive], imgX+10, imgY-20);\n    }\n  }\n\n  // confidence centroid...\n  dc.DrawText(\"Centroid of class confidences (pseudo regression:)\",confGaugeX, confGaugeY+(gaugeH+gaugeSpace)*nClasses+10);\n  renderGauge(dc, confGaugeX, confGaugeY+(gaugeH+gaugeSpace)*nClasses+30, gaugeW, gaugeH, (int)(ctr*100.0), \"<- level of interest\", \"green\");\n  \n}\n\n\n// catch the event from the thread\nBEGIN_EVENT_TABLE(ClsResultFrame, wxFrame)\nEVT_COMMAND  (RESULT_UPDATE_ID, wxEVT_COMMAND_TEXT_UPDATED, ClsResultFrame::onResultUpdate)\nEND_EVENT_TABLE()\n\n\nBEGIN_EVENT_TABLE(wxMultiImagePanel, wxPanel)\n// catch paint events\nEVT_PAINT(wxMultiImagePanel::paintEvent)\nEND_EVENT_TABLE()\n\nconst int ID_CHECKBOX = 100;\n\n\nbool ClsResultApp::OnInit()\n{\n    // make sure to call this first\n    wxInitAllImageHandlers();\n\n\n    mframe = new ClsResultFrame( _(\"TUM openSMILE classifier demo output\"), wxPoint(50, 50), wxSize(650, 350), smileObj->nClasses, smileObj->nRegression );\n    mframe->Show(true);\n    int i;\n    for (i=0; i<smileObj->nClasses ; i++) {\n      mframe->drawPane->loadClassImage(i,smileObj->className[i],smileObj->imageFile[i],wxBITMAP_TYPE_JPEG);\n      \n    }\n    for (i=0; i<smileObj->nRegression ; i++) {\n      mframe->drawPane->setRegressionText(i,smileObj->regressionName[i]);\n    }\n    SetTopWindow(mframe);\n    return true;\n}\n\nClsResultFrame::ClsResultFrame(const wxString& title, const wxPoint& pos, const wxSize& size, int nCls, int nReg)\n       : wxFrame(NULL, wxID_ANY, title, pos, size)\n{\n    //wxPanel *panel = new wxPanel(this, wxID_ANY);\n    \n    if (nCls < 0) nCls = 0;\n    if (nReg < 0) nReg = 0;\n\n    //wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);\n    drawPane = new wxMultiImagePanel( this, nCls, nReg );\n\n    // wxT(\"vo.jpg\"), wxBITMAP_TYPE_JPEG\n\n    //sizer->Add(drawPane, 10, wxEXPAND);\n    //this->SetSizer(sizer);\n\n\n   // m_cb = new wxCheckBox(panel, ID_CHECKBOX, wxT(\"Voice activity\"), \n   //                     wxPoint(20, 20));\n\n   // m_cb->SetValue(false);\n\n//    wxImageHandler * jpegLoader = new wxJPEGHandler();\n//    wxImage::AddHandler(jpegLoader);\n\n//    bmp.LoadFile(\"vo.jpg\", wxBITMAP_TYPE_JPEG); \n\n/*\n    Connect(ID_CHECKBOX, wxEVT_COMMAND_CHECKBOX_CLICKED, \n          wxCommandEventHandler(CheckBox::OnToggle));\n  Centre();\n*/\n\n/*\nwxMenu *menuFile = new wxMenu;\n\n    menuFile->Append( ID_About, _(\"&About...\") );\n    menuFile->AppendSeparator();\n    menuFile->Append( ID_Quit, _(\"E&xit\") );\n\n    wxMenuBar *menuBar = new wxMenuBar;\n    menuBar->Append( menuFile, _(\"&File\") );\n\n    SetMenuBar( menuBar );\n*/\n\n    CreateStatusBar();\n    SetStatusText( _(\"openSMILE GUI plugin.\") );\n}\n/*\nvoid MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))\n{\n    Close(true);\n}\nvoid MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))\n{\n    wxMessageBox( _(\"This is a wxWidgets Hello world sample\"),\n                  _(\"About Hello World\"), \n                  wxOK | wxICON_INFORMATION, this );\n}\n*/\n//IMPLEMENT_APP(MyApp)\n\n\n\n\n\n//-----\n\ncClassifierResultGUI::cClassifierResultGUI(const char *_name) :\n  cSmileComponent(_name)\n{\n  // ...\n}\n\nvoid cClassifierResultGUI::fetchConfig()\n{\n  //cSmileComponent::fetchConfig();\n  \n  nClasses = getArraySize(\"classes\");\n  nRegression = getArraySize(\"regression\");\n  int nImages = getArraySize(\"images\");\n\n  if (nClasses > 0) {\n    int i;\n    className = (const char**)calloc(1,sizeof(const char*)*nClasses);\n    imageFile = (const char**)calloc(1,sizeof(const char*)*nClasses);\n    for (i=0; i<nClasses; i++) {\n      className[i] = getStr_f(myvprint(\"classes[%i]\",i));\n      if (i<nImages) \n        imageFile[i] = getStr_f(myvprint(\"images[%i]\",i));\n    }\n  }\n  if (nRegression > 0) {\n    regressionName = (const char**)calloc(1,sizeof(const char*)*nRegression);\n    int i;\n    for (i=0; i<nRegression; i++) {\n      regressionName[i] = getStr_f(myvprint(\"regression[%i]\",i));\n    }\n  }\n}\n\n\n/*\nint cClassifierResultGUI::myConfigureInstance()\n{\n  return  cDataSink::myConfigureInstance();\n  \n}\n*/\n\n\nSMILE_THREAD_RETVAL wxClsThreadRunner(void *_data)\n{\n  if (_data != NULL) {\n    cClassifierResultGUI *obj = (cClassifierResultGUI*)_data;\n    smileMutexLock(obj->wxMtx);\n    obj->pApp = new ClsResultApp(); \n    obj->pApp->smileObj = obj;\n    wxApp::SetInstance(obj->pApp);\n    smileMutexUnlock(obj->wxMtx);\n    wxEntry(0, NULL);\n    obj->pApp = NULL;\n//    obj->terminate = 1;\n    printf(\"wxwin terminate.\\n\");\n  }\n  SMILE_THREAD_RET;\n}\n\n\nint cClassifierResultGUI::myFinaliseInstance()\n{\n  // FIRST call cDataSink myFinaliseInstance, this will finalise our dataWriter...\n  //int ret = cSmileComponent::myFinaliseInstance();\n\n  /* if that was SUCCESSFUL (i.e. ret == 1), then do some stuff like\n     loading models or opening output files: */\n\n  \n  //fo = new openSmilePluginGUI::TestForm();\n  //IMPLEMENT_APP_NO_MAIN(appname)\n  int ret = 1;\n  smileMutexCreate(wxMtx);\n\n  if (!(int)smileThreadCreate(guiThr, wxClsThreadRunner, this)) {\n    SMILE_ERR(1,\"error creating GUI thread!!\");\n  }\n\n  return ret;\n}\n\n// search for a class by its name and get the local index\nint cClassifierResultGUI::getClassIndex(const char *name)\n{\n  int i;\n  if (className == NULL) return -1;\n  if (name == NULL) return -1;\n  for (i=0; i<nClasses; i++) {\n    if (!strcmp(name,className[i])) { return i; }\n  }\n  return -1;\n}\n\n// search for a class by its name and get the local index\nint cClassifierResultGUI::getRegressionIndex(const char *name)\n{\n  int i;\n  if (regressionName == NULL) return -1;\n  if (name == NULL) return -1;\n  for (i=0; i<nRegression; i++) {\n    if (!strcmp(name,regressionName[i])) { return i; }\n  }\n  return -1;\n}\n\nint cClassifierResultGUI::processComponentMessage( cComponentMessage *_msg )\n{\n  // TODO: classificationResult's' message for multiple outputs!\n  smileMutexLock(wxMtx);\n  if (pApp == NULL) return 0;\n  smileMutexUnlock(wxMtx);\n\n  if (isMessageType(_msg,\"classificationResult\")) {  \n    // determine origin by message's user-defined name, which can be set in the config file\n    int nCl = _msg->intData[0]; // number of classes in message (for class confidences)\n\n    SMILE_IMSG(3,\"received 'classificationResult' message (nCl = %i)\",nCl);\n\n\n    //int cl = getClassIndex((const char*)_msg->custData2);\n    //int rg = -1;\n    //if (nCl <= 1) { \n\n    int rg = getRegressionIndex((const char*)(_msg->custData2));\n    if (rg < 0) {\n      //SMILE_IERR(3,\"unknown classification result message '%s', name not found in local gui config\",(const char*)(_msg->custData2));\n      //return 0;\n      classificationEvent *c = new classificationEvent(nClasses,(int)(_msg->floatData[0]),_msg->msgname,0);\n      int i;\n      for (i=0; i<MIN(nCl,nClasses); i++) {\n        if (_msg->custData != NULL) {\n          c->confidences[i] = ((double*)(_msg->custData))[i];\n        } else {\n          c->confidences[i] = 0.0;\n        }\n      }\n\n      wxCommandEvent myevent(wxEVT_COMMAND_TEXT_UPDATED, RESULT_UPDATE_ID);\n      myevent.SetClientData(c);\n      pApp->mframe->GetEventHandler()->AddPendingEvent( myevent );\n    } else {\n      classificationEvent *c = new classificationEvent(0,0,(const char*)(_msg->custData2),nRegression);\n      c->regUpdate = rg;\n      c->regressionValue[rg] = _msg->floatData[0];\n      printf (\"regression rg=%i val=%f\\n\",rg,_msg->floatData[0]);\n      wxCommandEvent myevent(wxEVT_COMMAND_TEXT_UPDATED, RESULT_UPDATE_ID);\n      myevent.SetClientData(c);\n      pApp->mframe->GetEventHandler()->AddPendingEvent( myevent );\n    }\n\n\n    \n    return 1;  // message was processed\n  }\n\n  return 0;\n}\n\nint cClassifierResultGUI::myTick(long long t)\n{\n  return 0;\n\n}\n#if 0\n  SMILE_DBG(4,\"tick # %i, reading value vector:\",t);\n  cVector *vec= reader->getFrameRel(lag);  //new cVector(nValues+1);\n  if (vec == NULL) return 0;\n  //else reader->nextFrame();\n\n  long vi = vec->tmeta->vIdx;\n  double tm = vec->tmeta->time;\n\n  // update VA status in GUI....\n//  pApp->AddPendingEvent();\n// notify the main thread\n   \n  if ((int)(vec->dataF[0]) != old) {\n   old = (int)(vec->dataF[0]);\n   wxCommandEvent myevent(wxEVT_COMMAND_TEXT_UPDATED, VAD_UPDATE_ID);\n   myevent.SetInt((int)(vec->dataF[0]));  // pass some data along the event, a number in this case\n   pApp->mframe->GetEventHandler()->AddPendingEvent( myevent );\n  }\n\n/*  \n  // now print the vector:\n  int i;\n  for (i=0; i<vec->N; i++) {\n    //SMILE_PRINT(\"  (a=%i vi=%i, tm=%fs) %s.%s = %f\",reader->getCurR(),vi,tm,reader->getLevelName(),vec->name(i),vec->dataF[i]);\n    printf(\"  %s.%s = %f\\n\",reader->getLevelName(),vec->name(i),vec->dataF[i]);\n  }\n  \n  if (fHandle != NULL) {\n    for (i=0; i<vec->N; i++) {\n      fprintf(fHandle, \"%s = %f\\n\",vec->name(i),vec->dataF[i]);\n    }\n  }\n*/\n  // tick success\n  return 1;\n}\n#endif\n\ncClassifierResultGUI::~cClassifierResultGUI()\n{\n  if (className != NULL) free(className);\n  if (regressionName != NULL) free(regressionName);\n  if (imageFile != NULL) free(imageFile);\n}\n\n"
  },
  {
    "path": "plugindev/ClassifierResultGUI.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample dataSink:\nreads data from data memory and outputs it to console/logfile (via smileLogger)\nthis component is also useful for debugging\n\n*/\n\n\n#ifndef __CCLASSIFIERRESULTGUI_HPP\n#define __CCLASSIFIERRESULTGUI_HPP\n\n#include <smileCommon.hpp>\n#include <smileComponent.hpp>\n#include <wx/wx.h>\n\n#define COMPONENT_DESCRIPTION_CCLASSIFIERRESULTGUI \"This is an example of a cDataSink descendant. It reads data from the data memory and prints it to the console. This component is intended as a template for developers.\"\n#define COMPONENT_NAME_CCLASSIFIERRESULTGUI \"cClassifierResultGUI\"\n\n#undef class\n\n\n#include <wx/sizer.h>\n \nclass wxMultiImagePanel : public wxPanel\n    {\n      const char **clsName;\n      int classActive;\n      int nClasses;\n      wxBitmap *image;\n      float *confidence;\n\n      int nRegression;\n      const char ** regressionText;\n      float * regressionValue;\n\n    public:\n        wxMultiImagePanel(wxFrame* parent,  int _nClasses=0, int nRegr=0);\n        \n        void loadClassImage(int clsIdx, const char *clsname, wxString file, wxBitmapType format);\n        void setRegressionText(int nr, const char *text) {\n          if (regressionText != NULL && nr>=0 && nr < nRegression) {\n            regressionText[nr] = text;\n          }\n        }\n\n        void paintEvent(wxPaintEvent & evt);\n        void paintNow();\n        \n        void renderGauge(wxDC&  dc, int x, int y, int w, int h, int val, const char * label, const char *col=\"blue\");\n        void render(wxDC& dc);\n        \n        void setClassResult(int nr) {\n          if (nr >= 0 && nr < nClasses) {\n            classActive = nr;\n          }\n        }\n        void setClassConfidence(int idx, float conf) {\n          if (confidence != NULL && idx >= 0 && idx < nClasses) {\n            confidence[idx] = conf;\n          }\n        }\n        void setRegressionVal(int nr, float val) {\n          if (regressionValue != NULL && nr >= 0 && nr < nRegression) {\n            regressionValue[nr] = val; \n          }\n        }\n\n          ~wxMultiImagePanel() {\n            if (regressionText != NULL) free(regressionText);\n            if (clsName != NULL) free(clsName);\n            if (regressionValue != NULL) delete[] regressionValue;\n            if (confidence != NULL) delete[] confidence;\n            if (image != NULL) delete[] image;\n          }\n\n        DECLARE_EVENT_TABLE()\n    };\n \n \nclass classificationEvent {\npublic:\n  classificationEvent(int _nClasses=0, int _maxClsIdx=0, const char *_classname=NULL, int nRegr=0) : \n      confidences(NULL), nClasses(_nClasses), maxClsIdx(_maxClsIdx), classname(_classname), nRegression(nRegr), regUpdate(-1)\n      {\n        if (nClasses > 0) { confidences = new float[nClasses]; }\n        if (nRegression > 0) { regressionValue = new float[nRegression]; }\n      }\n      ~classificationEvent() { \n        if (confidences != NULL) delete[] confidences;\n        if (regressionValue != NULL) delete[] regressionValue;\n      }\n\n  const char *classname;\n  int maxClsIdx;\n  int nClasses;\n  int nRegression;\n  int regUpdate; // the index to update, set to -1 to update all\n  float *confidences;\n  float *regressionValue;\n  \n};\n \n\n// the ID we'll use to identify our event\nconst int RESULT_UPDATE_ID = 100002;\n\nclass ClsResultFrame: public wxFrame\n{\n  //wxBitmap bmp;\n    \n  wxCheckBox *m_cb;\n\npublic:\n    wxMultiImagePanel * drawPane; \n\n    ClsResultFrame(const wxString& title, const wxPoint& pos, const wxSize& size, int nCls, int nReg);\n\n/*    void OnQuit(wxCommandEvent& event);\n    void OnAbout(wxCommandEvent& event);*/\n\n    // this is called when the event from the thread is received\n    void onResultUpdate(wxCommandEvent& evt)\n    {\n      //smileMutexLock(wxMtx);\n      // replot\n      classificationEvent *ce = (classificationEvent *)evt.GetClientData();\n      if (ce->nClasses > 0) {\n        drawPane->setClassResult(ce->maxClsIdx);\n      } else {\n      if (ce->regUpdate >= 0) {\n            printf(\"event: clsidx = %i  val=%f\\n\",ce->regUpdate,ce->regressionValue[ce->regUpdate]);\n\n        drawPane->setRegressionVal(ce->regUpdate, ce->regressionValue[ce->regUpdate]);\n      } else {\n        int i;\n        for (i=0; i<ce->nRegression; i++) {\n          drawPane->setRegressionVal(i, ce->regressionValue[i]);\n        }\n      }\n      }\n\n      int i;\n      for (i=0; i<ce->nClasses; i++) {\n        drawPane->setClassConfidence(i,ce->confidences[i]);\n      }\n\n      drawPane->paintNow();\n      //smileMutexUnlock(wxMtx);\n    }\n\n    DECLARE_EVENT_TABLE()\n};\n\nclass cClassifierResultGUI;\n\nclass ClsResultApp: public wxApp\n{\n  virtual bool OnInit();\npublic:\n  cClassifierResultGUI * smileObj;\n  ClsResultFrame * mframe;\n  \n};\n\n\nclass cClassifierResultGUI : public cSmileComponent {\n  private:\n    smileThread guiThr;\n    \n    //gcroot<openSmilePluginGUI::TestForm^> fo;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    int getClassIndex(const char *name);\n    int getRegressionIndex(const char *name);\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n    virtual int processComponentMessage( cComponentMessage *_msg );\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    int nClasses;\n    int nRegression;\n    const char **className;\n    const char **imageFile;\n    const char **regressionName;\n\n    smileMutex wxMtx;\n    ClsResultApp* pApp;\n    cClassifierResultGUI(const char *_name);\n\n    virtual ~cClassifierResultGUI();\n};\n\n\n\n\n#endif // __CCLASSIFIERRESULTGUI_HPP\n"
  },
  {
    "path": "plugindev/INSTALL",
    "content": "Installation Instructions\n*************************\n\nCopyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,\n2006 Free Software Foundation, Inc.\n\nThis file is free documentation; the Free Software Foundation gives\nunlimited permission to copy, distribute and modify it.\n\nBasic Installation\n==================\n\nBriefly, the shell commands `./configure; make; make install' should\nconfigure, build, and install this package.  The following\nmore-detailed instructions are generic; see the `README' file for\ninstructions specific to this package.\n\n   The `configure' shell script attempts to guess correct values for\nvarious system-dependent variables used during compilation.  It uses\nthose values to create a `Makefile' in each directory of the package.\nIt may also create one or more `.h' files containing system-dependent\ndefinitions.  Finally, it creates a shell script `config.status' that\nyou can run in the future to recreate the current configuration, and a\nfile `config.log' containing compiler output (useful mainly for\ndebugging `configure').\n\n   It can also use an optional file (typically called `config.cache'\nand enabled with `--cache-file=config.cache' or simply `-C') that saves\nthe results of its tests to speed up reconfiguring.  Caching is\ndisabled by default to prevent problems with accidental use of stale\ncache files.\n\n   If you need to do unusual things to compile the package, please try\nto figure out how `configure' could check whether to do them, and mail\ndiffs or instructions to the address given in the `README' so they can\nbe considered for the next release.  If you are using the cache, and at\nsome point `config.cache' contains results you don't want to keep, you\nmay remove or edit it.\n\n   The file `configure.ac' (or `configure.in') is used to create\n`configure' by a program called `autoconf'.  You need `configure.ac' if\nyou want to change it or regenerate `configure' using a newer version\nof `autoconf'.\n\nThe simplest way to compile this package is:\n\n  1. `cd' to the directory containing the package's source code and type\n     `./configure' to configure the package for your system.\n\n     Running `configure' might take a while.  While running, it prints\n     some messages telling which features it is checking for.\n\n  2. Type `make' to compile the package.\n\n  3. Optionally, type `make check' to run any self-tests that come with\n     the package.\n\n  4. Type `make install' to install the programs and any data files and\n     documentation.\n\n  5. You can remove the program binaries and object files from the\n     source code directory by typing `make clean'.  To also remove the\n     files that `configure' created (so you can compile the package for\n     a different kind of computer), type `make distclean'.  There is\n     also a `make maintainer-clean' target, but that is intended mainly\n     for the package's developers.  If you use it, you may have to get\n     all sorts of other programs in order to regenerate files that came\n     with the distribution.\n\nCompilers and Options\n=====================\n\nSome systems require unusual options for compilation or linking that the\n`configure' script does not know about.  Run `./configure --help' for\ndetails on some of the pertinent environment variables.\n\n   You can give `configure' initial values for configuration parameters\nby setting variables in the command line or in the environment.  Here\nis an example:\n\n     ./configure CC=c99 CFLAGS=-g LIBS=-lposix\n\n   *Note Defining Variables::, for more details.\n\nCompiling For Multiple Architectures\n====================================\n\nYou can compile the package for more than one kind of computer at the\nsame time, by placing the object files for each architecture in their\nown directory.  To do this, you can use GNU `make'.  `cd' to the\ndirectory where you want the object files and executables to go and run\nthe `configure' script.  `configure' automatically checks for the\nsource code in the directory that `configure' is in and in `..'.\n\n   With a non-GNU `make', it is safer to compile the package for one\narchitecture at a time in the source code directory.  After you have\ninstalled the package for one architecture, use `make distclean' before\nreconfiguring for another architecture.\n\nInstallation Names\n==================\n\nBy default, `make install' installs the package's commands under\n`/usr/local/bin', include files under `/usr/local/include', etc.  You\ncan specify an installation prefix other than `/usr/local' by giving\n`configure' the option `--prefix=PREFIX'.\n\n   You can specify separate installation prefixes for\narchitecture-specific files and architecture-independent files.  If you\npass the option `--exec-prefix=PREFIX' to `configure', the package uses\nPREFIX as the prefix for installing programs and libraries.\nDocumentation and other data files still use the regular prefix.\n\n   In addition, if you use an unusual directory layout you can give\noptions like `--bindir=DIR' to specify different values for particular\nkinds of files.  Run `configure --help' for a list of the directories\nyou can set and what kinds of files go in them.\n\n   If the package supports it, you can cause programs to be installed\nwith an extra prefix or suffix on their names by giving `configure' the\noption `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.\n\nOptional Features\n=================\n\nSome packages pay attention to `--enable-FEATURE' options to\n`configure', where FEATURE indicates an optional part of the package.\nThey may also pay attention to `--with-PACKAGE' options, where PACKAGE\nis something like `gnu-as' or `x' (for the X Window System).  The\n`README' should mention any `--enable-' and `--with-' options that the\npackage recognizes.\n\n   For packages that use the X Window System, `configure' can usually\nfind the X include and library files automatically, but if it doesn't,\nyou can use the `configure' options `--x-includes=DIR' and\n`--x-libraries=DIR' to specify their locations.\n\nSpecifying the System Type\n==========================\n\nThere may be some features `configure' cannot figure out automatically,\nbut needs to determine by the type of machine the package will run on.\nUsually, assuming the package is built to be run on the _same_\narchitectures, `configure' can figure that out, but if it prints a\nmessage saying it cannot guess the machine type, give it the\n`--build=TYPE' option.  TYPE can either be a short name for the system\ntype, such as `sun4', or a canonical name which has the form:\n\n     CPU-COMPANY-SYSTEM\n\nwhere SYSTEM can have one of these forms:\n\n     OS KERNEL-OS\n\n   See the file `config.sub' for the possible values of each field.  If\n`config.sub' isn't included in this package, then this package doesn't\nneed to know the machine type.\n\n   If you are _building_ compiler tools for cross-compiling, you should\nuse the option `--target=TYPE' to select the type of system they will\nproduce code for.\n\n   If you want to _use_ a cross compiler, that generates code for a\nplatform different from the build platform, you should specify the\n\"host\" platform (i.e., that on which the generated programs will\neventually be run) with `--host=TYPE'.\n\nSharing Defaults\n================\n\nIf you want to set default values for `configure' scripts to share, you\ncan create a site shell script called `config.site' that gives default\nvalues for variables like `CC', `cache_file', and `prefix'.\n`configure' looks for `PREFIX/share/config.site' if it exists, then\n`PREFIX/etc/config.site' if it exists.  Or, you can set the\n`CONFIG_SITE' environment variable to the location of the site script.\nA warning: not all `configure' scripts look for a site script.\n\nDefining Variables\n==================\n\nVariables not defined in a site shell script can be set in the\nenvironment passed to `configure'.  However, some packages may run\nconfigure again during the build, and the customized values of these\nvariables may be lost.  In order to avoid this problem, you should set\nthem in the `configure' command line, using `VAR=value'.  For example:\n\n     ./configure CC=/usr/local2/bin/gcc\n\ncauses the specified `gcc' to be used as the C compiler (unless it is\noverridden in the site shell script).\n\nUnfortunately, this technique does not work for `CONFIG_SHELL' due to\nan Autoconf bug.  Until the bug is fixed you can use this workaround:\n\n     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash\n\n`configure' Invocation\n======================\n\n`configure' recognizes the following options to control how it operates.\n\n`--help'\n`-h'\n     Print a summary of the options to `configure', and exit.\n\n`--version'\n`-V'\n     Print the version of Autoconf used to generate the `configure'\n     script, and exit.\n\n`--cache-file=FILE'\n     Enable the cache: use and save the results of the tests in FILE,\n     traditionally `config.cache'.  FILE defaults to `/dev/null' to\n     disable caching.\n\n`--config-cache'\n`-C'\n     Alias for `--cache-file=config.cache'.\n\n`--quiet'\n`--silent'\n`-q'\n     Do not print messages saying which checks are being made.  To\n     suppress all normal output, redirect it to `/dev/null' (any error\n     messages will still be shown).\n\n`--srcdir=DIR'\n     Look for the package's source code in directory DIR.  Usually\n     `configure' can determine that directory automatically.\n\n`configure' also accepts some other, not widely useful, options.  Run\n`configure --help' for more details.\n\n"
  },
  {
    "path": "plugindev/Makefile.am",
    "content": "# NOTE: you need to add custom LIBS and CFLAGS here::::\n\nlib_LTLIBRARIES = libexampleplugin.la\nlibexampleplugin_la_SOURCES = pluginMain.cpp \\\n  plug_exampleSink.cpp\nlibexampleplugin_la_LIBADD = $(OPENSMILELIB_LIBS)\n\nINCLUDES = $(OPENSMILELIB_CFLAGS)\n\n"
  },
  {
    "path": "plugindev/NEWS",
    "content": "\n"
  },
  {
    "path": "plugindev/README",
    "content": "The files in this subdirecory are the build tree for opensmile plugins\n\n"
  },
  {
    "path": "plugindev/autogen.sh",
    "content": "# Copyright (C) 2008 Florian Eyben\n#  \n# This file is free software; as a special exception the author gives\n# unlimited permission to copy and/or distribute it, with or without \n# modifications, as long as this notice is preserved.\n# \n# This program is distributed in the hope that it will be useful, but\n# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the\n# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n#!/bin/sh\nrm -f config.cache\necho \"- aclocal.\"\naclocal -I m4\necho \"- autoconf.\"\nautoconf\necho \"- autoheader.\"\nautoheader\necho \"- automake.\"\nautomake -a\nlibtoolize\n\nexit\n"
  },
  {
    "path": "plugindev/configure.ac",
    "content": "\nAC_INIT([.],1)\nAM_INIT_AUTOMAKE(testplugin,0.0.0)\n\n\nAC_PROG_CC\nAC_PROG_CXX\n# AC_PROG_RANLIB\nAC_PROG_LIBTOOL\nAM_PROG_CC_C_O\n\nACX_PTHREAD\n\n#CHECK_HAVE_SEMAINEAPI\nCHECK_HAVE_OPENSMILELIB\n\n# CONFIGURE_TARGETS\n\nif test x`uname | grep mingw` != x ; then\n  AC_DEFINE([WIN32],[1], [Compile on MinGW32-Msys])\n  AC_DEFINE([__WINDOWS],[1], [Compile on MinGW32-Msys])\n  AC_DEFINE([__MINGW32],[1], [Compile on MinGW32-Msys])\n  AC_DEFINE([__MINGW],[1], [Compile on MinGW32-Msys])\nfi \n\nif test x`uname | grep MINGW` != x ; then\n  AC_DEFINE([WIN32],[1], [Compile on MinGW32-Msys])\n  AC_DEFINE([__WINDOWS],[1], [Compile on MinGW32-Msys])\n  AC_DEFINE([__MINGW32],[1], [Compile on MinGW32-Msys])\n  AC_DEFINE([__MINGW],[1], [Compile on MinGW32-Msys])\nfi \n\n\nAM_CONFIG_HEADER(config.h)\nAC_OUTPUT(Makefile)\n\n"
  },
  {
    "path": "plugindev/exampleGuipluginSink.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample dataSink:\nreads data from data memory and outputs it to console/logfile (via smileLogger)\nthis component is also useful for debugging\n\n*/\n\n\n#include <exampleGuipluginSink.hpp>\n\n#define MODULE \"cExampleGuipluginSink\"\n\n\nSMILECOMPONENT_STATICS(cExampleGuipluginSink)\n\nSMILECOMPONENT_REGCOMP(cExampleGuipluginSink)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CEXAMPLEGUIPLUGINSINK;\n  sdescription = COMPONENT_DESCRIPTION_CEXAMPLEGUIPLUGINSINK;\n\n  // we inherit cDataSink configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSink\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"filename\",\"The name of a text file to dump values to (this file will be overwritten, if it exists)\",(const char *)NULL);\n    ct->setField(\"lag\",\"Output data <lag> frames behind\",0,0,0);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cExampleGuipluginSink);\n}\n\n\n//SMILECOMPONENT_CREATE(cExampleGuipluginSink)\ncSmileComponent * cExampleGuipluginSink::create(const char*_instname) { \n  cSmileComponent *c = new cExampleGuipluginSink(_instname); \n  if (c!=NULL) c->setComponentInfo(sconfman,COMPONENT_NAME_CEXAMPLEGUIPLUGINSINK,COMPONENT_DESCRIPTION_CEXAMPLEGUIPLUGINSINK); \n  return c; \n}\n\n//--- wx ---\n\n\n\n/*\nenum\n{\n    ID_Quit = 1,\n    ID_About,\n};\n\nBEGIN_EVENT_TABLE(MyFrame, wxFrame)\n    EVT_MENU(ID_Quit,  MyFrame::OnQuit)\n    EVT_MENU(ID_About, MyFrame::OnAbout)\nEND_EVENT_TABLE()\n*/\n\r\n\n\r\nwxImagePanel::wxImagePanel(wxFrame* parent, wxString file, wxBitmapType format) :\r\nwxPanel(parent)\r\n{\r\n    // load the file... ideally add a check to see if loading was successful\r\n    image.LoadFile(file, format);\r\n}\r\n \r\n/*\r\n * Called by the system of by wxWidgets when the panel needs\r\n * to be redrawn. You can also trigger this call by\r\n * calling Refresh()/Update().\r\n */\r\n \r\nvoid wxImagePanel::paintEvent(wxPaintEvent & evt)\r\n{\r\n    // depending on your system you may need to look at double-buffered dcs\r\n    wxPaintDC dc(this);\r\n    render(dc);\r\n}\r\n \r\n/*\r\n * Alternatively, you can use a clientDC to paint on the panel\r\n * at any time. Using this generally does not free you from\r\n * catching paint events, since it is possible that e.g. the window\r\n * manager throws away your drawing when the window comes to the\r\n * background, and expects you will redraw it when the window comes\r\n * back (by sending a paint event).\r\n */\r\nvoid wxImagePanel::paintNow()\r\n{\r\n    // depending on your system you may need to look at double-buffered dcs\r\n    wxClientDC dc(this);\r\n    render(dc);\r\n}\r\n \r\n/*\r\n * Here we do the actual rendering. I put it in a separate\r\n * method so that it can work no matter what type of DC\r\n * (e.g. wxPaintDC or wxClientDC) is used.\r\n */\r\nvoid wxImagePanel::render(wxDC&  dc)\r\n{\r\n  if (showImg) {\r\n    dc.DrawBitmap( image, 50, 50, false );\r\n  } else {\r\n    dc.Clear();\r\n  }\r\n\r\n}\r\n\r\n\n// catch the event from the thread\r\nBEGIN_EVENT_TABLE(MyFrame, wxFrame)\r\nEVT_COMMAND  (VAD_UPDATE_ID, wxEVT_COMMAND_TEXT_UPDATED, MyFrame::onVadUpdate)\r\nEND_EVENT_TABLE()\r\n\n\r\nBEGIN_EVENT_TABLE(wxImagePanel, wxPanel)\r\n\r\n// catch paint events\r\nEVT_PAINT(wxImagePanel::paintEvent)\r\n \r\nEND_EVENT_TABLE()\n\nconst int ID_CHECKBOX = 100;\r\n\n\nbool MyApp::OnInit()\n{\n    // make sure to call this first\r\n    wxInitAllImageHandlers();\r\n\n    \r\n\n    mframe = new MyFrame( _(\"TUM openSMILE status window\"), wxPoint(50, 50), wxSize(450, 340) );\n    mframe->Show(true);\n    SetTopWindow(mframe);\n    return true;\n}\n\nMyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)\n       : wxFrame(NULL, wxID_ANY, title, pos, size)\n{\n    //wxPanel *panel = new wxPanel(this, wxID_ANY);\r\n    \n    \r\n    //wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);\r\n    drawPane = new wxImagePanel( this, wxT(\"vo.jpg\"), wxBITMAP_TYPE_JPEG);\r\n    //sizer->Add(drawPane, 10, wxEXPAND);\r\n    //this->SetSizer(sizer);\n\n\n   // m_cb = new wxCheckBox(panel, ID_CHECKBOX, wxT(\"Voice activity\"), \r\n   //                     wxPoint(20, 20));\r\n\n   // m_cb->SetValue(false);\r\n\r\n//    wxImageHandler * jpegLoader = new wxJPEGHandler();\r\n//    wxImage::AddHandler(jpegLoader);\r\n\r\n//    bmp.LoadFile(\"vo.jpg\", wxBITMAP_TYPE_JPEG); \r\n\r\n/*\r\n    Connect(ID_CHECKBOX, wxEVT_COMMAND_CHECKBOX_CLICKED, \r\n          wxCommandEventHandler(CheckBox::OnToggle));\r\n  Centre();\r\n*/\r\n\n/*\nwxMenu *menuFile = new wxMenu;\n\n    menuFile->Append( ID_About, _(\"&About...\") );\n    menuFile->AppendSeparator();\n    menuFile->Append( ID_Quit, _(\"E&xit\") );\n\n    wxMenuBar *menuBar = new wxMenuBar;\n    menuBar->Append( menuFile, _(\"&File\") );\n\n    SetMenuBar( menuBar );\n*/\n\n    CreateStatusBar();\n    SetStatusText( _(\"openSMILE status GUI.\") );\n}\n/*\nvoid MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))\n{\n    Close(true);\n}\nvoid MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))\n{\n    wxMessageBox( _(\"This is a wxWidgets Hello world sample\"),\n                  _(\"About Hello World\"), \n                  wxOK | wxICON_INFORMATION, this );\n}\n*/\n//IMPLEMENT_APP(MyApp)\n\n\n\n\n\n//-----\n\ncExampleGuipluginSink::cExampleGuipluginSink(const char *_name) :\n  cDataSink(_name),\n  fHandle(NULL)\n{\n  // ...\n}\n\nvoid cExampleGuipluginSink::fetchConfig()\n{\n  cDataSink::fetchConfig();\n  \n  filename = getStr(\"filename\");\n  SMILE_DBG(2,\"filename = '%s'\",filename);\n  lag = getInt(\"lag\");\n  SMILE_DBG(2,\"lag = %i\",lag);\n}\n\n\n/*\nint cExampleGuipluginSink::myConfigureInstance()\n{\n  return  cDataSink::myConfigureInstance();\n  \n}\n*/\n\n\nSMILE_THREAD_RETVAL wxAppThreadRunner(void *_data)\n{\n  if (_data != NULL) {\n    cExampleGuipluginSink *obj = (cExampleGuipluginSink*)_data;\n    obj->pApp = new MyApp(); \n    wxApp::SetInstance(obj->pApp);\n    wxEntry(0, NULL);\n  }\n  SMILE_THREAD_RET;\n}\n\n\nint cExampleGuipluginSink::myFinaliseInstance()\n{\n  // FIRST call cDataSink myFinaliseInstance, this will finalise our dataWriter...\n  int ret = cDataSink::myFinaliseInstance();\n\n  /* if that was SUCCESSFUL (i.e. ret == 1), then do some stuff like\n     loading models or opening output files: */\n\n  if ((ret)&&(filename != NULL)) {\n    fHandle = fopen(filename,\"w\");\n    if (fHandle == NULL) {\n      SMILE_IERR(1,\"failed to open file '%s' for writing!\",filename);\n      COMP_ERR(\"aborting\");\n\t    //return 0;\n    }\n  }\n\n  //fo = new openSmilePluginGUI::TestForm();\n  //IMPLEMENT_APP_NO_MAIN(appname)\n  if (!(int)smileThreadCreate(guiThr, wxAppThreadRunner, this)) {\n    SMILE_ERR(1,\"error creating GUI thread!!\");\n  }\n\n  return ret;\n}\n\n\nint cExampleGuipluginSink::myTick(long long t)\n{\n  SMILE_DBG(4,\"tick # %i, reading value vector:\",t);\n  cVector *vec= reader->getFrameRel(lag);  //new cVector(nValues+1);\n  if (vec == NULL) return 0;\n  //else reader->nextFrame();\n\n  long vi = vec->tmeta->vIdx;\n  double tm = vec->tmeta->time;\n\n  // update VA status in GUI....\n//  pApp->AddPendingEvent();\n// notify the main thread\r\n   \r\n  if ((int)(vec->dataF[0]) != old) {\r\n   old = (int)(vec->dataF[0]);\r\n   wxCommandEvent myevent(wxEVT_COMMAND_TEXT_UPDATED, VAD_UPDATE_ID);\r\n   myevent.SetInt((int)(vec->dataF[0]));  // pass some data along the event, a number in this case\r\n   pApp->mframe->GetEventHandler()->AddPendingEvent( myevent );\r\n  }\r\n\n/*  \n  // now print the vector:\n  int i;\n  for (i=0; i<vec->N; i++) {\n    //SMILE_PRINT(\"  (a=%i vi=%i, tm=%fs) %s.%s = %f\",reader->getCurR(),vi,tm,reader->getLevelName(),vec->name(i),vec->dataF[i]);\n    printf(\"  %s.%s = %f\\n\",reader->getLevelName(),vec->name(i),vec->dataF[i]);\n  }\n  \n  if (fHandle != NULL) {\n    for (i=0; i<vec->N; i++) {\n      fprintf(fHandle, \"%s = %f\\n\",vec->name(i),vec->dataF[i]);\n    }\n  }\n*/\n  // tick success\n  return 1;\n}\n\n\ncExampleGuipluginSink::~cExampleGuipluginSink()\n{\n  if (fHandle != NULL) {\n    fclose(fHandle);\n  }\n}\n\n"
  },
  {
    "path": "plugindev/exampleGuipluginSink.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample dataSink:\nreads data from data memory and outputs it to console/logfile (via smileLogger)\nthis component is also useful for debugging\n\n*/\n\n\n#ifndef __CEXAMPLEGUIPLUGINSINK_HPP\n#define __CEXAMPLEGUIPLUGINSINK_HPP\n\n#include <smileCommon.hpp>\n#include <dataSink.hpp>\n#include <wx/wx.h>\n\n#define COMPONENT_DESCRIPTION_CEXAMPLEGUIPLUGINSINK \"This is an example of a cDataSink descendant. It reads data from the data memory and prints it to the console. This component is intended as a template for developers.\"\n#define COMPONENT_NAME_CEXAMPLEGUIPLUGINSINK \"cExampleGuipluginSink\"\n\n#undef class\n\n\n#include <wx/sizer.h>\r\n \r\nclass wxImagePanel : public wxPanel\r\n    {\r\n        wxBitmap image;\r\n        \r\n        \r\n    public:\r\n        bool showImg;\r\n\r\n        wxImagePanel(wxFrame* parent, wxString file, wxBitmapType format);\r\n        \r\n        void paintEvent(wxPaintEvent & evt);\r\n        void paintNow();\r\n        \r\n        void render(wxDC& dc);\r\n        \r\n        DECLARE_EVENT_TABLE()\r\n    };\r\n \r\n \r\n \r\n \r\n\n// the ID we'll use to identify our event\r\nconst int VAD_UPDATE_ID = 100000;\r\n\nclass MyFrame: public wxFrame\n{\n  //wxBitmap bmp;\n  wxImagePanel * drawPane;   \r\n  wxCheckBox *m_cb;\n\npublic:\n    \n    MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);\n\n/*    void OnQuit(wxCommandEvent& event);\n    void OnAbout(wxCommandEvent& event);*/\n\r\n    // this is called when the event from the thread is received\r\n    void onVadUpdate(wxCommandEvent& evt)\r\n    {\r\n      // get the number sent along the event and use it to update the GUI\r\n      if (evt.GetInt()==1) {\r\n        //m_cb->SetValue( true );\r\n        drawPane->showImg = true;\r\n        drawPane->paintNow();\r\n      } else {\r\n        //m_cb->SetValue( false );\r\n        drawPane->showImg = false;\r\n        drawPane->paintNow();\r\n      }\r\n    }\r\n\n\n    \n\n    DECLARE_EVENT_TABLE()\n};\n\n\nclass MyApp: public wxApp\n{\n  virtual bool OnInit();\npublic:\n  MyFrame * mframe;\n  \n};\n\n\nclass cExampleGuipluginSink : public cDataSink {\n  private:\n    const char *filename;\n    FILE * fHandle;\n    int lag;\n    //wxCommandEvent &myevent; //( wxEVT_COMMAND_TEXT_UPDATED, VAD_UPDATE_ID );\n    int old;\n\n    smileThread guiThr;\n    //gcroot<openSmilePluginGUI::TestForm^> fo;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    MyApp* pApp;\n    cExampleGuipluginSink(const char *_name);\n\n    virtual ~cExampleGuipluginSink();\n};\n\n\n\n\n#endif // __CEXAMPLEGUIPLUGINSINK_HPP\n"
  },
  {
    "path": "plugindev/m4/find_pthread.m4",
    "content": "# from http://autoconf-archive.cryp.to/acx_pthread.html\n#  Copyright © 2008 Steven G. Johnson <stevenj@alum.mit.edu>\n# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n# You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.\n# As a special exception, the respective Autoconf Macro's copyright owner gives unlimited permission to copy, distribute and modify the configure scripts that are the output of Autoconf when processing the Macro. You need not follow the terms of the GNU General Public License when using or distributing such scripts, even though portions of the text of the Macro appear in them. The GNU General Public License (GPL) does govern all other use of the material that constitutes the Autoconf Macro.\n# This special exception to the GPL applies to versions of the Autoconf Macro released by the Autoconf Macro Archive. When you make and distribute a modified version of the Autoconf Macro, you may extend this special exception to the GPL to apply to your modified version as well.\n\nAC_DEFUN([ACX_PTHREAD], [\nAC_REQUIRE([AC_CANONICAL_HOST])\nAC_LANG_SAVE\nAC_LANG_C\nacx_pthread_ok=no\n\n# We used to check for pthread.h first, but this fails if pthread.h\n# requires special compiler flags (e.g. on True64 or Sequent).\n# It gets checked for in the link test anyway.\n\n# First of all, check if the user has set any of the PTHREAD_LIBS,\n# etcetera environment variables, and if threads linking works using\n# them:\nif test x\"$PTHREAD_LIBS$PTHREAD_CFLAGS\" != x; then\n        save_CFLAGS=\"$CFLAGS\"\n        CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\n        save_LIBS=\"$LIBS\"\n        LIBS=\"$PTHREAD_LIBS $LIBS\"\n        AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])\n        AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)\n        AC_MSG_RESULT($acx_pthread_ok)\n        if test x\"$acx_pthread_ok\" = xno; then\n                PTHREAD_LIBS=\"\"\n                PTHREAD_CFLAGS=\"\"\n        fi\n        LIBS=\"$save_LIBS\"\n        CFLAGS=\"$save_CFLAGS\"\nfi\n\n# We must check for the threads library under a number of different\n# names; the ordering is very important because some systems\n# (e.g. DEC) have both -lpthread and -lpthreads, where one of the\n# libraries is broken (non-POSIX).\n\n# Create a list of thread flags to try.  Items starting with a \"-\" are\n# C compiler flags, and other items are library names, except for \"none\"\n# which indicates that we try without any flags at all, and \"pthread-config\"\n# which is a program returning the flags for the Pth emulation library.\n\nacx_pthread_flags=\"pthreads none -Kthread -kthread lthread pthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config\"\n\n# The ordering *is* (sometimes) important.  Some notes on the\n# individual items follow:\n\n# pthreads: AIX (must check this before -lpthread)\n# none: in case threads are in libc; should be tried before -Kthread and\n#       other compiler flags to prevent continual compiler warnings\n# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)\n# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)\n# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)\n# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)\n# -pthreads: Solaris/gcc\n# -mthreads: Mingw32/gcc, Lynx/gcc\n# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it\n#      doesn't hurt to check since this sometimes defines pthreads too;\n#      also defines -D_REENTRANT)\n#      ... -mt is also the pthreads flag for HP/aCC\n# pthread: Linux, etcetera\n# --thread-safe: KAI C++\n# pthread-config: use pthread-config program (for GNU Pth library)\n\ncase \"${host_cpu}-${host_os}\" in\n        *solaris*)\n\n        # On Solaris (at least, for some versions), libc contains stubbed\n        # (non-functional) versions of the pthreads routines, so link-based\n        # tests will erroneously succeed.  (We need to link with -pthreads/-mt/\n        # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather\n        # a function called by this macro, so we could check for that, but\n        # who knows whether they'll stub that too in a future libc.)  So,\n        # we'll just look for -pthreads and -lpthread first:\n\n        acx_pthread_flags=\"-pthreads pthread -mt -pthread $acx_pthread_flags\"\n        ;;\nesac\n\nif test x\"$acx_pthread_ok\" = xno; then\nfor flag in $acx_pthread_flags; do\n\n        case $flag in\n                none)\n                AC_MSG_CHECKING([whether pthreads work without any flags])\n                ;;\n\n                -*)\n                AC_MSG_CHECKING([whether pthreads work with $flag])\n                PTHREAD_CFLAGS=\"$flag\"\n                ;;\n\n                pthread-config)\n                AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)\n                if test x\"$acx_pthread_config\" = xno; then continue; fi\n                PTHREAD_CFLAGS=\"`pthread-config --cflags`\"\n                PTHREAD_LIBS=\"`pthread-config --ldflags` `pthread-config --libs`\"\n                ;;\n\n                *)\n                AC_MSG_CHECKING([for the pthreads library -l$flag])\n                PTHREAD_LIBS=\"-l$flag\"\n                ;;\n        esac\n\n        save_LIBS=\"$LIBS\"\n        save_CFLAGS=\"$CFLAGS\"\n        LIBS=\"$PTHREAD_LIBS $LIBS\"\n        CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\n\n        # Check for various functions.  We must include pthread.h,\n        # since some functions may be macros.  (On the Sequent, we\n        # need a special flag -Kthread to make this header compile.)\n        # We check for pthread_join because it is in -lpthread on IRIX\n        # while pthread_create is in libc.  We check for pthread_attr_init\n        # due to DEC craziness with -lpthreads.  We check for\n        # pthread_cleanup_push because it is one of the few pthread\n        # functions on Solaris that doesn't have a non-functional libc stub.\n        # We try pthread_create on general principles.\n        AC_TRY_LINK([#include <pthread.h>],\n                    [pthread_t th; pthread_join(th, 0);\n                     pthread_attr_init(0); pthread_cleanup_push(0, 0);\n                     pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],\n                    [acx_pthread_ok=yes])\n\n        LIBS=\"$save_LIBS\"\n        CFLAGS=\"$save_CFLAGS\"\n\n        AC_MSG_RESULT($acx_pthread_ok)\n        if test \"x$acx_pthread_ok\" = xyes; then\n                break;\n        fi\n\n        PTHREAD_LIBS=\"\"\n        PTHREAD_CFLAGS=\"\"\ndone\nfi\n\n# Various other checks:\nif test \"x$acx_pthread_ok\" = xyes; then\n        save_LIBS=\"$LIBS\"\n        LIBS=\"$PTHREAD_LIBS $LIBS\"\n        save_CFLAGS=\"$CFLAGS\"\n        CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\n\n        # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.\n        AC_MSG_CHECKING([for joinable pthread attribute])\n        attr_name=unknown\n        for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do\n            AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],\n                        [attr_name=$attr; break])\n        done\n        AC_MSG_RESULT($attr_name)\n        if test \"$attr_name\" != PTHREAD_CREATE_JOINABLE; then\n            AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,\n                               [Define to necessary symbol if this constant\n                                uses a non-standard name on your system.])\n        fi\n\n        AC_MSG_CHECKING([if more special flags are required for pthreads])\n        flag=no\n        case \"${host_cpu}-${host_os}\" in\n            *-aix* | *-freebsd* | *-darwin*) flag=\"-D_THREAD_SAFE\";;\n            *solaris* | *-osf* | *-hpux*) flag=\"-D_REENTRANT\";;\n        esac\n        AC_MSG_RESULT(${flag})\n        if test \"x$flag\" != xno; then\n            PTHREAD_CFLAGS=\"$flag $PTHREAD_CFLAGS\"\n        fi\n\n        LIBS=\"$save_LIBS\"\n        CFLAGS=\"$save_CFLAGS\"\n\n        # More AIX lossage: must compile with xlc_r or cc_r\n        if test x\"$GCC\" != xyes; then\n          AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})\n        else\n          PTHREAD_CC=$CC\n        fi\nelse\n        PTHREAD_CC=\"$CC\"\nfi\n\n\nAC_SUBST([PTHREAD_LIBS])\nAC_SUBST([PTHREAD_CFLAGS])\nAC_SUBST([PTHREAD_CC])\n\n# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:\nif test x\"$acx_pthread_ok\" = xyes; then\n        ifelse([$1],,AC_DEFINE([HAVE_PTHREAD],1,[Define if you have POSIX threads libraries and header files.]),[$1])\n        :\nelse\n        acx_pthread_ok=no\n        $2\nfi\nAC_LANG_RESTORE\n])dnl ACX_PTHREAD\n\n\n"
  },
  {
    "path": "plugindev/m4/opensmile.m4",
    "content": "\nAC_DEFUN([CHECK_HAVE_OPENSMILELIB], [\n\n# Ask user for path to libmysqlclient stuff:.\nAC_ARG_WITH(opensmilelib,\n    [ --with-opensmilelib=<path> prefix of opensmile build directory. e.g. /home/myname/opensmile],\n    [OPENSMILELIB_PREFIX=$with_opensmilelib],\n    AC_MSG_ERROR([You must call configure with the --with-opensmilelib option.\n    This tells configure where to find the opensmilelib library and headers necessary for building the plugin.])\n)\n\nAC_SUBST(OPENSMILELIB_PREFIX)\nOPENSMILELIB_LIBS=\"-L${OPENSMILELIB_PREFIX}/.libs -lopensmile\"\nOPENSMILELIB_CFLAGS=\"-I${OPENSMILELIB_PREFIX}/src\"\nAC_SUBST(OPENSMILELIB_LIBS)\nAC_SUBST(OPENSMILELIB_CFLAGS)\n\n\n]);\n\n"
  },
  {
    "path": "plugindev/plug_exampleSink.cpp",
    "content": "/*F***************************************************************************\r\n * \r\n * openSMILE - the Munich open source Multimedia Interpretation by \r\n * Large-scale Extraction toolkit\r\n * \r\n * This file is part of openSMILE.\r\n * \r\n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\r\n * \r\n * See file \"COPYING\" for details on usage rights and licensing terms.\r\n * By using, copying, editing, compiling, modifying, reading, etc. this\r\n * file, you agree to the licensing terms in the file COPYING.\r\n * If you do not agree to the licensing terms,\r\n * you must immediately destroy all copies of this file.\r\n * \r\n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\r\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\r\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\r\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\r\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\r\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\r\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\r\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\r\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\r\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\r\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\r\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\r\n * THE SOFTWARE OR DERIVATIVE WORKS.\r\n * \r\n * Main authors: Florian Eyben, Felix Weninger, \r\n *            Martin Woellmer, Bjoern Schuller\r\n * \r\n * Copyright (c) 2008-2013, \r\n *   Institute for Human-Machine Communication,\r\n *   Technische Universitaet Muenchen, Germany\r\n * \r\n * Copyright (c) 2013-2015, \r\n *   audEERING UG (haftungsbeschraenkt),\r\n *   Gilching, Germany\r\n * \r\n * Copyright (c) 2016,   \r\n *   audEERING GmbH,\r\n *   Gilching Germany\r\n ***************************************************************************E*/\r\n\r\n\r\n/*  openSMILE component:\r\n\r\nexample dataSink\r\nwrites data to data memory...\r\n\r\n*/\r\n\r\n\r\n#include <plug_exampleSink.hpp>\r\n\r\n#define MODULE \"cExampleSinkPlugin\"\r\n\r\n\r\nSMILECOMPONENT_STATICS(cExampleSinkPlugin)\r\n\r\nSMILECOMPONENT_REGCOMP(cExampleSinkPlugin)\r\n{\r\n  SMILECOMPONENT_REGCOMP_INIT\r\n  scname = COMPONENT_NAME_CEXAMPLESINK;\r\n  sdescription = COMPONENT_DESCRIPTION_CEXAMPLESINK;\r\n\r\n  // we inherit cDataSink configType and extend it:\r\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSink\")\r\n  \r\n  SMILECOMPONENT_IFNOTREGAGAIN(\r\n    ct->setField(\"filename\",\"file to dump values to\",\"dump.txt\");\r\n    ct->setField(\"lag\",\"output data <lag> frames behind\",0);\r\n  )\r\n  SMILECOMPONENT_MAKEINFO(cExampleSinkPlugin);\r\n}\r\n\r\nSMILECOMPONENT_CREATE(cExampleSinkPlugin)\r\n\r\n//-----\r\n\r\ncExampleSinkPlugin::cExampleSinkPlugin(const char *_name) :\r\n  cDataSink(_name)\r\n{\r\n  // ...\r\nprintf(\"I'm here...\\n\");\r\n}\r\n\r\nvoid cExampleSinkPlugin::fetchConfig()\r\n{\r\n  cDataSink::fetchConfig();\r\nprintf(\"I'm here in fetchConfig...\\n\");\r\n  \r\n  filename = getStr(\"filename\");\r\nprintf(\"filename=%s\\n\",filename);\r\nprintf(\"log=%i\\n\",(long)&smileLog);\r\nsmileLog.message(FMT(\"test\"), 2, \"cYEAH\");\r\n\r\n  SMILE_DBG(2,\"filename = '%s'\",filename);\r\n  lag = getInt(\"lag\");\r\n  SMILE_DBG(2,\"lag = %i\",lag);\r\n}\r\n\r\n/*\r\nint cExampleSink::myConfigureInstance()\r\n{\r\n  int ret=1;\r\n  ret *= cDataSink::myConfigureInstance();\r\n  // ....\r\n  //return ret;\r\n}\r\n*/\r\n\r\n/*\r\nint cExampleSink::myFinaliseInstance()\r\n{\r\n  int ret=1;\r\n  ret *= cDataSink::myFinaliseInstance();\r\n  // ....\r\n  //return ret;\r\n}\r\n*/\r\n\r\nint cExampleSinkPlugin::myTick(long long t)\r\n{\r\n  SMILE_DBG(4,\"tick # %i, reading value vector:\",t);\r\n  cVector *vec= reader->getFrameRel(lag);  //new cVector(nValues+1);\r\n  if (vec == NULL) return 0;\r\n  else reader->nextFrame();\r\n\r\n  long vi = vec->tmeta->vIdx;\r\n  double tm = vec->tmeta->time;\r\n  \r\n  // now print the vector:\r\n  SMILE_IMSG(2,\"FUCKING AWSOME PLUGIN OUTPUT:\");\r\n  int i;\r\n  for (i=0; i<vec->N; i++) {\r\n    printf(\"  (a=%i vi=%i, tm=%fs) %s.%s = %f\\n\",reader->getCurR(),vi,tm,reader->getLevelName(),vec->name(i),vec->dataF[i]);\r\n  }\r\n\r\n// SMILE_PRINT(\"%i\",var1,)\r\n\r\n\r\n  // tick success\r\n  return 1;\r\n}\r\n\r\n\r\ncExampleSinkPlugin::~cExampleSinkPlugin()\r\n{\r\n  // ...\r\n}\r\n\r\n"
  },
  {
    "path": "plugindev/plug_exampleSink.hpp",
    "content": "/*F***************************************************************************\r\n * \r\n * openSMILE - the Munich open source Multimedia Interpretation by \r\n * Large-scale Extraction toolkit\r\n * \r\n * This file is part of openSMILE.\r\n * \r\n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\r\n * \r\n * See file \"COPYING\" for details on usage rights and licensing terms.\r\n * By using, copying, editing, compiling, modifying, reading, etc. this\r\n * file, you agree to the licensing terms in the file COPYING.\r\n * If you do not agree to the licensing terms,\r\n * you must immediately destroy all copies of this file.\r\n * \r\n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\r\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\r\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\r\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\r\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\r\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\r\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\r\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\r\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\r\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\r\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\r\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\r\n * THE SOFTWARE OR DERIVATIVE WORKS.\r\n * \r\n * Main authors: Florian Eyben, Felix Weninger, \r\n *            Martin Woellmer, Bjoern Schuller\r\n * \r\n * Copyright (c) 2008-2013, \r\n *   Institute for Human-Machine Communication,\r\n *   Technische Universitaet Muenchen, Germany\r\n * \r\n * Copyright (c) 2013-2015, \r\n *   audEERING UG (haftungsbeschraenkt),\r\n *   Gilching, Germany\r\n * \r\n * Copyright (c) 2016,   \r\n *   audEERING GmbH,\r\n *   Gilching Germany\r\n ***************************************************************************E*/\r\n\r\n\r\n/*  openSMILE component:\r\n\r\nexample plugin: data sink example\r\n\r\n*/\r\n\r\n\r\n#ifndef __EXAMPLE_SINK_HPP\r\n#define __EXAMPLE_SINK_HPP\r\n\r\n#include <smileCommon.hpp>\r\n#include <smileComponent.hpp>\r\n#include <dataSink.hpp>\r\n\r\n#define COMPONENT_DESCRIPTION_CEXAMPLESINK \"dataSink example, read data and prints it to screen\"\r\n#define COMPONENT_NAME_CEXAMPLESINK \"cExampleSinkPlugin\"\r\n\r\n// add this for plugins to compile properly in MSVC++\r\n#ifdef SMILEPLUGIN\r\n#ifdef class\r\n#undef class\r\n#endif\r\n#endif\r\n\r\nclass cExampleSinkPlugin : public cDataSink {\r\n  private:\r\n/*    static cConfigManager *sconfman;\r\n    static const char *cname;  // name of component object type\r\n    static const char *description;*/\r\n\r\n    const char *filename;\r\n    int lag;\r\n    \r\n  protected:\r\n    SMILECOMPONENT_STATIC_DECL_PR\r\n    \r\n    virtual void fetchConfig();\r\n    //virtual int myConfigureInstance();\r\n    //virtual int myFinaliseInstance();\r\n    virtual int myTick(long long t);\r\n\r\n\r\n  public:\r\n    //static sComponentInfo * registerComponent(cConfigManager *_confman);\r\n    //static cSmileComponent * create(const char *_instname);\r\n    SMILECOMPONENT_STATIC_DECL\r\n    \r\n    cExampleSinkPlugin(const char *_name);\r\n\r\n    virtual ~cExampleSinkPlugin();\r\n};\r\n\r\n\r\n\r\n\r\n#endif // __EXAMPLE_SINK_HPP\r\n"
  },
  {
    "path": "plugindev/pluginGuiMain.cpp",
    "content": "/*F***************************************************************************\r\n * \r\n * openSMILE - the Munich open source Multimedia Interpretation by \r\n * Large-scale Extraction toolkit\r\n * \r\n * This file is part of openSMILE.\r\n * \r\n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\r\n * \r\n * See file \"COPYING\" for details on usage rights and licensing terms.\r\n * By using, copying, editing, compiling, modifying, reading, etc. this\r\n * file, you agree to the licensing terms in the file COPYING.\r\n * If you do not agree to the licensing terms,\r\n * you must immediately destroy all copies of this file.\r\n * \r\n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\r\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\r\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\r\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\r\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\r\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\r\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\r\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\r\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\r\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\r\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\r\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\r\n * THE SOFTWARE OR DERIVATIVE WORKS.\r\n * \r\n * Main authors: Florian Eyben, Felix Weninger, \r\n *            Martin Woellmer, Bjoern Schuller\r\n * \r\n * Copyright (c) 2008-2013, \r\n *   Institute for Human-Machine Communication,\r\n *   Technische Universitaet Muenchen, Germany\r\n * \r\n * Copyright (c) 2013-2015, \r\n *   audEERING UG (haftungsbeschraenkt),\r\n *   Gilching, Germany\r\n * \r\n * Copyright (c) 2016,   \r\n *   audEERING GmbH,\r\n *   Gilching Germany\r\n ***************************************************************************E*/\r\n\r\n/* openSMILE plugin loader */\r\n\r\n#include <smileCommon.hpp>\r\n#include <smileLogger.hpp>\r\n#include <componentManager.hpp>\r\n\r\n\r\n//++ include all your component headers here: ----------------\r\n#include <exampleGuipluginSink.hpp>\r\n#include <simpleVisualiserGUI.hpp>\r\n#include <classifierResultGUI.hpp>\r\n\r\n//++ ---------------------------------------------------------\r\n\r\n// dll export for msvc++\r\n#ifdef _MSC_VER \r\n#define DLLEXPORT_P __declspec(dllexport)\r\n#else\r\n#define DLLEXPORT_P\r\n#endif\r\n\r\n\r\n#define MODULE \"pluginLoader\"\r\n\r\nstatic DLLLOCAL const registerFunction complist[] = {\r\n//++ add your component register functions here: -------------\r\n  cExampleGuipluginSink::registerComponent,\r\n  cSimpleVisualiserGUI::registerComponent,\r\n  cClassifierResultGUI::registerComponent,\r\n\r\n//++ ---------------------------------------------------------\r\n  NULL  // last element must always be NULL to terminate the list !!\r\n};\r\n\r\nsComponentInfo *master=NULL;\r\n\r\n//Library:\r\nextern \"C\" DLLEXPORT_P sComponentInfo * registerPluginComponent(cConfigManager *_confman, cComponentManager *_compman) {\r\n  registerFunction f;\r\n  sComponentInfo *cur = NULL, *last = NULL;\r\n  int i=0;\r\n  f = complist[i];\r\n  while (f!=NULL) {\r\n    cur = (f)(_confman, _compman);\r\n    cur->next = NULL;\r\n    if (i==0) master = cur;\r\n    else { last->next = cur; }\r\n    last = cur;\r\n    f=complist[++i];\r\n  }\r\n  return master;\r\n}\r\n\r\n/*extern \"C\" DLLEXPORT_P sComponentInfo * registerPluginComponent(cConfigManager *_confman, cComponentManager *_compman) {\r\n  return (sComponentInfo *)complist;\r\n}*/\r\n\r\n\r\n// this function frees all memory allocated within the scope of the dll ...\r\nextern \"C\" DLLEXPORT_P void unRegisterPluginComponent() {\r\n  while (master != NULL) {\r\n    sComponentInfo *tmp = master;\r\n    if (master->next != NULL) master = master->next;\r\n    delete tmp;\r\n  }\r\n}\r\n"
  },
  {
    "path": "plugindev/pluginMain.cpp",
    "content": "/*F***************************************************************************\r\n * \r\n * openSMILE - the Munich open source Multimedia Interpretation by \r\n * Large-scale Extraction toolkit\r\n * \r\n * This file is part of openSMILE.\r\n * \r\n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\r\n * \r\n * See file \"COPYING\" for details on usage rights and licensing terms.\r\n * By using, copying, editing, compiling, modifying, reading, etc. this\r\n * file, you agree to the licensing terms in the file COPYING.\r\n * If you do not agree to the licensing terms,\r\n * you must immediately destroy all copies of this file.\r\n * \r\n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\r\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\r\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\r\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\r\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\r\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\r\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\r\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\r\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\r\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\r\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\r\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\r\n * THE SOFTWARE OR DERIVATIVE WORKS.\r\n * \r\n * Main authors: Florian Eyben, Felix Weninger, \r\n *            Martin Woellmer, Bjoern Schuller\r\n * \r\n * Copyright (c) 2008-2013, \r\n *   Institute for Human-Machine Communication,\r\n *   Technische Universitaet Muenchen, Germany\r\n * \r\n * Copyright (c) 2013-2015, \r\n *   audEERING UG (haftungsbeschraenkt),\r\n *   Gilching, Germany\r\n * \r\n * Copyright (c) 2016,   \r\n *   audEERING GmbH,\r\n *   Gilching Germany\r\n ***************************************************************************E*/\r\n\r\n/* openSMILE plugin loader */\r\n\r\n#include <smileCommon.hpp>\r\n#include <smileLogger.hpp>\r\n#include <componentManager.hpp>\r\n\r\n\r\n//++ include all your component headers here: ----------------\r\n#include <plug_exampleSink.hpp>\r\n\r\n\r\n//++ ---------------------------------------------------------\r\n\r\n// dll export for msvc++\r\n#ifdef _MSC_VER \r\n#define DLLEXPORT_P __declspec(dllexport)\r\n#else\r\n#define DLLEXPORT_P\r\n#endif\r\n\r\n\r\n#define MODULE \"pluginLoader\"\r\n\r\nstatic DLLLOCAL const registerFunction complist[] = {\r\n//++ add your component register functions here: -------------\r\n  cExampleSinkPlugin::registerComponent,\r\n\r\n\r\n//++ ---------------------------------------------------------\r\n  NULL  // last element must always be NULL to terminate the list !!\r\n};\r\n\r\n//Library:\r\nextern \"C\" DLLEXPORT_P sComponentInfo * registerPluginComponent(cConfigManager *_confman, cComponentManager *_compman) {\r\n  registerFunction f;\r\n  sComponentInfo *master=NULL;\r\n  sComponentInfo *cur = NULL, *last = NULL;\r\n  int i=0;\r\n  f = complist[i];\r\n  while (f!=NULL) {\r\n    cur = (f)(_confman, _compman);\r\n\tcur->next = NULL;\r\n    if (i==0) master = cur;\r\n    else { last->next = cur; }\r\n    last = cur;\r\n    f=complist[++i];\r\n  }\r\n  return master;\r\n}\r\n\r\n\r\n\r\n"
  },
  {
    "path": "plugindev/simpleVisualiserGUI.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample dataSink:\nreads data from data memory and outputs it to console/logfile (via smileLogger)\nthis component is also useful for debugging\n\n*/\n\n\n#include <simpleVisualiserGUI.hpp>\n\n#define MODULE \"cSimpleVisualiserGUI\"\n\n\nSMILECOMPONENT_STATICS(cSimpleVisualiserGUI)\n\nSMILECOMPONENT_REGCOMP(cSimpleVisualiserGUI)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CSIMPLEVISUALISERGUI;\n  sdescription = COMPONENT_DESCRIPTION_CSIMPLEVISUALISERGUI;\n\n  // we inherit cDataSink configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSink\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    //ct->setField(\"filename\",\"The name of a text file to dump values to (this file will be overwritten, if it exists)\",(const char *)NULL);\n    //ct->setField(\"lag\",\"Output data <lag> frames behind\",0,0,0);\n    ct->setField(\"action\",\"type of visualisation action to perform: moving2dplot, movingMatplot\",\"moving2dplot\");\n    ct->setField(\"inputs\",\"array that selects the inputs to plot (by name!) (see inputsIdx for listing them by index in the input vector)\",(const char*)NULL,ARRAY_TYPE);\n    ct->setField(\"inputsIdx\",\"array that selects the inputs to plot by index in the input vector\",0,ARRAY_TYPE);\n    ct->setField(\"fullVectorAsInput\",\"don't select individual elements, use full input vector for plotting (this is especially useful for matrix plots)\",0);\n    ct->setField(\"inputScale\",\"scale factor for each input element\",1.0,ARRAY_TYPE);\n    ct->setField(\"inputscaleFullinput\",\"scale factor for all fields when fullVectorAsInput=1.\",1.0);\n    ct->setField(\"inputoffsetFullinput\",\"additive offset for all fields when fullVectorAsInput=1.\",0.0);\n    ct->setField(\"inputOffset\",\"additive offset for each input element (the offset is applied before the scaling:  y=(x+offset)*scale \",0.0,ARRAY_TYPE);\n    ct->setField(\"inputColours\",\"array that configures the plot colours for each input element.\",(const char*)NULL,ARRAY_TYPE);\n    ct->setField(\"matMultiplier\",\"number of times to repeat each line in a mat-plot, use this to zoom in on the y axis\",1);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cSimpleVisualiserGUI);\n}\n\n\n//SMILECOMPONENT_CREATE(cSimpleVisualiserGUI)\ncSmileComponent * cSimpleVisualiserGUI::create(const char*_instname) { \n  cSmileComponent *c = new cSimpleVisualiserGUI(_instname); \n  if (c!=NULL) c->setComponentInfo(sconfman,COMPONENT_NAME_CSIMPLEVISUALISERGUI,COMPONENT_DESCRIPTION_CSIMPLEVISUALISERGUI); \n  return c; \n}\n\n//--- wx ---\n\n\n\n\nwxRtplotPanel::wxRtplotPanel(wxFrame* parent) :\nwxPanel(parent),\nlastT(0),curT(0),\n//curval(0),lastval(0)\npaintEventCur(NULL),paintEventLast(NULL)\n{\n    \n}\n \n/*\n * Called by the system of by wxWidgets when the panel needs\n * to be redrawn. You can also trigger this call by\n * calling Refresh()/Update().\n */\n \nvoid wxRtplotPanel::paintEvent(wxPaintEvent & evt)\n{\n    // depending on your system you may need to look at double-buffered dcs\n    wxPaintDC dc(this);\n    render(dc);\n}\n \n/*\n * Alternatively, you can use a clientDC to paint on the panel\n * at any time. Using this generally does not free you from\n * catching paint events, since it is possible that e.g. the window\n * manager throws away your drawing when the window comes to the\n * background, and expects you will redraw it when the window comes\n * back (by sending a paint event).\n */\nvoid wxRtplotPanel::paintNow()\n{\n    // depending on your system you may need to look at double-buffered dcs\n    wxClientDC dc(this);\n    render(dc);\n}\n \n/*\n * Here we do the actual rendering. I put it in a separate\n * method so that it can work no matter what type of DC\n * (e.g. wxPaintDC or wxClientDC) is used.\n */\nvoid wxRtplotPanel::render(wxDC&  dc)\n{\n  smileMutexLock(wxMtx);\n  int action;\n  if (showImg && paintEventCur != NULL) {\n    action = paintEventCur->action;\n  } else {\n    return;\n  }\n  smileMutexUnlock(wxMtx);\n  switch (action) {\n    case VIS_ACT_MOVINGMATPLOT:\n      renderMovingMatPlot(dc);\n      break;\n    case VIS_ACT_MOVING2DPLOT:\n    default:\n      renderMoving2dPlot(dc);\n  }\n}\n  \nvoid wxRtplotPanel::renderMoving2dPlot(wxDC&  dc)\n{\n  smileMutexLock(wxMtx);\n\n  if (showImg && paintEventCur != NULL) {\n\n    ////// draw the plot from the plot data\n   if (curT == 0) dc.Clear();\n\n   int coord0x = 50;\n   int coord0y = 350;\n   int coordWidth = 600;\n   int coordHeight = 300;\n\n   // background\n   dc.FloodFill(1,1,wxColour(\"white\"),wxFLOOD_BORDER);\n\n    // axes\n    dc.DrawLine(coord0x,coord0y-coordHeight,coord0x,coord0y+10);\n    dc.DrawLine(coord0x-10,coord0y,coord0x+coordWidth+20,coord0y);\n      // axes arrows\n    dc.DrawLine(coord0x,coord0y-coordHeight,coord0x+10,coord0y-coordHeight+10);\n    dc.DrawLine(coord0x,coord0y-coordHeight,coord0x-10,coord0y-coordHeight+10);\n    if (paintEventCur->names != NULL && paintEventCur->names[0] != NULL) {\n      dc.DrawText(paintEventCur->names[0],coord0x-20,coord0y-coordHeight-30);\n    } else {\n      dc.DrawText(\"value\",coord0x-20,coord0y-coordHeight-30);\n    }\n    dc.DrawLine(coord0x+coordWidth+20,coord0y,coord0x+coordWidth+10,coord0y-10);\n    dc.DrawLine(coord0x+coordWidth+20,coord0y,coord0x+coordWidth+10,coord0y+10);\n    dc.DrawText(\"t / sec.\",coord0x+coordWidth+15,coord0y+20);\n      \n    // axes ticks\n    int i;\n    for (i=0; i<=(coordWidth / 100); i++) { // t axis\n      dc.DrawLine(coord0x+i*100,coord0y-5,coord0x+i*100,coord0y+5);\n      char * x = myvprint(\"%i\",i);\n      if (x!=NULL) {\n        dc.DrawText(x,coord0x+i*100-5,coord0y+20);\n        free(x);\n      }\n    }\n    for (i=0; i<(coordHeight / 100); i++) { // y axis\n      dc.DrawLine(coord0x-5,coord0y-i*100,coord0x+5,coord0y-i*100);\n      \n      FLOAT_DMEM tv = (FLOAT_DMEM)i*paintEventCur->scale0 + paintEventCur->offset0;\n      char * x;\n      if ((tv < 1.0)&&(tv>-1.0)) {\n        if (tv == 0.0) x = myvprint(\"0.0\");\n        else x = myvprint(\"%.3f\",tv);\n      } else {\n        if ((tv < 100.0)&&(tv >-100.0)) {\n          x = myvprint(\"%.2f\",tv);\n        } else {\n          x = myvprint(\"%i\",(int)tv);\n        }\n      }\n      if (x!=NULL) {\n        dc.DrawText(x,5,coord0y-i*100);\n        free(x);\n      }\n      \n    }\n\n    // TODO: save the axes and background as bitmap, and only plot bitmap\n\n\n    // data curve(s)\n    //int  i;\n    for (i=0; i<paintEventCur->nVals; i++) {\n      int lastval = 0;\n\n      if (paintEventLast != NULL && paintEventLast->val != NULL) {\n        if (i<paintEventLast->nVals)\n          lastval = paintEventLast->val[i];\n      }\n      if (paintEventCur->colours != NULL && paintEventCur->colours[i] != NULL) {\n        // there is some kind of bug here... either wrong indicies, or uncaught exceptions\n        dc.SetPen(wxPen(wxColour(paintEventCur->colours[i]),2));\n      } else {\n        dc.SetPen(wxPen(wxColour(\"blue\"),2));\n      }\n      if (curT != 0) {\n        dc.DrawLine(coord0x+lastT,coord0y-lastval,coord0x+curT,coord0y-(paintEventCur->val[i]));\n      }\n  \n    }\n\n    if (paintEventLast != NULL) { delete paintEventLast; }\n    paintEventLast = paintEventCur;\n\n    lastT = curT;\n    curT = (curT+1)%coordWidth;\n    \n    // TODO: save plot as bitmap for OnPaint event\n\n  // wxBitmap b = dc.GetAsBitmap();\n\n\n  } else {\n    dc.Clear();\n  }\n\n  smileMutexUnlock(wxMtx);\n}\n\n\nvoid wxRtplotPanel::renderMovingMatPlot(wxDC&  dc)\n{\n  smileMutexLock(wxMtx);\n\n  if (showImg && paintEventCur != NULL) {\n\n    ////// draw the plot from the plot data\n   if (curT == 0) dc.Clear();\n\n   int coord0x = 50;\n   int coord0y = 350;\n   int coordWidth = 600;\n   int coordHeight = 300;\n\n   // background\n   dc.FloodFill(1,1,wxColour(\"white\"),wxFLOOD_BORDER);\n\n    // axes\n    dc.DrawLine(coord0x,coord0y-coordHeight,coord0x,coord0y+10);\n    dc.DrawLine(coord0x-10,coord0y,coord0x+coordWidth+20,coord0y);\n      // axes arrows\n    dc.DrawLine(coord0x,coord0y-coordHeight,coord0x+10,coord0y-coordHeight+10);\n    dc.DrawLine(coord0x,coord0y-coordHeight,coord0x-10,coord0y-coordHeight+10);\n    if (paintEventCur->names != NULL && paintEventCur->names[0] != NULL) {\n      dc.DrawText(paintEventCur->names[0],coord0x-20,coord0y-coordHeight-30);\n    } else {\n      dc.DrawText(\"value\",coord0x-20,coord0y-coordHeight-30);\n    }\n    dc.DrawLine(coord0x+coordWidth+20,coord0y,coord0x+coordWidth+10,coord0y-10);\n    dc.DrawLine(coord0x+coordWidth+20,coord0y,coord0x+coordWidth+10,coord0y+10);\n    dc.DrawText(\"t / sec.\",coord0x+coordWidth+15,coord0y+20);\n      \n    // axes ticks\n    int i;\n    for (i=0; i<=(coordWidth / 100); i++) { // t axis\n      dc.DrawLine(coord0x+i*100,coord0y-5,coord0x+i*100,coord0y+5);\n      char * x = myvprint(\"%i\",i);\n      if (x!=NULL) {\n        dc.DrawText(x,coord0x+i*100-5,coord0y+20);\n        free(x);\n      }\n    }\n    for (i=0; i<(coordHeight / 100); i++) { // y axis\n      dc.DrawLine(coord0x-5,coord0y-i*100,coord0x+5,coord0y-i*100);\n      \n      FLOAT_DMEM tv = (FLOAT_DMEM)i*paintEventCur->scale0 + paintEventCur->offset0;\n      char * x;\n      if ((tv < 1.0)&&(tv>-1.0)) {\n        if (tv == 0.0) x = myvprint(\"0.0\");\n        else x = myvprint(\"%.3f\",tv);\n      } else {\n        if ((tv < 100.0)&&(tv >-100.0)) {\n          x = myvprint(\"%.2f\",tv);\n        } else {\n          x = myvprint(\"%i\",(int)tv);\n        }\n      }\n      if (x!=NULL) {\n        dc.DrawText(x,5,coord0y-i*100);\n        free(x);\n      }\n      \n    }\n\n    // TODO: save the axes and background as bitmap, and only plot bitmap\n\n    int mu = paintEventCur->matMultiplier;\n\n    // data curve(s)\n    //int  i;\n    for (i=0; i<MIN(paintEventCur->nVals,coordHeight); i++) {\n      int v = paintEventCur->val[i];\n      if (v > 255) v = 255; \n      if (v < 0) v = 0;\n      dc.SetPen(wxPen(wxColour(v,v,v)));      \n      if (curT != 0) {\n        if (mu > 1) {\n          dc.DrawLine(coord0x+curT,coord0y-i*mu-1 , coord0x+curT,coord0y-(i+1)*mu-2 );\n        } else {\n          dc.DrawPoint(coord0x+curT,coord0y-i-1);\n        }\n      }\n    }\n\n    if (paintEventLast != NULL) { delete paintEventLast; }\n    paintEventLast = paintEventCur;\n\n    lastT = curT;\n    curT = (curT+1)%coordWidth;\n    \n    // TODO: save plot as bitmap for OnPaint event\n\n  // wxBitmap b = dc.GetAsBitmap();\n\n\n  } else {\n    dc.Clear();\n  }\n\n  smileMutexUnlock(wxMtx);\n}\n\nenum\r\n{\r\n    ID_Quit = 1,\r\n    ID_About,\r\n};\r\n\n// catch the event from the thread\nBEGIN_EVENT_TABLE(visFrame, wxFrame)\nEVT_COMMAND  (PLOT_UPDATE_ID, wxEVT_COMMAND_TEXT_UPDATED, visFrame::onPlotUpdate)\nEND_EVENT_TABLE()\n\n\nBEGIN_EVENT_TABLE(wxRtplotPanel, wxPanel)\n// catch paint events\nEVT_PAINT(wxRtplotPanel::paintEvent)\nEND_EVENT_TABLE()\n\n\nconst int ID_CHECKBOX = 100;\n\n\nbool visApp::OnInit()\n{\n    // make sure to call this first\n    //wxInitAllImageHandlers();\n    vframe = new visFrame( _(\"TUM openSMILE visualiser demo window\"), wxPoint(50, 50), wxSize(750, 440), wxMtx );\n    //vframe->yscale100 = yscale100;\n    vframe->Show(true);\n    SetTopWindow(vframe);\n    return true;\n}\n\nvisFrame::visFrame(const wxString& title, const wxPoint& pos, const wxSize& size, smileMutex _wxMtx)\n       : wxFrame(NULL, wxID_ANY, title, pos, size)\n{\n\n    drawPane = new wxRtplotPanel( this );\n    drawPane->wxMtx = _wxMtx;\n    wxMtx = _wxMtx;\n\n    CreateStatusBar();\n    SetStatusText( _(\"openSMILE visualiser GUI.\") );\n}\n\nvoid visFrame::OnQuit(wxCommandEvent& WXUNUSED(event))\n{\n    Close(true);\n}\n\n//IMPLEMENT_APP(MyApp)\n\n\n\n\n\n//-----\n\ncSimpleVisualiserGUI::cSimpleVisualiserGUI(const char *_name) :\n  cDataSink(_name),\n  inputsIdx(NULL), nInputs(0),\n  inputScale(NULL), inputOffset(NULL),\n  inputNames(NULL), inputColours(NULL),\n  pApp(NULL), terminate(0)\n{\n  // ...\n}\n\nvoid cSimpleVisualiserGUI::fetchConfig()\n{\n  cDataSink::fetchConfig();\n  /*\n  ct->setField(\"action\",\"type of visualisation action to perform\",\"movingplot\");\n    ct->setField(\"inputs\",\"array that selects the inputs to plot (by name!) (see inputsIdx for listing them by index in the input vector)\",(const char*)NULL,ARRAY_TYPE);\n    ct->setField(\"inputsIdx\",\"array \n    */\n  const char * actStr = getStr(\"action\");\n  if (!strncmp(actStr,\"moving2dplot\",12)) {\n    action = VIS_ACT_MOVING2DPLOT;\n  } else if (!strncmp(actStr,\"movingMatplot\",13)) {\n    action = VIS_ACT_MOVINGMATPLOT;\n  } else { // default action:\n    action = VIS_ACT_MOVING2DPLOT;\n  }\n\n  fullinput = getInt(\"fullVectorAsInput\");\n\n  if (!fullinput) {\n    int i;\n    nInputs = getArraySize(\"inputs\");\n    if (nInputs <= 0 ) {\n      nInputs = getArraySize(\"inputsIdx\");\n      if (nInputs <= 0) {\n        SMILE_IERR(1,\"either 'inputs' or 'inputsIdx' with at least one element must be set in the config to configure at least on element in the input vector to plot\");\n        COMP_ERR(\"aborting.\");\n      }\n      // read indicies  directly from inputsIdx\n      inputsIdx = new int[nInputs];\n      for (i=0; i<nInputs; i++) {\n        inputsIdx[i] = getInt_f(myvprint(\"inputsIdx[%i]\",i));\n      }\n    } else {\n      // read strings and translate to indicies\n      // ... this needs to be done in myFinaliseInstance\n    }\n  }\n\n  if (nInputs > 0) {\n    inputScale = new FLOAT_DMEM[nInputs];\n    inputOffset = new FLOAT_DMEM[nInputs];\n    inputColours = (const char **)calloc(1,sizeof(const char *)*nInputs);\n    int i;\n    for (i=0; i<nInputs; i++) {\n      inputScale[i] = (FLOAT_DMEM)getDouble_f(myvprint(\"inputScale[%i]\",i));\n      inputOffset[i] = (FLOAT_DMEM)getDouble_f(myvprint(\"inputOffset[%i]\",i));\n      inputColours[i] = getStr_f(myvprint(\"inputColours[%i]\",i));\n    }\n  }\n\n  matMultiplier=getInt(\"matMultiplier\");\n}\n\n\n/*\nint cSimpleVisualiserGUI::myConfigureInstance()\n{\n  return  cDataSink::myConfigureInstance();\n  \n}\n*/\n\n\nSMILE_THREAD_RETVAL wxVisAppThreadRunner(void *_data)\n{\n  if (_data != NULL) {\n    cSimpleVisualiserGUI *obj = (cSimpleVisualiserGUI*)_data;\n    smileMutexLock(obj->wxMtx);\n    obj->pApp = new visApp(); \n    obj->pApp->wxMtx = obj->wxMtx;\n    //obj->pApp->yscale100 = obj->yscale100;\n    wxApp::SetInstance(obj->pApp);\n    // we need a mutex / flag here, to notify the main app that our wxApp was created!\n    smileMutexUnlock(obj->wxMtx);\n    wxEntry(0, NULL);\n    smileMutexLock(obj->wxMtx);\n    //delete (obj->pApp);\n    obj->pApp = NULL;\n    obj->terminate = 1;\n    printf(\"wxwin terminate.\\n\");\n    smileMutexUnlock(obj->wxMtx);\n  }\n  SMILE_THREAD_RET;\n}\n\n\n// TODO: use dataProcessor::findElement, once it is comitted to the openSMILE trunk\nint cSimpleVisualiserGUI::getElidxFromName(const char *_name) \n{\n  const FrameMetaInfo * fmeta = reader->getFrameMetaInfo();\n  int ri;\n  long elIdx=-1;\n  long idx = fmeta->findFieldByPartialName( _name , &ri, NULL );\n  if (idx < 0) {\n    SMILE_IWRN(2,\"Requested input element '*%s*' not found, check your config!\",_name);\n  } else {\n    elIdx = fmeta->fieldToElementIdx( idx ) + ri;\n  }\n  return elIdx;\n}\n\nint cSimpleVisualiserGUI::myFinaliseInstance()\n{\n  // FIRST call cDataSink myFinaliseInstance, this will finalise our dataWriter...\n  int ret = cDataSink::myFinaliseInstance();\n\n  int i;\n  if (ret && fullinput) {\n    nInputs = reader->getLevelN();\n    if (nInputs > 0) {\n      inputNames = (const char**)calloc(1,sizeof(const char *)*nInputs);\n      inputScale = new FLOAT_DMEM[nInputs];\n      inputOffset = new FLOAT_DMEM[nInputs];\n      inputsIdx = new int[nInputs];\n      FLOAT_DMEM scaleAll = getDouble(\"inputscaleFullinput\");\n      FLOAT_DMEM offsetAll = getDouble(\"inputoffsetFullinput\");\n      for (i=0; i<nInputs; i++) {\n        inputsIdx[i] = i;\n        inputNames[i] = reader->getElementName(inputsIdx[i]);\n        inputScale[i] = scaleAll;\n        inputOffset[i] = offsetAll;\n      }\n    }\n  } else\n  if (ret && nInputs > 0 ) {\n    inputNames = (const char**)calloc(1,sizeof(const char *)*nInputs);\n    if (inputsIdx == NULL) {\n\n      inputsIdx = new int[nInputs];\n      for (i=0; i<nInputs; i++) {\n        const char * tmp = getStr_f(myvprint(\"inputs[%i]\",i));\n        inputNames[i] = tmp; \n        if (tmp != NULL) {\n          long idx = getElidxFromName(tmp);\n          inputsIdx[i] = idx;\n        } else {\n          inputsIdx[i] = -1;\n        }\n      }\n\n    } else {\n      for (i=0; i<nInputs; i++) {\n        inputNames[i] = reader->getElementName(inputsIdx[i]);\n      }\n    }\n  }\n\n  smileMutexCreate(wxMtx);\n\n  //yscale100 = 100.0 / inputScale[0];\n\n  //fo = new openSmilePluginGUI::TestForm();\n  //IMPLEMENT_APP_NO_MAIN(appname)\n  if (!(int)smileThreadCreate(guiThr, wxVisAppThreadRunner, this)) {\n    SMILE_ERR(1,\"error creating GUI thread!!\");\n  }\n\n  return ret;\n}\n\n\nint cSimpleVisualiserGUI::myTick(long long t)\n{\n  SMILE_DBG(4,\"tick # %i, reading value vector:\",t);\n  cVector *vec = NULL;\n  if (!terminate) vec= reader->getNextFrame();  \n  if (vec == NULL) return 0;\n  //else reader->nextFrame();\n\n  long vi = vec->tmeta->vIdx;\n  double tm = vec->tmeta->time;\n\n  smileMutexLock(wxMtx);\n  if (pApp == NULL) {\n    smileMutexUnlock(wxMtx);\n    if (terminate) return 0;\n    else return 1;\n  }\n  smileMutexUnlock(wxMtx);\n\n  // update VA status in GUI....\n//  pApp->AddPendingEvent();\n// notify the main thread\n  \n  int nr = 0;\n  paintDataEvent *pe = new paintDataEvent(nInputs);\n\n  for (nr = 0; nr<nInputs; nr++) {\n\n    long idx = inputsIdx[nr];\n    FLOAT_DMEM data = 0.0;\n    if (idx >= 0) data = vec->dataF[idx];\n    pe->val[nr] = (int)((data+inputOffset[nr])*inputScale[nr]);\n\n  }\n  pe->scale0 = 100.0 / inputScale[0];\n  pe->offset0 = inputOffset[nr]*inputScale[0];\n  pe->names = inputNames;\n  pe->colours = inputColours;\n  pe->action = action;\n  pe->matMultiplier = matMultiplier;\n\n  //smileMutexLock(wxMtx);\n  wxCommandEvent myevent(wxEVT_COMMAND_TEXT_UPDATED, PLOT_UPDATE_ID);\n//  myevent.SetInt((int)((data+inputOffset[nr])*inputScale[nr]));  // pass some data along the event, a number in this case\n//  myevent.SetString(vec->fmeta->getName(idx)); // TODO: this name is not present when using inputsIdx in the config...\n  myevent.SetClientData(pe);\n  pApp->vframe->GetEventHandler()->AddPendingEvent( myevent );\n  //smileMutexUnlock(wxMtx);\n\n  // tick success\n  return 1;\n}\n\n\ncSimpleVisualiserGUI::~cSimpleVisualiserGUI()\n{\n  if (inputsIdx != NULL) {\n    delete[] inputsIdx;\n  }\n  if (inputScale != NULL) {\n    delete[] inputScale;\n  }\n  if (inputOffset != NULL) {\n    delete[] inputOffset;\n  }\n  if (inputColours != NULL) {\n    free(inputColours);\n  }\n  if (inputNames != NULL) {\n    free(inputNames);\n  }\n\n  // TODO: send event to make wxApp terminate\n  smileThreadJoin(guiThr);\n\n  smileMutexDestroy(wxMtx);\n\n}\n\n"
  },
  {
    "path": "plugindev/simpleVisualiserGUI.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample dataSink:\nreads data from data memory and outputs it to console/logfile (via smileLogger)\nthis component is also useful for debugging\n\n*/\n\n\n#ifndef __CSIMPLEVISUALISERGUI_HPP\n#define __CSIMPLEVISUALISERGUI_HPP\n\n#include <smileCommon.hpp>\n#include <dataSink.hpp>\n#include <wx/wx.h>\n\n#define COMPONENT_DESCRIPTION_CSIMPLEVISUALISERGUI \"This is an example of a cDataSink descendant. It reads data from the data memory and prints it to the console. This component is intended as a template for developers.\"\n#define COMPONENT_NAME_CSIMPLEVISUALISERGUI \"cSimpleVisualiserGUI\"\n\n#undef class\n\nclass paintDataEvent {\npublic:\n  paintDataEvent(int _nvals=1) : val(NULL) {\n    nVals = _nvals;\n    if (_nvals > 0) {\n      val = new int[_nvals];\n    }\n  }\n  ~paintDataEvent() { if (val != NULL) delete[] val;  }\n\n  int action; // type of plot\n  int matMultiplier;\n  int nVals;\n  int *val;\n  const char **colours;\n  const char **names;\n  FLOAT_DMEM scale0;\n  FLOAT_DMEM offset0;\n};\n\n\n\n#include <wx/sizer.h>\n \nclass wxRtplotPanel : public wxPanel\n    {\n        //wxBitmap image;\n        \n        \n    public:\n        paintDataEvent *paintEventCur;\n        paintDataEvent *paintEventLast;\n\n        bool showImg;\n        smileMutex wxMtx;\n        //int curval, lastval;\n        int curT, lastT;\n        //const  char * featureName;\n        //FLOAT_DMEM yscale100;\n\n        wxRtplotPanel(wxFrame* parent);\n        \n        void paintEvent(wxPaintEvent & evt);\n        void paintNow();\n        \n        void render(wxDC& dc);\n        void renderMoving2dPlot(wxDC& dc);\n        void renderMovingMatPlot(wxDC& dc);\n        \n        DECLARE_EVENT_TABLE()\n    };\n \n \n  \n\n\n// the ID we'll use to identify our event\nconst int PLOT_UPDATE_ID = 100001;\n\nclass visFrame: public wxFrame\n{\n  //wxBitmap bmp;\n  wxRtplotPanel * drawPane;   \n  wxCheckBox *m_cb;\n\npublic:\n    //FLOAT_DMEM yscale100;\n    smileMutex wxMtx;\n\n    visFrame(const wxString& title, const wxPoint& pos, const wxSize& size, smileMutex _wxMtx);\n\n    void OnQuit(wxCommandEvent& event);\n/*    void OnAbout(wxCommandEvent& event);*/\n\n    // this is called when the event from the thread is received\n    void onPlotUpdate(wxCommandEvent& evt)\n    {\n      //int val = evt.GetInt();\n\n      // update the plot data (cyclic buffer)\n\n      smileMutexLock(wxMtx);\n      // replot\n      drawPane->paintEventCur = (paintDataEvent *)evt.GetClientData();\n      smileMutexUnlock(wxMtx);\n\n/*\n      drawPane->yscale100 = yscale100;\n      drawPane->featureName = evt.GetString();\n      drawPane->curval = val;\n      */\n      drawPane->showImg = true;\n      drawPane->paintNow();\n\n      \n    }\n\n\n    \n\n    DECLARE_EVENT_TABLE()\n};\n\n\nclass visApp: public wxApp\n{\n  virtual bool OnInit();\npublic:\n  //FLOAT_DMEM yscale100;\n  smileMutex wxMtx;\n\n  visFrame * vframe;\n  \n};\n\n#define VIS_ACT_MOVING2DPLOT 1\n#define VIS_ACT_MOVINGMATPLOT 2\n\nclass cSimpleVisualiserGUI : public cDataSink {\n  private:\n    int action; int fullinput;\n    int nInputs;\n    int *inputsIdx;\n    FLOAT_DMEM *inputScale;\n    FLOAT_DMEM *inputOffset;\n\n    const char **inputNames;\n    const char **inputColours;\n    \n    //wxCommandEvent &myevent; //( wxEVT_COMMAND_TEXT_UPDATED, VAD_UPDATE_ID );\n    //int old;\n\n    smileThread guiThr;\n    //gcroot<openSmilePluginGUI::TestForm^> fo;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    int getElidxFromName(const char *_name); \n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    //FLOAT_DMEM yscale100;\n\n    int matMultiplier;\n    int terminate;\n    visApp* pApp;\n    smileMutex wxMtx;\n\n    cSimpleVisualiserGUI(const char *_name);\n\n    virtual ~cSimpleVisualiserGUI();\n};\n\n\n\n\n#endif // __CSIMPLEVISUALISERGUI\n"
  },
  {
    "path": "progsrc/android-template/.gitignore",
    "content": "*.iml\n.gradle\n/local.properties\n/.idea/workspace.xml\n/.idea/libraries\n.DS_Store\n/build\n/captures\n"
  },
  {
    "path": "progsrc/android-template/.idea/.name",
    "content": "openSMILE Android Template"
  },
  {
    "path": "progsrc/android-template/.idea/compiler.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"CompilerConfiguration\">\n    <resourceExtensions />\n    <wildcardResourcePatterns>\n      <entry name=\"!?*.java\" />\n      <entry name=\"!?*.form\" />\n      <entry name=\"!?*.class\" />\n      <entry name=\"!?*.groovy\" />\n      <entry name=\"!?*.scala\" />\n      <entry name=\"!?*.flex\" />\n      <entry name=\"!?*.kt\" />\n      <entry name=\"!?*.clj\" />\n      <entry name=\"!?*.aj\" />\n    </wildcardResourcePatterns>\n    <annotationProcessing>\n      <profile default=\"true\" name=\"Default\" enabled=\"false\">\n        <processorPath useClasspath=\"true\" />\n      </profile>\n    </annotationProcessing>\n  </component>\n</project>"
  },
  {
    "path": "progsrc/android-template/.idea/copyright/profiles_settings.xml",
    "content": "<component name=\"CopyrightManager\">\n  <settings default=\"\" />\n</component>"
  },
  {
    "path": "progsrc/android-template/.idea/encodings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"Encoding\">\n    <file url=\"PROJECT\" charset=\"UTF-8\" />\n  </component>\n</project>"
  },
  {
    "path": "progsrc/android-template/.idea/gradle.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"GradleSettings\">\n    <option name=\"linkedExternalProjectsSettings\">\n      <GradleProjectSettings>\n        <option name=\"distributionType\" value=\"DEFAULT_WRAPPED\" />\n        <option name=\"externalProjectPath\" value=\"$PROJECT_DIR$\" />\n        <option name=\"modules\">\n          <set>\n            <option value=\"/media/ghagerer/data/encfs/code/openSMILE/trunk/progsrc/android-template\" />\n            <option value=\"/media/ghagerer/data/encfs/code/openSMILE/trunk/progsrc/android-template/app\" />\n          </set>\n        </option>\n        <option name=\"myModules\">\n          <set>\n            <option value=\"/media/ghagerer/data/encfs/code/openSMILE/trunk/progsrc/android-template\" />\n            <option value=\"/media/ghagerer/data/encfs/code/openSMILE/trunk/progsrc/android-template/app\" />\n          </set>\n        </option>\n      </GradleProjectSettings>\n    </option>\n  </component>\n</project>"
  },
  {
    "path": "progsrc/android-template/.idea/misc.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"EntryPointsManager\">\n    <entry_points version=\"2.0\" />\n  </component>\n  <component name=\"NullableNotNullManager\">\n    <option name=\"myDefaultNullable\" value=\"android.support.annotation.Nullable\" />\n    <option name=\"myDefaultNotNull\" value=\"android.support.annotation.NonNull\" />\n    <option name=\"myNullables\">\n      <value>\n        <list size=\"4\">\n          <item index=\"0\" class=\"java.lang.String\" itemvalue=\"org.jetbrains.annotations.Nullable\" />\n          <item index=\"1\" class=\"java.lang.String\" itemvalue=\"javax.annotation.Nullable\" />\n          <item index=\"2\" class=\"java.lang.String\" itemvalue=\"edu.umd.cs.findbugs.annotations.Nullable\" />\n          <item index=\"3\" class=\"java.lang.String\" itemvalue=\"android.support.annotation.Nullable\" />\n        </list>\n      </value>\n    </option>\n    <option name=\"myNotNulls\">\n      <value>\n        <list size=\"4\">\n          <item index=\"0\" class=\"java.lang.String\" itemvalue=\"org.jetbrains.annotations.NotNull\" />\n          <item index=\"1\" class=\"java.lang.String\" itemvalue=\"javax.annotation.Nonnull\" />\n          <item index=\"2\" class=\"java.lang.String\" itemvalue=\"edu.umd.cs.findbugs.annotations.NonNull\" />\n          <item index=\"3\" class=\"java.lang.String\" itemvalue=\"android.support.annotation.NonNull\" />\n        </list>\n      </value>\n    </option>\n  </component>\n  <component name=\"ProjectLevelVcsManager\" settingsEditedManually=\"false\">\n    <OptionsSetting value=\"true\" id=\"Add\" />\n    <OptionsSetting value=\"true\" id=\"Remove\" />\n    <OptionsSetting value=\"true\" id=\"Checkout\" />\n    <OptionsSetting value=\"true\" id=\"Update\" />\n    <OptionsSetting value=\"true\" id=\"Status\" />\n    <OptionsSetting value=\"true\" id=\"Edit\" />\n    <ConfirmationsSetting value=\"0\" id=\"Add\" />\n    <ConfirmationsSetting value=\"0\" id=\"Remove\" />\n  </component>\n  <component name=\"ProjectRootManager\" version=\"2\" languageLevel=\"JDK_1_7\" default=\"true\" assert-keyword=\"true\" jdk-15=\"true\" project-jdk-name=\"1.8\" project-jdk-type=\"JavaSDK\">\n    <output url=\"file://$PROJECT_DIR$/build/classes\" />\n  </component>\n  <component name=\"ProjectType\">\n    <option name=\"id\" value=\"Android\" />\n  </component>\n  <component name=\"SvnBranchConfigurationManager\">\n    <option name=\"mySupportsUserInfoFilter\" value=\"true\" />\n  </component>\n</project>"
  },
  {
    "path": "progsrc/android-template/.idea/modules.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"ProjectModuleManager\">\n    <modules>\n      <module fileurl=\"file:///media/ghagerer/data/encfs/code/openSMILE/trunk/progsrc/android-template/android-template.iml\" filepath=\"/media/ghagerer/data/encfs/code/openSMILE/trunk/progsrc/android-template/android-template.iml\" />\n      <module fileurl=\"file:///media/ghagerer/data/encfs/code/openSMILE/trunk/progsrc/android-template/app/app.iml\" filepath=\"/media/ghagerer/data/encfs/code/openSMILE/trunk/progsrc/android-template/app/app.iml\" />\n    </modules>\n  </component>\n</project>"
  },
  {
    "path": "progsrc/android-template/.idea/runConfigurations.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"RunConfigurationProducerService\">\n    <option name=\"ignoredProducers\">\n      <set>\n        <option value=\"org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer\" />\n        <option value=\"org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer\" />\n        <option value=\"org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer\" />\n      </set>\n    </option>\n  </component>\n</project>"
  },
  {
    "path": "progsrc/android-template/.idea/vcs.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"VcsDirectoryMappings\">\n    <mapping directory=\"\" vcs=\"svn\" />\n  </component>\n</project>"
  },
  {
    "path": "progsrc/android-template/README_SETUP.TXT",
    "content": "\nAfter checking out from SVN, the following steps might be necessary:\n\n1. edit app/src/main/jni/sync-build-libopensmile.sh\n   and adapt OPENSMILE_DIR to point to your trunk of opensmile\n2. if you have not yet run buildAndroid.sh in the opensmile trunk,\n   do so now to fully build the android libs\n3. To sync the libs with the app project, do:\n     cd app/src/main/jni\n     sh sync-build-libopensmile.sh\n4. open project in android studio\n5. Change \n    sdk.dir=\n    ndk.dir=\n   in GradleScripts -> local.properties\n   to your SDK and NDK locations.\n   (take a NDK version _NOT_ higher than ndk-r10e-rc4)\n6. Edit the OPENSMILE path in \n     app/src/main/jni/Android.mk\n7. Edit the ndk-build command (and path) in \n     app/build.gradle\n   or better: add the NDK directory to your system path\n   and then use 'ndk-build' as command\n\n8. Copy openSMILE configs and models to app/src/assets.\n   Load these by specifying them in app/src/plugins/Config.scala.\n\n9. For a new GUI application, create a new SmilePlugin within app/src/scala/.../plugins\n   See the existing example and config code and respective documentation there.\n\n10. If you want to do something different than just showing some live openSMILE output,\n    take a look at the following classes and respective methods:\n    - src/scala/.../MainActivity.scala -> SmileThread & onSmileMessageReceived()\n    - src/java/.../SmileJNI.java -> interface Listener & registerListener()"
  },
  {
    "path": "progsrc/android-template/app/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "progsrc/android-template/app/build.gradle",
    "content": "apply plugin: 'com.android.application'\napply plugin: \"jp.leafytree.android-scala\"\n\nandroid {\n    compileSdkVersion 23\n    buildToolsVersion \"22.0.1\"\n\n    defaultConfig {\n        applicationId \"com.audeering.opensmile.androidtemplate\"\n        minSdkVersion 21\n        targetSdkVersion 23\n        versionCode 1\n        versionName \"1.0\"\n        multiDexEnabled true\n    }\n\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n\n    sourceSets {\n        main {\n            scala {\n                srcDir \"src/main/scala\"\n            }\n            jniLibs.srcDir 'src/main/libs'\n            jni.srcDirs = [] //disable automatic ndk-build call\n        }\n        androidTest {\n            scala {\n                srcDir \"src/androidTest/scala\"\n            }\n        }\n    }\n\n    project.ext.versionCodes = ['armeabi': 1]\n\n    //versionCode digit for each supported ABI, with 64bit>32bit and x86>armeabi-*\n    android.applicationVariants.all { variant ->\n        // assign different version code for each output\n        variant.outputs.each { output ->\n            output.versionCodeOverride =\n                    project.ext.versionCodes.get(output.getFilter(com.android.build.OutputFile.ABI), 0) * 1000000 + defaultConfig.versionCode\n        }\n    }\n\n    // call regular ndk-build(.cmd) script from app directory\n    task ndkBuild(type: Exec) {\n        commandLine '/path/to/android/ndk-r10e/ndk-build', 'NDK_DEBUG=1', 'TARGET_PLATFORM=android-21', '-C', file('src/main').absolutePath\n    }\n\n    tasks.withType(JavaCompile) {\n        compileTask -> compileTask.dependsOn ndkBuild\n    }\n}\n\ndependencies {\n    compile fileTree(dir: 'libs', include: ['*.jar'])\n    testCompile 'junit:junit:4.12'\n    compile 'com.android.support:appcompat-v7:23.4.0'\n    compile 'org.scala-lang:scala-library:2.11.7'\n    compile 'org.json:json:20160212'\n    compile 'javax.vecmath:vecmath:1.5.2'\n}\n"
  },
  {
    "path": "progsrc/android-template/app/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /home/gerry/Android/Sdk/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the proguardFiles\n# directive in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n"
  },
  {
    "path": "progsrc/android-template/app/src/androidTest/java/com/audeering/opensmile/androidtemplate/ApplicationTest.java",
    "content": "package com.audeering.opensmile.androidtemplate;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\n/**\n * <a href=\"http://d.android.com/tools/testing/testing_android.html\">Testing Fundamentals</a>\n */\npublic class ApplicationTest extends ApplicationTestCase<Application> {\n    public ApplicationTest() {\n        super(Application.class);\n    }\n}"
  },
  {
    "path": "progsrc/android-template/app/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.audeering.opensmile.androidtemplate\">\n\n    <application\n        android:allowBackup=\"true\"\n        android:icon=\"@mipmap/ic_launcher\"\n        android:label=\"@string/app_name\"\n        android:supportsRtl=\"true\"\n        android:theme=\"@style/AppTheme\">\n\n        <activity\n            android:name=\"com.audeering.opensmile.androidtemplate.MainActivity\"\n            android:screenOrientation=\"portrait\"\n            android:configChanges=\"keyboardHidden|orientation|screenSize\" >\n\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n                <category android:name=\"android.intent.category.LAUNCHER\" />\n            </intent-filter>\n\n        </activity>\n\n    </application>\n\n    <uses-permission android:name=\"android.permission.RECORD_AUDIO\" />\n    <uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" />\n    <uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\" />\n\n</manifest>\n"
  },
  {
    "path": "progsrc/android-template/app/src/main/assets/BufferModeRb.conf.inc",
    "content": "writer.levelconf.growDyn = 0\nwriter.levelconf.isRb = 1\nwriter.levelconf.nT = 10\nwriter.levelconf.noHang = 2\n"
  },
  {
    "path": "progsrc/android-template/app/src/main/assets/features.conf.inc",
    "content": "// This file is part of openSMILE.\n// (c) 2016 by audEERING GmbH. All rights reserved.\n// See file COPYING for details on licensing terms.\n//\n// Written by Florian Eyben. fe@audeering.com\n\n[componentInstances:cComponentManager]\ninstance[framesB].type=cFramer\ninstance[energyMeter].type=cEnergy\ninstance[winB].type=cWindower\ninstance[fftB].type=cTransformFFT\ninstance[fftmagB].type=cFFTmagphase\ninstance[bandspec].type=cMelspec\n\n[framesB:cFramer]\nreader.dmLevel = wave\nwriter.dmLevel = framesB\n\\{\\cm[bufferModeRbConf{BufferModeRb.conf.inc}:buffer mode for pre-functionals levels]}\nframeSize = 0.025\nframeStep = 0.010\n\n[energyMeter:cEnergy]\nreader.dmLevel=framesB\nwriter.dmLevel=energyB\nlog=1\nrms=0\nebiasLog = 30\nescaleLog = 12\n\n[winB:cWindower]\nreader.dmLevel=framesB\nwriter.dmLevel=windowsB\ncopyInputName = 1\nprocessArrayFields = 1\n ; hamming window\nwinFunc = ham\n\n[fftB:cTransformFFT]\nreader.dmLevel=windowsB\nwriter.dmLevel=fftB\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\n\n[fftmagB:cFFTmagphase]\nreader.dmLevel=fftB\nwriter.dmLevel=fftmagB\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\nmagnitude = 1\nphase = 0\n\n[fftmagBphase:cFFTmagphase]\nreader.dmLevel=fftB\nwriter.dmLevel=fftmagBphase\ncopyInputName = 1\nprocessArrayFields = 1\ninverse = 0\nmagnitude = 0\nphase = 1\n\n[bandspec:cMelspec]\nreader.dmLevel=fftmagB\nwriter.dmLevel=melspec\ncopyInputName = 1\nprocessArrayFields = 1\nhtkcompatible = 0\nnBands = 3\nusePower = 1\nlofreq = 0\nhifreq = 8000\nspecScale = bark\ninverse = 0\n\n\n"
  },
  {
    "path": "progsrc/android-template/app/src/main/assets/liveinput_android.conf",
    "content": "// This file is part of openSMILE.\n// (c) 2016 by audEERING GmbH. All rights reserved.\n// See file COPYING for details on licensing terms.\n//\n// Written by Florian Eyben. fe@audeering.com\n\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\ninstance[waveIn].type=cOpenslesSource\ninstance[jniMessageInterface].type = cJniMessageInterface\nprintLevelStats = 5\nprofiling = 0\nnThreads = 1\n\n[waveIn:cOpenslesSource]\nwriter.dmLevel=wave\nmonoMixdown = 0\nwriter.levelconf.growDyn = 0\nwriter.levelconf.isRb = 1\nwriter.levelconf.nT = 32000\nsampleRate = 16000\nnBits = 16\nchannels = 1\naudioBuffersize = 256\n\n\\{features.conf.inc}\n\\{messages.conf.inc}\n\n[jniMessageInterface:cJniMessageInterface]\nsendMessagesInTick = 1\nJNIcallbackClass = com/audeering/opensmile/androidtemplate/SmileJNI\nJNIstringReceiverMethod = receiveText\n\n"
  },
  {
    "path": "progsrc/android-template/app/src/main/assets/messages.conf.inc",
    "content": "// This file is part of openSMILE.\n// (c) 2016 by audEERING GmbH. All rights reserved.\n// See file COPYING for details on licensing terms.\n//\n// Written by Florian Eyben. fe@audeering.com\n\n[componentInstances:cComponentManager]\ninstance[bandEnergy].type=cSimpleMessageSender\n\n[bandEnergy:cSimpleMessageSender]\nreader.dmLevel = melspec;energyB\nsendPeriodically = 2\nmessageName = energy_act\nmessageType = energy\nmessageRecp = jniMessageInterface\nenableDebugSender = 0\n"
  },
  {
    "path": "progsrc/android-template/app/src/main/java/com/audeering/opensmile/androidtemplate/SmileJNI.java",
    "content": "/*\n Copyright (c) 2015 audEERING UG. All rights reserved.\n\n Date: 17.08.2015\n Author(s): Florian Eyben\n E-mail:  fe@audeering.com\n\n This is the interface between the Android app and the openSMILE binary.\n openSMILE is called via SMILExtractJNI()\n Messages from openSMILE are received by implementing the SmileJNI.Listener interface.\n*/\n\npackage com.audeering.opensmile.androidtemplate;\n\npublic class SmileJNI {\n\n    /**\n     * load the JNI interface\n     */\n    static {\n        System.loadLibrary(\"smile_jni\");\n    }\n\n    /**\n     * method to execute openSMILE binary from the Android app activity, see smile_jni.cpp.\n     * @param configfile\n     * @param externalStoragePath\n     * @param updateProfile\n     * @return\n     */\n    public static native String SMILExtractJNI(String configfile, int updateProfile);\n    public static native String SMILEndJNI();\n\n    /**\n     * process the messages from openSMILE (redirect to app activity etc.)\n     */\n    public interface Listener {\n        void onSmileMessageReceived(String text);\n    }\n    private static Listener listener_;\n    public static void registerListener (Listener listener) {\n        listener_ = listener;\n    }\n\n    /**\n     * this is the first method called by openSMILE binary. it redirects the call to the Android\n     * app activity.\n     * @param text JSON encoded string\n     */\n    static void receiveText(String text) {\n        if (listener_ != null)\n            listener_.onSmileMessageReceived(text);\n    }\n}\n"
  },
  {
    "path": "progsrc/android-template/app/src/main/jni/Android.mk",
    "content": "\nLOCAL_PATH := $(call my-dir)\n\ninclude $(CLEAR_VARS)\n\nLOCAL_MODULE := opensmile\nLOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libopensmile.a\n#LOCAL_EXPORT_C_INCLUDES := \ninclude $(PREBUILT_STATIC_LIBRARY)\n\n\ninclude $(CLEAR_VARS)\n\n############ set here the absolute path of your opensmile directory\nOPENSMILE_ROOT := /path/to/opensmile/root/dir\n##########################################################\n\nOPENSMILE_INCLUDES_DIR := $(OPENSMILE_ROOT)/src/include\nOPENSMILE_LIBS_DIR := $(OPENSMILE_ROOT)/inst/android\n\nLOCAL_MODULE\t:= smile_jni\nLOCAL_SRC_FILES := smile_jni.cpp \nLOCAL_SRC_FILES += smilextract.cpp\n\nLOCAL_CPP_FEATURES := exceptions\n\nLOCAL_C_INCLUDES := $(OPENSMILE_INCLUDES_DIR)\n\nLOCAL_STATIC_LIBRARIES := opensmile\nLOCAL_LDLIBS := -ggdb -lstdc++ -lm -ldl -llog -D__STDC_CONSTANT_MACROS -lc\nLOCAL_LDLIBS += -lOpenSLES\n\ninclude $(BUILD_SHARED_LIBRARY)\n\n"
  },
  {
    "path": "progsrc/android-template/app/src/main/jni/Application.mk",
    "content": "APP_STL := gnustl_shared\nAPP_MODULES := smile_jni\n"
  },
  {
    "path": "progsrc/android-template/app/src/main/jni/smile_jni.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n#include <signal.h>\n#include <stdlib.h>\n#include <android/log.h>\n#include <jni.h>\n\n#include \"smilextract.h\"\n#include \"smile_jni.h\"\n\nextern \"C\" {\n\ncComponentManager * myCmanGlob = NULL;\nJavaVM *javaVm = NULL;\n\nJavaVM * JNIcallback_getJavaVm() {\n    return javaVm;\n}\n\nstatic jobject gClassLoader;\nstatic jmethodID gFindClassMethod;\n\n// http://stackoverflow.com/questions/14765776/jni-error-app-bug-accessed-stale-local-reference-0xbc00021-index-8-in-a-tabl\n\nJNIEnv* getEnv() {\n    JNIEnv *env;\n    int status = javaVm->GetEnv((void**)&env, JNI_VERSION_1_6);\n    if(status < 0) {\n        status = javaVm->AttachCurrentThread(&env, NULL);\n        if(status < 0) {\n            return NULL;\n        }\n    }\n    return env;\n}\n\nJNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *pjvm, void *reserved) {\n    javaVm = pjvm;\n    JNIEnv * env = getEnv();\n    jclass randomClass = env->FindClass(\"com/audeering/opensmile/androidtemplate/SmileJNI\");\n    jclass classClass = env->GetObjectClass(randomClass);\n    jclass classLoaderClass = env->FindClass(\"java/lang/ClassLoader\");\n    jmethodID getClassLoaderMethod = env->GetMethodID(classClass, \"getClassLoader\",\n                                                      \"()Ljava/lang/ClassLoader;\");\n    jobject tmp1 = env->CallObjectMethod(randomClass, getClassLoaderMethod);\n    gClassLoader = (jobject)env->NewGlobalRef(tmp1);\n    gFindClassMethod = env->GetMethodID(classLoaderClass, \"findClass\",\n                                        \"(Ljava/lang/String;)Ljava/lang/Class;\");\n    return JNI_VERSION_1_6;\n}\n\n// Starts openSMILE through JNI.\nJNIEXPORT jstring JNICALL Java_com_audeering_opensmile_androidtemplate_SmileJNI_SMILExtractJNI( JNIEnv* env, jobject thiz, jstring conf, jint updateProfile){\n    const char SMILExtract[] = \"SMILExtract\";\n    const char * configfile = env->GetStringUTFChars(conf, NULL);\n    //\"-nologfile\" necessary, as we cannot write to the default logfile location!\n    // -l <N> sets the debugging level. 5 is most verbose. 0 supresses all messages. 2 is recommended.\n    // -O option is a dummy, no actual output file should be written to this location\n    const char *cmd[] = {SMILExtract, \"-C\", configfile, \"-nologfile\", \"-l\", \"2\"};\n    // TODO: sdcard location, if needed: Environment.getExternalStorageDirectory()\n    int cmd_num = 6; // IMPORTANT: synchronize with the size of the cmd array\n    // NOTE: app will seg-fault if cmd_num is larger than the actual number of arguments!\n\n    __android_log_print(ANDROID_LOG_INFO, \"opensmile\", \"starting opensmile...\");\n    // gets and stores global pointer to java vm\n    env->GetJavaVM(&javaVm);\n    // executes SMILExtract main function, modified for Android\n    int ret = SMILExtractFunction(cmd_num, cmd, javaVm, &gClassLoader, &gFindClassMethod);\n    __android_log_print(ANDROID_LOG_INFO, \"opensmile\", \"stopped opensmile.\");\n    return env->NewStringUTF(\"openSMILE ran\");\n}\n\n// Terminates openSMILE upon external/user request.\nJNIEXPORT jstring JNICALL Java_com_audeering_opensmile_androidtemplate_SmileJNI_SMILEndJNI(JNIEnv* env, jobject thiz , jlong cmanglob){\n    myCmanGlob = getComponentManager();\n    if (myCmanGlob != NULL){\n        myCmanGlob->requestAbort();\n        return env->NewStringUTF(\"Finished openSMILE\");\n    } else {\n        return env->NewStringUTF(\"component manager pointer was null\");\n    }\n}\n\n\n}\n"
  },
  {
    "path": "progsrc/android-template/app/src/main/jni/smile_jni.h",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n#ifndef OPENSMILE_ANDROID_SMILE_JNI_H\n#define OPENSMILE_ANDROID_SMILE_JNI_H\n\n#endif // OPENSMILE_ANDROID_SMILE_JNI_H\n\n"
  },
  {
    "path": "progsrc/android-template/app/src/main/jni/smilextract.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n// NOTE: it is important that this include comes before #define MODULE..\n// why is unclear, but otherwise it does not compile ;-)\n#include \"smilextract.h\"\n\n#define MODULE \"SMILExtract\"\n#include <android/log.h>\n#include <jni.h>\n\ncComponentManager *cmanGlob = NULL;\ncComponentManager *getComponentManager() {\n    return cmanGlob;\n};\n\nint SMILExtractFunction(int argc, const char *argv[], JavaVM *jvm, void * classLoader, void * findClassMethod)\n{\n    cmanGlob = NULL;\n    __android_log_print(ANDROID_LOG_INFO, \"opensmile\", \"Started openSMILE thread.\");\n    //same as SMILEXtract, only renamed the main() function\n    try {\n        smileCommon_fixLocaleEnUs();\n        // set up the smile logger\n        LOGGER.setLogLevel(1);\n        LOGGER.enableConsoleOutput();\n\n        // commandline parser:\n        cCommandlineParser cmdline(argc, argv);\n        cmdline.addStr( \"configfile\", 'C', \"Path to openSMILE config file\", \"smile.conf\" );\n        cmdline.addInt( \"loglevel\", 'l', \"Verbosity level (0-9)\", 2 );\n#ifdef DEBUG\n        cmdline.addBoolean( \"debug\", 'd', \"Show debug messages (on/off)\", 0 );\n#endif\n        cmdline.addInt( \"nticks\", 't', \"Number of ticks to process (-1 = infinite) (only works for single thread processing, i.e. nThreads=1)\", -1 );\n        //cmdline.addBoolean( \"configHelp\", 'H', \"Show documentation of registered config types (on/off)\", 0 );\n        cmdline.addBoolean( \"components\", 'L', \"Show component list\", 0 );\n        cmdline.addStr( \"configHelp\", 'H', \"Show documentation of registered config types (on/off/argument) (if an argument is given, show only documentation for config types beginning with the name given in the argument)\", NULL, 0 );\n        cmdline.addStr( \"configDflt\", 0, \"Show default config section templates for each config type (on/off/argument) (if an argument is given, show only documentation for config types beginning with the name given in the argument, OR for a list of components in conjunctions with the 'cfgFileTemplate' option enabled)\", NULL, 0 );\n        cmdline.addBoolean( \"cfgFileTemplate\", 0, \"Print a complete template config file for a configuration containing the components specified in a comma separated string as argument to the 'configDflt' option\", 0 );\n        cmdline.addBoolean( \"cfgFileDescriptions\", 0, \"Include description in config file templates.\", 0 );\n        cmdline.addBoolean( \"ccmdHelp\", 'c', \"Show custom commandline option help (those specified in config file)\", 0 );\n        cmdline.addStr( \"logfile\", 0, \"set log file\", \"smile.log\" );\n        cmdline.addBoolean( \"nologfile\", 0, \"don't write to a log file (e.g. on a read-only filesystem)\", 0 );\n        cmdline.addBoolean( \"noconsoleoutput\", 0, \"don't output any messages to the console (log file is not affected by this option)\", 0 );\n        cmdline.addBoolean( \"appendLogfile\", 0, \"append log messages to an existing logfile instead of overwriting the logfile at every start\", 0 );\n\n        int help = 0;\n        if (cmdline.doParse() == -1) {\n            LOGGER.setLogLevel(0);\n            help = 1;\n        }\n        if (argc <= 1) {\n            __android_log_print(ANDROID_LOG_INFO, \"opensmile\", \"\\nNo commandline options were given.\\n Please run ' SMILExtract -h ' to see some usage information!\\n\\n\");\n            return 10;\n        }\n\n        if (help==1) { return 0; }\n\n        if (cmdline.getBoolean(\"nologfile\")) {\n            LOGGER.setLogFile((const char *)NULL,0,!(cmdline.getBoolean(\"noconsoleoutput\")));\n        } else {\n            LOGGER.setLogFile(cmdline.getStr(\"logfile\"),cmdline.getBoolean(\"appendLogfile\"),!(cmdline.getBoolean(\"noconsoleoutput\")));\n        }\n        LOGGER.setLogLevel(cmdline.getInt(\"loglevel\"));\n        SMILE_MSG(2,\"openSMILE starting!\");\n\n\n#ifdef DEBUG  \n        if (!cmdline.getBoolean(\"debug\"))\n          LOGGER.setLogLevel(LOG_DEBUG, 0);\n#endif\n        SMILE_MSG(2,\"config file is: %s\",cmdline.getStr(\"configfile\"));\n        // create configManager:\n        cConfigManager *configManager = new cConfigManager(&cmdline);\n        cComponentManager *cMan = new cComponentManager(configManager,componentlist);\n\n        const char *selStr=NULL;\n        if (cmdline.isSet(\"configHelp\")) {\n#ifndef EXTERNAL_BUILD\n            selStr = cmdline.getStr(\"configHelp\");\n            configManager->printTypeHelp(1/*!!! -> 1*/,selStr,0);\n#endif\n            help = 1;\n        }\n        if (cmdline.isSet(\"configDflt\")) {\n#ifndef EXTERNAL_BUILD\n            int fullMode=0;\n            int wDescr = 0;\n            if (cmdline.getBoolean(\"cfgFileTemplate\")) fullMode=1;\n            if (cmdline.getBoolean(\"cfgFileDescriptions\")) wDescr=1;\n            selStr = cmdline.getStr(\"configDflt\");\n            configManager->printTypeDfltConfig(selStr,1,fullMode,wDescr);\n#endif\n            help = 1;\n        }\n        if (cmdline.getBoolean(\"components\")) {\n#ifndef EXTERNAL_BUILD\n            cMan->printComponentList();\n#endif  // EXTERNAL_BUILD\n            help = 1;\n        }\n\n        if (help==1) {\n            delete configManager;\n            delete cMan;\n            return -1;\n        }\n\n        try{\n            configManager->addReader( new cFileConfigReader( cmdline.getStr(\"configfile\"), -1, &cmdline) );\n            configManager->readConfig();\n        } catch (cConfigException *cc) {\n            return 0;\n        }\n\n        /* re-parse the command-line to include options created in the config file */\n        cmdline.doParse(1,0); // warn if unknown options are detected on the commandline\n        if (cmdline.getBoolean(\"ccmdHelp\")) {\n            cmdline.showUsage();\n            delete configManager;\n            delete cMan;\n            return -1;\n        }\n\n        configManager->addExternalPointer(\"JavaVM\", jvm);\n        configManager->addExternalPointer(\"ClassLoader\", classLoader);\n        configManager->addExternalPointer(\"FindClassMethod\", findClassMethod);\n        /* create all instances specified in the config file */\n        cMan->createInstances(0); // 0 = do not read config (we already did that above..)\n        cmanGlob = cMan;\n        /* run single or mutli-threaded, depending on componentManager config in config file */\n        long long nTicks = cMan->runMultiThreaded(cmdline.getInt(\"nticks\"));\n\n        /* it is important that configManager is deleted BEFORE componentManger!\n          (since component Manger unregisters plugin Dlls, which might have allocated configTypes, etc.) */\n        delete configManager;\n        delete cMan;\n\n    } catch (cSMILException *c) {\n        // TODO: free cMan and configManager !?\n        // free exception ??\n        return EXIT_ERROR;\n    }\n\n    return EXIT_SUCCESS;\n}\n"
  },
  {
    "path": "progsrc/android-template/app/src/main/jni/smilextract.h",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n#ifndef OPENSMILEANDROID_SMILEXTRACT_H\n#define OPENSMILEANDROID_SMILEXTRACT_H\n\n#include <core/smileCommon.hpp>\n#include <core/configManager.hpp>\n#include <core/commandlineParser.hpp>\n#include <core/componentManager.hpp>\n#include <jni.h>\n\ncComponentManager *getComponentManager();\nint SMILExtractFunction(int argc, const char *argv[], JavaVM *jvm, void * classLoader, void * findClassMethod);\n\n#endif // OPENSMILE_ANDROID_SMILEXTRACT_H\n\n"
  },
  {
    "path": "progsrc/android-template/app/src/main/jni/sync-build-libopensmile.sh",
    "content": "#!/usr/bin/env bash\n\n# This file is part of openSMILE.\n#\n# Copyright (c) audEERING. All rights reserved.\n# See the file COPYING for details on license terms.\n\nARCH=\"armeabi\";\n\n############ you might need to change this if you move the\n############ android studio project somewhere else, i.e.\n############ outside of the opensmile root folder\nOPENSMILE_DIR=\"../../../../../../\"\n##########################################################\n\nPWDD=`pwd`;\ncd $OPENSMILE_DIR\n\n## IMPORTANT:\n##   run buildAndroid.sh in the opensmile trunk directory\n##   once first to set up the build environment, \n##   or comment out the line below:\n# sh buildAndroid.sh\n## NOTE: leaving this enabled, will cause a full re-build, every time you run\n##  this script to include a change in openSMILE in the compiled\n##  android library.\n\n# Alternatively, just use make to re-build the changed parts:\nmake -j8\nmake install\n\ncd $PWDD\nmkdir -p $ARCH\ncp -f $OPENSMILE_DIR/inst/android/lib/libopensmile.a ./$ARCH\n\n# not needed...\n# cp -af $OPENSMILE_DIR/inst/android/lib/libopensmile.so* ./$ARCH\n\n"
  },
  {
    "path": "progsrc/android-template/app/src/main/res/layout/fragment_show.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n    Copyright (c) 2015 audEERING UG. All rights reserved.\n\n    Date: 12.11.2015\n    Author(s): Erik Marchi\n    E-mail:  em@audeering.com\n\n    Place a short description of what this code does here (1-2 sentences).\n\n    For the main source file / library headers / etc., put a more elaborate description\n    of usage, functionality, etc. (README style or Quickstart style).\n-->\n\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    android:shrinkColumns=\"*\"  android:stretchColumns=\"*\" android:background=\"@drawable/backg\"\n    android:padding=\"10dp\"\n    android:gravity=\"bottom\"\n    android:orientation=\"vertical\">\n\n    <LinearLayout\n        android:layout_height=\"wrap_content\"\n        android:layout_width=\"fill_parent\"\n        android:gravity=\"center_horizontal\" >\n\n        <TextView\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:textAppearance=\"?android:attr/textAppearanceLarge\"\n            android:text=\"@string/treble\"\n            android:id=\"@+id/trebleLabel\" />\n\n        <TextView\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:textAppearance=\"?android:attr/textAppearanceLarge\"\n            android:text=\"0\"\n            android:id=\"@+id/treble\"\n            android:layout_marginLeft=\"10dp\" />\n    </LinearLayout>\n\n    <LinearLayout\n        android:layout_height=\"wrap_content\"\n        android:layout_width=\"fill_parent\"\n        android:gravity=\"center_horizontal\" >\n\n        <TextView\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:textAppearance=\"?android:attr/textAppearanceLarge\"\n            android:text=\"@string/middle\"\n            android:id=\"@+id/middleLabel\" />\n\n        <TextView\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:textAppearance=\"?android:attr/textAppearanceLarge\"\n            android:text=\"0\"\n            android:id=\"@+id/middle\"\n            android:layout_marginLeft=\"10dp\" />\n    </LinearLayout>\n\n    <LinearLayout\n        android:layout_height=\"wrap_content\"\n        android:layout_width=\"fill_parent\"\n        android:gravity=\"center_horizontal\">\n\n        <TextView\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:textAppearance=\"?android:attr/textAppearanceLarge\"\n            android:text=\"@string/bass\"\n            android:id=\"@+id/bassLabel\" />\n\n        <TextView\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:textAppearance=\"?android:attr/textAppearanceLarge\"\n            android:text=\"0\"\n            android:id=\"@+id/bass\"\n            android:layout_marginLeft=\"10dp\" />\n\n    </LinearLayout>\n\n\n    <LinearLayout\n        android:layout_height=\"match_parent\"\n        android:layout_width=\"match_parent\"\n        android:orientation=\"horizontal\"\n        android:layout_span=\"7\"\n        android:layout_gravity=\"center_horizontal\">\n\n        <ImageView\n            android:layout_span=\"3\"\n            android:id=\"@+id/imageviewBottomLogo\"\n            android:background=\"#fbffff\"\n            android:layout_gravity=\"bottom|center_horizontal\"\n            android:layout_margin=\"5dp\"\n            android:src=\"@drawable/audeering_long\"\n            android:layout_width=\"180dp\"\n            android:layout_height=\"50dp\">\n        </ImageView>\n\n        <ImageView\n            android:id=\"@+id/imageviewSensAILogo\"\n            android:layout_width=\"160dp\"\n            android:layout_height=\"50dp\"\n            android:layout_gravity=\"center_vertical|bottom\"\n            android:layout_margin=\"5dp\"\n            android:layout_span=\"7\"\n            android:src=\"@drawable/opensmile\">\n        </ImageView>\n\n    </LinearLayout>\n\n</LinearLayout>\n\n\n"
  },
  {
    "path": "progsrc/android-template/app/src/main/res/layout/main.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<android.support.v4.view.ViewPager\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:id=\"@+id/pager\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\" />\n\n"
  },
  {
    "path": "progsrc/android-template/app/src/main/res/menu/toolbar.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n    Copyright (c) 2015 audEERING UG. All rights reserved.\n\n    Date: 12.11.2015\n    Author(s): Erik Marchi\n    E-mail:  em@audeering.com\n\n    Place a short description of what this code does here (1-2 sentences).\n\n    For the main source file / library headers / etc., put a more elaborate description\n    of usage, functionality, etc. (README style or Quickstart style).\n-->\n\n<menu\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    tools:context=\".SomeActivity\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"?attr/actionBarSize\" >\n\n    <item\n        android:id=\"@+id/action_play_stop\"\n        android:icon=\"@drawable/ic_play_arrow_white_24dp\"\n        android:title=\"@string/action_play\"\n        app:showAsAction=\"always\"/>\n\n    <!--\n    <item\n        android:id=\"@+id/action_hide_show\"\n        android:icon=\"@drawable/ic_visibility_off_white_24dp\"\n        android:title=\"@string/action_hide\"\n        app:showAsAction=\"always\"/>\n    <item\n        android:id=\"@+id/action_new_user\"\n        android:icon=\"@drawable/ic_autorenew_white_24dp\"\n        android:title=\"@string/action_new_user\"\n        app:showAsAction=\"always\"/>\n\n    <item\n        android:id=\"@+id/action_show_details\"\n        android:title=\"Show details\"\n        android:orderInCategory=\"100\"\n        app:showAsAction=\"never\" />\n    <item\n        android:id=\"@+id/action_hide_details\"\n        android:title=\"Hide details\"\n        android:orderInCategory=\"100\"\n        app:showAsAction=\"never\" />\n    <item\n        android:id=\"@+id/action_enable_disable_accumulation\"\n        android:title=\"@string/action_disable_acc\"\n        android:orderInCategory=\"100\"\n        app:showAsAction=\"never\" />\n    <item\n        android:id=\"@+id/action_set_energy_th\"\n        android:title=\"@string/action_set_energy_th\"\n        android:orderInCategory=\"100\"\n        app:showAsAction=\"never\" />-->\n</menu>"
  },
  {
    "path": "progsrc/android-template/app/src/main/res/values/colors.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <color name=\"colorPrimary\">#3F51B5</color>\n    <color name=\"colorPrimaryDark\">#303F9F</color>\n    <color name=\"colorAccent\">#FF4081</color>\n</resources>\n"
  },
  {
    "path": "progsrc/android-template/app/src/main/res/values/strings.xml",
    "content": "<resources>\n    <string name=\"app_name\">openSMILE</string>\n    <string name=\"treble\">Treble:</string>\n    <string name=\"middle\">Middle:</string>\n    <string name=\"bass\">Bass:</string>\n    <string name=\"action_play\">play</string>\n    <string name=\"asset_dialog_title\">Caching AI models</string>\n</resources>\n"
  },
  {
    "path": "progsrc/android-template/app/src/main/res/values/styles.xml",
    "content": "<resources>\n\n    <!-- Base application theme. -->\n    <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar\">\n        <!-- Customize your theme here. -->\n        <item name=\"colorPrimary\">@color/colorPrimary</item>\n        <item name=\"colorPrimaryDark\">@color/colorPrimaryDark</item>\n        <item name=\"colorAccent\">@color/colorAccent</item>\n    </style>\n\n</resources>\n"
  },
  {
    "path": "progsrc/android-template/app/src/main/scala/com/audeering/opensmile/androidtemplate/MainActivity.scala",
    "content": "package com.audeering.opensmile.androidtemplate\n\nimport java.io._\n\nimport android.Manifest.permission._\nimport android.app.ProgressDialog\nimport android.content.pm.PackageManager._\nimport android.os.{Bundle, Handler}\nimport android.support.v4.app._\nimport android.support.v4.content.ContextCompat\nimport android.support.v4.view.ViewPager\nimport android.support.v7.app.AppCompatActivity\nimport android.util.Log\nimport android.view._\nimport com.audeering.opensmile.androidtemplate.plugins.Config\n\n/*\n Copyright (c) 2016 audEERING UG. All rights reserved.\n\n Date: 08.08.2016\n Author(s): Gerhard Hagerer\n E-mail:  gh@audeering.com\n\n  This is the main activity and the initialization class for this app\n*/\n\nclass MainActivity extends AppCompatActivity {\n\n  val TAG = classOf[MainActivity].getCanonicalName\n  var pagerAdapter: PagerAdapter = null\n  var pager: ViewPager = null\n  val assets = Config.assets\n  def conf = getCacheDir + \"/\" + Config.mainConf\n\n  val PERMISSION_REQUEST = 0\n  val permissions = Array[String](RECORD_AUDIO, WRITE_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE)\n\n  override def onCreate(state: Bundle) {\n    super.onCreate(state)\n    setContentView(R.layout.main)\n    pagerAdapter = new PagerAdapter(getSupportFragmentManager)\n    pager = R.id.pager.as[ViewPager]\n    pager.setAdapter(pagerAdapter)\n    SmilePlugin\n    pager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener{\n      override def onPageSelected(pos: Int) {\n        SmilePlugin.updateView(activeFragment.get, pos)\n      }\n    })\n    setupAssets\n  }\n\n  object SmileThread {\n    var isActive = false\n    def start {\n      (() => {\n        isActive = true\n        SmileJNI.SMILExtractJNI(conf, 1)\n      }).run\n    }\n    def stop {\n      isActive = false\n      SmileJNI.SMILEndJNI\n    }\n  }\n\n  def setMenuItemIcon(item: MenuItem, icon: Int, delay: Int = 2000) {\n    (() => {\n      item.setEnabled(false)\n      item.setVisible(false)\n    }).runUi\n    (() => {\n      item.setIcon(icon)\n      item.setEnabled(true)\n      item.setVisible(true)\n    }).runUiDelayed(delay)\n  }\n\n  override def onOptionsItemSelected(item: MenuItem): Boolean = {\n    item.getItemId match {\n      case R.id.home =>\n      case R.id.action_play_stop =>\n        if (SmileThread.isActive) {\n          SmileThread.stop\n          setMenuItemIcon(item, R.drawable.ic_play_arrow_white_24dp)\n        }\n        else {\n          SmileThread.start\n          setMenuItemIcon(item, R.drawable.ic_stop_white_24dp)\n        }\n      case _ =>\n    }\n    true\n  }\n\n  /**\n    * show a loading popup while the openSMILE conf-files are being loaded\n    * if the required permissions are not granted yet, it covers that, too\n    */\n  def setupAssets {\n    val grants = permissions.map( ContextCompat.checkSelfPermission(this, _) )\n    if (grants contains PERMISSION_DENIED) {\n      ActivityCompat.requestPermissions(this, permissions, PERMISSION_REQUEST)\n    }\n    else {\n      val dialog = new ProgressDialog(this)\n      dialog.setTitle(R.string.asset_dialog_title)\n      dialog.setMessage(\"Please wait...\")\n      dialog.show()\n      (() => {\n        assets.foreach(cacheAsset(_))\n        (() => dialog.dismiss ).runUi\n      }).run\n    }\n  }\n\n\n  override def onRequestPermissionsResult(request: Int, permissions: Array[String], grants: Array[Int]) {\n    if (request != PERMISSION_REQUEST || Option(grants) == None || grants.contains(PERMISSION_DENIED))\n      log(\"Permission denied\")\n    else\n      log(\"Permission granted\")\n    setupAssets\n  }\n\n  /**\n    * copies a file to a given destination\n    *\n    * @param filename the file to be copied\n    * @param dst destination directory (default: cacheDir)\n    */\n  def cacheAsset(filename: String, dst: String = getCacheDir.toString) {\n    val is = getAssets.open(filename)\n    val outfile = new File(dst + \"/\" + filename)\n    outfile.getParentFile.mkdirs()\n    val os = new FileOutputStream(outfile)\n    val buffer = new Array[Byte](50000)\n    Stream.continually(is.read(buffer))\n      .takeWhile(_ != -1)\n      .foreach(os.write(buffer, 0, _))\n    is.close\n    os.flush\n    os.close\n  }\n\n  // START shortcut methods\n  def log(str: String) = Log.i(TAG, str)\n  def activeFragment: Option[View] = {\n    val tag = \"android:switcher:\" + R.id.pager + \":\" + pager.getCurrentItem\n    val fragment = getSupportFragmentManager.findFragmentByTag(tag)\n    if (Option(fragment) != None)\n      return Option(fragment.getView())\n    None\n  }\n  implicit class ViewGetter(id: Int) {\n    def as[t] = findViewById(id).asInstanceOf[t]\n    def as[t](v: View) = v.findViewById(id).asInstanceOf[t]\n  }\n  implicit class Closure(func: () => Any) {\n    def asRunnable = new Runnable { override def run() = func() }\n    def asThread   = new Thread(asRunnable)\n    def run        = asThread.start()\n    def runUi      = runOnUiThread(asRunnable)\n    def runUiDelayed(delay: Int) = new Handler().postDelayed(func.asRunnable, delay)\n  }\n  // END shortcut methods\n\n  /**\n    * this adds items like buttons to the action bar\n    */\n  override def onCreateOptionsMenu(menu: Menu) = {\n    getMenuInflater.inflate(R.menu.toolbar, menu)\n    super.onCreateOptionsMenu(menu)\n  }\n\n  class PagerAdapter(fm: FragmentManager) extends FragmentPagerAdapter(fm) {\n    override def getItem(pos: Int) = new SlideFragment(pos)\n    override def getCount = SmilePlugin.layoutsNum\n    override def instantiateItem(container: ViewGroup, pos: Int): Object = {\n      val obj = super.instantiateItem(container, pos)\n      if (obj.isInstanceOf[Fragment] && pos == 0 && SmilePlugin.activeView == None) {\n        SmilePlugin.updateView(container, 0)\n      }\n      obj\n    }\n  }\n\n  class SlideFragment(val pos: Int) extends Fragment {\n    override def onCreateView(inflater: LayoutInflater, container: ViewGroup, state: Bundle) = {\n      inflater.inflate(SmilePlugin.layouts(pos), container, false)\n    }\n  }\n}\n"
  },
  {
    "path": "progsrc/android-template/app/src/main/scala/com/audeering/opensmile/androidtemplate/SmileMessage.scala",
    "content": "package com.audeering.opensmile.androidtemplate\n\nimport org.json.{JSONArray, JSONObject}\n\nimport scala.collection.mutable\n\n/*\n Copyright (c) 2016 audEERING UG. All rights reserved.\n\n Date: 08.08.2016\n Author(s): Gerhard Hagerer\n E-mail:  gh@audeering.com\n\n  This is for parsing a text message coming from openSMILE JNI in JSON format\n  Additional helper methods are provided too for easier access to standard attributes\n*/\n\n\nclass SmileMessage(jsn: String) extends JSONObject(jsn) {\n  def floatData(i: Int) = getJSONObject(\"floatData\").getDouble(\"\"+i).toFloat\n  def intData(i: Int) = getJSONObject(\"floatData\").getInt(\"\"+i)\n  def apply(key: String) = getString(key)\n}"
  },
  {
    "path": "progsrc/android-template/app/src/main/scala/com/audeering/opensmile/androidtemplate/SmilePlugin.scala",
    "content": "package com.audeering.opensmile.androidtemplate\n\nimport android.app.Activity\nimport android.view.View\nimport com.audeering.opensmile.androidtemplate.plugins.{Config, Energy}\n\nimport scala.collection.mutable.ListBuffer\n\n/*\n Copyright (c) 2016 audEERING UG. All rights reserved.\n\n Date: 08.08.2016\n Author(s): Gerhard Hagerer\n E-mail:  gh@audeering.com\n\n  Here classes for receiving and showing the output values from openSMILE can be defined\n  as plugins\n*/\n\n\nobject SmilePlugin extends SmileJNI.Listener {\n\n  var activePage = 0\n  var activeView: Option[View] = None\n  val fragments = ListBuffer[Int]()\n  val plugins = Config.plugins\n\n  SmileJNI.registerListener(this)\n\n  def updateView(v: View, id: Int): Unit = {\n      activeView = Option(v)\n      activePage = id\n  }\n\n  /**\n    * this gets called when openSMILE sends a message to the app\n    *\n    * @param text JSON encoded string\n    */\n  override def onSmileMessageReceived(text: String) {\n    // at first parse JSON\n    val msg = new SmileMessage(text)\n    val msgtype = msg(\"msgtype\")\n    val msgname = msg(\"msgname\")\n\n    // now see which SmilePlugins are there for that kind of openSMILE message (filtering)\n    // and iterate over all SmilePlugins and execute their values\n    plugins.filter( _.filter(msg) ).foreach( _.updateValues(msg) )\n\n    // now only take the plugin which is visible and call its ui update (don't forget VAD)\n    runUI(() => {\n      val visiblePlugin = plugins.filter( _.layoutId == plugins(activePage).layoutId )(0)\n      visiblePlugin.updateUI\n    })\n  }\n\n  def runUI(func: () => Unit) {\n    val act = activeView.get.getContext.asInstanceOf[Activity]\n    act.runOnUiThread(new Runnable {\n      override def run(): Unit = func()\n    })\n  }\n  def view[t](id: Int) = activeView.get.findViewById(id).asInstanceOf[t]\n  def layoutsNum = plugins.size\n  def layouts = plugins.map(_.layoutId)\n}\n\ntrait SmilePlugin {\n  val layoutId: Int\n  def updateValues(values: SmileMessage)\n  def updateUI()\n  def runUI(func: () => Unit) = SmilePlugin.runUI(func)\n  def filter(jsn: SmileMessage): Boolean = true\n  implicit class idToView(id: Int) {\n    def as[t]: t = SmilePlugin.view[t](id)\n  }\n}"
  },
  {
    "path": "progsrc/android-template/app/src/main/scala/com/audeering/opensmile/androidtemplate/plugins/Config.scala",
    "content": "package com.audeering.opensmile.androidtemplate.plugins\n\nimport com.audeering.opensmile.androidtemplate.SmilePlugin\n\n/*\n Copyright (c) 2016 audEERING UG. All rights reserved.\n\n Date: 09.08.16\n Author(s): Gerhard Hagerer\n E-mail:  gh@audeering.com\n\n Place a short description of what this code does here (1-2 sentences).\n\n This class contains everything to configure the plugins.\n Each plugin must be declared as an object of the package\n com.audeering.opensmile.androidtemplate.plugins.\n Then, you have to add our own plugin object to the plugin list of the present Config object,\n see plugins attribute below.\n Do not forget to include your openSMILE config files to the assets attribute.\n It is assumed, that you place your configs within the app/src/assets folder.\n Your main config, which includes all the other ones, must be declared explicitly as such by\n defining the mainConf accordingly.\n*/\n\nobject Config {\n  val assets = List(\n    \"liveinput_android.conf\",\n    \"BufferModeRb.conf.inc\",\n    \"messages.conf.inc\",\n    \"features.conf.inc\"\n  )\n  val mainConf = \"liveinput_android.conf\"\n  val plugins: List[SmilePlugin] = List(Energy)\n}\n"
  },
  {
    "path": "progsrc/android-template/app/src/main/scala/com/audeering/opensmile/androidtemplate/plugins/Energy.scala",
    "content": "package com.audeering.opensmile.androidtemplate.plugins\n\nimport android.widget.TextView\nimport com.audeering.opensmile.androidtemplate.{SmileMessage, SmilePlugin, R}\n\n/*\n Copyright (c) 2016 audEERING UG. All rights reserved.\n\n Date: 08.08.16\n Author(s): Gerhard Hagerer\n E-mail:  gh@audeering.com\n\n this is an example plugin showing the energy as number from three bands: treble, middle, bass\n*/\n\nobject Energy extends SmilePlugin {\n\n  // here is the reference to the layout to display values coming from openSMILE\n  // it contains three text fields, one for each band\n  override val layoutId = R.layout.fragment_show\n\n  // this is a filter function, which is applie\n  override def filter(jsn: SmileMessage) = {\n    jsn(\"msgtype\") == \"energy\" && jsn(\"msgname\") == \"energy_act\"\n  }\n\n  // these attributes hold values calculated by updateValues()\n  var bass, middle, treble = 0f\n\n  /**\n    * openSMILE sends information to the app in the form of JSON messages.\n    * These are\n    *\n    * @param msg a JSONObject representing an openSMILE message\n    */\n  override def updateValues(msg: SmileMessage): Unit = {\n    treble = msg.floatData(2)\n    middle = msg.floatData(1)\n    bass   = msg.floatData(0)\n  }\n\n  /**\n    * this method runs on the UI thread. it should take the object attributes saved in\n    * updateValues() and display these on GUI elements.\n    */\n  override def updateUI() {\n    R.id.treble.as[TextView].setText(\"\" + treble)\n    R.id.middle.as[TextView].setText(\"\" + middle)\n    R.id.bass.as[TextView].setText(\"\" + bass)\n  }\n}"
  },
  {
    "path": "progsrc/android-template/app/src/test/java/com/audeering/opensmile/androidtemplate/ExampleUnitTest.java",
    "content": "package com.audeering.opensmile.androidtemplate;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\n/**\n * To work on unit tests, switch the Test Artifact in the Build Variants view.\n */\npublic class ExampleUnitTest {\n    @Test\n    public void addition_isCorrect() throws Exception {\n        assertEquals(4, 2 + 2);\n    }\n}"
  },
  {
    "path": "progsrc/android-template/build.gradle",
    "content": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n    repositories {\n        jcenter()\n    }\n    dependencies {\n        classpath 'com.android.tools.build:gradle:1.3.1'\n        classpath \"jp.leafytree.gradle:gradle-android-scala-plugin:1.4\"\n    }\n}\n\nallprojects {\n    repositories {\n        jcenter()\n        maven { url 'https://maven.google.com' }\n    }\n}\n\ntask clean(type: Delete) {\n    delete rootProject.buildDir\n}\n"
  },
  {
    "path": "progsrc/android-template/gradle/wrapper/gradle-wrapper.properties",
    "content": "#Mon Aug 08 15:02:37 CEST 2016\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-2.2-all.zip\n"
  },
  {
    "path": "progsrc/android-template/gradle.properties",
    "content": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will override*\n# any settings specified in this file.\n\n# For more details on how to configure your build environment visit\n# http://www.gradle.org/docs/current/userguide/build_environment.html\n\n# Specifies the JVM arguments used for the daemon process.\n# The setting is particularly useful for tweaking memory settings.\n# Default value: -Xmx10248m -XX:MaxPermSize=256m\n# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8\n\n# When configured, Gradle will run in incubating parallel mode.\n# This option should only be used with decoupled projects. More details, visit\n# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects\n# org.gradle.parallel=true"
  },
  {
    "path": "progsrc/android-template/gradlew",
    "content": "#!/usr/bin/env bash\n\n##############################################################################\n##\n##  Gradle start up script for UN*X\n##\n##############################################################################\n\n# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nDEFAULT_JVM_OPTS=\"\"\n\nAPP_NAME=\"Gradle\"\nAPP_BASE_NAME=`basename \"$0\"`\n\n# Use the maximum available, or set MAX_FD != -1 to use that value.\nMAX_FD=\"maximum\"\n\nwarn ( ) {\n    echo \"$*\"\n}\n\ndie ( ) {\n    echo\n    echo \"$*\"\n    echo\n    exit 1\n}\n\n# OS specific support (must be 'true' or 'false').\ncygwin=false\nmsys=false\ndarwin=false\ncase \"`uname`\" in\n  CYGWIN* )\n    cygwin=true\n    ;;\n  Darwin* )\n    darwin=true\n    ;;\n  MINGW* )\n    msys=true\n    ;;\nesac\n\n# Attempt to set APP_HOME\n# Resolve links: $0 may be a link\nPRG=\"$0\"\n# Need this for relative symlinks.\nwhile [ -h \"$PRG\" ] ; do\n    ls=`ls -ld \"$PRG\"`\n    link=`expr \"$ls\" : '.*-> \\(.*\\)$'`\n    if expr \"$link\" : '/.*' > /dev/null; then\n        PRG=\"$link\"\n    else\n        PRG=`dirname \"$PRG\"`\"/$link\"\n    fi\ndone\nSAVED=\"`pwd`\"\ncd \"`dirname \\\"$PRG\\\"`/\" >/dev/null\nAPP_HOME=\"`pwd -P`\"\ncd \"$SAVED\" >/dev/null\n\nCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar\n\n# Determine the Java command to use to start the JVM.\nif [ -n \"$JAVA_HOME\" ] ; then\n    if [ -x \"$JAVA_HOME/jre/sh/java\" ] ; then\n        # IBM's JDK on AIX uses strange locations for the executables\n        JAVACMD=\"$JAVA_HOME/jre/sh/java\"\n    else\n        JAVACMD=\"$JAVA_HOME/bin/java\"\n    fi\n    if [ ! -x \"$JAVACMD\" ] ; then\n        die \"ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\n    fi\nelse\n    JAVACMD=\"java\"\n    which java >/dev/null 2>&1 || die \"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\nfi\n\n# Increase the maximum file descriptors if we can.\nif [ \"$cygwin\" = \"false\" -a \"$darwin\" = \"false\" ] ; then\n    MAX_FD_LIMIT=`ulimit -H -n`\n    if [ $? -eq 0 ] ; then\n        if [ \"$MAX_FD\" = \"maximum\" -o \"$MAX_FD\" = \"max\" ] ; then\n            MAX_FD=\"$MAX_FD_LIMIT\"\n        fi\n        ulimit -n $MAX_FD\n        if [ $? -ne 0 ] ; then\n            warn \"Could not set maximum file descriptor limit: $MAX_FD\"\n        fi\n    else\n        warn \"Could not query maximum file descriptor limit: $MAX_FD_LIMIT\"\n    fi\nfi\n\n# For Darwin, add options to specify how the application appears in the dock\nif $darwin; then\n    GRADLE_OPTS=\"$GRADLE_OPTS \\\"-Xdock:name=$APP_NAME\\\" \\\"-Xdock:icon=$APP_HOME/media/gradle.icns\\\"\"\nfi\n\n# For Cygwin, switch paths to Windows format before running java\nif $cygwin ; then\n    APP_HOME=`cygpath --path --mixed \"$APP_HOME\"`\n    CLASSPATH=`cygpath --path --mixed \"$CLASSPATH\"`\n    JAVACMD=`cygpath --unix \"$JAVACMD\"`\n\n    # We build the pattern for arguments to be converted via cygpath\n    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`\n    SEP=\"\"\n    for dir in $ROOTDIRSRAW ; do\n        ROOTDIRS=\"$ROOTDIRS$SEP$dir\"\n        SEP=\"|\"\n    done\n    OURCYGPATTERN=\"(^($ROOTDIRS))\"\n    # Add a user-defined pattern to the cygpath arguments\n    if [ \"$GRADLE_CYGPATTERN\" != \"\" ] ; then\n        OURCYGPATTERN=\"$OURCYGPATTERN|($GRADLE_CYGPATTERN)\"\n    fi\n    # Now convert the arguments - kludge to limit ourselves to /bin/sh\n    i=0\n    for arg in \"$@\" ; do\n        CHECK=`echo \"$arg\"|egrep -c \"$OURCYGPATTERN\" -`\n        CHECK2=`echo \"$arg\"|egrep -c \"^-\"`                                 ### Determine if an option\n\n        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition\n            eval `echo args$i`=`cygpath --path --ignore --mixed \"$arg\"`\n        else\n            eval `echo args$i`=\"\\\"$arg\\\"\"\n        fi\n        i=$((i+1))\n    done\n    case $i in\n        (0) set -- ;;\n        (1) set -- \"$args0\" ;;\n        (2) set -- \"$args0\" \"$args1\" ;;\n        (3) set -- \"$args0\" \"$args1\" \"$args2\" ;;\n        (4) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" ;;\n        (5) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" ;;\n        (6) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" ;;\n        (7) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" ;;\n        (8) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" ;;\n        (9) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" \"$args8\" ;;\n    esac\nfi\n\n# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules\nfunction splitJvmOpts() {\n    JVM_OPTS=(\"$@\")\n}\neval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS\nJVM_OPTS[${#JVM_OPTS[*]}]=\"-Dorg.gradle.appname=$APP_BASE_NAME\"\n\nexec \"$JAVACMD\" \"${JVM_OPTS[@]}\" -classpath \"$CLASSPATH\" org.gradle.wrapper.GradleWrapperMain \"$@\"\n"
  },
  {
    "path": "progsrc/android-template/gradlew.bat",
    "content": "@if \"%DEBUG%\" == \"\" @echo off\r\n@rem ##########################################################################\r\n@rem\r\n@rem  Gradle startup script for Windows\r\n@rem\r\n@rem ##########################################################################\r\n\r\n@rem Set local scope for the variables with windows NT shell\r\nif \"%OS%\"==\"Windows_NT\" setlocal\r\n\r\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\r\nset DEFAULT_JVM_OPTS=\r\n\r\nset DIRNAME=%~dp0\r\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\r\nset APP_BASE_NAME=%~n0\r\nset APP_HOME=%DIRNAME%\r\n\r\n@rem Find java.exe\r\nif defined JAVA_HOME goto findJavaFromJavaHome\r\n\r\nset JAVA_EXE=java.exe\r\n%JAVA_EXE% -version >NUL 2>&1\r\nif \"%ERRORLEVEL%\" == \"0\" goto init\r\n\r\necho.\r\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\r\necho.\r\necho Please set the JAVA_HOME variable in your environment to match the\r\necho location of your Java installation.\r\n\r\ngoto fail\r\n\r\n:findJavaFromJavaHome\r\nset JAVA_HOME=%JAVA_HOME:\"=%\r\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\r\n\r\nif exist \"%JAVA_EXE%\" goto init\r\n\r\necho.\r\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\r\necho.\r\necho Please set the JAVA_HOME variable in your environment to match the\r\necho location of your Java installation.\r\n\r\ngoto fail\r\n\r\n:init\r\n@rem Get command-line arguments, handling Windowz variants\r\n\r\nif not \"%OS%\" == \"Windows_NT\" goto win9xME_args\r\nif \"%@eval[2+2]\" == \"4\" goto 4NT_args\r\n\r\n:win9xME_args\r\n@rem Slurp the command line arguments.\r\nset CMD_LINE_ARGS=\r\nset _SKIP=2\r\n\r\n:win9xME_args_slurp\r\nif \"x%~1\" == \"x\" goto execute\r\n\r\nset CMD_LINE_ARGS=%*\r\ngoto execute\r\n\r\n:4NT_args\r\n@rem Get arguments from the 4NT Shell from JP Software\r\nset CMD_LINE_ARGS=%$\r\n\r\n:execute\r\n@rem Setup the command line\r\n\r\nset CLASSPATH=%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\r\n\r\n@rem Execute Gradle\r\n\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% \"-Dorg.gradle.appname=%APP_BASE_NAME%\" -classpath \"%CLASSPATH%\" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%\r\n\r\n:end\r\n@rem End local scope for the variables with windows NT shell\r\nif \"%ERRORLEVEL%\"==\"0\" goto mainEnd\r\n\r\n:fail\r\nrem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\r\nrem the _cmd.exe /c_ return code!\r\nif  not \"\" == \"%GRADLE_EXIT_CONSOLE%\" exit 1\r\nexit /b 1\r\n\r\n:mainEnd\r\nif \"%OS%\"==\"Windows_NT\" endlocal\r\n\r\n:omega\r\n"
  },
  {
    "path": "progsrc/android-template/settings.gradle",
    "content": "include ':app'\n"
  },
  {
    "path": "progsrc/openSMILEbatchGUI/Form1.Designer.cs",
    "content": "﻿namespace openSMILEbatchGUI\r\n{\r\n    partial class Form1\r\n    {\r\n        /// <summary>\r\n        /// Required designer variable.\r\n        /// </summary>\r\n        private System.ComponentModel.IContainer components = null;\r\n\r\n        /// <summary>\r\n        /// Clean up any resources being used.\r\n        /// </summary>\r\n        /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>\r\n        protected override void Dispose(bool disposing)\r\n        {\r\n            if (disposing && (components != null))\r\n            {\r\n                components.Dispose();\r\n            }\r\n            base.Dispose(disposing);\r\n        }\r\n\r\n        #region Windows Form Designer generated code\r\n\r\n        /// <summary>\r\n        /// Required method for Designer support - do not modify\r\n        /// the contents of this method with the code editor.\r\n        /// </summary>\r\n        private void InitializeComponent()\r\n        {\r\n            this.button1 = new System.Windows.Forms.Button();\r\n            this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();\r\n            this.fileListBox = new System.Windows.Forms.CheckedListBox();\r\n            this.progressBar1 = new System.Windows.Forms.ProgressBar();\r\n            this.groupBox1 = new System.Windows.Forms.GroupBox();\r\n            this.button12 = new System.Windows.Forms.Button();\r\n            this.button11 = new System.Windows.Forms.Button();\r\n            this.label9 = new System.Windows.Forms.Label();\r\n            this.labelFile = new System.Windows.Forms.TextBox();\r\n            this.arffAppend = new System.Windows.Forms.CheckBox();\r\n            this.csvAppend = new System.Windows.Forms.CheckBox();\r\n            this.lldCsvAppend = new System.Windows.Forms.CheckBox();\r\n            this.button10 = new System.Windows.Forms.Button();\r\n            this.label5 = new System.Windows.Forms.Label();\r\n            this.workDirectory = new System.Windows.Forms.TextBox();\r\n            this.button9 = new System.Windows.Forms.Button();\r\n            this.csvOutName = new System.Windows.Forms.TextBox();\r\n            this.button8 = new System.Windows.Forms.Button();\r\n            this.lldCsvOutName = new System.Windows.Forms.TextBox();\r\n            this.button7 = new System.Windows.Forms.Button();\r\n            this.label4 = new System.Windows.Forms.Label();\r\n            this.arffOutName = new System.Windows.Forms.TextBox();\r\n            this.label3 = new System.Windows.Forms.Label();\r\n            this.configurations = new System.Windows.Forms.ComboBox();\r\n            this.haveCsvOut = new System.Windows.Forms.CheckBox();\r\n            this.haveArffOut = new System.Windows.Forms.CheckBox();\r\n            this.haveLldCsvOut = new System.Windows.Forms.CheckBox();\r\n            this.button2 = new System.Windows.Forms.Button();\r\n            this.selectedFolder = new System.Windows.Forms.TextBox();\r\n            this.label1 = new System.Windows.Forms.Label();\r\n            this.label2 = new System.Windows.Forms.Label();\r\n            this.groupBox2 = new System.Windows.Forms.GroupBox();\r\n            this.logBox = new System.Windows.Forms.TextBox();\r\n            this.label6 = new System.Windows.Forms.Label();\r\n            this.progressLabel = new System.Windows.Forms.Label();\r\n            this.button5 = new System.Windows.Forms.Button();\r\n            this.button6 = new System.Windows.Forms.Button();\r\n            this.button4 = new System.Windows.Forms.Button();\r\n            this.button3 = new System.Windows.Forms.Button();\r\n            this.label7 = new System.Windows.Forms.Label();\r\n            this.fileExtensionFilter = new System.Windows.Forms.TextBox();\r\n            this.label8 = new System.Windows.Forms.Label();\r\n            this.saveFileDialogArff = new System.Windows.Forms.SaveFileDialog();\r\n            this.saveFileDialogCsv = new System.Windows.Forms.SaveFileDialog();\r\n            this.saveFileDialogLldCsv = new System.Windows.Forms.SaveFileDialog();\r\n            this.folderBrowserDialog2 = new System.Windows.Forms.FolderBrowserDialog();\r\n            this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();\r\n            this.button13 = new System.Windows.Forms.Button();\r\n            this.groupBox1.SuspendLayout();\r\n            this.groupBox2.SuspendLayout();\r\n            this.SuspendLayout();\r\n            // \r\n            // button1\r\n            // \r\n            this.button1.Enabled = false;\r\n            this.button1.Font = new System.Drawing.Font(\"Microsoft Sans Serif\", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r\n            this.button1.Location = new System.Drawing.Point(466, 378);\r\n            this.button1.Name = \"button1\";\r\n            this.button1.Size = new System.Drawing.Size(75, 39);\r\n            this.button1.TabIndex = 0;\r\n            this.button1.Text = \"3. Start!\";\r\n            this.button1.UseVisualStyleBackColor = true;\r\n            this.button1.Click += new System.EventHandler(this.button1_Click);\r\n            // \r\n            // fileListBox\r\n            // \r\n            this.fileListBox.FormattingEnabled = true;\r\n            this.fileListBox.HorizontalScrollbar = true;\r\n            this.fileListBox.Location = new System.Drawing.Point(15, 94);\r\n            this.fileListBox.Name = \"fileListBox\";\r\n            this.fileListBox.Size = new System.Drawing.Size(426, 409);\r\n            this.fileListBox.TabIndex = 1;\r\n            this.fileListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.fileListBox_ItemCheck);\r\n            this.fileListBox.SelectedIndexChanged += new System.EventHandler(this.checkedListBox1_SelectedIndexChanged);\r\n            // \r\n            // progressBar1\r\n            // \r\n            this.progressBar1.Location = new System.Drawing.Point(25, 42);\r\n            this.progressBar1.Name = \"progressBar1\";\r\n            this.progressBar1.Size = new System.Drawing.Size(373, 23);\r\n            this.progressBar1.TabIndex = 2;\r\n            // \r\n            // groupBox1\r\n            // \r\n            this.groupBox1.Controls.Add(this.button13);\r\n            this.groupBox1.Controls.Add(this.button12);\r\n            this.groupBox1.Controls.Add(this.button11);\r\n            this.groupBox1.Controls.Add(this.label9);\r\n            this.groupBox1.Controls.Add(this.labelFile);\r\n            this.groupBox1.Controls.Add(this.arffAppend);\r\n            this.groupBox1.Controls.Add(this.csvAppend);\r\n            this.groupBox1.Controls.Add(this.lldCsvAppend);\r\n            this.groupBox1.Controls.Add(this.button10);\r\n            this.groupBox1.Controls.Add(this.label5);\r\n            this.groupBox1.Controls.Add(this.workDirectory);\r\n            this.groupBox1.Controls.Add(this.button9);\r\n            this.groupBox1.Controls.Add(this.csvOutName);\r\n            this.groupBox1.Controls.Add(this.button8);\r\n            this.groupBox1.Controls.Add(this.lldCsvOutName);\r\n            this.groupBox1.Controls.Add(this.button7);\r\n            this.groupBox1.Controls.Add(this.label4);\r\n            this.groupBox1.Controls.Add(this.arffOutName);\r\n            this.groupBox1.Controls.Add(this.label3);\r\n            this.groupBox1.Controls.Add(this.configurations);\r\n            this.groupBox1.Controls.Add(this.haveCsvOut);\r\n            this.groupBox1.Controls.Add(this.haveArffOut);\r\n            this.groupBox1.Controls.Add(this.haveLldCsvOut);\r\n            this.groupBox1.Location = new System.Drawing.Point(466, 29);\r\n            this.groupBox1.Name = \"groupBox1\";\r\n            this.groupBox1.Size = new System.Drawing.Size(506, 274);\r\n            this.groupBox1.TabIndex = 4;\r\n            this.groupBox1.TabStop = false;\r\n            this.groupBox1.Text = \"Options\";\r\n            // \r\n            // button12\r\n            // \r\n            this.button12.Location = new System.Drawing.Point(406, 222);\r\n            this.button12.Name = \"button12\";\r\n            this.button12.Size = new System.Drawing.Size(53, 23);\r\n            this.button12.TabIndex = 30;\r\n            this.button12.Text = \"Info...\";\r\n            this.button12.UseVisualStyleBackColor = true;\r\n            this.button12.Click += new System.EventHandler(this.button12_Click);\r\n            // \r\n            // button11\r\n            // \r\n            this.button11.Location = new System.Drawing.Point(465, 247);\r\n            this.button11.Name = \"button11\";\r\n            this.button11.Size = new System.Drawing.Size(34, 21);\r\n            this.button11.TabIndex = 29;\r\n            this.button11.Text = \"...\";\r\n            this.button11.UseVisualStyleBackColor = true;\r\n            this.button11.Click += new System.EventHandler(this.button11_Click_1);\r\n            // \r\n            // label9\r\n            // \r\n            this.label9.AutoSize = true;\r\n            this.label9.Location = new System.Drawing.Point(28, 232);\r\n            this.label9.Name = \"label9\";\r\n            this.label9.Size = new System.Drawing.Size(372, 13);\r\n            this.label9.TabIndex = 28;\r\n            this.label9.Text = \"File selection list and labels (csv, with first column, filenames, and then label\" +\r\n    \"s):\";\r\n            // \r\n            // labelFile\r\n            // \r\n            this.labelFile.Location = new System.Drawing.Point(24, 248);\r\n            this.labelFile.Name = \"labelFile\";\r\n            this.labelFile.Size = new System.Drawing.Size(435, 20);\r\n            this.labelFile.TabIndex = 27;\r\n            this.labelFile.TextChanged += new System.EventHandler(this.labelFile_TextChanged);\r\n            // \r\n            // arffAppend\r\n            // \r\n            this.arffAppend.AutoSize = true;\r\n            this.arffAppend.Checked = true;\r\n            this.arffAppend.CheckState = System.Windows.Forms.CheckState.Checked;\r\n            this.arffAppend.Location = new System.Drawing.Point(334, 195);\r\n            this.arffAppend.Name = \"arffAppend\";\r\n            this.arffAppend.Size = new System.Drawing.Size(167, 17);\r\n            this.arffAppend.TabIndex = 26;\r\n            this.arffAppend.Text = \"Append to Functionals Arff file\";\r\n            this.arffAppend.UseVisualStyleBackColor = true;\r\n            // \r\n            // csvAppend\r\n            // \r\n            this.csvAppend.AutoSize = true;\r\n            this.csvAppend.Checked = true;\r\n            this.csvAppend.CheckState = System.Windows.Forms.CheckState.Checked;\r\n            this.csvAppend.Location = new System.Drawing.Point(164, 195);\r\n            this.csvAppend.Name = \"csvAppend\";\r\n            this.csvAppend.Size = new System.Drawing.Size(172, 17);\r\n            this.csvAppend.TabIndex = 25;\r\n            this.csvAppend.Text = \"Append to Functionals CSV file\";\r\n            this.csvAppend.UseVisualStyleBackColor = true;\r\n            // \r\n            // lldCsvAppend\r\n            // \r\n            this.lldCsvAppend.AutoSize = true;\r\n            this.lldCsvAppend.Checked = true;\r\n            this.lldCsvAppend.CheckState = System.Windows.Forms.CheckState.Checked;\r\n            this.lldCsvAppend.Location = new System.Drawing.Point(24, 195);\r\n            this.lldCsvAppend.Name = \"lldCsvAppend\";\r\n            this.lldCsvAppend.Size = new System.Drawing.Size(138, 17);\r\n            this.lldCsvAppend.TabIndex = 24;\r\n            this.lldCsvAppend.Text = \"Append to LLD CSV file\";\r\n            this.lldCsvAppend.UseVisualStyleBackColor = true;\r\n            // \r\n            // button10\r\n            // \r\n            this.button10.Location = new System.Drawing.Point(389, 45);\r\n            this.button10.Name = \"button10\";\r\n            this.button10.Size = new System.Drawing.Size(34, 21);\r\n            this.button10.TabIndex = 23;\r\n            this.button10.Text = \"...\";\r\n            this.button10.UseVisualStyleBackColor = true;\r\n            this.button10.Click += new System.EventHandler(this.button10_Click);\r\n            // \r\n            // label5\r\n            // \r\n            this.label5.AutoSize = true;\r\n            this.label5.Font = new System.Drawing.Font(\"Microsoft Sans Serif\", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r\n            this.label5.Location = new System.Drawing.Point(27, 49);\r\n            this.label5.Name = \"label5\";\r\n            this.label5.Size = new System.Drawing.Size(109, 13);\r\n            this.label5.TabIndex = 22;\r\n            this.label5.Text = \"1. Work directory:\";\r\n            this.label5.Click += new System.EventHandler(this.label5_Click);\r\n            // \r\n            // workDirectory\r\n            // \r\n            this.workDirectory.Location = new System.Drawing.Point(142, 46);\r\n            this.workDirectory.Name = \"workDirectory\";\r\n            this.workDirectory.Size = new System.Drawing.Size(241, 20);\r\n            this.workDirectory.TabIndex = 21;\r\n            this.workDirectory.Text = \"..\\\\..\\\\..\\\\..\\\\\";\r\n            this.workDirectory.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;\r\n            this.workDirectory.TextChanged += new System.EventHandler(this.workDirectory_TextChanged);\r\n            // \r\n            // button9\r\n            // \r\n            this.button9.Location = new System.Drawing.Point(465, 157);\r\n            this.button9.Name = \"button9\";\r\n            this.button9.Size = new System.Drawing.Size(34, 21);\r\n            this.button9.TabIndex = 20;\r\n            this.button9.Text = \"...\";\r\n            this.button9.UseVisualStyleBackColor = true;\r\n            this.button9.Click += new System.EventHandler(this.button9_Click);\r\n            // \r\n            // csvOutName\r\n            // \r\n            this.csvOutName.Location = new System.Drawing.Point(150, 158);\r\n            this.csvOutName.Name = \"csvOutName\";\r\n            this.csvOutName.Size = new System.Drawing.Size(309, 20);\r\n            this.csvOutName.TabIndex = 19;\r\n            // \r\n            // button8\r\n            // \r\n            this.button8.Location = new System.Drawing.Point(465, 135);\r\n            this.button8.Name = \"button8\";\r\n            this.button8.Size = new System.Drawing.Size(34, 21);\r\n            this.button8.TabIndex = 18;\r\n            this.button8.Text = \"...\";\r\n            this.button8.UseVisualStyleBackColor = true;\r\n            this.button8.Click += new System.EventHandler(this.button8_Click);\r\n            // \r\n            // lldCsvOutName\r\n            // \r\n            this.lldCsvOutName.Location = new System.Drawing.Point(150, 136);\r\n            this.lldCsvOutName.Name = \"lldCsvOutName\";\r\n            this.lldCsvOutName.Size = new System.Drawing.Size(309, 20);\r\n            this.lldCsvOutName.TabIndex = 17;\r\n            // \r\n            // button7\r\n            // \r\n            this.button7.Location = new System.Drawing.Point(465, 112);\r\n            this.button7.Name = \"button7\";\r\n            this.button7.Size = new System.Drawing.Size(34, 21);\r\n            this.button7.TabIndex = 16;\r\n            this.button7.Text = \"...\";\r\n            this.button7.UseVisualStyleBackColor = true;\r\n            this.button7.Click += new System.EventHandler(this.button7_Click);\r\n            // \r\n            // label4\r\n            // \r\n            this.label4.AutoSize = true;\r\n            this.label4.Location = new System.Drawing.Point(32, 97);\r\n            this.label4.Name = \"label4\";\r\n            this.label4.Size = new System.Drawing.Size(427, 13);\r\n            this.label4.TabIndex = 7;\r\n            this.label4.Text = \"** The following options are only available if supported by the selected configur\" +\r\n    \"ation file **\";\r\n            // \r\n            // arffOutName\r\n            // \r\n            this.arffOutName.Location = new System.Drawing.Point(150, 113);\r\n            this.arffOutName.Name = \"arffOutName\";\r\n            this.arffOutName.Size = new System.Drawing.Size(309, 20);\r\n            this.arffOutName.TabIndex = 5;\r\n            // \r\n            // label3\r\n            // \r\n            this.label3.AutoSize = true;\r\n            this.label3.Location = new System.Drawing.Point(21, 24);\r\n            this.label3.Name = \"label3\";\r\n            this.label3.Size = new System.Drawing.Size(146, 13);\r\n            this.label3.TabIndex = 4;\r\n            this.label3.Text = \"openSMILE configuration file:\";\r\n            // \r\n            // configurations\r\n            // \r\n            this.configurations.FormattingEnabled = true;\r\n            this.configurations.Location = new System.Drawing.Point(175, 19);\r\n            this.configurations.Name = \"configurations\";\r\n            this.configurations.Size = new System.Drawing.Size(324, 21);\r\n            this.configurations.TabIndex = 3;\r\n            // \r\n            // haveCsvOut\r\n            // \r\n            this.haveCsvOut.AutoSize = true;\r\n            this.haveCsvOut.Location = new System.Drawing.Point(24, 161);\r\n            this.haveCsvOut.Name = \"haveCsvOut\";\r\n            this.haveCsvOut.Size = new System.Drawing.Size(97, 17);\r\n            this.haveCsvOut.TabIndex = 2;\r\n            this.haveCsvOut.Text = \"Save CSV File:\";\r\n            this.haveCsvOut.UseVisualStyleBackColor = true;\r\n            // \r\n            // haveArffOut\r\n            // \r\n            this.haveArffOut.AutoSize = true;\r\n            this.haveArffOut.Checked = true;\r\n            this.haveArffOut.CheckState = System.Windows.Forms.CheckState.Checked;\r\n            this.haveArffOut.Location = new System.Drawing.Point(24, 116);\r\n            this.haveArffOut.Name = \"haveArffOut\";\r\n            this.haveArffOut.Size = new System.Drawing.Size(102, 17);\r\n            this.haveArffOut.TabIndex = 1;\r\n            this.haveArffOut.Text = \"Output file (Arff):\";\r\n            this.haveArffOut.UseVisualStyleBackColor = true;\r\n            // \r\n            // haveLldCsvOut\r\n            // \r\n            this.haveLldCsvOut.AutoSize = true;\r\n            this.haveLldCsvOut.Location = new System.Drawing.Point(24, 139);\r\n            this.haveLldCsvOut.Name = \"haveLldCsvOut\";\r\n            this.haveLldCsvOut.Size = new System.Drawing.Size(120, 17);\r\n            this.haveLldCsvOut.TabIndex = 0;\r\n            this.haveLldCsvOut.Text = \"Save LLD CSV File:\";\r\n            this.haveLldCsvOut.UseVisualStyleBackColor = true;\r\n            this.haveLldCsvOut.CheckedChanged += new System.EventHandler(this.haveLldCsvOut_CheckedChanged);\r\n            // \r\n            // button2\r\n            // \r\n            this.button2.Location = new System.Drawing.Point(254, 6);\r\n            this.button2.Name = \"button2\";\r\n            this.button2.Size = new System.Drawing.Size(187, 20);\r\n            this.button2.TabIndex = 5;\r\n            this.button2.Text = \"Select folder to process ...\";\r\n            this.button2.UseVisualStyleBackColor = true;\r\n            this.button2.Click += new System.EventHandler(this.button2_Click);\r\n            // \r\n            // selectedFolder\r\n            // \r\n            this.selectedFolder.Location = new System.Drawing.Point(15, 29);\r\n            this.selectedFolder.Name = \"selectedFolder\";\r\n            this.selectedFolder.Size = new System.Drawing.Size(426, 20);\r\n            this.selectedFolder.TabIndex = 8;\r\n            this.selectedFolder.Text = \"..\\\\..\\\\..\\\\..\\\\example-audio\";\r\n            this.selectedFolder.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;\r\n            // \r\n            // label1\r\n            // \r\n            this.label1.AutoSize = true;\r\n            this.label1.Location = new System.Drawing.Point(12, 13);\r\n            this.label1.Name = \"label1\";\r\n            this.label1.Size = new System.Drawing.Size(163, 13);\r\n            this.label1.TabIndex = 9;\r\n            this.label1.Text = \"Folder with audio files to process:\";\r\n            // \r\n            // label2\r\n            // \r\n            this.label2.AutoSize = true;\r\n            this.label2.Location = new System.Drawing.Point(12, 75);\r\n            this.label2.Name = \"label2\";\r\n            this.label2.Size = new System.Drawing.Size(102, 13);\r\n            this.label2.TabIndex = 10;\r\n            this.label2.Text = \"List of selected files:\";\r\n            // \r\n            // groupBox2\r\n            // \r\n            this.groupBox2.Controls.Add(this.logBox);\r\n            this.groupBox2.Controls.Add(this.label6);\r\n            this.groupBox2.Controls.Add(this.progressLabel);\r\n            this.groupBox2.Controls.Add(this.progressBar1);\r\n            this.groupBox2.Location = new System.Drawing.Point(553, 323);\r\n            this.groupBox2.Name = \"groupBox2\";\r\n            this.groupBox2.Size = new System.Drawing.Size(419, 229);\r\n            this.groupBox2.TabIndex = 11;\r\n            this.groupBox2.TabStop = false;\r\n            this.groupBox2.Text = \"Job progress\";\r\n            // \r\n            // logBox\r\n            // \r\n            this.logBox.Location = new System.Drawing.Point(25, 97);\r\n            this.logBox.Multiline = true;\r\n            this.logBox.Name = \"logBox\";\r\n            this.logBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;\r\n            this.logBox.Size = new System.Drawing.Size(373, 115);\r\n            this.logBox.TabIndex = 7;\r\n            // \r\n            // label6\r\n            // \r\n            this.label6.AutoSize = true;\r\n            this.label6.Location = new System.Drawing.Point(22, 81);\r\n            this.label6.Name = \"label6\";\r\n            this.label6.Size = new System.Drawing.Size(227, 13);\r\n            this.label6.TabIndex = 6;\r\n            this.label6.Text = \"openSMILE console output and log messages:\";\r\n            // \r\n            // progressLabel\r\n            // \r\n            this.progressLabel.AutoSize = true;\r\n            this.progressLabel.Location = new System.Drawing.Point(22, 26);\r\n            this.progressLabel.Name = \"progressLabel\";\r\n            this.progressLabel.Size = new System.Drawing.Size(0, 13);\r\n            this.progressLabel.TabIndex = 5;\r\n            // \r\n            // button5\r\n            // \r\n            this.button5.Enabled = false;\r\n            this.button5.Location = new System.Drawing.Point(466, 453);\r\n            this.button5.Name = \"button5\";\r\n            this.button5.Size = new System.Drawing.Size(75, 23);\r\n            this.button5.TabIndex = 12;\r\n            this.button5.Text = \"Cancel\";\r\n            this.button5.UseVisualStyleBackColor = true;\r\n            this.button5.Click += new System.EventHandler(this.button5_Click);\r\n            // \r\n            // button6\r\n            // \r\n            this.button6.Font = new System.Drawing.Font(\"Microsoft Sans Serif\", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r\n            this.button6.Location = new System.Drawing.Point(299, 67);\r\n            this.button6.Name = \"button6\";\r\n            this.button6.Size = new System.Drawing.Size(142, 23);\r\n            this.button6.TabIndex = 13;\r\n            this.button6.Text = \"2. Refresh Audio Files\";\r\n            this.button6.UseVisualStyleBackColor = true;\r\n            this.button6.Click += new System.EventHandler(this.button6_Click);\r\n            // \r\n            // button4\r\n            // \r\n            this.button4.Location = new System.Drawing.Point(313, 531);\r\n            this.button4.Name = \"button4\";\r\n            this.button4.Size = new System.Drawing.Size(104, 21);\r\n            this.button4.TabIndex = 15;\r\n            this.button4.Text = \"Select none\";\r\n            this.button4.UseVisualStyleBackColor = true;\r\n            this.button4.Click += new System.EventHandler(this.button4_Click_1);\r\n            // \r\n            // button3\r\n            // \r\n            this.button3.Location = new System.Drawing.Point(25, 531);\r\n            this.button3.Name = \"button3\";\r\n            this.button3.Size = new System.Drawing.Size(103, 21);\r\n            this.button3.TabIndex = 14;\r\n            this.button3.Text = \"Select all\";\r\n            this.button3.UseVisualStyleBackColor = true;\r\n            this.button3.Click += new System.EventHandler(this.button3_Click);\r\n            // \r\n            // label7\r\n            // \r\n            this.label7.AutoSize = true;\r\n            this.label7.Location = new System.Drawing.Point(12, 52);\r\n            this.label7.Name = \"label7\";\r\n            this.label7.Size = new System.Drawing.Size(96, 13);\r\n            this.label7.TabIndex = 17;\r\n            this.label7.Text = \"File extension filter:\";\r\n            // \r\n            // fileExtensionFilter\r\n            // \r\n            this.fileExtensionFilter.Location = new System.Drawing.Point(114, 49);\r\n            this.fileExtensionFilter.Name = \"fileExtensionFilter\";\r\n            this.fileExtensionFilter.Size = new System.Drawing.Size(61, 20);\r\n            this.fileExtensionFilter.TabIndex = 18;\r\n            this.fileExtensionFilter.Text = \"*.wav\";\r\n            // \r\n            // label8\r\n            // \r\n            this.label8.AutoSize = true;\r\n            this.label8.Location = new System.Drawing.Point(120, 75);\r\n            this.label8.Name = \"label8\";\r\n            this.label8.Size = new System.Drawing.Size(150, 13);\r\n            this.label8.TabIndex = 19;\r\n            this.label8.Text = \"Use double click to (de-)select\";\r\n            // \r\n            // openFileDialog1\r\n            // \r\n            this.openFileDialog1.DefaultExt = \"csv\";\r\n            this.openFileDialog1.FileName = \"openFileDialog1\";\r\n            // \r\n            // button13\r\n            // \r\n            this.button13.Font = new System.Drawing.Font(\"Microsoft Sans Serif\", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r\n            this.button13.Location = new System.Drawing.Point(429, 45);\r\n            this.button13.Name = \"button13\";\r\n            this.button13.Size = new System.Drawing.Size(77, 21);\r\n            this.button13.TabIndex = 31;\r\n            this.button13.Text = \"Refresh!\";\r\n            this.button13.UseVisualStyleBackColor = true;\r\n            this.button13.Click += new System.EventHandler(this.button13_Click);\r\n            // \r\n            // Form1\r\n            // \r\n            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\r\n            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r\n            this.ClientSize = new System.Drawing.Size(978, 564);\r\n            this.Controls.Add(this.label8);\r\n            this.Controls.Add(this.fileExtensionFilter);\r\n            this.Controls.Add(this.label7);\r\n            this.Controls.Add(this.button4);\r\n            this.Controls.Add(this.button3);\r\n            this.Controls.Add(this.button6);\r\n            this.Controls.Add(this.button5);\r\n            this.Controls.Add(this.groupBox2);\r\n            this.Controls.Add(this.label2);\r\n            this.Controls.Add(this.label1);\r\n            this.Controls.Add(this.selectedFolder);\r\n            this.Controls.Add(this.button2);\r\n            this.Controls.Add(this.groupBox1);\r\n            this.Controls.Add(this.fileListBox);\r\n            this.Controls.Add(this.button1);\r\n            this.Name = \"Form1\";\r\n            this.Text = \"openSMILE batch processing GUI\";\r\n            this.Load += new System.EventHandler(this.Form1_Load);\r\n            this.groupBox1.ResumeLayout(false);\r\n            this.groupBox1.PerformLayout();\r\n            this.groupBox2.ResumeLayout(false);\r\n            this.groupBox2.PerformLayout();\r\n            this.ResumeLayout(false);\r\n            this.PerformLayout();\r\n\r\n        }\r\n\r\n        #endregion\r\n\r\n        private System.Windows.Forms.Button button1;\r\n        private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;\r\n        private System.Windows.Forms.CheckedListBox fileListBox;\r\n        private System.Windows.Forms.ProgressBar progressBar1;\r\n        private System.Windows.Forms.GroupBox groupBox1;\r\n        private System.Windows.Forms.CheckBox haveCsvOut;\r\n        private System.Windows.Forms.CheckBox haveArffOut;\r\n        private System.Windows.Forms.CheckBox haveLldCsvOut;\r\n        private System.Windows.Forms.Button button2;\r\n        private System.Windows.Forms.TextBox selectedFolder;\r\n        private System.Windows.Forms.Label label1;\r\n        private System.Windows.Forms.Label label2;\r\n        private System.Windows.Forms.GroupBox groupBox2;\r\n        private System.Windows.Forms.Label progressLabel;\r\n        private System.Windows.Forms.Button button5;\r\n        private System.Windows.Forms.Button button6;\r\n        private System.Windows.Forms.Button button4;\r\n        private System.Windows.Forms.Button button3;\r\n        private System.Windows.Forms.Button button9;\r\n        private System.Windows.Forms.TextBox csvOutName;\r\n        private System.Windows.Forms.Button button8;\r\n        private System.Windows.Forms.TextBox lldCsvOutName;\r\n        private System.Windows.Forms.Button button7;\r\n        private System.Windows.Forms.Label label4;\r\n        private System.Windows.Forms.TextBox arffOutName;\r\n        private System.Windows.Forms.Label label3;\r\n        private System.Windows.Forms.ComboBox configurations;\r\n        private System.Windows.Forms.Button button10;\r\n        private System.Windows.Forms.Label label5;\r\n        private System.Windows.Forms.TextBox workDirectory;\r\n        private System.Windows.Forms.Label label6;\r\n        private System.Windows.Forms.CheckBox arffAppend;\r\n        private System.Windows.Forms.CheckBox csvAppend;\r\n        private System.Windows.Forms.CheckBox lldCsvAppend;\r\n        private System.Windows.Forms.Label label7;\r\n        private System.Windows.Forms.TextBox fileExtensionFilter;\r\n        private System.Windows.Forms.Label label8;\r\n        private System.Windows.Forms.SaveFileDialog saveFileDialogArff;\r\n        private System.Windows.Forms.SaveFileDialog saveFileDialogCsv;\r\n        private System.Windows.Forms.SaveFileDialog saveFileDialogLldCsv;\r\n        private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog2;\r\n        private System.Windows.Forms.TextBox logBox;\r\n        private System.Windows.Forms.Label label9;\r\n        private System.Windows.Forms.TextBox labelFile;\r\n        private System.Windows.Forms.Button button11;\r\n        private System.Windows.Forms.OpenFileDialog openFileDialog1;\r\n        private System.Windows.Forms.Button button12;\r\n        private System.Windows.Forms.Button button13;\r\n    }\r\n}\r\n\r\n"
  },
  {
    "path": "progsrc/openSMILEbatchGUI/Form1.cs",
    "content": "﻿using System;\r\nusing System.Collections.Generic;\r\nusing System.ComponentModel;\r\nusing System.Data;\r\nusing System.Drawing;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Windows.Forms;\r\nusing System.Threading;\r\nusing System.IO;\r\nusing System.Diagnostics;\r\n\r\nnamespace openSMILEbatchGUI\r\n{\r\n    public partial class Form1 : Form\r\n    {\r\n        public Form1()\r\n        {\r\n            InitializeComponent();\r\n        }\r\n\r\n        private void button4_Click(object sender, EventArgs e)\r\n        {\r\n\r\n        }\r\n\r\n        private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)\r\n        {\r\n\r\n        }\r\n\r\n        private void buildSelFileListFromFolder()\r\n        {\r\n            fileListBox.Items.Clear();\r\n            // iterate through directory\r\n            if (System.IO.Directory.Exists(selectedFolder.Text))\r\n            {\r\n                string[] files = System.IO.Directory.GetFiles(@selectedFolder.Text, fileExtensionFilter.Text);\r\n                foreach (string f in files)\r\n                {\r\n                    string fname = System.IO.Path.GetFileName(f);\r\n                    fileListBox.Items.Add(fname);\r\n                }\r\n            }\r\n            selectAllFiles(true);\r\n        }\r\n\r\n        private void button2_Click(object sender, EventArgs e)\r\n        {\r\n            if (selectedFolder.Text != \"\")\r\n            {\r\n                folderBrowserDialog1.SelectedPath = selectedFolder.Text;\r\n            }\r\n            else\r\n            {\r\n                folderBrowserDialog1.SelectedPath = System.IO.Directory.GetCurrentDirectory();\r\n            }\r\n            folderBrowserDialog1.RootFolder = Environment.SpecialFolder.MyComputer;\r\n            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)\r\n            {\r\n                selectedFolder.Text = folderBrowserDialog1.SelectedPath;\r\n                buildSelFileListFromFolder();\r\n            }\r\n        }\r\n\r\n        private void Form1_Load(object sender, EventArgs e)\r\n        {\r\n            workDirectory.Text = System.IO.Path.GetFullPath(\".\"); // System.IO.Directory.GetCurrentDirectory();\r\n            refreshConfigFiles();\r\n            MessageBox.Show(\"Please set work directory to the root (trunk) directory of the openSMILE package!\");\r\n        }\r\n\r\n        private void refreshConfigFiles()\r\n        {\r\n            string cd = workDirectory.Text + \"\\\\config\";\r\n            if (System.IO.Directory.Exists(cd))\r\n            {\r\n                string[] files = System.IO.Directory.GetFiles(@cd, \"*.conf\");\r\n                string defaultConfig = \"\";\r\n                foreach (string f in files)\r\n                {\r\n                    string fname = System.IO.Path.GetFileName(f);\r\n                    configurations.Items.Add(fname);\r\n                    if (fname == \"GenevaExtended.conf\")\r\n                    {\r\n                        defaultConfig = fname;\r\n                    }\r\n                    if (defaultConfig == \"\" && fname == \"IS09_emotion.conf\")\r\n                    {\r\n                        defaultConfig = fname;\r\n                    }\r\n                }\r\n                // default: Geneva Extended, if available, else IS09 emotion\r\n                configurations.Text = defaultConfig;\r\n            }\r\n            else\r\n            {\r\n                //MessageBox.Show(\"Directory with openSMILE configuration files (\" + cd + \") does not exist. Please change the 'Work directory' setting accordingly!\");\r\n            }\r\n        }\r\n\r\n        private void button11_Click(object sender, EventArgs e)\r\n        {\r\n            refreshConfigFiles();\r\n        }\r\n\r\n        private void button6_Click(object sender, EventArgs e)\r\n        {\r\n            selectedFolder.Text = System.IO.Path.GetFullPath(selectedFolder.Text);\r\n            buildSelFileListFromFolder();\r\n        }\r\n\r\n        private void selectAllFiles(bool state = true)\r\n        {\r\n            for (int i = 0; i < fileListBox.Items.Count; i++)\r\n            {\r\n                fileListBox.SetItemChecked(i, state);\r\n            }\r\n        }\r\n\r\n        private void button3_Click(object sender, EventArgs e)\r\n        {\r\n            selectAllFiles(true);    \r\n        }\r\n\r\n        private void button4_Click_1(object sender, EventArgs e)\r\n        {\r\n            selectAllFiles(false);    \r\n        }\r\n\r\n        private void initProgress(int N)\r\n        {\r\n            progressBar1.Maximum = N;\r\n            progressBar1.Minimum = 0;\r\n            progressBar1.Step = 1;\r\n            progressBar1.Value = 0;\r\n        }\r\n\r\n        private void logProgress(int i, int N)\r\n        {\r\n            progressBar1.Value = i;\r\n            progressLabel.Text = \"Processing file \" + i.ToString() + \" of \" + N.ToString() + \" ...\";\r\n        }\r\n\r\n        private void logOutput(string line)\r\n        {\r\n            logBox.AppendText(line + \"\\n\");\r\n        }\r\n\r\n        private int runSmileBinary(string workpath, string binary, string options)\r\n        {\r\n            try\r\n            {\r\n                // run opensmile\r\n                Process p = new System.Diagnostics.Process();\r\n                p.EnableRaisingEvents = true;\r\n//                p.StartInfo.FileName = smilePath;\r\n                //p.StartInfo.Arguments = smileArgs;\r\n                p.StartInfo.FileName = \"wrapper.exe\";\r\n                p.StartInfo.Arguments = binary + \" \" + options;\r\n                p.StartInfo.WorkingDirectory = workpath;\r\n\r\n                p.StartInfo.UseShellExecute = false;\r\n                p.StartInfo.CreateNoWindow = true;\r\n                p.StartInfo.RedirectStandardOutput = true;\r\n                p.StartInfo.RedirectStandardError = true;\r\n                //p.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived);\r\n                p.ErrorDataReceived += new DataReceivedEventHandler(p_ErrorDataReceived);\r\n                p.Exited += new EventHandler(p_Exited);\r\n\r\n                // delete old log file\r\n                if (System.IO.File.Exists(logfile))\r\n                {\r\n                    System.IO.File.Delete(logfile);\r\n                }\r\n                if (p.Start())\r\n                {\r\n                    return p.Id;\r\n                }\r\n                else\r\n                {\r\n                    return 0;\r\n                }\r\n            }\r\n            catch (Win32Exception e)\r\n            {\r\n                MessageBox.Show(\"Could not run wrapper.exe to invoke \" + binary + \": \" + e.Message, \"Error\", MessageBoxButtons.OK, MessageBoxIcon.Error);\r\n                return 0;\r\n            }\r\n        }\r\n\r\n        List<string> filesToProcessQueue;\r\n        int nextFileIndex = 0;\r\n        int fileSelCount = 0;\r\n        string logfile = \"\";\r\n\r\n        private void p_ErrorDataReceived(object sendingProcess,\r\n            DataReceivedEventArgs errLine)\r\n        {\r\n            // Write the error text to the file if there is something \r\n            // to write and an error file has been specified. \r\n\r\n            if (!String.IsNullOrEmpty(errLine.Data))\r\n            {\r\n                this.Invoke(new MethodInvoker(delegate\r\n                {\r\n                    logOutput(errLine.Data);\r\n                }));\r\n            }\r\n        }\r\n\r\n        // a smile process has finished\r\n        void p_Exited(object sender, EventArgs e)\r\n        {\r\n            // get exit code from process object\r\n            Process p = (Process)sender;\r\n            // load log file:\r\n            string txt = File.ReadAllText(logfile);\r\n            this.Invoke(new MethodInvoker(delegate\r\n            {\r\n                logOutput(txt + \"\\n\");\r\n            }));\r\n            if (p.ExitCode != 0)\r\n            {\r\n                // error running smile...\r\n                this.Invoke(new MethodInvoker(delegate\r\n                {\r\n                    progressLabel.Text = \"An error occurred, see log for details.\";\r\n                    prepareUiAfterAnalysisRun();\r\n                }));\r\n                // exit the loop\r\n\r\n                /*int idx = ad.getIndex();\r\n                listView1.Invoke(new MethodInvoker(delegate\r\n                {\r\n                    listView1.Items[idx].Checked = false;\r\n                    listView1.Items[idx].SubItems[2].Text = \"error\";\r\n                    listView1.Items[idx].ForeColor = Color.Gray;\r\n                }\r\n                ));*/\r\n            }\r\n            else\r\n            {\r\n                // run next file in loop\r\n                this.Invoke(new MethodInvoker(delegate\r\n                {\r\n                    processNextFile();\r\n                }));\r\n            }\r\n            p.Dispose();\r\n        }\r\n\r\n        private string getLabels(string filename)\r\n        {\r\n            if (labels == null)\r\n            {\r\n                return \"\";\r\n            }\r\n            string basename = System.IO.Path.GetFileNameWithoutExtension(filename);\r\n            string opts = \"\";\r\n            string[] vals = (string[])labels[basename];\r\n            if (vals != null)\r\n            {\r\n                for (int i = 1; i < vals.Count(); i++)\r\n                {\r\n                    opts += \"-\" + classnames[i] + \" \" + vals[i] + \" \";\r\n                }\r\n                //MessageBox.Show(opts);\r\n            }\r\n            return opts;\r\n        }\r\n        \r\n        private void processNextFile()\r\n        {\r\n            bool next = true;\r\n            while (next)\r\n            {\r\n                logProgress(nextFileIndex, fileSelCount);\r\n                if (nextFileIndex < fileSelCount)\r\n                {\r\n                    string f = filesToProcessQueue[nextFileIndex];\r\n                    nextFileIndex++;\r\n                    this.Invoke(new MethodInvoker(delegate\r\n                    {\r\n\r\n                        // get labels\r\n                        string extraoptions = getLabels(f);\r\n                        if (labelFile.Text != \"\" && extraoptions == \"\")\r\n                        {\r\n                            logOutput(\"Skipping file '\" + f + \"'. Not in label list.\\n\");\r\n                        }\r\n                        else\r\n                        {\r\n                            logOutput(\"Processing file '\" + f + \"'.\\n\");\r\n                            next = false;\r\n                            // run openSMILE\r\n                            runOpenSMILE(f, extraoptions);\r\n                        }\r\n                    }\r\n                    ));\r\n                }\r\n                else\r\n                {\r\n                    this.Invoke(new MethodInvoker(delegate\r\n                    {\r\n                        progressLabel.Text = \"Done.\";\r\n                        prepareUiAfterAnalysisRun();\r\n                    }));\r\n                    next = false;\r\n                }\r\n            }\r\n        }\r\n\r\n        System.Collections.Hashtable labels;\r\n        string[] classnames;\r\n\r\n        private void runOpenSMILE(string filename, string extraoptions=\"\")\r\n        {\r\n            string binary = System.IO.Path.GetFullPath(workDirectory.Text + \"\\\\SMILExtract_Release.exe\");\r\n            logfile = System.IO.Path.GetFullPath(workDirectory.Text + \"\\\\smile.log\");\r\n            string options = \"-C \\\"\" + System.IO.Path.GetFullPath(workDirectory.Text + \"\\\\config\\\\\" + configurations.Text) + \"\\\" \";\r\n            options += \"-logfile \\\"\" + logfile + \"\\\" \";\r\n            string wavFilename = System.IO.Path.GetFullPath(filename);\r\n            options += \"-I \\\"\" + wavFilename + \"\\\" \";\r\n            options += \"-instname \\\"\" + Path.GetFileName(wavFilename) + \"\\\" \";\r\n            string arffOutFile = System.IO.Path.GetFullPath(arffOutName.Text);\r\n            string csvOutFile = System.IO.Path.GetFullPath(csvOutName.Text);\r\n            string lldCsvOutFile = System.IO.Path.GetFullPath(lldCsvOutName.Text);\r\n            if (haveArffOut.Checked)\r\n            {\r\n                options += \"-O \\\"\" + arffOutFile + \"\\\" \";\r\n                if (arffAppend.Checked)\r\n                {\r\n                    options += \"-appendarff 1 \";  // note: this is the default\r\n                }\r\n                else\r\n                {\r\n                    options += \"-appendarff 0 \";\r\n                }\r\n            }\r\n            else\r\n            {\r\n                options += \"-O ? \";\r\n            }\r\n            if (haveCsvOut.Checked)\r\n            {\r\n                options += \"-csvoutput \\\"\" + csvOutFile + \"\\\" \";\r\n                if (csvAppend.Checked)\r\n                {\r\n                    options += \"-appendcsv 1 \";\r\n                }\r\n                else\r\n                {\r\n                    options += \"-appendcsv 0 \";\r\n                }\r\n            }\r\n            else\r\n            {\r\n                options += \"-csvoutput ? \";\r\n            }\r\n            if (haveLldCsvOut.Checked)\r\n            {\r\n                options += \"-lldcsvoutput \\\"\" + lldCsvOutFile + \"\\\" \";\r\n                if (lldCsvAppend.Checked)\r\n                {\r\n                    options += \"-appendcsvlld 1 \";\r\n                }\r\n                else\r\n                {\r\n                    options += \"-appendcsvlld 0 \";\r\n                }\r\n            }\r\n            else\r\n            {\r\n                options += \"-lldcsvoutput ? \";\r\n            }\r\n            /*\r\n             * if (!createLogFile.Checked)\r\n            {\r\n                options += \"-nologfile \";\r\n            }\r\n             * */\r\n            options += \"-l 2 \";\r\n            options += extraoptions + \" \";\r\n            logBox.AppendText(\"Running command: '\" + binary + \" \" + options + \"'\\n\");\r\n            if (runSmileBinary(System.IO.Path.GetFullPath(workDirectory.Text), binary, options) == 0)\r\n            {\r\n                prepareUiAfterAnalysisRun();\r\n            }\r\n        }\r\n\r\n        private void prepareUiForAnalysisRun()\r\n        {\r\n            // disable all controls that should not be changed during the analysis run\r\n            groupBox1.Enabled = false;\r\n            selectedFolder.Enabled = false;\r\n            button1.Enabled = false;\r\n            button2.Enabled = false;\r\n            button3.Enabled = false;\r\n            button4.Enabled = false;\r\n            button5.Enabled = true;\r\n            fileListBox.Enabled = false;\r\n        }\r\n\r\n        private void prepareUiAfterAnalysisRun()\r\n        {\r\n            groupBox1.Enabled = true;\r\n            selectedFolder.Enabled = true;\r\n            button1.Enabled = true;\r\n            button2.Enabled = true;\r\n            button3.Enabled = true;\r\n            button4.Enabled = true;\r\n            button5.Enabled = false;\r\n            fileListBox.Enabled = true;\r\n        }\r\n\r\n        private int getNumFilesSelected()\r\n        {\r\n            int fileSelCount = 0;\r\n            for (int i = 0; i < fileListBox.Items.Count; i++)\r\n            {\r\n                if (fileListBox.GetItemChecked(i))\r\n                {\r\n                    fileSelCount++;\r\n                }\r\n            }\r\n            return fileSelCount;\r\n        }\r\n\r\n        private void runAnalysisLoop()\r\n        {\r\n            fileSelCount = getNumFilesSelected();\r\n            if (fileSelCount > 0)\r\n            {\r\n                prepareUiForAnalysisRun();\r\n                initProgress(fileSelCount);\r\n                // TODO: thread this!\r\n                filesToProcessQueue = new List<string>();\r\n                for (int i = 0; i < fileListBox.Items.Count; i++)\r\n                {\r\n                    if (fileListBox.GetItemChecked(i))\r\n                    {\r\n                        string f = selectedFolder.Text + \"\\\\\" + fileListBox.Items[i].ToString();\r\n                        filesToProcessQueue.Add(f);\r\n                    }\r\n                }\r\n                // in append mode, delete existing files\r\n                if (haveArffOut.Checked && arffAppend.Checked && File.Exists(arffOutName.Text))\r\n                {\r\n                    DialogResult dlrs = MessageBox.Show(\"The ARFF output file already exists. The existing file will be deleted now. Proceed?\", \"Overwrite files?\", MessageBoxButtons.YesNo);\r\n                    if (dlrs == DialogResult.Yes)\r\n                    {\r\n                        File.Delete(arffOutName.Text);\r\n                    }\r\n                    else\r\n                    {\r\n                        prepareUiAfterAnalysisRun();\r\n                        return;\r\n                    }\r\n                    // TODO: show a warning dialogue and ask for overwrite yes/no\r\n                }\r\n                if (haveCsvOut.Checked && csvAppend.Checked && File.Exists(csvOutName.Text))\r\n                {\r\n                    DialogResult dlrs = MessageBox.Show(\"The CSV output file already exists. The existing file will be deleted now. Proceed?\", \"Overwrite files?\", MessageBoxButtons.YesNo);\r\n                    if (dlrs == DialogResult.Yes)\r\n                    {\r\n                        File.Delete(csvOutName.Text);\r\n                    }\r\n                    else\r\n                    {\r\n                        prepareUiAfterAnalysisRun();\r\n                        return;\r\n                    }\r\n                }\r\n                if (haveLldCsvOut.Checked && lldCsvAppend.Checked && File.Exists(lldCsvOutName.Text))\r\n                {\r\n                    DialogResult dlrs = MessageBox.Show(\"The LLD CSV output file already exists. The existing file will be deleted now. Proceed?\", \"Overwrite files?\", MessageBoxButtons.YesNo);\r\n                    if (dlrs == DialogResult.Yes)\r\n                    {\r\n                        File.Delete(lldCsvOutName.Text);\r\n                    }\r\n                    else\r\n                    {\r\n                        prepareUiAfterAnalysisRun();\r\n                        return;\r\n                    }\r\n                }\r\n                nextFileIndex = 0;\r\n                processNextFile();  // start with the first\r\n            }\r\n            else\r\n            {\r\n                MessageBox.Show(\"No files selected for processing! Please select some files in the box on the left (use double click, or the 'select all' button)\");\r\n            }\r\n        }\r\n\r\n        private bool loadLabelList()\r\n        {\r\n            if (labelFile.Text == \"\")\r\n            {\r\n                return true;\r\n            }\r\n            if (System.IO.File.Exists(labelFile.Text))\r\n            {\r\n                string[] labelLines = File.ReadAllLines(@labelFile.Text);\r\n                string[] labelVals = labelLines[0].Split(';');\r\n                classnames = new string[labelLines.Count()];\r\n                classnames[0] = \"Filename\";\r\n                for (int i = 1; i < labelVals.Count(); i++)\r\n                {\r\n                    classnames[i] = labelVals[i];\r\n                }\r\n                labels = new System.Collections.Hashtable();\r\n                for (int i = 1; i < labelLines.Count(); i++) \r\n                {\r\n                  string[] labelValues = labelLines[i].Split(';');\r\n                  string filename = System.IO.Path.GetFileNameWithoutExtension(labelValues[0]);\r\n                  labels.Add(filename, labelValues);\r\n                }\r\n                return true;\r\n            }\r\n            else\r\n            {\r\n                MessageBox.Show(\"ERROR: Label file not found! Please leave field empty if you do not have a label file.\");\r\n            }\r\n            return false;\r\n        }\r\n\r\n        private void button1_Click(object sender, EventArgs e)\r\n        {\r\n            if (loadLabelList())\r\n            {\r\n                runAnalysisLoop();\r\n            }\r\n        }\r\n\r\n        private void button7_Click(object sender, EventArgs e)\r\n        {\r\n            if (saveFileDialogArff.ShowDialog() == DialogResult.OK) \r\n            {\r\n                arffOutName.Text = saveFileDialogArff.FileName;\r\n                haveArffOut.Checked = true;\r\n            }\r\n        }\r\n\r\n        private void button8_Click(object sender, EventArgs e)\r\n        {\r\n            if (saveFileDialogLldCsv.ShowDialog() == DialogResult.OK) \r\n            {\r\n                lldCsvOutName.Text = saveFileDialogLldCsv.FileName;\r\n                haveLldCsvOut.Checked = true;\r\n            }\r\n        }\r\n\r\n        private void button9_Click(object sender, EventArgs e)\r\n        {\r\n            if (saveFileDialogCsv.ShowDialog() == DialogResult.OK) \r\n            {\r\n                csvOutName.Text = saveFileDialogCsv.FileName;\r\n                haveCsvOut.Checked = true;\r\n            }\r\n\r\n        }\r\n\r\n        private void fileListBox_ItemCheck(object sender, ItemCheckEventArgs e)\r\n        {\r\n            if (getNumFilesSelected() > 0)\r\n            {\r\n                button1.Enabled = true;\r\n            }\r\n            else\r\n            {\r\n                button1.Enabled = false;\r\n            }\r\n        }\r\n\r\n        private void workDirectory_TextChanged(object sender, EventArgs e)\r\n        {\r\n            refreshConfigFiles();\r\n        }\r\n\r\n        private void button10_Click(object sender, EventArgs e)\r\n        {\r\n            folderBrowserDialog2.RootFolder = Environment.SpecialFolder.MyComputer;\r\n            folderBrowserDialog2.SelectedPath = workDirectory.Text;\r\n            if (folderBrowserDialog2.ShowDialog() == DialogResult.OK)\r\n            {\r\n                workDirectory.Text = folderBrowserDialog2.SelectedPath;\r\n            }\r\n            if (System.IO.Directory.Exists(workDirectory.Text))\r\n            {\r\n                System.IO.Directory.CreateDirectory(workDirectory.Text + \"\\\\data\");\r\n            }\r\n        }\r\n\r\n        private void haveLldCsvOut_CheckedChanged(object sender, EventArgs e)\r\n        {\r\n\r\n        }\r\n\r\n        private void button5_Click(object sender, EventArgs e)\r\n        {\r\n            filesToProcessQueue.Clear();\r\n        }\r\n\r\n        private void button11_Click_1(object sender, EventArgs e)\r\n        {\r\n            if (openFileDialog1.ShowDialog() == DialogResult.OK)\r\n            {\r\n                labelFile.Text = openFileDialog1.FileName;\r\n            }\r\n        }\r\n\r\n        private void labelFile_TextChanged(object sender, EventArgs e)\r\n        {\r\n\r\n        }\r\n\r\n        Form2 form2 = null;\r\n        private void button12_Click(object sender, EventArgs e)\r\n        {\r\n            if (form2 == null)\r\n            {\r\n                form2 = new Form2();\r\n            }\r\n            form2.Show();\r\n        }\r\n\r\n        private void label5_Click(object sender, EventArgs e)\r\n        {\r\n\r\n        }\r\n\r\n        private void button13_Click(object sender, EventArgs e)\r\n        {\r\n            workDirectory.Text = System.IO.Path.GetFullPath(workDirectory.Text);\r\n            refreshConfigFiles();\r\n            if (arffOutName.Text == \"\")\r\n            {\r\n                arffOutName.Text = workDirectory.Text + \"\\\\data\\\\output.arff\";\r\n            }\r\n            if (csvOutName.Text == \"\")\r\n            {\r\n                csvOutName.Text = workDirectory.Text + \"\\\\data\\\\output.csv\";\r\n            }\r\n            if (lldCsvOutName.Text == \"\")\r\n            {\r\n                lldCsvOutName.Text = workDirectory.Text + \"\\\\data\\\\output_lld.csv\";\r\n            }\r\n        }\r\n\r\n        \r\n\r\n    }\r\n}\r\n"
  },
  {
    "path": "progsrc/openSMILEbatchGUI/Form1.resx",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<root>\r\n  <!-- \r\n    Microsoft ResX Schema \r\n    \r\n    Version 2.0\r\n    \r\n    The primary goals of this format is to allow a simple XML format \r\n    that is mostly human readable. The generation and parsing of the \r\n    various data types are done through the TypeConverter classes \r\n    associated with the data types.\r\n    \r\n    Example:\r\n    \r\n    ... ado.net/XML headers & schema ...\r\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\r\n    <resheader name=\"version\">2.0</resheader>\r\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\r\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\r\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\r\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\r\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\r\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\r\n    </data>\r\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\r\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\r\n        <comment>This is a comment</comment>\r\n    </data>\r\n                \r\n    There are any number of \"resheader\" rows that contain simple \r\n    name/value pairs.\r\n    \r\n    Each data row contains a name, and value. The row also contains a \r\n    type or mimetype. Type corresponds to a .NET class that support \r\n    text/value conversion through the TypeConverter architecture. \r\n    Classes that don't support this are serialized and stored with the \r\n    mimetype set.\r\n    \r\n    The mimetype is used for serialized objects, and tells the \r\n    ResXResourceReader how to depersist the object. This is currently not \r\n    extensible. For a given mimetype the value must be set accordingly:\r\n    \r\n    Note - application/x-microsoft.net.object.binary.base64 is the format \r\n    that the ResXResourceWriter will generate, however the reader can \r\n    read any of the formats listed below.\r\n    \r\n    mimetype: application/x-microsoft.net.object.binary.base64\r\n    value   : The object must be serialized with \r\n            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\r\n            : and then encoded with base64 encoding.\r\n    \r\n    mimetype: application/x-microsoft.net.object.soap.base64\r\n    value   : The object must be serialized with \r\n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\r\n            : and then encoded with base64 encoding.\r\n\r\n    mimetype: application/x-microsoft.net.object.bytearray.base64\r\n    value   : The object must be serialized into a byte array \r\n            : using a System.ComponentModel.TypeConverter\r\n            : and then encoded with base64 encoding.\r\n    -->\r\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\r\n    <xsd:import namespace=\"http://www.w3.org/XML/1998/namespace\" />\r\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\r\n      <xsd:complexType>\r\n        <xsd:choice maxOccurs=\"unbounded\">\r\n          <xsd:element name=\"metadata\">\r\n            <xsd:complexType>\r\n              <xsd:sequence>\r\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\r\n              </xsd:sequence>\r\n              <xsd:attribute name=\"name\" use=\"required\" type=\"xsd:string\" />\r\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\r\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\r\n              <xsd:attribute ref=\"xml:space\" />\r\n            </xsd:complexType>\r\n          </xsd:element>\r\n          <xsd:element name=\"assembly\">\r\n            <xsd:complexType>\r\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\r\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\r\n            </xsd:complexType>\r\n          </xsd:element>\r\n          <xsd:element name=\"data\">\r\n            <xsd:complexType>\r\n              <xsd:sequence>\r\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\r\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\r\n              </xsd:sequence>\r\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" msdata:Ordinal=\"1\" />\r\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\r\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\r\n              <xsd:attribute ref=\"xml:space\" />\r\n            </xsd:complexType>\r\n          </xsd:element>\r\n          <xsd:element name=\"resheader\">\r\n            <xsd:complexType>\r\n              <xsd:sequence>\r\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\r\n              </xsd:sequence>\r\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\r\n            </xsd:complexType>\r\n          </xsd:element>\r\n        </xsd:choice>\r\n      </xsd:complexType>\r\n    </xsd:element>\r\n  </xsd:schema>\r\n  <resheader name=\"resmimetype\">\r\n    <value>text/microsoft-resx</value>\r\n  </resheader>\r\n  <resheader name=\"version\">\r\n    <value>2.0</value>\r\n  </resheader>\r\n  <resheader name=\"reader\">\r\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r\n  </resheader>\r\n  <resheader name=\"writer\">\r\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r\n  </resheader>\r\n  <metadata name=\"folderBrowserDialog1.TrayLocation\" type=\"System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\">\r\n    <value>17, 17</value>\r\n  </metadata>\r\n  <metadata name=\"saveFileDialogArff.TrayLocation\" type=\"System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\">\r\n    <value>175, 17</value>\r\n  </metadata>\r\n  <metadata name=\"saveFileDialogCsv.TrayLocation\" type=\"System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\">\r\n    <value>315, 17</value>\r\n  </metadata>\r\n  <metadata name=\"saveFileDialogLldCsv.TrayLocation\" type=\"System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\">\r\n    <value>455, 17</value>\r\n  </metadata>\r\n  <metadata name=\"folderBrowserDialog2.TrayLocation\" type=\"System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\">\r\n    <value>609, 17</value>\r\n  </metadata>\r\n  <metadata name=\"openFileDialog1.TrayLocation\" type=\"System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\">\r\n    <value>17, 54</value>\r\n  </metadata>\r\n</root>"
  },
  {
    "path": "progsrc/openSMILEbatchGUI/Form2.Designer.cs",
    "content": "﻿namespace openSMILEbatchGUI\r\n{\r\n    partial class Form2\r\n    {\r\n        /// <summary>\r\n        /// Required designer variable.\r\n        /// </summary>\r\n        private System.ComponentModel.IContainer components = null;\r\n\r\n        /// <summary>\r\n        /// Clean up any resources being used.\r\n        /// </summary>\r\n        /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>\r\n        protected override void Dispose(bool disposing)\r\n        {\r\n            if (disposing && (components != null))\r\n            {\r\n                components.Dispose();\r\n            }\r\n            base.Dispose(disposing);\r\n        }\r\n\r\n        #region Windows Form Designer generated code\r\n\r\n        /// <summary>\r\n        /// Required method for Designer support - do not modify\r\n        /// the contents of this method with the code editor.\r\n        /// </summary>\r\n        private void InitializeComponent()\r\n        {\r\n            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form2));\r\n            this.richTextBox1 = new System.Windows.Forms.RichTextBox();\r\n            this.button1 = new System.Windows.Forms.Button();\r\n            this.SuspendLayout();\r\n            // \r\n            // richTextBox1\r\n            // \r\n            this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;\r\n            this.richTextBox1.Location = new System.Drawing.Point(31, 25);\r\n            this.richTextBox1.Name = \"richTextBox1\";\r\n            this.richTextBox1.ReadOnly = true;\r\n            this.richTextBox1.Size = new System.Drawing.Size(477, 213);\r\n            this.richTextBox1.TabIndex = 0;\r\n            this.richTextBox1.Text = resources.GetString(\"richTextBox1.Text\");\r\n            // \r\n            // button1\r\n            // \r\n            this.button1.Location = new System.Drawing.Point(247, 247);\r\n            this.button1.Name = \"button1\";\r\n            this.button1.Size = new System.Drawing.Size(75, 23);\r\n            this.button1.TabIndex = 1;\r\n            this.button1.Text = \"Close\";\r\n            this.button1.UseVisualStyleBackColor = true;\r\n            this.button1.Click += new System.EventHandler(this.button1_Click);\r\n            // \r\n            // Form2\r\n            // \r\n            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\r\n            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r\n            this.ClientSize = new System.Drawing.Size(540, 282);\r\n            this.Controls.Add(this.button1);\r\n            this.Controls.Add(this.richTextBox1);\r\n            this.Name = \"Form2\";\r\n            this.Text = \"Label File Format\";\r\n            this.ResumeLayout(false);\r\n\r\n        }\r\n\r\n        #endregion\r\n\r\n        private System.Windows.Forms.RichTextBox richTextBox1;\r\n        private System.Windows.Forms.Button button1;\r\n    }\r\n}"
  },
  {
    "path": "progsrc/openSMILEbatchGUI/Form2.cs",
    "content": "﻿using System;\r\nusing System.Collections.Generic;\r\nusing System.ComponentModel;\r\nusing System.Data;\r\nusing System.Drawing;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Windows.Forms;\r\n\r\nnamespace openSMILEbatchGUI\r\n{\r\n    public partial class Form2 : Form\r\n    {\r\n        public Form2()\r\n        {\r\n            InitializeComponent();\r\n        }\r\n\r\n        private void button1_Click(object sender, EventArgs e)\r\n        {\r\n            Hide();\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "progsrc/openSMILEbatchGUI/Program.cs",
    "content": "﻿using System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Windows.Forms;\r\n\r\nnamespace openSMILEbatchGUI\r\n{\r\n    static class Program\r\n    {\r\n        /// <summary>\r\n        /// The main entry point for the application.\r\n        /// </summary>\r\n        [STAThread]\r\n        static void Main()\r\n        {\r\n            Application.EnableVisualStyles();\r\n            Application.SetCompatibleTextRenderingDefault(false);\r\n            Application.Run(new Form1());\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "progsrc/openSMILEbatchGUI/Properties/AssemblyInfo.cs",
    "content": "﻿using System.Reflection;\r\nusing System.Runtime.CompilerServices;\r\nusing System.Runtime.InteropServices;\r\n\r\n// General Information about an assembly is controlled through the following \r\n// set of attributes. Change these attribute values to modify the information\r\n// associated with an assembly.\r\n[assembly: AssemblyTitle(\"openSMILEbatchGUI\")]\r\n[assembly: AssemblyDescription(\"\")]\r\n[assembly: AssemblyConfiguration(\"\")]\r\n[assembly: AssemblyCompany(\"Microsoft\")]\r\n[assembly: AssemblyProduct(\"openSMILEbatchGUI\")]\r\n[assembly: AssemblyCopyright(\"Copyright © Microsoft 2014\")]\r\n[assembly: AssemblyTrademark(\"\")]\r\n[assembly: AssemblyCulture(\"\")]\r\n\r\n// Setting ComVisible to false makes the types in this assembly not visible \r\n// to COM components.  If you need to access a type in this assembly from \r\n// COM, set the ComVisible attribute to true on that type.\r\n[assembly: ComVisible(false)]\r\n\r\n// The following GUID is for the ID of the typelib if this project is exposed to COM\r\n[assembly: Guid(\"74eac452-fa25-4e21-89a3-30088f659b20\")]\r\n\r\n// Version information for an assembly consists of the following four values:\r\n//\r\n//      Major Version\r\n//      Minor Version \r\n//      Build Number\r\n//      Revision\r\n//\r\n// You can specify all the values or you can default the Build and Revision Numbers \r\n// by using the '*' as shown below:\r\n// [assembly: AssemblyVersion(\"1.0.*\")]\r\n[assembly: AssemblyVersion(\"1.0.0.0\")]\r\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]\r\n"
  },
  {
    "path": "progsrc/openSMILEbatchGUI/Properties/Resources.Designer.cs",
    "content": "﻿//------------------------------------------------------------------------------\r\n// <auto-generated>\r\n//     This code was generated by a tool.\r\n//     Runtime Version:4.0.30319.2034\r\n//\r\n//     Changes to this file may cause incorrect behavior and will be lost if\r\n//     the code is regenerated.\r\n// </auto-generated>\r\n//------------------------------------------------------------------------------\r\n\r\nnamespace openSMILEbatchGUI.Properties\r\n{\r\n\r\n\r\n    /// <summary>\r\n    ///   A strongly-typed resource class, for looking up localized strings, etc.\r\n    /// </summary>\r\n    // This class was auto-generated by the StronglyTypedResourceBuilder\r\n    // class via a tool like ResGen or Visual Studio.\r\n    // To add or remove a member, edit your .ResX file then rerun ResGen\r\n    // with the /str option, or rebuild your VS project.\r\n    [global::System.CodeDom.Compiler.GeneratedCodeAttribute(\"System.Resources.Tools.StronglyTypedResourceBuilder\", \"4.0.0.0\")]\r\n    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r\n    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]\r\n    internal class Resources\r\n    {\r\n\r\n        private static global::System.Resources.ResourceManager resourceMan;\r\n\r\n        private static global::System.Globalization.CultureInfo resourceCulture;\r\n\r\n        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute(\"Microsoft.Performance\", \"CA1811:AvoidUncalledPrivateCode\")]\r\n        internal Resources()\r\n        {\r\n        }\r\n\r\n        /// <summary>\r\n        ///   Returns the cached ResourceManager instance used by this class.\r\n        /// </summary>\r\n        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]\r\n        internal static global::System.Resources.ResourceManager ResourceManager\r\n        {\r\n            get\r\n            {\r\n                if ((resourceMan == null))\r\n                {\r\n                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager(\"openSMILEbatchGUI.Properties.Resources\", typeof(Resources).Assembly);\r\n                    resourceMan = temp;\r\n                }\r\n                return resourceMan;\r\n            }\r\n        }\r\n\r\n        /// <summary>\r\n        ///   Overrides the current thread's CurrentUICulture property for all\r\n        ///   resource lookups using this strongly typed resource class.\r\n        /// </summary>\r\n        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]\r\n        internal static global::System.Globalization.CultureInfo Culture\r\n        {\r\n            get\r\n            {\r\n                return resourceCulture;\r\n            }\r\n            set\r\n            {\r\n                resourceCulture = value;\r\n            }\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "progsrc/openSMILEbatchGUI/Properties/Resources.resx",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<root>\r\n  <!-- \r\n    Microsoft ResX Schema \r\n    \r\n    Version 2.0\r\n    \r\n    The primary goals of this format is to allow a simple XML format \r\n    that is mostly human readable. The generation and parsing of the \r\n    various data types are done through the TypeConverter classes \r\n    associated with the data types.\r\n    \r\n    Example:\r\n    \r\n    ... ado.net/XML headers & schema ...\r\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\r\n    <resheader name=\"version\">2.0</resheader>\r\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\r\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\r\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\r\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\r\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\r\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\r\n    </data>\r\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\r\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\r\n        <comment>This is a comment</comment>\r\n    </data>\r\n                \r\n    There are any number of \"resheader\" rows that contain simple \r\n    name/value pairs.\r\n    \r\n    Each data row contains a name, and value. The row also contains a \r\n    type or mimetype. Type corresponds to a .NET class that support \r\n    text/value conversion through the TypeConverter architecture. \r\n    Classes that don't support this are serialized and stored with the \r\n    mimetype set.\r\n    \r\n    The mimetype is used for serialized objects, and tells the \r\n    ResXResourceReader how to depersist the object. This is currently not \r\n    extensible. For a given mimetype the value must be set accordingly:\r\n    \r\n    Note - application/x-microsoft.net.object.binary.base64 is the format \r\n    that the ResXResourceWriter will generate, however the reader can \r\n    read any of the formats listed below.\r\n    \r\n    mimetype: application/x-microsoft.net.object.binary.base64\r\n    value   : The object must be serialized with \r\n            : System.Serialization.Formatters.Binary.BinaryFormatter\r\n            : and then encoded with base64 encoding.\r\n    \r\n    mimetype: application/x-microsoft.net.object.soap.base64\r\n    value   : The object must be serialized with \r\n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\r\n            : and then encoded with base64 encoding.\r\n\r\n    mimetype: application/x-microsoft.net.object.bytearray.base64\r\n    value   : The object must be serialized into a byte array \r\n            : using a System.ComponentModel.TypeConverter\r\n            : and then encoded with base64 encoding.\r\n    -->\r\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\r\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\r\n      <xsd:complexType>\r\n        <xsd:choice maxOccurs=\"unbounded\">\r\n          <xsd:element name=\"metadata\">\r\n            <xsd:complexType>\r\n              <xsd:sequence>\r\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\r\n              </xsd:sequence>\r\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\r\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\r\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\r\n            </xsd:complexType>\r\n          </xsd:element>\r\n          <xsd:element name=\"assembly\">\r\n            <xsd:complexType>\r\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\r\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\r\n            </xsd:complexType>\r\n          </xsd:element>\r\n          <xsd:element name=\"data\">\r\n            <xsd:complexType>\r\n              <xsd:sequence>\r\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\r\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\r\n              </xsd:sequence>\r\n              <xsd:attribute name=\"name\" type=\"xsd:string\" msdata:Ordinal=\"1\" />\r\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\r\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\r\n            </xsd:complexType>\r\n          </xsd:element>\r\n          <xsd:element name=\"resheader\">\r\n            <xsd:complexType>\r\n              <xsd:sequence>\r\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\r\n              </xsd:sequence>\r\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\r\n            </xsd:complexType>\r\n          </xsd:element>\r\n        </xsd:choice>\r\n      </xsd:complexType>\r\n    </xsd:element>\r\n  </xsd:schema>\r\n  <resheader name=\"resmimetype\">\r\n    <value>text/microsoft-resx</value>\r\n  </resheader>\r\n  <resheader name=\"version\">\r\n    <value>2.0</value>\r\n  </resheader>\r\n  <resheader name=\"reader\">\r\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r\n  </resheader>\r\n  <resheader name=\"writer\">\r\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r\n  </resheader>\r\n</root>"
  },
  {
    "path": "progsrc/openSMILEbatchGUI/Properties/Settings.Designer.cs",
    "content": "﻿//------------------------------------------------------------------------------\r\n// <auto-generated>\r\n//     This code was generated by a tool.\r\n//     Runtime Version:4.0.30319.2034\r\n//\r\n//     Changes to this file may cause incorrect behavior and will be lost if\r\n//     the code is regenerated.\r\n// </auto-generated>\r\n//------------------------------------------------------------------------------\r\n\r\nnamespace openSMILEbatchGUI.Properties\r\n{\r\n\r\n\r\n    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]\r\n    [global::System.CodeDom.Compiler.GeneratedCodeAttribute(\"Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator\", \"10.0.0.0\")]\r\n    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase\r\n    {\r\n\r\n        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));\r\n\r\n        public static Settings Default\r\n        {\r\n            get\r\n            {\r\n                return defaultInstance;\r\n            }\r\n        }\r\n    }\r\n}\r\n"
  },
  {
    "path": "progsrc/openSMILEbatchGUI/Properties/Settings.settings",
    "content": "﻿<?xml version='1.0' encoding='utf-8'?>\r\n<SettingsFile xmlns=\"http://schemas.microsoft.com/VisualStudio/2004/01/settings\" CurrentProfile=\"(Default)\">\r\n  <Profiles>\r\n    <Profile Name=\"(Default)\" />\r\n  </Profiles>\r\n  <Settings />\r\n</SettingsFile>\r\n"
  },
  {
    "path": "progsrc/openSMILEbatchGUI/openSMILEbatchGUI.csproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <PropertyGroup>\r\n    <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>\r\n    <Platform Condition=\" '$(Platform)' == '' \">x86</Platform>\r\n    <ProductVersion>8.0.30703</ProductVersion>\r\n    <SchemaVersion>2.0</SchemaVersion>\r\n    <ProjectGuid>{2DE82BD3-FE77-4ADD-8537-B4451DBDBB39}</ProjectGuid>\r\n    <OutputType>WinExe</OutputType>\r\n    <AppDesignerFolder>Properties</AppDesignerFolder>\r\n    <RootNamespace>openSMILEbatchGUI</RootNamespace>\r\n    <AssemblyName>openSMILEbatchGUI</AssemblyName>\r\n    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>\r\n    <TargetFrameworkProfile>Client</TargetFrameworkProfile>\r\n    <FileAlignment>512</FileAlignment>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Debug|x86' \">\r\n    <PlatformTarget>x86</PlatformTarget>\r\n    <DebugSymbols>true</DebugSymbols>\r\n    <DebugType>full</DebugType>\r\n    <Optimize>false</Optimize>\r\n    <OutputPath>bin\\Debug\\</OutputPath>\r\n    <DefineConstants>DEBUG;TRACE</DefineConstants>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <WarningLevel>4</WarningLevel>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Release|x86' \">\r\n    <PlatformTarget>x86</PlatformTarget>\r\n    <DebugType>pdbonly</DebugType>\r\n    <Optimize>true</Optimize>\r\n    <OutputPath>bin\\Release\\</OutputPath>\r\n    <DefineConstants>TRACE</DefineConstants>\r\n    <ErrorReport>prompt</ErrorReport>\r\n    <WarningLevel>4</WarningLevel>\r\n  </PropertyGroup>\r\n  <ItemGroup>\r\n    <Reference Include=\"System\" />\r\n    <Reference Include=\"System.Core\" />\r\n    <Reference Include=\"System.Xml.Linq\" />\r\n    <Reference Include=\"System.Data.DataSetExtensions\" />\r\n    <Reference Include=\"Microsoft.CSharp\" />\r\n    <Reference Include=\"System.Data\" />\r\n    <Reference Include=\"System.Deployment\" />\r\n    <Reference Include=\"System.Drawing\" />\r\n    <Reference Include=\"System.Windows.Forms\" />\r\n    <Reference Include=\"System.Xml\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <Compile Include=\"Form1.cs\">\r\n      <SubType>Form</SubType>\r\n    </Compile>\r\n    <Compile Include=\"Form1.Designer.cs\">\r\n      <DependentUpon>Form1.cs</DependentUpon>\r\n    </Compile>\r\n    <Compile Include=\"Form2.cs\">\r\n      <SubType>Form</SubType>\r\n    </Compile>\r\n    <Compile Include=\"Form2.Designer.cs\">\r\n      <DependentUpon>Form2.cs</DependentUpon>\r\n    </Compile>\r\n    <Compile Include=\"Program.cs\" />\r\n    <Compile Include=\"Properties\\AssemblyInfo.cs\" />\r\n    <EmbeddedResource Include=\"Form1.resx\">\r\n      <DependentUpon>Form1.cs</DependentUpon>\r\n    </EmbeddedResource>\r\n    <EmbeddedResource Include=\"Form2.resx\">\r\n      <DependentUpon>Form2.cs</DependentUpon>\r\n    </EmbeddedResource>\r\n    <EmbeddedResource Include=\"Properties\\Resources.resx\">\r\n      <Generator>ResXFileCodeGenerator</Generator>\r\n      <LastGenOutput>Resources.Designer.cs</LastGenOutput>\r\n      <SubType>Designer</SubType>\r\n    </EmbeddedResource>\r\n    <Compile Include=\"Properties\\Resources.Designer.cs\">\r\n      <AutoGen>True</AutoGen>\r\n      <DependentUpon>Resources.resx</DependentUpon>\r\n    </Compile>\r\n    <None Include=\"Properties\\Settings.settings\">\r\n      <Generator>SettingsSingleFileGenerator</Generator>\r\n      <LastGenOutput>Settings.Designer.cs</LastGenOutput>\r\n    </None>\r\n    <Compile Include=\"Properties\\Settings.Designer.cs\">\r\n      <AutoGen>True</AutoGen>\r\n      <DependentUpon>Settings.settings</DependentUpon>\r\n      <DesignTimeSharedInput>True</DesignTimeSharedInput>\r\n    </Compile>\r\n  </ItemGroup>\r\n  <Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\r\n  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r\n       Other similar extension points exist, see Microsoft.Common.targets.\r\n  <Target Name=\"BeforeBuild\">\r\n  </Target>\r\n  <Target Name=\"AfterBuild\">\r\n  </Target>\r\n  -->\r\n</Project>"
  },
  {
    "path": "progsrc/openSMILEbatchGUI/openSMILEbatchGUI.sln",
    "content": "﻿\r\nMicrosoft Visual Studio Solution File, Format Version 11.00\r\n# Visual Studio 2010\r\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"openSMILEbatchGUI\", \"openSMILEbatchGUI.csproj\", \"{2DE82BD3-FE77-4ADD-8537-B4451DBDBB39}\"\r\nEndProject\r\nGlobal\r\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\r\n\t\tDebug|x86 = Debug|x86\r\n\t\tRelease|x86 = Release|x86\r\n\tEndGlobalSection\r\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n\t\t{2DE82BD3-FE77-4ADD-8537-B4451DBDBB39}.Debug|x86.ActiveCfg = Debug|x86\r\n\t\t{2DE82BD3-FE77-4ADD-8537-B4451DBDBB39}.Debug|x86.Build.0 = Debug|x86\r\n\t\t{2DE82BD3-FE77-4ADD-8537-B4451DBDBB39}.Release|x86.ActiveCfg = Release|x86\r\n\t\t{2DE82BD3-FE77-4ADD-8537-B4451DBDBB39}.Release|x86.Build.0 = Release|x86\r\n\tEndGlobalSection\r\n\tGlobalSection(SolutionProperties) = preSolution\r\n\t\tHideSolutionNode = FALSE\r\n\tEndGlobalSection\r\nEndGlobal\r\n"
  },
  {
    "path": "progsrc/smilextract/SMILExtract.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n/*\n\nThis is the main commandline application\n\n*/\n\n#include <core/smileCommon.hpp>\n\n#include <core/configManager.hpp>\n#include <core/commandlineParser.hpp>\n#include <core/componentManager.hpp>\n\n#define MODULE \"SMILExtract\"\n\n\n/************** Ctrl+C signal handler **/\n#include  <signal.h>\n\ncComponentManager *cmanGlob = NULL;\n\nvoid INThandler(int);\nint ctrlc = 0;\n\nvoid INThandler(int sig)\n{\n  signal(sig, SIG_IGN);\n  if (cmanGlob != NULL) cmanGlob->requestAbort();\n  signal(SIGINT, INThandler);\n  ctrlc = 1;\n}\n/*******************************************/\n\n\nint main(int argc, const char *argv[])\n{\n  try {\n\n    smileCommon_fixLocaleEnUs();\n\n    // set up the smile logger\n    LOGGER.setLogLevel(1);\n    LOGGER.enableConsoleOutput();\n\n\n    // commandline parser:\n    cCommandlineParser cmdline(argc,argv);\n    cmdline.addStr( \"configfile\", 'C', \"Path to openSMILE config file\", \"smile.conf\" );\n    cmdline.addInt( \"loglevel\", 'l', \"Verbosity level (0-9)\", 2 );\n#ifdef DEBUG\n    cmdline.addBoolean( \"debug\", 'd', \"Show debug messages (on/off)\", 0 );\n#endif\n    cmdline.addInt( \"nticks\", 't', \"Number of ticks to process (-1 = infinite) (only works for single thread processing, i.e. nThreads=1)\", -1 );\n    //cmdline.addBoolean( \"configHelp\", 'H', \"Show documentation of registered config types (on/off)\", 0 );\n    cmdline.addBoolean( \"components\", 'L', \"Show component list\", 0 );\n    cmdline.addStr( \"configHelp\", 'H', \"Show documentation of registered config types (on/off/argument) (if an argument is given, show only documentation for config types beginning with the name given in the argument)\", NULL, 0 );\n    cmdline.addStr( \"configDflt\", 0, \"Show default config section templates for each config type (on/off/argument) (if an argument is given, show only documentation for config types beginning with the name given in the argument, OR for a list of components in conjunctions with the 'cfgFileTemplate' option enabled)\", NULL, 0 );\n    cmdline.addBoolean( \"cfgFileTemplate\", 0, \"Print a complete template config file for a configuration containing the components specified in a comma separated string as argument to the 'configDflt' option\", 0 );\n    cmdline.addBoolean( \"cfgFileDescriptions\", 0, \"Include description in config file templates.\", 0 );\n    cmdline.addBoolean( \"ccmdHelp\", 'c', \"Show custom commandline option help (those specified in config file)\", 0 );\n    cmdline.addStr( \"logfile\", 0, \"set log file\", \"smile.log\" );\n    cmdline.addBoolean( \"nologfile\", 0, \"don't write to a log file (e.g. on a read-only filesystem)\", 0 );\n    cmdline.addBoolean( \"noconsoleoutput\", 0, \"don't output any messages to the console (log file is not affected by this option)\", 0 );\n    cmdline.addBoolean( \"appendLogfile\", 0, \"append log messages to an existing logfile instead of overwriting the logfile at every start\", 0 );\n\n    int help = 0;\n    if (cmdline.doParse() == -1) {\n      LOGGER.setLogLevel(0);\n      help = 1;\n    }\n    if (argc <= 1) {\n      printf(\"\\nNo commandline options were given.\\n Please run ' SMILExtract -h ' to see some usage information!\\n\\n\");\n      return 10;\n    }\n\n    if (help==1) { return 0; }\n\n    if (cmdline.getBoolean(\"nologfile\")) {\n      LOGGER.setLogFile((const char *)NULL,0,!(cmdline.getBoolean(\"noconsoleoutput\")));\n    } else {\n      LOGGER.setLogFile(cmdline.getStr(\"logfile\"),cmdline.getBoolean(\"appendLogfile\"),!(cmdline.getBoolean(\"noconsoleoutput\")));\n    }\n    LOGGER.setLogLevel(cmdline.getInt(\"loglevel\"));\n    SMILE_MSG(2,\"openSMILE starting!\");\n\n#ifdef DEBUG  // ??\n    if (!cmdline.getBoolean(\"debug\"))\n      LOGGER.setLogLevel(LOG_DEBUG, 0);\n#endif\n\n    SMILE_MSG(2,\"config file is: %s\",cmdline.getStr(\"configfile\"));\n\n\n    // create configManager:\n    cConfigManager *configManager = new cConfigManager(&cmdline);\n\n\n    cComponentManager *cMan = new cComponentManager(configManager,componentlist);\n\n\n    const char *selStr=NULL;\n    if (cmdline.isSet(\"configHelp\")) {\n#ifndef EXTERNAL_BUILD\n      selStr = cmdline.getStr(\"configHelp\");\n      configManager->printTypeHelp(1/*!!! -> 1*/,selStr,0);\n#endif\n      help = 1;\n    }\n    if (cmdline.isSet(\"configDflt\")) {\n#ifndef EXTERNAL_BUILD\n      int fullMode=0; \n      int wDescr = 0;\n      if (cmdline.getBoolean(\"cfgFileTemplate\")) fullMode=1;\n      if (cmdline.getBoolean(\"cfgFileDescriptions\")) wDescr=1;\n      selStr = cmdline.getStr(\"configDflt\");\n      configManager->printTypeDfltConfig(selStr,1,fullMode,wDescr);\n#endif\n      help = 1;\n    }\n    if (cmdline.getBoolean(\"components\")) {\n#ifndef EXTERNAL_BUILD\n      cMan->printComponentList();\n#endif  // EXTERNAL_BUILD\n      help = 1;\n    }\n\n    if (help==1) {\n      delete configManager;\n      delete cMan;\n      return -1; \n    }\n\n\n    // TODO: read config here and print ccmdHelp...\n    // add the file config reader:\n    try{ \n      configManager->addReader( new cFileConfigReader( cmdline.getStr(\"configfile\"), -1, &cmdline) );\n      configManager->readConfig();\n    } catch (cConfigException *cc) {\n      return 0;\n    }\n\n    /* re-parse the command-line to include options created in the config file */\n    cmdline.doParse(1,0); // warn if unknown options are detected on the commandline\n    if (cmdline.getBoolean(\"ccmdHelp\")) {\n      cmdline.showUsage();\n      delete configManager;\n      delete cMan;\n      return -1;\n    }\n\n    /* create all instances specified in the config file */\n    cMan->createInstances(0); // 0 = do not read config (we already did that above..)\n\n    /*\n    MAIN TICK LOOP :\n    */\n    cmanGlob = cMan;\n    signal(SIGINT, INThandler); // install Ctrl+C signal handler\n\n    /* run single or mutli-threaded, depending on componentManager config in config file */\n    long long nTicks = cMan->runMultiThreaded(cmdline.getInt(\"nticks\"));\n\n    /* it is important that configManager is deleted BEFORE componentManger! \n      (since component Manager unregisters plugin Dlls, which might have allocated configTypes, etc.) */\n    delete configManager;\n    delete cMan;\n\n  } catch(cSMILException *c) { \n    // free exception ?? \n    return EXIT_ERROR; \n  } \n\n  if (ctrlc) return EXIT_CTRLC;\n  return EXIT_SUCCESS;\n}\n"
  },
  {
    "path": "progsrc/tools/compile_libsvmBinaryModelconverter.sh",
    "content": "#!/bin/sh\n\n# This file is part of openSMILE.\n#\n# Copyright (c) audEERING. All rights reserved.\n# See the file COPYING for details on license terms.\n\necho g++ -g -DNOSMILE -I../../src/include -c ../../src/classifiers/libsvm/svm.cpp -o svm.o\ng++ -g -DNOSMILE -c -I../../src/include ../../src/classifiers/libsvm/svm.cpp -o svm.o\necho g++ -g -DNOSMILE -I../../src/include libsvmBinaryModelconverter.cpp svm.o -o modelconverter\ng++ -g -DNOSMILE -I../../src/include libsvmBinaryModelconverter.cpp svm.o -o modelconverter\n\n"
  },
  {
    "path": "progsrc/tools/convertAllLibsvmModels.sh",
    "content": "#!/bin/sh\n\nBINDIR=`dirname \"$0\"`\nMODELDIR=\"$BINDIR/../models\"\nMODELDIR=`(cd $MODELDIR ; pwd)`\n\nfor f in `find $MODELDIR -name allft.model -print` ; do\n  $BINDIR/modelconverter $f ${f}.bin\ndone\n"
  },
  {
    "path": "progsrc/tools/libsvmBinaryModelconverter.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n#include <stdio.h>\n\n#include <classifiers/libsvm/svm.h>\n\nint main(int argc, char**argv) \n{\n  if (argc < 3) {\n    printf(\"\\nUSAGE: %s <ASCII model file> <binary model file>\\n\",argv[0]);\n    printf(\" Convert an ASCII LibSVM model file into a binary LibSVM model file.\\n\\n\");\n    printf(\"USAGE: %s - <binary model file> <ASCII model file>\\n\",argv[0]);\n    printf(\" Convert a binary LibSVM model file into an ASCII LibSVM model file.\\n\\n\");\n    return -1;\n  }\n\n  if (argv[1][0] == '-') {  // bin -> ASCII\n \n    if (argc < 4) {\n\n      printf(\"USAGE: %s - <binary model file> <ASCII model file>\\n\",argv[0]);\n      printf(\" Convert a binary LibSVM model file into an ASCII LibSVM model file.\\n\\n\");\n      return -1;\n    \n    }\n\n    printf(\"Loading binary model '%s'... \",argv[2]);\n\n    svm_model * m = svm_load_binary_model(argv[2]);\n\n    if (m==NULL) {\n      printf(\"\\nERROR: failed loading model '%s'!\\n\",argv[2]);\n      return -2;\n    }\n\n    printf (\"OK\\n\");\n    printf(\"Saving ASCII model '%s'... \",argv[3]);\n \n    int r = svm_save_model(argv[3],m);\n    if (!r) printf (\"OK\\n\");\n    else { \n      printf(\"ERROR: failed saving ASCII model '%s' (code=%i)\\n\",argv[3],r); \n      return -3;\n    }\n\n    svm_destroy_model(m);\n \n  } else { // ASCII -> bin\n\n    printf(\"Loading ASCII model '%s'... \",argv[1]);\n\n    svm_model * m = svm_load_model(argv[1]);\n\n    if (m==NULL) {\n      printf(\"\\nERROR: failed loading model '%s'!\\n\",argv[1]);\n      return -2;\n    }\n\n    printf (\"OK\\n\");\n    printf(\"Saving binary model '%s'... \",argv[2]);\n \n    int r = svm_save_binary_model(argv[2],m);\n    if (!r) printf (\"OK\\n\");\n    else { \n      printf(\"ERROR: failed saving binary model '%s' (code=%i)\\n\",argv[2],r); \n      return -3;\n    }\n\n    svm_destroy_model(m);\n\n  }\n\n  return 0;\n}\n\n"
  },
  {
    "path": "progsrc/tools/modelmake.c",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n#include <stdio.h>\n#include <stdlib.h>\n\n/*\n  sample code to make a 1-nn model from mfcc feature files (bianry format.. ??)\n*/\n\nint main(int argc, char**argv) \n{\n  if (argc < 3) {\n    printf(\"Usage: a.out <input mfcc file(s) ...> <output model file>\\n\");\n    return -1;\n  }\n  int i; long Nv=0;\n  float N,nVec;\n  float *means = NULL;\n\n  for (i=1; i<argc-1; i++) {\n \n  FILE *f= fopen(argv[i],\"rb\");\n  if (f==NULL) { printf(\"could not open '%s', skipping.\\n\"); continue; }\n\n  \n  fread( &N, sizeof(float), 1, f );\n  fread( &nVec, sizeof(float), 1, f );\n  int i,j;\n  if (means == NULL) means=calloc(1,sizeof(float)*(int)N);\n  float *vec=calloc(1,sizeof(float)*(int)N);\n  for (i=0; i<(int)nVec; i++) {\n    fread( vec, sizeof(float), (int)N, f );\n    for(j=0; j<(int)N; j++) {\n      means[j] += vec[j];\n    }\n    Nv++;\n  }\n  fclose(f);\n  free(vec);\n\n  }\n\n  int j;\n  for(j=0; j<(int)N; j++) {\n    means[j] /= (float)Nv;\n  }\n\n  FILE *f = fopen(argv[2],\"wb\");\n  N--;\n  fwrite( &N, sizeof(float), 1, f);\n  nVec = (float)1.0;\n  fwrite( &nVec, sizeof(float), 1, f);\n  fwrite( (means+1), sizeof(float), (int)(N-1), f);\n  fclose(f);\n\n  free(means);\n}\n\n"
  },
  {
    "path": "scripts/arff_naninfzero_checker.pl",
    "content": "#!/usr/bin/perl\n\n# This file is part of openSMILE.\n#\n# Copyright (c) audEERING. All rights reserved.\n# See the file COPYING for details on license terms.\n\n# locate nan in arff files (and inf) and display affected attribute\n\n$arff=$ARGV[0];\nunless ($arff) {\n  print \" -- locate nan in arff files (and inf) and display affected attribute --\\n\";\n  print \" -- this is useful for debugging new feature extractor components --\\n\";\n  print \"USAGE: $0 <arff_file_to_check.arff>\\n\";\n  exit;\n}\n\nopen(FILE,\"<$arff\");\n$data=0; my @attr;\n@nonzero; $N=0;\nwhile(<FILE>) {\n  my $line=$_;\n  $line=~ s/\\n$//; $line=~s/\\r$//;\n  if ($data) {\n    @el = split(/,/,$line);\n    $N=$#el+1;\n    for ($i=0; $i<=$#el; $i++) { \n     if ($el[$i] != 0.0) {\n       $nonzero[$i] = 1;\n     }\n     #if ($el[$i] !~ /^0\\.000000e\\+00/) {\n     #  $nonzero[$i] = 1;\n     #}\n     if (($el[$i] =~ /nan/i)||($el[$i] =~ /inf/i)) {\n       print \"nan/inf @ # $i = $attr[$i]\\n\";\n     }\n    }\n  } else {\n    if($line=~/^\\@data/) { $data = 1; }\n    else {\n      if($line=~/^\\@attribute ([^ ]+) /) {\n        push(@attr,$1);\n      }\n    }\n  }\n}\nclose(FILE);\n\nfor ($i=0; $i<$N; $i++) {\n  unless ($nonzero[$i]) {\n    print \"all-zero: \".$attr[$i].\"\\n\";\n  }\n}\n"
  },
  {
    "path": "scripts/avec2012/README.txt",
    "content": "Root folder:\r\n\r\navec2012/\r\n\r\nplace scripts and configs into \r\navec2012/featureextraction\r\n\r\nextract the train/test/devel zips into\r\navec2012/audio\r\n\r\nso that you have\r\navec2012/audio/devel/wav/\r\navec2012/audio/devel/words/\r\n...\r\n\r\nthen \r\ncd avec2012/featureextraction\r\n\r\nand run \"perl extr.pl\"\r\n\r\nThis creates the features in \r\navec2012/arff/\r\n\r\nFor word-level audio features,\r\n(voiced) segment level features,\r\nand phrase level features\r\n\r\nand the LLDs based on voiced segments\r\n\r\nAll the feature files include frame timestamps and durations (except for the LLD files). These are the two fields following the instance ID string (they are relative to the start time found in the instance ID strin). The instance ID string contains the start time (seconds) of the current word, phrase, or voiced segment relative to the start of the audio file. \r\n\r\nVoiced segment level functionals follow an incremental and overlapping sampling :   every 0.5s a 2s window is sampled \r\nPhrase and word functionals are computed over the whole unit (phrase or word)\r\n\r\nPhrase and voiced segment boundaries are put when a pause between words is > 1.0 seconds.\r\nThe threshold is decreased linearly for phrase boundaries it make a phrase end more likely and force it at the next pause > 0 after 20 seconds. (i.e. after 10 seconds phrase duration the threshold will be 0.5 seconds)\r\n\r\nCurrently missing: averaging of 4 LLD frames (~resampling of LLD to match the video rate...)\r\n"
  },
  {
    "path": "scripts/avec2012/avec2011_full.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file                             //////////////////\n/////////   for AVEC 2011                                            //////////////////\n/////////   based on avec2011.conf                                   //////////////////\n/////////  * written 2012 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) 2011-2013 TUM, MMK                                     //////////////////\n///////// (c) 2014 audEERING UG (limited)                            //////////////////\n/////////   All rights reserved, see file COPYING for license terms  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\n;;;;;;; component list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\nprintLevelStats=0\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;; main section ;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[waveIn].type=cWaveSource\n\n[waveIn:cWaveSource]\nwriter.dmLevel=wave\nfilename=\\cm[inputfile(I){test.wav}:name of input file]\nmonoMixdown=1\nstart = \\cm[start{0}:start in input wave file in seconds]\nend = \\cm[end{-1}:end in input wave file in seconds]\n\n;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[frame60].type=cFramer\ninstance[win60].type=cWindower\ninstance[fft60].type=cTransformFFT\ninstance[fftmp60].type=cFFTmagphase\n\n[frame60:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frame60\nframeSize = 0.060\nframeStep = 0.010\nframeCenterSpecial = left\n\n\n[win60:cWindower]\nreader.dmLevel=frame60\nwriter.dmLevel=winG60\nwinFunc=gauss\ngain=1.0\nsigma=0.4\n\n[fft60:cTransformFFT]\nreader.dmLevel=winG60\nwriter.dmLevel=fftcG60\n\n[fftmp60:cFFTmagphase]\nreader.dmLevel=fftcG60\nwriter.dmLevel=fftmagG60\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[frame25].type=cFramer\ninstance[pe25].type=cVectorPreemphasis\ninstance[win25].type=cWindower\ninstance[fft25].type=cTransformFFT\ninstance[fftmp25].type=cFFTmagphase\n\n[frame25:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frame25\nframeSize = 0.025\nframeStep = 0.010\nframeCenterSpecial = left\n\n[pe25:cVectorPreemphasis]\nreader.dmLevel=frame25\nwriter.dmLevel=frame25pe\nk=0.97\nde=0\n\n[win25:cWindower]\nreader.dmLevel=frame25\nwriter.dmLevel=winH25\nwinFunc=hamming\n\n[fft25:cTransformFFT]\nreader.dmLevel=winH25\nwriter.dmLevel=fftcH25\n\n[fftmp25:cFFTmagphase]\nreader.dmLevel=fftcH25\nwriter.dmLevel=fftmagH25\n\n\n\n;;;;;;;;;;;;;;;;;;;; HPS pitch\n\n[componentInstances:cComponentManager]\ninstance[scale].type=cSpecScale\ninstance[shs].type=cPitchShs\ninstance[pitchSmooth].type=cPitchSmootherViterbi\ninstance[energy60].type=cEnergy\ninstance[volmerge].type=cValbasedSelector\n\n[energy60:cEnergy]\nreader.dmLevel=winG60\nwriter.dmLevel=e60\nrms=1\nlog=0\nwriter.levelconf.nT=200\n\n\n[scale:cSpecScale]\nreader.dmLevel=fftmagG60\nwriter.dmLevel=hpsG60\ncopyInputName = 1\nprocessArrayFields = 0\nscale=octave\nsourceScale = lin\n// logScaleBase = 2\n// logSourceScaleBase = 2\n// firstNote = 55\ninterpMethod = spline\nminF = 20\nmaxF = -1\nnPointsTarget = 0\nspecSmooth = 1\nspecEnhance = 1\nauditoryWeighting = 1 \n\n[shs:cPitchShs]\nreader.dmLevel=hpsG60\nwriter.dmLevel=pitchShsG60\ncopyInputName = 1\nprocessArrayFields = 0\nmaxPitch = 620\nminPitch = 42\nnCandidates = 6\nscores = 1\nvoicing = 1\nF0C1 = 0\nvoicingC1 = 0\nF0raw = 1\nvoicingClip = 1\nvoicingCutoff = 0.700000\ninputFieldSearch = Mag_octScale\noctaveCorrection = 0\nnHarmonics = 15\ncompressionFactor = 0.850000\ngreedyPeakAlgo = 1\n\n[pitchSmooth:cPitchSmootherViterbi]\nreader.dmLevel=pitchShsG60\nreader2.dmLevel=pitchShsG60\nwriter.dmLevel=pitchG60a\ncopyInputName = 1\nbufferLength=90\nF0final = 1\nF0finalEnv = 0\nvoicingFinalClipped = 0\nvoicingFinalUnclipped = 1\nF0raw = 0\nvoicingC1 = 0\nvoicingClip = 0\nwTvv =10.0\nwTvvd= 5.0\nwTvuv=10.0\nwThr = 4.0\nwTuu = 0.0\nwLocal=2.0\nwRange=1.0\n\n// SHS/Viterbi pitch algo does strange things at very low amplitudes, so we filter these out \n[volmerge:cValbasedSelector]\nreader.dmLevel = e60;pitchG60a\nwriter.dmLevel = pitchG60\nidx=0\nthreshold=0.0008\nremoveIdx=1\nzeroVec=1\noutputVal=0.0\n\n\n;;;;;;;;;;;;;;;;;;; VQ\n\n[componentInstances:cComponentManager]\ninstance[pitchJitter].type=cPitchJitter\n\n\n[pitchJitter:cPitchJitter]\nreader.dmLevel = wave\nwriter.dmLevel = jitterShimmer\n// nameAppend =\ncopyInputName = 1\n; is pitchF really necessary, or can we use pitchG60 ?\nF0reader.dmLevel = pitchG60\nF0field = F0final\nsearchRangeRel = 0.250000\njitterLocal = 1\njitterDDP = 1\njitterLocalEnv = 0\njitterDDPEnv = 0\nshimmerLocal = 1\nshimmerLocalEnv = 0\nonlyVoiced = 0\nlogHNR = 1\n;periodLengths = 0\n;periodStarts = 0\n\n;;;;;;;;;;;;;;;;;;;;; Energy / loudness\n\n\n[componentInstances:cComponentManager]\ninstance[melspec1].type=cMelspec\ninstance[audspec].type=cPlp\ninstance[audspecSum].type=cVectorOperation\n\n\n[melspec1:cMelspec]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=melspec1\n; htk compatible sample value scaling\nhtkcompatible = 0\nnBands = 26\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 20\nhifreq = 8000\nspecScale = bark\n\n; perform auditory weighting of spectrum\n[audspec:cPlp]\nreader.dmLevel=melspec1\nwriter.dmLevel=audspec\nfirstCC = 0\nlpOrder = 5\ncepLifter = 22\ncompression = 0.33\nhtkcompatible = 0 \ndoIDFT = 0\ndoLpToCeps = 0\ndoLP = 0\ndoInvLog = 0\ndoAud = 1\ndoLog = 0\nnewRASTA=0\nRASTA=0\n\n[audspecSum:cVectorOperation]\nreader.dmLevel = audspec\nwriter.dmLevel = audspecSum\n// nameAppend = \ncopyInputName = 1\nprocessArrayFields = 0\noperation = ll1\nnameBase = audspec\n\n;;;;;;;;;;;;;;; spectral\n\n[componentInstances:cComponentManager]\ninstance[spectral].type=cSpectral\n\n\n[spectral:cSpectral]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=spectral\nbands[0]=250-650\nbands[1]=1000-4000\nrollOff[0] = 0.25\nrollOff[1] = 0.50\nrollOff[2] = 0.75\nrollOff[3] = 0.90\nflux=1\ncentroid=0\nmaxPos=0\nminPos=0\nentropy=1\nvariance=1\nskewness=1\nkurtosis=1\nslope=0\nsharpness = 1\ntonality = 0\nharmonicity = 1\nflatness = 0\n\n\n;;;;;;;;;;;;;;; mfcc\n\n[componentInstances:cComponentManager]\ninstance[melspecMfcc].type=cMelspec\ninstance[mfcc].type=cMfcc\n\n[melspecMfcc:cMelspec]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=melspecMfcc\ncopyInputName = 1\nprocessArrayFields = 1\n; htk compatible sample value scaling\nhtkcompatible = 1\nnBands = 26\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 20\nhifreq = 8000\nspecScale = mel\ninverse = 0\n\n[mfcc:cMfcc]\nreader.dmLevel=melspecMfcc\nwriter.dmLevel=mfcc1_12\ncopyInputName = 1\nprocessArrayFields = 1\nfirstMfcc = 1\nlastMfcc  = 10\ncepLifter = 22.0\nhtkcompatible = 1\n\n\n;;;;;;;;;;;;;;;;  zcr\n\n[componentInstances:cComponentManager]\ninstance[mzcr].type=cMZcr\n\n[mzcr:cMZcr]\nreader.dmLevel = frame25\nwriter.dmLevel = zcr\ncopyInputName = 1\nprocessArrayFields = 1\nzcr = 1\nmcr = 0\namax = 0\nmaxmin = 0\ndc = 0\n\n\n;;;;;;;;;;;;;;;;;;;; smoothing and selection\n\n[componentInstances:cComponentManager]\ninstance[smoNz].type=cContourSmoother\ninstance[smoA].type=cContourSmoother\ninstance[smoB].type=cContourSmoother\ninstance[f0sel].type=cDataSelector\ninstance[f0psel].type=cDataSelector\n\n[smoNz:cContourSmoother]\nreader.dmLevel = pitchG60;jitterShimmer\nwriter.dmLevel = lld_nzsmo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\nnoZeroSma = 1\n\n[f0sel:cDataSelector]\nreader.dmLevel = lld_nzsmo\nwriter.dmLevel = lld_f0v_nzsmo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = f0v\nselected = F0final_sma\n\n[f0psel:cDataSelector]\nreader.dmLevel = lld_nzsmo\nwriter.dmLevel = lld_f0p_nzsmo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = f0p\nselected = F0final_sma\n\n\n[smoA:cContourSmoother]\nreader.dmLevel = audspecSum;zcr\nwriter.dmLevel = lldA_smo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n[smoB:cContourSmoother]\nreader.dmLevel = spectral;mfcc1_12\nwriter.dmLevel = lldB_smo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n;;;;;;;;; deltas\n[componentInstances:cComponentManager]\ninstance[deNz].type=cDeltaRegression\ninstance[deA].type=cDeltaRegression\ninstance[deB].type=cDeltaRegression\n\n[deNz:cDeltaRegression]\nreader.dmLevel = lld_nzsmo\nwriter.dmLevel = lld_nzsmo_de\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n; TODO?  delta with zero segments removed...\n\n[deA:cDeltaRegression]\nreader.dmLevel = lldA_smo\nwriter.dmLevel = lldA_smo_de\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n[deB:cDeltaRegression]\nreader.dmLevel = lldB_smo\nwriter.dmLevel = lldB_smo_de\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n;;;;;;;;; functionals / statistics\n\n\n[componentInstances:cComponentManager]\ninstance[functionalsA].type=cFunctionals\ninstance[functionalsAde].type=cFunctionals\ninstance[functionalsF0v].type=cFunctionals\ninstance[functionalsF0p].type=cFunctionals\ninstance[functionalsNz].type=cFunctionals\ninstance[functionalsNzDe].type=cFunctionals\ninstance[functionalsDur].type=cFunctionals\n\n; functionals for energy and spectral related lld\n[functionalsA:cFunctionals]\nreader.dmLevel = lldA_smo;lldB_smo\nwriter.dmLevel = functionalsA\n// nameAppend = \ncopyInputName = 1\nframeMode = full\nframeSize = 0\nframeStep = 0\nframeCenterSpecial = left\n\nfunctionalsEnabled = Percentiles ; Means ; Moments ; Peaks2 ; Segments ; Regression ; Times ; Lpc\n\nMeans.amean = 1\nMeans.absmean = 0\nMeans.rqmean = 1\nMeans.flatness = 1\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\n\nPeaks2.numPeaks = 0\nPeaks2.meanPeakDist = 1\nPeaks2.meanPeakDistDelta = 0\nPeaks2.peakDistStddev = 1\nPeaks2.peakRangeAbs = 0\nPeaks2.peakRangeRel = 1\nPeaks2.peakMeanAbs = 0\nPeaks2.peakMeanMeanDist = 0\nPeaks2.peakMeanRel = 1\nPeaks2.ptpAmpMeanAbs = 0\nPeaks2.ptpAmpMeanRel = 0\nPeaks2.ptpAmpStddevAbs = 0\nPeaks2.ptpAmpStddevRel = 0\nPeaks2.minRangeAbs = 0\nPeaks2.minRangeRel = 1\nPeaks2.minMeanAbs = 0\nPeaks2.minMeanMeanDist = 0\nPeaks2.minMeanRel = 0\nPeaks2.mtmAmpMeanAbs = 0\nPeaks2.mtmAmpMeanRel = 0\nPeaks2.mtmAmpStddevAbs = 0\nPeaks2.mtmAmpStddevRel = 0\nPeaks2.meanRisingSlope = 1\nPeaks2.maxRisingSlope = 0\nPeaks2.minRisingSlope = 0\nPeaks2.stddevRisingSlope = 1\nPeaks2.meanFallingSlope = 1\nPeaks2.maxFallingSlope = 0\nPeaks2.minFallingSlope = 0\nPeaks2.stddevFallingSlope = 1\nPeaks2.norm = seconds\nPeaks2.relThresh = 0.100000\nPeaks2.dynRelThresh = 0\n;Peaks2.posDbgOutp = minmax.txt\nPeaks2.posDbgAppend = 0\nPeaks2.consoleDbg = 0\n\nSegments.maxNumSeg = 100\nSegments.segmentationAlgorithm = NArelTh\nSegments.thresholds = 0.25\nSegments.rangeRelThreshold = 0.200000\nSegments.numSegments = 0\nSegments.meanSegLen = 1\nSegments.maxSegLen = 1\nSegments.minSegLen = 1\nSegments.segLenStddev = 1\nSegments.norm = second\n\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\n\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\n\nRegression.linregc1 = 1\nRegression.linregc2 = 0\nRegression.linregerrA = 1\nRegression.linregerrQ = 0\nRegression.qregc1 = 1\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 1\nRegression.qregerrQ = 0\nRegression.oldBuggyQerr = 0\nRegression.centroid = 0\nRegression.normRegCoeff = 1\nRegression.normInputs = 1\n\nTimes.upleveltime25 = 1\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 1\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.buggySecNorm = 0\nTimes.norm = segment\n\nLpc.lpGain = 1\nLpc.lpc = 1\nLpc.firstCoeff = 0\nLpc.order = 5\n\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n; functionals for energy and spectral related lld\n[functionalsAde:cFunctionals]\nreader.dmLevel = lldA_smo_de;lldB_smo_de\nwriter.dmLevel = functionalsAde\n// nameAppend = \ncopyInputName = 1\nframeMode = full\nframeSize = 0\nframeStep = 0\nframeCenterSpecial = left\n\nfunctionalsEnabled = Percentiles ; Means ; Moments ; Times \nMeans.amean = 0\nMeans.posamean = 1\nMeans.absmean = 0\nMeans.rqmean = 1\nMeans.flatness = 1\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\n\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\n\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\n\nTimes.upleveltime25 = 1\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 1\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.buggySecNorm = 0\nTimes.norm = segment\n\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n\n\n; functionals for pitch onsets/offsets (voiced)\n[functionalsF0v:cFunctionals]\nreader.dmLevel = lld_f0v_nzsmo\n  ;lld_f0_nzsmo_de\nwriter.dmLevel = functionalsF0v\n//nameAppend = ff0\ncopyInputName = 1\nframeMode = full\nframeSize = 0\nframeStep = 0\nframeCenterSpecial = left\n\nfunctionalsEnabled = Means ; Segments\n\nMeans.amean = 0\nMeans.absmean = 0\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 1\nMeans.norm = segment\n\nSegments.maxNumSeg = 100\nSegments.segmentationAlgorithm = nonX\nSegments.X = 0.0\nSegments.numSegments = 0\nSegments.meanSegLen = 1\nSegments.maxSegLen = 1\nSegments.minSegLen = 1\nSegments.segLenStddev = 1\nSegments.norm = second\n\n\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n; functionals for pitch onsets (pauses)\n[functionalsF0p:cFunctionals]\nreader.dmLevel = lld_f0p_nzsmo\nwriter.dmLevel = functionalsF0p\n//nameAppend = pauses\ncopyInputName = 0\nframeMode = full\n\nframeCenterSpecial = left\nfunctionalsEnabled = Means ; Segments\nMeans.amean = 0\nMeans.posamean = 0\nMeans.absmean = 0\nMeans.qmean = 0\nMeans.rqmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 1\nMeans.flatness = 0\nMeans.norm = segment\n\nSegments.maxNumSeg = 100\nSegments.segmentationAlgorithm = eqX\nSegments.X = 0.0\nSegments.numSegments = 0\nSegments.meanSegLen = 1\nSegments.maxSegLen = 1\nSegments.minSegLen = 1\nSegments.segLenStddev = 1\nSegments.norm = second\n\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n\n; functionals for pitch and vq related lld in voiced regions\n[functionalsNz:cFunctionals]\nreader.dmLevel = lld_nzsmo\nwriter.dmLevel = functionalsNz\n// nameAppend = \ncopyInputName = 1\nframeMode = full\nframeSize = 0\nframeStep = 0\nframeCenterSpecial = left\n\nfunctionalsEnabled = Percentiles ; Means ; Moments ; Peaks2 ; Regression ; Times \n\nMeans.amean = 1\nMeans.absmean = 0\nMeans.rqmean = 1\nMeans.qmean = 0\nMeans.flatness = 1\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\n\n\nPeaks2.numPeaks = 0\nPeaks2.meanPeakDist = 1\nPeaks2.meanPeakDistDelta = 0\nPeaks2.peakDistStddev = 1\nPeaks2.peakRangeAbs = 0\nPeaks2.peakRangeRel = 1\nPeaks2.peakMeanAbs = 0\nPeaks2.peakMeanMeanDist = 0\nPeaks2.peakMeanRel = 1\nPeaks2.ptpAmpMeanAbs = 0\nPeaks2.ptpAmpMeanRel = 0\nPeaks2.ptpAmpStddevAbs = 0\nPeaks2.ptpAmpStddevRel = 0\nPeaks2.minRangeAbs = 0\nPeaks2.minRangeRel = 1\nPeaks2.minMeanAbs = 0\nPeaks2.minMeanMeanDist = 0\nPeaks2.minMeanRel = 0\nPeaks2.mtmAmpMeanAbs = 0\nPeaks2.mtmAmpMeanRel = 0\nPeaks2.mtmAmpStddevAbs = 0\nPeaks2.mtmAmpStddevRel = 0\nPeaks2.meanRisingSlope = 1\nPeaks2.maxRisingSlope = 0\nPeaks2.minRisingSlope = 0\nPeaks2.stddevRisingSlope = 1\nPeaks2.meanFallingSlope = 1\nPeaks2.maxFallingSlope = 0\nPeaks2.minFallingSlope = 0\nPeaks2.stddevFallingSlope = 1\nPeaks2.norm = seconds\nPeaks2.relThresh = 0.100000\nPeaks2.dynRelThresh = 0\n;Peaks2.posDbgOutp = minmax.txt\nPeaks2.posDbgAppend = 0\nPeaks2.consoleDbg = 0\n\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\n\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\n\nRegression.linregc1 = 1\nRegression.linregc2 = 0\nRegression.linregerrA = 1\nRegression.linregerrQ = 0\nRegression.qregc1 = 1\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 1\nRegression.qregerrQ = 0\nRegression.oldBuggyQerr = 0\nRegression.centroid = 0\nRegression.normRegCoeff = 1\nRegression.normInputs = 1\n\nTimes.upleveltime25 = 1\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 1\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.buggySecNorm = 0\nTimes.norm = segment\n\nLpc.lpGain = 1\nLpc.lpc = 1\nLpc.firstCoeff = 0\nLpc.order = 5\n\nnonZeroFuncts = 1\nmasterTimeNorm = segment\n\n\n; functionals for pitch and vq related lld in voiced regions\n[functionalsNzDe:cFunctionals]\nreader.dmLevel = lld_nzsmo_de\nwriter.dmLevel = functionalsNzDe\n// nameAppend = \ncopyInputName = 1\nframeMode = full\nframeSize = 0\nframeStep = 0\nframeCenterSpecial = left\n\nfunctionalsEnabled = Percentiles ; Means ; Moments ; Times \n\nMeans.amean = 0\nMeans.posamean = 1\nMeans.absmean = 0\nMeans.rqmean = 1\nMeans.qmean = 0\nMeans.flatness = 1\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\n\n\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\n\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\n\nTimes.upleveltime25 = 1\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 1\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.buggySecNorm = 0\nTimes.norm = segment\n\nLpc.lpGain = 1\nLpc.lpc = 1\nLpc.firstCoeff = 0\nLpc.order = 5\n\nnonZeroFuncts = 1\nmasterTimeNorm = segment\n\n; functionals for pitch and vq related lld in voiced regions\n[functionalsDur:cFunctionals]\nreader.dmLevel = lld_f0v_nzsmo\nwriter.dmLevel = functionalsDur\n// nameAppend =\ncopyInputName = 1\nframeMode = full\nframeCenterSpecial = left\nnoPostEOIprocessing=0\n\nfunctionalsEnabled = Times\n\nTimes.upleveltime25 = 0\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 0\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 0\nTimes.downleveltime90 = 0\nTimes.risetime = 0\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 1\nTimes.buggySecNorm = 0\nTimes.norm = second\n\nnonZeroFuncts = 0\nmasterTimeNorm = second\n\n\n;;;;;;;;; output all features....\n\n[componentInstances:cComponentManager]\ninstance[arffsink].type=cArffSink\n\n[arffsink:cArffSink]\nreader.dmLevel=functionalsDur;functionalsA;functionalsNz;functionalsAde;functionalsNzDe;functionalsF0v;functionalsF0p\nfilename=\\cm[output(O){default.arff}:output arff file for feature data]\nappend=1\nframeIndex=0\nframeTime=1\nrelation=avec2012_fullsegment\ninstanceName=\\cm[instname{unlabelled}:name of file which will be saved in arff file]\n ; name of class label\nclass[0].name = arousal\nclass[0].type = numeric\nclass[1].name = expectancy\nclass[1].type = numeric\nclass[2].name = power\nclass[2].type = numeric\nclass[3].name = valence\nclass[3].type = numeric\n ; the class label or value for the current instance\n\\{labels.inc}\n \n\n\n"
  },
  {
    "path": "scripts/avec2012/avec2011_list.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file                             //////////////////\n/////////   for AVEC 2012                                            //////////////////\n/////////   based on avec2011.conf                                   //////////////////\n/////////  * written 2012 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) 2011-2013 TUM, MMK                                     //////////////////\n///////// (c) 2014 audEERING UG (limited)                            //////////////////\n/////////   All rights reserved, see file COPYING for license terms  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\n;;;;;;; component list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\nprintLevelStats=0\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;; main section ;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[waveIn].type=cWaveSource\n\n[waveIn:cWaveSource]\nwriter.dmLevel=wave\nfilename=\\cm[inputfile(I){test.wav}:name of input file]\nmonoMixdown=1\nstart = \\cm[start{0}:start in input wave file in seconds]\nend = \\cm[end{-1}:end in input wave file in seconds]\n\n;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[frame60].type=cFramer\ninstance[win60].type=cWindower\ninstance[fft60].type=cTransformFFT\ninstance[fftmp60].type=cFFTmagphase\n\n[frame60:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frame60\nframeSize = 0.060\nframeStep = 0.010\nframeCenterSpecial = left\n\n\n[win60:cWindower]\nreader.dmLevel=frame60\nwriter.dmLevel=winG60\nwinFunc=gauss\ngain=1.0\nsigma=0.4\n\n[fft60:cTransformFFT]\nreader.dmLevel=winG60\nwriter.dmLevel=fftcG60\n\n[fftmp60:cFFTmagphase]\nreader.dmLevel=fftcG60\nwriter.dmLevel=fftmagG60\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[frame25].type=cFramer\ninstance[pe25].type=cVectorPreemphasis\ninstance[win25].type=cWindower\ninstance[fft25].type=cTransformFFT\ninstance[fftmp25].type=cFFTmagphase\n\n[frame25:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frame25\nframeSize = 0.025\nframeStep = 0.010\nframeCenterSpecial = left\n\n[pe25:cVectorPreemphasis]\nreader.dmLevel=frame25\nwriter.dmLevel=frame25pe\nk=0.97\nde=0\n\n[win25:cWindower]\nreader.dmLevel=frame25\nwriter.dmLevel=winH25\nwinFunc=hamming\n\n[fft25:cTransformFFT]\nreader.dmLevel=winH25\nwriter.dmLevel=fftcH25\n\n[fftmp25:cFFTmagphase]\nreader.dmLevel=fftcH25\nwriter.dmLevel=fftmagH25\n\n\n\n;;;;;;;;;;;;;;;;;;;; HPS pitch\n\n[componentInstances:cComponentManager]\ninstance[scale].type=cSpecScale\ninstance[shs].type=cPitchShs\ninstance[pitchSmooth].type=cPitchSmootherViterbi\ninstance[energy60].type=cEnergy\ninstance[volmerge].type=cValbasedSelector\n\n[energy60:cEnergy]\nreader.dmLevel=winG60\nwriter.dmLevel=e60\nrms=1\nlog=0\nwriter.levelconf.nT=200\n\n\n[scale:cSpecScale]\nreader.dmLevel=fftmagG60\nwriter.dmLevel=hpsG60\ncopyInputName = 1\nprocessArrayFields = 0\nscale=octave\nsourceScale = lin\n// logScaleBase = 2\n// logSourceScaleBase = 2\n// firstNote = 55\ninterpMethod = spline\nminF = 20\nmaxF = -1\nnPointsTarget = 0\nspecSmooth = 1\nspecEnhance = 1\nauditoryWeighting = 1 \n\n[shs:cPitchShs]\nreader.dmLevel=hpsG60\nwriter.dmLevel=pitchShsG60\ncopyInputName = 1\nprocessArrayFields = 0\nmaxPitch = 620\nminPitch = 42\nnCandidates = 6\nscores = 1\nvoicing = 1\nF0C1 = 0\nvoicingC1 = 0\nF0raw = 1\nvoicingClip = 1\nvoicingCutoff = 0.700000\ninputFieldSearch = Mag_octScale\noctaveCorrection = 0\nnHarmonics = 15\ncompressionFactor = 0.850000\ngreedyPeakAlgo = 1\n\n[pitchSmooth:cPitchSmootherViterbi]\nreader.dmLevel=pitchShsG60\nreader2.dmLevel=pitchShsG60\nwriter.dmLevel=pitchG60a\ncopyInputName = 1\nbufferLength=90\nF0final = 1\nF0finalEnv = 0\nvoicingFinalClipped = 0\nvoicingFinalUnclipped = 1\nF0raw = 0\nvoicingC1 = 0\nvoicingClip = 0\nwTvv =10.0\nwTvvd= 5.0\nwTvuv=10.0\nwThr = 4.0\nwTuu = 0.0\nwLocal=2.0\nwRange=1.0\n\n// SHS/Viterbi pitch algo does strange things at very low amplitudes, so we filter these out \n[volmerge:cValbasedSelector]\nreader.dmLevel = e60;pitchG60a\nwriter.dmLevel = pitchG60\nidx=0\nthreshold=0.0008\nremoveIdx=1\nzeroVec=1\noutputVal=0.0\n\n\n;;;;;;;;;;;;;;;;;;; VQ\n\n[componentInstances:cComponentManager]\ninstance[pitchJitter].type=cPitchJitter\n\n\n[pitchJitter:cPitchJitter]\nreader.dmLevel = wave\nwriter.dmLevel = jitterShimmer\n// nameAppend =\ncopyInputName = 1\n; is pitchF really necessary, or can we use pitchG60 ?\nF0reader.dmLevel = pitchG60\nF0field = F0final\nsearchRangeRel = 0.250000\njitterLocal = 1\njitterDDP = 1\njitterLocalEnv = 0\njitterDDPEnv = 0\nshimmerLocal = 1\nshimmerLocalEnv = 0\nonlyVoiced = 0\nlogHNR = 1\n;periodLengths = 0\n;periodStarts = 0\n\n;;;;;;;;;;;;;;;;;;;;; Energy / loudness\n\n\n[componentInstances:cComponentManager]\ninstance[melspec1].type=cMelspec\ninstance[audspec].type=cPlp\ninstance[audspecSum].type=cVectorOperation\n\n\n[melspec1:cMelspec]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=melspec1\n; htk compatible sample value scaling\nhtkcompatible = 0\nnBands = 26\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 20\nhifreq = 8000\nspecScale = bark\n\n; perform auditory weighting of spectrum\n[audspec:cPlp]\nreader.dmLevel=melspec1\nwriter.dmLevel=audspec\nfirstCC = 0\nlpOrder = 5\ncepLifter = 22\ncompression = 0.33\nhtkcompatible = 0 \ndoIDFT = 0\ndoLpToCeps = 0\ndoLP = 0\ndoInvLog = 0\ndoAud = 1\ndoLog = 0\nnewRASTA=0\nRASTA=0\n\n[audspecSum:cVectorOperation]\nreader.dmLevel = audspec\nwriter.dmLevel = audspecSum\n// nameAppend = \ncopyInputName = 1\nprocessArrayFields = 0\noperation = ll1\nnameBase = audspec\n\n;;;;;;;;;;;;;;; spectral\n\n[componentInstances:cComponentManager]\ninstance[spectral].type=cSpectral\n\n\n[spectral:cSpectral]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=spectral\nbands[0]=250-650\nbands[1]=1000-4000\nrollOff[0] = 0.25\nrollOff[1] = 0.50\nrollOff[2] = 0.75\nrollOff[3] = 0.90\nflux=1\ncentroid=0\nmaxPos=0\nminPos=0\nentropy=1\nvariance=1\nskewness=1\nkurtosis=1\nslope=0\nsharpness = 1\ntonality = 0\nharmonicity = 1\nflatness = 0\n\n\n;;;;;;;;;;;;;;; mfcc\n\n[componentInstances:cComponentManager]\ninstance[melspecMfcc].type=cMelspec\ninstance[mfcc].type=cMfcc\n\n[melspecMfcc:cMelspec]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=melspecMfcc\ncopyInputName = 1\nprocessArrayFields = 1\n; htk compatible sample value scaling\nhtkcompatible = 1\nnBands = 26\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 20\nhifreq = 8000\nspecScale = mel\ninverse = 0\n\n[mfcc:cMfcc]\nreader.dmLevel=melspecMfcc\nwriter.dmLevel=mfcc1_12\ncopyInputName = 1\nprocessArrayFields = 1\nfirstMfcc = 1\nlastMfcc  = 10\ncepLifter = 22.0\nhtkcompatible = 1\n\n\n;;;;;;;;;;;;;;;;  zcr\n\n[componentInstances:cComponentManager]\ninstance[mzcr].type=cMZcr\n\n[mzcr:cMZcr]\nreader.dmLevel = frame25\nwriter.dmLevel = zcr\ncopyInputName = 1\nprocessArrayFields = 1\nzcr = 1\nmcr = 0\namax = 0\nmaxmin = 0\ndc = 0\n\n\n;;;;;;;;;;;;;;;;;;;; smoothing and selection\n\n[componentInstances:cComponentManager]\ninstance[smoNz].type=cContourSmoother\ninstance[smoA].type=cContourSmoother\ninstance[smoB].type=cContourSmoother\ninstance[f0sel].type=cDataSelector\ninstance[f0psel].type=cDataSelector\n\n[smoNz:cContourSmoother]\nreader.dmLevel = pitchG60;jitterShimmer\nwriter.dmLevel = lld_nzsmo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\nnoZeroSma = 1\n\n[f0sel:cDataSelector]\nreader.dmLevel = lld_nzsmo\nwriter.dmLevel = lld_f0v_nzsmo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = f0v\nselected = F0final_sma\n\n[f0psel:cDataSelector]\nreader.dmLevel = lld_nzsmo\nwriter.dmLevel = lld_f0p_nzsmo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = f0p\nselected = F0final_sma\n\n\n[smoA:cContourSmoother]\nreader.dmLevel = audspecSum;zcr\nwriter.dmLevel = lldA_smo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n[smoB:cContourSmoother]\nreader.dmLevel = spectral;mfcc1_12\nwriter.dmLevel = lldB_smo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n;;;;;;;;; deltas\n[componentInstances:cComponentManager]\ninstance[deNz].type=cDeltaRegression\ninstance[deA].type=cDeltaRegression\ninstance[deB].type=cDeltaRegression\n\n[deNz:cDeltaRegression]\nreader.dmLevel = lld_nzsmo\nwriter.dmLevel = lld_nzsmo_de\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n; TODO?  delta with zero segments removed...\n\n[deA:cDeltaRegression]\nreader.dmLevel = lldA_smo\nwriter.dmLevel = lldA_smo_de\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n[deB:cDeltaRegression]\nreader.dmLevel = lldB_smo\nwriter.dmLevel = lldB_smo_de\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n;;;;;;;;; LLD dump ;;;;;;;;;;\n[componentInstances:cComponentManager]\ninstance[lldDumper].type=cArffSink\n\n[lldDumper:cArffSink]\nreader.dmLevel = lldA_smo;lldB_smo;lldA_smo_de;lldB_smo_de;lld_nzsmo;lld_nzsmo_de\nfilename = \\cm[lldArff(B){lld.arff}:arff file to write LLDs from voiced regions to]\nframeTime = 1\nframeIndex = 0\nappend = 1\nrelation = avec2012_lld\ninstanceName=\\cm[instnameLld{unlabelled}:name of file which will be saved in arff file]\n ; dummy class label for ARFF compatibility\nclass[0].name = class\nclass[0].type = numeric\ntarget[0].all = 0.0\n \n;;;;;;;;; functionals / statistics\n\n\n[componentInstances:cComponentManager]\ninstance[functionalsA].type=cFunctionals\ninstance[functionalsAde].type=cFunctionals\ninstance[functionalsF0v].type=cFunctionals\ninstance[functionalsF0p].type=cFunctionals\ninstance[functionalsNz].type=cFunctionals\ninstance[functionalsNzDe].type=cFunctionals\ninstance[functionalsDur].type=cFunctionals\n\n; functionals for energy and spectral related lld\n[functionalsA:cFunctionals]\nreader.dmLevel = lldA_smo;lldB_smo\nwriter.dmLevel = functionalsA\n// nameAppend = \ncopyInputName = 1\nframeMode = list\nframeListFile = \\cm[frameListFile{frame_functionals.list}:frame list]\nframeCenterSpecial = left\nnoPostEOIprocessing=0\n\nfunctionalsEnabled = Percentiles ; Means ; Moments ; Peaks2 ; Segments ; Regression ; Times ; Lpc\n\nMeans.amean = 1\nMeans.absmean = 0\nMeans.rqmean = 1\nMeans.flatness = 1\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\n\nPeaks2.numPeaks = 0\nPeaks2.meanPeakDist = 1\nPeaks2.meanPeakDistDelta = 0\nPeaks2.peakDistStddev = 1\nPeaks2.peakRangeAbs = 0\nPeaks2.peakRangeRel = 1\nPeaks2.peakMeanAbs = 0\nPeaks2.peakMeanMeanDist = 0\nPeaks2.peakMeanRel = 1\nPeaks2.ptpAmpMeanAbs = 0\nPeaks2.ptpAmpMeanRel = 0\nPeaks2.ptpAmpStddevAbs = 0\nPeaks2.ptpAmpStddevRel = 0\nPeaks2.minRangeAbs = 0\nPeaks2.minRangeRel = 1\nPeaks2.minMeanAbs = 0\nPeaks2.minMeanMeanDist = 0\nPeaks2.minMeanRel = 0\nPeaks2.mtmAmpMeanAbs = 0\nPeaks2.mtmAmpMeanRel = 0\nPeaks2.mtmAmpStddevAbs = 0\nPeaks2.mtmAmpStddevRel = 0\nPeaks2.meanRisingSlope = 1\nPeaks2.maxRisingSlope = 0\nPeaks2.minRisingSlope = 0\nPeaks2.stddevRisingSlope = 1\nPeaks2.meanFallingSlope = 1\nPeaks2.maxFallingSlope = 0\nPeaks2.minFallingSlope = 0\nPeaks2.stddevFallingSlope = 1\nPeaks2.norm = seconds\nPeaks2.relThresh = 0.100000\nPeaks2.dynRelThresh = 0\n;Peaks2.posDbgOutp = minmax.txt\nPeaks2.posDbgAppend = 0\nPeaks2.consoleDbg = 0\n\nSegments.maxNumSeg = 100\nSegments.segmentationAlgorithm = NArelTh\nSegments.thresholds = 0.25\nSegments.rangeRelThreshold = 0.200000\nSegments.numSegments = 0\nSegments.meanSegLen = 1\nSegments.maxSegLen = 1\nSegments.minSegLen = 1\nSegments.segLenStddev = 1\nSegments.norm = second\n\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\n\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\n\nRegression.linregc1 = 1\nRegression.linregc2 = 0\nRegression.linregerrA = 1\nRegression.linregerrQ = 0\nRegression.qregc1 = 1\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 1\nRegression.qregerrQ = 0\nRegression.oldBuggyQerr = 0\nRegression.centroid = 0\nRegression.normRegCoeff = 1\nRegression.normInputs = 1\n\nTimes.upleveltime25 = 1\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 1\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.buggySecNorm = 0\nTimes.norm = segment\n\nLpc.lpGain = 1\nLpc.lpc = 1\nLpc.firstCoeff = 0\nLpc.order = 5\n\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n; functionals for energy and spectral related lld\n[functionalsAde:cFunctionals]\nreader.dmLevel = lldA_smo_de;lldB_smo_de\nwriter.dmLevel = functionalsAde\n// nameAppend = \ncopyInputName = 1\nframeMode = list\nframeListFile = \\cm[frameListFile{frame_functionals.list}:frame list]\nframeCenterSpecial = left\nnoPostEOIprocessing=0\nfunctionalsEnabled = Percentiles ; Means ; Moments ; Times \nMeans.amean = 0\nMeans.posamean = 1\nMeans.absmean = 0\nMeans.rqmean = 1\nMeans.flatness = 1\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\n\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\n\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\n\nTimes.upleveltime25 = 1\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 1\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.buggySecNorm = 0\nTimes.norm = segment\n\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n\n\n; functionals for pitch onsets/offsets (voiced)\n[functionalsF0v:cFunctionals]\nreader.dmLevel = lld_f0v_nzsmo\n  ;lld_f0_nzsmo_de\nwriter.dmLevel = functionalsF0v\n//nameAppend = ff0\ncopyInputName = 1\nframeMode = list\nframeListFile = \\cm[frameListFile{frame_functionals.list}:frame list]\nframeCenterSpecial = left\nnoPostEOIprocessing=0\n\nfunctionalsEnabled = Means ; Segments\n\nMeans.amean = 0\nMeans.absmean = 0\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 1\nMeans.norm = segment\n\nSegments.maxNumSeg = 100\nSegments.segmentationAlgorithm = nonX\nSegments.X = 0.0\nSegments.numSegments = 0\nSegments.meanSegLen = 1\nSegments.maxSegLen = 1\nSegments.minSegLen = 1\nSegments.segLenStddev = 1\nSegments.norm = second\n\n\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n; functionals for pitch onsets (pauses)\n[functionalsF0p:cFunctionals]\nreader.dmLevel = lld_f0p_nzsmo\nwriter.dmLevel = functionalsF0p\n//nameAppend = pauses\ncopyInputName = 0\nframeMode = list\nframeListFile = \\cm[frameListFile{frame_functionals.list}:frame list]\nnoPostEOIprocessing=0\n\nframeCenterSpecial = left\nfunctionalsEnabled = Means ; Segments\nMeans.amean = 0\nMeans.posamean = 0\nMeans.absmean = 0\nMeans.qmean = 0\nMeans.rqmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 1\nMeans.flatness = 0\nMeans.norm = segment\n\nSegments.maxNumSeg = 100\nSegments.segmentationAlgorithm = eqX\nSegments.X = 0.0\nSegments.numSegments = 0\nSegments.meanSegLen = 1\nSegments.maxSegLen = 1\nSegments.minSegLen = 1\nSegments.segLenStddev = 1\nSegments.norm = second\n\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n; functionals for pitch and vq related lld in voiced regions\n[functionalsDur:cFunctionals]\nreader.dmLevel = lld_f0v_nzsmo\nwriter.dmLevel = functionalsDur\n// nameAppend = \ncopyInputName = 1\nframeMode = list\nframeListFile = \\cm[frameListFile{frame_functionals.list}:frame list]\nframeCenterSpecial = left\nnoPostEOIprocessing=0\n\nfunctionalsEnabled = Times \n\nTimes.upleveltime25 = 0\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 0\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 0\nTimes.downleveltime90 = 0\nTimes.risetime = 0\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 1\nTimes.buggySecNorm = 0\nTimes.norm = second\n\nnonZeroFuncts = 0\nmasterTimeNorm = second\n\n\n\n; functionals for pitch and vq related lld in voiced regions\n[functionalsNz:cFunctionals]\nreader.dmLevel = lld_nzsmo\nwriter.dmLevel = functionalsNz\n// nameAppend = \ncopyInputName = 1\nframeMode = list\nframeListFile = \\cm[frameListFile{frame_functionals.list}:frame list]\nframeCenterSpecial = left\nnoPostEOIprocessing=0\n\nfunctionalsEnabled = Percentiles ; Means ; Moments ; Peaks2 ; Regression ; Times \n\nMeans.amean = 1\nMeans.absmean = 0\nMeans.rqmean = 1\nMeans.qmean = 0\nMeans.flatness = 1\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\n\n\nPeaks2.numPeaks = 0\nPeaks2.meanPeakDist = 1\nPeaks2.meanPeakDistDelta = 0\nPeaks2.peakDistStddev = 1\nPeaks2.peakRangeAbs = 0\nPeaks2.peakRangeRel = 1\nPeaks2.peakMeanAbs = 0\nPeaks2.peakMeanMeanDist = 0\nPeaks2.peakMeanRel = 1\nPeaks2.ptpAmpMeanAbs = 0\nPeaks2.ptpAmpMeanRel = 0\nPeaks2.ptpAmpStddevAbs = 0\nPeaks2.ptpAmpStddevRel = 0\nPeaks2.minRangeAbs = 0\nPeaks2.minRangeRel = 1\nPeaks2.minMeanAbs = 0\nPeaks2.minMeanMeanDist = 0\nPeaks2.minMeanRel = 0\nPeaks2.mtmAmpMeanAbs = 0\nPeaks2.mtmAmpMeanRel = 0\nPeaks2.mtmAmpStddevAbs = 0\nPeaks2.mtmAmpStddevRel = 0\nPeaks2.meanRisingSlope = 1\nPeaks2.maxRisingSlope = 0\nPeaks2.minRisingSlope = 0\nPeaks2.stddevRisingSlope = 1\nPeaks2.meanFallingSlope = 1\nPeaks2.maxFallingSlope = 0\nPeaks2.minFallingSlope = 0\nPeaks2.stddevFallingSlope = 1\nPeaks2.norm = seconds\nPeaks2.relThresh = 0.100000\nPeaks2.dynRelThresh = 0\n;Peaks2.posDbgOutp = minmax.txt\nPeaks2.posDbgAppend = 0\nPeaks2.consoleDbg = 0\n\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\n\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\n\nRegression.linregc1 = 1\nRegression.linregc2 = 0\nRegression.linregerrA = 1\nRegression.linregerrQ = 0\nRegression.qregc1 = 1\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 1\nRegression.qregerrQ = 0\nRegression.oldBuggyQerr = 0\nRegression.centroid = 0\nRegression.normRegCoeff = 1\nRegression.normInputs = 1\n\nTimes.upleveltime25 = 1\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 1\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.buggySecNorm = 0\nTimes.norm = segment\n\nLpc.lpGain = 1\nLpc.lpc = 1\nLpc.firstCoeff = 0\nLpc.order = 5\n\nnonZeroFuncts = 1\nmasterTimeNorm = segment\n\n\n; functionals for pitch and vq related lld in voiced regions\n[functionalsNzDe:cFunctionals]\nreader.dmLevel = lld_nzsmo_de\nwriter.dmLevel = functionalsNzDe\n// nameAppend = \ncopyInputName = 1\nframeMode = list\nframeListFile = \\cm[frameListFile{frame_functionals.list}:frame list]\nframeCenterSpecial = left\nnoPostEOIprocessing=0\n\nfunctionalsEnabled = Percentiles ; Means ; Moments ; Times \n\nMeans.amean = 0\nMeans.posamean = 1\nMeans.absmean = 0\nMeans.rqmean = 1\nMeans.qmean = 0\nMeans.flatness = 1\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\n\n\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\n\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\n\nTimes.upleveltime25 = 1\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 1\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.buggySecNorm = 0\nTimes.norm = segment\n\nLpc.lpGain = 1\nLpc.lpc = 1\nLpc.firstCoeff = 0\nLpc.order = 5\n\nnonZeroFuncts = 1\nmasterTimeNorm = segment\n\n\n;;;;;;;;; output all features....\n\n[componentInstances:cComponentManager]\ninstance[arffsink].type=cArffSink\n\n[arffsink:cArffSink]\nreader.dmLevel=functionalsDur;functionalsA;functionalsNz;functionalsAde;functionalsNzDe;functionalsF0v;functionalsF0p\nfilename=\\cm[output(O){default.arff}:output arff file for feature data]\nappend=1\nframeIndex=0\nframeTime=1\nrelation=avec2012_segments\ninstanceName=\\cm[instname{unlabelled}:name of file which will be saved in arff file]\nclass[0].name = arousal\nclass[0].type = numeric\nclass[1].name = expectancy\nclass[1].type = numeric\nclass[2].name = power\nclass[2].type = numeric\nclass[3].name = valence\nclass[3].type = numeric\n ; the class label or value for the current instance\n\\{labels.inc}\n\n\n"
  },
  {
    "path": "scripts/avec2012/extr.pl",
    "content": "use File::Basename;\r\n\r\n##\r\n## openSMILE audio feature extraction script\r\n## for AVEC 2012 challenge\r\n## written by Florian Eyben, TUM, MMK. All rights reserved.\r\n##  (c) 2012-2013, TUM, MMK\r\n##  (c) 2014 audEERING UG (limited)                           \r\n##    All rights reserved, see file COPYING for license terms.\r\n##\r\n## This script was written for Linux, but should be portable\r\n## to windows with a few modifications.\r\n## You need \"sox\" to convert wave files to a format that openSMILE\r\n## can read (the wavext header is currently not yet supported)\r\n##\r\n\r\n# IMPORTANT: when running multiple instances of this script\r\n#  at the same time, please run from a different directory\r\n#  as the scripts will use the same filenames in the current\r\n#  directory, and thus interefere with each other!!\r\n\r\n# path to openSMILE binary\r\n$OS = \"../opensmile/inst/bin/SMILExtract\";\r\n\r\n# if set to 1, don't do extraction, just print details\r\n$debugprint = 0;\r\n\r\n# incremental functionals window parameters (.segments.arff) in seconds\r\n$samplingStep = 0.5;\r\n$samplingSize = 2.0;\r\n\r\n# the affective dimensions used in the challenge\r\n@dimensions = (\"arousal\", \"expectancy\", \"power\", \"valence\");\r\n\r\n# on which sets to run: use one of  devel, train, tests\r\n@sets = (\"devel\", \"train\", \"tests\");\r\n\r\n$label_samplingrate = 0.02;  # in seconds\r\n\r\n# temporary files created in the working directory\r\n$framelistfile = \".tmp.frame.list\";\r\n$labelincludefile = \"labels.inc\";\r\n\r\nforeach $set (@sets) {\r\n\r\n###################################################\r\n\r\n$base = \".\";\r\n$setpath = \"../audio/$set\";\r\n# output directory\r\n$arffbase = \"../arff\";\r\n$labelspath = \"$setpath/labels\";\r\nmkdir($arffbase);\r\n\r\n$conf_full = \"$base/avec2011_full.conf\";\r\n$conf_list = \"$base/avec2011_list.conf\";\r\n$arff_words = \"$arffbase/$set\\_words.arff\";\r\n$arff_phrases = \"$arffbase/$set\\_phrases.arff\";\r\n$arff_segments = \"$arffbase/$set\\_segments.arff\";\r\n$lldarff = \"$arffbase/$set\\_lld.arff\";\r\n\r\nsub deleteArffs {\r\n  my $a = $_[0];\r\n  $a =~ s/\\.arff$/*.arff/;\r\n  my @f = glob(\"$a\");\r\n  foreach $F (@f) {\r\n    unlink($F);\r\n  }\r\n}\r\n\r\n# delete existing files, as opensmile will append to them\r\n&deleteArffs($arff_words);\r\n&deleteArffs($arff_phrases);\r\n&deleteArffs($arff_segments);\r\n&deleteArffs($lldarff);\r\n\r\nsub validate_word_duration {\r\n  # old avec2011 algo for forcing minimum word length of 120ms by iteratively\r\n  # increasing the length on both sides by 10ms steps\r\n  my $start = ${$_[0]}[0];\r\n  my $end = ${$_[0]}[1];\r\n  while ($end - $start < 0.25) {\r\n        $start -= 0.01;\r\n        $end += 0.01;\r\n  }\r\n  ${$_[0]}[0] = $start;\r\n  ${$_[0]}[1] = $end;\r\n}\r\n\r\n@wds = glob(\"$setpath/words/*.txt\");\r\nforeach $wordfile (@wds) {\r\n\r\nprint \"==== wordfile: $wordfile ===\\n\";\r\n\r\nopen(F,\"<$wordfile\");\r\nmy @words;\r\nmy @segment;\r\nmy @phrase;\r\n$n = 0; $ns=0; $np=0;\r\n$t0 = 0;\r\n$s0 = -1;\r\n$p0 = -1;\r\n$curpause = 1.0;\r\nwhile(<F>) {\r\n  chomp;\r\n  $_=~s/^\\s+//;\r\n  $_=~s/\\s+$//;\r\n  @x = split(/\\s+/,$_);\r\n  $x[0] /= 1000;\r\n  $x[1] /= 1000;\r\n  $pause = $x[0] - $t0;\r\n  $words[$n][0] = $x[0];\r\n  $words[$n][1] = $x[1];\r\n  &validate_word_duration($words[$n]);\r\n  $n++;\r\n  if ($pause < 0) { $pause = 0.0; }\r\n  if ($pause > 1.0 && $s0 != -1) { # begin a new segment\r\n    $segment[$ns][0] = $s0-0.2;\r\n    $segment[$ns][1] = $t0+0.2;\r\n    $s0 = -1; $ns++;\r\n  }\r\n  if ($pause > $curpause && $p0 != -1) { # begin a new phrase\r\n    $phrase[$np][0] = $p0-0.2;\r\n    $phrase[$np][1] = $t0+0.2;\r\n    $p0 = -1; $np++; $curpause = 1.0;\r\n  }\r\n  if ($s0 == -1) { $s0 = $x[0]; }\r\n  if ($p0 == -1) { $p0 = $x[0]; }\r\n  $curpause -= ($x[1]-$t0)/5.0;\r\n  if ($curpause < 0.0) { $curpause = 0.0; }\r\n  $t0 = $x[1];\r\n}\r\nclose(F);\r\n\r\n# end the segment and phrase\r\n$segment[$ns][0] = $s0-0.25;\r\n$segment[$ns][1] = $t0+0.25;\r\n$phrase[$np][0] = $p0-0.25;\r\n$phrase[$np][1] = $t0+0.25;\r\n$np++; $ns++;\r\n\r\nsub recording_ID_from_basename {\r\n  my $basename = shift;\r\n  my $ID = \"XXX\";\r\n  if ($basename =~ /(\\d+)\\.wav$/i) {\r\n    $ID = $1;\r\n  }\r\n  return $ID;\r\n}\r\n\r\n# words, phrases: full turn conf, w. start/end\r\n# segments: incremental conf, with start end of turn, and framelist for segs\r\n\r\nsub runsmile {\r\n  my $start = shift;\r\n  my $end = shift;\r\n  my $wave = shift;\r\n  my $arff = shift;\r\n  my $conf = shift;\r\n  my $nn = shift;\r\n  my $labelinc = shift;\r\n  my $lldarff = shift;\r\n  my $framelistfile = shift;\r\n  my $extra = \"\";\r\n  if ($start < 0) { $start = 0; }\r\n  if ($end < $start) { return; }\r\n  my $basename = basename($wave); \r\n  my $ID = &recording_ID_from_basename($basename);\r\n  $basename =~ s/\\.wav$//i;\r\n  $arff =~ s/\\.arff$/$ID.arff/i;\r\n  if ($lldarff) {\r\n    $extra .= \"-lldArff \\\"$lldarff\\\" \";\r\n    $extra .= \"-instnameLld \\\"$basename.seg$nn.start$start\\\" \";\r\n  }\r\n  if ($framelistfile) {\r\n    $extra .= \"-frameListFile \\\"$framelistfile\\\"\";\r\n  }\r\n  print \"  File $wave - start=$start - end=$end\\n\";\r\n  print(\"  $OS -l 1 -C \\\"$conf\\\" -start $start -end $end -I \\\"$wave\\\" -O \\\"$arff\\\" -instname \\\"$basename.seg$nn.start$start\\\" $extra\\n\");\r\n  if ($debugprint) { return; }\r\n  $ret = system(\"$OS -l 1 -C \\\"$conf\\\" -start $start -end $end -I \\\"$wave\\\" -O \\\"$arff\\\" -instname \\\"$basename.seg$nn.start$start\\\" $extra\");\r\n  if ($ret) { exit -1; }\r\n}\r\n\r\n$wave = $wordfile;\r\n$wave =~ s/.txt$/.wav/;\r\n$wave =~ s/words\\//wav\\//;\r\n$wave =~ s/_wordTimings/_audio/;\r\n\r\n$wavebase = basename($wave);\r\nsystem(\"sox \\\"$wave\\\" -c 1 -2 -s ./$wavebase\");\r\n$wave = \"$wavebase\";\r\n\r\nmy %labels;\r\nmy $nolabels = 0;\r\n\r\nsub load_labels_file {\r\n  my $basename = shift;\r\n  my $ID = &recording_ID_from_basename($basename);\r\n  my $dim;\r\n  foreach $dim (@dimensions) {\r\n    my $labels_file = \"$labelspath/labels_continuous_$set$ID\\_$dim.dat\";\r\n    unless (-e $labels_file) {\r\n      print \"ERROR: label file $labels_file does not exist.\\n  This is ok, if you're extracting features for the tests,\\n  the target values in the arff files will all be set to 0.0 in this case.\\n\";\r\n      return 0;\r\n    }\r\n    my $n = 0;\r\n    open(LF, \"<$labels_file\");\r\n    while(<LF>) {\r\n      chomp;\r\n      $_=~s/^\\s+//; $_=~s/\\s+$//;\r\n      $labels{$dim}[$n] = $_;\r\n      $n++;\r\n    }\r\n    close(LF);\r\n  }\r\n  return 1;\r\n}\r\n\r\nmy $have_labels = &load_labels_file($wavebase);\r\n\r\nsub compute_label_for_segment {\r\n  my $start = shift;\r\n  my $end = shift;\r\n  my $dim = shift;\r\n  my $i;\r\n  my $labelsum = 0.0;\r\n  my $start_i = int($start / $label_samplingrate);\r\n  my $end_i = int($end / $label_samplingrate);\r\n  for ($i = $start_i; $i <= $end_i; $i++) {\r\n    $labelsum += $labels{$dim}[$i];\r\n  }\r\n  if ($end_i > $start_i) {\r\n    $labelsum /= ($end_i - $start_i + 1);\r\n  }\r\n  return $labelsum;\r\n}\r\n\r\nsub compute_label_string_for_segment {\r\n  my $start = shift;\r\n  my $end = shift;\r\n  my $have_labels = shift;\r\n  my $label_string = \"\";\r\n  if ($have_labels) {\r\n    foreach $dim (@dimensions) {\r\n      my $label = &compute_label_for_segment($start, $end, $dim);\r\n      $label_string .= \"-label_$dim \\\"$label\\\"\";\r\n      ## TODO: negative labels will break openSMILE option parsing!!\r\n      # Solution: have this script generate an includable config file with the targets (or one file for each dimension)\r\n    }\r\n  }\r\n  return $label_string;\r\n}\r\n\r\nsub generate_label_include_for_segment {\r\n  my $start = shift;\r\n  my $end = shift;\r\n  my $have_labels = shift;\r\n  my $segment_num = shift;\r\n  my $label_string = \"\";\r\n  if ($have_labels) {\r\n    my $d = 0;\r\n    foreach $dim (@dimensions) {\r\n      my $label = &compute_label_for_segment($start, $end, $dim);\r\n      if ($segment_num) {\r\n        $label_string .= \"target[$d].instance[\".($segment_num - 1).\"] = $label\\n\";\r\n      } else {\r\n        $label_string .= \"target[$d].all = $label\\n\";\r\n      }\r\n      $d++;\r\n    }\r\n  } else {\r\n    my $d = 0;\r\n    foreach $dim (@dimensions) {\r\n      if ($segment_num) {\r\n        $label_string .= \"target[$d].instance[\".($segment_num - 1).\"] = 0.0\\n\";\r\n      } else {\r\n        $label_string .= \"target[$d].all = 0.0\\n\";\r\n      }\r\n      $d++;\r\n    }\r\n  }\r\n  return $label_string;\r\n}\r\n\r\n# words\r\nprint \"Num words: $n\\n\";\r\nfor ($i=0; $i<$n; $i++) {\r\n  my $label_str = &generate_label_include_for_segment($words[$i][0], $words[$i][1], $have_labels);\r\n  print \"  word $i : $words[$i][0] - $words[$i][1]\\n\";\r\n  open(F,\">$labelincludefile\");\r\n  print F $label_str.\"\\n\";\r\n  close(F);\r\n  &runsmile($words[$i][0], $words[$i][1], $wave, $arff_words, $conf_full, $i, $labelincludefile);\r\n}\r\n\r\n# phrases\r\nif(0) {\r\nprint \"Num phrases: $np\\n\";\r\nfor ($i=0; $i<$np; $i++) {\r\n  my $label_str = &generate_label_include_for_segment($phrase[$i][0], $phrase[$i][1], $have_labels);\r\n  print \"  phrase $i : $phrase[$i][0] - $phrase[$i][1]\\n\";\r\n  open(F,\">$labelincludefile\");\r\n  print F $label_str.\"\\n\";\r\n  close(F);\r\n  &runsmile($phrase[$i][0], $phrase[$i][1], $wave, $arff_phrases, $conf_full, $i, $labelincludeile);\r\n}\r\n}\r\n\r\n# segments\r\nprint \"Num segments: $ns\\n\";\r\nfor ($i=0; $i<$ns; $i++) {\r\n  # generate frame list\r\n  $len = $segment[$i][1] - $segment[$i][0];\r\n  $framelist = \"\";\r\n  my $label_str = \"\";\r\n  my $n = 0;\r\n  if ($len > ($samplingSize-$samplingStep+0.05)) {\r\n  for ($j=0; $j<$len-($samplingSize-$samplingStep); $j+=$samplingStep) {\r\n    $st = $j;\r\n    $ed = $st+$samplingSize;\r\n    if ($ed > $len-0.05) { $ed = $len-0.05; }\r\n    $framelist .= $st.\"s-\".$ed.\"s,\";\r\n    $label_str .= &generate_label_include_for_segment($segment[$i][0] + $st, $segment[$i][0] + $ed, $have_labels, $n + 1);\r\n    $n++;\r\n  }\r\n  } else {\r\n    $framelist = \"0s-$len\".\"s,\";\r\n    $label_str .= &generate_label_include_for_segment($segment[$i][0] + $st, $segment[$i][0] + $ed, $have_labels, $n + 1);\r\n    $n++;\r\n  }\r\n  chop($framelist);\r\n  \r\n  open(F,\">$labelincludefile\");\r\n  print F $label_str.\"\\n\";\r\n  close(F);\r\n  open(F,\">$framelistfile\");\r\n  print F $framelist;\r\n  close(F);\r\n  print \"  segment $i : $segment[$i][0] - $segment[$i][1]\\n\";\r\n  print \"    FRAMELIST($ns, $len): $framelist\\n\";\r\n  &runsmile($segment[$i][0], $segment[$i][1], $wave, $arff_segments, $conf_list, $i, $labelincludefile, $lldarff, $framelistfile);\r\n}\r\nunlink($framelistfile);\r\nunlink(\"$wavebase\");\r\n\r\n}\r\n}\r\n\r\n\r\n"
  },
  {
    "path": "scripts/avec2012/labels.inc",
    "content": ""
  },
  {
    "path": "scripts/avec2013/avec2013_functionals.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file                             //////////////////\n/////////   for AVEC 2013                                            //////////////////\n/////////   based on avec2011.conf                                   //////////////////\n/////////  * written 2013 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) 2013 TUM, MMK                                          //////////////////\n///////// (c) 2014-2016 audEERING                                    //////////////////\n/////////   All rights reserved, see file COPYING for license terms  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\\{avec2013_lld_core.conf}\n\\{avec2013_functionals_core.conf}\n\n;;;;;;;;; output all features....\n\n[componentInstances:cComponentManager]\ninstance[arffsink].type=cArffSink\n\n[arffsink:cArffSink]\nreader.dmLevel=functionalsDur;functionalsA;functionalsNz;functionalsAde;functionalsNzDe;functionalsF0v;functionalsF0p\nfilename=\\cm[output(O){default_functionals.arff}:output arff file for feature data]\nappend=1\nframeIndex=0\nframeTime=1\nframeTimeAdd=\\cm[frameTimeAdd(F){0}:frame time offset (start of segment in seconds)]\nrelation=\\cm[frameModeConf]\ninstanceName=\\cm[instname{unlabelled}:name of file which will be saved in arff file]\nerrorOnNoOutput = 1\nclass[0].name = unused_target_label\nclass[0].type = numeric\ntarget[0].all = 0.0\n\n;; more class labels, nor used for now..\n;class[0].name = arousal\n;class[0].type = numeric\n;class[1].name = valence\n;class[1].type = numeric\n;class[2].type = depression\n;class[2].type = numeric\n ; the class label or value for the current instance\n;\\{labels.inc}\n \n\n\n"
  },
  {
    "path": "scripts/avec2013/avec2013_functionals_core.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file                             //////////////////\n/////////   for AVEC 2013                                            //////////////////\n/////////   based on avec2011.conf                                   //////////////////\n/////////  * written 2013 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) 2013 TUM, MMK                                          //////////////////\n///////// (c) 2014 audEERING                                         //////////////////\n/////////   All rights reserved, see file COPYING for license terms  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\n;;;;;;;;; functionals / statistics\n\n\n[componentInstances:cComponentManager]\ninstance[functionalsA].type=cFunctionals\ninstance[functionalsAde].type=cFunctionals\ninstance[functionalsF0v].type=cFunctionals\ninstance[functionalsF0p].type=cFunctionals\ninstance[functionalsNz].type=cFunctionals\ninstance[functionalsNzDe].type=cFunctionals\ninstance[functionalsDur].type=cFunctionals\n\n; functionals for energy and spectral related lld\n[functionalsA:cFunctionals]\nreader.dmLevel = lldA_smo;lldB_smo\nwriter.dmLevel = functionalsA\n// nameAppend = \ncopyInputName = 1\n\\{\\cm[frameModeConf{avec2013_functionals_frame_mode.conf}:functionals frame mode config]}\n\nfunctionalsEnabled = Percentiles ; Means ; Moments ; Peaks2 ; Segments ; Regression ; Times ; Lpc\n\nMeans.amean = 1\nMeans.absmean = 0\nMeans.rqmean = 1\nMeans.flatness = 1\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\n\nPeaks2.doRatioLimit = 0\nPeaks2.numPeaks = 0\nPeaks2.meanPeakDist = 1\nPeaks2.meanPeakDistDelta = 0\nPeaks2.peakDistStddev = 1\nPeaks2.peakRangeAbs = 0\nPeaks2.peakRangeRel = 1\nPeaks2.peakMeanAbs = 0\nPeaks2.peakMeanMeanDist = 0\nPeaks2.peakMeanRel = 1\nPeaks2.ptpAmpMeanAbs = 0\nPeaks2.ptpAmpMeanRel = 0\nPeaks2.ptpAmpStddevAbs = 0\nPeaks2.ptpAmpStddevRel = 0\nPeaks2.minRangeAbs = 0\nPeaks2.minRangeRel = 1\nPeaks2.minMeanAbs = 0\nPeaks2.minMeanMeanDist = 0\nPeaks2.minMeanRel = 0\nPeaks2.mtmAmpMeanAbs = 0\nPeaks2.mtmAmpMeanRel = 0\nPeaks2.mtmAmpStddevAbs = 0\nPeaks2.mtmAmpStddevRel = 0\nPeaks2.meanRisingSlope = 1\nPeaks2.maxRisingSlope = 0\nPeaks2.minRisingSlope = 0\nPeaks2.stddevRisingSlope = 1\nPeaks2.meanFallingSlope = 1\nPeaks2.maxFallingSlope = 0\nPeaks2.minFallingSlope = 0\nPeaks2.stddevFallingSlope = 1\nPeaks2.norm = seconds\nPeaks2.relThresh = 0.100000\nPeaks2.dynRelThresh = 0\n;Peaks2.posDbgOutp = minmax.txt\nPeaks2.posDbgAppend = 0\nPeaks2.consoleDbg = 0\n\nSegments.maxNumSeg = 100\nSegments.segmentationAlgorithm = NArelTh\nSegments.thresholds = 0.25\nSegments.rangeRelThreshold = 0.200000\nSegments.numSegments = 0\nSegments.meanSegLen = 1\nSegments.maxSegLen = 1\nSegments.minSegLen = 1\nSegments.segLenStddev = 1\nSegments.norm = second\n\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nMoments.doRatioLimit = 0\n\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\n\nRegression.linregc1 = 1\nRegression.linregc2 = 0\nRegression.linregerrA = 1\nRegression.linregerrQ = 0\nRegression.qregc1 = 1\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 1\nRegression.qregerrQ = 0\nRegression.oldBuggyQerr = 0\nRegression.centroid = 0\nRegression.normRegCoeff = 1\nRegression.normInputs = 1\nRegression.centroidUseAbsValues = 0\nRegression.centroidRatioLimit = 0\nRegression.doRatioLimit = 0\n\nTimes.upleveltime25 = 1\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 1\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.buggySecNorm = 0\nTimes.norm = segment\n\nLpc.lpGain = 1\nLpc.lpc = 1\nLpc.firstCoeff = 0\nLpc.order = 5\n\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n; functionals for energy and spectral related lld (deltas)\n[functionalsAde:cFunctionals]\nreader.dmLevel = lldA_smo_de;lldB_smo_de\nwriter.dmLevel = functionalsAde\n// nameAppend = \ncopyInputName = 1\n\\{\\cm[frameModeConf]}\n\nfunctionalsEnabled = Percentiles ; Means ; Moments ; Times \nMeans.amean = 0\nMeans.posamean = 1\nMeans.absmean = 0\nMeans.rqmean = 1\nMeans.flatness = 1\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\n\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nMoments.doRatioLimit = 0\n\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\n\nTimes.upleveltime25 = 1\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 1\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.buggySecNorm = 0\nTimes.norm = segment\n\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n\n\n; functionals for voiced segments and pitch onsets\n[functionalsF0v:cFunctionals]\nreader.dmLevel = lld_f0v_nzsmo\n  ;lld_f0_nzsmo_de\nwriter.dmLevel = functionalsF0v\n//nameAppend = ff0\ncopyInputName = 1\n\\{\\cm[frameModeConf]}\nfunctionalsEnabled = Means ; Segments\nMeans.amean = 0\nMeans.absmean = 0\nMeans.qmean = 0\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 1\nMeans.norm = segment\nSegments.maxNumSeg = 999\nSegments.segmentationAlgorithm = nonX\nSegments.X = 0.0\nSegments.numSegments = 0\nSegments.meanSegLen = 1\nSegments.maxSegLen = 1\nSegments.minSegLen = 1\nSegments.segLenStddev = 1\nSegments.norm = second\nOnset.threshold = 1\nOnset.onsetRate = 1\nOnset.norm = second\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n; functionals for unvoiced segments\n[functionalsF0p:cFunctionals]\nreader.dmLevel = lld_f0p_nzsmo\nwriter.dmLevel = functionalsF0p\n//nameAppend = pauses\ncopyInputName = 0\n\\{\\cm[frameModeConf]}\nframeCenterSpecial = left\nfunctionalsEnabled = Segments\nSegments.maxNumSeg = 999\nSegments.segmentationAlgorithm = eqX\nSegments.X = 0.0\nSegments.numSegments = 0\nSegments.meanSegLen = 1\nSegments.maxSegLen = 1\nSegments.minSegLen = 1\nSegments.segLenStddev = 1\nSegments.norm = second\nnonZeroFuncts = 0\nmasterTimeNorm = segment\n\n\n\n; functionals for pitch and vq related lld in voiced regions\n[functionalsNz:cFunctionals]\nreader.dmLevel = lld_nzsmo\nwriter.dmLevel = functionalsNz\n// nameAppend = \ncopyInputName = 1\n\\{\\cm[frameModeConf]}\nfunctionalsEnabled = Percentiles ; Means ; Moments ; Peaks2 ; Regression ; Times \nMeans.amean = 1\nMeans.absmean = 0\nMeans.rqmean = 1\nMeans.qmean = 0\nMeans.flatness = 1\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\nPeaks2.doRatioLimit = 0\nPeaks2.numPeaks = 0\nPeaks2.meanPeakDist = 1\nPeaks2.meanPeakDistDelta = 0\nPeaks2.peakDistStddev = 1\nPeaks2.peakRangeAbs = 0\nPeaks2.peakRangeRel = 1\nPeaks2.peakMeanAbs = 0\nPeaks2.peakMeanMeanDist = 0\nPeaks2.peakMeanRel = 1\nPeaks2.ptpAmpMeanAbs = 0\nPeaks2.ptpAmpMeanRel = 0\nPeaks2.ptpAmpStddevAbs = 0\nPeaks2.ptpAmpStddevRel = 0\nPeaks2.minRangeAbs = 0\nPeaks2.minRangeRel = 1\nPeaks2.minMeanAbs = 0\nPeaks2.minMeanMeanDist = 0\nPeaks2.minMeanRel = 0\nPeaks2.mtmAmpMeanAbs = 0\nPeaks2.mtmAmpMeanRel = 0\nPeaks2.mtmAmpStddevAbs = 0\nPeaks2.mtmAmpStddevRel = 0\nPeaks2.meanRisingSlope = 1\nPeaks2.maxRisingSlope = 0\nPeaks2.minRisingSlope = 0\nPeaks2.stddevRisingSlope = 1\nPeaks2.meanFallingSlope = 1\nPeaks2.maxFallingSlope = 0\nPeaks2.minFallingSlope = 0\nPeaks2.stddevFallingSlope = 1\nPeaks2.norm = seconds\nPeaks2.relThresh = 0.100000\nPeaks2.dynRelThresh = 0\n;Peaks2.posDbgOutp = minmax.txt\nPeaks2.posDbgAppend = 0\nPeaks2.consoleDbg = 0\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\nRegression.linregc1 = 1\nRegression.linregc2 = 0\nRegression.linregerrA = 1\nRegression.linregerrQ = 0\nRegression.qregc1 = 1\nRegression.qregc2 = 0\nRegression.qregc3 = 0\nRegression.qregerrA = 1\nRegression.qregerrQ = 0\nRegression.oldBuggyQerr = 0\nRegression.centroid = 0\nRegression.normRegCoeff = 1\nRegression.normInputs = 1\nRegression.centroidUseAbsValues = 0\nRegression.centroidRatioLimit = 0\nRegression.doRatioLimit = 0\nTimes.upleveltime25 = 1\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 1\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.buggySecNorm = 0\nTimes.norm = segment\nLpc.lpGain = 1\nLpc.lpc = 1\nLpc.firstCoeff = 0\nLpc.order = 5\nnonZeroFuncts = 1\nmasterTimeNorm = segment\n\n\n; functionals for pitch and vq related lld in voiced regions (deltas)\n[functionalsNzDe:cFunctionals]\nreader.dmLevel = lld_nzsmo_de\nwriter.dmLevel = functionalsNzDe\n// nameAppend = \ncopyInputName = 1\n\\{\\cm[frameModeConf]}\nfunctionalsEnabled = Percentiles ; Means ; Moments ; Times \nMeans.amean = 0\nMeans.posamean = 1\nMeans.absmean = 0\nMeans.rqmean = 1\nMeans.qmean = 0\nMeans.flatness = 1\nMeans.nzamean = 0\nMeans.nzabsmean = 0\nMeans.nzqmean = 0\nMeans.nzgmean = 0\nMeans.nnz = 0\nMeans.norm = frames\nMoments.variance = 0\nMoments.stddev = 1\nMoments.skewness = 1\nMoments.kurtosis = 1\nMoments.amean = 0\nMoments.doRatioLimit = 0\nPercentiles.quartiles = 1\nPercentiles.iqr = 1\nPercentiles.percentile[0] = 0.01\nPercentiles.percentile[1] = 0.99\nPercentiles.pctlrange[0] = 0-1\nPercentiles.interp = 1\nTimes.upleveltime25 = 1\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 1\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 1\nTimes.downleveltime90 = 0\nTimes.risetime = 1\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 0\nTimes.buggySecNorm = 0\nTimes.norm = segment\nLpc.lpGain = 1\nLpc.lpc = 1\nLpc.firstCoeff = 0\nLpc.order = 5\nnonZeroFuncts = 1\nmasterTimeNorm = segment\n\n\n; functionals for input segment duration\n[functionalsDur:cFunctionals]\nreader.dmLevel = lld_f0v_nzsmo\nwriter.dmLevel = functionalsDur\n// nameAppend =\ncopyInputName = 1\n\\{\\cm[frameModeConf]}\nnoPostEOIprocessing=0\nfunctionalsEnabled = Times\nTimes.upleveltime25 = 0\nTimes.downleveltime25 = 0\nTimes.upleveltime50 = 0\nTimes.downleveltime50 = 0\nTimes.upleveltime75 = 0\nTimes.downleveltime75 = 0\nTimes.upleveltime90 = 0\nTimes.downleveltime90 = 0\nTimes.risetime = 0\nTimes.falltime = 0\nTimes.leftctime = 0\nTimes.rightctime = 0\nTimes.duration = 1\nTimes.buggySecNorm = 0\nTimes.norm = second\nnonZeroFuncts = 0\nmasterTimeNorm = second\n\n\n\n\n\n"
  },
  {
    "path": "scripts/avec2013/avec2013_functionals_frame_mode.conf",
    "content": "\nframeMode = full\nframeSize = 0\nframeStep = 0\nframeCenterSpecial = left\n\n"
  },
  {
    "path": "scripts/avec2013/avec2013_functionals_frame_mode_long.conf",
    "content": "\nframeMode = fixed\nframeSize = 20.0\nframeStep = 2.0\nframeCenterSpecial = left\n\n"
  },
  {
    "path": "scripts/avec2013/avec2013_functionals_frame_mode_short.conf",
    "content": "\nframeMode = fixed\nframeSize = 3.0\nframeStep = 2.0\nframeCenterSpecial = left\n\n"
  },
  {
    "path": "scripts/avec2013/avec2013_functionals_frame_mode_short_with_last.conf",
    "content": "\nframeMode = fixed\nframeSize = 3.0\nframeStep = 2.0\nframeCenterSpecial = left\nallowLastFrameIncomplete = 1\n\n"
  },
  {
    "path": "scripts/avec2013/avec2013_lld_arff.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file                             //////////////////\n/////////   for AVEC 2013                                            //////////////////\n/////////   based on avec2011.conf                                   //////////////////\n/////////  * written 2013 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) 2013 TUM, MMK                                          //////////////////\n///////// (c) 2014 audEERING UG (limited)                            //////////////////\n/////////   All rights reserved, see file COPYING for license terms  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\\{avec2013_lld_core.conf}\n\n;;;;;;;;; output all features....\n\n[componentInstances:cComponentManager]\ninstance[arffsink].type=cArffSink\n\n[arffsink:cArffSink]\nreader.dmLevel=lldA_smo;lldA_smo_de;lldB_smo;lldB_smo_de;lld_nzsmo;lld_nzsmo_de\nfilename=\\cm[output_arff{default_lld.arff}:output arff file for feature data]\nappend=0\nframeIndex=0\nframeTime=1\nrelation=avec2013_lld_per_session\ninstanceBase=\\cm[instname{unlabelled}:name of file which will be saved in arff file]\nerrorOnNoOutput = 1\nclass[0].name = unused_target_label\nclass[0].type = numeric\ntarget[0].all = 0.0\n\n;; more class labels, nor used for now..\n;class[0].name = arousal\n;class[0].type = numeric\n;class[1].name = valence\n;class[1].type = numeric\n;class[2].type = depression\n;class[2].type = numeric\n ; the class label or value for the current instance\n;\\{labels.inc}\n \n\n\n"
  },
  {
    "path": "scripts/avec2013/avec2013_lld_core.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file                             //////////////////\n/////////   for AVEC 2013                                            //////////////////\n/////////   based on avec2011.conf                                   //////////////////\n/////////  * written 2013 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) 2013 TUM, MMK                                          //////////////////\n///////// (c) 2014-2016 audEERING                                    //////////////////\n/////////   All rights reserved, see file COPYING for license terms  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\n;;;;;;; component list ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[dataMemory].type=cDataMemory\nprintLevelStats=0\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;; main section ;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[waveIn].type=cWaveSource\n\n[waveIn:cWaveSource]\nwriter.dmLevel=wave\nfilename=\\cm[inputfile(I){test.wav}:name of input file]\nmonoMixdown=1\nstart = \\cm[start{0}:start in input wave file in seconds]\nend = \\cm[end{-1}:end in input wave file in seconds]\n\n;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[frame60].type=cFramer\ninstance[win60].type=cWindower\ninstance[fft60].type=cTransformFFT\ninstance[fftmp60].type=cFFTmagphase\n\n[frame60:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frame60\nframeSize = 0.060\nframeStep = 0.010\nframeCenterSpecial = left\n\n\n[win60:cWindower]\nreader.dmLevel=frame60\nwriter.dmLevel=winG60\nwinFunc=gauss\ngain=1.0\nsigma=0.4\n\n[fft60:cTransformFFT]\nreader.dmLevel=winG60\nwriter.dmLevel=fftcG60\nzeroPadSymmetric = 0\n\n[fftmp60:cFFTmagphase]\nreader.dmLevel=fftcG60\nwriter.dmLevel=fftmagG60\n\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n[componentInstances:cComponentManager]\ninstance[frame25].type=cFramer\ninstance[pe25].type=cVectorPreemphasis\ninstance[win25].type=cWindower\ninstance[fft25].type=cTransformFFT\ninstance[fftmp25].type=cFFTmagphase\n\n[frame25:cFramer]\nreader.dmLevel=wave\nwriter.dmLevel=frame25\nframeSize = 0.025\nframeStep = 0.010\nframeCenterSpecial = left\n\n[pe25:cVectorPreemphasis]\nreader.dmLevel=frame25\nwriter.dmLevel=frame25pe\nk=0.97\nde=0\n\n[win25:cWindower]\nreader.dmLevel=frame25\nwriter.dmLevel=winH25\nwinFunc=hamming\n\n[fft25:cTransformFFT]\nreader.dmLevel=winH25\nwriter.dmLevel=fftcH25\nzeroPadSymmetric = 0\n\n[fftmp25:cFFTmagphase]\nreader.dmLevel=fftcH25\nwriter.dmLevel=fftmagH25\n\n\n\n;;;;;;;;;;;;;;;;;;;; HPS pitch\n\n[componentInstances:cComponentManager]\ninstance[scale].type=cSpecScale\ninstance[shs].type=cPitchShs\ninstance[pitchSmooth].type=cPitchSmootherViterbi\ninstance[energy60].type=cEnergy\ninstance[volmerge].type=cValbasedSelector\n\n[energy60:cEnergy]\nreader.dmLevel=winG60\nwriter.dmLevel=e60\nrms=1\nlog=0\nwriter.levelconf.nT=200\n\n\n[scale:cSpecScale]\nreader.dmLevel=fftmagG60\nwriter.dmLevel=hpsG60\ncopyInputName = 1\nprocessArrayFields = 0\nscale=octave\nsourceScale = lin\n// logScaleBase = 2\n// logSourceScaleBase = 2\n// firstNote = 55\ninterpMethod = spline\nminF = 20\nmaxF = -1\nnPointsTarget = 0\nspecSmooth = 1\nspecEnhance = 1\nauditoryWeighting = 1 \n\n[shs:cPitchShs]\nreader.dmLevel=hpsG60\nwriter.dmLevel=pitchShsG60\ncopyInputName = 1\nprocessArrayFields = 0\nmaxPitch = 620\nminPitch = 42\nnCandidates = 6\nscores = 1\nvoicing = 1\nF0C1 = 0\nvoicingC1 = 0\nF0raw = 1\nvoicingClip = 1\nvoicingCutoff = 0.700000\ninputFieldSearch = Mag_octScale\noctaveCorrection = 0\nnHarmonics = 15\ncompressionFactor = 0.850000\ngreedyPeakAlgo = 1\n\n[pitchSmooth:cPitchSmootherViterbi]\nreader.dmLevel=pitchShsG60\nreader2.dmLevel=pitchShsG60\nwriter.dmLevel=pitchG60a\ncopyInputName = 1\nbufferLength=90\nF0final = 1\nF0finalEnv = 0\nvoicingFinalClipped = 0\nvoicingFinalUnclipped = 1\nF0raw = 0\nvoicingC1 = 0\nvoicingClip = 0\nwTvv =10.0\nwTvvd= 5.0\nwTvuv=10.0\nwThr = 4.0\nwTuu = 0.0\nwLocal=2.0\nwRange=1.0\n\n// SHS/Viterbi pitch algo does strange things at very low amplitudes, so we filter these out \n[volmerge:cValbasedSelector]\nreader.dmLevel = e60;pitchG60a\nwriter.dmLevel = pitchG60\nidx=0\nthreshold=0.0008\nremoveIdx=1\nzeroVec=1\noutputVal=0.0\n\n\n;;;;;;;;;;;;;;;;;;; VQ\n\n[componentInstances:cComponentManager]\ninstance[pitchJitter].type=cPitchJitter\n\n\n[pitchJitter:cPitchJitter]\nreader.dmLevel = wave\nwriter.dmLevel = jitterShimmer\n// nameAppend =\ncopyInputName = 1\n; is pitchF really necessary, or can we use pitchG60 ?\nF0reader.dmLevel = pitchG60\nF0field = F0final\nsearchRangeRel = 0.250000\njitterLocal = 1\njitterDDP = 1\njitterLocalEnv = 0\njitterDDPEnv = 0\nshimmerLocal = 1\nshimmerLocalEnv = 0\nonlyVoiced = 0\nlogHNR = 1\ninputMaxDelaySec = 2.0\n;periodLengths = 0\n;periodStarts = 0\nuseBrokenJitterThresh = 1\n\n;;;;;;;;;;;;;;;;;;;;; Energy / loudness\n\n\n[componentInstances:cComponentManager]\ninstance[melspec1].type=cMelspec\ninstance[audspec].type=cPlp\ninstance[audspecSum].type=cVectorOperation\n\n\n[melspec1:cMelspec]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=melspec1\n; htk compatible sample value scaling\nhtkcompatible = 0\nnBands = 26\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 20\nhifreq = 8000\nspecScale = bark\n\n; perform auditory weighting of spectrum\n[audspec:cPlp]\nreader.dmLevel=melspec1\nwriter.dmLevel=audspec\nfirstCC = 0\nlpOrder = 5\ncepLifter = 22\ncompression = 0.33\nhtkcompatible = 0 \ndoIDFT = 0\ndoLpToCeps = 0\ndoLP = 0\ndoInvLog = 0\ndoAud = 1\ndoLog = 0\nnewRASTA=0\nRASTA=0\n\n[audspecSum:cVectorOperation]\nreader.dmLevel = audspec\nwriter.dmLevel = audspecSum\n// nameAppend = \ncopyInputName = 1\nprocessArrayFields = 0\noperation = ll1\nnameBase = audspec\n\n;;;;;;;;;;;;;;; spectral\n\n[componentInstances:cComponentManager]\ninstance[spectral].type=cSpectral\n\n\n[spectral:cSpectral]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=spectral\nbands[0]=250-650\nbands[1]=1000-4000\nrollOff[0] = 0.25\nrollOff[1] = 0.50\nrollOff[2] = 0.75\nrollOff[3] = 0.90\nflux=1\ncentroid=0\nmaxPos=0\nminPos=0\nentropy=1\nvariance=1\nskewness=1\nkurtosis=1\nslope=0\nsharpness = 1\ntonality = 0\nharmonicity = 1\nflatness = 1\n\n\n;;;;;;;;;;;;;;; mfcc\n\n[componentInstances:cComponentManager]\ninstance[melspecMfcc].type=cMelspec\ninstance[mfcc].type=cMfcc\n\n[melspecMfcc:cMelspec]\nreader.dmLevel=fftmagH25\nwriter.dmLevel=melspecMfcc\ncopyInputName = 1\nprocessArrayFields = 1\n; htk compatible sample value scaling\nhtkcompatible = 1\nnBands = 26\n; use power spectrum instead of magnitude spectrum\nusePower = 1\nlofreq = 20\nhifreq = 8000\nspecScale = mel\ninverse = 0\n\n[mfcc:cMfcc]\nreader.dmLevel=melspecMfcc\nwriter.dmLevel=mfcc1_12\ncopyInputName = 1\nprocessArrayFields = 1\nfirstMfcc = 1\nlastMfcc  = 16\ncepLifter = 22.0\nhtkcompatible = 1\n\n\n;;;;;;;;;;;;;;;;  zcr\n\n[componentInstances:cComponentManager]\ninstance[mzcr].type=cMZcr\n\n[mzcr:cMZcr]\nreader.dmLevel = frame25\nwriter.dmLevel = zcr\ncopyInputName = 1\nprocessArrayFields = 1\nzcr = 1\nmcr = 0\namax = 0\nmaxmin = 0\ndc = 0\n\n\n;;;;;;;;;;;;;;;;;;;; smoothing and selection\n\n[componentInstances:cComponentManager]\ninstance[smoNz].type=cContourSmoother\ninstance[smoA].type=cContourSmoother\ninstance[smoB].type=cContourSmoother\ninstance[f0sel].type=cDataSelector\ninstance[f0psel].type=cDataSelector\n\n[smoNz:cContourSmoother]\nreader.dmLevel = pitchG60;jitterShimmer\nwriter.dmLevel = lld_nzsmo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\nnoZeroSma = 1\n\n[f0sel:cDataSelector]\nreader.dmLevel = lld_nzsmo\nwriter.dmLevel = lld_f0v_nzsmo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = f0v\nselected = F0final_sma\n\n[f0psel:cDataSelector]\nreader.dmLevel = lld_nzsmo\nwriter.dmLevel = lld_f0p_nzsmo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = f0p\nselected = F0final_sma\n\n\n[smoA:cContourSmoother]\nreader.dmLevel = audspecSum;zcr\nwriter.dmLevel = lldA_smo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n[smoB:cContourSmoother]\nreader.dmLevel = spectral;mfcc1_12\nwriter.dmLevel = lldB_smo\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nnameAppend = sma\ncopyInputName = 1\nnoPostEOIprocessing = 0\nsmaWin = 3\n\n;;;;;;;;; deltas\n[componentInstances:cComponentManager]\ninstance[deNz].type=cDeltaRegression\ninstance[deA].type=cDeltaRegression\ninstance[deB].type=cDeltaRegression\n\n[deNz:cDeltaRegression]\nreader.dmLevel = lld_nzsmo\nwriter.dmLevel = lld_nzsmo_de\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\nonlyInSegments = 1\nzeroSegBound = 1\n; TODO?  delta with zero segments removed...\n\n[deA:cDeltaRegression]\nreader.dmLevel = lldA_smo\nwriter.dmLevel = lldA_smo_de\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n[deB:cDeltaRegression]\nreader.dmLevel = lldB_smo\nwriter.dmLevel = lldB_smo_de\nwriter.levelconf.isRb=0\nwriter.levelconf.growDyn=1\n\n\n\n; OUTPUTS: lldA_smo;lldA_smo_de;lldB_smo;lldB_smo_de;lld_nzsmo;lld_nzsmo_de\n;  optional for pitch functionals: lld_f0v_smo;lld_f0p_smo\n\n"
  },
  {
    "path": "scripts/avec2013/avec2013_lld_htk.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file                             //////////////////\n/////////   for AVEC 2013                                            //////////////////\n/////////   based on avec2011.conf                                   //////////////////\n/////////  * written 2013 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) 2013 TUM, MMK                                          //////////////////\n///////// (c) 2014 audEERING UG (limited)                            //////////////////\n/////////   All rights reserved, see file COPYING for license terms  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\\{avec2013_lld_core.conf}\n\n;;;;;;;;; output all features....\n\n[componentInstances:cComponentManager]\ninstance[htksink].type=cHtkSink\n\n[htksink:cHtkSink]\nreader.dmLevel=lldA_smo;lldA_smo_de;lldB_smo;lldB_smo_de;lld_nzsmo;lld_nzsmo_de\nfilename=\\cm[output_htk(O){default_lld.htk}:output binary htk file for feature data]\nparmKind = 9\nerrorOnNoOutput = 1\nappend = 0\n\n\n"
  },
  {
    "path": "scripts/avec2013/avec2013_lld_htk_and_arff.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE configuration file                             //////////////////\n/////////   for AVEC 2013                                            //////////////////\n/////////   based on avec2011.conf                                   //////////////////\n/////////  * written 2013 by Florian Eyben *                         //////////////////\n/////////                                                            //////////////////\n///////// (c) 2013 TUM, MMK                                          //////////////////\n///////// (c) 2014 audEERING UG (limited)                            //////////////////\n/////////   All rights reserved, see file COPYING for license terms  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\\{avec2013_lld_core.conf}\n\n;;;;;;;;; output all features in HTK and ARFF format ...\n\n[componentInstances:cComponentManager]\ninstance[htksink].type=cHtkSink\n\n[htksink:cHtkSink]\nreader.dmLevel=lldA_smo;lldA_smo_de;lldB_smo;lldB_smo_de;lld_nzsmo;lld_nzsmo_de\nfilename=\\cm[output_htk(O){default_lld.htk}:output binary htk file for feature data]\nparmKind = 9\nerrorOnNoOutput = 1\nappend = 0\n\n\n[componentInstances:cComponentManager]\ninstance[arffsink].type=cArffSink\n\n[arffsink:cArffSink]\nreader.dmLevel=lldA_smo;lldA_smo_de;lldB_smo;lldB_smo_de;lld_nzsmo;lld_nzsmo_de\nfilename=\\cm[output_arff{default_lld.arff}:output arff file for feature data]\nappend=0\nframeIndex=0\nframeTime=1\nrelation=avec2013_lld_per_session\ninstanceBase=\\cm[instname{unlabelled}:name of file which will be saved in arff file]\nerrorOnNoOutput = 1\nclass[0].name = unused_target_label\nclass[0].type = numeric\ntarget[0].all = 0.0\n\n;; more class labels, nor used for now..\n;class[0].name = arousal\n;class[0].type = numeric\n;class[1].name = valence\n;class[1].type = numeric\n;class[2].type = depression\n;class[2].type = numeric\n ; the class label or value for the current instance\n;\\{labels.inc}\n \n\n\n"
  },
  {
    "path": "scripts/avec2013/extract_all_audio.pl",
    "content": "#!/usr/bin/perl\n\n#\n# AVEC 2013 audio feature batch extraction script\n# (c) 2013 by Florian Eyben\n#  (c) 2014 audEERING UG (limited)                           \n#    All rights reserved, see file COPYING for license terms.\n#\n\nuse File::Basename;\nmy @instances = glob(\"../Audio/*.mp4\");\n\nfor (my $i = 0; $i <= $#instances; $i++) {\n  my $inst = $instances[$i];\n  $inst = basename($inst);\n  $inst =~ s/_audio\\.mp4$//;\n  print \"== Extracting features for instance \\\"$inst\\\" ==\\n\";\n  my $ret = system(\"perl extractor_script.pl \\\"$inst\\\"\");\n  print \"\\n\\n\";\n  if ($ret) { exit -1; }\n}\n\n"
  },
  {
    "path": "scripts/avec2013/extractor_script.pl",
    "content": "#!/usr/bin/perl\n\n#\n#  AVEC 2013 audio feature extraction script for openSMILE\n#  (c) 2013 by Florian Eyben, TUM\n#  (c) 2014-2016 audEERING.\n#    All rights reserved, see file COPYING for license terms.\n#\n\nmy $instance = $ARGV[0];\nmy $clean = $ARGV[1];\n\nif ($#ARGV < 0) {\n  print \"Usage: $0 <instance id, e.g. 101_1_cut> [clean = 2 (recompute all files), = 1 (first instance, delete existing arff files to avoid appending to old file), = 0 delete nothing]\\n\";\n  exit -1;\n}\n\n###\n\n# path to SMILExtract binary\nmy $SE = \"./SMILExtract\";\n\n# base path with Audio and Annotation folders\nmy $bp = \"..\";\n\n# file names for files generated by the script\nmy $wav = \"$bp/Audio/$instance\\_audio.wav\";\nmkdir(\"vad\");\nmy $vadcsv = \"vad/$instance\\_audio.csv\";\nmkdir(\"lld\");\nmy $lld_htk = \"lld/$instance\\_audio.htk\";\nmy $lld_arff = \"lld/$instance\\_audio.arff\";\nmkdir(\"functionals\");\nmy $func_short = \"functionals/$instance\\_short.arff\";\nmy $func_long = \"functionals/$instance\\_long.arff\";\nmy $func_short_vad = \"functionals/$instance\\_short_vad_aligned.arff\";\nmy $func_vad_seg = \"functionals/$instance\\_vad_seg.arff\";\nmy $func_per_instance = \"functionals/$instance\\_per_instance.arff\";\n\n\n#### code ...\n\n# generate WAV\nif ($clean == 2) { \n  unlink($vadcsv);\n}\nunless (-e $wav) {\n  print \"Converting mp4 to wav for instance $instance ...\\n\";\n  my $ret = system(\"mplayer -ao pcm:file=\\\"$wav\\\" -vo null \\\"$bp/Audio/$instance\\_audio.mp4\\\" 2>/dev/null > /dev/null\");\n  print \"DONE.\\n\";\n}\n\n# perform VAD to CSV\nif ($clean == 2) { \n  unlink($vadcsv);\n}\nunless (-e $vadcsv) {\nif (-e \"tum_vad_2012.conf\") {\n  print \"Performing VAD on audio stream $instance ...\\n\";\n  my $cmd = \"$SE -l 0 -C tum_vad_2012.conf -I \\\"$wav\\\" -csv \\\"$vadcsv\\\" -nologfile >/dev/null 2>/dev/null\";\n  my $ret = system($cmd);\n  if ($ret) {\n    print \"  ERROR: Failed to run openSMILE! Instance: $instance.\\n  Command: $cmd\\n\";\n    exit -1;\n  } else {\n    print \"DONE.\\n\";\n  }\n} else {\n  print \"WARN: Not performing VAD, vad config and data files not included in this package! Please contact the author for obtaining these.\\n\";\n}\n}\n\n### read VAD from CSV\nprint \"Loading VAD targets from $vadcsv.\\n\";\nmy @vad = ();\nmy $i = 0;\nopen(F, \"<$vadcsv\");\nwhile(<F>) {\n  chomp;\n  my @x = split(/\\s*;\\s*/, $_);\n  $vad[$i][0] = $x[0];\n  $vad[$i][1] = $x[1];\n  $i++;\n}\nclose(F);\nprint \"DONE. Loaded targets for \".($#vad+1).\" frames.\\n\";\n\n# find VAD segments\nmy @vad_segs = ();\nmy $voice = 0;\nmy $threshS = -0.2;\nmy $threshV = 0.2;\nmy $sil_num = 20;\nmy $voice_num = 10;\n\nmy $voice_cnt = 0;\nmy $sil_cnt = 0;\nmy $seg_nr = 0;\nmy $seg_start = 0;\nfor (my $i = 0; $i <= $#vad; $i++) {\n  my $t = $vad[$i]->[0];\n  my $v = $vad[$i]->[1];\n  # hystereses:\n  if ($voice) {\n    if ($v < $threshS) {\n      $sil_cnt++;\n      if ($sil_cnt > $sil_num) { \n        $voice = 0;\n        $vad_segs[$seg_nr]{\"start\"} = $seg_start - 1;\n        $vad_segs[$seg_nr]{\"end\"} = $i - $sil_cnt + 3;\n        $seg_nr++;\n      }\n    } else {\n      $sil_cnt = 0;\n    }\n  } else {\n    if ($v > $threshV) {\n      $voice_cnt++;\n      if ($voice_cnt > $voice_num) { \n        $seg_start = $i - $voice_cnt;\n        $voice = 1; \n      }\n    } else {\n      $voice_cnt = 0;\n    }\n  }\n}\n\n## cut VAD segments for debugging purpose\nprint \"Trimming VAD segments for debugging purpose..\\n\";\nmkdir(\"vad/\".$instance.\"_audio_voicesegs\");\nopen(F, \">vad/$instance\\_audio_voiceseg.sh\");\nprint F \"#!/bin/sh\\n\\n\";\nprint F \"mkdir $instance\\_audio_voicesegs\\n\";\nfor (my $i = 0; $i <= $#vad_segs; $i++) {\n  my $start = $vad_segs[$i]{\"start\"} * 0.01;\n  my $end = $vad_segs[$i]{\"end\"} * 0.01;\n  my $len = $end - $start;\n  if ($clean == 2) { \n    unlink(\"vad/$instance\\_audio_voicesegs/seg_$i.wav\");\n  }\n  unless (-e \"vad/$instance\\_audio_voicesegs/seg_$i.wav\") {\n    my $cmd = \"sox \\\"$wav\\\" \\\"vad/$instance\\_audio_voicesegs/seg_$i.wav\\\" trim $start $len\";\n    #print \"  seg_$i.wav  (start: $start, len: $len)\\n\";\n    my $ret = system($cmd);\n    if ($ret) {\n      print \"  ERROR: Failed to run sox! Instance: $instance.\\n  Command: $cmd\\n\";\n      exit -1;\n    }\n  }\n  my $cmd = \"sox \\\"../$wav\\\" \\\"$instance\\_audio_voicesegs/seg_$i.wav\\\" trim $start $len\";\n  print F \"$cmd\\n\";\n}\nprint F \"\\n\";\nclose(F);\nprint \"DONE. (voice segmenter script in: vad/$instance\\_audio_voiceseg.sh)\\n\";\n\n\n# extract LLD to HTK format and ARFF\nif ($clean == 2) {\n  unlink(\"$lld_arff\");\n  unlink(\"$lld_htk\");\n}\nunless (-e \"$lld_arff\") {\n  print \"Extracting LLD features ...\\n\";\n  my $cmd = \"$SE -C avec2013_lld_htk_and_arff.conf -I \\\"$wav\\\" -output_htk \\\"$lld_htk\\\" -output_arff \\\"$lld_arff\\\" -instname \\\"$instance\\\" -nologfile 2> /dev/null >/dev/null\";\n  my $ret = system($cmd);\n  if ($ret) {\n    unlink(\"$lld_arff\");\n    unlink(\"$lld_htk\");\n    print \"  ERROR: Failed to run openSMILE! Instance: $instance.\\n  Command: $cmd\\n\";\n    exit -1;\n  } else {\n    print \"DONE.\\n\";\n  }\n}\n\n# extract functionals (3s) at rate 1s to ARFF with labels (A/V/Depri/VAD%)\nif ($clean) {\n  unlink(\"$func_short\");\n}\nunless (-e $func_short) {\nprint \"Extracting Functionals (short) ...\\n\";\nmy $cmd = \"$SE -C avec2013_functionals.conf -I \\\"$wav\\\" -O \\\"$func_short\\\" -frameModeConf avec2013_functionals_frame_mode_short.conf -instname \\\"$instance\\\" -nologfile 2> /dev/null >/dev/null\";\nmy $ret = system($cmd);\nif ($ret) {\n  print \"  ERROR: Failed to run openSMILE! Instance: $instance.\\n  Command: $cmd\\n\";\n  unlink(\"$func_short\");\n  exit -1;\n} else {\n  print \"DONE.\\n\";\n}\n}\n\n\n# extract functionals long (20s) at rate 1s to ARFF with labels (A/V/Depri)\nif ($clean) {\n  unlink(\"$func_long\");\n}\nunless (-e $func_long) {\nprint \"Extracting Functionals (long) ...\\n\";\nmy $cmd = \"$SE -C avec2013_functionals.conf -I \\\"$wav\\\" -O \\\"$func_long\\\" -frameModeConf avec2013_functionals_frame_mode_long.conf -instname \\\"$instance\\\" -nologfile 2>/dev/null >/dev/null\";\nmy $ret = system($cmd);\nif ($ret) {\n  print \"  ERROR: Failed to run openSMILE! Instance: $instance.\\n  Command: $cmd\\n\";\n  unlink(\"$func_long\");\n  exit -1;\n} else {\n  print \"DONE.\\n\";\n}\n}\n\n# extract functionals for whole segment to ARFF with labels (A/V/Depri)\nif ($clean) {\n  unlink(\"$func_per_instance\");\n}\nunless (-e $func_per_instance) {\nprint \"Extracting Functionals (per instance) ...\\n\";\nmy $cmd = \"$SE -C avec2013_functionals.conf -I \\\"$wav\\\" -O \\\"$func_per_instance\\\" -frameModeConf avec2013_functionals_frame_mode.conf -instname \\\"$instance\\\" -nologfile 2>/dev/null >/dev/null\";\nmy $ret = system($cmd);\nif ($ret) {\n  print \"  ERROR: Failed to run openSMILE! Instance: $instance.\\n  Command: $cmd\\n\";\n  unlink(\"$func_per_instance\");\n  exit -1;\n} else {\n  print \"DONE.\\n\";\n}\n}\n\n## VAD segment functionals:\nif ($clean) {\n  unlink(\"$func_vad_seg\");\n}\n# extract functionals of VAD segments to ARFF with labels (A/V/Depri)\nunless (-e $func_vad_seg) {\nprint \"Extracting functionals for VAD segments (full) ...\\n\";\nfor (my $i = 0; $i <= $#vad_segs; $i++) {\n  my $start = $vad_segs[$i]{\"start\"} * 0.01;\n  my $end = $vad_segs[$i]{\"end\"} * 0.01;\n  my $cmd = \"$SE -C avec2013_functionals.conf -frameTimeAdd \\\"$start\\\" -start \\\"$start\\\" -end \\\"$end\\\" -I \\\"$wav\\\" -O \\\"$func_vad_seg\\\" -frameModeConf avec2013_functionals_frame_mode.conf -instname \\\"$instance\\_seg$i\\\" -nologfile 2>/dev/null >/dev/null\";\n  my $ret = system($cmd);\n  if ($ret) {\n    print \"  ERROR: Failed to run openSMILE! Instance: $instance.\\n  Command: $cmd\\n\";\n    unlink(\"$func_vad_seg\");\n    exit -1;\n  }\n}\nprint \"DONE.\\n\";\n}\n\nif ($clean) {\n  unlink(\"$func_short_vad\");\n}\n# extract functionals of VAD segments to ARFF with labels (A/V/Depri)\nif (0) {\nunless (-e $func_short_vad) {\nprint \"Extracting functionals for VAD segments (short) ...\\n\";\nfor (my $i = 0; $i <= $#vad_segs; $i++) {\n  my $start = $vad_segs[$i]{\"start\"} * 0.01;\n  my $end = $vad_segs[$i]{\"end\"} * 0.01;\n  my $cmd = \"$SE -C avec2013_functionals.conf -frameTimeAdd \\\"$start\\\" -start \\\"$start\\\" -end \\\"$end\\\" -I \\\"$wav\\\" -O \\\"$func_short_vad\\\" -frameModeConf avec2013_functionals_frame_mode_short_with_last.conf -instname \\\"$instance\\_seg$i\\\" -nologfile 2>/dev/null >/dev/null\";\n  my $ret = system($cmd);\n  if ($ret) {\n    print \"  ERROR: Failed to run openSMILE! Instance: $instance.\\n  Command: $cmd\\n\";\n    unlink(\"$func_short_vad\");\n    exit -1;\n  }\n}\nprint \"DONE.\\n\";\n}\n}\n\nexit 0;\n\n"
  },
  {
    "path": "scripts/avec2013/feature_set_news.txt",
    "content": "\ndelta's for voicing only in voiced segments!\n\n+ spectral slope and flatness\n+ mfcc 11-16\n\nfunctionals:\n+ voiced segment onset rate\n\n"
  },
  {
    "path": "scripts/clonecomp.pl",
    "content": "#!/usr/bin/perl\n\n# This file is part of openSMILE.\n#\n# Copyright (c) audEERING. All rights reserved.\n# See the file COPYING for details on license terms.\n\n# script to clone an openSMILE component\n#   .cpp and .hpp files are copied and the classname is updated\n\nif ($#ARGV <3 ) { \n  print \"USAGE: clonecomp.pl <inputCompBase> <outputCompBase> <inputCompName> <outputCompName>\\n\";\n  exit;\n}\n\n$src=\"../src\";\n\n$in=$ARGV[2];\n$on=$ARGV[3];\n$inT=$in;\n$inT=~tr/a-z/A-Z/;\n$onT=$on;\n$onT=~tr/a-z/A-Z/;\n$if=$ARGV[0];\n$of=$ARGV[1];\n\nprint \"$in (in)\\n\";\nprint \"$on (out)\\n\";\n\n@ex=(\"cpp\",\"hpp\");\nforeach $ext (@ex) {\n\nmy $pref = \"\";\nif ($ext =~ /h/) {\n  $pref = \"include/\";\n}\n\nopen(IN,\"<$src/$pref\".$ARGV[0].\".$ext\");\nopen(OUT,\">$src/$pref\".$ARGV[1].\".$ext\");\nwhile(<IN>) {\n  my $line=$_;\n  $line =~ s/$in/$on/g;\n  $line =~ s/_$inT/_$onT/;\n  if ($ext eq \"cpp\") {\n    $line =~ s/<$if.hpp>/<$of.hpp>/;\n  } else {\n    $onTh = $onT.\"_HPP\";\n    $line =~ s/^#ifndef __.+?_HPP/#ifndef __$onTh/;\n    $line =~ s/^#define __.+?_HPP/#define __$onTh/;\n    $line =~ s/^#endif *\\/\\/ *__.+?_HPP/#endif \\/\\/ __$onTh/;\n  }\n  print OUT $line;\n}\nclose(OUT);\nclose(IN);\n\n}\n"
  },
  {
    "path": "scripts/extract_features_batch.pl",
    "content": "#############################################################\n# Generic batch feature extraction script.\n# Requires perl to run.\n# Calls openSMILE on multiple files in a directory.\n# \n# This file is part of openSMILE.\n# (c) 2016 by audEERING.\n# All rights reserved. See file COPYING for details.\n#############################################################\n\n\nuse strict;\nuse FileHandle;\nuse File::Basename;\n\n### change these variables to match your setting\nmy $openSMILE_root = \"..\";\nmy $SMILExtract = \"$openSMILE_root/SMILExtract\";\nmy $config = \"$openSMILE_root/config/IS13_ComParE.conf\";\nmy $corpus = \"corpus_name\";\n## glob expression to list all wave files\nmy $wavs = \"/path/to/*.wav\";\n\n## NOTE: comment out these two lines once the above settings have been changed...\nprint(\"\\nThis script has no parameters.\\nPlease edit the variables in the code to fit your configuration.\\n\\n\");\nexit 1;\n###\n\n# see load_labels documentation for details (loading labels from a list file)\n# my $labels = \"path to text based label file....\";  \n\n####\nmy $arff_all = \"$corpus-all.arff\";\n## for data-set partitioning based on filename (see below)\n#my $arff_train = \"$corpus-train.arff\";\n#my $arff_devel = \"$corpus-devel.arff\";\n#my $arff_test = \"$corpus-test.arff\";\n\n###\n\n\n## example function to load labels from\n## a ';' separated table file\n##   first line is a header with field names\n##   first column is the filename (wav)\n##   second column is the label\nsub load_labels {\n  my $labels = shift;\n  my $F = FileHandle->new();\n  open($F, \"<$labels\");\n  my $head = <$F>;\n  $head =~ s/\\r?\\n$//;\n  my @headEl = split(/;/, $head);\n  my %labs = ();\n  while(<$F>) {\n    my $line = $_;\n    $line =~ s/\\r?\\n$//;\n    my @x = split(/;/, $line);\n    $labs{$x[0]}{\"label\"} = $x[1];\n    # .. can add more labels here ...\n  }\n  $F->close();\n  return \\%labs;\n}\n\n\n## deletes existing arff files, so that openSMILE does not append to them.\nunlink($arff_all);\n#unlink($arff_train);\n#unlink($arff_devel);\n#unlink($arff_test);\n\n## enable this to load labels...\n#my $lab = load_labels($labels);\n#my @labs = keys %{$lab};\n\n## use this to iterate through labels....\n#foreach my $l (@labs) {\n#  my $wav = $wavs.\"/\".$l;\n\n## alternatively we iterate through the list of wave files\nmy @Wavs = glob($wavs);\nforeach my $wav (@Wavs) {\n  my $l = basename($wav);\n####\n  my $arff = $arff_all;\n  ### example for splitting in 3 partitions based on filename expression\n  #if ($l =~ /^training_/) {\n  #  $arff = $arff_train;\n  #}\n  #if ($l =~ /^validation_/) {\n  #  $arff = $arff_devel;  \n  #}\n  #if ($l =~ /^test_/) {\n  #  $arff = $arff_test;\n  #}\n  if ($arff) {\n    my $targets = \"\";\n    ## this is an example for adding labels loaded from a text file directly into the arff file:\n    ## the options -class and -classtype must be defined in the given arff_targets.conf.inc file,\n    ## this file allows to define multiple such options for a multi-target arff file.\n    # my $targets = \"-arfftargetsfile ./arff_targets.conf.inc\";\n    # $targets .= \" -class \".$lab->{$l}{\"label\"};\n    # $targets .= \" -classtype {emotional,neutral}\";\n    #################\n    my $inst = $l;\n    ## if you get errors that the wave file format cannot be read by openSMILE,\n    ## you first need to convert your audio files with the open-source tool 'sox'.\n    ##   e.g. sox -R $wav -c 1 -e signed-integer -b 16 tmp-output.wav\n    ## then set $wav = \"tmp-output.wav\"\n    ## and don't forget to delete tmp-output.wav at the end...\n    my $cmd = \"$SMILExtract -nologfile -l 2 -C \\\"$config\\\" -I \\\"$wav\\\" -O \\\"$arff\\\" -instname \\\"$inst\\\" $targets\";\n    print \"running: $cmd\\n\";\n    my $ret = system($cmd);\n    if ($ret) {\n      print \"ERROR: $cmd\\n\";\n      exit -1;\n    }\n  }\n}\n\n"
  },
  {
    "path": "scripts/gnuplot/gpconvert.pl",
    "content": "#!/usr/bin/perl\n\n# Usage: gpconvert.pl <input file> [output file , default: same as input]\n#\n# this script converts a CSV file (; delimiter)\n# and saves it as a space separated file for gnuplot\n#\n\n$col = $ARGV[0];\n\nunless ($ARGV[1]) {\n  print \"Usage: gpconvert.pl <column> <input file> [output file, default: overwrite input file]\\n\";\n  exit -1;\n}\n\n$j=0;\nopen(F,\"<$ARGV[1]\");\nwhile(<F>) {\n  $_=~s/\\r?\\n//;\n  if ($_ !~ /;/) { print \"no column delimiter ; found !\"; exit -1; }\n  if ($_ !~ /[a-df-zA-DF-Z]/) { # skip a header line with alphanumeric characters\n  split(/;/);  # <<- the delimiter ;\n  for ($i=0;$i<=$#_;$i++) { $d[$i][$j] = $_[$i]; }\n  $j++;\n  }\n}\nclose(F);\nif ($ARGV[2]) {\n  open(F,\">$ARGV[2]\");\n} else {\n  open(F,\">$ARGV[1]\");\n}\nfor ($n=0; $n<$j; $n++) {\n  $s=\"$n \";\n#  for ($i=0; $i<$#d; $i++) {\n    $s.=$d[$col][$n].\" \";  \n#  }\n  chop($s);\n  print F $s.\"\\n\";\n}\nclose(F);\n\n"
  },
  {
    "path": "scripts/gnuplot/gpframeconvert.pl",
    "content": "#!/usr/bin/perl\n\n# Usage: gpconvert.pl <input file> [output file , default: same as input]\n#\n# this script converts a CSV file (; delimiter)\n# and saves it as a space separated file for gnuplot\n#\n\n$col = $ARGV[0];\n\nunless ($ARGV[1]) {\n  print \"Usage: gpframeconvert.pl <index> <input file> [output file, default: overwrite input file]\\n\";\n  exit -1;\n}\n\n$j=0;\nopen(F,\"<$ARGV[1]\");\nwhile(<F>) {\n  $_=~s/\\r?\\n//;\n  if ($_ !~ /;/) { print \"no column delimiter ; found !\"; exit -1; }\n  if ($_ !~ /[a-df-zA-DF-Z]/) { # skip a header line with alphanumeric characters\n  split(/;/);  # <<- the delimiter ;\n  for ($i=0;$i<=$#_;$i++) { $d[$i][$j] = $_[$i]; }\n  $j++;\n  }\n}\nclose(F);\nif ($ARGV[2]) {\n  open(F,\">$ARGV[2]\");\n} else {\n  open(F,\">$ARGV[1]\");\n}\nfor ($n=0; $n<$#d; $n++) {\n  $s=\"$n \";\n#  for ($i=0; $i<$#d; $i++) {\n    $s.=$d[$n][$col].\" \";  \n#  }\n  chop($s);\n  print F $s.\"\\n\";\n}\nclose(F);\n\n"
  },
  {
    "path": "scripts/gnuplot/plotaudspec.sh",
    "content": "#!/bin/sh\n\nif [ \"$1\" = \"\" ]; then\n  echo \"Usage: plotaudspec.sh <input csv file>\";\n  exit;\nfi\n\nperl transpose_lin.pl $1 .tmp.plot.dat\necho \"Starting gnuplot, type 'quit' to exit the gnuplot prompt!\"\ngnuplot -persist plotmatrix_spec.gp\nrm .tmp.plot.dat\n\n"
  },
  {
    "path": "scripts/gnuplot/plotchroma.sh",
    "content": "#!/bin/sh\n\nif [ \"$1\" = \"\" ]; then\n  echo \"Usage: plotchroma.sh <input csv file>\";\n  exit;\nfi\n\nperl transpose.pl $1 .tmp.plot.dat\necho \"Starting gnuplot, type 'quit' to exit the gnuplot prompt!\"\ngnuplot -persist plotmatrix_chroma.gp\nrm .tmp.plot.dat\n\n"
  },
  {
    "path": "scripts/gnuplot/plotcontour.gp",
    "content": "\nset title 'Feature contour plot'\nset ylabel 'Amplitude/Value'\nset xlabel 'Time/frames'\nplot '.tmp.plot.dat' using 1:2 with lines\n\n\n"
  },
  {
    "path": "scripts/gnuplot/plotcontour.sh",
    "content": "#!/bin/sh\n\nif [ \"$1\" = \"\" ]; then\n  echo \"Usage: plotcontour.sh <column to extract> <input csv file>\";\n  exit;\nfi\n\nperl gpconvert.pl $1 $2 .tmp.plot.dat\necho \"Starting gnuplot, type 'quit' to exit the gnuplot prompt!\"\ngnuplot -persist plotcontour.gp\n## to run gnuplot an remain in interactive mode:\n## gnuplot plotcontour.gp -\nrm .tmp.plot.dat\n\n"
  },
  {
    "path": "scripts/gnuplot/plotframe.gp",
    "content": "\nset title 'Plot of a single frame'\nset ylabel 'Amplitude/Value'\nset xlabel 'Feature index'\nplot '.tmp.plot.dat' using 1:2 with lines\n\n\n"
  },
  {
    "path": "scripts/gnuplot/plotframe.sh",
    "content": "#!/bin/sh\n\nif [ \"$1\" = \"\" ]; then\n  echo \"Usage: plotframe.sh <input csv file> [index of frame to extract, default: the first (0)]\";\n  exit;\nfi\n\nif [ \"$2\" = \"\" ]; then\n  perl gpframeconvert.pl 0 $1 .tmp.plot.dat\nelse\n  perl gpframeconvert.pl $2 $1 .tmp.plot.dat\nfi\n\necho \"Starting gnuplot, type 'quit' to exit the gnuplot prompt!\"\ngnuplot -persist plotframe.gp\n## to run gnuplot an remain in interactive mode:\n## gnuplot plotframe.gp -\nrm .tmp.plot.dat\n\n"
  },
  {
    "path": "scripts/gnuplot/plotmatrix.gp",
    "content": "\nset pm3d map\nset palette gray\nset view map\n\nset xlabel 'Time/frames'\nset ylabel 'Feature Index'\nset zlabel 'Power'\n\n## change the name '.tmp.plot.dat' to your filename...\nsplot '.tmp.plot.dat' matrix title 'Matrix plot'\n\n\n"
  },
  {
    "path": "scripts/gnuplot/plotmatrix.sh",
    "content": "#!/bin/sh\n\nif [ \"$1\" = \"\" ]; then\n  echo \"Usage: plotmatrix.sh <input csv file>\";\n  exit;\nfi\n\nperl transpose.pl $1 .tmp.plot.dat\necho \"Starting gnuplot, type 'quit' to exit the gnuplot prompt!\"\ngnuplot -persist plotmatrix.gp\n## to run gnuplot an remain in interactive mode:\n## gnuplot plotmatrix.gp -\nrm .tmp.plot.dat\n\n"
  },
  {
    "path": "scripts/gnuplot/plotmatrix_chroma.gp",
    "content": "\nset pm3d map\nset palette gray\nset view map\n\nset xlabel 'Time/frames'\nset ylabel 'Semitone bin (0-11)'\nset zlabel 'Intensity'\n\n## change the name to your filename...\nsplot '.tmp.plot.dat' matrix title 'Chromagram'\n\n\n"
  },
  {
    "path": "scripts/gnuplot/plotmatrix_spec.gp",
    "content": "\nset pm3d map\nset palette gray\nset view map\n\nset xlabel 'Time/frames'\nset ylabel 'Spectral bin/band'\nset zlabel 'Magnitude/Intensity'\n\n## change the name to your filename...\nsplot '.tmp.plot.dat' matrix title 'Spectrogram'\n\n\n"
  },
  {
    "path": "scripts/gnuplot/transpose.pl",
    "content": "#!/usr/bin/perl\n\n# Usage: transpose.pl <input file> [output file , default: same as input]\n#\n# this script transposes a CSV file (; delimiter)\n# and saves it as a space separated file for gnuplot\n# the values in the CSV file are squared, which usually\n# leads to a better display behaviour for spectrograms, etc.\n# Please see the comments in the code below, how to change this.\n#\n\nunless ($ARGV[0]) {\n  print \"Usage: transpose.pl <input file> [output file, default: overwrite input file]\\n\";\n  exit -1;\n}\n\n$j=0;\nopen(F,\"<$ARGV[0]\");\nwhile(<F>) {\n  $_=~s/\\r?\\n//;\n  if ($_ !~ /;/) { print \"no column delimiter ; found !\"; exit -1; }\n  if ($_ !~ /[a-df-zA-DF-Z]/) { # skip a header line with alphanumeric characters\n  @_=split(/;/);  # <<- the delimiter ;\n  for ($i=0;$i<=$#_;$i++) { $d[$i][$j] = $_[$i]; }\n  $j++;\n  }\n}\nclose(F);\nif ($ARGV[1]) {\n  open(F,\">$ARGV[1]\");\n} else {\n  open(F,\">$ARGV[0]\");\n}\nfor ($n=$#d; $n>=0; $n--) {\n  $s=\"\";\n  for ($i=0; $i<$j; $i++) {\n    $s.=$d[$n][$i]*$d[$n][$i].\" \"; ## comment out this line with a \"##\" when using the line below\n##    $s.=$d[$n][$i].\" \";  ## uncomment this line, to use the magnitude instead of power\n  }\n  chop($s);\n  print F $s.\"\\n\";\n}\nclose(F);\n\n"
  },
  {
    "path": "scripts/gnuplot/transpose_lin.pl",
    "content": "#!/usr/bin/perl\n\n# Usage: transpose.pl <input file> [output file , default: same as input]\n#\n# this script transposes a CSV file (; delimiter)\n# and saves it as a space separated file for gnuplot\n# the values in the CSV file are squared, which usually\n# leads to a better display behaviour for spectrograms, etc.\n# Please see the comments in the code below, how to change this.\n#\n\nunless ($ARGV[0]) {\n  print \"Usage: transpose.pl <input file> [output file, default: overwrite input file]\\n\";\n  exit -1;\n}\n\n$j=0;\nopen(F,\"<$ARGV[0]\");\nwhile(<F>) {\n  $_=~s/\\r?\\n//;\n  if ($_ !~ /;/) { print \"no column delimiter ; found !\"; exit -1; }\n  if ($_ !~ /[a-df-zA-DF-Z]/) { # skip a header line with alphanumeric characters\n  @_=split(/;/);  # <<- the delimiter ;\n  for ($i=0;$i<=$#_;$i++) { $d[$i][$j] = $_[$i]; }\n  $j++;\n  }\n}\nclose(F);\nif ($ARGV[1]) {\n  open(F,\">$ARGV[1]\");\n} else {\n  open(F,\">$ARGV[0]\");\n}\nfor ($n=$#d; $n>=0; $n--) {\n  $s=\"\";\n  for ($i=0; $i<$j; $i++) {\n    $s.=$d[$n][$i].\" \";  \n  }\n  chop($s);\n  print F $s.\"\\n\";\n}\nclose(F);\n\n"
  },
  {
    "path": "scripts/modeltrain/README.txt",
    "content": "\nUse the perl script \"makemodel.pl\" to build an emotion/affect recognition LibSVM model (both SVM and SVR supported, see buildmodel.pl if you want to change parameters).\n\nThe script takes either an Arff-file as single argument OR a corpus directory according to Florian's emotion class directory standard. In the latter case the script takes a second parameter, which is the openSMILE configuration file to use.\n\n"
  },
  {
    "path": "scripts/modeltrain/arff-functions.pl",
    "content": "### Functions to handle .arff files (WEKA)\r\n\r\n\r\n# returns reference to arff hash\r\nsub load_arff {\r\n  my $file = $_[0];\r\n  \r\n  my %hash = ();\r\n  my $data = 0;\r\n  my $featnr = 0;\r\n  my $instnr = 0;\r\n  \r\n  open(FILE,\"<$file\");\r\n  while (<FILE>) {\r\n    my $line = $_;\r\n    $line =~ s/\\n$//;\r\n    $line =~ s/\\r$//;\r\n    if ($line !~ /^\\s*$/) {\r\n      if ($data) { \r\n        #my @els = split(/,/,$line);  # TODO: quoting \"\" '' \r\n        $line =~ s/,,/, ,/g;\r\n        my @els = ($line =~ /(\\'.*?\\'|\".*?\"|[^,]+)/g);\r\n        my $i;\r\n        for ($i=0; $i <= $#els; $i++) {\r\n          $hash{\"instances\"}[$instnr][$i] = \"$els[$i]\";\r\n        }\r\n        #$hash{\"instances\"}[$instnr][$i] = \\@els;\r\n        $instnr++;\r\n      } else {\r\n        if ($line =~ /^\\@data/i)  {\r\n          $data = 1; $instnr = 0;\r\n        } else {\r\n          if ($line =~ /^\\@relation\\s+(.+)$/i) {\r\n            $hash{\"relation\"} = $1;\r\n          }\r\n          if ($line =~ /^\\@attribute\\s+(.+?)\\s+(.+?)$/i) {\r\n            $hash{\"attributes\"}[$featnr]{\"name\"} = $1;\r\n            $hash{\"attributes\"}[$featnr]{\"type\"} = $2;\r\n            $hash{\"attribute_names\"}{$1} = $featnr+1;  # reverse lookup hash  ## +1 !!\r\n            $hash{\"attributes\"}[$featnr]{\"selected\"} = 1;\r\n            #print $hash{\"attributes\"}[$featnr]{\"name\"}.\"\\n\";\r\n            $featnr++;\r\n          }\r\n        \r\n        }\r\n        \r\n      }\r\n    }\r\n  }\r\n  close(FILE);\r\n  \r\n  return \\%hash;\r\n}\r\n\r\n\r\n# USAGE: &save_arff( $file, \\%hash )\r\nsub save_arff {\r\n  my $file = $_[0];\r\n  my $hashref = $_[1];\r\n  \r\n  my $tmp;\r\n  my $name; my $type;\r\n  my $i = 0;\r\n  \r\n  open(FILE,\">$file\");\r\n  $tmp = $hashref->{\"relation\"};\r\n  print FILE \"\\@relation $tmp\\n\\n\";\r\n  \r\n  for ($i=0; $i <= $#{$hashref->{\"attributes\"}}; $i++) {\r\n    #if ($hashref->{\"attributes\"}[$i]{\"selected\"}) {\r\n      $name = $hashref->{\"attributes\"}[$i]{\"name\"};\r\n      $type = $hashref->{\"attributes\"}[$i]{\"type\"};\r\n      print FILE \"\\@attribute $name $type\\n\";\r\n    #}\r\n  }\r\n  \r\n  print FILE \"\\n\\@data\\n\\n\";\r\n  \r\n  for ($i=0; $i <= $#{$hashref->{\"instances\"}}; $i++) {\r\n    my $line = \"\";\r\n    for ($j= 0; $j <= $#{$hashref->{\"instances\"}[$i]}; $j++) {\r\n      $line .= $hashref->{\"instances\"}[$i][$j].\",\";\r\n    }\r\n    chop($line);\r\n    print FILE $line.\"\\n\";\r\n  }\r\n  \r\n  close(FILE);\r\n  \r\n}\r\n\r\n\r\n# Perform attribute selection while saving. Saves memory and is faster\r\nsub save_arff_AttrSelected {\r\n  my $file = $_[0];\r\n  my $hashref = $_[1];\r\n  \r\n  my $tmp;\r\n  my $name; my $type;\r\n  my $i = 0; my $j;\r\n  \r\n  open(FILE,\">$file\");\r\n  $tmp = $hashref->{\"relation\"};\r\n  print FILE \"\\@relation $tmp\\n\\n\";\r\n  \r\n  for ($i=0; $i <= $#{$hashref->{\"attributes\"}}; $i++) {\r\n    if ($hashref->{\"attributes\"}[$i]{\"selected\"}) {\r\n      $name = $hashref->{\"attributes\"}[$i]{\"name\"};\r\n      $type = $hashref->{\"attributes\"}[$i]{\"type\"};\r\n      print FILE \"\\@attribute $name $type\\n\";\r\n    }\r\n  }\r\n  \r\n  print FILE \"\\n\\@data\\n\\n\";\r\n  \r\n  for ($i=0; $i <= $#{$hashref->{\"instances\"}}; $i++) {\r\n    my $line = \"\";\r\n    for ($j= 0; $j <= $#{$hashref->{\"instances\"}[$i]}; $j++) {\r\n      #print $j.\"\\n\";\r\n      if ($hashref->{\"attributes\"}[$j]{\"selected\"}) {\r\n        $line .= $hashref->{\"instances\"}[$i][$j].\",\";\r\n      }\r\n    }\r\n    chop($line); # remove last comma\r\n    print FILE $line.\"\\n\";\r\n  }\r\n  \r\n  close(FILE);\r\n}\r\n\r\n## convert arff to csv, first line contains header with feature names and types in []\r\nsub arff_to_csv {\r\n  my $arff = $_[0];\r\n  my $csv = $_[1];\r\n  my $csvDelim = \",\";\r\n\r\n  my $hr = &load_arff($arff);\r\n  \r\n  open(FILE,\">$csv\");\r\n  #header line\r\n  my $line = \"\"; my $i;\r\n  for ($i = 0; $i <= $#{$hr->{\"attributes\"}}; $i++) {\r\n    $line .= $hr->{\"attributes\"}[$i]{\"name\"}.\"[\".$hr->{\"attributes\"}[$i]{\"type\"}.\"]$csvDelim\";\r\n  }\r\n  chop($line);\r\n  print FILE $line.\"\\n\";\r\n  # print data\r\n  for ($i = 0; $i <= $#{$hr->{\"instances\"}}; $i++) {\r\n    $line = \"\";\r\n    my $j;\r\n    for ($j = 0; $j <= $#{$hr->{\"instances\"}[$i]}; $j++) {\r\n           if ($hr->{\"instances\"}[$i][$j] eq \"nan\") { print $hr->{\"attributes\"}[$j]{\"name\"}.\"\\n\"; }\r\n      $line .= $hr->{\"instances\"}[$i][$j].$csvDelim;\r\n    }\r\n    chop($line);\r\n    print FILE $line.\"\\n\";\r\n  }\r\n  close(FILE);\r\n}\r\n\r\n## convert csv to arff, \r\n# first line in csv file contains header with feature names (and types in [] -> optional!)\r\nsub csv_to_arff { # return value: arff hash reference\r\n  my $csv = $_[0];  # filename\r\n  my $arff = $_[1]; # arff filename\r\n  \r\n  my $csvdelim = \",\";\r\n  if ($_[2]) { $csvdelim = $_[2]; }\r\n  \r\n  #my $hr = &load_arff($arff);\r\n  my %hr=();\r\n  $hr{\"relation\"}=\"from_csv\";\r\n\r\n  open(FILE,\"<$csv\");\r\n  #header line\r\n  my $line = \"\"; my $i;\r\n  $line=<FILE>; \r\n  chop($line);\r\n  my @els=split(/$csvdelim/,$line);\r\n  my $i=0;\r\n  for ($i=0; $i <= $#els; $i++) {\r\n    if ($els[$i] =~ /^(.+?)\\[(.+?)\\]$/) {\r\n      $hr{\"attributes\"}[$i]{\"name\"} = $1;\r\n      $hr{\"attributes\"}[$i]{\"type\"} = $2;\r\n    } else {\r\n      $hr{\"attributes\"}[$i]{\"name\"} = $els[$i];\r\n      $hr{\"attributes\"}[$i]{\"type\"} = \"numeric\";\r\n    }\r\n  }\r\n  print \"attributes: $i \\n\";\r\n\r\n  my $i=0;\r\n  while (<FILE>)  {\r\n    $line = $_; chop($line);\r\n    my @els=split(/$csvdelim/,$line);\r\n    my $j;\r\n    for ($j=0; $j<=$#els; $j++) {\r\n      $hr{\"instances\"}[$i][$j] = $els[$j];\r\n    }\r\n    print \"attr[$i]: $j\\n\";\r\n    $i++;\r\n  }\r\n  \r\n  close(FILE);\r\n  \r\n  &save_arff($arff,\\%hr);\r\n  return \\%hr;\r\n}\r\n\r\n\r\n## convert arff to csvs, first line contains header with feature names and types in []\r\n## special function that creates multiple csvs by parsing first attribute (filename)\r\nsub arff_to_csvs {\r\n  my $arff = $_[0];\r\n  my $csv = $_[1];\r\n\r\n  my $hr = &load_arff($arff);\r\n  \r\n  #load session names:\r\n  open(FILE,\"all.txt\");\r\n  my @sessnames = ();\r\n  while(<FILE>) {\r\n    chop; push(@sessnames,$_);\r\n  }\r\n  close(FILE);\r\n  \r\n  my $sess;\r\n  foreach $sess (@sessnames) {\r\n  \r\n  my $ccsv = $csv.\".$sess.csv\";\r\n  $ccsv =~ s/csv\\.$sess\\.csv$/$sess.csv/;\r\n  open(FILE,\">$ccsv\");\r\n  #header line\r\n  my $line = \"\"; my $i;\r\n  for ($i = 0; $i <= $#{$hr->{\"attributes\"}}; $i++) {\r\n    $line .= $hr->{\"attributes\"}[$i]{\"name\"}.\"[\".$hr->{\"attributes\"}[$i]{\"type\"}.\"],\";\r\n  }\r\n  chop($line);\r\n  print FILE $line.\"\\n\";\r\n  # print data\r\n  for ($i = 0; $i <= $#{$hr->{\"instances\"}}; $i++) {\r\n    if ($hr->{\"instances\"}[$i][0] =~ /$sess/) {\r\n    \r\n    $line = \"\";\r\n    my $j;\r\n    for ($j = 0; $j <= $#{$hr->{\"instances\"}[$i]}; $j++) {\r\n      $line .= $hr->{\"instances\"}[$i][$j].\",\";\r\n    }\r\n    chop($line);\r\n    print FILE $line.\"\\n\";\r\n    \r\n    }\r\n  }\r\n  close(FILE);\r\n  \r\n  }\r\n}\r\n\r\n## load both files, check if attributes are the same, and save, SLOW!!\r\n## (this funtions concats INSTANCES)\r\nsub concat_arffs_save {\r\n  my $file1 = $_[0];\r\n  my $file2 = $_[1];\r\n  my $outfile = $_[2];\r\n\r\n  my $hr1 = &load_arff($file1);\r\n  my $hr2 = &load_arff($file2);\r\n  \r\n  my $error = 0;\r\n  \r\n  my $i;\r\n  #check attributes:\r\n  for($i=0; $i <= $#{$hr1->{\"attributes\"}}; $i++) {\r\n    if ($hr1->{\"attributes\"}[$i]{\"name\"} ne $hr2->{\"attributes\"}[$i]{\"name\"}) {\r\n      print \"Attribute name mismatch: (1) \".$hr1->{\"attributes\"}[$i]{\"name\"}.\" <-> (2) \".$hr2->{\"attributes\"}[$i]{\"name\"}.\"\\n\";\r\n      $error = 1;\r\n      last;\r\n    }\r\n    if ($hr1->{\"attributes\"}[$i]{\"type\"} ne $hr2->{\"attributes\"}[$i]{\"type\"}) {\r\n      print \"Attribute type mismatch: \".$hr2->{\"attributes\"}[$i]{\"type\"}.\" :: (1) \".$hr1->{\"attributes\"}[$i]{\"type\"}.\" <-> (2) \".$hr2->{\"attributes\"}[$i]{\"type\"}.\"\\n\";\r\n      $error = 2;\r\n      last;\r\n    }  \r\n  }\r\n  \r\n  unless ($error) {\r\n    # concat\r\n    push(@{$hr1->{\"instances\"}},@{$hr2->{\"instances\"}}); \r\n    # save\r\n    &save_arff($outfile,$hr1);\r\n  }\r\n  \r\n  return $error;\r\n}\r\n\r\n\r\n## copy and append only, fast!\r\nsub concat_arffs_simple {\r\n  my $file1 = $_[0];\r\n  my $file2 = $_[1];\r\n  my $outfile = $_[2];\r\n\r\n  open(FILE,\"<$file1\");\r\n  open(OF,\">$outfile\");\r\n  while(<FILE>) {\r\n    print OF $_;\r\n  }  \r\n  close(FILE);\r\n  \r\n  open(FILE,\"<$file2\");\r\n  while(<FILE>) {\r\n    my $line = $_;\r\n    if ($line =~ /^\\@data/i) { last; }\r\n  }\r\n  while(<FILE>) {\r\n    print OF $_;\r\n  }\r\n  close(FILE);\r\n  close(OF);\r\n}\r\n\r\n\r\n# concat attributes! (only works when the number of instances is the same for both files!)\r\n# USAGE: join_arff(input1, input2, $output, [# features to skip at end of first file])\r\n# optional: return value is hash ref. to joined arff hash\r\nsub join_arff() {\r\n  my $in1 = $_[0];\r\n  my $in2 = $_[1];\r\n  my $out = $_[2];\r\n  my $skip = 1; # attributes of in1 to skip/overwrite (from end)\r\n  if ($_[3]) { $skip = $_[3]; }\r\n\r\n  my $hr1=&load_arff($in2);\r\n  my $hr2=&load_arff($in1);\r\n\r\n  my @attr1 = @{$hr1->{\"attributes\"}};\r\n  my @inst1 = @{$hr1->{\"instances\"}};\r\n  my @attr2 = @{$hr2->{\"attributes\"}};\r\n  my @inst2 = @{$hr2->{\"instances\"}};\r\n  my $na2 = $#attr2;\r\n\r\n  if ($#inst2 != $#inst1) {\r\n    print \"Number of instances does not match! cannot merge!\\n\";\r\n    return -1;\r\n  }\r\n  \r\n  my $i;\r\n  # append hr1 attributes to hr2\r\n  for ($i=0; $i<=$#attr1; $i++) {\r\n    $hr2->{\"attributes\"}[$na2+$i+1-$skip] = $attr1[$i];\r\n  }\r\n\r\n  #append hr1 instances to hr2 instances\r\n  for ($i=0; $i<=$#inst2; $i++) {\r\n    for ($j=0; $j<=$#attr1; $j++) {\r\n      $hr2->{\"instances\"}[$i][$na2+$j+1-$skip] = $inst1[$i][$j];\r\n    }\r\n  }\r\n\r\n\r\n  # save result (hr2):\r\n  &save_arff($out , $hr2);\r\n  \r\n  return \\%hr2;\r\n}\r\n\r\n# synchronize two arff files, so that they have the same attributes\r\n# this one only works if, the attributes are in the same order in both files\r\nsub sync_arffs {\r\n  my $file1 = $_[0];  # arff file to be modified\r\n  my $file2 = $_[1]; # arff file to sync to...\r\n  my $outfile = $_[2];  # file to save result to\r\n  my $addnames = $_[3];  # reference to hash w. attribute names that will be added as keys \r\n                         # (attr. must exist in file1, and not in file2)\r\n  \r\n  my %addnames_local = ();\r\n  if ($addnames) {  #  check if it is a reference ???!!!\r\n    %addnames_local = %{$addnames};\r\n  }\r\n  \r\n  print \"Loading $file1...\\n\";\r\n  my $hr1 = &load_arff($file1);\r\n  print \"Loading $file2...\\n\";\r\n  my $hr2 = &load_arff($file2);\r\n\r\n  print \"Syncing attributes...\\n\";\r\n  my $i;  \r\n  # in hr1 select only those that are present in hr2:\r\n  for($i=0; $i <= $#{$hr1->{\"attributes\"}}; $i++) {\r\n    #print \"$i\\n\";\r\n    if ( ($hr2->{\"attribute_names\"}{$hr1->{\"attributes\"}[$i]{\"name\"}}) || \r\n          ($addnames_local{$hr1->{\"attributes\"}[$i]{\"name\"}}) ) {\r\n      $hr1->{\"attributes\"}[$i]{\"selected\"} = 1;\r\n    } else {\r\n      $hr1->{\"attributes\"}[$i]{\"selected\"} = 0;\r\n    }\r\n  }\r\n  \r\n  print \"Saving $outfile...\\n\";\r\n  &save_arff_AttrSelected($outfile,$hr1);\r\n}\r\n\r\n# synchronize two arff files, so that they have the same attributes\r\n# can handle attributes in arbitrary order, will produce output in the same attr. order as reference\r\nsub sync_arffs_order {\r\n  my $file1 = $_[0];  # arff file to be modified\r\n  my $file2 = $_[1]; # arff file to sync to...\r\n  my $outfile = $_[2];  # file to save result to\r\n  my $addnames = $_[3];  # reference to hash w. attribute names that will be added as keys \r\n                         # (attr. must exist in file1, and not in file2)\r\n  \r\n  my %addnames_local = ();\r\n  if ($addnames) {  #  check if it is a reference ???!!!\r\n    %addnames_local = %{$addnames};\r\n  }\r\n  \r\n  print \"Loading $file1...\\n\";\r\n  my $hr1 = &load_arff($file1);\r\n  print \"Loading $file2...\\n\";\r\n  my $hr2 = &load_arff($file2);\r\n  my %hrOut={};\r\n  \r\n  print \"Syncing attributes...\\n\";\r\n  $hrOut{\"relation\"} = $hr1->{\"relation\"};\r\n  my $i;  \r\n  # copy attributes from hr1 in hrOut, if present in hr2\r\n  for($i=0; $i <= $#{$hr2->{\"attributes\"}}; $i++) {\r\n  \r\n    $hrOut{\"attributes\"}[$i]{\"name\"} = $hr2->{\"attributes\"}[$i]{\"name\"};\r\n    $hrOut{\"attributes\"}[$i]{\"type\"} = $hr2->{\"attributes\"}[$i]{\"type\"};\r\n    $hrOut{\"attributes\"}[$i]{\"selected\"} = 1;\r\n    $hrOut{\"attribute_names\"}{$hr2->{\"attributes\"}[$i]{\"name\"}} = $i+1;\r\n    my $attrNr1 = $hr1->{\"attribute_names\"}{$hr2->{\"attributes\"}[$i]{\"name\"}}-1;\r\n    \r\n    for ($j=0; $j <= $#{$hr1->{\"instances\"}}; $j++) {\r\n      $hrOut{\"instances\"}[$j][$i] = $hr1->{\"instances\"}[$j][$attrNr1];\r\n    }\r\n  }\r\n  #TODO: add addnames_local names at the end...\r\n  #if ( ($hr2->{\"attribute_names\"}{$hr1->{\"attributes\"}[$i]{\"name\"}}) || \r\n  #      ($addnames_local{$hr1->{\"attributes\"}[$i]{\"name\"}}) ) {\r\n  #  $hr1->{\"attributes\"}[$i]{\"selected\"} = 1;\r\n  #} else {\r\n  #  $hr1->{\"attributes\"}[$i]{\"selected\"} = 0;\r\n  #}\r\n\r\n  \r\n  print \"Saving $outfile...\\n\";\r\n  &save_arff($outfile,\\%hrOut);\r\n}\r\n\r\n# synchronize two arff files, so that they have the same attributes\r\n# can handle attributes in arbitrary order, will produce output in the same attr. order as reference\r\nsub sync_arff_to_attrlist_order {\r\n  my $file1 = $_[0];  # arff file to be modified\r\n  my $attrlist = $_[1]; # attr. list\r\n  my $outfile = $_[2];  # file to save result to\r\n  \r\n  print \"Loading input $file1...\\n\";\r\n  my $hr1 = &load_arff($file1);\r\n  print \"Loading attribute list $file2...\\n\";\r\n  open(FFFILE,\"<$attrlist\");\r\n  my @ftlist;\r\n  while (<FFFILE>) {\r\n    my $line=$_;\r\n    $line=~s/\\n$//;\r\n    $line=~s/\\r$//;\r\n    $line=~s/^\\s*//;\r\n    $line=~s/\\s*$//;\r\n    if ($line !~ /^$/) {\r\n      push(@ftlist,$line);\r\nprint \"ATTR:$line\\n\";\r\n    }\r\n  }\r\n  close(FFFILE);\r\n\r\n  my %hrOut={};\r\n  \r\n  print \"Syncing attributes...\\n\";\r\n  $hrOut{\"relation\"} = $hr1->{\"relation\"};\r\n  my $i;  \r\n  # copy attributes from hr1 in hrOut, if present in hr2\r\n  for($i=0; $i <= $#ftlist; $i++) {\r\n    my $anum = $hr1->{\"attribute_names\"}{$ftlist[$i]}-1;    \r\n\r\n    $hrOut{\"attributes\"}[$i]{\"name\"} = $hr1->{\"attributes\"}[$anum]{\"name\"};\r\n    $hrOut{\"attributes\"}[$i]{\"type\"} = $hr1->{\"attributes\"}[$anum]{\"type\"};\r\n    $hrOut{\"attributes\"}[$i]{\"selected\"} = 1;\r\n    $hrOut{\"attribute_names\"}{$hr1->{\"attributes\"}[$anum]{\"name\"}} = $i+1;\r\n    #my $attrNr1 = $hr1->{\"attribute_names\"}{$hr2->{\"attributes\"}[$i]{\"name\"}}-1;\r\n    \r\n    for ($j=0; $j <= $#{$hr1->{\"instances\"}}; $j++) {\r\n      $hrOut{\"instances\"}[$j][$i] = $hr1->{\"instances\"}[$j][$anum];\r\n    }\r\n  }\r\n  #TODO: add addnames_local names at the end...\r\n  #if ( ($hr2->{\"attribute_names\"}{$hr1->{\"attributes\"}[$i]{\"name\"}}) || \r\n  #      ($addnames_local{$hr1->{\"attributes\"}[$i]{\"name\"}}) ) {\r\n  #  $hr1->{\"attributes\"}[$i]{\"selected\"} = 1;\r\n  #} else {\r\n  #  $hr1->{\"attributes\"}[$i]{\"selected\"} = 0;\r\n  #}\r\n\r\n  \r\n  print \"Saving $outfile...\\n\";\r\n  &save_arff($outfile,\\%hrOut);\r\n}\r\n\r\n# add a new attribute at the beginning with a unique instance id\r\n# USAGE: &add_instance_id($inputarff, $outputarff);\r\nsub add_instance_id {\r\n  my $input = $_[0];\r\n  my $output = $_[1];\r\n  \r\n  my $hr = &load_arff($input);\r\n  my @attr = @{$hr->{\"attributes\"}};\r\n  my $i;\r\n  my %id;\r\n  $id{\"name\"} = \"id\";\r\n  $id{\"type\"} = \"numeric\";\r\n  unshift(@{$hr->{\"attributes\"}},\\%id);\r\n  \r\n  for ($i=0; $i<=$#{$hr->{\"instances\"}}; $i++) {\r\n    unshift(@{$hr->{\"instances\"}[$i]},$i+1);\r\n  }\r\n  &save_arff($output,$hr);\r\n}\r\n\r\n# remove first attribute (instance id) and return array with its values\r\n# USAGE: @instance_ids = &remove_instance_id($inputarff, [$outputarff]);\r\nsub remove_instance_id {\r\n  my $input = $_[0];\r\n  my $output = $_[1];\r\n  \r\n  my $hr = &load_arff($input);\r\n  my @attr = @{$hr->{\"attributes\"}};\r\n  my $id = shift(@{$hr->{\"attributes\"}});\r\n  \r\n  my $i; my @ids=();\r\n  for ($i=0; $i<=$#{$hr->{\"instances\"}}; $i++) {\r\n    $ids[$i] = shift(@{$hr->{\"instances\"}[$i]});\r\n  }\r\n  \r\n  if ($output) {\r\n    &save_arff($output,$hr);\r\n  }\r\n  \r\n  return @ids;\r\n}\r\n\r\n\r\n# USAGE : arff_concat_orderd( $output, $unique_hashref, @inputs ) \r\n# unique_hash:   hash{\"filename\"}[linenr] = uniqueid\r\n# @inputs:  array of input filenames as in hash index\r\n# $output : output filename\r\nsub arff_concat_ordered {\r\n  my $output = shift;\r\n  my $unique_hashref = shift;\r\n  my @inputs = @_;\r\n  \r\n  my %h=();\r\n  # concat all input files with instances in correct order:\r\n  foreach $f (@inputs) {\r\n     my $in = &load_arff($f);\r\n     if ($in->{\"atrributes\"}[0]{\"name\"} =~ /^id$/i) {\r\n       print \"ERROR: first attribute is not an id! in file $f\\n\";\r\n       return;\r\n     }\r\n     unless ($h{\"attributes\"}) {\r\n       $h{\"attributes\"} = $in->{\"attributes\"};\r\n     }\r\n     my $i;\r\n     for ($i=0; $i<=$#{$in->{\"instances\"}}; $i++) {\r\n       $h{\"instances\"}[$in->{\"$instances\"}[$i][0]] = $in->{\"instances\"}[$i];\r\n     }\r\n  }\r\n  # now remove the id field:\r\n  my $id = shift(@{$h{\"attributes\"}});\r\n  my $i; my @ids=();\r\n  for ($i=0; $i<=$#{$h{\"instances\"}}; $i++) {\r\n    $ids[$i] = shift(@{$h{\"instances\"}[$i]});\r\n  }\r\n  # and save to output file:\r\n  &save_arff($output,\\%h);\r\n}\r\n\r\n# remove specific attributes from an arff file (by name)\r\nsub arff_remove_attr {\r\n  my $input = shift;  # input arff\r\n  my $output = shift; # output arff\r\n  my @names = @_;  # names of attributes to remove\r\n  \r\n  my $in=&load_arff($input);\r\n  # get indicies of attributes to remove:\r\n  # $hash{\"attribute_names\"}{$1}\r\n  foreach $f (@names) {\r\n    splice(@{$in->{\"attributes\"}}, $in->{\"attribute_names\"}{$f});\r\n    \r\n  }\r\n  &save_arff($output,$in);\r\n}\r\n\r\n####################### weka calls: ######################\r\nsub chop_newline {\r\n  my $i;\r\n  #for ($i=0; $i<=$#_; $i++) {\r\n    $_ =~ s/\\n$//;\r\n    $_ =~ s/\\n$//;\r\n  #}\r\n  return $_;\r\n}\r\n\r\n$wekacmd = \"java -Xmx1024m -classpath /home/don/eyb/inst/weka-3-5-6/weka.jar \";  \r\n# run a weka function:\r\nsub run_weka {\r\n  #my @cmdline = @_;\r\n  #unshift(@cmdline,split(/ /,$wekacmd));\r\n  #print \"running command: \".join(\" \",@cmdline).\"\\n\";\r\n  #my $cmd = \"\\\"\".join(\"\\\" \\\"\",@cmdline).\"\\\"\";\r\n  #system(@cmdline);\r\n\r\n  my $cmdline = $_[0];\r\n print \"running command: \".$wekacmd.\" \".$cmdline.\"\\n\";\r\n  system($wekacmd.\" \".$cmdline);\r\n  \r\n  if ($?) {\r\n    print \"ERROR running Weka\\n\";\r\n    return $retval;\r\n  }\r\n  \r\n  return $retval;\r\n}\r\n#weka.filters.unsupervised.attribute.Remove -R 5 -i $input_arff -o $input_arff.arff\r\n\r\n\r\n# &scv_split($input_arff, $nfolds, [$output base])\r\n# split arff file into N folds , create train and test arff file for each fold\r\n#  append _fNN_train to each filename base\r\n# return value: hash reference to hash with arrays of train/test files\r\nsub scv_split {\r\n  my $input = $_[0];\r\n  my $nfolds = $_[1];\r\n  my $outbase = $_[2];\r\n  my $class = \"-c last\";  # classification (nominal class)\r\n  #$class = \"\";         # regression (numerical class)\r\n  \r\n  unless ($outbase) {\r\n    $outbase = $input;\r\n    $outbase =~ s/\\.arff$//i;\r\n  }\r\n  \r\n  my %files=();\r\n  $files{\"nfolds\"} = $nfolds;\r\n  my $i;\r\n  for ($i=1; $i<=$nfolds; $i++) {\r\n    my $fnr = sprintf(\"%3i\",$i); $fnr =~ s/\\s/0/g;\r\n    my $train = $outbase.\"_f$fnr\".\"_train.arff\";\r\n    my $test  = $outbase.\"_f$fnr\".\"_test.arff\";\r\n    $files{\"train\"}[$i-1] = $train;\r\n    $files{\"test\"}[$i-1]  = $test;\r\n    #print \"FOLD: $fnr -> $train\\n\";\r\n    print \"Generating train/test files for FOLD $fnr ... \";\r\n    unless (-f $train) {\r\n      if (&run_weka(\"weka.filters.supervised.instance.StratifiedRemoveFolds -i $input -o $train $class -V -S 0 -N $nfolds -F $i \")) { return 1; }\r\n    } else { print \"(trainfile exists) \"; }\r\n    unless (-f $test) {\r\n      if (&run_weka(\"weka.filters.supervised.instance.StratifiedRemoveFolds -i $input -o $test $class -S 0 -N $nfolds -F $i \")) { return 1; }\r\n    } else { print \"(testfile exists) \"; }\r\n    print \"done\\n\";\r\n  } \r\n  \r\n  return \\%files;\r\n}\r\n\r\n\r\nsub weka_cfs {\r\n  my $input = shift;\r\n  my $output = shift;\r\n  return &run_weka(\"weka.filters.supervised.attribute.AttributeSelection -E \\\"weka.attributeSelection.CfsSubsetEval \\\" -S \\\"weka.attributeSelection.BestFirst -D 1 -N 5\\\" -i $input -o $output \");\r\n}\r\n\r\n$default_classifier = \"weka.classifiers.functions.SVMreg -C 1.0 -N 0 -I \\\"weka.classifiers.functions.supportVector.RegSMOImproved -L 0.0010 -W 1 -P 1.0E-12 -T 0.0010 -V\\\" -K \\\"weka.classifiers.functions.supportVector.PolyKernel -C 250007 -E 1.0\\\"\";\r\n\r\n# train on train_arff, test with test_arff, save predicitons in file\r\n# this function does not save a model\r\nsub classify_predict {\r\n  my $trainarff = shift;\r\n  my $testarff = shift;\r\n  my $predictions = shift;\r\n  my $classifier = shift;\r\n  unless ($classifier) { $classifier = $default_classifier; }\r\n  \r\n  return &run_weka(\"$classifier -T $testarff -t $trainarff -no-cv -p 0 > $predictions\");\r\n}\r\n\r\n# train on train_arff, test with test_arff, save results in file\r\n# this function does not save a model\r\nsub classify_eval {\r\n  my $trainarff = shift;\r\n  my $testarff = shift;\r\n  my $results = shift;\r\n  my $classifier = shift;\r\n  unless ($classifier) { $classifier = $default_classifier; }\r\n  \r\n  #TODO: how to get confusion matrix???\r\n  return &run_weka(\"$classifier -T $testarff -t $trainarff -no-cv > $results\");\r\n}\r\n\r\n# parse weka results and return as perl hash ref\r\nsub parse_weka_results {\r\n  my $results = shift;  # results filename\r\n  my %res;\r\n  open(FFILE,\"<$results\");\r\n  my $flag=0;\r\n  while(<FFILE>) {\r\n    chop; my $line=$_;\r\n    if ($line=~/^=== .+ test .+ ===\\s*$/) { $flag=1; }\r\n    else {\r\n      if ($flag) {\r\n        if ($line=~/^===/) { $flag=0; }\r\n        if ($line=~/Correctly Classified Instances\\s+([0-9]+)\\s/) {\r\n          $res{\"correct\"}=$1;\r\n        }\r\n        if ($line=~/Incorrectly Classified Instances\\s+([0-9]+)\\s/) {\r\n          $res{\"incorrect\"}=$1;\r\n        }\r\n        if ($line=~/Total Number of Instances\\s+([0-9]+)\\s/) {\r\n          $res{\"total\"}=$1;\r\n        }\r\n      }\r\n    }\r\n  }\r\n  close(FFILE);\r\n  return \\%res;\r\n}\r\n\r\n# get confusion matrix from weka results file\r\nsub parse_weka_confmat {\r\n  my $results = shift;  # results filename\r\n  my $clsref = shift;\r\n  open(FFILE,\"<$results\");\r\n  my $flag=0;\r\n  my %cfmat, %cfmat0;\r\n  my @clses;\r\n  while(<FFILE>) {\r\n    chop; my $line=$_;\r\n    if ($line=~/^=== Confusion Matrix ===\\s*$/) { $flag=1; }\r\n    else {\r\n      if ($flag==1) { # read header\r\n\tif ($line=~/<-- classified as/) { $flag = 2; \r\n\t  \r\n\t}\r\n      } elsif ($flag==2) {\r\n        # read elements\r\n\tif ($line =~ /^ +(.+?) +\\| +[a-z]+ = (.+)$/) {\r\n          my $els = $1;\r\n          my $cls = $2;\r\n          $cfmat0{$cls} = $els;\r\n          my $fl=0;\r\n          my $tmp;\r\n\t  foreach $tmp (@{$clsref}) {\r\n            if ($cls eq $tmp) { $fl=1; }\r\n\t  }\r\n          unless ($fl) { push(@{$clsref},$cls); }\r\n        }\r\n      }\r\n    }\r\n  }\r\n  my $ttt=0;\r\n  my $c;\r\n  foreach $c (@{$clsref}) {\r\n    my $l = $cfmat0{$c};\r\n    my @el = split(/ +/,$l);\r\n    if ($#el != $#{$clsref}) { print \"CONF MAT PARSE ERROR $#el != \".$#{$clsref}.\"!\\n\"; }\r\n    my $i;\r\n    for ($i=0; $i<=$#el; $i++)  {\r\n      $cfmat{$c}{$clsref->[$i]} = $el[$i];\r\n      $ttt+=$el[$i];\r\n    }\r\n  }\r\n#print \"total:::: $ttt\\n\";\r\n  close(FFILE);\r\n  return \\%cfmat;\r\n}\r\n\r\n# build a model from a given arff file\r\nsub build_model {\r\n  my $trainarff = $_[0];\r\n  my $model = $_[1];\r\n  my $classifier = $_[2];\r\n  my $trainlog = $_[3];\r\n  unless ($trainlog) { $trainlog = \"/dev/null\"; }\r\n  unless ($classifier) { $classifier = $default_classifier; }\r\n\r\n  &run_weka(\"$classifier -t $trainarff -d $model -no-cv > $trainlog\");\r\n}\r\n\r\n# test a model with a given test data set (arff)\r\nsub test_model {\r\n  my $testarff = $_[0];\r\n  my $model = $_[1];\r\n  my $results = $_[2];\r\n  my $classifier = $_[3];\r\n\r\n  &run_weka(\"$classifier -T $testarff -l $model > $results\");\r\n}\r\n\r\n# compute predictions for a given arff file using a given model\r\n# USAGE: [ @pred = ] &compute_predictions( $testarff, $model, $predicitions, [$classifier] );\r\nsub compute_predictions {\r\n  my $testarff = shift;\r\n  my $model = shift;\r\n  my $predictions = shift;\r\n#  my @classifier = @_;\r\n#  unless (@classifier) { @classifier = @default_classifier; }\r\n  my $classifier = shift;\r\n  unless ($classifier) { $classifier = $default_classifier; }\r\n\r\n#  &run_weka(@classifier,\"-T\", \"$testarff\", \"-l\", \"$model\", \"-p\",  \"0\", \"-no-cv\");\r\n  &run_weka($classifier.\" -T $testarff -l $model -p 0 -no-cv\");\r\n  \r\n  my @pred = &load_predictions($predicitons);\r\n    \r\n  return @pred;\r\n}\r\n\r\n\r\n# load weka predicitons:\r\n# USAGE: @pred = &load_predictions($filename);\r\nsub load_predictions {\r\n  my $fname = $_[0];\r\n  \r\n  my $i;\r\n  my @predictions=();\r\n  \r\n  open(FFILE,\"<$fname\");\r\n  my $header=<FFILE>; $header=&chop_newline($header);\r\n  $header =~ s/^\\s+//; $header =~ s/\\s+$//;\r\n  my @attrs = split(/\\s+/,$header);\r\n  my $predNr = 2;\r\n  for ($i=0;$i<=$#attrs;$i++) { if ($attrs[$i] =~ /^predicted$/i) {$predNr = $i; last;} }\r\n  \r\n  #$i=0;\r\n  while(<FFILE>) {\r\n    my $line=&chop_newline($_);\r\n    $line =~ s/^\\s+//; $line =~ s/\\s+$//;\r\n    print \"l: $line\\n\";\r\n    my @els = split(/\\s+/,$line);\r\n    if ($#els > 0) {\r\n      $predictions[$els[0]] = $els[$predNr];\r\n    }\r\n    print $els[$predNr].\"\\n\";\r\n    print $predNr.\"\\n\";\r\n  }\r\n  close(FFILE);\r\n  \r\n  return @predictions;\r\n}\r\n\r\n\r\n1;\r\n"
  },
  {
    "path": "scripts/modeltrain/arff-standardize.c",
    "content": "/*F***************************************************************************\r\n * \r\n * openSMILE - the Munich open source Multimedia Interpretation by \r\n * Large-scale Extraction toolkit\r\n * \r\n * This file is part of openSMILE.\r\n * \r\n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\r\n * \r\n * See file \"COPYING\" for details on usage rights and licensing terms.\r\n * By using, copying, editing, compiling, modifying, reading, etc. this\r\n * file, you agree to the licensing terms in the file COPYING.\r\n * If you do not agree to the licensing terms,\r\n * you must immediately destroy all copies of this file.\r\n * \r\n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\r\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\r\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\r\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\r\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\r\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\r\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\r\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\r\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\r\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\r\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\r\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\r\n * THE SOFTWARE OR DERIVATIVE WORKS.\r\n * \r\n * Main authors: Florian Eyben, Felix Weninger, \r\n *            Martin Woellmer, Bjoern Schuller\r\n * \r\n * Copyright (c) 2008-2013, \r\n *   Institute for Human-Machine Communication,\r\n *   Technische Universitaet Muenchen, Germany\r\n * \r\n * Copyright (c) 2013-2015, \r\n *   audEERING UG (haftungsbeschraenkt),\r\n *   Gilching, Germany\r\n * \r\n * Copyright (c) 2016,   \r\n *   audEERING GmbH,\r\n *   Gilching Germany\r\n ***************************************************************************E*/\r\n\r\n\r\n\r\n/*\r\n\r\nread in one ARFF file, compute mean and variance and standardize + save normadta \r\ncompute mean and variance \r\n\r\n*/\r\n\r\n\r\n#include <stdio.h>\r\n#include <stdlib.h>\r\n#include <malloc.h>\r\n#include <strings.h>\r\n#include <string.h>\r\n#include <inttypes.h>\r\n#include <math.h>\r\n\r\n\r\n\r\ntypedef struct {\r\n  long dim;\r\n  float *x;\r\n} sVectorFloat;\r\ntypedef sVectorFloat * vectorFloat;\r\n\r\ntypedef struct {\r\n  long dim;\r\n  double *x;\r\n} sVectorDouble;\r\ntypedef sVectorDouble * vectorDouble;\r\n\r\ntypedef struct {\r\n  long dim;\r\n  void *x;\r\n} sVector;\r\ntypedef sVector * vector;\r\n\r\ntypedef struct {\r\n  int nDim;\r\n  long *dim;\r\n  long long els;\r\n  float *x;\r\n} sMatrixFloat;\r\ntypedef sMatrixFloat * matrixFloat;\r\n\r\ntypedef struct {\r\n  long rows, cols;\r\n  long long els;\r\n  float *x;\r\n} sMatrix2DFloat;\r\ntypedef sMatrix2DFloat * matrix2DFloat;\r\n\r\n\r\ninline vector vectorCreate(long dim, int elSize) // elSize : size of vector element in bytes\r\n{\r\n  vector ret = (vector)malloc(sizeof(sVector));\r\n  if (ret == NULL) return NULL;\r\n  ret->x = calloc(1,elSize*dim);\r\n  ret->dim = dim;\r\n  return ret;\r\n}\r\n\r\ninline vectorFloat vectorFloatCreate(long dim) \r\n{\r\n  vectorFloat ret = (vectorFloat)malloc(sizeof(sVectorFloat));\r\n  if (ret == NULL) return NULL;\r\n  ret->x = (float *)calloc(1,sizeof(float)*dim);\r\n  ret->dim = dim;\r\n  return ret;\r\n}\r\n\r\ninline vectorDouble vectorDoubleCreate(long dim) \r\n{\r\n  vectorDouble ret = (vectorDouble)malloc(sizeof(sVectorDouble));\r\n  if (ret == NULL) return NULL;\r\n  ret->x = (double *)calloc(1,sizeof(double)*dim);\r\n  ret->dim = dim;\r\n  return ret;\r\n}\r\n\r\ninline vectorFloat vectorFloatDestroy(vectorFloat vec)\r\n{\r\n  if (vec != NULL) {\r\n    if (vec->x != NULL) free(vec->x);\r\n    free(vec);\r\n  }\r\n  return NULL;       \r\n}\r\n\r\ninline vectorDouble vectorDoubleDestroy(vectorDouble vec)\r\n{\r\n  if (vec != NULL) {\r\n    if (vec->x != NULL) free(vec->x);\r\n    free(vec);\r\n  }\r\n  return NULL;       \r\n}\r\n\r\nmatrixFloat matrixFloatCreate(int nDim, long *dim) \r\n{\r\n  int i;\r\n  matrixFloat ret = (matrixFloat)malloc(sizeof(sMatrixFloat));\r\n  if (ret == NULL) return NULL;\r\n  ret->els = 1;\r\n  for (i=0; i<nDim; i++) {\r\n    ret->els *= dim[i];    \r\n  }\r\n  ret->x = (float *)calloc(1,sizeof(float)*ret->els);\r\n  ret->dim = dim;\r\n  return ret;\r\n}\r\n\r\nmatrix2DFloat matrix2DFloatCreate(long rows, long cols) \r\n{\r\n  matrix2DFloat ret = (matrix2DFloat)malloc(sizeof(sMatrix2DFloat));\r\n  if (ret == NULL) return NULL;\r\n  ret->els = rows*cols;\r\n  ret->rows = rows;\r\n  ret->cols = cols;\r\n  ret->x = (float *)calloc(1,sizeof(float)*ret->els);\r\n  return ret;\r\n}\r\n\r\nmatrix2DFloat matrix2DFloatDestroy(matrix2DFloat mat) \r\n{\r\n  if (mat == NULL) return NULL;\r\n  if (mat->x != NULL) free(mat->x);\r\n  free(mat);\r\n  return NULL;\r\n}\r\n\r\n\r\n\r\ninline float minFloat(float a, float b)\r\n{\r\n  if (a < b) return a;\r\n  else return b;         \r\n}\r\n\r\ninline long minLong(long a, long b)\r\n{\r\n  if (a < b) return a;\r\n  else return b;         \r\n}\r\n\r\nvectorFloat getMatrix2DFloatRow(matrix2DFloat mat, long row)\r\n{\r\n  if ((mat != NULL)&&(mat->x != NULL)) {\r\n    vectorFloat r = vectorFloatCreate(mat->cols);\r\n    if (r == NULL) return NULL;\r\n    memcpy(r->x, mat->x + (row * (mat->cols)), (mat->cols) * sizeof(float));\r\n    return r;\r\n  }\r\n  return NULL;\r\n}\r\n\r\nvoid setMatrix2DFloatRow(matrix2DFloat mat, long row, vectorFloat r)\r\n{\r\n  if ((mat != NULL)&&(mat->x != NULL)) {\r\n    if (r == NULL) return;\r\n    memcpy(mat->x + (row * (mat->cols)), r->x , (mat->cols) * sizeof(float));\r\n  }\r\n}\r\n\r\n// add vector b onto vector a\r\nvoid vectorFloatAdd(vectorFloat a, vectorFloat b)\r\n{\r\n  if ((a!= NULL)&&(a->x != NULL)&&(b!= NULL)&&(b->x != NULL)) {\r\n    long i;\r\n    long lng = minLong(a->dim, b->dim);\r\n    for (i=0; i<lng; i++) {\r\n      a->x[i] += b->x[i];    \r\n    }\r\n  }\r\n}\r\n\r\n// subtract vector b from vector a\r\nvoid vectorFloatSub(vectorFloat a, vectorFloat b)\r\n{\r\n  if ((a!= NULL)&&(a->x != NULL)&&(b!= NULL)&&(b->x != NULL)) {\r\n    long i;\r\n    long lng = minLong(a->dim, b->dim);\r\n    for (i=0; i<lng; i++) {\r\n      a->x[i] -= b->x[i];    \r\n    }\r\n  }\r\n}\r\n\r\n// add vector b onto vector a\r\nvoid vectorDoubleAdd(vectorDouble a, vectorDouble b)\r\n{\r\n  if ((a!= NULL)&&(a->x != NULL)&&(b!= NULL)&&(b->x != NULL)) {\r\n    long i;\r\n    long lng = minLong(a->dim, b->dim);\r\n    for (i=0; i<lng; i++) {\r\n      a->x[i] += b->x[i];    \r\n    }\r\n  }\r\n}\r\n\r\n// subtract vector b from vector a\r\nvoid vectorDoubleSub(vectorDouble a, vectorDouble b)\r\n{\r\n  if ((a!= NULL)&&(a->x != NULL)&&(b!= NULL)&&(b->x != NULL)) {\r\n    long i;\r\n    long lng = minLong(a->dim, b->dim);\r\n    for (i=0; i<lng; i++) {\r\n      a->x[i] -= b->x[i];    \r\n    }\r\n  }\r\n}\r\n\r\n// divide elements in vector a by corresponding elements in vector b, save in a\r\nvoid vectorFloatElemDiv(vectorFloat a, vectorFloat b)\r\n{\r\n  if ((a!= NULL)&&(a->x != NULL)&&(b!= NULL)&&(b->x != NULL)) {\r\n    long i;\r\n    long lng = minLong(a->dim, b->dim);\r\n    for (i=0; i<lng; i++) {\r\n      a->x[i] /= b->x[i];    \r\n    }\r\n  }\r\n}\r\n\r\n// divide elements in vector a by corresponding elements in vector b, save in a\r\nvoid vectorDoubleElemDiv(vectorDouble a, vectorDouble b)\r\n{\r\n  if ((a!= NULL)&&(a->x != NULL)&&(b!= NULL)&&(b->x != NULL)) {\r\n    long i;\r\n    long lng = minLong(a->dim, b->dim);\r\n    for (i=0; i<lng; i++) {\r\n      a->x[i] /= b->x[i];    \r\n    }\r\n  }\r\n}\r\n\r\n// divide elements in vector a by corresponding elements in vector b, save in a\r\n// SAFE: do not dived by 0, result will then be 0\r\nvoid vectorDoubleElemSafeDiv(vectorDouble a, vectorDouble b)\r\n{\r\n  if ((a!= NULL)&&(a->x != NULL)&&(b!= NULL)&&(b->x != NULL)) {\r\n    long i;\r\n    long lng = minLong(a->dim, b->dim);\r\n    for (i=0; i<lng; i++) {\r\n      if (b->x[i] != 0.0)\r\n        a->x[i] /= b->x[i];    \r\n      else \r\n        a->x[i] = 0.0;\r\n    }\r\n  }\r\n}\r\n\r\nvectorDouble vectorFloatToVectorDouble(vectorFloat a)\r\n{\r\n  if ((a!= NULL)&&(a->x != NULL)) {\r\n    long i;\r\n    vectorDouble d = vectorDoubleCreate(a->dim);\r\n    if (d==NULL) return NULL;\r\n    for (i=0; i<a->dim; i++) {\r\n      d->x[i] = (double)(a->x[i]);\r\n    }\r\n    return d;\r\n  }\r\n  return NULL;\r\n}\r\n\r\nvectorFloat vectorDoubleToVectorFloat(vectorDouble a)\r\n{\r\n  if ((a!= NULL)&&(a->x != NULL)) {\r\n    long i;\r\n    vectorFloat d = vectorFloatCreate(a->dim);\r\n    if (d==NULL) return NULL;\r\n    for (i=0; i<a->dim; i++) {\r\n      d->x[i] = (float)(a->x[i]);\r\n    }\r\n    return d;\r\n  }\r\n  return NULL;\r\n}\r\n\r\nvoid vectorDoubleScalarDiv(vectorDouble vec, long long n)\r\n{\r\n  if ((vec != NULL)&&(vec->x != NULL)) {\r\n    long i;\r\n    double nD = (double)n;\r\n    for (i=0; i<vec->dim; i++) {\r\n      vec->x[i] /= nD;\r\n    }         \r\n  }\r\n}\r\n\r\nvoid vectorDoubleElemSqrt(vectorDouble vec)\r\n{\r\n  if ((vec != NULL)&&(vec->x != NULL)) {\r\n    long i;\r\n    for (i=0; i<vec->dim; i++) {\r\n      vec->x[i] = sqrt(vec->x[i]);\r\n    }         \r\n  }\r\n}\r\n\r\nvoid vectorDoubleElemSqr(vectorDouble vec)\r\n{\r\n  if ((vec != NULL)&&(vec->x != NULL)) {\r\n    long i;\r\n    for (i=0; i<vec->dim; i++) {\r\n      vec->x[i] = vec->x[i] * vec->x[i];\r\n    }         \r\n  }\r\n}\r\n\r\n\r\nvectorFloat columnSum (matrix2DFloat mat)\r\n{\r\n  long i,j;\r\n  if ((mat != NULL)&&(mat->x != NULL)) {\r\n    vectorFloat v = getMatrix2DFloatRow(mat,0);\r\n    for(i=1; i<mat->rows; i++) {\r\n       vectorFloat r = getMatrix2DFloatRow(mat,i);\r\n       vectorFloatAdd(v,r);\r\n       vectorFloatDestroy(r);\r\n    }\r\n    return v;\r\n  }       \r\n  return NULL;\r\n}\r\n\r\nvectorDouble columnVarianceSum (matrix2DFloat mat, vectorDouble means)\r\n{\r\n  long i,j;\r\n  if ((mat != NULL)&&(mat->x != NULL)) {\r\n    vectorFloat vf = getMatrix2DFloatRow(mat,0);\r\n    vectorDouble v = vectorFloatToVectorDouble(vf);\r\n\r\n    vf = vectorFloatDestroy(vf);\r\n    for(i=1; i<mat->rows; i++) {\r\n       vectorFloat r = getMatrix2DFloatRow(mat,i);\r\n       vectorDouble rD = vectorFloatToVectorDouble(r);\r\n       vectorFloatDestroy(r);\r\n       vectorDoubleSub(rD,means);\r\n       vectorDoubleElemSqr(rD);\r\n       vectorDoubleAdd(v,rD);\r\n       vectorDoubleDestroy(rD);\r\n    }\r\n    return v;\r\n  }       \r\n  return NULL;\r\n}\r\n\r\nvoid matRowsNormaliseMean (matrix2DFloat mat, vectorFloat mean)\r\n{\r\n  long i,j;\r\n  if ((mat != NULL)&&(mat->x != NULL)) {\r\n    for(i=0; i<mat->rows; i++) {\r\n       vectorFloat r = getMatrix2DFloatRow(mat,i);\r\n       vectorFloatSub(r,mean);\r\n       setMatrix2DFloatRow(mat,i,r);\r\n       vectorFloatDestroy(r);\r\n    }\r\n  }       \r\n}\r\n\r\nvoid matRowsStandardiseVariance (matrix2DFloat mat, vectorFloat stddev)\r\n{\r\n  long i,j;\r\n  if ((mat != NULL)&&(mat->x != NULL)) {\r\n    for(i=0; i<mat->rows; i++) {\r\n       vectorFloat r = getMatrix2DFloatRow(mat,i);\r\n       vectorFloatElemDiv(r,stddev);\r\n       setMatrix2DFloatRow(mat,i,r);\r\n       vectorFloatDestroy(r);\r\n    }\r\n  }       \r\n}\r\n\r\n#include <stdarg.h>\r\n#define MIN_LOG_STRLEN   255\r\n/* allocate a string and expand vararg format string expression into it */\r\n// WARNING: memory allocated by myvprint must freed by the code calling myvprint!!\r\nchar *myvprint(const char *fmt, ...) {\r\n  char *s= (char *)malloc(sizeof(char)*(MIN_LOG_STRLEN+1));\r\n  if (s==NULL) return NULL;\r\n  va_list ap;\r\n  va_start(ap, fmt);\r\n  int len = vsnprintf(s,MIN_LOG_STRLEN+1, fmt, ap);\r\n  if (len > MIN_LOG_STRLEN) {\r\n    free(s);        \r\n    s = (char *)malloc(sizeof(char)*len+2);\r\n    va_start(ap, fmt);\r\n    len = vsnprintf(s,len+1, fmt, ap);\r\n  }\r\n  va_end(ap);\r\n  return s;\r\n}\r\n\r\n    //  matRowsNormaliseMean(data,mean);\r\n    //  matRowsStandardiseVariance(data,stddev);\r\n\r\nint main(int argc, char *argv[])\r\n{\r\n  if (argc < 5) {\r\n    fprintf(stderr, \"USAGE: %s <input_arff_file> <output_arff_file(or'-')> <start ft#> <rel.end ft.#> [normdata.dat_file_to_load OR -normdata_file_to_saveTo]\\n\",argv[0]);\r\n    return -1;\r\n  }\r\n  \r\n  vectorDouble sum = NULL; \r\n  vectorDouble var = NULL; \r\n  vectorDouble mean = NULL;\r\n  vectorDouble stddev = NULL;\r\n  vectorFloat meanF = NULL;\r\n  vectorFloat stddevF = NULL;\r\n  long long n = 0;\r\n  FILE *iarff;\r\n  \r\n  int startft = atoi(argv[3]); \r\n  int endft = atoi(argv[4]); \r\n  if ((argc == 5)||(argv[5][0]=='-')) { // no normdata file given, create normadata from input arff\r\n \r\n  /*** mean ****/\r\n  iarff = fopen(argv[1],\"r\");\r\n  int read;\r\n  char *line=NULL;\r\n  char *nline=NULL;\r\n  size_t len=0;\r\n  int data = 0;\r\n  int Natt = 0;\r\n  while ((read = getline(&line, &len, iarff)) != -1) {\r\n    int llen = strlen(line);\r\n    if (llen <= 0) continue;\r\n//printf(\"llen=%i\\n\",llen);\r\n    if (line[llen-1] == '\\n') {\r\n      line[llen-1] = 0; // strip \\n character\r\n      llen--;\r\n    }\r\n    if (llen <= 0) continue;\r\n    if (line[llen-1] == '\\r') {\r\n      line[llen-1] = 0; // strip \\r character\r\n      llen--;\r\n    }\r\n    if (llen <= 0) continue;\r\n    // ignore non-data lines...\r\n    if (data == 0) {\r\n      if (llen >= 5) {\r\n        data = 1;\r\n        if (line[0] != '@') data = 0;\r\n\telse if (line[1] != 'd') data = 0;\r\n\telse if (line[2] != 'a') data = 0;\r\n\telse if (line[3] != 't') data = 0;\r\n\telse if (line[4] != 'a') data = 0;\r\n//printf(\"data=%i line='%s'\\n\",data,line);\r\n      }\r\n      if (llen >= 10) {\r\n        int att = 1;\r\n        if (line[0] != '@') att = 0;\r\n\telse if (line[1] != 'a') att = 0;\r\n\telse if (line[2] != 't') att = 0;\r\n\telse if (line[3] != 't') att = 0;\r\n\telse if (line[4] != 'r') att = 0;\r\n\telse if (line[5] != 'i') att = 0;\r\n\telse if (line[6] != 'b') att = 0;\r\n\telse if (line[7] != 'u') att = 0;\r\n\telse if (line[8] != 't') att = 0;\r\n\telse if (line[9] != 'e') att = 0;\r\n        if (att) Natt++;\r\n      }\r\n      nline = NULL;\r\n    } else {\r\n      nline = line;\r\n      // remove spaces\r\n      while ((llen>0)&&(nline[0]==' ')) { nline++; llen--; }\r\n      while ((llen>0)&&(nline[llen-1]==' ')) { nline[llen-1]=0; llen--; }\r\n      // convert line to vecotr\r\n      char *el=NULL;\r\n      int vlen = (Natt-endft)-startft+1;\r\n      vectorDouble d = vectorDoubleCreate(vlen);\r\n      if (sum == NULL) {\r\n        sum = vectorDoubleCreate(vlen);\r\nprintf(\"create sum vlen=%i\\n\",vlen); fflush(stdout);\r\n      }\r\n      int fti=1;\r\n      if (llen > 0) {\r\n        do {\r\n  \t  el=strchr(nline,',');\r\n          if (el!=NULL) \r\n  \t    el[0] = 0;\r\n\t  if (fti>=startft) \r\n            if (fti<vlen+startft)\r\n              d->x[fti-startft] = atof(nline);\r\n          fti++;\r\n\t  if (el!=NULL) {\r\n\t    nline = el+1;             \r\n          }\r\n        } while (el!=NULL);\r\n      }\r\n      if (fti-startft < vlen) { printf(\"warning: less elements on line than expected!!\\n\"); }\r\n      // add vector to sum...\r\n      vectorDoubleAdd(sum,d);\r\n      vectorDoubleDestroy(d);\r\n      n++;\r\n    }\r\n    free(line); line=NULL;\r\n\r\n  }\r\n  fclose(iarff);\r\n\r\n  // compute means:\r\n  if (n>0)\r\n    vectorDoubleScalarDiv(sum,n);\r\n  mean = sum;\r\n  \r\n  /**** variance ****/\r\n  vectorDouble var = NULL;\r\n  iarff = fopen(argv[1],\"r\");\r\n  read = 0;\r\n  line=NULL;\r\n  nline=NULL;\r\n  len=0;\r\n  data = 0;\r\n  Natt = 0;\r\n  while ((read = getline(&line, &len, iarff)) != -1) {\r\n    int llen = strlen(line);\r\n    if (llen <= 0) continue;\r\n    if (line[llen-1] == '\\n') {\r\n      line[llen-1] = 0; // strip \\n character\r\n      llen--;\r\n    }\r\n    if (llen <= 0) continue;\r\n    if (line[llen-1] == '\\r') {\r\n      line[llen-1] = 0; // strip \\r character\r\n      llen--;\r\n    }\r\n    if (llen <= 0) continue;\r\n    // ignore non-data lines...\r\n    if (data == 0) {\r\n      if (llen >= 5) {\r\n        data = 1;\r\n        if (line[0] != '@') data = 0;\r\n        else if (line[1] != 'd') data = 0;\r\n        else if (line[2] != 'a') data = 0;\r\n        else if (line[3] != 't') data = 0;\r\n        else if (line[4] != 'a') data = 0;\r\n      }\r\n      if (llen >= 10) {\r\n        int att = 1;\r\n        if (line[0] != '@') att = 0;\r\n        else if (line[1] != 'a') att = 0;\r\n        else if (line[2] != 't') att = 0;\r\n        else if (line[3] != 't') att = 0;\r\n        else if (line[4] != 'r') att = 0;\r\n        else if (line[5] != 'i') att = 0;\r\n        else if (line[6] != 'b') att = 0;\r\n        else if (line[7] != 'u') att = 0;\r\n        else if (line[8] != 't') att = 0;\r\n        else if (line[9] != 'e') att = 0;\r\n        if (att) Natt++;\r\n      }\r\n      nline = NULL;\r\n    } else {\r\n      nline = line;\r\n      // remove spaces\r\n      while ((llen>0)&&(nline[0]==' ')) { nline++; llen--; }\r\n      while ((llen>0)&&(nline[llen-1]==' ')) { nline[llen-1]=0; llen--; }\r\n      // convert line to vecotr\r\n      char *el=NULL;\r\n      int vlen = (Natt-endft)-startft+1;\r\n      vectorDouble d = vectorDoubleCreate(vlen);\r\n      if (var == NULL) {\r\n        var = vectorDoubleCreate(vlen);\r\n      }\r\n      int fti=1;\r\n      if (llen > 0) {\r\n        do {\r\n          el=strchr(nline,',');\r\n          if (el != NULL) \r\n            el[0] = 0;\r\n          if (fti>=startft)\r\n            if (fti<vlen+startft)\r\n              d->x[fti-startft] = atof(nline);\r\n          fti++;\r\n          if (el!=NULL) {\r\n            nline = el+1;\r\n          }\r\n        } while (el!=NULL);\r\n      }\r\n      if (fti-startft < vlen) { printf(\"warning: less elements on line than expected!!\\n\"); }\r\n      // add vector var to variance sum...\r\n//...\r\n      vectorDoubleSub(d,mean);\r\n      vectorDoubleElemSqr(d);\r\n      vectorDoubleAdd(var,d);\r\n      vectorDoubleDestroy(d); d=NULL;\r\n      //n++;\r\n    }\r\n    free(line); line=NULL;\r\n\r\n  }\r\n  fclose(iarff);\r\n\r\n\r\n  if (n>0)\r\n    vectorDoubleScalarDiv(var,n);\r\n  stddev = var;\r\n  vectorDoubleElemSqrt(stddev);\r\n  \r\n  //printf(\"var0: %f (dim=%i)\\n\",var->x[0],var->dim);\r\n  // save normdata file in current path \r\n  \r\n  FILE *nd ;\r\n  if ((argc>5)&&(argv[5][0]=='-')) {\r\n    nd = fopen((argv[5]+1),\"wb\");\r\n  } else {\r\n    nd = fopen(\"normdata.dat\",\"wb\");\r\n  }\r\n  if (nd != NULL) {\r\n    fwrite(mean->x, sizeof(double)*mean->dim, 1, nd);\r\n    fwrite(stddev->x, sizeof(double)*stddev->dim, 1, nd);\r\n    fclose(nd);  \r\n  } else {\r\n    fprintf(stderr,\"ERROR saving normdata\\n\");       \r\n  }\r\n\r\n  //meanF = vectorDoubleToVectorFloat(mean);\r\n  //stddevF = vectorDoubleToVectorFloat(stddev);\r\n\r\n  }\r\n\r\n/* do actual standardisation::: */\r\n/***************************************************************************/\r\n\r\n  FILE * oarff=NULL;\r\n  iarff = fopen(argv[1],\"r\");\r\n  if (!(argv[2][0] == '-')) {\r\n    oarff = fopen(argv[2],\"w\");\r\n  } else {\r\n    char *tmp = myvprint(\"%s.norm.arff\",argv[1]);\r\n    oarff = fopen(tmp,\"w\");\r\n    free(tmp);\r\n  }\r\n  int read = 0;\r\n  char *line=NULL;\r\n  char *nline=NULL;\r\n  size_t len=0;\r\n  int data = 0;\r\n  int Natt = 0;\r\n  while ((read = getline(&line, &len, iarff)) != -1) {\r\n    int llen = strlen(line);\r\n    if (line[llen-1] == '\\n') {\r\n      line[llen-1] = 0; // strip \\n character\r\n      llen--;\r\n    }\r\n    if (line[llen-1] == '\\r') {\r\n      line[llen-1] = 0; // strip \\r character\r\n      llen--;\r\n    }\r\n    // ignore non-data lines...\r\n    if (data == 0) {\r\n      if (llen >= 5) {\r\n        data = 1;\r\n        if (line[0] != '@') data = 0;\r\n        else if (line[1] != 'd') data = 0;\r\n        else if (line[2] != 'a') data = 0;\r\n        else if (line[3] != 't') data = 0;\r\n        else if (line[4] != 'a') data = 0;\r\n      }\r\n      if (llen >= 10) {\r\n        int att = 1;\r\n        if (line[0] != '@') att = 0;\r\n        else if (line[1] != 'a') att = 0;\r\n        else if (line[2] != 't') att = 0;\r\n        else if (line[3] != 't') att = 0;\r\n        else if (line[4] != 'r') att = 0;\r\n        else if (line[5] != 'i') att = 0;\r\n        else if (line[6] != 'b') att = 0;\r\n        else if (line[7] != 'u') att = 0;\r\n        else if (line[8] != 't') att = 0;\r\n        else if (line[9] != 'e') att = 0;\r\n        if (att) Natt++;\r\n      }\r\n      nline = NULL;\r\n      fprintf(oarff,\"%s\\n\",line);\r\n    } else {\r\n      int vlen = (Natt-endft)-startft+1;\r\n      if ((mean == NULL)&&(argc > 5)) {\r\n        mean = vectorDoubleCreate(vlen);\r\n        stddev = vectorDoubleCreate(vlen);\r\n//  FILE *nd = fopen(\"normdata.dat\",\"rb\");\r\n        FILE *nd = fopen(argv[5],\"rb\");\r\n        if (nd != NULL) {\r\n          fread(mean->x, sizeof(double)*mean->dim, 1, nd);\r\n          fread(stddev->x, sizeof(double)*stddev->dim, 1, nd);\r\n          fclose(nd);  \r\n        } else {\r\n          fprintf(stderr,\"ERROR loading normdata\\n\");       \r\n        }\r\n      }\r\n\r\n\r\n      nline = line;\r\n      // remove spaces\r\n      while ((llen>0)&&(nline[0]==' ')) { nline++; llen--; }\r\n      while ((llen>0)&&(nline[llen-1]==' ')) { nline[llen-1]=0; llen--; }\r\n      // convert line to vecotr\r\n      char *el=NULL;\r\n      vectorDouble d = vectorDoubleCreate(vlen);\r\n      if (var == NULL) {\r\n        var = vectorDoubleCreate(vlen);\r\n      }\r\n      int fti=1;\r\n      char *oline0=NULL;\r\n      char *oline1=NULL;\r\n      char *oline0e=NULL;\r\n      char *oline1e=NULL;\r\n      if (llen > 0) {\r\n        do {\r\n          el=strchr(nline,',');\r\n          if (el!=NULL) \r\n            el[0] = 0;\r\n          if (fti>=startft)\r\n            if (fti<vlen+startft)\r\n              d->x[fti-startft] = atof(nline);\r\n            else {\r\n              if (oline0e != NULL) {\r\n                oline1e = myvprint(\"%s,%s\",oline0e,nline);\r\n                free(oline0e); oline0e=oline1e;\r\n              } else {\r\n                oline0e = strdup(nline);\r\n              }\r\n            }\r\n          else {\r\n            if (oline0 != NULL) {\r\n              oline1 = myvprint(\"%s,%s\",oline0,nline);\r\n              free(oline0); oline0=oline1;\r\n            } else {\r\n              oline0 = strdup(nline);\r\n            }\r\n\t  }\r\n          fti++;\r\n          if (el!=NULL) {\r\n            nline = el+1;\r\n          }\r\n        } while (el!=NULL);\r\n      if (fti-startft < vlen) { printf(\"warning: less elements on line than expected!!\\n\"); }\r\n      // add vector var to variance sum...\r\n//...\r\n      vectorDoubleSub(d,mean);\r\n      vectorDoubleElemSafeDiv(d,stddev);\r\n      // rebuild line and write to file...\r\n      int prev = 0;\r\n      if (oline0 != NULL) {\r\n        fprintf(oarff,\"%s\",oline0);\r\n        free(oline0);\r\n        prev = 1;\r\n      }\r\n      long i;\r\n      for (i=0; i<vlen; i++) {\r\n        if (prev)\r\n          fprintf(oarff,\",%f\",d->x[i]);\r\n        else\r\n          fprintf(oarff,\"%f\",d->x[i]);\r\n        prev = 1;\r\n      }\r\n      if (oline0e != NULL) {\r\n        if (prev) fprintf(oarff,\",\");\r\n        fprintf(oarff,\"%s\",oline0e);\r\n        free(oline0e);\r\n      }\r\n      fprintf(oarff,\"\\n\");\r\n\r\n/*\r\n\r\n      char *oline=strdup(oline0);\r\n      int i;\r\n      for (i=0; i<vlen; i++) {\r\n        char *tmp = myvprint(\"%s,%f\",oline,d->x[i]);\r\n        free(oline); oline=tmp;\r\n      }\r\n      char *tmp = myvprint(\"%s,%s\",oline,oline0e);\r\n      free(oline); oline=tmp;\r\n      fprintf(oarff,\"%s\\n\",oline);*/\r\n      //n++;\r\n      }\r\n    }\r\n    free(line); line=NULL;\r\n\r\n  }\r\n  fclose(oarff);\r\n  fclose(iarff);\r\n\r\n \r\n \r\n  vectorDoubleDestroy(mean);  // at the end...\r\n  vectorDoubleDestroy(stddev);  \r\n  vectorFloatDestroy(meanF);  // at the end...\r\n  vectorFloatDestroy(stddevF);  \r\n  \r\n  //printf(\"Hello World!\\n\");\r\n}\r\n\r\n\r\n"
  },
  {
    "path": "scripts/modeltrain/arffToLsvm.pl",
    "content": "#!/usr/bin/perl\n\n# convert an arff file to lSVM feature file format\n\n$input_arff = $ARGV[0];\n$output = $input_arff;\n$output =~ s/\\.arff$/.lsvm/;\nif ($ARGV[1]) { $output = $ARGV[1]; }\n$clsfile = $output;\n$clsfile =~ s/\\.lsvm$/.classes/;\n$discfile = $output;\n$discfile =~ s/\\.lsvm$/.disc/;\n\n$indata = 0;\nmy %cla=();\nmy $discrete = 0;\n\nopen(OUT,\">$output\");\nopen(FILE,\"<$input_arff\");\nwhile (<FILE>) {\n  my $line = $_; $line=~s/\\r?\\n$//;\n  if ($line =~ /^\\@data/) { \n    $indata = 1; \n#print \"LL: '$lastline'\\n\";\n    if ($lastline =~ /^\\@attribute\\s+([^\\s]+)\\s+(.+)$/) {\n      $at = $2;\n      if ($at =~ /numeric/i) {\n        # no conversion necessary\n        $discrete = 0;\n      } else {\n\t$discrete = 1;\n        $at =~ s/^\\s*[\\{\\\"]\\s*//;\n        $at =~ s/\\s*[\\}\\\"]\\s*$//;\n\t@cls = split(/\\s*,\\s*/,$at);\n\tfor ($i=0; $i<=$#cls; $i++) { $cla{$cls[$i]}  = \"$i\"; }\n#print \"here $at\\n\";\n      }\n\n    }\n  } else {\n \n  if (($indata)&&($line =~ /,/)) {\n    @els = split(/,/,$line);\n    $class = $els[$#els];\n#print \"class: $class\\n\";\n    if ($discrete == 1) {\n      print OUT $cla{$class}.\" \";\n#    print \"  $cla{$class}\\n\";\n    } else {\n      print OUT \"$class \";\n    }\n    for ($i=0; $i<$#els; $i++) {\n      $i1 = $i + 1;\n    #for ($i=2; $i<$#els; $i++) {\n    #  $i1 = $i - 1;\n      print OUT $i1.\":\".$els[$i].\" \";\n    }\n    print OUT \"\\n\";\n  }\n  unless ($indata) {\n    if ($line!~/^\\s*$/) {\n      if ($line=~/^\\@attribute /) {\n        $lastline = $line;\n      }\n    } \n  }\n\n  }\n}\nclose(FILE);\nclose(OUT);\nif ($discrete) {\n  open(FILE,\">$clsfile\");\n  for ($i=0; $i<=$#cls; $i++) { print FILE $i.\":\".$cls[$i].\"\\n\"; }\n  close(FILE);\n  open(FILE,\">$discfile\");\n  print FILE \"1\\n\";\n  close(FILE);\n} else {\n  open(FILE,\">$discfile\");\n  print FILE \"0\\n\";\n  close(FILE);\n}\n"
  },
  {
    "path": "scripts/modeltrain/buildmodel.pl",
    "content": "#!/usr/bin/perl\n\n# USAGE: buildmodel.pl <training lsvm file> [svm config file]\n\n$input_lsvm = $ARGV[0];\n$conf = $input_lsvm;\n$conf =~ s/\\.lsvm$/.config/;\n\n$scale = $input_lsvm; $scale=~s/\\.lsvm$/.scale/; \n$scaled_lsvm = $input_lsvm; $scaled_lsvm =~ s/\\.lsvm/.scaled.lsvm/;\n$model = $input_lsvm; $model=~s/\\.lsvm$/.model/;\n\nif ($^O =~ /win/i) {\n  $ext = \".exe\";\n} else {\n  $ext = \"\";\n}\n \n# scale features, build model\n\nunless (-e $scaled_lsvm) {\n  system(\"libsvm-small/svm-scale$ext -s $scale $input_lsvm > $scaled_lsvm\");\n}\n\n$discfile = $input_lsvm; $discfile=~s/\\.lsvm$/.disc/;\nopen(FILE,\"<$discfile\");\n$disc=<FILE>; $disc=~s/\\r?\\n$//;\nclose(FILE);\n\nif ($disc) { # classification if disc==1\n\nprint \"  building an SVM CLASSFICATION model...\\n\";\n#classification:\n## change LibSVM parameters here, if you want to use a different configuration:\n## See the LibSVM documentation for more information:\n\nif (-e $ARGV[1]) {\n  $svm_config = `cat $ARGV[1]`;\n  $svm_config =~ s/\\n//g;\n  $svm_config =~ s/\\r//g;\n} else {\n  $svm_config = \"-b 1 -s 0 -t 1 -d 1 -c 0.3\";\n}\n\n#system(\"libsvm-small/svm-train$ext -n 0.5 -b 1 -s 1 -t 1 -d 2 -c 0.7 $scaled_lsvm $model\");\n\n# Original:\nsystem(\"libsvm-small/svm-train$ext $svm_config $scaled_lsvm $model\");\n\n} else { # regression otherwise:\n\nprint \"  building an SVR REGRESSION model...\\n\";\nif (-e $ARGV[1]) {\n  $svm_config = `cat $ARGV[1]`;\n  $svm_config =~ s/\\n//g;\n  $svm_config =~ s/\\r//g;\n} else {\n  $svm_config = \"-s 3 -t 1 -d 1 -c 0.4\";\n}\n\n##### regression:\n## change LibSVM parameters here, if you want to use a different configuration:\n## See the LibSVM documentation for more information:\nsystem(\"svm-train$ext $svm_config $scaled_lsvm $model\");\n\n\n}\n\nopen(FILE,\">$conf\");\nprint FILE \"$svm_config\\n\";\nclose(FILE);\n\n"
  },
  {
    "path": "scripts/modeltrain/fsel.pl",
    "content": "#!/usr/bin/perl\n\n\n# load train.arff in weka and so CFS\n# convert resulting arff to openEAR feature selection file\n\n$input_arff = $ARGV[0];\n\n##### CHANGE THIS TO YOUR WEKA PATH\n$wekapath = \"\\$CLASSPATH:/home/don/eyb/inst/weka-3-5-6/weka.jar\";\n$wekacmd = \"java -Xmx2048m -classpath $wekapath \";  \n##############################################################\n\n# run weka...\nsub run_weka {\n  my $cmdline = $_[0];\n  \n  my $retval = system($wekacmd.\" \".$cmdline);\n  \n  if ($retval) {\n    print \"ERROR running Weka\\n\";\n    exit 1;\n  }\n  \n  return $retval;\n}\n\nrequire \"arff-functions.pl\";\n\nprint \"removing filename and timestamp fields from $input_arff ...\\n\";\n$stripped_arff = $input_arff.\".stripped.arff\";\n$fsel_tmp_arff = $input_arff.\".fsel.arff\";\n \nmy $hr = &load_arff($input_arff);\nmy $numattr = $#{$hr->{\"attributes\"}};\n    \n$hr->{\"attributes\"}[0]{\"selected\"} = 0;  # filename\n$hr->{\"attributes\"}[1]{\"selected\"} = 0;  # timestamp\n    \n&save_arff_AttrSelected($stripped_arff,$hr);\n\nprint \"Running WEKA CFS feature selection ...\\n\";   \n&run_weka(\"weka.filters.supervised.attribute.AttributeSelection -E \\\"weka.attributeSelection.CfsSubsetEval\\\" -S \\\"weka.attributeSelection.BestFirst -D 1 -N 5\\\" -i \\\"$stripped_arff\\\" -o \\\"$fsel_tmp_arff\\\" \");\n\n\n\nsystem(\"./arffToLsvm.pl $fsel_tmp_arff\");\n\n# convert arff:\n\n$outpArff=$fsel_tmp_arff;\n$feaTUMfselfile=$input_arff;\n$feaTUMfselfile=~ s/\\.arff/.fselection/;\n\n# count number of features first\n$nStr = 0;\nopen(FILE,\"<$outpArff\");\nwhile (<FILE>) {\n  my $line = $_; chop($line);\n  if ($line =~ /^\\@attribute (.+?) numeric/) {\n    $nStr++;  \n  }\n  if ($line =~ /^\\@data/) { last; }\n}\nclose(FILE);\n\nopen(OUT,\">$feaTUMfselfile\");\nprint OUT \"str\\n\";\nprint OUT \"$nStr\\n\";\nopen(FILE,\"<$outpArff\");\nwhile (<FILE>) {\n  my $line = $_; chop($line);\n  if ($line =~ /^\\@attribute (.+?) numeric/) {\n    $attr = $1;\n    print \"selecting: $attr \\n\";\n    print OUT \"$attr\\n\";\n  }\n  if ($line =~ /^\\@data/) { last; }\n}\nclose(FILE);\nclose(OUT);\n\n"
  },
  {
    "path": "scripts/modeltrain/libsvm-small/COPYRIGHT",
    "content": "\nCopyright (c) 2000-2009 Chih-Chung Chang and Chih-Jen Lin\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n\n1. Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright\nnotice, this list of conditions and the following disclaimer in the\ndocumentation and/or other materials provided with the distribution.\n\n3. Neither name of copyright holders nor the names of its contributors\nmay be used to endorse or promote products derived from this software\nwithout specific prior written permission.\n\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR\nCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\nEXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\nPROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\nPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
  },
  {
    "path": "scripts/modeltrain/libsvm-small/Makefile",
    "content": "CXX = g++\nCFLAGS = -Wall -static -Wconversion -O3 -fPIC\nSHVER = 1\n\nall: svm-train svm-predict svm-scale\n\nlib: svm.o\n\t$(CXX) -shared svm.o -o libsvm.so.$(SHVER)\n\nsvm-predict: svm-predict.c svm.o\n\t$(CXX) $(CFLAGS) svm-predict.c svm.o -o svm-predict -lm\nsvm-train: svm-train.c svm.o\n\t$(CXX) $(CFLAGS) svm-train.c svm.o -o svm-train -lm\nsvm-scale: svm-scale.c\n\t$(CXX) $(CFLAGS) svm-scale.c -o svm-scale\nsvm.o: svm.cpp svm.h\n\t$(CXX) $(CFLAGS) -c svm.cpp\nclean:\n\trm -f *~ svm.o svm-train svm-predict svm-scale\n"
  },
  {
    "path": "scripts/modeltrain/libsvm-small/Makefile.win",
    "content": "#You must ensure nmake.exe, cl.exe, link.exe are in system path.\n#VCVARS32.bat\n#Under dosbox prompt\n#nmake -f Makefile.win\n\nPYTHON_INC = c:\\python26\\include\nPYTHON_LIB = c:\\python26\\libs\\python26.lib\n##########################################\nCXX = cl.exe\nCFLAGS = -nologo -O2 -EHsc -I. -D __WIN32__ -D _CRT_SECURE_NO_DEPRECATE\nTARGET = windows\n\nall: $(TARGET)\\svm-train.exe $(TARGET)\\svm-predict.exe $(TARGET)\\svm-scale.exe $(TARGET)\\svm-toy.exe\n\npython: $(TARGET)\\python\\svmc.pyd\n\n$(TARGET)\\svm-predict.exe: svm.h svm-predict.c svm.obj\n    $(CXX) $(CFLAGS) svm-predict.c svm.obj -Fe$(TARGET)\\svm-predict.exe\n\n$(TARGET)\\svm-train.exe: svm.h svm-train.c svm.obj\n    $(CXX) $(CFLAGS) svm-train.c svm.obj -Fe$(TARGET)\\svm-train.exe\n\n$(TARGET)\\svm-scale.exe: svm.h svm-scale.c\n    $(CXX) $(CFLAGS) svm-scale.c -Fe$(TARGET)\\svm-scale.exe\n\n$(TARGET)\\svm-toy.exe: svm.h svm.obj svm-toy\\windows\\svm-toy.cpp\n\t$(CXX) $(CFLAGS) svm-toy\\windows\\svm-toy.cpp svm.obj user32.lib gdi32.lib comdlg32.lib  -Fe$(TARGET)\\svm-toy.exe\n\nsvm.obj: svm.cpp svm.h\n    $(CXX) $(CFLAGS) -c svm.cpp\n\n$(TARGET)\\python\\svmc.pyd: python\\svmc_wrap.c svm.obj $(PYTHON_LIB)\n    $(CXX) $(CFLAGS) -I$(PYTHON_INC) -LD $** -Fe$(TARGET)\\python\\svmc.pyd\n# $** means all dependencies\n\nclean:\n    -erase /Q *.obj $(TARGET)\\. $(TARGET)\\python\\. \n\n\n"
  },
  {
    "path": "scripts/modeltrain/libsvm-small/README",
    "content": "Libsvm is a simple, easy-to-use, and efficient software for SVM\nclassification and regression. It solves C-SVM classification, nu-SVM\nclassification, one-class-SVM, epsilon-SVM regression, and nu-SVM\nregression. It also provides an automatic model selection tool for\nC-SVM classification. This document explains the use of libsvm.\n\nLibsvm is available at \nhttp://www.csie.ntu.edu.tw/~cjlin/libsvm\nPlease read the COPYRIGHT file before using libsvm.\n\nTable of Contents\n=================\n\n- Quick Start\n- Installation and Data Format\n- `svm-train' Usage\n- `svm-predict' Usage\n- `svm-scale' Usage\n- Tips on Practical Use\n- Examples\n- Precomputed Kernels \n- Library Usage\n- Java Version\n- Building Windows Binaries\n- Additional Tools: Sub-sampling, Parameter Selection, Format checking, etc.\n- Python Interface\n- Additional Information\n\nQuick Start\n===========\n\nIf you are new to SVM and if the data is not large, please go to \n`tools' directory and use easy.py after installation. It does \neverything automatic -- from data scaling to parameter selection.\n\nUsage: easy.py training_file [testing_file]\n\nMore information about parameter selection can be found in\n`tools/README.'\n\nInstallation and Data Format\n============================\n\nOn Unix systems, type `make' to build the `svm-train' and `svm-predict'\nprograms. Run them without arguments to show the usages of them.\n\nOn other systems, consult `Makefile' to build them (e.g., see\n'Building Windows binaries' in this file) or use the pre-built\nbinaries (Windows binaries are in the directory `windows').\n\nThe format of training and testing data file is:\n\n<label> <index1>:<value1> <index2>:<value2> ...\n.\n.\n.\n\nEach line contains an instance and is ended by a '\\n' character.  For\nclassification, <label> is an integer indicating the class label\n(multi-class is supported). For regression, <label> is the target\nvalue which can be any real number. For one-class SVM, it's not used\nso can be any number.  Except using precomputed kernels (explained in\nanother section), <index>:<value> gives a feature (attribute) value.\n<index> is an integer starting from 1 and <value> is a real\nnumber. Indices must be in ASCENDING order. Labels in the testing\nfile are only used to calculate accuracy or errors. If they are\nunknown, just fill the first column with any numbers.\n\nA sample classification data included in this package is\n`heart_scale'. To check if your data is in a correct form, use\n`tools/checkdata.py' (details in `tools/README').\n\nType `svm-train heart_scale', and the program will read the training\ndata and output the model file `heart_scale.model'. If you have a test\nset called heart_scale.t, then type `svm-predict heart_scale.t\nheart_scale.model output' to see the prediction accuracy. The `output'\nfile contains the predicted class labels.\n\nThere are some other useful programs in this package.\n\nsvm-scale:\n\n\tThis is a tool for scaling input data file.\n\nsvm-toy:\n\n\tThis is a simple graphical interface which shows how SVM\n\tseparate data in a plane. You can click in the window to \n\tdraw data points. Use \"change\" button to choose class \n\t1, 2 or 3 (i.e., up to three classes are supported), \"load\"\n\tbutton to load data from a file, \"save\" button to save data to\n\ta file, \"run\" button to obtain an SVM model, and \"clear\"\n\tbutton to clear the window.\n\n\tYou can enter options in the bottom of the window, the syntax of\n\toptions is the same as `svm-train'.\n\n\tNote that \"load\" and \"save\" consider data in the\n\tclassification but not the regression case. Each data point\n\thas one label (the color) which must be 1, 2, or 3 and two\n\tattributes (x-axis and y-axis values) in [0,1].\n\n\tType `make' in respective directories to build them.\n\n\tYou need Qt library to build the Qt version.\n\t(available from http://www.trolltech.com)\n\n\tYou need GTK+ library to build the GTK version.\n\t(available from http://www.gtk.org)\n\t\n\tThe pre-built Windows binaries are in the `windows'\n\tdirectory. We use Visual C++ on a 32-bit machine, so the\n\tmaximal cache size is 2GB.\n\n`svm-train' Usage\n=================\n\nUsage: svm-train [options] training_set_file [model_file]\noptions:\n-s svm_type : set type of SVM (default 0)\n\t0 -- C-SVC\n\t1 -- nu-SVC\n\t2 -- one-class SVM\n\t3 -- epsilon-SVR\n\t4 -- nu-SVR\n-t kernel_type : set type of kernel function (default 2)\n\t0 -- linear: u'*v\n\t1 -- polynomial: (gamma*u'*v + coef0)^degree\n\t2 -- radial basis function: exp(-gamma*|u-v|^2)\n\t3 -- sigmoid: tanh(gamma*u'*v + coef0)\n\t4 -- precomputed kernel (kernel values in training_set_file)\n-d degree : set degree in kernel function (default 3)\n-g gamma : set gamma in kernel function (default 1/k)\n-r coef0 : set coef0 in kernel function (default 0)\n-c cost : set the parameter C of C-SVC, epsilon-SVR, and nu-SVR (default 1)\n-n nu : set the parameter nu of nu-SVC, one-class SVM, and nu-SVR (default 0.5)\n-p epsilon : set the epsilon in loss function of epsilon-SVR (default 0.1)\n-m cachesize : set cache memory size in MB (default 100)\n-e epsilon : set tolerance of termination criterion (default 0.001)\n-h shrinking : whether to use the shrinking heuristics, 0 or 1 (default 1)\n-b probability_estimates : whether to train a SVC or SVR model for probability estimates, 0 or 1 (default 0)\n-wi weight : set the parameter C of class i to weight*C, for C-SVC (default 1)\n-v n: n-fold cross validation mode\n-q : quiet mode (no outputs)\n\n\nThe k in the -g option means the number of attributes in the input data.\n\noption -v randomly splits the data into n parts and calculates cross\nvalidation accuracy/mean squared error on them.\n\nSee libsvm FAQ for the meaning of outputs.\n\n`svm-predict' Usage\n===================\n\nUsage: svm-predict [options] test_file model_file output_file\noptions:\n-b probability_estimates: whether to predict probability estimates, 0 or 1 (default 0); for one-class SVM only 0 is supported\n\nmodel_file is the model file generated by svm-train.\ntest_file is the test data you want to predict.\nsvm-predict will produce output in the output_file.\n\n`svm-scale' Usage\n=================\n\nUsage: svm-scale [options] data_filename\noptions:\n-l lower : x scaling lower limit (default -1)\n-u upper : x scaling upper limit (default +1)\n-y y_lower y_upper : y scaling limits (default: no y scaling)\n-s save_filename : save scaling parameters to save_filename\n-r restore_filename : restore scaling parameters from restore_filename\n\nSee 'Examples' in this file for examples.\n\nTips on Practical Use\n=====================\n\n* Scale your data. For example, scale each attribute to [0,1] or [-1,+1].\n* For C-SVC, consider using the model selection tool in the tools directory.\n* nu in nu-SVC/one-class-SVM/nu-SVR approximates the fraction of training\n  errors and support vectors.\n* If data for classification are unbalanced (e.g. many positive and\n  few negative), try different penalty parameters C by -wi (see\n  examples below).\n* Specify larger cache size (i.e., larger -m) for huge problems.\n\nExamples\n========\n\n> svm-scale -l -1 -u 1 -s range train > train.scale\n> svm-scale -r range test > test.scale\n\nScale each feature of the training data to be in [-1,1]. Scaling\nfactors are stored in the file range and then used for scaling the\ntest data.\n\n> svm-train -s 0 -c 5 -t 2 -g 0.5 -e 0.1 data_file \n\nTrain a classifier with RBF kernel exp(-0.5|u-v|^2), C=10, and\nstopping tolerance 0.1.\n\n> svm-train -s 3 -p 0.1 -t 0 data_file\n\nSolve SVM regression with linear kernel u'v and epsilon=0.1\nin the loss function.\n\n> svm-train -c 10 -w1 1 -w-1 5 data_file\n\nTrain a classifier with penalty 10 = 1 * 10 for class 1 and penalty 50\n= 5 * 50 for class -1.\n\n> svm-train -s 0 -c 100 -g 0.1 -v 5 data_file\n\nDo five-fold cross validation for the classifier using\nthe parameters C = 100 and gamma = 0.1\n\n> svm-train -s 0 -b 1 data_file\n> svm-predict -b 1 test_file data_file.model output_file\n\nObtain a model with probability information and predict test data with\nprobability estimates\n\nPrecomputed Kernels \n===================\n\nUsers may precompute kernel values and input them as training and\ntesting files.  Then libsvm does not need the original\ntraining/testing sets.\n\nAssume there are L training instances x1, ..., xL and. \nLet K(x, y) be the kernel\nvalue of two instances x and y. The input formats\nare:\n\nNew training instance for xi:\n\n<label> 0:i 1:K(xi,x1) ... L:K(xi,xL) \n\nNew testing instance for any x:\n\n<label> 0:? 1:K(x,x1) ... L:K(x,xL) \n\nThat is, in the training file the first column must be the \"ID\" of\nxi. In testing, ? can be any value.\n\nAll kernel values including ZEROs must be explicitly provided.  Any\npermutation or random subsets of the training/testing files are also\nvalid (see examples below).\n\nNote: the format is slightly different from the precomputed kernel\npackage released in libsvmtools earlier.\n\nExamples:\n\n\tAssume the original training data has three four-feature\n\tinstances and testing data has one instance:\n\n\t15  1:1 2:1 3:1 4:1\n\t45      2:3     4:3\n\t25          3:1\n\n\t15  1:1     3:1\n\n\tIf the linear kernel is used, we have the following new\n\ttraining/testing sets:\n\n\t15  0:1 1:4 2:6  3:1\n\t45  0:2 1:6 2:18 3:0 \n\t25  0:3 1:1 2:0  3:1\n \n\t15  0:? 1:2 2:0  3:1\n\n\t? can be any value.\n\n\tAny subset of the above training file is also valid. For example,\n\n\t25  0:3 1:1 2:0  3:1\n\t45  0:2 1:6 2:18 3:0 \n\n\timplies that the kernel matrix is\n\n\t\t[K(2,2) K(2,3)] = [18 0]\n\t\t[K(3,2) K(3,3)] = [0  1]\n\nLibrary Usage\n=============\n\nThese functions and structures are declared in the header file\n`svm.h'.  You need to #include \"svm.h\" in your C/C++ source files and\nlink your program with `svm.cpp'. You can see `svm-train.c' and\n`svm-predict.c' for examples showing how to use them. We define\nLIBSVM_VERSION and declare `extern int libsvm_version; ' in svm.h, so\nyou can check the version number.\n\nBefore you classify test data, you need to construct an SVM model\n(`svm_model') using training data. A model can also be saved in\na file for later use. Once an SVM model is available, you can use it\nto classify new data.\n\n- Function: struct svm_model *svm_train(const struct svm_problem *prob,\n\t\t\t\t\tconst struct svm_parameter *param);\n\n    This function constructs and returns an SVM model according to\n    the given training data and parameters.\n\n    struct svm_problem describes the problem:\n\t\n\tstruct svm_problem\n\t{\n\t\tint l;\n\t\tdouble *y;\n\t\tstruct svm_node **x;\n\t};\n \n    where `l' is the number of training data, and `y' is an array containing\n    their target values. (integers in classification, real numbers in\n    regression) `x' is an array of pointers, each of which points to a sparse\n    representation (array of svm_node) of one training vector. \n\n    For example, if we have the following training data:\n\n    LABEL\tATTR1\tATTR2\tATTR3\tATTR4\tATTR5\n    -----\t-----\t-----\t-----\t-----\t-----\n      1\t\t  0\t  0.1\t  0.2\t  0\t  0\n      2\t\t  0\t  0.1\t  0.3\t -1.2\t  0\n      1\t\t  0.4\t  0\t  0\t  0\t  0\n      2\t\t  0\t  0.1\t  0\t  1.4\t  0.5\n      3\t\t -0.1\t -0.2\t  0.1\t  1.1\t  0.1\n\n    then the components of svm_problem are:\n\n    l = 5\n\n    y -> 1 2 1 2 3\n\n    x -> [ ] -> (2,0.1) (3,0.2) (-1,?)\n\t [ ] -> (2,0.1) (3,0.3) (4,-1.2) (-1,?)\n\t [ ] -> (1,0.4) (-1,?)\n\t [ ] -> (2,0.1) (4,1.4) (5,0.5) (-1,?)\n\t [ ] -> (1,-0.1) (2,-0.2) (3,0.1) (4,1.1) (5,0.1) (-1,?)\n\n    where (index,value) is stored in the structure `svm_node':\n\n\tstruct svm_node\n\t{\n\t\tint index;\n\t\tdouble value;\n\t};\n\n    index = -1 indicates the end of one vector. Note that indices must\n    be in ASCENDING order.\n \n    struct svm_parameter describes the parameters of an SVM model:\n\n\tstruct svm_parameter\n\t{\n\t\tint svm_type;\n\t\tint kernel_type;\n\t\tint degree;\t/* for poly */\n\t\tdouble gamma;\t/* for poly/rbf/sigmoid */\n\t\tdouble coef0;\t/* for poly/sigmoid */\n\n\t\t/* these are for training only */\n\t\tdouble cache_size; /* in MB */\n\t\tdouble eps;\t/* stopping criteria */\n\t\tdouble C;\t/* for C_SVC, EPSILON_SVR, and NU_SVR */\n\t\tint nr_weight;\t\t/* for C_SVC */\n\t\tint *weight_label;\t/* for C_SVC */\n\t\tdouble* weight;\t\t/* for C_SVC */\n\t\tdouble nu;\t/* for NU_SVC, ONE_CLASS, and NU_SVR */\n\t\tdouble p;\t/* for EPSILON_SVR */\n\t\tint shrinking;\t/* use the shrinking heuristics */\n\t\tint probability; /* do probability estimates */\n\t};\n\n    svm_type can be one of C_SVC, NU_SVC, ONE_CLASS, EPSILON_SVR, NU_SVR.\n\n    C_SVC:\t\tC-SVM classification\n    NU_SVC:\t\tnu-SVM classification\n    ONE_CLASS:\t\tone-class-SVM\n    EPSILON_SVR:\tepsilon-SVM regression\n    NU_SVR:\t\tnu-SVM regression\n\n    kernel_type can be one of LINEAR, POLY, RBF, SIGMOID.\n\n    LINEAR:\tu'*v\n    POLY:\t(gamma*u'*v + coef0)^degree\n    RBF:\texp(-gamma*|u-v|^2)\n    SIGMOID:\ttanh(gamma*u'*v + coef0)\n    PRECOMPUTED: kernel values in training_set_file\n\n    cache_size is the size of the kernel cache, specified in megabytes.\n    C is the cost of constraints violation. \n    eps is the stopping criterion. (we usually use 0.00001 in nu-SVC,\n    0.001 in others). nu is the parameter in nu-SVM, nu-SVR, and\n    one-class-SVM. p is the epsilon in epsilon-insensitive loss function\n    of epsilon-SVM regression. shrinking = 1 means shrinking is conducted;\n    = 0 otherwise. probability = 1 means model with probability\n    information is obtained; = 0 otherwise.\n\n    nr_weight, weight_label, and weight are used to change the penalty\n    for some classes (If the weight for a class is not changed, it is\n    set to 1). This is useful for training classifier using unbalanced\n    input data or with asymmetric misclassification cost.\n\n    nr_weight is the number of elements in the array weight_label and\n    weight. Each weight[i] corresponds to weight_label[i], meaning that\n    the penalty of class weight_label[i] is scaled by a factor of weight[i].\n    \n    If you do not want to change penalty for any of the classes,\n    just set nr_weight to 0.\n\n    *NOTE* Because svm_model contains pointers to svm_problem, you can\n    not free the memory used by svm_problem if you are still using the\n    svm_model produced by svm_train(). \n\n    *NOTE* To avoid wrong parameters, svm_check_parameter() should be\n    called before svm_train().\n\n- Function: double svm_predict(const struct svm_model *model,\n                               const struct svm_node *x);\n\n    This function does classification or regression on a test vector x\n    given a model.\n\n    For a classification model, the predicted class for x is returned.\n    For a regression model, the function value of x calculated using\n    the model is returned. For an one-class model, +1 or -1 is\n    returned.\n\n- Function: void svm_cross_validation(const struct svm_problem *prob,\n\tconst struct svm_parameter *param, int nr_fold, double *target);\n\n    This function conducts cross validation. Data are separated to\n    nr_fold folds. Under given parameters, sequentially each fold is\n    validated using the model from training the remaining. Predicted\n    labels (of all prob's instances) in the validation process are\n    stored in the array called target.\n\n    The format of svm_prob is same as that for svm_train(). \n\n- Function: int svm_get_svm_type(const struct svm_model *model);\n\n    This function gives svm_type of the model. Possible values of\n    svm_type are defined in svm.h.\n\n- Function: int svm_get_nr_class(const svm_model *model);\n\n    For a classification model, this function gives the number of\n    classes. For a regression or an one-class model, 2 is returned.\n\n- Function: void svm_get_labels(const svm_model *model, int* label)\n    \n    For a classification model, this function outputs the name of\n    labels into an array called label. For regression and one-class\n    models, label is unchanged.\n\n- Function: double svm_get_svr_probability(const struct svm_model *model);\n\n    For a regression model with probability information, this function\n    outputs a value sigma > 0. For test data, we consider the\n    probability model: target value = predicted value + z, z: Laplace\n    distribution e^(-|z|/sigma)/(2sigma)\n\n    If the model is not for svr or does not contain required\n    information, 0 is returned.\n\n- Function: void svm_predict_values(const svm_model *model, \n\t\t\t\t    const svm_node *x, double* dec_values)\n\n    This function gives decision values on a test vector x given a\n    model.\n\n    For a classification model with nr_class classes, this function\n    gives nr_class*(nr_class-1)/2 decision values in the array\n    dec_values, where nr_class can be obtained from the function\n    svm_get_nr_class. The order is label[0] vs. label[1], ...,\n    label[0] vs. label[nr_class-1], label[1] vs. label[2], ...,\n    label[nr_class-2] vs. label[nr_class-1], where label can be\n    obtained from the function svm_get_labels.\n\n    For a regression model, label[0] is the function value of x\n    calculated using the model. For one-class model, label[0] is +1 or\n    -1.\n\n- Function: double svm_predict_probability(const struct svm_model *model, \n\t    const struct svm_node *x, double* prob_estimates);\n    \n    This function does classification or regression on a test vector x\n    given a model with probability information.\n\n    For a classification model with probability information, this\n    function gives nr_class probability estimates in the array\n    prob_estimates. nr_class can be obtained from the function\n    svm_get_nr_class. The class with the highest probability is\n    returned. For regression/one-class SVM, the array prob_estimates\n    is unchanged and the returned value is the same as that of\n    svm_predict.\n\n- Function: const char *svm_check_parameter(const struct svm_problem *prob,\n                                            const struct svm_parameter *param);\n\n    This function checks whether the parameters are within the feasible\n    range of the problem. This function should be called before calling\n    svm_train() and svm_cross_validation(). It returns NULL if the\n    parameters are feasible, otherwise an error message is returned.\n\n- Function: int svm_check_probability_model(const struct svm_model *model);\n\n    This function checks whether the model contains required\n    information to do probability estimates. If so, it returns\n    +1. Otherwise, 0 is returned. This function should be called\n    before calling svm_get_svr_probability and\n    svm_predict_probability.\n\n- Function: int svm_save_model(const char *model_file_name,\n\t\t\t       const struct svm_model *model);\n\n    This function saves a model to a file; returns 0 on success, or -1\n    if an error occurs.\n\n- Function: struct svm_model *svm_load_model(const char *model_file_name);\n\n    This function returns a pointer to the model read from the file,\n    or a null pointer if the model could not be loaded.\n\n- Function: void svm_destroy_model(struct svm_model *model);\n\n    This function frees the memory used by a model.\n\n- Function: void svm_destroy_param(struct svm_parameter *param);\n\n    This function frees the memory used by a parameter set.\n\n- Variable: extern void (*svm_print_string) (const char *);\n\n    Users can specify their output format by\n\tsvm_print_string = &your_print_function;\n\nJava Version\n============\n\nThe pre-compiled java class archive `libsvm.jar' and its source files are\nin the java directory. To run the programs, use\n\njava -classpath libsvm.jar svm_train <arguments>\njava -classpath libsvm.jar svm_predict <arguments>\njava -classpath libsvm.jar svm_toy\njava -classpath libsvm.jar svm_scale <arguments>\n\nNote that you need Java 1.5 (5.0) or above to run it.\n\nYou may need to add Java runtime library (like classes.zip) to the classpath.\nYou may need to increase maximum Java heap size.\n\nLibrary usages are similar to the C version. These functions are available:\n\npublic class svm {\n\tpublic static final int LIBSVM_VERSION=289; \n\tpublic static svm_print_interface svm_print_string;\n\tpublic static svm_model svm_train(svm_problem prob, svm_parameter param);\n\tpublic static void svm_cross_validation(svm_problem prob, svm_parameter param, int nr_fold, double[] target);\n\tpublic static int svm_get_svm_type(svm_model model);\n\tpublic static int svm_get_nr_class(svm_model model);\n\tpublic static void svm_get_labels(svm_model model, int[] label);\n\tpublic static double svm_get_svr_probability(svm_model model);\n\tpublic static void svm_predict_values(svm_model model, svm_node[] x, double[] dec_values);\n\tpublic static double svm_predict(svm_model model, svm_node[] x);\n\tpublic static double svm_predict_probability(svm_model model, svm_node[] x, double[] prob_estimates);\n\tpublic static void svm_save_model(String model_file_name, svm_model model) throws IOException\n\tpublic static svm_model svm_load_model(String model_file_name) throws IOException\n\tpublic static String svm_check_parameter(svm_problem prob, svm_parameter param);\n\tpublic static int svm_check_probability_model(svm_model model);\n}\n\nThe library is in the \"libsvm\" package.\nNote that in Java version, svm_node[] is not ended with a node whose index = -1.\n\nUsers can specify their output format by\n\n\tsvm.svm_print_string = new svm_print_interface()\n\t{ \n\t\tpublic void print(String s)\n\t\t{\n\t\t\t// your own format\n\t\t}\n\t};\n\nBuilding Windows Binaries\n=========================\n\nWindows binaries are in the directory `windows'. To build them via\nVisual C++, use the following steps:\n\n1. Open a DOS command box (or Visual Studio Command Prompt) and change\nto libsvm directory. If environment variables of VC++ have not been\nset, type\n\n\"C:\\Program Files\\Microsoft Visual Studio 8\\VC\\bin\\vcvars32.bat\"\n\nYou may have to modify the above according which version of VC++ or\nwhere it is installed.\n\n2. Type\n\nnmake -f Makefile.win clean all\n\n3. (optional) To build python interface, download and install Python.\nEdit Makefile.win and change PYTHON_INC and PYTHON_LIB to your python\ninstallation. Type\n\nnmake -f Makefile.win python \n\nand then copy windows\\python\\svmc.pyd to the python directory.\n\nAnother way is to build them from Visual C++ environment. See details\nin libsvm FAQ.\n\n- Additional Tools: Sub-sampling, Parameter Selection, Format checking, etc.\n============================================================================\n\nSee the README file in the tools directory.\n\nPython Interface\n================\n\nSee the README file in python directory.\n\nAdditional Information\n======================\n\nIf you find LIBSVM helpful, please cite it as\n\nChih-Chung Chang and Chih-Jen Lin, LIBSVM: a library for \nsupport vector machines, 2001.\nSoftware available at http://www.csie.ntu.edu.tw/~cjlin/libsvm\n\nLIBSVM implementation document is available at\nhttp://www.csie.ntu.edu.tw/~cjlin/papers/libsvm.pdf\n\nFor any questions and comments, please email cjlin@csie.ntu.edu.tw\n\nAcknowledgments:\nThis work was supported in part by the National Science \nCouncil of Taiwan via the grant NSC 89-2213-E-002-013.\nThe authors thank their group members and users\nfor many helpful discussions and comments. They are listed in\nhttp://www.csie.ntu.edu.tw/~cjlin/libsvm/acknowledgements\n\n"
  },
  {
    "path": "scripts/modeltrain/libsvm-small/svm-predict.c",
    "content": "#include <stdio.h>\n#include <ctype.h>\n#include <stdlib.h>\n#include <string.h>\n#include <errno.h>\n#include \"svm.h\"\n\nstruct svm_node *x;\nint max_nr_attr = 64;\n\nstruct svm_model* model;\nint predict_probability=0;\n\nstatic char *line = NULL;\nstatic int max_line_len;\n\nstatic char* readline(FILE *input)\n{\n\tint len;\n\t\n\tif(fgets(line,max_line_len,input) == NULL)\n\t\treturn NULL;\n\n\twhile(strrchr(line,'\\n') == NULL)\n\t{\n\t\tmax_line_len *= 2;\n\t\tline = (char *) realloc(line,max_line_len);\n\t\tlen = (int) strlen(line);\n\t\tif(fgets(line+len,max_line_len-len,input) == NULL)\n\t\t\tbreak;\n\t}\n\treturn line;\n}\n\nvoid exit_input_error(int line_num)\n{\n\tfprintf(stderr,\"Wrong input format at line %d\\n\", line_num);\n\texit(1);\n}\n\nvoid liblinear_predict(FILE *input, FILE *output)\n{\n\tint correct = 0;\n\tint total = 0;\n\tdouble error = 0;\n\tdouble sump = 0, sumt = 0, sumpp = 0, sumtt = 0, sumpt = 0;\n\n\tint svm_type=svm_get_svm_type(model);\n\tint nr_class=svm_get_nr_class(model);\n\tdouble *prob_estimates=NULL;\n\tint j;\n\n\tif(predict_probability)\n\t{\n\t\tif (svm_type==NU_SVR || svm_type==EPSILON_SVR)\n\t\t\tprintf(\"Prob. model for test data: target value = predicted value + z,\\nz: Laplace distribution e^(-|z|/sigma)/(2sigma),sigma=%g\\n\",svm_get_svr_probability(model));\n\t\telse\n\t\t{\n\t\t\tint *labels=(int *) malloc(nr_class*sizeof(int));\n\t\t\tsvm_get_labels(model,labels);\n\t\t\tprob_estimates = (double *) malloc(nr_class*sizeof(double));\n\t\t\tfprintf(output,\"labels\");\t\t\n\t\t\tfor(j=0;j<nr_class;j++)\n\t\t\t\tfprintf(output,\" %d\",labels[j]);\n\t\t\tfprintf(output,\"\\n\");\n\t\t\tfree(labels);\n\t\t}\n\t}\n\n\tmax_line_len = 1024;\n\tline = (char *)malloc(max_line_len*sizeof(char));\n\twhile(readline(input) != NULL)\n\t{\n\t\tint i = 0;\n\t\tdouble target_label, predict_label;\n\t\tchar *idx, *val, *label, *endptr;\n\t\tint inst_max_index = -1; // strtol gives 0 if wrong format, and precomputed kernel has <index> start from 0\n\n\t\tlabel = strtok(line,\" \\t\");\n\t\ttarget_label = strtod(label,&endptr);\n\t\tif(endptr == label)\n\t\t\texit_input_error(total+1);\n\n\t\twhile(1)\n\t\t{\n\t\t\tif(i>=max_nr_attr-1)\t// need one more for index = -1\n\t\t\t{\n\t\t\t\tmax_nr_attr *= 2;\n\t\t\t\tx = (struct svm_node *) realloc(x,max_nr_attr*sizeof(struct svm_node));\n\t\t\t}\n\n\t\t\tidx = strtok(NULL,\":\");\n\t\t\tval = strtok(NULL,\" \\t\");\n\n\t\t\tif(val == NULL)\n\t\t\t\tbreak;\n\t\t\terrno = 0;\n\t\t\tx[i].index = (int) strtol(idx,&endptr,10);\n\t\t\tif(endptr == idx || errno != 0 || *endptr != '\\0' || x[i].index <= inst_max_index)\n\t\t\t\texit_input_error(total+1);\n\t\t\telse\n\t\t\t\tinst_max_index = x[i].index;\n\n\t\t\terrno = 0;\n\t\t\tx[i].value = strtod(val,&endptr);\n\t\t\tif(endptr == val || errno != 0 || (*endptr != '\\0' && !isspace(*endptr)))\n\t\t\t\texit_input_error(total+1);\n\n\t\t\t++i;\n\t\t}\n\t\tx[i].index = -1;\n\n\t\tif (predict_probability && (svm_type==C_SVC || svm_type==NU_SVC))\n\t\t{\n\t\t\tpredict_label = svm_predict_probability(model,x,prob_estimates);\n\t\t\tfprintf(output,\"%g\",predict_label);\n\t\t\tfor(j=0;j<nr_class;j++)\n\t\t\t\tfprintf(output,\" %g\",prob_estimates[j]);\n\t\t\tfprintf(output,\"\\n\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tpredict_label = svm_predict(model,x);\n\t\t\tfprintf(output,\"%g\\n\",predict_label);\n\t\t}\n\n\t\tif(predict_label == target_label)\n\t\t\t++correct;\n\t\terror += (predict_label-target_label)*(predict_label-target_label);\n\t\tsump += predict_label;\n\t\tsumt += target_label;\n\t\tsumpp += predict_label*predict_label;\n\t\tsumtt += target_label*target_label;\n\t\tsumpt += predict_label*target_label;\n\t\t++total;\n\t}\n\tif (svm_type==NU_SVR || svm_type==EPSILON_SVR)\n\t{\n\t\tprintf(\"Mean squared error = %g (regression)\\n\",error/total);\n\t\tprintf(\"Squared correlation coefficient = %g (regression)\\n\",\n\t\t       ((total*sumpt-sump*sumt)*(total*sumpt-sump*sumt))/\n\t\t       ((total*sumpp-sump*sump)*(total*sumtt-sumt*sumt))\n\t\t       );\n\t}\n\telse\n\t\tprintf(\"Accuracy = %g%% (%d/%d) (classification)\\n\",\n\t\t       (double)correct/total*100,correct,total);\n\tif(predict_probability)\n\t\tfree(prob_estimates);\n}\n\nvoid exit_with_help()\n{\n\tprintf(\n\t\"Usage: svm-predict [options] test_file model_file output_file\\n\"\n\t\"options:\\n\"\n\t\"-b probability_estimates: whether to predict probability estimates, 0 or 1 (default 0); for one-class SVM only 0 is supported\\n\"\n\t);\n\texit(1);\n}\n\nint main(int argc, char **argv)\n{\n\tFILE *input, *output;\n\tint i;\n\n\t// parse options\n\tfor(i=1;i<argc;i++)\n\t{\n\t\tif(argv[i][0] != '-') break;\n\t\t++i;\n\t\tswitch(argv[i-1][1])\n\t\t{\n\t\t\tcase 'b':\n\t\t\t\tpredict_probability = atoi(argv[i]);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tfprintf(stderr,\"Unknown option: -%c\\n\", argv[i-1][1]);\n\t\t\t\texit_with_help();\n\t\t}\n\t}\n\tif(i>=argc-2)\n\t\texit_with_help();\n\t\n\tinput = fopen(argv[i],\"r\");\n\tif(input == NULL)\n\t{\n\t\tfprintf(stderr,\"can't open input file %s\\n\",argv[i]);\n\t\texit(1);\n\t}\n\n\toutput = fopen(argv[i+2],\"w\");\n\tif(output == NULL)\n\t{\n\t\tfprintf(stderr,\"can't open output file %s\\n\",argv[i+2]);\n\t\texit(1);\n\t}\n\n\tif((model=svm_load_model(argv[i+1]))==0)\n\t{\n\t\tfprintf(stderr,\"can't open model file %s\\n\",argv[i+1]);\n\t\texit(1);\n\t}\n\n\tx = (struct svm_node *) malloc(max_nr_attr*sizeof(struct svm_node));\n\tif(predict_probability)\n\t{\n\t\tif(svm_check_probability_model(model)==0)\n\t\t{\n\t\t\tfprintf(stderr,\"Model does not support probabiliy estimates\\n\");\n\t\t\texit(1);\n\t\t}\n\t}\n\telse\n\t{\n\t\tif(svm_check_probability_model(model)!=0)\n\t\t\tprintf(\"Model supports probability estimates, but disabled in prediction.\\n\");\n\t}\n\tliblinear_predict(input,output);\n\tsvm_destroy_model(model);\n\tfree(x);\n\tfree(line);\n\tfclose(input);\n\tfclose(output);\n\treturn 0;\n}\n"
  },
  {
    "path": "scripts/modeltrain/libsvm-small/svm-scale.c",
    "content": "#include <float.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <ctype.h>\n#include <string.h>\n\nvoid exit_with_help()\n{\n\tprintf(\n\t\"Usage: svm-scale [options] data_filename\\n\"\n\t\"options:\\n\"\n\t\"-l lower : x scaling lower limit (default -1)\\n\"\n\t\"-u upper : x scaling upper limit (default +1)\\n\"\n\t\"-y y_lower y_upper : y scaling limits (default: no y scaling)\\n\"\n\t\"-s save_filename : save scaling parameters to save_filename\\n\"\n\t\"-r restore_filename : restore scaling parameters from restore_filename\\n\"\n\t);\n\texit(1);\n}\n\nchar *line = NULL;\nint max_line_len = 1024;\ndouble lower=-1.0,upper=1.0,y_lower,y_upper;\nint y_scaling = 0;\ndouble *feature_max;\ndouble *feature_min;\ndouble y_max = -DBL_MAX;\ndouble y_min = DBL_MAX;\nint max_index;\nlong int num_nonzeros = 0;\nlong int new_num_nonzeros = 0;\n\n#define max(x,y) (((x)>(y))?(x):(y))\n#define min(x,y) (((x)<(y))?(x):(y))\n\nvoid output_target(double value);\nvoid output(int index, double value);\nchar* readline(FILE *input);\n\nint main(int argc,char **argv)\n{\n\tint i,index;\n\tFILE *fp, *fp_restore = NULL;\n\tchar *save_filename = NULL;\n\tchar *restore_filename = NULL;\n\n\tfor(i=1;i<argc;i++)\n\t{\n\t\tif(argv[i][0] != '-') break;\n\t\t++i;\n\t\tswitch(argv[i-1][1])\n\t\t{\n\t\t\tcase 'l': lower = atof(argv[i]); break;\n\t\t\tcase 'u': upper = atof(argv[i]); break;\n\t\t\tcase 'y':\n\t\t\t\ty_lower = atof(argv[i]);\n\t\t\t\t++i;\n\t\t\t\ty_upper = atof(argv[i]);\n\t\t\t\ty_scaling = 1;\n\t\t\t\tbreak;\n\t\t\tcase 's': save_filename = argv[i]; break;\n\t\t\tcase 'r': restore_filename = argv[i]; break;\n\t\t\tdefault:\n\t\t\t\tfprintf(stderr,\"unknown option\\n\");\n\t\t\t\texit_with_help();\n\t\t}\n\t}\n\n\tif(!(upper > lower) || (y_scaling && !(y_upper > y_lower)))\n\t{\n\t\tfprintf(stderr,\"inconsistent lower/upper specification\\n\");\n\t\texit(1);\n\t}\n\t\n\tif(restore_filename && save_filename)\n\t{\n\t\tfprintf(stderr,\"cannot use -r and -s simultaneously\\n\");\n\t\texit(1);\n\t}\n\n\tif(argc != i+1) \n\t\texit_with_help();\n\n\tfp=fopen(argv[i],\"r\");\n\t\n\tif(fp==NULL)\n\t{\n\t\tfprintf(stderr,\"can't open file %s\\n\", argv[i]);\n\t\texit(1);\n\t}\n\n\tline = (char *) malloc(max_line_len*sizeof(char));\n\n#define SKIP_TARGET\\\n\twhile(isspace(*p)) ++p;\\\n\twhile(!isspace(*p)) ++p;\n\n#define SKIP_ELEMENT\\\n\twhile(*p!=':') ++p;\\\n\t++p;\\\n\twhile(isspace(*p)) ++p;\\\n\twhile(*p && !isspace(*p)) ++p;\n\t\n\t/* assumption: min index of attributes is 1 */\n\t/* pass 1: find out max index of attributes */\n\tmax_index = 0;\n\n\tif(restore_filename)\n\t{\n\t\tint idx, c;\n\n\t\tfp_restore = fopen(restore_filename,\"r\");\n\t\tif(fp_restore==NULL)\n\t\t{\n\t\t\tfprintf(stderr,\"can't open file %s\\n\", restore_filename);\n\t\t\texit(1);\n\t\t}\n\n\t\tc = fgetc(fp_restore);\n\t\tif(c == 'y')\n\t\t{\n\t\t\treadline(fp_restore);\n\t\t\treadline(fp_restore);\n\t\t\treadline(fp_restore);\n\t\t}\n\t\treadline(fp_restore);\n\t\treadline(fp_restore);\n\n\t\twhile(fscanf(fp_restore,\"%d %*f %*f\\n\",&idx) == 1)\n\t\t\tmax_index = max(idx,max_index);\n\t\trewind(fp_restore);\n\t}\n\n\twhile(readline(fp)!=NULL)\n\t{\n\t\tchar *p=line;\n\n\t\tSKIP_TARGET\n\n\t\twhile(sscanf(p,\"%d:%*f\",&index)==1)\n\t\t{\n\t\t\tmax_index = max(max_index, index);\n\t\t\tSKIP_ELEMENT\n\t\t\tnum_nonzeros++;\n\t\t}\t\t\n\t}\n\trewind(fp);\n\t\n\tfeature_max = (double *)malloc((max_index+1)* sizeof(double));\n\tfeature_min = (double *)malloc((max_index+1)* sizeof(double));\n\t\n\tif(feature_max == NULL || feature_min == NULL)\n\t{\n\t\tfprintf(stderr,\"can't allocate enough memory\\n\");\n\t\texit(1);\n\t}\n\n\tfor(i=0;i<=max_index;i++)\n\t{\n\t\tfeature_max[i]=-DBL_MAX;\n\t\tfeature_min[i]=DBL_MAX;\n\t}\n\n\t/* pass 2: find out min/max value */\n\twhile(readline(fp)!=NULL)\n\t{\n\t\tchar *p=line;\n\t\tint next_index=1;\n\t\tdouble target;\n\t\tdouble value;\n\n\t\tsscanf(p,\"%lf\",&target);\n\t\ty_max = max(y_max,target);\n\t\ty_min = min(y_min,target);\n\t\t\n\t\tSKIP_TARGET\n\n\t\twhile(sscanf(p,\"%d:%lf\",&index,&value)==2)\n\t\t{\n\t\t\tfor(i=next_index;i<index;i++)\n\t\t\t{\n\t\t\t\tfeature_max[i]=max(feature_max[i],0);\n\t\t\t\tfeature_min[i]=min(feature_min[i],0);\n\t\t\t}\n\t\t\t\n\t\t\tfeature_max[index]=max(feature_max[index],value);\n\t\t\tfeature_min[index]=min(feature_min[index],value);\n\n\t\t\tSKIP_ELEMENT\n\t\t\tnext_index=index+1;\n\t\t}\t\t\n\n\t\tfor(i=next_index;i<=max_index;i++)\n\t\t{\n\t\t\tfeature_max[i]=max(feature_max[i],0);\n\t\t\tfeature_min[i]=min(feature_min[i],0);\n\t\t}\t\n\t}\n\n\trewind(fp);\n\n\t/* pass 2.5: save/restore feature_min/feature_max */\n\t\n\tif(restore_filename)\n\t{\n\t\t/* fp_restore rewinded in finding max_index */\n\t\tint idx, c;\n\t\tdouble fmin, fmax;\n\t\t\n\t\tif((c = fgetc(fp_restore)) == 'y')\n\t\t{\n\t\t\tfscanf(fp_restore, \"%lf %lf\\n\", &y_lower, &y_upper);\n\t\t\tfscanf(fp_restore, \"%lf %lf\\n\", &y_min, &y_max);\n\t\t\ty_scaling = 1;\n\t\t}\n\t\telse\n\t\t\tungetc(c, fp_restore);\n\n\t\tif (fgetc(fp_restore) == 'x') {\n\t\t\tfscanf(fp_restore, \"%lf %lf\\n\", &lower, &upper);\n\t\t\twhile(fscanf(fp_restore,\"%d %lf %lf\\n\",&idx,&fmin,&fmax)==3)\n\t\t\t{\n\t\t\t\tif(idx<=max_index)\n\t\t\t\t{\n\t\t\t\t\tfeature_min[idx] = fmin;\n\t\t\t\t\tfeature_max[idx] = fmax;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfclose(fp_restore);\n\t}\n\t\n\tif(save_filename)\n\t{\n\t\tFILE *fp_save = fopen(save_filename,\"w\");\n\t\tif(fp_save==NULL)\n\t\t{\n\t\t\tfprintf(stderr,\"can't open file %s\\n\", save_filename);\n\t\t\texit(1);\n\t\t}\n\t\tif(y_scaling)\n\t\t{\n\t\t\tfprintf(fp_save, \"y\\n\");\n\t\t\tfprintf(fp_save, \"%.16g %.16g\\n\", y_lower, y_upper);\n\t\t\tfprintf(fp_save, \"%.16g %.16g\\n\", y_min, y_max);\n\t\t}\n\t\tfprintf(fp_save, \"x\\n\");\n\t\tfprintf(fp_save, \"%.16g %.16g\\n\", lower, upper);\n\t\tfor(i=1;i<=max_index;i++)\n\t\t{\n\t\t\tif(feature_min[i]!=feature_max[i])\n\t\t\t\tfprintf(fp_save,\"%d %.16g %.16g\\n\",i,feature_min[i],feature_max[i]);\n\t\t}\n\t\tfclose(fp_save);\n\t}\n\t\n\t/* pass 3: scale */\n\twhile(readline(fp)!=NULL)\n\t{\n\t\tchar *p=line;\n\t\tint next_index=1;\n\t\tdouble target;\n\t\tdouble value;\n\t\t\n\t\tsscanf(p,\"%lf\",&target);\n\t\toutput_target(target);\n\n\t\tSKIP_TARGET\n\n\t\twhile(sscanf(p,\"%d:%lf\",&index,&value)==2)\n\t\t{\n\t\t\tfor(i=next_index;i<index;i++)\n\t\t\t\toutput(i,0);\n\t\t\t\n\t\t\toutput(index,value);\n\n\t\t\tSKIP_ELEMENT\n\t\t\tnext_index=index+1;\n\t\t}\t\t\n\n\t\tfor(i=next_index;i<=max_index;i++)\n\t\t\toutput(i,0);\n\n\t\tprintf(\"\\n\");\n\t}\n\n\tif (new_num_nonzeros > num_nonzeros)\n\t\tfprintf(stderr, \n\t\t\t\"Warning: original #nonzeros %ld\\n\"\n\t\t\t\"         new      #nonzeros %ld\\n\"\n\t\t\t\"Use -l 0 if many original feature values are zeros\\n\",\n\t\t\tnum_nonzeros, new_num_nonzeros);\n\n\tfree(line);\n\tfree(feature_max);\n\tfree(feature_min);\n\tfclose(fp);\n\treturn 0;\n}\n\nchar* readline(FILE *input)\n{\n\tint len;\n\t\n\tif(fgets(line,max_line_len,input) == NULL)\n\t\treturn NULL;\n\n\twhile(strrchr(line,'\\n') == NULL)\n\t{\n\t\tmax_line_len *= 2;\n\t\tline = (char *) realloc(line, max_line_len);\n\t\tlen = (int) strlen(line);\n\t\tif(fgets(line+len,max_line_len-len,input) == NULL)\n\t\t\tbreak;\n\t}\n\treturn line;\n}\n\nvoid output_target(double value)\n{\n\tif(y_scaling)\n\t{\n\t\tif(value == y_min)\n\t\t\tvalue = y_lower;\n\t\telse if(value == y_max)\n\t\t\tvalue = y_upper;\n\t\telse value = y_lower + (y_upper-y_lower) *\n\t\t\t     (value - y_min)/(y_max-y_min);\n\t}\n\tprintf(\"%g \",value);\n}\n\nvoid output(int index, double value)\n{\n\t/* skip single-valued attribute */\n\tif(feature_max[index] == feature_min[index])\n\t\treturn;\n\n\tif(value == feature_min[index])\n\t\tvalue = lower;\n\telse if(value == feature_max[index])\n\t\tvalue = upper;\n\telse\n\t\tvalue = lower + (upper-lower) * \n\t\t\t(value-feature_min[index])/\n\t\t\t(feature_max[index]-feature_min[index]);\n\n\tif(value != 0)\n\t{\n\t\tprintf(\"%d:%g \",index, value);\n\t\tnew_num_nonzeros++;\n\t}\n}\n"
  },
  {
    "path": "scripts/modeltrain/libsvm-small/svm-train.c",
    "content": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <ctype.h>\n#include <errno.h>\n#include \"svm.h\"\n#define Malloc(type,n) (type *)malloc((n)*sizeof(type))\n\nvoid print_null(const char *s) {}\n\nvoid exit_with_help()\n{\n\tprintf(\n\t\"Usage: svm-train [options] training_set_file [model_file]\\n\"\n\t\"options:\\n\"\n\t\"-s svm_type : set type of SVM (default 0)\\n\"\n\t\"\t0 -- C-SVC\\n\"\n\t\"\t1 -- nu-SVC\\n\"\n\t\"\t2 -- one-class SVM\\n\"\n\t\"\t3 -- epsilon-SVR\\n\"\n\t\"\t4 -- nu-SVR\\n\"\n\t\"-t kernel_type : set type of kernel function (default 2)\\n\"\n\t\"\t0 -- linear: u'*v\\n\"\n\t\"\t1 -- polynomial: (gamma*u'*v + coef0)^degree\\n\"\n\t\"\t2 -- radial basis function: exp(-gamma*|u-v|^2)\\n\"\n\t\"\t3 -- sigmoid: tanh(gamma*u'*v + coef0)\\n\"\n\t\"\t4 -- precomputed kernel (kernel values in training_set_file)\\n\"\n\t\"-d degree : set degree in kernel function (default 3)\\n\"\n\t\"-g gamma : set gamma in kernel function (default 1/k)\\n\"\n\t\"-r coef0 : set coef0 in kernel function (default 0)\\n\"\n\t\"-c cost : set the parameter C of C-SVC, epsilon-SVR, and nu-SVR (default 1)\\n\"\n\t\"-n nu : set the parameter nu of nu-SVC, one-class SVM, and nu-SVR (default 0.5)\\n\"\n\t\"-p epsilon : set the epsilon in loss function of epsilon-SVR (default 0.1)\\n\"\n\t\"-m cachesize : set cache memory size in MB (default 100)\\n\"\n\t\"-e epsilon : set tolerance of termination criterion (default 0.001)\\n\"\n\t\"-h shrinking : whether to use the shrinking heuristics, 0 or 1 (default 1)\\n\"\n\t\"-b probability_estimates : whether to train a SVC or SVR model for probability estimates, 0 or 1 (default 0)\\n\"\n\t\"-wi weight : set the parameter C of class i to weight*C, for C-SVC (default 1)\\n\"\n\t\"-v n: n-fold cross validation mode\\n\"\n\t\"-q : quiet mode (no outputs)\\n\"\n\t);\n\texit(1);\n}\n\nvoid exit_input_error(int line_num)\n{\n\tfprintf(stderr,\"Wrong input format at line %d\\n\", line_num);\n\texit(1);\n}\n\nvoid parse_command_line(int argc, char **argv, char *input_file_name, char *model_file_name);\nvoid read_problem(const char *filename);\nvoid do_cross_validation();\n\nstruct svm_parameter param;\t\t// set by parse_command_line\nstruct svm_problem prob;\t\t// set by read_problem\nstruct svm_model *model;\nstruct svm_node *x_space;\nint cross_validation;\nint nr_fold;\n\nstatic char *line = NULL;\nstatic int max_line_len;\n\nstatic char* readline(FILE *input)\n{\n\tint len;\n\t\n\tif(fgets(line,max_line_len,input) == NULL)\n\t\treturn NULL;\n\n\twhile(strrchr(line,'\\n') == NULL)\n\t{\n\t\tmax_line_len *= 2;\n\t\tline = (char *) realloc(line,max_line_len);\n\t\tlen = (int) strlen(line);\n\t\tif(fgets(line+len,max_line_len-len,input) == NULL)\n\t\t\tbreak;\n\t}\n\treturn line;\n}\n\nint main(int argc, char **argv)\n{\n\tchar input_file_name[1024];\n\tchar model_file_name[1024];\n\tconst char *error_msg;\n\n\tparse_command_line(argc, argv, input_file_name, model_file_name);\n\tread_problem(input_file_name);\n\terror_msg = svm_check_parameter(&prob,&param);\n\n\tif(error_msg)\n\t{\n\t\tfprintf(stderr,\"Error: %s\\n\",error_msg);\n\t\texit(1);\n\t}\n\n\tif(cross_validation)\n\t{\n\t\tdo_cross_validation();\n\t}\n\telse\n\t{\n\t\tmodel = svm_train(&prob,&param);\n\t\tsvm_save_model(model_file_name,model);\n\t\tsvm_destroy_model(model);\n\t}\n\tsvm_destroy_param(&param);\n\tfree(prob.y);\n\tfree(prob.x);\n\tfree(x_space);\n\tfree(line);\n\n\treturn 0;\n}\n\nvoid do_cross_validation()\n{\n\tint i;\n\tint total_correct = 0;\n\tdouble total_error = 0;\n\tdouble sumv = 0, sumy = 0, sumvv = 0, sumyy = 0, sumvy = 0;\n\tdouble *target = Malloc(double,prob.l);\n\n\tsvm_cross_validation(&prob,&param,nr_fold,target);\n\tif(param.svm_type == EPSILON_SVR ||\n\t   param.svm_type == NU_SVR)\n\t{\n\t\tfor(i=0;i<prob.l;i++)\n\t\t{\n\t\t\tdouble y = prob.y[i];\n\t\t\tdouble v = target[i];\n\t\t\ttotal_error += (v-y)*(v-y);\n\t\t\tsumv += v;\n\t\t\tsumy += y;\n\t\t\tsumvv += v*v;\n\t\t\tsumyy += y*y;\n\t\t\tsumvy += v*y;\n\t\t}\n\t\tprintf(\"Cross Validation Mean squared error = %g\\n\",total_error/prob.l);\n\t\tprintf(\"Cross Validation Squared correlation coefficient = %g\\n\",\n\t\t\t((prob.l*sumvy-sumv*sumy)*(prob.l*sumvy-sumv*sumy))/\n\t\t\t((prob.l*sumvv-sumv*sumv)*(prob.l*sumyy-sumy*sumy))\n\t\t\t);\n\t}\n\telse\n\t{\n\t\tfor(i=0;i<prob.l;i++)\n\t\t\tif(target[i] == prob.y[i])\n\t\t\t\t++total_correct;\n\t\tprintf(\"Cross Validation Accuracy = %g%%\\n\",100.0*total_correct/prob.l);\n\t}\n\tfree(target);\n}\n\nvoid parse_command_line(int argc, char **argv, char *input_file_name, char *model_file_name)\n{\n\tint i;\n\n\t// default values\n\tparam.svm_type = C_SVC;\n\tparam.kernel_type = RBF;\n\tparam.degree = 3;\n\tparam.gamma = 0;\t// 1/k\n\tparam.coef0 = 0;\n\tparam.nu = 0.5;\n\tparam.cache_size = 100;\n\tparam.C = 1;\n\tparam.eps = 1e-3;\n\tparam.p = 0.1;\n\tparam.shrinking = 1;\n\tparam.probability = 0;\n\tparam.nr_weight = 0;\n\tparam.weight_label = NULL;\n\tparam.weight = NULL;\n\tcross_validation = 0;\n\n\t// parse options\n\tfor(i=1;i<argc;i++)\n\t{\n\t\tif(argv[i][0] != '-') break;\n\t\tif(++i>=argc)\n\t\t\texit_with_help();\n\t\tswitch(argv[i-1][1])\n\t\t{\n\t\t\tcase 's':\n\t\t\t\tparam.svm_type = atoi(argv[i]);\n\t\t\t\tbreak;\n\t\t\tcase 't':\n\t\t\t\tparam.kernel_type = atoi(argv[i]);\n\t\t\t\tbreak;\n\t\t\tcase 'd':\n\t\t\t\tparam.degree = atoi(argv[i]);\n\t\t\t\tbreak;\n\t\t\tcase 'g':\n\t\t\t\tparam.gamma = atof(argv[i]);\n\t\t\t\tbreak;\n\t\t\tcase 'r':\n\t\t\t\tparam.coef0 = atof(argv[i]);\n\t\t\t\tbreak;\n\t\t\tcase 'n':\n\t\t\t\tparam.nu = atof(argv[i]);\n\t\t\t\tbreak;\n\t\t\tcase 'm':\n\t\t\t\tparam.cache_size = atof(argv[i]);\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\tparam.C = atof(argv[i]);\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\t\tparam.eps = atof(argv[i]);\n\t\t\t\tbreak;\n\t\t\tcase 'p':\n\t\t\t\tparam.p = atof(argv[i]);\n\t\t\t\tbreak;\n\t\t\tcase 'h':\n\t\t\t\tparam.shrinking = atoi(argv[i]);\n\t\t\t\tbreak;\n\t\t\tcase 'b':\n\t\t\t\tparam.probability = atoi(argv[i]);\n\t\t\t\tbreak;\n\t\t\tcase 'q':\n\t\t\t\tsvm_print_string = &print_null;\n\t\t\t\ti--;\n\t\t\t\tbreak;\n\t\t\tcase 'v':\n\t\t\t\tcross_validation = 1;\n\t\t\t\tnr_fold = atoi(argv[i]);\n\t\t\t\tif(nr_fold < 2)\n\t\t\t\t{\n\t\t\t\t\tfprintf(stderr,\"n-fold cross validation: n must >= 2\\n\");\n\t\t\t\t\texit_with_help();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'w':\n\t\t\t\t++param.nr_weight;\n\t\t\t\tparam.weight_label = (int *)realloc(param.weight_label,sizeof(int)*param.nr_weight);\n\t\t\t\tparam.weight = (double *)realloc(param.weight,sizeof(double)*param.nr_weight);\n\t\t\t\tparam.weight_label[param.nr_weight-1] = atoi(&argv[i-1][2]);\n\t\t\t\tparam.weight[param.nr_weight-1] = atof(argv[i]);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tfprintf(stderr,\"Unknown option: -%c\\n\", argv[i-1][1]);\n\t\t\t\texit_with_help();\n\t\t}\n\t}\n\n\t// determine filenames\n\n\tif(i>=argc)\n\t\texit_with_help();\n\n\tstrcpy(input_file_name, argv[i]);\n\n\tif(i<argc-1)\n\t\tstrcpy(model_file_name,argv[i+1]);\n\telse\n\t{\n\t\tchar *p = strrchr(argv[i],'/');\n\t\tif(p==NULL)\n\t\t\tp = argv[i];\n\t\telse\n\t\t\t++p;\n\t\tsprintf(model_file_name,\"%s.model\",p);\n\t}\n}\n\n// read in a problem (in svmlight format)\n\nvoid read_problem(const char *filename)\n{\n\tint elements, max_index, inst_max_index, i, j;\n\tFILE *fp = fopen(filename,\"r\");\n\tchar *endptr;\n\tchar *idx, *val, *label;\n\n\tif(fp == NULL)\n\t{\n\t\tfprintf(stderr,\"can't open input file %s\\n\",filename);\n\t\texit(1);\n\t}\n\n\tprob.l = 0;\n\telements = 0;\n\n\tmax_line_len = 1024;\n\tline = Malloc(char,max_line_len);\n\twhile(readline(fp)!=NULL)\n\t{\n\t\tchar *p = strtok(line,\" \\t\"); // label\n\n\t\t// features\n\t\twhile(1)\n\t\t{\n\t\t\tp = strtok(NULL,\" \\t\");\n\t\t\tif(p == NULL || *p == '\\n') // check '\\n' as ' ' may be after the last feature\n\t\t\t\tbreak;\n\t\t\t++elements;\n\t\t}\n\t\t++elements;\n\t\t++prob.l;\n\t}\n\trewind(fp);\n\n\tprob.y = Malloc(double,prob.l);\n\tprob.x = Malloc(struct svm_node *,prob.l);\n\tx_space = Malloc(struct svm_node,elements);\n\n\tmax_index = 0;\n\tj=0;\n\tfor(i=0;i<prob.l;i++)\n\t{\n\t\tinst_max_index = -1; // strtol gives 0 if wrong format, and precomputed kernel has <index> start from 0\n\t\treadline(fp);\n\t\tprob.x[i] = &x_space[j];\n\t\tlabel = strtok(line,\" \\t\");\n\t\tprob.y[i] = strtod(label,&endptr);\n\t\tif(endptr == label)\n\t\t\texit_input_error(i+1);\n\n\t\twhile(1)\n\t\t{\n\t\t\tidx = strtok(NULL,\":\");\n\t\t\tval = strtok(NULL,\" \\t\");\n\n\t\t\tif(val == NULL)\n\t\t\t\tbreak;\n\n\t\t\terrno = 0;\n\t\t\tx_space[j].index = (int) strtol(idx,&endptr,10);\n\t\t\tif(endptr == idx || errno != 0 || *endptr != '\\0' || x_space[j].index <= inst_max_index)\n\t\t\t\texit_input_error(i+1);\n\t\t\telse\n\t\t\t\tinst_max_index = x_space[j].index;\n\n\t\t\terrno = 0;\n\t\t\tx_space[j].value = strtod(val,&endptr);\n\t\t\tif(endptr == val || errno != 0 || (*endptr != '\\0' && !isspace(*endptr)))\n\t\t\t\texit_input_error(i+1);\n\n\t\t\t++j;\n\t\t}\n\n\t\tif(inst_max_index > max_index)\n\t\t\tmax_index = inst_max_index;\n\t\tx_space[j++].index = -1;\n\t}\n\n\tif(param.gamma == 0 && max_index > 0)\n\t\tparam.gamma = 1.0/max_index;\n\n\tif(param.kernel_type == PRECOMPUTED)\n\t\tfor(i=0;i<prob.l;i++)\n\t\t{\n\t\t\tif (prob.x[i][0].index != 0)\n\t\t\t{\n\t\t\t\tfprintf(stderr,\"Wrong input format: first column must be 0:sample_serial_number\\n\");\n\t\t\t\texit(1);\n\t\t\t}\n\t\t\tif ((int)prob.x[i][0].value <= 0 || (int)prob.x[i][0].value > max_index)\n\t\t\t{\n\t\t\t\tfprintf(stderr,\"Wrong input format: sample_serial_number out of range\\n\");\n\t\t\t\texit(1);\n\t\t\t}\n\t\t}\n\n\tfclose(fp);\n}\n"
  },
  {
    "path": "scripts/modeltrain/libsvm-small/svm.cpp",
    "content": "#include <math.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <ctype.h>\n#include <float.h>\n#include <string.h>\n#include <stdarg.h>\n#include \"svm.h\"\nint libsvm_version = LIBSVM_VERSION;\ntypedef float Qfloat;\ntypedef signed char schar;\n#ifndef min\ntemplate <class T> inline T min(T x,T y) { return (x<y)?x:y; }\n#endif\n#ifndef max\ntemplate <class T> inline T max(T x,T y) { return (x>y)?x:y; }\n#endif\ntemplate <class T> inline void swap(T& x, T& y) { T t=x; x=y; y=t; }\ntemplate <class S, class T> inline void clone(T*& dst, S* src, int n)\n{\n\tdst = new T[n];\n\tmemcpy((void *)dst,(void *)src,sizeof(T)*n);\n}\ninline double powi(double base, int times)\n{\n\tdouble tmp = base, ret = 1.0;\n\n\tfor(int t=times; t>0; t/=2)\n\t{\n\t\tif(t%2==1) ret*=tmp;\n\t\ttmp = tmp * tmp;\n\t}\n\treturn ret;\n}\n#define INF HUGE_VAL\n#define TAU 1e-12\n#define Malloc(type,n) (type *)malloc((n)*sizeof(type))\n\nstatic void print_string_stdout(const char *s)\n{\n\tfputs(s,stdout);\n\tfflush(stdout);\n}\nvoid (*svm_print_string) (const char *) = &print_string_stdout;\n#if 1\nstatic void info(const char *fmt,...)\n{\n\tchar buf[BUFSIZ];\n\tva_list ap;\n\tva_start(ap,fmt);\n\tvsprintf(buf,fmt,ap);\n\tva_end(ap);\n\t(*svm_print_string)(buf);\n}\n#else\nstatic void info(const char *fmt,...) {}\n#endif\n\n//\n// Kernel Cache\n//\n// l is the number of total data items\n// size is the cache size limit in bytes\n//\nclass Cache\n{\npublic:\n\tCache(int l,long int size);\n\t~Cache();\n\n\t// request data [0,len)\n\t// return some position p where [p,len) need to be filled\n\t// (p >= len if nothing needs to be filled)\n\tint get_data(const int index, Qfloat **data, int len);\n\tvoid swap_index(int i, int j);\t\nprivate:\n\tint l;\n\tlong int size;\n\tstruct head_t\n\t{\n\t\thead_t *prev, *next;\t// a circular list\n\t\tQfloat *data;\n\t\tint len;\t\t// data[0,len) is cached in this entry\n\t};\n\n\thead_t *head;\n\thead_t lru_head;\n\tvoid lru_delete(head_t *h);\n\tvoid lru_insert(head_t *h);\n};\n\nCache::Cache(int l_,long int size_):l(l_),size(size_)\n{\n\thead = (head_t *)calloc(l,sizeof(head_t));\t// initialized to 0\n\tsize /= sizeof(Qfloat);\n\tsize -= l * sizeof(head_t) / sizeof(Qfloat);\n\tsize = max(size, 2 * (long int) l);\t// cache must be large enough for two columns\n\tlru_head.next = lru_head.prev = &lru_head;\n}\n\nCache::~Cache()\n{\n\tfor(head_t *h = lru_head.next; h != &lru_head; h=h->next)\n\t\tfree(h->data);\n\tfree(head);\n}\n\nvoid Cache::lru_delete(head_t *h)\n{\n\t// delete from current location\n\th->prev->next = h->next;\n\th->next->prev = h->prev;\n}\n\nvoid Cache::lru_insert(head_t *h)\n{\n\t// insert to last position\n\th->next = &lru_head;\n\th->prev = lru_head.prev;\n\th->prev->next = h;\n\th->next->prev = h;\n}\n\nint Cache::get_data(const int index, Qfloat **data, int len)\n{\n\thead_t *h = &head[index];\n\tif(h->len) lru_delete(h);\n\tint more = len - h->len;\n\n\tif(more > 0)\n\t{\n\t\t// free old space\n\t\twhile(size < more)\n\t\t{\n\t\t\thead_t *old = lru_head.next;\n\t\t\tlru_delete(old);\n\t\t\tfree(old->data);\n\t\t\tsize += old->len;\n\t\t\told->data = 0;\n\t\t\told->len = 0;\n\t\t}\n\n\t\t// allocate new space\n\t\th->data = (Qfloat *)realloc(h->data,sizeof(Qfloat)*len);\n\t\tsize -= more;\n\t\tswap(h->len,len);\n\t}\n\n\tlru_insert(h);\n\t*data = h->data;\n\treturn len;\n}\n\nvoid Cache::swap_index(int i, int j)\n{\n\tif(i==j) return;\n\n\tif(head[i].len) lru_delete(&head[i]);\n\tif(head[j].len) lru_delete(&head[j]);\n\tswap(head[i].data,head[j].data);\n\tswap(head[i].len,head[j].len);\n\tif(head[i].len) lru_insert(&head[i]);\n\tif(head[j].len) lru_insert(&head[j]);\n\n\tif(i>j) swap(i,j);\n\tfor(head_t *h = lru_head.next; h!=&lru_head; h=h->next)\n\t{\n\t\tif(h->len > i)\n\t\t{\n\t\t\tif(h->len > j)\n\t\t\t\tswap(h->data[i],h->data[j]);\n\t\t\telse\n\t\t\t{\n\t\t\t\t// give up\n\t\t\t\tlru_delete(h);\n\t\t\t\tfree(h->data);\n\t\t\t\tsize += h->len;\n\t\t\t\th->data = 0;\n\t\t\t\th->len = 0;\n\t\t\t}\n\t\t}\n\t}\n}\n\n//\n// Kernel evaluation\n//\n// the static method k_function is for doing single kernel evaluation\n// the constructor of Kernel prepares to calculate the l*l kernel matrix\n// the member function get_Q is for getting one column from the Q Matrix\n//\nclass QMatrix {\npublic:\n\tvirtual Qfloat *get_Q(int column, int len) const = 0;\n\tvirtual Qfloat *get_QD() const = 0;\n\tvirtual void swap_index(int i, int j) const = 0;\n\tvirtual ~QMatrix() {}\n};\n\nclass Kernel: public QMatrix {\npublic:\n\tKernel(int l, svm_node * const * x, const svm_parameter& param);\n\tvirtual ~Kernel();\n\n\tstatic double k_function(const svm_node *x, const svm_node *y,\n\t\t\t\t const svm_parameter& param);\n\tvirtual Qfloat *get_Q(int column, int len) const = 0;\n\tvirtual Qfloat *get_QD() const = 0;\n\tvirtual void swap_index(int i, int j) const\t// no so const...\n\t{\n\t\tswap(x[i],x[j]);\n\t\tif(x_square) swap(x_square[i],x_square[j]);\n\t}\nprotected:\n\n\tdouble (Kernel::*kernel_function)(int i, int j) const;\n\nprivate:\n\tconst svm_node **x;\n\tdouble *x_square;\n\n\t// svm_parameter\n\tconst int kernel_type;\n\tconst int degree;\n\tconst double gamma;\n\tconst double coef0;\n\n\tstatic double dot(const svm_node *px, const svm_node *py);\n\tdouble kernel_linear(int i, int j) const\n\t{\n\t\treturn dot(x[i],x[j]);\n\t}\n\tdouble kernel_poly(int i, int j) const\n\t{\n\t\treturn powi(gamma*dot(x[i],x[j])+coef0,degree);\n\t}\n\tdouble kernel_rbf(int i, int j) const\n\t{\n\t\treturn exp(-gamma*(x_square[i]+x_square[j]-2*dot(x[i],x[j])));\n\t}\n\tdouble kernel_sigmoid(int i, int j) const\n\t{\n\t\treturn tanh(gamma*dot(x[i],x[j])+coef0);\n\t}\n\tdouble kernel_precomputed(int i, int j) const\n\t{\n\t\treturn x[i][(int)(x[j][0].value)].value;\n\t}\n};\n\nKernel::Kernel(int l, svm_node * const * x_, const svm_parameter& param)\n:kernel_type(param.kernel_type), degree(param.degree),\n gamma(param.gamma), coef0(param.coef0)\n{\n\tswitch(kernel_type)\n\t{\n\t\tcase LINEAR:\n\t\t\tkernel_function = &Kernel::kernel_linear;\n\t\t\tbreak;\n\t\tcase POLY:\n\t\t\tkernel_function = &Kernel::kernel_poly;\n\t\t\tbreak;\n\t\tcase RBF:\n\t\t\tkernel_function = &Kernel::kernel_rbf;\n\t\t\tbreak;\n\t\tcase SIGMOID:\n\t\t\tkernel_function = &Kernel::kernel_sigmoid;\n\t\t\tbreak;\n\t\tcase PRECOMPUTED:\n\t\t\tkernel_function = &Kernel::kernel_precomputed;\n\t\t\tbreak;\n\t}\n\n\tclone(x,x_,l);\n\n\tif(kernel_type == RBF)\n\t{\n\t\tx_square = new double[l];\n\t\tfor(int i=0;i<l;i++)\n\t\t\tx_square[i] = dot(x[i],x[i]);\n\t}\n\telse\n\t\tx_square = 0;\n}\n\nKernel::~Kernel()\n{\n\tdelete[] x;\n\tdelete[] x_square;\n}\n\ndouble Kernel::dot(const svm_node *px, const svm_node *py)\n{\n\tdouble sum = 0;\n\twhile(px->index != -1 && py->index != -1)\n\t{\n\t\tif(px->index == py->index)\n\t\t{\n\t\t\tsum += px->value * py->value;\n\t\t\t++px;\n\t\t\t++py;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(px->index > py->index)\n\t\t\t\t++py;\n\t\t\telse\n\t\t\t\t++px;\n\t\t}\t\t\t\n\t}\n\treturn sum;\n}\n\ndouble Kernel::k_function(const svm_node *x, const svm_node *y,\n\t\t\t  const svm_parameter& param)\n{\n\tswitch(param.kernel_type)\n\t{\n\t\tcase LINEAR:\n\t\t\treturn dot(x,y);\n\t\tcase POLY:\n\t\t\treturn powi(param.gamma*dot(x,y)+param.coef0,param.degree);\n\t\tcase RBF:\n\t\t{\n\t\t\tdouble sum = 0;\n\t\t\twhile(x->index != -1 && y->index !=-1)\n\t\t\t{\n\t\t\t\tif(x->index == y->index)\n\t\t\t\t{\n\t\t\t\t\tdouble d = x->value - y->value;\n\t\t\t\t\tsum += d*d;\n\t\t\t\t\t++x;\n\t\t\t\t\t++y;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif(x->index > y->index)\n\t\t\t\t\t{\t\n\t\t\t\t\t\tsum += y->value * y->value;\n\t\t\t\t\t\t++y;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tsum += x->value * x->value;\n\t\t\t\t\t\t++x;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\twhile(x->index != -1)\n\t\t\t{\n\t\t\t\tsum += x->value * x->value;\n\t\t\t\t++x;\n\t\t\t}\n\n\t\t\twhile(y->index != -1)\n\t\t\t{\n\t\t\t\tsum += y->value * y->value;\n\t\t\t\t++y;\n\t\t\t}\n\t\t\t\n\t\t\treturn exp(-param.gamma*sum);\n\t\t}\n\t\tcase SIGMOID:\n\t\t\treturn tanh(param.gamma*dot(x,y)+param.coef0);\n\t\tcase PRECOMPUTED:  //x: test (validation), y: SV\n\t\t\treturn x[(int)(y->value)].value;\n\t\tdefault:\n\t\t\treturn 0;  // Unreachable \n\t}\n}\n\n// An SMO algorithm in Fan et al., JMLR 6(2005), p. 1889--1918\n// Solves:\n//\n//\tmin 0.5(\\alpha^T Q \\alpha) + p^T \\alpha\n//\n//\t\ty^T \\alpha = \\delta\n//\t\ty_i = +1 or -1\n//\t\t0 <= alpha_i <= Cp for y_i = 1\n//\t\t0 <= alpha_i <= Cn for y_i = -1\n//\n// Given:\n//\n//\tQ, p, y, Cp, Cn, and an initial feasible point \\alpha\n//\tl is the size of vectors and matrices\n//\teps is the stopping tolerance\n//\n// solution will be put in \\alpha, objective value will be put in obj\n//\nclass Solver {\npublic:\n\tSolver() {};\n\tvirtual ~Solver() {};\n\n\tstruct SolutionInfo {\n\t\tdouble obj;\n\t\tdouble rho;\n\t\tdouble upper_bound_p;\n\t\tdouble upper_bound_n;\n\t\tdouble r;\t// for Solver_NU\n\t};\n\n\tvoid Solve(int l, const QMatrix& Q, const double *p_, const schar *y_,\n\t\t   double *alpha_, double Cp, double Cn, double eps,\n\t\t   SolutionInfo* si, int shrinking);\nprotected:\n\tint active_size;\n\tschar *y;\n\tdouble *G;\t\t// gradient of objective function\n\tenum { LOWER_BOUND, UPPER_BOUND, FREE };\n\tchar *alpha_status;\t// LOWER_BOUND, UPPER_BOUND, FREE\n\tdouble *alpha;\n\tconst QMatrix *Q;\n\tconst Qfloat *QD;\n\tdouble eps;\n\tdouble Cp,Cn;\n\tdouble *p;\n\tint *active_set;\n\tdouble *G_bar;\t\t// gradient, if we treat free variables as 0\n\tint l;\n\tbool unshrink;\t// XXX\n\n\tdouble get_C(int i)\n\t{\n\t\treturn (y[i] > 0)? Cp : Cn;\n\t}\n\tvoid update_alpha_status(int i)\n\t{\n\t\tif(alpha[i] >= get_C(i))\n\t\t\talpha_status[i] = UPPER_BOUND;\n\t\telse if(alpha[i] <= 0)\n\t\t\talpha_status[i] = LOWER_BOUND;\n\t\telse alpha_status[i] = FREE;\n\t}\n\tbool is_upper_bound(int i) { return alpha_status[i] == UPPER_BOUND; }\n\tbool is_lower_bound(int i) { return alpha_status[i] == LOWER_BOUND; }\n\tbool is_free(int i) { return alpha_status[i] == FREE; }\n\tvoid swap_index(int i, int j);\n\tvoid reconstruct_gradient();\n\tvirtual int select_working_set(int &i, int &j);\n\tvirtual double calculate_rho();\n\tvirtual void do_shrinking();\nprivate:\n\tbool be_shrunk(int i, double Gmax1, double Gmax2);\t\n};\n\nvoid Solver::swap_index(int i, int j)\n{\n\tQ->swap_index(i,j);\n\tswap(y[i],y[j]);\n\tswap(G[i],G[j]);\n\tswap(alpha_status[i],alpha_status[j]);\n\tswap(alpha[i],alpha[j]);\n\tswap(p[i],p[j]);\n\tswap(active_set[i],active_set[j]);\n\tswap(G_bar[i],G_bar[j]);\n}\n\nvoid Solver::reconstruct_gradient()\n{\n\t// reconstruct inactive elements of G from G_bar and free variables\n\n\tif(active_size == l) return;\n\n\tint i,j;\n\tint nr_free = 0;\n\n\tfor(j=active_size;j<l;j++)\n\t\tG[j] = G_bar[j] + p[j];\n\n\tfor(j=0;j<active_size;j++)\n\t\tif(is_free(j))\n\t\t\tnr_free++;\n\n\tif(2*nr_free < active_size)\n\t\tinfo(\"\\nWarning: using -h 0 may be faster\\n\");\n\n\tif (nr_free*l > 2*active_size*(l-active_size))\n\t{\n\t\tfor(i=active_size;i<l;i++)\n\t\t{\n\t\t\tconst Qfloat *Q_i = Q->get_Q(i,active_size);\n\t\t\tfor(j=0;j<active_size;j++)\n\t\t\t\tif(is_free(j))\n\t\t\t\t\tG[i] += alpha[j] * Q_i[j];\n\t\t}\n\t}\n\telse\n\t{\n\t\tfor(i=0;i<active_size;i++)\n\t\t\tif(is_free(i))\n\t\t\t{\n\t\t\t\tconst Qfloat *Q_i = Q->get_Q(i,l);\n\t\t\t\tdouble alpha_i = alpha[i];\n\t\t\t\tfor(j=active_size;j<l;j++)\n\t\t\t\t\tG[j] += alpha_i * Q_i[j];\n\t\t\t}\n\t}\n}\n\nvoid Solver::Solve(int l, const QMatrix& Q, const double *p_, const schar *y_,\n\t\t   double *alpha_, double Cp, double Cn, double eps,\n\t\t   SolutionInfo* si, int shrinking)\n{\n\tthis->l = l;\n\tthis->Q = &Q;\n\tQD=Q.get_QD();\n\tclone(p, p_,l);\n\tclone(y, y_,l);\n\tclone(alpha,alpha_,l);\n\tthis->Cp = Cp;\n\tthis->Cn = Cn;\n\tthis->eps = eps;\n\tunshrink = false;\n\n\t// initialize alpha_status\n\t{\n\t\talpha_status = new char[l];\n\t\tfor(int i=0;i<l;i++)\n\t\t\tupdate_alpha_status(i);\n\t}\n\n\t// initialize active set (for shrinking)\n\t{\n\t\tactive_set = new int[l];\n\t\tfor(int i=0;i<l;i++)\n\t\t\tactive_set[i] = i;\n\t\tactive_size = l;\n\t}\n\n\t// initialize gradient\n\t{\n\t\tG = new double[l];\n\t\tG_bar = new double[l];\n\t\tint i;\n\t\tfor(i=0;i<l;i++)\n\t\t{\n\t\t\tG[i] = p[i];\n\t\t\tG_bar[i] = 0;\n\t\t}\n\t\tfor(i=0;i<l;i++)\n\t\t\tif(!is_lower_bound(i))\n\t\t\t{\n\t\t\t\tconst Qfloat *Q_i = Q.get_Q(i,l);\n\t\t\t\tdouble alpha_i = alpha[i];\n\t\t\t\tint j;\n\t\t\t\tfor(j=0;j<l;j++)\n\t\t\t\t\tG[j] += alpha_i*Q_i[j];\n\t\t\t\tif(is_upper_bound(i))\n\t\t\t\t\tfor(j=0;j<l;j++)\n\t\t\t\t\t\tG_bar[j] += get_C(i) * Q_i[j];\n\t\t\t}\n\t}\n\n\t// optimization step\n\n\tint iter = 0;\n\tint counter = min(l,1000)+1;\n\n\twhile(1)\n\t{\n\t\t// show progress and do shrinking\n\n\t\tif(--counter == 0)\n\t\t{\n\t\t\tcounter = min(l,1000);\n\t\t\tif(shrinking) do_shrinking();\n\t\t\tinfo(\".\");\n\t\t}\n\n\t\tint i,j;\n\t\tif(select_working_set(i,j)!=0)\n\t\t{\n\t\t\t// reconstruct the whole gradient\n\t\t\treconstruct_gradient();\n\t\t\t// reset active set size and check\n\t\t\tactive_size = l;\n\t\t\tinfo(\"*\");\n\t\t\tif(select_working_set(i,j)!=0)\n\t\t\t\tbreak;\n\t\t\telse\n\t\t\t\tcounter = 1;\t// do shrinking next iteration\n\t\t}\n\t\t\n\t\t++iter;\n\n\t\t// update alpha[i] and alpha[j], handle bounds carefully\n\t\t\n\t\tconst Qfloat *Q_i = Q.get_Q(i,active_size);\n\t\tconst Qfloat *Q_j = Q.get_Q(j,active_size);\n\n\t\tdouble C_i = get_C(i);\n\t\tdouble C_j = get_C(j);\n\n\t\tdouble old_alpha_i = alpha[i];\n\t\tdouble old_alpha_j = alpha[j];\n\n\t\tif(y[i]!=y[j])\n\t\t{\n\t\t\tdouble quad_coef = Q_i[i]+Q_j[j]+2*Q_i[j];\n\t\t\tif (quad_coef <= 0)\n\t\t\t\tquad_coef = TAU;\n\t\t\tdouble delta = (-G[i]-G[j])/quad_coef;\n\t\t\tdouble diff = alpha[i] - alpha[j];\n\t\t\talpha[i] += delta;\n\t\t\talpha[j] += delta;\n\t\t\t\n\t\t\tif(diff > 0)\n\t\t\t{\n\t\t\t\tif(alpha[j] < 0)\n\t\t\t\t{\n\t\t\t\t\talpha[j] = 0;\n\t\t\t\t\talpha[i] = diff;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(alpha[i] < 0)\n\t\t\t\t{\n\t\t\t\t\talpha[i] = 0;\n\t\t\t\t\talpha[j] = -diff;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(diff > C_i - C_j)\n\t\t\t{\n\t\t\t\tif(alpha[i] > C_i)\n\t\t\t\t{\n\t\t\t\t\talpha[i] = C_i;\n\t\t\t\t\talpha[j] = C_i - diff;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(alpha[j] > C_j)\n\t\t\t\t{\n\t\t\t\t\talpha[j] = C_j;\n\t\t\t\t\talpha[i] = C_j + diff;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tdouble quad_coef = Q_i[i]+Q_j[j]-2*Q_i[j];\n\t\t\tif (quad_coef <= 0)\n\t\t\t\tquad_coef = TAU;\n\t\t\tdouble delta = (G[i]-G[j])/quad_coef;\n\t\t\tdouble sum = alpha[i] + alpha[j];\n\t\t\talpha[i] -= delta;\n\t\t\talpha[j] += delta;\n\n\t\t\tif(sum > C_i)\n\t\t\t{\n\t\t\t\tif(alpha[i] > C_i)\n\t\t\t\t{\n\t\t\t\t\talpha[i] = C_i;\n\t\t\t\t\talpha[j] = sum - C_i;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(alpha[j] < 0)\n\t\t\t\t{\n\t\t\t\t\talpha[j] = 0;\n\t\t\t\t\talpha[i] = sum;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(sum > C_j)\n\t\t\t{\n\t\t\t\tif(alpha[j] > C_j)\n\t\t\t\t{\n\t\t\t\t\talpha[j] = C_j;\n\t\t\t\t\talpha[i] = sum - C_j;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(alpha[i] < 0)\n\t\t\t\t{\n\t\t\t\t\talpha[i] = 0;\n\t\t\t\t\talpha[j] = sum;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// update G\n\n\t\tdouble delta_alpha_i = alpha[i] - old_alpha_i;\n\t\tdouble delta_alpha_j = alpha[j] - old_alpha_j;\n\t\t\n\t\tfor(int k=0;k<active_size;k++)\n\t\t{\n\t\t\tG[k] += Q_i[k]*delta_alpha_i + Q_j[k]*delta_alpha_j;\n\t\t}\n\n\t\t// update alpha_status and G_bar\n\n\t\t{\n\t\t\tbool ui = is_upper_bound(i);\n\t\t\tbool uj = is_upper_bound(j);\n\t\t\tupdate_alpha_status(i);\n\t\t\tupdate_alpha_status(j);\n\t\t\tint k;\n\t\t\tif(ui != is_upper_bound(i))\n\t\t\t{\n\t\t\t\tQ_i = Q.get_Q(i,l);\n\t\t\t\tif(ui)\n\t\t\t\t\tfor(k=0;k<l;k++)\n\t\t\t\t\t\tG_bar[k] -= C_i * Q_i[k];\n\t\t\t\telse\n\t\t\t\t\tfor(k=0;k<l;k++)\n\t\t\t\t\t\tG_bar[k] += C_i * Q_i[k];\n\t\t\t}\n\n\t\t\tif(uj != is_upper_bound(j))\n\t\t\t{\n\t\t\t\tQ_j = Q.get_Q(j,l);\n\t\t\t\tif(uj)\n\t\t\t\t\tfor(k=0;k<l;k++)\n\t\t\t\t\t\tG_bar[k] -= C_j * Q_j[k];\n\t\t\t\telse\n\t\t\t\t\tfor(k=0;k<l;k++)\n\t\t\t\t\t\tG_bar[k] += C_j * Q_j[k];\n\t\t\t}\n\t\t}\n\t}\n\n\t// calculate rho\n\n\tsi->rho = calculate_rho();\n\n\t// calculate objective value\n\t{\n\t\tdouble v = 0;\n\t\tint i;\n\t\tfor(i=0;i<l;i++)\n\t\t\tv += alpha[i] * (G[i] + p[i]);\n\n\t\tsi->obj = v/2;\n\t}\n\n\t// put back the solution\n\t{\n\t\tfor(int i=0;i<l;i++)\n\t\t\talpha_[active_set[i]] = alpha[i];\n\t}\n\n\t// juggle everything back\n\t/*{\n\t\tfor(int i=0;i<l;i++)\n\t\t\twhile(active_set[i] != i)\n\t\t\t\tswap_index(i,active_set[i]);\n\t\t\t\t// or Q.swap_index(i,active_set[i]);\n\t}*/\n\n\tsi->upper_bound_p = Cp;\n\tsi->upper_bound_n = Cn;\n\n\tinfo(\"\\noptimization finished, #iter = %d\\n\",iter);\n\n\tdelete[] p;\n\tdelete[] y;\n\tdelete[] alpha;\n\tdelete[] alpha_status;\n\tdelete[] active_set;\n\tdelete[] G;\n\tdelete[] G_bar;\n}\n\n// return 1 if already optimal, return 0 otherwise\nint Solver::select_working_set(int &out_i, int &out_j)\n{\n\t// return i,j such that\n\t// i: maximizes -y_i * grad(f)_i, i in I_up(\\alpha)\n\t// j: minimizes the decrease of obj value\n\t//    (if quadratic coefficeint <= 0, replace it with tau)\n\t//    -y_j*grad(f)_j < -y_i*grad(f)_i, j in I_low(\\alpha)\n\t\n\tdouble Gmax = -INF;\n\tdouble Gmax2 = -INF;\n\tint Gmax_idx = -1;\n\tint Gmin_idx = -1;\n\tdouble obj_diff_min = INF;\n\n\tfor(int t=0;t<active_size;t++)\n\t\tif(y[t]==+1)\t\n\t\t{\n\t\t\tif(!is_upper_bound(t))\n\t\t\t\tif(-G[t] >= Gmax)\n\t\t\t\t{\n\t\t\t\t\tGmax = -G[t];\n\t\t\t\t\tGmax_idx = t;\n\t\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(!is_lower_bound(t))\n\t\t\t\tif(G[t] >= Gmax)\n\t\t\t\t{\n\t\t\t\t\tGmax = G[t];\n\t\t\t\t\tGmax_idx = t;\n\t\t\t\t}\n\t\t}\n\n\tint i = Gmax_idx;\n\tconst Qfloat *Q_i = NULL;\n\tif(i != -1) // NULL Q_i not accessed: Gmax=-INF if i=-1\n\t\tQ_i = Q->get_Q(i,active_size);\n\n\tfor(int j=0;j<active_size;j++)\n\t{\n\t\tif(y[j]==+1)\n\t\t{\n\t\t\tif (!is_lower_bound(j))\n\t\t\t{\n\t\t\t\tdouble grad_diff=Gmax+G[j];\n\t\t\t\tif (G[j] >= Gmax2)\n\t\t\t\t\tGmax2 = G[j];\n\t\t\t\tif (grad_diff > 0)\n\t\t\t\t{\n\t\t\t\t\tdouble obj_diff; \n\t\t\t\t\tdouble quad_coef=Q_i[i]+QD[j]-2.0*y[i]*Q_i[j];\n\t\t\t\t\tif (quad_coef > 0)\n\t\t\t\t\t\tobj_diff = -(grad_diff*grad_diff)/quad_coef;\n\t\t\t\t\telse\n\t\t\t\t\t\tobj_diff = -(grad_diff*grad_diff)/TAU;\n\n\t\t\t\t\tif (obj_diff <= obj_diff_min)\n\t\t\t\t\t{\n\t\t\t\t\t\tGmin_idx=j;\n\t\t\t\t\t\tobj_diff_min = obj_diff;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (!is_upper_bound(j))\n\t\t\t{\n\t\t\t\tdouble grad_diff= Gmax-G[j];\n\t\t\t\tif (-G[j] >= Gmax2)\n\t\t\t\t\tGmax2 = -G[j];\n\t\t\t\tif (grad_diff > 0)\n\t\t\t\t{\n\t\t\t\t\tdouble obj_diff; \n\t\t\t\t\tdouble quad_coef=Q_i[i]+QD[j]+2.0*y[i]*Q_i[j];\n\t\t\t\t\tif (quad_coef > 0)\n\t\t\t\t\t\tobj_diff = -(grad_diff*grad_diff)/quad_coef;\n\t\t\t\t\telse\n\t\t\t\t\t\tobj_diff = -(grad_diff*grad_diff)/TAU;\n\n\t\t\t\t\tif (obj_diff <= obj_diff_min)\n\t\t\t\t\t{\n\t\t\t\t\t\tGmin_idx=j;\n\t\t\t\t\t\tobj_diff_min = obj_diff;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif(Gmax+Gmax2 < eps)\n\t\treturn 1;\n\n\tout_i = Gmax_idx;\n\tout_j = Gmin_idx;\n\treturn 0;\n}\n\nbool Solver::be_shrunk(int i, double Gmax1, double Gmax2)\n{\n\tif(is_upper_bound(i))\n\t{\n\t\tif(y[i]==+1)\n\t\t\treturn(-G[i] > Gmax1);\n\t\telse\n\t\t\treturn(-G[i] > Gmax2);\n\t}\n\telse if(is_lower_bound(i))\n\t{\n\t\tif(y[i]==+1)\n\t\t\treturn(G[i] > Gmax2);\n\t\telse\t\n\t\t\treturn(G[i] > Gmax1);\n\t}\n\telse\n\t\treturn(false);\n}\n\nvoid Solver::do_shrinking()\n{\n\tint i;\n\tdouble Gmax1 = -INF;\t\t// max { -y_i * grad(f)_i | i in I_up(\\alpha) }\n\tdouble Gmax2 = -INF;\t\t// max { y_i * grad(f)_i | i in I_low(\\alpha) }\n\n\t// find maximal violating pair first\n\tfor(i=0;i<active_size;i++)\n\t{\n\t\tif(y[i]==+1)\t\n\t\t{\n\t\t\tif(!is_upper_bound(i))\t\n\t\t\t{\n\t\t\t\tif(-G[i] >= Gmax1)\n\t\t\t\t\tGmax1 = -G[i];\n\t\t\t}\n\t\t\tif(!is_lower_bound(i))\t\n\t\t\t{\n\t\t\t\tif(G[i] >= Gmax2)\n\t\t\t\t\tGmax2 = G[i];\n\t\t\t}\n\t\t}\n\t\telse\t\n\t\t{\n\t\t\tif(!is_upper_bound(i))\t\n\t\t\t{\n\t\t\t\tif(-G[i] >= Gmax2)\n\t\t\t\t\tGmax2 = -G[i];\n\t\t\t}\n\t\t\tif(!is_lower_bound(i))\t\n\t\t\t{\n\t\t\t\tif(G[i] >= Gmax1)\n\t\t\t\t\tGmax1 = G[i];\n\t\t\t}\n\t\t}\n\t}\n\n\tif(unshrink == false && Gmax1 + Gmax2 <= eps*10) \n\t{\n\t\tunshrink = true;\n\t\treconstruct_gradient();\n\t\tactive_size = l;\n\t\tinfo(\"*\");\n\t}\n\n\tfor(i=0;i<active_size;i++)\n\t\tif (be_shrunk(i, Gmax1, Gmax2))\n\t\t{\n\t\t\tactive_size--;\n\t\t\twhile (active_size > i)\n\t\t\t{\n\t\t\t\tif (!be_shrunk(active_size, Gmax1, Gmax2))\n\t\t\t\t{\n\t\t\t\t\tswap_index(i,active_size);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tactive_size--;\n\t\t\t}\n\t\t}\n}\n\ndouble Solver::calculate_rho()\n{\n\tdouble r;\n\tint nr_free = 0;\n\tdouble ub = INF, lb = -INF, sum_free = 0;\n\tfor(int i=0;i<active_size;i++)\n\t{\n\t\tdouble yG = y[i]*G[i];\n\n\t\tif(is_upper_bound(i))\n\t\t{\n\t\t\tif(y[i]==-1)\n\t\t\t\tub = min(ub,yG);\n\t\t\telse\n\t\t\t\tlb = max(lb,yG);\n\t\t}\n\t\telse if(is_lower_bound(i))\n\t\t{\n\t\t\tif(y[i]==+1)\n\t\t\t\tub = min(ub,yG);\n\t\t\telse\n\t\t\t\tlb = max(lb,yG);\n\t\t}\n\t\telse\n\t\t{\n\t\t\t++nr_free;\n\t\t\tsum_free += yG;\n\t\t}\n\t}\n\n\tif(nr_free>0)\n\t\tr = sum_free/nr_free;\n\telse\n\t\tr = (ub+lb)/2;\n\n\treturn r;\n}\n\n//\n// Solver for nu-svm classification and regression\n//\n// additional constraint: e^T \\alpha = constant\n//\nclass Solver_NU : public Solver\n{\npublic:\n\tSolver_NU() {}\n\tvoid Solve(int l, const QMatrix& Q, const double *p, const schar *y,\n\t\t   double *alpha, double Cp, double Cn, double eps,\n\t\t   SolutionInfo* si, int shrinking)\n\t{\n\t\tthis->si = si;\n\t\tSolver::Solve(l,Q,p,y,alpha,Cp,Cn,eps,si,shrinking);\n\t}\nprivate:\n\tSolutionInfo *si;\n\tint select_working_set(int &i, int &j);\n\tdouble calculate_rho();\n\tbool be_shrunk(int i, double Gmax1, double Gmax2, double Gmax3, double Gmax4);\n\tvoid do_shrinking();\n};\n\n// return 1 if already optimal, return 0 otherwise\nint Solver_NU::select_working_set(int &out_i, int &out_j)\n{\n\t// return i,j such that y_i = y_j and\n\t// i: maximizes -y_i * grad(f)_i, i in I_up(\\alpha)\n\t// j: minimizes the decrease of obj value\n\t//    (if quadratic coefficeint <= 0, replace it with tau)\n\t//    -y_j*grad(f)_j < -y_i*grad(f)_i, j in I_low(\\alpha)\n\n\tdouble Gmaxp = -INF;\n\tdouble Gmaxp2 = -INF;\n\tint Gmaxp_idx = -1;\n\n\tdouble Gmaxn = -INF;\n\tdouble Gmaxn2 = -INF;\n\tint Gmaxn_idx = -1;\n\n\tint Gmin_idx = -1;\n\tdouble obj_diff_min = INF;\n\n\tfor(int t=0;t<active_size;t++)\n\t\tif(y[t]==+1)\n\t\t{\n\t\t\tif(!is_upper_bound(t))\n\t\t\t\tif(-G[t] >= Gmaxp)\n\t\t\t\t{\n\t\t\t\t\tGmaxp = -G[t];\n\t\t\t\t\tGmaxp_idx = t;\n\t\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(!is_lower_bound(t))\n\t\t\t\tif(G[t] >= Gmaxn)\n\t\t\t\t{\n\t\t\t\t\tGmaxn = G[t];\n\t\t\t\t\tGmaxn_idx = t;\n\t\t\t\t}\n\t\t}\n\n\tint ip = Gmaxp_idx;\n\tint in = Gmaxn_idx;\n\tconst Qfloat *Q_ip = NULL;\n\tconst Qfloat *Q_in = NULL;\n\tif(ip != -1) // NULL Q_ip not accessed: Gmaxp=-INF if ip=-1\n\t\tQ_ip = Q->get_Q(ip,active_size);\n\tif(in != -1)\n\t\tQ_in = Q->get_Q(in,active_size);\n\n\tfor(int j=0;j<active_size;j++)\n\t{\n\t\tif(y[j]==+1)\n\t\t{\n\t\t\tif (!is_lower_bound(j))\t\n\t\t\t{\n\t\t\t\tdouble grad_diff=Gmaxp+G[j];\n\t\t\t\tif (G[j] >= Gmaxp2)\n\t\t\t\t\tGmaxp2 = G[j];\n\t\t\t\tif (grad_diff > 0)\n\t\t\t\t{\n\t\t\t\t\tdouble obj_diff; \n\t\t\t\t\tdouble quad_coef = Q_ip[ip]+QD[j]-2*Q_ip[j];\n\t\t\t\t\tif (quad_coef > 0)\n\t\t\t\t\t\tobj_diff = -(grad_diff*grad_diff)/quad_coef;\n\t\t\t\t\telse\n\t\t\t\t\t\tobj_diff = -(grad_diff*grad_diff)/TAU;\n\n\t\t\t\t\tif (obj_diff <= obj_diff_min)\n\t\t\t\t\t{\n\t\t\t\t\t\tGmin_idx=j;\n\t\t\t\t\t\tobj_diff_min = obj_diff;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (!is_upper_bound(j))\n\t\t\t{\n\t\t\t\tdouble grad_diff=Gmaxn-G[j];\n\t\t\t\tif (-G[j] >= Gmaxn2)\n\t\t\t\t\tGmaxn2 = -G[j];\n\t\t\t\tif (grad_diff > 0)\n\t\t\t\t{\n\t\t\t\t\tdouble obj_diff; \n\t\t\t\t\tdouble quad_coef = Q_in[in]+QD[j]-2*Q_in[j];\n\t\t\t\t\tif (quad_coef > 0)\n\t\t\t\t\t\tobj_diff = -(grad_diff*grad_diff)/quad_coef;\n\t\t\t\t\telse\n\t\t\t\t\t\tobj_diff = -(grad_diff*grad_diff)/TAU;\n\n\t\t\t\t\tif (obj_diff <= obj_diff_min)\n\t\t\t\t\t{\n\t\t\t\t\t\tGmin_idx=j;\n\t\t\t\t\t\tobj_diff_min = obj_diff;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif(max(Gmaxp+Gmaxp2,Gmaxn+Gmaxn2) < eps)\n\t\treturn 1;\n\n\tif (y[Gmin_idx] == +1)\n\t\tout_i = Gmaxp_idx;\n\telse\n\t\tout_i = Gmaxn_idx;\n\tout_j = Gmin_idx;\n\n\treturn 0;\n}\n\nbool Solver_NU::be_shrunk(int i, double Gmax1, double Gmax2, double Gmax3, double Gmax4)\n{\n\tif(is_upper_bound(i))\n\t{\n\t\tif(y[i]==+1)\n\t\t\treturn(-G[i] > Gmax1);\n\t\telse\t\n\t\t\treturn(-G[i] > Gmax4);\n\t}\n\telse if(is_lower_bound(i))\n\t{\n\t\tif(y[i]==+1)\n\t\t\treturn(G[i] > Gmax2);\n\t\telse\t\n\t\t\treturn(G[i] > Gmax3);\n\t}\n\telse\n\t\treturn(false);\n}\n\nvoid Solver_NU::do_shrinking()\n{\n\tdouble Gmax1 = -INF;\t// max { -y_i * grad(f)_i | y_i = +1, i in I_up(\\alpha) }\n\tdouble Gmax2 = -INF;\t// max { y_i * grad(f)_i | y_i = +1, i in I_low(\\alpha) }\n\tdouble Gmax3 = -INF;\t// max { -y_i * grad(f)_i | y_i = -1, i in I_up(\\alpha) }\n\tdouble Gmax4 = -INF;\t// max { y_i * grad(f)_i | y_i = -1, i in I_low(\\alpha) }\n\n\t// find maximal violating pair first\n\tint i;\n\tfor(i=0;i<active_size;i++)\n\t{\n\t\tif(!is_upper_bound(i))\n\t\t{\n\t\t\tif(y[i]==+1)\n\t\t\t{\n\t\t\t\tif(-G[i] > Gmax1) Gmax1 = -G[i];\n\t\t\t}\n\t\t\telse\tif(-G[i] > Gmax4) Gmax4 = -G[i];\n\t\t}\n\t\tif(!is_lower_bound(i))\n\t\t{\n\t\t\tif(y[i]==+1)\n\t\t\t{\t\n\t\t\t\tif(G[i] > Gmax2) Gmax2 = G[i];\n\t\t\t}\n\t\t\telse\tif(G[i] > Gmax3) Gmax3 = G[i];\n\t\t}\n\t}\n\n\tif(unshrink == false && max(Gmax1+Gmax2,Gmax3+Gmax4) <= eps*10) \n\t{\n\t\tunshrink = true;\n\t\treconstruct_gradient();\n\t\tactive_size = l;\n\t}\n\n\tfor(i=0;i<active_size;i++)\n\t\tif (be_shrunk(i, Gmax1, Gmax2, Gmax3, Gmax4))\n\t\t{\n\t\t\tactive_size--;\n\t\t\twhile (active_size > i)\n\t\t\t{\n\t\t\t\tif (!be_shrunk(active_size, Gmax1, Gmax2, Gmax3, Gmax4))\n\t\t\t\t{\n\t\t\t\t\tswap_index(i,active_size);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tactive_size--;\n\t\t\t}\n\t\t}\n}\n\ndouble Solver_NU::calculate_rho()\n{\n\tint nr_free1 = 0,nr_free2 = 0;\n\tdouble ub1 = INF, ub2 = INF;\n\tdouble lb1 = -INF, lb2 = -INF;\n\tdouble sum_free1 = 0, sum_free2 = 0;\n\n\tfor(int i=0;i<active_size;i++)\n\t{\n\t\tif(y[i]==+1)\n\t\t{\n\t\t\tif(is_upper_bound(i))\n\t\t\t\tlb1 = max(lb1,G[i]);\n\t\t\telse if(is_lower_bound(i))\n\t\t\t\tub1 = min(ub1,G[i]);\n\t\t\telse\n\t\t\t{\n\t\t\t\t++nr_free1;\n\t\t\t\tsum_free1 += G[i];\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(is_upper_bound(i))\n\t\t\t\tlb2 = max(lb2,G[i]);\n\t\t\telse if(is_lower_bound(i))\n\t\t\t\tub2 = min(ub2,G[i]);\n\t\t\telse\n\t\t\t{\n\t\t\t\t++nr_free2;\n\t\t\t\tsum_free2 += G[i];\n\t\t\t}\n\t\t}\n\t}\n\n\tdouble r1,r2;\n\tif(nr_free1 > 0)\n\t\tr1 = sum_free1/nr_free1;\n\telse\n\t\tr1 = (ub1+lb1)/2;\n\t\n\tif(nr_free2 > 0)\n\t\tr2 = sum_free2/nr_free2;\n\telse\n\t\tr2 = (ub2+lb2)/2;\n\t\n\tsi->r = (r1+r2)/2;\n\treturn (r1-r2)/2;\n}\n\n//\n// Q matrices for various formulations\n//\nclass SVC_Q: public Kernel\n{ \npublic:\n\tSVC_Q(const svm_problem& prob, const svm_parameter& param, const schar *y_)\n\t:Kernel(prob.l, prob.x, param)\n\t{\n\t\tclone(y,y_,prob.l);\n\t\tcache = new Cache(prob.l,(long int)(param.cache_size*(1<<20)));\n\t\tQD = new Qfloat[prob.l];\n\t\tfor(int i=0;i<prob.l;i++)\n\t\t\tQD[i]= (Qfloat)(this->*kernel_function)(i,i);\n\t}\n\t\n\tQfloat *get_Q(int i, int len) const\n\t{\n\t\tQfloat *data;\n\t\tint start, j;\n\t\tif((start = cache->get_data(i,&data,len)) < len)\n\t\t{\n\t\t\tfor(j=start;j<len;j++)\n\t\t\t\tdata[j] = (Qfloat)(y[i]*y[j]*(this->*kernel_function)(i,j));\n\t\t}\n\t\treturn data;\n\t}\n\n\tQfloat *get_QD() const\n\t{\n\t\treturn QD;\n\t}\n\n\tvoid swap_index(int i, int j) const\n\t{\n\t\tcache->swap_index(i,j);\n\t\tKernel::swap_index(i,j);\n\t\tswap(y[i],y[j]);\n\t\tswap(QD[i],QD[j]);\n\t}\n\n\t~SVC_Q()\n\t{\n\t\tdelete[] y;\n\t\tdelete cache;\n\t\tdelete[] QD;\n\t}\nprivate:\n\tschar *y;\n\tCache *cache;\n\tQfloat *QD;\n};\n\nclass ONE_CLASS_Q: public Kernel\n{\npublic:\n\tONE_CLASS_Q(const svm_problem& prob, const svm_parameter& param)\n\t:Kernel(prob.l, prob.x, param)\n\t{\n\t\tcache = new Cache(prob.l,(long int)(param.cache_size*(1<<20)));\n\t\tQD = new Qfloat[prob.l];\n\t\tfor(int i=0;i<prob.l;i++)\n\t\t\tQD[i]= (Qfloat)(this->*kernel_function)(i,i);\n\t}\n\t\n\tQfloat *get_Q(int i, int len) const\n\t{\n\t\tQfloat *data;\n\t\tint start, j;\n\t\tif((start = cache->get_data(i,&data,len)) < len)\n\t\t{\n\t\t\tfor(j=start;j<len;j++)\n\t\t\t\tdata[j] = (Qfloat)(this->*kernel_function)(i,j);\n\t\t}\n\t\treturn data;\n\t}\n\n\tQfloat *get_QD() const\n\t{\n\t\treturn QD;\n\t}\n\n\tvoid swap_index(int i, int j) const\n\t{\n\t\tcache->swap_index(i,j);\n\t\tKernel::swap_index(i,j);\n\t\tswap(QD[i],QD[j]);\n\t}\n\n\t~ONE_CLASS_Q()\n\t{\n\t\tdelete cache;\n\t\tdelete[] QD;\n\t}\nprivate:\n\tCache *cache;\n\tQfloat *QD;\n};\n\nclass SVR_Q: public Kernel\n{ \npublic:\n\tSVR_Q(const svm_problem& prob, const svm_parameter& param)\n\t:Kernel(prob.l, prob.x, param)\n\t{\n\t\tl = prob.l;\n\t\tcache = new Cache(l,(long int)(param.cache_size*(1<<20)));\n\t\tQD = new Qfloat[2*l];\n\t\tsign = new schar[2*l];\n\t\tindex = new int[2*l];\n\t\tfor(int k=0;k<l;k++)\n\t\t{\n\t\t\tsign[k] = 1;\n\t\t\tsign[k+l] = -1;\n\t\t\tindex[k] = k;\n\t\t\tindex[k+l] = k;\n\t\t\tQD[k]= (Qfloat)(this->*kernel_function)(k,k);\n\t\t\tQD[k+l]=QD[k];\n\t\t}\n\t\tbuffer[0] = new Qfloat[2*l];\n\t\tbuffer[1] = new Qfloat[2*l];\n\t\tnext_buffer = 0;\n\t}\n\n\tvoid swap_index(int i, int j) const\n\t{\n\t\tswap(sign[i],sign[j]);\n\t\tswap(index[i],index[j]);\n\t\tswap(QD[i],QD[j]);\n\t}\n\t\n\tQfloat *get_Q(int i, int len) const\n\t{\n\t\tQfloat *data;\n\t\tint j, real_i = index[i];\n\t\tif(cache->get_data(real_i,&data,l) < l)\n\t\t{\n\t\t\tfor(j=0;j<l;j++)\n\t\t\t\tdata[j] = (Qfloat)(this->*kernel_function)(real_i,j);\n\t\t}\n\n\t\t// reorder and copy\n\t\tQfloat *buf = buffer[next_buffer];\n\t\tnext_buffer = 1 - next_buffer;\n\t\tschar si = sign[i];\n\t\tfor(j=0;j<len;j++)\n\t\t\tbuf[j] = (Qfloat) si * (Qfloat) sign[j] * data[index[j]];\n\t\treturn buf;\n\t}\n\n\tQfloat *get_QD() const\n\t{\n\t\treturn QD;\n\t}\n\n\t~SVR_Q()\n\t{\n\t\tdelete cache;\n\t\tdelete[] sign;\n\t\tdelete[] index;\n\t\tdelete[] buffer[0];\n\t\tdelete[] buffer[1];\n\t\tdelete[] QD;\n\t}\nprivate:\n\tint l;\n\tCache *cache;\n\tschar *sign;\n\tint *index;\n\tmutable int next_buffer;\n\tQfloat *buffer[2];\n\tQfloat *QD;\n};\n\n//\n// construct and solve various formulations\n//\nstatic void solve_c_svc(\n\tconst svm_problem *prob, const svm_parameter* param,\n\tdouble *alpha, Solver::SolutionInfo* si, double Cp, double Cn)\n{\n\tint l = prob->l;\n\tdouble *minus_ones = new double[l];\n\tschar *y = new schar[l];\n\n\tint i;\n\n\tfor(i=0;i<l;i++)\n\t{\n\t\talpha[i] = 0;\n\t\tminus_ones[i] = -1;\n\t\tif(prob->y[i] > 0) y[i] = +1; else y[i]=-1;\n\t}\n\n\tSolver s;\n\ts.Solve(l, SVC_Q(*prob,*param,y), minus_ones, y,\n\t\talpha, Cp, Cn, param->eps, si, param->shrinking);\n\n\tdouble sum_alpha=0;\n\tfor(i=0;i<l;i++)\n\t\tsum_alpha += alpha[i];\n\n\tif (Cp==Cn)\n\t\tinfo(\"nu = %f\\n\", sum_alpha/(Cp*prob->l));\n\n\tfor(i=0;i<l;i++)\n\t\talpha[i] *= y[i];\n\n\tdelete[] minus_ones;\n\tdelete[] y;\n}\n\nstatic void solve_nu_svc(\n\tconst svm_problem *prob, const svm_parameter *param,\n\tdouble *alpha, Solver::SolutionInfo* si)\n{\n\tint i;\n\tint l = prob->l;\n\tdouble nu = param->nu;\n\n\tschar *y = new schar[l];\n\n\tfor(i=0;i<l;i++)\n\t\tif(prob->y[i]>0)\n\t\t\ty[i] = +1;\n\t\telse\n\t\t\ty[i] = -1;\n\n\tdouble sum_pos = nu*l/2;\n\tdouble sum_neg = nu*l/2;\n\n\tfor(i=0;i<l;i++)\n\t\tif(y[i] == +1)\n\t\t{\n\t\t\talpha[i] = min(1.0,sum_pos);\n\t\t\tsum_pos -= alpha[i];\n\t\t}\n\t\telse\n\t\t{\n\t\t\talpha[i] = min(1.0,sum_neg);\n\t\t\tsum_neg -= alpha[i];\n\t\t}\n\n\tdouble *zeros = new double[l];\n\n\tfor(i=0;i<l;i++)\n\t\tzeros[i] = 0;\n\n\tSolver_NU s;\n\ts.Solve(l, SVC_Q(*prob,*param,y), zeros, y,\n\t\talpha, 1.0, 1.0, param->eps, si,  param->shrinking);\n\tdouble r = si->r;\n\n\tinfo(\"C = %f\\n\",1/r);\n\n\tfor(i=0;i<l;i++)\n\t\talpha[i] *= y[i]/r;\n\n\tsi->rho /= r;\n\tsi->obj /= (r*r);\n\tsi->upper_bound_p = 1/r;\n\tsi->upper_bound_n = 1/r;\n\n\tdelete[] y;\n\tdelete[] zeros;\n}\n\nstatic void solve_one_class(\n\tconst svm_problem *prob, const svm_parameter *param,\n\tdouble *alpha, Solver::SolutionInfo* si)\n{\n\tint l = prob->l;\n\tdouble *zeros = new double[l];\n\tschar *ones = new schar[l];\n\tint i;\n\n\tint n = (int)(param->nu*prob->l);\t// # of alpha's at upper bound\n\n\tfor(i=0;i<n;i++)\n\t\talpha[i] = 1;\n\tif(n<prob->l)\n\t\talpha[n] = param->nu * prob->l - n;\n\tfor(i=n+1;i<l;i++)\n\t\talpha[i] = 0;\n\n\tfor(i=0;i<l;i++)\n\t{\n\t\tzeros[i] = 0;\n\t\tones[i] = 1;\n\t}\n\n\tSolver s;\n\ts.Solve(l, ONE_CLASS_Q(*prob,*param), zeros, ones,\n\t\talpha, 1.0, 1.0, param->eps, si, param->shrinking);\n\n\tdelete[] zeros;\n\tdelete[] ones;\n}\n\nstatic void solve_epsilon_svr(\n\tconst svm_problem *prob, const svm_parameter *param,\n\tdouble *alpha, Solver::SolutionInfo* si)\n{\n\tint l = prob->l;\n\tdouble *alpha2 = new double[2*l];\n\tdouble *linear_term = new double[2*l];\n\tschar *y = new schar[2*l];\n\tint i;\n\n\tfor(i=0;i<l;i++)\n\t{\n\t\talpha2[i] = 0;\n\t\tlinear_term[i] = param->p - prob->y[i];\n\t\ty[i] = 1;\n\n\t\talpha2[i+l] = 0;\n\t\tlinear_term[i+l] = param->p + prob->y[i];\n\t\ty[i+l] = -1;\n\t}\n\n\tSolver s;\n\ts.Solve(2*l, SVR_Q(*prob,*param), linear_term, y,\n\t\talpha2, param->C, param->C, param->eps, si, param->shrinking);\n\n\tdouble sum_alpha = 0;\n\tfor(i=0;i<l;i++)\n\t{\n\t\talpha[i] = alpha2[i] - alpha2[i+l];\n\t\tsum_alpha += fabs(alpha[i]);\n\t}\n\tinfo(\"nu = %f\\n\",sum_alpha/(param->C*l));\n\n\tdelete[] alpha2;\n\tdelete[] linear_term;\n\tdelete[] y;\n}\n\nstatic void solve_nu_svr(\n\tconst svm_problem *prob, const svm_parameter *param,\n\tdouble *alpha, Solver::SolutionInfo* si)\n{\n\tint l = prob->l;\n\tdouble C = param->C;\n\tdouble *alpha2 = new double[2*l];\n\tdouble *linear_term = new double[2*l];\n\tschar *y = new schar[2*l];\n\tint i;\n\n\tdouble sum = C * param->nu * l / 2;\n\tfor(i=0;i<l;i++)\n\t{\n\t\talpha2[i] = alpha2[i+l] = min(sum,C);\n\t\tsum -= alpha2[i];\n\n\t\tlinear_term[i] = - prob->y[i];\n\t\ty[i] = 1;\n\n\t\tlinear_term[i+l] = prob->y[i];\n\t\ty[i+l] = -1;\n\t}\n\n\tSolver_NU s;\n\ts.Solve(2*l, SVR_Q(*prob,*param), linear_term, y,\n\t\talpha2, C, C, param->eps, si, param->shrinking);\n\n\tinfo(\"epsilon = %f\\n\",-si->r);\n\n\tfor(i=0;i<l;i++)\n\t\talpha[i] = alpha2[i] - alpha2[i+l];\n\n\tdelete[] alpha2;\n\tdelete[] linear_term;\n\tdelete[] y;\n}\n\n//\n// decision_function\n//\nstruct decision_function\n{\n\tdouble *alpha;\n\tdouble rho;\t\n};\n\ndecision_function svm_train_one(\n\tconst svm_problem *prob, const svm_parameter *param,\n\tdouble Cp, double Cn)\n{\n\tdouble *alpha = Malloc(double,prob->l);\n\tSolver::SolutionInfo si;\n\tswitch(param->svm_type)\n\t{\n\t\tcase C_SVC:\n\t\t\tsolve_c_svc(prob,param,alpha,&si,Cp,Cn);\n\t\t\tbreak;\n\t\tcase NU_SVC:\n\t\t\tsolve_nu_svc(prob,param,alpha,&si);\n\t\t\tbreak;\n\t\tcase ONE_CLASS:\n\t\t\tsolve_one_class(prob,param,alpha,&si);\n\t\t\tbreak;\n\t\tcase EPSILON_SVR:\n\t\t\tsolve_epsilon_svr(prob,param,alpha,&si);\n\t\t\tbreak;\n\t\tcase NU_SVR:\n\t\t\tsolve_nu_svr(prob,param,alpha,&si);\n\t\t\tbreak;\n\t}\n\n\tinfo(\"obj = %f, rho = %f\\n\",si.obj,si.rho);\n\n\t// output SVs\n\n\tint nSV = 0;\n\tint nBSV = 0;\n\tfor(int i=0;i<prob->l;i++)\n\t{\n\t\tif(fabs(alpha[i]) > 0)\n\t\t{\n\t\t\t++nSV;\n\t\t\tif(prob->y[i] > 0)\n\t\t\t{\n\t\t\t\tif(fabs(alpha[i]) >= si.upper_bound_p)\n\t\t\t\t\t++nBSV;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(fabs(alpha[i]) >= si.upper_bound_n)\n\t\t\t\t\t++nBSV;\n\t\t\t}\n\t\t}\n\t}\n\n\tinfo(\"nSV = %d, nBSV = %d\\n\",nSV,nBSV);\n\n\tdecision_function f;\n\tf.alpha = alpha;\n\tf.rho = si.rho;\n\treturn f;\n}\n\n//\n// svm_model\n//\nstruct svm_model\n{\n\tsvm_parameter param;\t// parameter\n\tint nr_class;\t\t// number of classes, = 2 in regression/one class svm\n\tint l;\t\t\t// total #SV\n\tsvm_node **SV;\t\t// SVs (SV[l])\n\tdouble **sv_coef;\t// coefficients for SVs in decision functions (sv_coef[k-1][l])\n\tdouble *rho;\t\t// constants in decision functions (rho[k*(k-1)/2])\n\tdouble *probA;\t\t// pariwise probability information\n\tdouble *probB;\n\n\t// for classification only\n\n\tint *label;\t\t// label of each class (label[k])\n\tint *nSV;\t\t// number of SVs for each class (nSV[k])\n\t\t\t\t// nSV[0] + nSV[1] + ... + nSV[k-1] = l\n\t// XXX\n\tint free_sv;\t\t// 1 if svm_model is created by svm_load_model\n\t\t\t\t// 0 if svm_model is created by svm_train\n};\n\n// Platt's binary SVM Probablistic Output: an improvement from Lin et al.\nvoid sigmoid_train(\n\tint l, const double *dec_values, const double *labels, \n\tdouble& A, double& B)\n{\n\tdouble prior1=0, prior0 = 0;\n\tint i;\n\n\tfor (i=0;i<l;i++)\n\t\tif (labels[i] > 0) prior1+=1;\n\t\telse prior0+=1;\n\t\n\tint max_iter=100;\t// Maximal number of iterations\n\tdouble min_step=1e-10;\t// Minimal step taken in line search\n\tdouble sigma=1e-12;\t// For numerically strict PD of Hessian\n\tdouble eps=1e-5;\n\tdouble hiTarget=(prior1+1.0)/(prior1+2.0);\n\tdouble loTarget=1/(prior0+2.0);\n\tdouble *t=Malloc(double,l);\n\tdouble fApB,p,q,h11,h22,h21,g1,g2,det,dA,dB,gd,stepsize;\n\tdouble newA,newB,newf,d1,d2;\n\tint iter; \n\t\n\t// Initial Point and Initial Fun Value\n\tA=0.0; B=log((prior0+1.0)/(prior1+1.0));\n\tdouble fval = 0.0;\n\n\tfor (i=0;i<l;i++)\n\t{\n\t\tif (labels[i]>0) t[i]=hiTarget;\n\t\telse t[i]=loTarget;\n\t\tfApB = dec_values[i]*A+B;\n\t\tif (fApB>=0)\n\t\t\tfval += t[i]*fApB + log(1+exp(-fApB));\n\t\telse\n\t\t\tfval += (t[i] - 1)*fApB +log(1+exp(fApB));\n\t}\n\tfor (iter=0;iter<max_iter;iter++)\n\t{\n\t\t// Update Gradient and Hessian (use H' = H + sigma I)\n\t\th11=sigma; // numerically ensures strict PD\n\t\th22=sigma;\n\t\th21=0.0;g1=0.0;g2=0.0;\n\t\tfor (i=0;i<l;i++)\n\t\t{\n\t\t\tfApB = dec_values[i]*A+B;\n\t\t\tif (fApB >= 0)\n\t\t\t{\n\t\t\t\tp=exp(-fApB)/(1.0+exp(-fApB));\n\t\t\t\tq=1.0/(1.0+exp(-fApB));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tp=1.0/(1.0+exp(fApB));\n\t\t\t\tq=exp(fApB)/(1.0+exp(fApB));\n\t\t\t}\n\t\t\td2=p*q;\n\t\t\th11+=dec_values[i]*dec_values[i]*d2;\n\t\t\th22+=d2;\n\t\t\th21+=dec_values[i]*d2;\n\t\t\td1=t[i]-p;\n\t\t\tg1+=dec_values[i]*d1;\n\t\t\tg2+=d1;\n\t\t}\n\n\t\t// Stopping Criteria\n\t\tif (fabs(g1)<eps && fabs(g2)<eps)\n\t\t\tbreak;\n\n\t\t// Finding Newton direction: -inv(H') * g\n\t\tdet=h11*h22-h21*h21;\n\t\tdA=-(h22*g1 - h21 * g2) / det;\n\t\tdB=-(-h21*g1+ h11 * g2) / det;\n\t\tgd=g1*dA+g2*dB;\n\n\n\t\tstepsize = 1;\t\t// Line Search\n\t\twhile (stepsize >= min_step)\n\t\t{\n\t\t\tnewA = A + stepsize * dA;\n\t\t\tnewB = B + stepsize * dB;\n\n\t\t\t// New function value\n\t\t\tnewf = 0.0;\n\t\t\tfor (i=0;i<l;i++)\n\t\t\t{\n\t\t\t\tfApB = dec_values[i]*newA+newB;\n\t\t\t\tif (fApB >= 0)\n\t\t\t\t\tnewf += t[i]*fApB + log(1+exp(-fApB));\n\t\t\t\telse\n\t\t\t\t\tnewf += (t[i] - 1)*fApB +log(1+exp(fApB));\n\t\t\t}\n\t\t\t// Check sufficient decrease\n\t\t\tif (newf<fval+0.0001*stepsize*gd)\n\t\t\t{\n\t\t\t\tA=newA;B=newB;fval=newf;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse\n\t\t\t\tstepsize = stepsize / 2.0;\n\t\t}\n\n\t\tif (stepsize < min_step)\n\t\t{\n\t\t\tinfo(\"Line search fails in two-class probability estimates\\n\");\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (iter>=max_iter)\n\t\tinfo(\"Reaching maximal iterations in two-class probability estimates\\n\");\n\tfree(t);\n}\n\ndouble sigmoid_predict(double decision_value, double A, double B)\n{\n\tdouble fApB = decision_value*A+B;\n\tif (fApB >= 0)\n\t\treturn exp(-fApB)/(1.0+exp(-fApB));\n\telse\n\t\treturn 1.0/(1+exp(fApB)) ;\n}\n\n// Method 2 from the multiclass_prob paper by Wu, Lin, and Weng\nvoid multiclass_probability(int k, double **r, double *p)\n{\n\tint t,j;\n\tint iter = 0, max_iter=max(100,k);\n\tdouble **Q=Malloc(double *,k);\n\tdouble *Qp=Malloc(double,k);\n\tdouble pQp, eps=0.005/k;\n\t\n\tfor (t=0;t<k;t++)\n\t{\n\t\tp[t]=1.0/k;  // Valid if k = 1\n\t\tQ[t]=Malloc(double,k);\n\t\tQ[t][t]=0;\n\t\tfor (j=0;j<t;j++)\n\t\t{\n\t\t\tQ[t][t]+=r[j][t]*r[j][t];\n\t\t\tQ[t][j]=Q[j][t];\n\t\t}\n\t\tfor (j=t+1;j<k;j++)\n\t\t{\n\t\t\tQ[t][t]+=r[j][t]*r[j][t];\n\t\t\tQ[t][j]=-r[j][t]*r[t][j];\n\t\t}\n\t}\n\tfor (iter=0;iter<max_iter;iter++)\n\t{\n\t\t// stopping condition, recalculate QP,pQP for numerical accuracy\n\t\tpQp=0;\n\t\tfor (t=0;t<k;t++)\n\t\t{\n\t\t\tQp[t]=0;\n\t\t\tfor (j=0;j<k;j++)\n\t\t\t\tQp[t]+=Q[t][j]*p[j];\n\t\t\tpQp+=p[t]*Qp[t];\n\t\t}\n\t\tdouble max_error=0;\n\t\tfor (t=0;t<k;t++)\n\t\t{\n\t\t\tdouble error=fabs(Qp[t]-pQp);\n\t\t\tif (error>max_error)\n\t\t\t\tmax_error=error;\n\t\t}\n\t\tif (max_error<eps) break;\n\t\t\n\t\tfor (t=0;t<k;t++)\n\t\t{\n\t\t\tdouble diff=(-Qp[t]+pQp)/Q[t][t];\n\t\t\tp[t]+=diff;\n\t\t\tpQp=(pQp+diff*(diff*Q[t][t]+2*Qp[t]))/(1+diff)/(1+diff);\n\t\t\tfor (j=0;j<k;j++)\n\t\t\t{\n\t\t\t\tQp[j]=(Qp[j]+diff*Q[t][j])/(1+diff);\n\t\t\t\tp[j]/=(1+diff);\n\t\t\t}\n\t\t}\n\t}\n\tif (iter>=max_iter)\n\t\tinfo(\"Exceeds max_iter in multiclass_prob\\n\");\n\tfor(t=0;t<k;t++) free(Q[t]);\n\tfree(Q);\n\tfree(Qp);\n}\n\n// Cross-validation decision values for probability estimates\nvoid svm_binary_svc_probability(\n\tconst svm_problem *prob, const svm_parameter *param,\n\tdouble Cp, double Cn, double& probA, double& probB)\n{\n\tint i;\n\tint nr_fold = 5;\n\tint *perm = Malloc(int,prob->l);\n\tdouble *dec_values = Malloc(double,prob->l);\n\n\t// random shuffle\n\tfor(i=0;i<prob->l;i++) perm[i]=i;\n\tfor(i=0;i<prob->l;i++)\n\t{\n\t\tint j = i+rand()%(prob->l-i);\n\t\tswap(perm[i],perm[j]);\n\t}\n\tfor(i=0;i<nr_fold;i++)\n\t{\n\t\tint begin = i*prob->l/nr_fold;\n\t\tint end = (i+1)*prob->l/nr_fold;\n\t\tint j,k;\n\t\tstruct svm_problem subprob;\n\n\t\tsubprob.l = prob->l-(end-begin);\n\t\tsubprob.x = Malloc(struct svm_node*,subprob.l);\n\t\tsubprob.y = Malloc(double,subprob.l);\n\t\t\t\n\t\tk=0;\n\t\tfor(j=0;j<begin;j++)\n\t\t{\n\t\t\tsubprob.x[k] = prob->x[perm[j]];\n\t\t\tsubprob.y[k] = prob->y[perm[j]];\n\t\t\t++k;\n\t\t}\n\t\tfor(j=end;j<prob->l;j++)\n\t\t{\n\t\t\tsubprob.x[k] = prob->x[perm[j]];\n\t\t\tsubprob.y[k] = prob->y[perm[j]];\n\t\t\t++k;\n\t\t}\n\t\tint p_count=0,n_count=0;\n\t\tfor(j=0;j<k;j++)\n\t\t\tif(subprob.y[j]>0)\n\t\t\t\tp_count++;\n\t\t\telse\n\t\t\t\tn_count++;\n\n\t\tif(p_count==0 && n_count==0)\n\t\t\tfor(j=begin;j<end;j++)\n\t\t\t\tdec_values[perm[j]] = 0;\n\t\telse if(p_count > 0 && n_count == 0)\n\t\t\tfor(j=begin;j<end;j++)\n\t\t\t\tdec_values[perm[j]] = 1;\n\t\telse if(p_count == 0 && n_count > 0)\n\t\t\tfor(j=begin;j<end;j++)\n\t\t\t\tdec_values[perm[j]] = -1;\n\t\telse\n\t\t{\n\t\t\tsvm_parameter subparam = *param;\n\t\t\tsubparam.probability=0;\n\t\t\tsubparam.C=1.0;\n\t\t\tsubparam.nr_weight=2;\n\t\t\tsubparam.weight_label = Malloc(int,2);\n\t\t\tsubparam.weight = Malloc(double,2);\n\t\t\tsubparam.weight_label[0]=+1;\n\t\t\tsubparam.weight_label[1]=-1;\n\t\t\tsubparam.weight[0]=Cp;\n\t\t\tsubparam.weight[1]=Cn;\n\t\t\tstruct svm_model *submodel = svm_train(&subprob,&subparam);\n\t\t\tfor(j=begin;j<end;j++)\n\t\t\t{\n\t\t\t\tsvm_predict_values(submodel,prob->x[perm[j]],&(dec_values[perm[j]])); \n\t\t\t\t// ensure +1 -1 order; reason not using CV subroutine\n\t\t\t\tdec_values[perm[j]] *= submodel->label[0];\n\t\t\t}\t\t\n\t\t\tsvm_destroy_model(submodel);\n\t\t\tsvm_destroy_param(&subparam);\n\t\t}\n\t\tfree(subprob.x);\n\t\tfree(subprob.y);\n\t}\t\t\n\tsigmoid_train(prob->l,dec_values,prob->y,probA,probB);\n\tfree(dec_values);\n\tfree(perm);\n}\n\n// Return parameter of a Laplace distribution \ndouble svm_svr_probability(\n\tconst svm_problem *prob, const svm_parameter *param)\n{\n\tint i;\n\tint nr_fold = 5;\n\tdouble *ymv = Malloc(double,prob->l);\n\tdouble mae = 0;\n\n\tsvm_parameter newparam = *param;\n\tnewparam.probability = 0;\n\tsvm_cross_validation(prob,&newparam,nr_fold,ymv);\n\tfor(i=0;i<prob->l;i++)\n\t{\n\t\tymv[i]=prob->y[i]-ymv[i];\n\t\tmae += fabs(ymv[i]);\n\t}\t\t\n\tmae /= prob->l;\n\tdouble std=sqrt(2*mae*mae);\n\tint count=0;\n\tmae=0;\n\tfor(i=0;i<prob->l;i++)\n\t\tif (fabs(ymv[i]) > 5*std) \n\t\t\tcount=count+1;\n\t\telse \n\t\t\tmae+=fabs(ymv[i]);\n\tmae /= (prob->l-count);\n\tinfo(\"Prob. model for test data: target value = predicted value + z,\\nz: Laplace distribution e^(-|z|/sigma)/(2sigma),sigma= %g\\n\",mae);\n\tfree(ymv);\n\treturn mae;\n}\n\n\n// label: label name, start: begin of each class, count: #data of classes, perm: indices to the original data\n// perm, length l, must be allocated before calling this subroutine\nvoid svm_group_classes(const svm_problem *prob, int *nr_class_ret, int **label_ret, int **start_ret, int **count_ret, int *perm)\n{\n\tint l = prob->l;\n\tint max_nr_class = 16;\n\tint nr_class = 0;\n\tint *label = Malloc(int,max_nr_class);\n\tint *count = Malloc(int,max_nr_class);\n\tint *data_label = Malloc(int,l);\t\n\tint i;\n\n\tfor(i=0;i<l;i++)\n\t{\n\t\tint this_label = (int)prob->y[i];\n\t\tint j;\n\t\tfor(j=0;j<nr_class;j++)\n\t\t{\n\t\t\tif(this_label == label[j])\n\t\t\t{\n\t\t\t\t++count[j];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tdata_label[i] = j;\n\t\tif(j == nr_class)\n\t\t{\n\t\t\tif(nr_class == max_nr_class)\n\t\t\t{\n\t\t\t\tmax_nr_class *= 2;\n\t\t\t\tlabel = (int *)realloc(label,max_nr_class*sizeof(int));\n\t\t\t\tcount = (int *)realloc(count,max_nr_class*sizeof(int));\n\t\t\t}\n\t\t\tlabel[nr_class] = this_label;\n\t\t\tcount[nr_class] = 1;\n\t\t\t++nr_class;\n\t\t}\n\t}\n\n\tint *start = Malloc(int,nr_class);\n\tstart[0] = 0;\n\tfor(i=1;i<nr_class;i++)\n\t\tstart[i] = start[i-1]+count[i-1];\n\tfor(i=0;i<l;i++)\n\t{\n\t\tperm[start[data_label[i]]] = i;\n\t\t++start[data_label[i]];\n\t}\n\tstart[0] = 0;\n\tfor(i=1;i<nr_class;i++)\n\t\tstart[i] = start[i-1]+count[i-1];\n\n\t*nr_class_ret = nr_class;\n\t*label_ret = label;\n\t*start_ret = start;\n\t*count_ret = count;\n\tfree(data_label);\n}\n\n//\n// Interface functions\n//\nsvm_model *svm_train(const svm_problem *prob, const svm_parameter *param)\n{\n\tsvm_model *model = Malloc(svm_model,1);\n\tmodel->param = *param;\n\tmodel->free_sv = 0;\t// XXX\n\n\tif(param->svm_type == ONE_CLASS ||\n\t   param->svm_type == EPSILON_SVR ||\n\t   param->svm_type == NU_SVR)\n\t{\n\t\t// regression or one-class-svm\n\t\tmodel->nr_class = 2;\n\t\tmodel->label = NULL;\n\t\tmodel->nSV = NULL;\n\t\tmodel->probA = NULL; model->probB = NULL;\n\t\tmodel->sv_coef = Malloc(double *,1);\n\n\t\tif(param->probability && \n\t\t   (param->svm_type == EPSILON_SVR ||\n\t\t    param->svm_type == NU_SVR))\n\t\t{\n\t\t\tmodel->probA = Malloc(double,1);\n\t\t\tmodel->probA[0] = svm_svr_probability(prob,param);\n\t\t}\n\n\t\tdecision_function f = svm_train_one(prob,param,0,0);\n\t\tmodel->rho = Malloc(double,1);\n\t\tmodel->rho[0] = f.rho;\n\n\t\tint nSV = 0;\n\t\tint i;\n\t\tfor(i=0;i<prob->l;i++)\n\t\t\tif(fabs(f.alpha[i]) > 0) ++nSV;\n\t\tmodel->l = nSV;\n\t\tmodel->SV = Malloc(svm_node *,nSV);\n\t\tmodel->sv_coef[0] = Malloc(double,nSV);\n\t\tint j = 0;\n\t\tfor(i=0;i<prob->l;i++)\n\t\t\tif(fabs(f.alpha[i]) > 0)\n\t\t\t{\n\t\t\t\tmodel->SV[j] = prob->x[i];\n\t\t\t\tmodel->sv_coef[0][j] = f.alpha[i];\n\t\t\t\t++j;\n\t\t\t}\t\t\n\n\t\tfree(f.alpha);\n\t}\n\telse\n\t{\n\t\t// classification\n\t\tint l = prob->l;\n\t\tint nr_class;\n\t\tint *label = NULL;\n\t\tint *start = NULL;\n\t\tint *count = NULL;\n\t\tint *perm = Malloc(int,l);\n\n\t\t// group training data of the same class\n\t\tsvm_group_classes(prob,&nr_class,&label,&start,&count,perm);\t\t\n\t\tsvm_node **x = Malloc(svm_node *,l);\n\t\tint i;\n\t\tfor(i=0;i<l;i++)\n\t\t\tx[i] = prob->x[perm[i]];\n\n\t\t// calculate weighted C\n\n\t\tdouble *weighted_C = Malloc(double, nr_class);\n\t\tfor(i=0;i<nr_class;i++)\n\t\t\tweighted_C[i] = param->C;\n\t\tfor(i=0;i<param->nr_weight;i++)\n\t\t{\t\n\t\t\tint j;\n\t\t\tfor(j=0;j<nr_class;j++)\n\t\t\t\tif(param->weight_label[i] == label[j])\n\t\t\t\t\tbreak;\n\t\t\tif(j == nr_class)\n\t\t\t\tfprintf(stderr,\"warning: class label %d specified in weight is not found\\n\", param->weight_label[i]);\n\t\t\telse\n\t\t\t\tweighted_C[j] *= param->weight[i];\n\t\t}\n\n\t\t// train k*(k-1)/2 models\n\t\t\n\t\tbool *nonzero = Malloc(bool,l);\n\t\tfor(i=0;i<l;i++)\n\t\t\tnonzero[i] = false;\n\t\tdecision_function *f = Malloc(decision_function,nr_class*(nr_class-1)/2);\n\n\t\tdouble *probA=NULL,*probB=NULL;\n\t\tif (param->probability)\n\t\t{\n\t\t\tprobA=Malloc(double,nr_class*(nr_class-1)/2);\n\t\t\tprobB=Malloc(double,nr_class*(nr_class-1)/2);\n\t\t}\n\n\t\tint p = 0;\n\t\tfor(i=0;i<nr_class;i++)\n\t\t\tfor(int j=i+1;j<nr_class;j++)\n\t\t\t{\n\t\t\t\tsvm_problem sub_prob;\n\t\t\t\tint si = start[i], sj = start[j];\n\t\t\t\tint ci = count[i], cj = count[j];\n\t\t\t\tsub_prob.l = ci+cj;\n\t\t\t\tsub_prob.x = Malloc(svm_node *,sub_prob.l);\n\t\t\t\tsub_prob.y = Malloc(double,sub_prob.l);\n\t\t\t\tint k;\n\t\t\t\tfor(k=0;k<ci;k++)\n\t\t\t\t{\n\t\t\t\t\tsub_prob.x[k] = x[si+k];\n\t\t\t\t\tsub_prob.y[k] = +1;\n\t\t\t\t}\n\t\t\t\tfor(k=0;k<cj;k++)\n\t\t\t\t{\n\t\t\t\t\tsub_prob.x[ci+k] = x[sj+k];\n\t\t\t\t\tsub_prob.y[ci+k] = -1;\n\t\t\t\t}\n\n\t\t\t\tif(param->probability)\n\t\t\t\t\tsvm_binary_svc_probability(&sub_prob,param,weighted_C[i],weighted_C[j],probA[p],probB[p]);\n\n\t\t\t\tf[p] = svm_train_one(&sub_prob,param,weighted_C[i],weighted_C[j]);\n\t\t\t\tfor(k=0;k<ci;k++)\n\t\t\t\t\tif(!nonzero[si+k] && fabs(f[p].alpha[k]) > 0)\n\t\t\t\t\t\tnonzero[si+k] = true;\n\t\t\t\tfor(k=0;k<cj;k++)\n\t\t\t\t\tif(!nonzero[sj+k] && fabs(f[p].alpha[ci+k]) > 0)\n\t\t\t\t\t\tnonzero[sj+k] = true;\n\t\t\t\tfree(sub_prob.x);\n\t\t\t\tfree(sub_prob.y);\n\t\t\t\t++p;\n\t\t\t}\n\n\t\t// build output\n\n\t\tmodel->nr_class = nr_class;\n\t\t\n\t\tmodel->label = Malloc(int,nr_class);\n\t\tfor(i=0;i<nr_class;i++)\n\t\t\tmodel->label[i] = label[i];\n\t\t\n\t\tmodel->rho = Malloc(double,nr_class*(nr_class-1)/2);\n\t\tfor(i=0;i<nr_class*(nr_class-1)/2;i++)\n\t\t\tmodel->rho[i] = f[i].rho;\n\n\t\tif(param->probability)\n\t\t{\n\t\t\tmodel->probA = Malloc(double,nr_class*(nr_class-1)/2);\n\t\t\tmodel->probB = Malloc(double,nr_class*(nr_class-1)/2);\n\t\t\tfor(i=0;i<nr_class*(nr_class-1)/2;i++)\n\t\t\t{\n\t\t\t\tmodel->probA[i] = probA[i];\n\t\t\t\tmodel->probB[i] = probB[i];\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tmodel->probA=NULL;\n\t\t\tmodel->probB=NULL;\n\t\t}\n\n\t\tint total_sv = 0;\n\t\tint *nz_count = Malloc(int,nr_class);\n\t\tmodel->nSV = Malloc(int,nr_class);\n\t\tfor(i=0;i<nr_class;i++)\n\t\t{\n\t\t\tint nSV = 0;\n\t\t\tfor(int j=0;j<count[i];j++)\n\t\t\t\tif(nonzero[start[i]+j])\n\t\t\t\t{\t\n\t\t\t\t\t++nSV;\n\t\t\t\t\t++total_sv;\n\t\t\t\t}\n\t\t\tmodel->nSV[i] = nSV;\n\t\t\tnz_count[i] = nSV;\n\t\t}\n\t\t\n\t\tinfo(\"Total nSV = %d\\n\",total_sv);\n\n\t\tmodel->l = total_sv;\n\t\tmodel->SV = Malloc(svm_node *,total_sv);\n\t\tp = 0;\n\t\tfor(i=0;i<l;i++)\n\t\t\tif(nonzero[i]) model->SV[p++] = x[i];\n\n\t\tint *nz_start = Malloc(int,nr_class);\n\t\tnz_start[0] = 0;\n\t\tfor(i=1;i<nr_class;i++)\n\t\t\tnz_start[i] = nz_start[i-1]+nz_count[i-1];\n\n\t\tmodel->sv_coef = Malloc(double *,nr_class-1);\n\t\tfor(i=0;i<nr_class-1;i++)\n\t\t\tmodel->sv_coef[i] = Malloc(double,total_sv);\n\n\t\tp = 0;\n\t\tfor(i=0;i<nr_class;i++)\n\t\t\tfor(int j=i+1;j<nr_class;j++)\n\t\t\t{\n\t\t\t\t// classifier (i,j): coefficients with\n\t\t\t\t// i are in sv_coef[j-1][nz_start[i]...],\n\t\t\t\t// j are in sv_coef[i][nz_start[j]...]\n\n\t\t\t\tint si = start[i];\n\t\t\t\tint sj = start[j];\n\t\t\t\tint ci = count[i];\n\t\t\t\tint cj = count[j];\n\t\t\t\t\n\t\t\t\tint q = nz_start[i];\n\t\t\t\tint k;\n\t\t\t\tfor(k=0;k<ci;k++)\n\t\t\t\t\tif(nonzero[si+k])\n\t\t\t\t\t\tmodel->sv_coef[j-1][q++] = f[p].alpha[k];\n\t\t\t\tq = nz_start[j];\n\t\t\t\tfor(k=0;k<cj;k++)\n\t\t\t\t\tif(nonzero[sj+k])\n\t\t\t\t\t\tmodel->sv_coef[i][q++] = f[p].alpha[ci+k];\n\t\t\t\t++p;\n\t\t\t}\n\t\t\n\t\tfree(label);\n\t\tfree(probA);\n\t\tfree(probB);\n\t\tfree(count);\n\t\tfree(perm);\n\t\tfree(start);\n\t\tfree(x);\n\t\tfree(weighted_C);\n\t\tfree(nonzero);\n\t\tfor(i=0;i<nr_class*(nr_class-1)/2;i++)\n\t\t\tfree(f[i].alpha);\n\t\tfree(f);\n\t\tfree(nz_count);\n\t\tfree(nz_start);\n\t}\n\treturn model;\n}\n\n// Stratified cross validation\nvoid svm_cross_validation(const svm_problem *prob, const svm_parameter *param, int nr_fold, double *target)\n{\n\tint i;\n\tint *fold_start = Malloc(int,nr_fold+1);\n\tint l = prob->l;\n\tint *perm = Malloc(int,l);\n\tint nr_class;\n\n\t// stratified cv may not give leave-one-out rate\n\t// Each class to l folds -> some folds may have zero elements\n\tif((param->svm_type == C_SVC ||\n\t    param->svm_type == NU_SVC) && nr_fold < l)\n\t{\n\t\tint *start = NULL;\n\t\tint *label = NULL;\n\t\tint *count = NULL;\n\t\tsvm_group_classes(prob,&nr_class,&label,&start,&count,perm);\n\n\t\t// random shuffle and then data grouped by fold using the array perm\n\t\tint *fold_count = Malloc(int,nr_fold);\n\t\tint c;\n\t\tint *index = Malloc(int,l);\n\t\tfor(i=0;i<l;i++)\n\t\t\tindex[i]=perm[i];\n\t\tfor (c=0; c<nr_class; c++) \n\t\t\tfor(i=0;i<count[c];i++)\n\t\t\t{\n\t\t\t\tint j = i+rand()%(count[c]-i);\n\t\t\t\tswap(index[start[c]+j],index[start[c]+i]);\n\t\t\t}\n\t\tfor(i=0;i<nr_fold;i++)\n\t\t{\n\t\t\tfold_count[i] = 0;\n\t\t\tfor (c=0; c<nr_class;c++)\n\t\t\t\tfold_count[i]+=(i+1)*count[c]/nr_fold-i*count[c]/nr_fold;\n\t\t}\n\t\tfold_start[0]=0;\n\t\tfor (i=1;i<=nr_fold;i++)\n\t\t\tfold_start[i] = fold_start[i-1]+fold_count[i-1];\n\t\tfor (c=0; c<nr_class;c++)\n\t\t\tfor(i=0;i<nr_fold;i++)\n\t\t\t{\n\t\t\t\tint begin = start[c]+i*count[c]/nr_fold;\n\t\t\t\tint end = start[c]+(i+1)*count[c]/nr_fold;\n\t\t\t\tfor(int j=begin;j<end;j++)\n\t\t\t\t{\n\t\t\t\t\tperm[fold_start[i]] = index[j];\n\t\t\t\t\tfold_start[i]++;\n\t\t\t\t}\n\t\t\t}\n\t\tfold_start[0]=0;\n\t\tfor (i=1;i<=nr_fold;i++)\n\t\t\tfold_start[i] = fold_start[i-1]+fold_count[i-1];\n\t\tfree(start);\t\n\t\tfree(label);\n\t\tfree(count);\t\n\t\tfree(index);\n\t\tfree(fold_count);\n\t}\n\telse\n\t{\n\t\tfor(i=0;i<l;i++) perm[i]=i;\n\t\tfor(i=0;i<l;i++)\n\t\t{\n\t\t\tint j = i+rand()%(l-i);\n\t\t\tswap(perm[i],perm[j]);\n\t\t}\n\t\tfor(i=0;i<=nr_fold;i++)\n\t\t\tfold_start[i]=i*l/nr_fold;\n\t}\n\n\tfor(i=0;i<nr_fold;i++)\n\t{\n\t\tint begin = fold_start[i];\n\t\tint end = fold_start[i+1];\n\t\tint j,k;\n\t\tstruct svm_problem subprob;\n\n\t\tsubprob.l = l-(end-begin);\n\t\tsubprob.x = Malloc(struct svm_node*,subprob.l);\n\t\tsubprob.y = Malloc(double,subprob.l);\n\t\t\t\n\t\tk=0;\n\t\tfor(j=0;j<begin;j++)\n\t\t{\n\t\t\tsubprob.x[k] = prob->x[perm[j]];\n\t\t\tsubprob.y[k] = prob->y[perm[j]];\n\t\t\t++k;\n\t\t}\n\t\tfor(j=end;j<l;j++)\n\t\t{\n\t\t\tsubprob.x[k] = prob->x[perm[j]];\n\t\t\tsubprob.y[k] = prob->y[perm[j]];\n\t\t\t++k;\n\t\t}\n\t\tstruct svm_model *submodel = svm_train(&subprob,param);\n\t\tif(param->probability && \n\t\t   (param->svm_type == C_SVC || param->svm_type == NU_SVC))\n\t\t{\n\t\t\tdouble *prob_estimates=Malloc(double,svm_get_nr_class(submodel));\n\t\t\tfor(j=begin;j<end;j++)\n\t\t\t\ttarget[perm[j]] = svm_predict_probability(submodel,prob->x[perm[j]],prob_estimates);\n\t\t\tfree(prob_estimates);\t\t\t\n\t\t}\n\t\telse\n\t\t\tfor(j=begin;j<end;j++)\n\t\t\t\ttarget[perm[j]] = svm_predict(submodel,prob->x[perm[j]]);\n\t\tsvm_destroy_model(submodel);\n\t\tfree(subprob.x);\n\t\tfree(subprob.y);\n\t}\t\t\n\tfree(fold_start);\n\tfree(perm);\t\n}\n\n\nint svm_get_svm_type(const svm_model *model)\n{\n\treturn model->param.svm_type;\n}\n\nint svm_get_nr_class(const svm_model *model)\n{\n\treturn model->nr_class;\n}\n\nvoid svm_get_labels(const svm_model *model, int* label)\n{\n\tif (model->label != NULL)\n\t\tfor(int i=0;i<model->nr_class;i++)\n\t\t\tlabel[i] = model->label[i];\n}\n\ndouble svm_get_svr_probability(const svm_model *model)\n{\n\tif ((model->param.svm_type == EPSILON_SVR || model->param.svm_type == NU_SVR) &&\n\t    model->probA!=NULL)\n\t\treturn model->probA[0];\n\telse\n\t{\n\t\tfprintf(stderr,\"Model doesn't contain information for SVR probability inference\\n\");\n\t\treturn 0;\n\t}\n}\n\nvoid svm_predict_values(const svm_model *model, const svm_node *x, double* dec_values)\n{\n\tif(model->param.svm_type == ONE_CLASS ||\n\t   model->param.svm_type == EPSILON_SVR ||\n\t   model->param.svm_type == NU_SVR)\n\t{\n\t\tdouble *sv_coef = model->sv_coef[0];\n\t\tdouble sum = 0;\n\t\tfor(int i=0;i<model->l;i++)\n\t\t\tsum += sv_coef[i] * Kernel::k_function(x,model->SV[i],model->param);\n\t\tsum -= model->rho[0];\n\t\t*dec_values = sum;\n\t}\n\telse\n\t{\n\t\tint i;\n\t\tint nr_class = model->nr_class;\n\t\tint l = model->l;\n\t\t\n\t\tdouble *kvalue = Malloc(double,l);\n\t\tfor(i=0;i<l;i++)\n\t\t\tkvalue[i] = Kernel::k_function(x,model->SV[i],model->param);\n\n\t\tint *start = Malloc(int,nr_class);\n\t\tstart[0] = 0;\n\t\tfor(i=1;i<nr_class;i++)\n\t\t\tstart[i] = start[i-1]+model->nSV[i-1];\n\n\t\tint p=0;\n\t\tfor(i=0;i<nr_class;i++)\n\t\t\tfor(int j=i+1;j<nr_class;j++)\n\t\t\t{\n\t\t\t\tdouble sum = 0;\n\t\t\t\tint si = start[i];\n\t\t\t\tint sj = start[j];\n\t\t\t\tint ci = model->nSV[i];\n\t\t\t\tint cj = model->nSV[j];\n\t\t\t\t\n\t\t\t\tint k;\n\t\t\t\tdouble *coef1 = model->sv_coef[j-1];\n\t\t\t\tdouble *coef2 = model->sv_coef[i];\n\t\t\t\tfor(k=0;k<ci;k++)\n\t\t\t\t\tsum += coef1[si+k] * kvalue[si+k];\n\t\t\t\tfor(k=0;k<cj;k++)\n\t\t\t\t\tsum += coef2[sj+k] * kvalue[sj+k];\n\t\t\t\tsum -= model->rho[p];\n\t\t\t\tdec_values[p] = sum;\n\t\t\t\tp++;\n\t\t\t}\n\n\t\tfree(kvalue);\n\t\tfree(start);\n\t}\n}\n\ndouble svm_predict(const svm_model *model, const svm_node *x)\n{\n\tif(model->param.svm_type == ONE_CLASS ||\n\t   model->param.svm_type == EPSILON_SVR ||\n\t   model->param.svm_type == NU_SVR)\n\t{\n\t\tdouble res;\n\t\tsvm_predict_values(model, x, &res);\n\t\t\n\t\tif(model->param.svm_type == ONE_CLASS)\n\t\t\treturn (res>0)?1:-1;\n\t\telse\n\t\t\treturn res;\n\t}\n\telse\n\t{\n\t\tint i;\n\t\tint nr_class = model->nr_class;\n\t\tdouble *dec_values = Malloc(double, nr_class*(nr_class-1)/2);\n\t\tsvm_predict_values(model, x, dec_values);\n\n\t\tint *vote = Malloc(int,nr_class);\n\t\tfor(i=0;i<nr_class;i++)\n\t\t\tvote[i] = 0;\n\t\tint pos=0;\n\t\tfor(i=0;i<nr_class;i++)\n\t\t\tfor(int j=i+1;j<nr_class;j++)\n\t\t\t{\n\t\t\t\tif(dec_values[pos++] > 0)\n\t\t\t\t\t++vote[i];\n\t\t\t\telse\n\t\t\t\t\t++vote[j];\n\t\t\t}\n\n\t\tint vote_max_idx = 0;\n\t\tfor(i=1;i<nr_class;i++)\n\t\t\tif(vote[i] > vote[vote_max_idx])\n\t\t\t\tvote_max_idx = i;\n\t\tfree(vote);\n\t\tfree(dec_values);\n\t\treturn model->label[vote_max_idx];\n\t}\n}\n\ndouble svm_predict_probability(\n\tconst svm_model *model, const svm_node *x, double *prob_estimates)\n{\n\tif ((model->param.svm_type == C_SVC || model->param.svm_type == NU_SVC) &&\n\t    model->probA!=NULL && model->probB!=NULL)\n\t{\n\t\tint i;\n\t\tint nr_class = model->nr_class;\n\t\tdouble *dec_values = Malloc(double, nr_class*(nr_class-1)/2);\n\t\tsvm_predict_values(model, x, dec_values);\n\n\t\tdouble min_prob=1e-7;\n\t\tdouble **pairwise_prob=Malloc(double *,nr_class);\n\t\tfor(i=0;i<nr_class;i++)\n\t\t\tpairwise_prob[i]=Malloc(double,nr_class);\n\t\tint k=0;\n\t\tfor(i=0;i<nr_class;i++)\n\t\t\tfor(int j=i+1;j<nr_class;j++)\n\t\t\t{\n\t\t\t\tpairwise_prob[i][j]=min(max(sigmoid_predict(dec_values[k],model->probA[k],model->probB[k]),min_prob),1-min_prob);\n\t\t\t\tpairwise_prob[j][i]=1-pairwise_prob[i][j];\n\t\t\t\tk++;\n\t\t\t}\n\t\tmulticlass_probability(nr_class,pairwise_prob,prob_estimates);\n\n\t\tint prob_max_idx = 0;\n\t\tfor(i=1;i<nr_class;i++)\n\t\t\tif(prob_estimates[i] > prob_estimates[prob_max_idx])\n\t\t\t\tprob_max_idx = i;\n\t\tfor(i=0;i<nr_class;i++)\n\t\t\tfree(pairwise_prob[i]);\n\t\tfree(dec_values);\n\t\tfree(pairwise_prob);\t     \n\t\treturn model->label[prob_max_idx];\n\t}\n\telse \n\t\treturn svm_predict(model, x);\n}\n\nconst char *svm_type_table[] =\n{\n\t\"c_svc\",\"nu_svc\",\"one_class\",\"epsilon_svr\",\"nu_svr\",NULL\n};\n\nconst char *kernel_type_table[]=\n{\n\t\"linear\",\"polynomial\",\"rbf\",\"sigmoid\",\"precomputed\",NULL\n};\n\nint svm_save_model(const char *model_file_name, const svm_model *model)\n{\n\tFILE *fp = fopen(model_file_name,\"w\");\n\tif(fp==NULL) return -1;\n\n\tconst svm_parameter& param = model->param;\n\n\tfprintf(fp,\"svm_type %s\\n\", svm_type_table[param.svm_type]);\n\tfprintf(fp,\"kernel_type %s\\n\", kernel_type_table[param.kernel_type]);\n\n\tif(param.kernel_type == POLY)\n\t\tfprintf(fp,\"degree %d\\n\", param.degree);\n\n\tif(param.kernel_type == POLY || param.kernel_type == RBF || param.kernel_type == SIGMOID)\n\t\tfprintf(fp,\"gamma %g\\n\", param.gamma);\n\n\tif(param.kernel_type == POLY || param.kernel_type == SIGMOID)\n\t\tfprintf(fp,\"coef0 %g\\n\", param.coef0);\n\n\tint nr_class = model->nr_class;\n\tint l = model->l;\n\tfprintf(fp, \"nr_class %d\\n\", nr_class);\n\tfprintf(fp, \"total_sv %d\\n\",l);\n\t\n\t{\n\t\tfprintf(fp, \"rho\");\n\t\tfor(int i=0;i<nr_class*(nr_class-1)/2;i++)\n\t\t\tfprintf(fp,\" %g\",model->rho[i]);\n\t\tfprintf(fp, \"\\n\");\n\t}\n\t\n\tif(model->label)\n\t{\n\t\tfprintf(fp, \"label\");\n\t\tfor(int i=0;i<nr_class;i++)\n\t\t\tfprintf(fp,\" %d\",model->label[i]);\n\t\tfprintf(fp, \"\\n\");\n\t}\n\n\tif(model->probA) // regression has probA only\n\t{\n\t\tfprintf(fp, \"probA\");\n\t\tfor(int i=0;i<nr_class*(nr_class-1)/2;i++)\n\t\t\tfprintf(fp,\" %g\",model->probA[i]);\n\t\tfprintf(fp, \"\\n\");\n\t}\n\tif(model->probB)\n\t{\n\t\tfprintf(fp, \"probB\");\n\t\tfor(int i=0;i<nr_class*(nr_class-1)/2;i++)\n\t\t\tfprintf(fp,\" %g\",model->probB[i]);\n\t\tfprintf(fp, \"\\n\");\n\t}\n\n\tif(model->nSV)\n\t{\n\t\tfprintf(fp, \"nr_sv\");\n\t\tfor(int i=0;i<nr_class;i++)\n\t\t\tfprintf(fp,\" %d\",model->nSV[i]);\n\t\tfprintf(fp, \"\\n\");\n\t}\n\n\tfprintf(fp, \"SV\\n\");\n\tconst double * const *sv_coef = model->sv_coef;\n\tconst svm_node * const *SV = model->SV;\n\n\tfor(int i=0;i<l;i++)\n\t{\n\t\tfor(int j=0;j<nr_class-1;j++)\n\t\t\tfprintf(fp, \"%.16g \",sv_coef[j][i]);\n\n\t\tconst svm_node *p = SV[i];\n\n\t\tif(param.kernel_type == PRECOMPUTED)\n\t\t\tfprintf(fp,\"0:%d \",(int)(p->value));\n\t\telse\n\t\t\twhile(p->index != -1)\n\t\t\t{\n\t\t\t\tfprintf(fp,\"%d:%.8g \",p->index,p->value);\n\t\t\t\tp++;\n\t\t\t}\n\t\tfprintf(fp, \"\\n\");\n\t}\n\tif (ferror(fp) != 0 || fclose(fp) != 0) return -1;\n\telse return 0;\n}\n\nstatic char *line = NULL;\nstatic int max_line_len;\n\nstatic char* readline(FILE *input)\n{\n\tint len;\n\n\tif(fgets(line,max_line_len,input) == NULL)\n\t\treturn NULL;\n\n\twhile(strrchr(line,'\\n') == NULL)\n\t{\n\t\tmax_line_len *= 2;\n\t\tline = (char *) realloc(line,max_line_len);\n\t\tlen = (int) strlen(line);\n\t\tif(fgets(line+len,max_line_len-len,input) == NULL)\n\t\t\tbreak;\n\t}\n\treturn line;\n}\n\nsvm_model *svm_load_model(const char *model_file_name)\n{\n\tFILE *fp = fopen(model_file_name,\"rb\");\n\tif(fp==NULL) return NULL;\n\t\n\t// read parameters\n\n\tsvm_model *model = Malloc(svm_model,1);\n\tsvm_parameter& param = model->param;\n\tmodel->rho = NULL;\n\tmodel->probA = NULL;\n\tmodel->probB = NULL;\n\tmodel->label = NULL;\n\tmodel->nSV = NULL;\n\n\tchar cmd[81];\n\twhile(1)\n\t{\n\t\tfscanf(fp,\"%80s\",cmd);\n\n\t\tif(strcmp(cmd,\"svm_type\")==0)\n\t\t{\n\t\t\tfscanf(fp,\"%80s\",cmd);\n\t\t\tint i;\n\t\t\tfor(i=0;svm_type_table[i];i++)\n\t\t\t{\n\t\t\t\tif(strcmp(svm_type_table[i],cmd)==0)\n\t\t\t\t{\n\t\t\t\t\tparam.svm_type=i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(svm_type_table[i] == NULL)\n\t\t\t{\n\t\t\t\tfprintf(stderr,\"unknown svm type.\\n\");\n\t\t\t\tfree(model->rho);\n\t\t\t\tfree(model->label);\n\t\t\t\tfree(model->nSV);\n\t\t\t\tfree(model);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t\telse if(strcmp(cmd,\"kernel_type\")==0)\n\t\t{\t\t\n\t\t\tfscanf(fp,\"%80s\",cmd);\n\t\t\tint i;\n\t\t\tfor(i=0;kernel_type_table[i];i++)\n\t\t\t{\n\t\t\t\tif(strcmp(kernel_type_table[i],cmd)==0)\n\t\t\t\t{\n\t\t\t\t\tparam.kernel_type=i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(kernel_type_table[i] == NULL)\n\t\t\t{\n\t\t\t\tfprintf(stderr,\"unknown kernel function.\\n\");\n\t\t\t\tfree(model->rho);\n\t\t\t\tfree(model->label);\n\t\t\t\tfree(model->nSV);\n\t\t\t\tfree(model);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t\telse if(strcmp(cmd,\"degree\")==0)\n\t\t\tfscanf(fp,\"%d\",&param.degree);\n\t\telse if(strcmp(cmd,\"gamma\")==0)\n\t\t\tfscanf(fp,\"%lf\",&param.gamma);\n\t\telse if(strcmp(cmd,\"coef0\")==0)\n\t\t\tfscanf(fp,\"%lf\",&param.coef0);\n\t\telse if(strcmp(cmd,\"nr_class\")==0)\n\t\t\tfscanf(fp,\"%d\",&model->nr_class);\n\t\telse if(strcmp(cmd,\"total_sv\")==0)\n\t\t\tfscanf(fp,\"%d\",&model->l);\n\t\telse if(strcmp(cmd,\"rho\")==0)\n\t\t{\n\t\t\tint n = model->nr_class * (model->nr_class-1)/2;\n\t\t\tmodel->rho = Malloc(double,n);\n\t\t\tfor(int i=0;i<n;i++)\n\t\t\t\tfscanf(fp,\"%lf\",&model->rho[i]);\n\t\t}\n\t\telse if(strcmp(cmd,\"label\")==0)\n\t\t{\n\t\t\tint n = model->nr_class;\n\t\t\tmodel->label = Malloc(int,n);\n\t\t\tfor(int i=0;i<n;i++)\n\t\t\t\tfscanf(fp,\"%d\",&model->label[i]);\n\t\t}\n\t\telse if(strcmp(cmd,\"probA\")==0)\n\t\t{\n\t\t\tint n = model->nr_class * (model->nr_class-1)/2;\n\t\t\tmodel->probA = Malloc(double,n);\n\t\t\tfor(int i=0;i<n;i++)\n\t\t\t\tfscanf(fp,\"%lf\",&model->probA[i]);\n\t\t}\n\t\telse if(strcmp(cmd,\"probB\")==0)\n\t\t{\n\t\t\tint n = model->nr_class * (model->nr_class-1)/2;\n\t\t\tmodel->probB = Malloc(double,n);\n\t\t\tfor(int i=0;i<n;i++)\n\t\t\t\tfscanf(fp,\"%lf\",&model->probB[i]);\n\t\t}\n\t\telse if(strcmp(cmd,\"nr_sv\")==0)\n\t\t{\n\t\t\tint n = model->nr_class;\n\t\t\tmodel->nSV = Malloc(int,n);\n\t\t\tfor(int i=0;i<n;i++)\n\t\t\t\tfscanf(fp,\"%d\",&model->nSV[i]);\n\t\t}\n\t\telse if(strcmp(cmd,\"SV\")==0)\n\t\t{\n\t\t\twhile(1)\n\t\t\t{\n\t\t\t\tint c = getc(fp);\n\t\t\t\tif(c==EOF || c=='\\n') break;\t\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfprintf(stderr,\"unknown text in model file: [%s]\\n\",cmd);\n\t\t\tfree(model->rho);\n\t\t\tfree(model->label);\n\t\t\tfree(model->nSV);\n\t\t\tfree(model);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n\t// read sv_coef and SV\n\n\tint elements = 0;\n\tlong pos = ftell(fp);\n\n\tmax_line_len = 1024;\n\tline = Malloc(char,max_line_len);\n\tchar *p,*endptr,*idx,*val;\n\n\twhile(readline(fp)!=NULL)\n\t{\n\t\tp = strtok(line,\":\");\n\t\twhile(1)\n\t\t{\n\t\t\tp = strtok(NULL,\":\");\n\t\t\tif(p == NULL)\n\t\t\t\tbreak;\n\t\t\t++elements;\n\t\t}\n\t}\n\telements += model->l;\n\n\tfseek(fp,pos,SEEK_SET);\n\n\tint m = model->nr_class - 1;\n\tint l = model->l;\n\tmodel->sv_coef = Malloc(double *,m);\n\tint i;\n\tfor(i=0;i<m;i++)\n\t\tmodel->sv_coef[i] = Malloc(double,l);\n\tmodel->SV = Malloc(svm_node*,l);\n\tsvm_node *x_space = NULL;\n\tif(l>0) x_space = Malloc(svm_node,elements);\n\n\tint j=0;\n\tfor(i=0;i<l;i++)\n\t{\n\t\treadline(fp);\n\t\tmodel->SV[i] = &x_space[j];\n\n\t\tp = strtok(line, \" \\t\");\n\t\tmodel->sv_coef[0][i] = strtod(p,&endptr);\n\t\tfor(int k=1;k<m;k++)\n\t\t{\n\t\t\tp = strtok(NULL, \" \\t\");\n\t\t\tmodel->sv_coef[k][i] = strtod(p,&endptr);\n\t\t}\n\n\t\twhile(1)\n\t\t{\n\t\t\tidx = strtok(NULL, \":\");\n\t\t\tval = strtok(NULL, \" \\t\");\n\n\t\t\tif(val == NULL)\n\t\t\t\tbreak;\n\t\t\tx_space[j].index = (int) strtol(idx,&endptr,10);\n\t\t\tx_space[j].value = strtod(val,&endptr);\n\n\t\t\t++j;\n\t\t}\n\t\tx_space[j++].index = -1;\n\t}\n\tfree(line);\n\n\tif (ferror(fp) != 0 || fclose(fp) != 0)\n\t\treturn NULL;\n\n\tmodel->free_sv = 1;\t// XXX\n\treturn model;\n}\n\nvoid svm_destroy_model(svm_model* model)\n{\n\tif(model->free_sv && model->l > 0)\n\t\tfree((void *)(model->SV[0]));\n\tfor(int i=0;i<model->nr_class-1;i++)\n\t\tfree(model->sv_coef[i]);\n\tfree(model->SV);\n\tfree(model->sv_coef);\n\tfree(model->rho);\n\tfree(model->label);\n\tfree(model->probA);\n\tfree(model->probB);\n\tfree(model->nSV);\n\tfree(model);\n}\n\nvoid svm_destroy_param(svm_parameter* param)\n{\n\tfree(param->weight_label);\n\tfree(param->weight);\n}\n\nconst char *svm_check_parameter(const svm_problem *prob, const svm_parameter *param)\n{\n\t// svm_type\n\n\tint svm_type = param->svm_type;\n\tif(svm_type != C_SVC &&\n\t   svm_type != NU_SVC &&\n\t   svm_type != ONE_CLASS &&\n\t   svm_type != EPSILON_SVR &&\n\t   svm_type != NU_SVR)\n\t\treturn \"unknown svm type\";\n\t\n\t// kernel_type, degree\n\t\n\tint kernel_type = param->kernel_type;\n\tif(kernel_type != LINEAR &&\n\t   kernel_type != POLY &&\n\t   kernel_type != RBF &&\n\t   kernel_type != SIGMOID &&\n\t   kernel_type != PRECOMPUTED)\n\t\treturn \"unknown kernel type\";\n\n\tif(param->degree < 0)\n\t\treturn \"degree of polynomial kernel < 0\";\n\n\t// cache_size,eps,C,nu,p,shrinking\n\n\tif(param->cache_size <= 0)\n\t\treturn \"cache_size <= 0\";\n\n\tif(param->eps <= 0)\n\t\treturn \"eps <= 0\";\n\n\tif(svm_type == C_SVC ||\n\t   svm_type == EPSILON_SVR ||\n\t   svm_type == NU_SVR)\n\t\tif(param->C <= 0)\n\t\t\treturn \"C <= 0\";\n\n\tif(svm_type == NU_SVC ||\n\t   svm_type == ONE_CLASS ||\n\t   svm_type == NU_SVR)\n\t\tif(param->nu <= 0 || param->nu > 1)\n\t\t\treturn \"nu <= 0 or nu > 1\";\n\n\tif(svm_type == EPSILON_SVR)\n\t\tif(param->p < 0)\n\t\t\treturn \"p < 0\";\n\n\tif(param->shrinking != 0 &&\n\t   param->shrinking != 1)\n\t\treturn \"shrinking != 0 and shrinking != 1\";\n\n\tif(param->probability != 0 &&\n\t   param->probability != 1)\n\t\treturn \"probability != 0 and probability != 1\";\n\n\tif(param->probability == 1 &&\n\t   svm_type == ONE_CLASS)\n\t\treturn \"one-class SVM probability output not supported yet\";\n\n\n\t// check whether nu-svc is feasible\n\t\n\tif(svm_type == NU_SVC)\n\t{\n\t\tint l = prob->l;\n\t\tint max_nr_class = 16;\n\t\tint nr_class = 0;\n\t\tint *label = Malloc(int,max_nr_class);\n\t\tint *count = Malloc(int,max_nr_class);\n\n\t\tint i;\n\t\tfor(i=0;i<l;i++)\n\t\t{\n\t\t\tint this_label = (int)prob->y[i];\n\t\t\tint j;\n\t\t\tfor(j=0;j<nr_class;j++)\n\t\t\t\tif(this_label == label[j])\n\t\t\t\t{\n\t\t\t\t\t++count[j];\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\tif(j == nr_class)\n\t\t\t{\n\t\t\t\tif(nr_class == max_nr_class)\n\t\t\t\t{\n\t\t\t\t\tmax_nr_class *= 2;\n\t\t\t\t\tlabel = (int *)realloc(label,max_nr_class*sizeof(int));\n\t\t\t\t\tcount = (int *)realloc(count,max_nr_class*sizeof(int));\n\t\t\t\t}\n\t\t\t\tlabel[nr_class] = this_label;\n\t\t\t\tcount[nr_class] = 1;\n\t\t\t\t++nr_class;\n\t\t\t}\n\t\t}\n\t\n\t\tfor(i=0;i<nr_class;i++)\n\t\t{\n\t\t\tint n1 = count[i];\n\t\t\tfor(int j=i+1;j<nr_class;j++)\n\t\t\t{\n\t\t\t\tint n2 = count[j];\n\t\t\t\tif(param->nu*(n1+n2)/2 > min(n1,n2))\n\t\t\t\t{\n\t\t\t\t\tfree(label);\n\t\t\t\t\tfree(count);\n\t\t\t\t\treturn \"specified nu is infeasible\";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfree(label);\n\t\tfree(count);\n\t}\n\n\treturn NULL;\n}\n\nint svm_check_probability_model(const svm_model *model)\n{\n\treturn ((model->param.svm_type == C_SVC || model->param.svm_type == NU_SVC) &&\n\t\tmodel->probA!=NULL && model->probB!=NULL) ||\n\t\t((model->param.svm_type == EPSILON_SVR || model->param.svm_type == NU_SVR) &&\n\t\t model->probA!=NULL);\n}\n"
  },
  {
    "path": "scripts/modeltrain/libsvm-small/svm.h",
    "content": "#ifndef _LIBSVM_H\n#define _LIBSVM_H\n\n#define LIBSVM_VERSION 289\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nextern int libsvm_version;\n\nstruct svm_node\n{\n\tint index;\n\tdouble value;\n};\n\nstruct svm_problem\n{\n\tint l;\n\tdouble *y;\n\tstruct svm_node **x;\n};\n\nenum { C_SVC, NU_SVC, ONE_CLASS, EPSILON_SVR, NU_SVR };\t/* svm_type */\nenum { LINEAR, POLY, RBF, SIGMOID, PRECOMPUTED }; /* kernel_type */\n\nstruct svm_parameter\n{\n\tint svm_type;\n\tint kernel_type;\n\tint degree;\t/* for poly */\n\tdouble gamma;\t/* for poly/rbf/sigmoid */\n\tdouble coef0;\t/* for poly/sigmoid */\n\n\t/* these are for training only */\n\tdouble cache_size; /* in MB */\n\tdouble eps;\t/* stopping criteria */\n\tdouble C;\t/* for C_SVC, EPSILON_SVR and NU_SVR */\n\tint nr_weight;\t\t/* for C_SVC */\n\tint *weight_label;\t/* for C_SVC */\n\tdouble* weight;\t\t/* for C_SVC */\n\tdouble nu;\t/* for NU_SVC, ONE_CLASS, and NU_SVR */\n\tdouble p;\t/* for EPSILON_SVR */\n\tint shrinking;\t/* use the shrinking heuristics */\n\tint probability; /* do probability estimates */\n};\n\nstruct svm_model *svm_train(const struct svm_problem *prob, const struct svm_parameter *param);\nvoid svm_cross_validation(const struct svm_problem *prob, const struct svm_parameter *param, int nr_fold, double *target);\n\nint svm_save_model(const char *model_file_name, const struct svm_model *model);\nstruct svm_model *svm_load_model(const char *model_file_name);\n\nint svm_get_svm_type(const struct svm_model *model);\nint svm_get_nr_class(const struct svm_model *model);\nvoid svm_get_labels(const struct svm_model *model, int *label);\ndouble svm_get_svr_probability(const struct svm_model *model);\n\nvoid svm_predict_values(const struct svm_model *model, const struct svm_node *x, double* dec_values);\ndouble svm_predict(const struct svm_model *model, const struct svm_node *x);\ndouble svm_predict_probability(const struct svm_model *model, const struct svm_node *x, double* prob_estimates);\n\nvoid svm_destroy_model(struct svm_model *model);\nvoid svm_destroy_param(struct svm_parameter *param);\n\nconst char *svm_check_parameter(const struct svm_problem *prob, const struct svm_parameter *param);\nint svm_check_probability_model(const struct svm_model *model);\n\nextern void (*svm_print_string) (const char *);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* _LIBSVM_H */\n"
  },
  {
    "path": "scripts/modeltrain/makemodel.pl",
    "content": "#!/usr/bin/perl\n$do_standardise = 0; # TODO: implement speaker standardisation...\n$do_select = 0;\n$regression = 0;  # 0: classification model , 1: regression model\n\n#--------------\nuse File::Basename;\nrequire \"arff-functions.pl\";\n\n#print \"Operating system: $^O\\n\\n\";\nif ($#ARGV < 0) {\n  print \"\\nUsage: perl makemodel.pl <corpus_path  arff file (must end in .arff)>  [SMILExtract config for corpus mode] [SVM Config]\\n\\n\";\n  exit -1;\n}\n\n# check if we run on windows...\nif ($^O =~ /win/i) {\n  $ext = \".exe\";\n  unless (-f \"libsvm-small/svm-train$ext\") {\n    print \"ERROR: The libsvm binaries in scripts/modeltrain/libsvm-small \\n\";\n    print \"       cannot be found (svm-train.exe, svm-scale.exe, ...)\\n\";\n    print \"       Please compile them first, or get a new openEAR realease\\n\";\n    print \"       which contains the binaries (or contact the authors!)\\n\";\n    exit;\n  }\n} else {\n  $ext = \"\";\n  # check for libsvm binaries...\n  unless (-f \"libsvm-small/svm-train\") {\n    # assume binaries have not yet been compiled\n    print \"WARNING: you have not yet compiled the LibSVM binaries!\\n\";\n    print \"  I will try to compile, this should work, if you have \\n\";\n    print \"  called this script from the 'scripts/modeltrain'\\n\";\n    print \"  directory. \\n\";\n    print \"  If you get errors in the following output, please do \\n\";\n    print \"  the following manually (relative to openEAR root path): \\n\";\n    print \"    cd scripts/modeltrain/libsvm-small \\n\";\n    print \"    make \\n\";\n    $ret = system(\"cd libsvm-small ; make\");\n    if ($ret == 0) {\n      print \"LibSVM built successfully!\\n\";\n    } else {\n      print \"FAILED building LibSVM!!\\n\";\n      exit -1;\n    }\n  }\n}\n$xtract = \"../../SMILExtract$ext\";\n\nmkdir (\"built_models\");\nmkdir (\"work\");\n$corp = $ARGV[0];  # full path to corpus OR direct arff file...\nif ($corp =~ /\\.arff$/i) {\n  $mode=\"arff\";\n  unless (-f \"$corp\") {\n    print \"ERROR '$corp' is not an ARFF file or does not exist!\\n\";\n    exit;\n  }\n  $cname=basename($corp);\n  $cname =~s/\\.arff$//i;\n  $arff = $corp;\n  $modelpath = \"built_models/$cname\";\n  $workpath = \"work/$cname\";\n  $svmConfig = $ARGV[1];\n} else {\n  $mode = \"corp\";\n  unless (-d \"$corp\") {\n    print \"ERROR '$corp' is not a corpus directory or does not exist!\\n\";\n    exit;\n  }\n  if ($corp =~ /\\/([^\\/]+)_FloEmoStdCls/) {\n    $cname = $1;\n  } else {\n    $cname = basename($corp);\n  }\n  $conf = $ARGV[1];\n  $svmConfig = $ARGV[2];\n  unless ($conf) { $conf = \"is09s.conf\"; }\n  $cb=$conf; $cb=~s/\\.conf$//;\n  $modelpath = \"built_models/$cname\";\n  $workpath = \"work/$cname\";\n  $arff = \"$workpath/$cb.arff\";\n}\n\n  mkdir(\"$modelpath\");\n  mkdir(\"$workpath\");\n\n\n#extract features\nif ($mode eq \"corp\") {\n  print \"-- Corpus mode --\\n  Running feature extraction on corpus '$corp' ...\\n\";\n  system(\"perl stddirectory_smileextract.pl \\\"$corp\\\" \\\"$conf\\\" \\\"$arff\\\"\");\n} else {\n  print \"-- Arff mode --\\n  Copying '$arff' to work directory ...\\n\";\n  $arffb = basename($arff);\n#  print(\"cp $arff $workpath/$arffb\");\n  system(\"cp $arff $workpath/$arffb\");\n  $arff = \"$workpath/$arffb\";\n}\n\n# ? standardise features\nif ($do_standardise) {\n print \"NOTE: standardsise not implemented yet, svm-scale will do the job during building of model\\n\";\n}\n\n# ? select features\n$lsvm=$arff; $lsvm=~s/\\.arff$/.lsvm/i;\nif ($do_select) {\n print \"Selecting features (CFS)... (this requires weka)\\n\";\n $fself = $arff;\n $fself=~s/\\.arff/.fselection/i;\n system(\"perl fsel.pl $arff\");\n $arff = \"$arff.fsel.arff\";\n # TOOD: remove index fields, convert to LSVM, re-use code from below..\n system(\"perl arffToLsvm.pl $arff $lsvm\");\n} else {\n  $fself=\"\";\n  print \"Converting arff to libsvm feature file (lsvm) ...\\n\";\n  # convert to lsvm\n  my $hr = &load_arff($arff);\n  my $numattr = $#{$hr->{\"attributes\"}};\n  if ($hr->{\"attributes\"}[0]{\"name\"} =~ /^name$/) {\n    $hr->{\"attributes\"}[0]{\"selected\"} = 0;  # remove filename\n  }\n  if ($hr->{\"attributes\"}[0]{\"name\"} =~ /^filename$/) {\n    $hr->{\"attributes\"}[0]{\"selected\"} = 0;  # remove filename\n  }\n  if ($hr->{\"attributes\"}[1]{\"name\"} =~ /^timestamp$/) {\n    $hr->{\"attributes\"}[1]{\"selected\"} = 0;  # remove filename\n  }\n  if ($hr->{\"attributes\"}[1]{\"name\"} =~ /^frameIndex$/) {\n    $hr->{\"attributes\"}[1]{\"selected\"} = 0;  # remove filename\n    if ($hr->{\"attributes\"}[2]{\"name\"} =~ /^frameTime$/) {\n      $hr->{\"attributes\"}[2]{\"selected\"} = 0;  # remove filename\n    }\n  }\n  if ($hr->{\"attributes\"}[1]{\"name\"} =~ /^frameTime$/) {\n    $hr->{\"attributes\"}[1]{\"selected\"} = 0;  # remove filename\n  }\n   #$hr->{\"attributes\"}[$numattr-1]{\"selected\"} = 0; # remove continuous label\n  &save_arff_AttrSelected($arff,$hr);\n  system(\"perl arffToLsvm.pl $arff $lsvm\");\n\n  # generate fsel file with list of features:\n  $outpArff=$arff;\n  $feaTUMfselfile=basename($arff);\n  $feaTUMfselfile=~ s/\\.arff/.fselection/;\n  $feaTUMfselfile=\"work/$feaTUMfselfile\";\n\n# count number of features first\n$nStr = 0; $haveNom = 0;\nopen(FILE,\"<$outpArff\");\nwhile (<FILE>) {\n  my $line = $_; chop($line);\n  if ($line =~ /^\\@attribute (.+?) numeric/) {\n    $nStr++;\n  }\n  if ($line =~ /^\\@attribute (.+?) \\{?.+,.+\\}?/) {\n    $haveNom=1;\n  }\n  if ($line =~ /^\\@data/) { last; }\n}\nclose(FILE);\n\nif ($haveNom==0) { $nStr--; }\nelse { print \"haveNom\\n\"; }\n\n#default : skip the last numeric attribute, if no nominal attribute is present\n$nNumCur=0;\nopen(OUT,\">$feaTUMfselfile\");\nprint OUT \"str\\n\";\nprint OUT \"$nStr\\n\";\nopen(FILE,\"<$outpArff\");\nwhile (<FILE>) {\n  my $line = $_; chop($line);\n  if ($line =~ /^\\@attribute (.+?) numeric/) {\n    $attr = $1;\n    $nNumCur++;\n#    print \"selecting: $attr \\n\";\n    if ($haveNom==1) {\n      print OUT \"$attr\\n\";\n    } elsif (($nNumCur <= $nStr)) {\n      print OUT \"$attr\\n\";\n    }\n  }\n  if ($line =~ /^\\@data/) { last; }\n}\nclose(FILE);\nclose(OUT);\n\n$fself = $feaTUMfselfile;\n\n}\n\n# train model\nprint \"Training libsvm model ...\\n\";\nsystem(\"perl buildmodel.pl $lsvm $svmConfig\");\n\n$discfile = $lsvm; $discfile=~s/\\.lsvm$/.disc/;\nopen(FILE,\"<$discfile\");\n$disc=<FILE>; $disc=~s/\\r?\\n$//;\nclose(FILE);\n\n$conf = $lsvm;\n$conf =~ s/\\.lsvm$/.config/;\n\n# copy final files to modelpath\n$scale = $lsvm; $scale=~s/\\.lsvm$/.scale/;\n$model = $lsvm; $model=~s/\\.lsvm$/.model/;\n$cls = $lsvm; $cls=~s/\\.lsvm$/.classes/;\nif ($cb) { $cb = \"$cb.\"; }\n\nif ($do_select) { $sel=\"cfssel.\"; }\nelse { $sel=\"allft.\"; }\n\nsystem(\"cp $scale $modelpath/$cb$sel\".\"scale\");\nsystem(\"cp $model $modelpath/$cb$sel\".\"model\");\n# convert to binary model\nunless (-f \"../../svm/modelconverter$ext\") {\n  print \"WARNING: modelconverter not found in ../../svm ! If you are running this script on windows, you must compile the modelconverter.cpp file manually!\\n\";\n  system(\"cd ../../svm ; sh compileConverter.sh\");\n}\nsystem(\"../../svm/modelconverter $modelpath/$cb$sel\".\"model $modelpath/$cb$sel\".\"model.bin\");\n\nsystem(\"cp $conf $modelpath/$cb$sel\".\"config\");\nif ($disc) {\n  system(\"cp $cls $modelpath/$cb$sel\".\"classes\");\n}\nif ($fself) {\n  system(\"cp $fself $modelpath/$cb$sel\".\"fselection\");\n}\n\n"
  },
  {
    "path": "scripts/modeltrain/stddirectory_smileextract.pl",
    "content": "#!/usr/bin/perl\r\n\r\n\r\n# openSMILE extraction script \r\n# usage: $0 <corpus base path> <opensmile config file> <output arff>\r\n\r\n# path to SMILExtract binary (incl trailing /)\r\n$sepath = \"../../\";\r\n\r\n\r\n#-------------------------------------------------------------------------\r\n\r\nif ($#ARGV < 1) {\r\n  print \"Usage: stddirectory_extract.pl <corpus base path> <opensmile config file> <output arff>\\n\";\r\n  exit -1;\r\n}\r\n\r\n$corp = $ARGV[0];\r\n\r\n$wavpath = \"$corp\";\r\n\r\n$pwd=`pwd`;\r\n$conf = $ARGV[1];\r\nunless ($conf) { $conf=\"is09s.conf\"; }\r\n\r\n\r\n$confb=$conf; $confb=~s/\\.conf//i;\r\n$arff = $ARGV[2];\r\n\r\nuse File::Basename;\r\n#$bn=basename($ft);\r\n#$arff=\"functionals_$bn.arff\";\r\n\r\n#-----\r\n$wavpath =~ s/ /\\\\ /g;\r\n@cl = glob(\"$wavpath\".\"/*\");\r\n$labs=\"\";\r\nmy @cls;\r\nforeach $c (@cl) {\r\n if ((-d \"$c\")&&($c !~ /smile-linux/)) {\r\n   $c = basename($c);\r\n   push(@cls,$c);\r\n   print \"label: \".$c.\"\\n\";\r\n   $labs .= \"$c,\";\r\n }\r\n}\r\nchop($labs);\r\n\r\n#!!!!!!!!\r\nunlink (\"$arff\");\r\n\r\nforeach $c (@cls) {\r\n\r\nprint $c.\"\\n\";\r\n@wavs = glob(\"$wavpath/$c/*.wav\");\r\nforeach $w (@wavs) {\r\n  print $w.\"... \";\r\n  $bn=basename($w);\r\n  $bn=~ s/\\.wav$//i;\r\n \r\n  # print(\"mplayer -ao pcm:waveheader:fast:file=\\\"$wave\\\" -vc null -vo null \\\"$w\\\"\");\r\n  #exit;\r\n\r\n  $ret = system(\"$sepath./SMILExtract -C $sepath./config/$conf -I \\\"$w\\\" -O \\\"$arff\\\" -instname \\\"$bn\\\" -classes \\\"\\{$labs\\}\\\" -classlabel \\\"$c\\\" -corpus \\\"$corp\\\" 2>/dev/null\"); #-o \\\"$work/features/lld/Train/$w.htk\\\"\r\n  if ($ret != 0) { print \"ERROR!\\n\\n\"; \r\n   print \"Failed on command: \".\"$sepath./SMILExtract -C $sepath./config/$conf -I \\\"$w\\\" -O \\\"$arff\\\" -instname \\\"$bn\\\" -classes \\\"\\{$labs\\}\\\" -classlabel \\\"$c\\\" -corpus \\\"$corp\\\" 2>/dev/null \\n\\n\";\r\n\r\n   exit; }\r\n  else { print \"OK.\\n\"; }\r\n}\r\n\r\n\r\n}\r\n\r\n"
  },
  {
    "path": "scripts/modeltrain/txtfile-functions.pl",
    "content": "###########################################################\r\n#  perl functions for simplified text file access         #\r\n#  these functions read/write text files into/from arrays #\r\n#  by Florian Eyben, TUM, MMK  (2008)                     #\r\n###########################################################\r\n\r\n# usage: @lines=readFile(\"filename\");\r\nsub readTextFile {\r\n  my @my_lines=();\r\n  if (-f \"$_[0]\") {\r\n    open(FILE,\"<$_[0]\");\r\n    @my_lines = <FILE>;\r\n    chop(@my_lines); # remove newline char.\r\n    close(FILE);\r\n    return @my_lines;\r\n  } \r\n}\r\n\r\nsub readTextFile_asString {\r\n  my @my_lines2=&readTextFile($_[0]);\r\n  my $my_tmp = join(\"\\n\",@my_lines2);\r\n  return \"$my_tmp\\n\";\r\n}\r\n\r\nsub readTextFile_asRawString {  # does NOT remove any newlines during reading...\r\n  my @my_lines=();\r\n  if (-f \"$_[0]\") {\r\n    open(FILE,\"<$_[0]\");\r\n    @my_lines = <FILE>;\r\n    close(FILE);\r\n    my $my_tmp = join(\"\",@my_lines);\r\n    return \"$my_tmp\";\r\n  } else { return \"\"; }\r\n}\r\n\r\n# usage: &writeToTextFile(filename,$text) - save $text without appending \\n at the end\r\n# usage: &writeToTextFile(filename,@text) - save array joined by \\n and with a \\n after the last element (=line)\r\n#  caution: file will be overwritten if it exists!\r\nsub writeToTextFile {\r\n  my $my_tmp = shift;\r\n  open(FILE,\">$my_tmp\");\r\n  if ($#_ > 0) { # array mode\r\n    print FILE join(\"\\n\",@_);\r\n    print FILE \"\\n\";\r\n  } else { # string mode\r\n    print FILE \"$_[0]\";\r\n  }\r\n  close(FILE);\r\n}\r\n\r\nsub appendToTextFile {\r\n  my $my_tmp = shift;\r\n  if (-f $my_tmp) {\r\n    open(FILE,\">>$my_tmp\");\r\n  } else {\r\n    open(FILE,\">$my_tmp\");\r\n  }\r\n  if ($#_ > 0) { # array mode\r\n    print FILE join(\"\\n\",@_);\r\n    print FILE \"\\n\";\r\n  } else { # string mode\r\n    print FILE \"$_[0]\";\r\n  }\r\n  close(FILE);\r\n}\r\n\r\n1;"
  },
  {
    "path": "scripts/vad/README.txt",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE LSTM-RNN voice activity detector<              //////////////////\n/////////                                                            //////////////////\n///////// (c) audEERING UG (haftungsbeschränkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\nThis folder contains configuration files and models for a\nprototype LSTM-RNN Voice Activity Detector.\nThis is meant as an example to show how to implement such\na VAD in openSMILE with the RNN components and to provide\na simple VAD for prototype development. The noise-robustness\nof this VAD is *not* state-of-the-art, it has been built on\na small-scale research data-set, mainly for clean speech. \n\n\nThis config implements a voice activity detector as described in:\n\n  Eyben, F.; Weninger, F.; Squartini, S.; Schuller, B.:\n    \"Real-life voice activity detection with LSTM Recurrent Neural \n    Networks and an application to Hollywood movies,\" \n    Proc. of ICASSP 2013, pp. 483-487, 26-31 May 2013. \n    doi: 10.1109/ICASSP.2013.6637694\n\nThe models are not the same models as used in the paper, but a\npreliminary version of the data presented in the paper.\n\nIf you need a more accurate and noise-robust VAD,\ncontact audEERING at info@audeering.com for a demo of\nour latest commercial VAD technology.\nWe have extremely robust detectors, which are even capable\nof reliably detecting sung speech (vocals) in single channel\npolyphonic music recordings.\n\n\nThere are two main config files to start from here:\n  vad_opensource.conf : Dumps vad activations per frame to CSV\n  vad_segmenter.conf  : Creates wave files with voice segments\n                        and optionally writes activations to CSV\n\nRun \n  SMILExtract -ccmdHelp -C <configfile>\nto see the commandline options supported by these config files.\n\nIf you want to include the VAD as a module in your own\nconfiguration files, you can use:\n  vad_opensource.conf.inc\n  turnDetector.conf.inc\n\nSee the comments in these config files for level input/output\nnaming requirements. See the main config files for examples\nof how to use the module includes.\n\n\n"
  },
  {
    "path": "scripts/vad/lstmvad_rplp18d_12.net",
    "content": "autosave true\nbatchLearn false\nbidirectional false\ndataFileNum 0\ndataFraction 1.0\ndataset train\ndisplay false\ndisplayAll false\nerrorTest false\ngradCheck false\nhiddenSize 50\nhiddenType lstm\ninitWeightRange 0.1\ninputNoiseDev 0.3\ninputSize 36\nlabelDelimiter ,\nlearnRate 1e-5\nloadWeights true\nmaxTestsNoBest 10\nmomentum 0.9\nnetUseImportanceWeight false\noptimiser steepest\nrandSeed 2\nrecurrent true\nsaveFileBase trained_nets/net4_proto.vad_rplp18d.seed2\nsaveFileNoTimestamp true\nseqsPerWeightUpdate 1\nsequence 0\nsubsampleBias false\nsubsampleType tanh\ntargetLabels sil\ntask regression\ntestDistortions false\ntotalEpochs 40\ntrainFile /home/iaa1/data/eyb/vad2012/ncout/train_timit_part0.vad_RASTA_PLP_18_new_D_std.nc,/home/iaa1/data/eyb/vad2012/ncout/train_buckeye_part0.vad_RASTA_PLP_18_new_D_std.nc,/home/iaa1/data/eyb/vad2012/ncout/train_timit_part1.vad_RASTA_PLP_18_new_D_std.nc,/home/iaa1/data/eyb/vad2012/ncout/train_buckeye_part1.vad_RASTA_PLP_18_new_D_std.nc,/home/iaa1/data/eyb/vad2012/ncout/train_timit_part2.vad_RASTA_PLP_18_new_D_std.nc,/home/iaa1/data/eyb/vad2012/ncout/train_buckeye_part2.vad_RASTA_PLP_18_new_D_std.nc\nvalFile /home/iaa1/data/eyb/vad2012/ncout/val_timit_part0.vad_RASTA_PLP_18_new_D_std.nc,/home/iaa1/data/eyb/vad2012/ncout/val_buckeye_part0.vad_RASTA_PLP_18_new_D_std.nc\nverbose false\nweightDistortion 0\ntrainer_epoch 14\nweightContainer_bias_to_hidden_0_0_deltas 200 -1.99516e-05 4.48064e-05 -0.000767233 -9.14626e-05 3.74249e-05 2.83748e-05 0.000239365 5.80469e-05 0.000106838 -7.50933e-05 0.000263419 -0.000377648 -7.56347e-06 2.09836e-05 -0.000531158 1.4857e-05 5.43028e-05 1.542e-05 0.000486663 9.75604e-05 -0.000319651 -0.000530647 0.00103749 -0.00058428 -0.000363198 -0.000306504 -0.0011169 -0.000272457 7.83875e-05 -2.92362e-05 0.000232784 -9.7805e-06 8.09087e-05 -9.22712e-06 -0.000851507 1.8463e-05 0.000321361 0.000466429 0.000689636 0.000476001 -0.000241884 -0.00020066 0.00130061 -0.000387487 0.000143066 4.96411e-05 -0.000678754 -0.000194493 -0.000160726 -3.38491e-05 0.000875098 1.37522e-05 -0.000422412 -0.00120165 0.0019546 -0.000525643 -9.80324e-05 -7.38454e-05 0.000354641 -0.000138335 1.98706e-05 -1.1247e-05 0.000553439 -0.000105229 -1.13617e-06 0.000146241 -0.000219821 0.000174662 2.03272e-05 8.01116e-05 -0.00019477 3.58812e-05 -4.60032e-05 -0.000121285 -5.2363e-05 -0.000118773 1.79847e-05 5.54962e-05 -2.60865e-05 -0.000109219 -4.1655e-05 4.6459e-05 0.000474449 -5.49482e-05 2.76839e-05 -5.76082e-05 -0.000994326 -1.92571e-05 0.000432874 0.000484373 -0.0008782 -0.000871781 -6.53445e-05 -3.21839e-05 0.000553109 -9.96264e-05 0.000319616 0.000309716 -0.000334632 -0.000347932 -0.000979236 -0.000812577 -0.000876466 -0.000890904 -5.21071e-05 4.8518e-05 8.01847e-05 -0.000118949 0.000108098 -3.97319e-05 -0.00105208 -0.000259927 -8.61183e-05 -0.000107296 -6.64512e-08 -0.000300323 8.51064e-05 3.94476e-05 0.00100217 0.000120243 -1.27632e-05 -4.05727e-05 0.000692619 -6.77036e-05 3.11682e-06 1.6617e-05 0.000468729 6.43445e-06 3.17259e-05 -8.52122e-05 0.000292063 7.87395e-05 0.00011371 8.72672e-05 -0.000138786 0.000202463 -2.25759e-05 2.75158e-06 -0.00017917 -2.66222e-05 -0.000140109 -0.000141946 0.000748189 7.36507e-05 -7.15315e-05 -6.30679e-05 0.000388028 -0.000121339 -0.000140405 -4.99484e-05 -0.000574873 -1.82134e-05 -5.38926e-05 -5.30809e-05 -0.000743596 -2.80434e-05 -0.000177643 -4.81274e-05 -0.0010356 4.04676e-05 -0.000390048 -0.00038756 -0.00164338 -0.000158854 4.49241e-05 6.29954e-05 -0.000184927 -0.000141718 -0.000190526 -2.93841e-05 -0.00145176 -0.000106099 -8.71121e-06 -0.000102073 -0.00079582 -6.19339e-05 -0.000526148 -0.000367158 0.00121479 -0.000159713 -2.25399e-05 -0.000181648 0.000959452 -0.000123745 9.12361e-05 7.98257e-05 -0.000864942 0.000197508 -4.94676e-05 -3.40292e-05 0.000398959 -4.26745e-05 0.000136126 9.7843e-05 0.000619172 0.000107907 -0.000293325 -0.00024008 0.000312882 -0.000497748\nweightContainer_bias_to_hidden_0_0_plasticities 200 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\nweightContainer_bias_to_hidden_0_0_weights 200 -0.090787 -0.025611 0.0686484 0.020715 -0.183305 -0.0514311 0.0240362 -0.0729901 -0.390663 0.265635 0.147228 -0.0208399 -0.104589 -0.0774166 0.00367128 -0.112317 -0.382623 0.43732 0.0701977 -0.0761555 -1.47089 1.09143 0.306384 -1.07971 -0.320082 0.0492079 0.371177 -0.198651 -0.322556 0.380218 0.0745057 -0.052245 -0.709443 0.311318 0.156893 -0.347423 -0.199716 0.449041 0.123378 -0.170316 -1.29131 0.299952 0.626696 -0.610752 -0.257146 0.258258 -0.0389681 -0.157554 -0.474364 0.69823 0.696208 0.274842 -1.68515 0.336885 1.06218 -0.198632 -0.0779467 0.11479 0.0894735 -0.139754 -0.413006 -0.00663865 -0.00642319 -0.454224 -0.0887571 0.240199 -0.178207 0.0293636 -0.368747 0.0635344 0.0634651 -0.221994 0.029159 0.229145 0.176904 0.0404112 -0.435518 0.218746 0.00239275 -0.45835 -0.177709 0.355238 0.317109 -0.164265 -0.417683 0.0156948 -0.470475 -0.320418 -1.36279 -0.0576207 -0.161182 -0.167941 0.192863 0.29193 -0.0282057 0.332661 -0.970847 0.636299 -0.117287 -0.722274 -3.58219 3.70157 -0.553343 -0.232276 -0.484217 0.262557 0.111359 -0.261932 -0.896064 0.583479 -0.0377573 -1.51472 -0.9334 0.547024 -0.0857952 -0.529523 -0.418695 0.0684181 0.383063 -0.205841 -0.700579 0.241562 0.360554 -0.446364 -0.119864 -0.186761 0.0189661 -0.20437 -1.0613 -0.535632 0.842101 -1.20872 -0.504905 0.24774 -0.19909 -0.251614 -0.213142 0.150525 -0.139476 -0.22194 -0.670078 -0.0341599 0.934486 -0.931747 -0.0982499 0.1526 0.146562 0.0856425 -0.301729 -0.0441415 -0.406311 -0.366714 -0.449713 0.0877422 -0.416363 -0.50319 -0.746189 0.113834 -0.717596 -0.723134 -0.966897 0.446275 -0.843039 -0.666983 -0.0690042 0.130759 -0.316706 -0.138208 -0.106739 0.15283 -0.217087 -0.119201 -0.364857 -0.0164419 -0.104133 -0.199913 -0.919475 0.533006 0.815641 -1.04558 -0.329349 -0.00601929 0.35322 -0.444459 -0.64087 -0.00986712 -0.614327 -0.309639 -0.27331 0.233924 0.179557 -0.225245 0.0749919 0.0358092 0.210549 0.0710572 -0.710864 -0.170808 0.156876 -0.499669\nweightContainer_bias_to_output_deltas 1 -0.0109575\nweightContainer_bias_to_output_plasticities 1 1\nweightContainer_bias_to_output_weights 1 -0.328142\nweightContainer_hidden_0_0_peepholes_deltas 150 -0.000112187 -0.000244427 -0.00021885 1.75543e-05 2.50924e-05 2.29404e-05 6.61633e-05 0.000358873 0.00119757 -4.18712e-05 -5.71147e-05 -6.09577e-05 -0.00013112 -0.000290922 -8.78166e-05 0.000549743 0.000951048 0.000969859 -0.000185397 -0.000289085 -0.00024156 -2.70176e-05 -0.000269407 -0.000192937 -0.000112449 -0.000215352 -0.000316033 0.000111647 0.000233694 0.000278182 6.61912e-05 0.000110838 0.000774643 -3.43196e-05 -0.000350854 -0.000756087 -1.10083e-05 5.84782e-05 -4.77198e-05 0.00106901 0.00209617 0.00134481 7.02118e-05 9.84524e-05 7.91491e-05 0.000122763 0.000174457 0.00059346 -0.0001406 -0.000229524 -0.000386738 -9.32881e-06 -4.83042e-05 -2.68122e-05 9.18725e-05 0.000341081 0.000254954 -5.6036e-05 -7.80558e-05 -0.000552087 6.98788e-05 0.00012723 4.61353e-05 -6.96291e-05 -0.000232799 -0.000270754 0.000189004 0.000435921 -0.00143788 0.000103942 0.000180976 0.000249714 0.000571498 0.000576632 -0.00106981 -0.000721738 -0.000473225 -0.00160571 -0.000168268 -0.000481436 -0.000732335 0.0010804 3.0342e-05 0.00206562 -0.000102236 -0.000356633 -0.000691144 7.84877e-05 4.0262e-05 8.86107e-05 0.000116718 0.000246179 0.000379068 2.1169e-05 3.03008e-05 2.56518e-05 0.000107357 0.000324508 -2.81076e-06 -3.3767e-06 -0.000263808 0.000486333 -8.76665e-06 -4.03935e-06 4.62405e-05 6.55661e-05 8.33292e-05 0.000169196 1.80206e-05 3.23031e-05 6.21876e-05 -6.2074e-05 -0.000265925 -0.000341123 -0.000177546 -0.000209964 -0.000363467 -0.000172605 -0.000506149 -0.000363223 -0.000289094 -0.000430273 -0.000385714 0.000227443 6.90163e-05 -0.000440788 -4.21301e-05 -6.44139e-05 -7.04012e-05 8.51443e-05 -0.000628853 -0.000178066 0.000282033 0.000344361 0.000328462 0.000251825 0.000475821 0.000637635 -7.01862e-05 -9.18049e-05 0.000260791 5.41986e-07 -1.161e-05 -0.000104373 0.000209972 0.000514648 0.000562167 0.000131159 0.000129938 0.000427909\nweightContainer_hidden_0_0_peepholes_plasticities 150 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\nweightContainer_hidden_0_0_peepholes_weights 150 -0.0582822 -0.0717567 -0.116709 0.0466333 0.00334405 0.0845384 -0.113949 -0.17412 0.324185 0.110866 -0.0725225 -0.422003 0.0723734 0.319526 0.329959 0.255159 -0.267925 -0.168246 0.063671 -0.0658368 0.187477 -0.0116592 0.163734 0.0643249 -0.0366798 0.145704 -0.0137499 -0.0216675 0.0425596 -0.0531198 0.117976 -0.327671 0.428641 0.0769959 0.121258 -0.314721 -0.265012 -2.51086 1.26959 0.837684 -0.336179 -0.0949343 -0.0293589 -0.0357165 -0.095552 -0.10349 -0.159679 0.412354 -0.066949 0.0370586 0.0335873 -0.0821785 -0.0319935 -0.0978408 -0.350031 -0.109881 -0.124293 0.162458 0.14267 -0.339189 -0.00708674 0.213557 -0.494643 -0.0030318 0.277255 0.276072 0.145391 -0.220638 -0.831469 0.0426866 -0.136254 0.0571479 -0.88166 0.7944 -0.474567 -2.03633 0.485977 0.633773 0.0280737 0.0415605 -0.0762735 0.080465 1.54812 0.228326 -0.0685759 0.145195 -0.217159 -0.0820535 -0.119761 -0.288874 -0.235261 0.0691181 0.0458398 0.013801 0.0471015 -0.0220044 -0.365381 -0.230267 -0.24482 0.303266 0.63298 0.115404 -0.0319068 0.283463 0.254602 1.30492 -0.0681746 -1.13219 -0.0882439 0.0724224 -0.0836222 0.130289 0.0401118 0.414498 -0.0985429 0.077117 0.377402 0.403568 0.176716 0.149658 -0.468978 0.496285 0.156111 0.168802 0.763113 -0.156811 0.0114554 0.280087 0.263341 0.100036 0.323918 -0.0260952 -0.0588127 0.126123 -1.31442 0.0649711 -0.0525275 0.0131568 0.712538 0.468058 -0.265749 -0.249805 -0.254891 -0.0415938 0.0245014 -0.0105911 -0.0284155 -0.0847691 -0.00358457 0.0589205\nweightContainer_hidden_0_0_to_hidden_0_0_delay_-1_deltas 10000 -4.99328e-05 -2.3538e-06 -3.76554e-06 -2.06321e-06 2.80715e-06 -1.86809e-05 -1.92886e-05 3.65167e-05 -1.4427e-06 -2.23034e-05 5.63673e-07 4.96743e-06 1.45407e-06 3.2181e-05 2.93589e-05 -1.1332e-05 -3.70308e-05 9.11944e-06 -1.84956e-05 -4.74611e-06 -2.0961e-05 1.80714e-05 -3.35373e-06 -6.47834e-05 1.28395e-06 -1.80926e-05 -3.526e-05 1.10187e-05 -4.76832e-06 -2.58417e-05 -2.32132e-06 9.90098e-06 -1.1652e-05 -1.95239e-06 -1.70876e-06 1.31975e-05 -2.29914e-05 -5.11554e-06 -5.4532e-06 7.16438e-06 -1.25207e-05 -6.95006e-06 -8.34835e-06 -1.41391e-05 4.1699e-06 -5.39459e-06 2.7832e-06 1.59893e-05 2.75331e-05 -3.47684e-06 -0.000118121 -3.87207e-06 -2.27575e-05 4.35665e-06 -2.18276e-06 -4.32189e-05 -9.11469e-06 2.28745e-05 -1.9537e-05 -2.87632e-05 7.74951e-06 1.85712e-05 -6.97985e-06 2.71858e-05 3.45437e-05 -3.32677e-05 -6.05143e-05 -8.67418e-06 -3.00249e-05 -1.19274e-05 -2.04504e-05 2.40273e-05 -3.57333e-07 -8.27858e-05 2.77915e-06 -1.59562e-07 -5.38258e-05 1.58037e-05 1.0448e-05 -5.27879e-05 -6.61756e-06 1.51103e-05 -2.58531e-05 -1.47202e-05 -1.27387e-05 2.16094e-05 -3.81517e-05 5.15653e-06 -1.07562e-05 -3.60245e-06 5.68396e-07 -2.25761e-05 -2.82357e-05 -1.6111e-05 3.48488e-06 3.65014e-06 1.05616e-05 2.08194e-05 4.82637e-06 -1.41101e-05 7.7842e-05 7.3403e-05 0.000171386 -5.63292e-05 -0.000108357 0.000140028 -0.000153524 1.26028e-05 6.79961e-06 -8.86961e-05 0.000109954 -7.71545e-05 -1.25297e-05 0.000255036 -5.42219e-05 0.000112651 0.000170922 5.18989e-05 -1.79969e-05 1.72772e-05 0.000175236 -7.7131e-05 -9.93596e-05 0.000222672 -6.77626e-05 -0.000126647 2.75228e-05 3.33644e-05 -6.02193e-05 4.69633e-05 1.89296e-05 -8.45527e-05 1.35943e-05 -0.000101008 -6.32956e-05 3.26478e-06 -3.24881e-05 -2.25973e-05 -4.86575e-05 -4.36039e-05 -7.81563e-05 -5.21061e-05 -1.45208e-05 -3.34207e-05 3.91743e-05 8.84929e-05 -2.72578e-05 8.67601e-05 -1.86194e-05 0.000113595 -8.72315e-05 5.70881e-06 -5.63576e-06 -8.50637e-07 -3.93501e-06 -2.4918e-05 -2.59177e-05 5.6394e-05 -4.48511e-06 -3.21614e-05 1.22796e-05 -2.93322e-07 -7.24244e-07 5.98927e-05 3.8202e-05 -7.49567e-06 -4.53494e-05 8.76546e-06 -2.76428e-05 -1.03883e-05 -1.33811e-05 1.72831e-05 -1.45852e-05 -6.43232e-05 -5.34654e-06 -3.7468e-05 -4.55613e-05 1.58983e-05 -7.26842e-06 -3.6587e-05 -2.54749e-06 1.27385e-05 -2.29186e-05 -7.04974e-06 -5.97491e-06 2.65226e-05 -3.19084e-05 -4.82405e-06 -1.3909e-05 1.92849e-06 -2.03343e-05 -2.1178e-05 -1.68672e-05 -1.40637e-05 7.05945e-06 2.89056e-06 4.64606e-06 3.38018e-05 2.6214e-05 6.65882e-06 -1.07586e-06 6.80005e-06 -1.6678e-06 -5.09822e-08 2.97892e-06 -1.19727e-05 3.49928e-07 6.32526e-06 -2.04572e-06 4.19098e-06 -8.38306e-06 9.99934e-06 -9.67196e-07 -3.6197e-06 2.31119e-06 -4.2788e-06 -9.85043e-06 5.67182e-06 -1.16731e-05 4.5687e-06 -8.60446e-07 5.97551e-06 2.39805e-06 -1.89438e-06 -1.17429e-07 5.27606e-06 -5.77552e-07 1.86807e-06 3.07297e-06 -2.92956e-06 -9.17297e-06 4.19388e-06 -7.16915e-06 8.38744e-06 2.04969e-06 -4.61513e-06 -6.45902e-06 -5.20072e-06 9.10248e-06 1.32297e-05 -7.2331e-06 7.88439e-07 7.86134e-06 7.48911e-07 -7.05364e-06 -4.3352e-06 2.74105e-06 1.19211e-05 3.23504e-06 -5.67254e-06 -6.86989e-06 1.00571e-05 4.55306e-06 6.50232e-07 3.91938e-06 -7.80746e-06 -2.73259e-07 4.24593e-06 3.27894e-06 -4.82861e-06 -9.64548e-06 1.02104e-05 -5.93751e-07 -8.28899e-07 2.57235e-06 -4.16824e-06 -1.90381e-05 7.58644e-06 -1.0022e-05 2.47342e-06 -5.67682e-06 4.84439e-06 1.28037e-06 -5.99652e-06 -5.95411e-07 1.70959e-06 -1.32416e-06 2.11332e-06 3.9694e-06 -1.44774e-05 -3.09258e-06 1.57296e-06 -5.26716e-06 8.12957e-06 1.30328e-06 -1.65988e-06 -9.25372e-07 -1.07329e-05 6.51483e-06 1.73162e-05 -6.02452e-06 -1.59795e-06 5.73308e-06 -1.07663e-06 -8.75749e-06 -1.52963e-06 1.57577e-06 1.10445e-05 4.22285e-06 -7.98219e-06 2.09398e-06 8.16606e-06 1.02461e-05 -1.35718e-05 4.39354e-05 2.95584e-05 6.98869e-05 -4.01185e-05 5.72656e-06 3.04022e-05 -1.26699e-05 -1.67841e-05 2.48681e-05 -0.000127465 -2.10473e-05 3.70404e-06 -4.67697e-05 -1.01514e-06 9.01e-05 -1.12887e-05 -5.45576e-05 -6.83096e-08 5.6145e-06 -7.10955e-06 3.37513e-06 -2.38693e-05 2.29824e-05 -3.04306e-05 -6.72879e-06 6.35896e-06 5.99971e-05 -2.40922e-05 3.59982e-05 1.24509e-06 7.19444e-05 -3.89478e-05 4.26136e-05 3.97791e-05 6.04745e-06 -1.20146e-05 4.99076e-05 4.44825e-05 3.20961e-05 8.43361e-06 3.40912e-06 -5.20934e-07 2.50126e-06 -8.40414e-05 -1.38129e-05 -8.03558e-06 -7.44198e-06 7.61347e-06 -1.69793e-06 -2.36917e-06 7.72848e-06 -1.36173e-05 3.91154e-06 7.83918e-06 3.70269e-06 -3.53951e-06 -1.59437e-05 1.38151e-05 1.95658e-06 -1.1025e-05 3.52853e-06 -6.6766e-06 -1.88823e-05 9.49016e-06 -1.40465e-05 6.43787e-06 -8.87142e-06 8.23354e-06 3.51332e-06 -2.70031e-06 1.59512e-06 8.72758e-06 1.82562e-06 3.49403e-06 5.60351e-06 -1.43496e-05 -7.86883e-06 5.26604e-06 -8.53834e-06 1.37572e-05 2.32609e-06 -5.72118e-06 -5.3154e-06 -1.30616e-05 1.25152e-05 2.74805e-05 -4.72714e-06 -1.27947e-06 1.12368e-05 3.73364e-06 -1.16362e-05 -8.25607e-06 2.15012e-06 1.0398e-05 2.57666e-06 -1.19162e-05 -2.23687e-05 5.84395e-06 5.78834e-05 -4.51468e-06 4.83688e-05 7.24149e-06 1.13868e-05 1.79593e-05 1.88292e-05 6.16002e-05 -9.11955e-05 -4.06412e-05 -1.10835e-05 -6.39978e-05 1.25662e-05 -4.4e-05 -2.04764e-05 2.49789e-06 -5.79917e-06 1.29191e-05 2.4192e-05 2.86927e-06 1.33576e-05 1.62823e-06 1.49284e-05 1.88457e-05 1.11522e-05 -2.62432e-05 2.37257e-05 6.48437e-05 -6.53304e-06 -9.56842e-06 5.88411e-06 5.52229e-05 6.60624e-06 2.37899e-05 2.38819e-05 -1.2877e-05 5.47614e-05 2.26529e-05 5.13009e-05 3.47486e-05 3.76736e-05 -9.19018e-06 -2.54157e-05 -1.49453e-05 1.61592e-05 1.44587e-05 5.69965e-05 -3.38874e-05 -3.4689e-05 2.1042e-05 0.000146887 9.16483e-06 2.54023e-05 4.55562e-05 -2.27862e-05 5.6525e-05 -1.07087e-05 4.59039e-05 -1.59964e-05 -2.97551e-05 -5.90604e-06 5.31155e-05 4.29002e-05 -8.90925e-06 -3.86533e-05 -5.01523e-06 -1.39853e-05 1.22519e-05 6.68484e-05 -2.39185e-05 -1.65767e-05 -4.00721e-05 -1.021e-05 -5.31009e-05 -2.41936e-05 5.61225e-06 -8.8141e-07 3.732e-05 5.08599e-07 5.75627e-06 -1.2042e-06 2.61799e-05 1.47932e-05 5.31976e-05 3.85867e-05 -2.57723e-05 2.10592e-05 -2.35193e-05 3.61365e-06 1.81702e-07 -2.07491e-05 -4.04446e-05 -7.99132e-06 6.08975e-05 5.52525e-06 4.7333e-05 3.25183e-05 3.4878e-06 3.10508e-06 -4.27096e-05 1.87561e-05 3.18699e-05 0.000149746 -8.08383e-05 0.000149689 -2.81083e-05 -2.90929e-05 0.000134672 -8.8292e-05 0.00012026 1.36053e-05 -0.000231587 1.05648e-05 -4.93995e-05 -0.000166102 -0.000107028 0.000157076 -2.48558e-05 -0.000215708 8.01498e-05 5.19667e-05 -0.000180796 2.3653e-05 -2.89742e-05 -3.02554e-05 -6.50157e-05 4.48935e-05 -0.000109906 1.16358e-05 8.35959e-06 -1.08652e-05 0.000157736 9.02083e-05 -1.66594e-05 4.7405e-05 -2.28841e-05 4.85276e-05 2.56141e-05 1.84969e-05 0.000138423 -6.02781e-05 -5.27062e-05 -7.53482e-05 -8.08613e-05 3.34745e-05 -3.52669e-05 6.91268e-05 -8.03092e-05 4.23939e-05 9.27609e-05 0.000243616 -5.72403e-06 -4.94219e-05 0.00014628 -7.1405e-05 8.55356e-05 1.22034e-05 6.09298e-05 -3.11367e-05 -6.42697e-06 -2.72292e-05 0.000123779 2.35275e-05 -3.37284e-06 -5.36361e-05 3.52767e-05 5.3187e-05 3.20156e-06 6.04017e-05 -2.94335e-05 -3.94785e-05 0.000112019 -9.1722e-06 -8.42986e-05 1.64426e-05 -9.00643e-06 -7.45903e-06 6.17616e-05 6.97362e-05 -3.65963e-05 5.57499e-05 1.87062e-06 -3.11042e-05 5.157e-05 1.9499e-05 -6.91118e-05 4.56296e-05 -2.07362e-05 -1.38113e-05 1.30188e-05 1.13867e-05 -4.52371e-05 -8.49825e-06 6.13237e-05 1.36188e-06 5.9257e-05 5.32698e-05 3.32162e-05 5.07256e-06 -1.52598e-06 -1.20192e-05 -1.82018e-05 -3.4651e-06 -7.70076e-06 1.1044e-06 -1.06257e-05 -8.44123e-08 -8.52916e-06 -1.18237e-05 1.12727e-05 5.78922e-06 -7.17268e-06 -8.12353e-06 5.39965e-06 -7.41538e-06 2.05352e-06 -6.95571e-06 -5.76792e-08 -1.70276e-05 1.31653e-06 6.96089e-07 -7.43662e-07 6.5198e-07 -5.64783e-07 -1.01671e-05 6.75817e-06 -4.86036e-06 -4.69863e-06 -3.57041e-06 5.14888e-06 -2.85673e-06 1.37869e-05 -8.99302e-06 -1.10713e-06 -9.13772e-06 -1.88431e-05 4.57604e-06 1.36124e-05 -2.33311e-06 1.501e-05 6.8505e-06 3.76536e-06 -5.13682e-06 -1.23968e-05 -4.64573e-06 -3.04101e-07 4.59979e-06 6.87389e-06 3.45299e-06 -2.07875e-06 1.04093e-05 -2.60769e-05 -1.61338e-05 1.78724e-06 -5.05066e-06 -7.17102e-06 8.15302e-09 1.61919e-07 -3.59476e-06 1.67502e-06 5.9172e-06 -6.21921e-06 -8.39489e-06 -2.57269e-06 -1.14693e-06 2.75086e-06 -3.2756e-06 3.80879e-06 -9.01963e-06 4.61727e-06 -2.59724e-07 1.53726e-05 1.01088e-06 3.65336e-06 -6.18828e-06 2.52677e-06 -4.93218e-06 5.18474e-06 1.0143e-06 1.48265e-06 2.78554e-06 9.22643e-07 -1.23679e-05 1.79795e-06 -3.70614e-06 -1.88653e-05 7.22519e-06 1.21691e-05 -3.26793e-06 7.15673e-06 2.21735e-06 2.52272e-06 -5.65431e-06 6.43203e-07 -3.90653e-06 1.85468e-06 5.75262e-06 1.03955e-06 3.41344e-06 -1.55343e-05 2.34788e-05 5.13728e-06 3.31936e-05 -1.87615e-05 -5.79205e-05 2.0059e-05 -2.87411e-05 -5.12646e-06 -7.51597e-06 -1.37033e-05 -1.32578e-05 7.6243e-05 6.96256e-06 1.59454e-05 2.11469e-05 -5.78938e-05 -6.62637e-05 1.27126e-05 3.13268e-05 5.05484e-05 -3.02072e-05 -3.3453e-05 -9.42815e-06 -8.75902e-05 -7.99705e-05 1.95609e-05 1.08814e-05 -5.58438e-05 -2.91278e-05 -1.33686e-05 -1.83168e-05 2.52114e-05 -3.35458e-05 -8.82401e-06 -5.34932e-05 -1.61401e-05 3.60083e-05 1.5994e-06 -2.6759e-05 1.57155e-05 -4.13969e-05 -1.77825e-05 -1.53957e-05 -2.865e-07 -1.8054e-05 4.69404e-05 2.77627e-05 -1.93707e-05 -8.16045e-06 -3.76991e-06 -4.85158e-06 -2.11359e-05 -4.81174e-07 -9.88896e-06 -2.64309e-07 1.0837e-06 6.86278e-06 -1.19919e-05 -5.95992e-06 1.00639e-05 5.79067e-06 -1.42488e-05 -5.08395e-06 1.69085e-06 -3.97592e-06 6.58058e-06 -6.82074e-06 7.97439e-06 -2.54215e-05 5.29213e-06 1.33791e-06 7.80304e-06 1.09708e-06 1.17962e-05 -3.1557e-06 7.34815e-06 -1.89637e-06 -1.08169e-05 -4.1686e-06 5.39317e-06 -9.45482e-06 8.40408e-06 -8.78103e-06 -1.59268e-06 -1.43402e-05 -1.85358e-05 4.05876e-06 1.09186e-05 2.11844e-06 1.43917e-05 5.06249e-06 3.80079e-06 -5.69867e-06 -1.02161e-05 -5.12971e-06 2.04599e-06 1.38607e-06 -1.10182e-07 1.40781e-05 -4.59143e-06 1.82242e-06 -3.4795e-05 -9.19392e-06 9.79989e-06 3.11181e-05 -6.91471e-05 -2.27454e-05 -1.50005e-05 -2.36278e-05 1.05368e-05 -9.98941e-06 -1.98157e-05 -3.33668e-05 2.38551e-06 2.75232e-05 -8.5847e-06 4.03422e-05 4.42651e-07 -2.61197e-05 7.24063e-06 3.08105e-05 3.08037e-05 2.55093e-05 4.29059e-05 4.84362e-05 -2.87845e-05 -3.18912e-05 1.45087e-05 3.67462e-05 -1.35726e-05 7.41126e-06 -3.24535e-05 -2.99213e-05 1.81816e-05 -8.7426e-07 -3.45731e-05 -8.21245e-06 -9.00336e-06 1.26439e-05 3.69787e-05 -2.54198e-06 -1.628e-06 3.92847e-06 5.27371e-06 2.74833e-05 2.90054e-06 -3.89956e-06 1.51272e-06 2.00043e-05 1.6921e-06 -2.05368e-06 -4.70864e-05 -2.94496e-05 5.21358e-05 7.09199e-05 -0.000116681 -5.04327e-05 1.1636e-05 -5.21527e-05 -1.19357e-05 -6.0659e-06 -2.86945e-05 -7.10924e-05 3.1734e-05 1.22704e-05 7.90623e-06 0.000103029 -7.5223e-06 -7.37422e-05 -1.15491e-05 3.80077e-05 1.96922e-05 2.77709e-05 -6.69583e-06 0.000106412 -4.52606e-05 -4.9873e-05 2.62439e-05 0.000109892 -2.1458e-05 5.80023e-05 -1.58447e-05 -3.15744e-05 3.80341e-05 6.17063e-05 -5.59379e-05 6.6647e-06 2.11459e-05 6.33819e-06 6.09569e-05 2.98517e-05 2.96423e-05 2.61911e-05 -2.03229e-05 2.99021e-05 -3.48735e-05 1.65806e-05 -3.49786e-06 0.000216398 5.25979e-06 -9.62103e-06 5.47338e-06 7.33975e-05 0.000131849 0.000261034 -0.000217365 4.52275e-06 0.000280279 -0.00017378 1.69918e-06 7.54309e-05 -0.000374795 -0.000165984 8.37356e-05 -0.000117258 -2.74528e-05 0.00025326 4.91786e-05 -0.000195951 2.29919e-05 9.13771e-05 7.32005e-05 9.10761e-05 1.36716e-05 0.000210679 -7.93853e-05 -1.34719e-05 -2.81524e-05 0.000239009 -4.40374e-05 0.000173872 6.20022e-05 0.000114397 -6.89595e-05 0.000329208 9.97827e-05 9.04354e-05 3.14237e-05 0.000189601 0.000260228 0.000135513 6.67551e-05 -3.11253e-05 -4.3751e-05 2.35592e-05 -0.000273779 -6.12615e-05 -0.00013983 6.80913e-06 9.82477e-06 9.65534e-06 -1.02511e-05 -5.7597e-06 4.00084e-06 4.77202e-05 -6.09034e-05 -2.27967e-05 -5.51397e-05 -4.80037e-05 2.08618e-05 -2.29627e-05 -7.02524e-05 -5.71129e-05 -1.34869e-05 2.40835e-05 1.49954e-06 6.2408e-05 1.6997e-06 -3.08616e-05 -1.07235e-05 4.27821e-05 5.0828e-05 3.6113e-05 5.6104e-05 8.14098e-05 -3.81541e-05 -1.51208e-05 1.70862e-05 4.47038e-05 -3.02674e-05 1.77103e-05 -3.292e-05 3.45733e-06 2.04995e-05 5.54089e-05 -1.04626e-05 7.05685e-06 1.15101e-05 6.24618e-05 5.95116e-05 1.24579e-05 3.05088e-05 -4.78506e-06 -1.55545e-06 2.6898e-05 1.98847e-06 1.48071e-05 -9.62982e-06 9.33338e-05 0.000100674 0.000176695 1.97244e-05 -0.000159873 0.000100278 -0.000120028 2.89633e-05 7.98647e-05 1.95243e-05 -1.26184e-05 1.18583e-05 1.28639e-05 0.000153389 -1.57133e-05 3.60554e-05 5.00019e-05 2.94773e-05 1.93312e-05 -2.30165e-05 6.7483e-05 -2.31849e-05 -6.48022e-05 0.00015204 1.09169e-05 -2.96022e-05 -1.46304e-05 1.26072e-05 -2.11586e-05 3.55291e-05 -8.07712e-06 6.70445e-06 4.34575e-05 -3.26122e-05 -0.000163418 3.13565e-05 -7.42355e-05 -3.73713e-05 7.47373e-05 -4.40339e-05 3.98955e-06 1.80719e-06 3.01624e-05 3.35228e-05 3.43536e-05 3.1036e-05 4.64403e-05 2.80027e-05 5.20341e-05 7.56933e-05 0.000101558 9.33273e-05 0.000183531 -5.35295e-05 -0.000192854 0.000179776 -0.000156213 0.000139687 7.21992e-05 3.58402e-05 4.82033e-05 -3.10666e-05 1.74122e-05 0.00027477 2.84198e-06 5.58688e-05 -1.3742e-05 2.49937e-06 6.11006e-05 -3.35026e-05 6.04613e-05 -3.19528e-05 -9.54647e-05 0.000126991 -2.67506e-05 -0.000135381 -5.62157e-07 -6.86818e-06 7.30796e-06 5.68964e-05 -2.52418e-05 -4.14553e-05 7.75672e-05 -1.33289e-05 -0.000206169 6.92347e-05 -0.000148582 -0.00011771 2.08503e-05 -4.09e-05 -6.58738e-05 -2.72709e-05 3.72725e-05 -2.42271e-05 3.0967e-05 7.13177e-05 2.40754e-05 1.36753e-05 6.18334e-05 7.30508e-05 2.96859e-05 -6.29479e-05 -7.00706e-05 0.000153283 0.00029863 -0.00011077 0.000114601 0.000112785 1.55991e-05 0.000232317 -5.94456e-06 0.000253585 6.4963e-06 -0.00013133 0.00011045 -2.16919e-05 -0.000283074 -7.6508e-05 0.000124285 -2.52578e-05 -0.000152346 8.32205e-07 6.68656e-05 -0.000191514 3.68832e-05 -4.54617e-05 1.16937e-05 -9.95625e-05 0.00011234 6.29224e-05 -0.000164665 9.5303e-06 -9.8433e-05 -4.88851e-05 8.66535e-05 7.89355e-05 0.000104931 5.90616e-05 1.80122e-05 5.84389e-05 5.32577e-05 0.000203909 -0.000104119 3.30529e-06 -7.07071e-06 -5.10252e-05 3.96255e-05 3.45711e-05 6.75295e-05 -0.000100579 0.000127391 8.67977e-05 0.00020868 -5.64702e-05 -0.000135725 0.000180105 -0.000222065 7.93947e-05 2.17239e-05 1.01444e-05 0.000101527 -1.42869e-05 4.0912e-05 0.000398787 -1.65457e-05 7.13342e-05 3.23318e-05 4.1081e-05 -2.97138e-06 -6.99383e-06 6.81134e-05 -6.49652e-05 -0.000119366 0.000279661 -5.03089e-05 -9.45815e-05 -6.45333e-05 4.94698e-05 -6.84186e-05 4.02908e-05 -9.33445e-06 -2.22755e-05 2.27483e-05 -6.7897e-06 -0.000269185 9.9063e-05 -0.000166052 -0.000179387 1.06757e-05 -4.68955e-05 -0.000160844 -6.0999e-05 5.24165e-06 -5.69591e-05 6.75961e-05 5.78106e-05 1.43006e-05 7.57501e-05 6.16538e-05 7.62352e-05 1.24257e-05 3.5783e-06 5.55159e-05 -3.92738e-05 -0.000103554 4.54416e-05 -9.80411e-05 5.1606e-05 -1.15854e-05 -1.14988e-05 5.44631e-05 -4.63838e-05 4.40288e-06 0.000147125 -7.71603e-06 1.99954e-05 5.81757e-05 5.57794e-06 -2.84387e-05 -3.74627e-06 6.10782e-05 -6.51829e-06 -5.50135e-05 4.30552e-05 -2.65139e-05 -0.000100843 -1.89774e-05 3.07883e-05 -3.61757e-05 3.73746e-05 4.2284e-07 7.50424e-07 1.49913e-06 -3.90693e-05 -6.95982e-05 4.37438e-05 -5.17089e-05 -3.65365e-05 -1.17064e-05 1.43686e-05 -3.03739e-05 -3.30513e-05 -7.35313e-06 -2.38817e-05 2.00228e-05 6.20927e-05 -3.13229e-06 3.15138e-05 1.18076e-05 5.88768e-05 5.47613e-07 -7.51064e-06 4.96689e-05 -1.92724e-05 -6.77786e-05 3.9044e-05 -0.000137878 5.38971e-05 -2.86401e-05 -3.81688e-08 6.39798e-05 -3.37212e-05 -1.28839e-06 0.000130226 1.32718e-05 8.01883e-06 4.46046e-05 3.15338e-06 -2.47068e-05 -1.4718e-05 5.83961e-05 2.01152e-06 -4.92216e-05 4.38927e-05 -2.57642e-05 -8.73588e-05 -2.53231e-05 2.26196e-05 -3.46568e-05 3.04974e-05 1.10609e-05 4.94571e-06 2.10916e-06 -2.76425e-05 -4.1379e-05 3.65369e-05 -3.67895e-05 -7.19165e-06 -8.49033e-06 9.59409e-06 -2.73986e-05 -4.6571e-05 9.3307e-07 -3.2089e-05 2.5926e-05 5.67123e-05 1.05141e-06 4.27268e-05 1.62901e-05 3.9647e-05 -2.76414e-05 1.4953e-05 0.000199951 -0.000111931 -0.000210153 0.000159972 -0.000163509 -2.8812e-06 -0.000131135 -9.6034e-05 0.000252509 -7.95101e-05 3.38683e-05 0.000512511 1.1116e-05 1.20747e-05 0.000135151 -4.94485e-06 -0.000100134 -1.20678e-05 0.000191133 -3.68343e-05 -0.00016342 0.000191542 -0.000113391 -0.00025338 -0.00013585 0.000103281 -0.000125826 8.89049e-05 6.95276e-05 -8.72891e-06 2.06121e-05 -8.89228e-05 -0.000178519 5.08742e-05 -0.000204937 -0.000133648 1.16164e-06 -0.000102937 -0.000190312 -0.000128679 -0.000126445 -0.000102402 0.000127968 0.000170367 -6.35486e-05 0.00013728 1.24869e-05 0.000175817 -6.09533e-06 6.52588e-06 4.17084e-05 -2.27008e-05 -7.83921e-05 3.55541e-05 -0.000107883 4.14931e-05 -1.64182e-05 -6.07178e-06 5.57851e-05 -3.65376e-05 -7.11173e-07 0.000115059 3.384e-06 1.09983e-05 5.23708e-05 6.07448e-06 -8.28776e-06 -7.96395e-06 4.85815e-05 3.1052e-06 -4.60403e-05 3.34817e-05 -2.32896e-05 -8.10271e-05 -2.64896e-05 2.28416e-05 -3.53818e-05 1.58648e-05 3.27498e-06 5.99412e-06 4.20345e-07 -4.49415e-05 -4.47286e-05 3.36793e-05 -3.97069e-05 -1.81085e-05 -1.23375e-05 1.18955e-05 -1.93831e-05 -3.46125e-05 9.14714e-06 -2.45875e-05 1.90235e-05 5.1102e-05 -1.51054e-06 3.49356e-05 1.83838e-05 4.46337e-05 1.48523e-05 -1.17968e-05 -3.48045e-05 7.21848e-07 -3.58043e-05 -6.65854e-05 3.90157e-05 7.12896e-06 1.41954e-05 3.35273e-05 -2.28884e-05 1.11455e-05 2.33274e-06 -6.26595e-05 -2.51346e-05 -2.08989e-05 2.25361e-06 -4.23413e-05 -8.32659e-06 1.05797e-05 1.47198e-05 2.12421e-06 1.72451e-05 -2.12462e-05 2.94691e-05 8.82174e-05 -2.6366e-05 -4.44183e-06 -4.1419e-06 1.90114e-05 -5.32533e-05 2.70417e-05 -4.0545e-05 -1.32049e-05 -1.91131e-05 -1.77945e-05 -4.18611e-05 2.13443e-05 -4.56898e-06 1.09551e-07 2.23408e-05 -2.59338e-06 -2.64822e-05 -4.96165e-06 -2.8344e-05 -2.29488e-05 1.01616e-05 1.79879e-05 3.69848e-06 1.94523e-05 3.85246e-05 2.11555e-05 1.70729e-05 -1.41378e-05 -4.06856e-05 3.73554e-05 4.22395e-05 -8.29176e-05 -1.51986e-05 4.46336e-05 -3.28187e-05 2.66645e-05 5.68284e-07 -5.06582e-05 -2.76369e-05 -4.08289e-06 1.64134e-05 -4.49917e-05 1.06591e-05 -3.29758e-06 2.42772e-05 -2.48654e-05 1.44081e-05 3.6956e-05 3.5112e-05 6.41249e-05 7.70733e-06 -1.96851e-05 5.05004e-06 6.5675e-05 3.05242e-05 -6.85713e-06 3.83804e-05 -2.20458e-05 -2.12779e-05 -7.30133e-07 2.7008e-05 2.42532e-05 -2.68528e-06 -1.97239e-05 1.61619e-05 5.19182e-06 -8.32876e-06 -5.60097e-06 -1.29997e-05 9.11383e-06 1.43414e-05 9.97879e-07 2.57413e-05 1.25628e-05 0.000126095 0.000124551 7.36123e-05 1.7617e-05 -0.000249364 0.000234928 -4.01619e-05 3.47467e-05 8.34839e-05 4.06513e-05 3.10739e-06 3.76815e-05 -4.33972e-05 0.000151956 -3.34803e-05 -3.82935e-05 0.000108271 4.84137e-05 5.47907e-05 -8.80972e-06 0.000165624 -6.63166e-05 -8.16366e-06 0.000193708 5.41182e-06 0.000150073 9.3816e-05 5.10708e-05 -1.07744e-05 0.000132059 7.92597e-05 -2.95799e-05 0.000132369 -4.21583e-05 -0.000144539 5.04768e-05 -2.78354e-05 4.09306e-05 -3.74768e-06 -9.55149e-05 -1.67741e-05 -0.000151075 5.79362e-05 2.91038e-05 6.09208e-05 7.07587e-05 -9.11364e-06 6.20646e-05 1.38956e-05 9.5337e-05 4.49814e-05 5.7117e-06 -4.98066e-06 -7.17431e-06 -2.26645e-05 -1.57844e-05 2.5318e-05 -6.21352e-05 9.56491e-09 2.25071e-05 -3.37024e-05 1.70412e-05 6.70106e-07 -6.28794e-05 -3.80865e-05 9.99898e-07 2.15153e-05 -2.84716e-05 1.34793e-05 3.28897e-06 4.22383e-06 -1.22409e-05 1.81906e-05 2.29698e-05 3.27809e-05 7.43936e-05 -2.61041e-06 -1.18461e-05 3.48032e-06 2.80533e-05 -5.4435e-06 -9.28056e-07 -5.32567e-06 -2.63625e-05 -3.17064e-05 -4.67965e-06 -8.40531e-06 9.29849e-06 -4.83252e-07 2.31116e-06 2.79709e-05 1.23544e-05 -3.98603e-06 -2.28845e-06 -2.71661e-05 -4.3118e-06 4.93856e-06 -4.41863e-07 2.26985e-05 1.17216e-05 -2.03144e-05 -5.48637e-05 -2.63718e-06 8.54537e-06 -5.52145e-05 -3.47672e-05 -2.62712e-05 -3.07363e-06 -4.70921e-05 5.57087e-06 1.36513e-05 1.40849e-05 -1.6302e-05 -2.58077e-06 1.25502e-05 -2.96628e-05 4.15987e-05 -4.8126e-05 -5.65288e-06 -3.24228e-06 6.2822e-05 -1.00493e-05 1.26329e-05 -4.89963e-05 1.81714e-05 5.9266e-05 7.94485e-07 -1.87659e-05 2.78943e-05 4.33529e-05 -2.34335e-05 9.91012e-07 -1.61338e-05 -3.91089e-05 -3.34545e-05 1.32245e-05 -4.41453e-05 5.80724e-05 2.50421e-05 7.71285e-06 3.15084e-05 -6.87248e-06 -6.32529e-05 1.95532e-06 1.80374e-06 4.40273e-05 1.69986e-05 2.02113e-05 -1.21866e-05 1.85167e-05 1.71908e-05 -1.93517e-05 6.00807e-06 2.55811e-06 -3.69483e-05 -1.78254e-05 -2.7028e-05 3.44066e-05 -8.48641e-05 9.21306e-06 2.8029e-05 2.5615e-05 -5.59709e-06 2.66798e-05 3.66591e-05 -1.06745e-05 -2.43327e-06 -2.90973e-05 -1.61203e-05 3.5388e-06 0.000107885 2.59863e-07 1.41587e-06 -1.09073e-05 1.70909e-05 5.11709e-05 1.59122e-06 -3.12941e-05 4.59817e-05 5.90189e-05 -4.18786e-05 5.42443e-06 -9.61583e-06 -1.90467e-05 -1.58155e-05 1.58338e-05 -3.30799e-05 3.25301e-05 5.75436e-06 4.59292e-06 -1.3704e-05 -7.68313e-06 -5.51662e-05 -7.80809e-06 -1.32304e-05 5.09439e-05 1.31594e-05 6.26953e-05 -2.34528e-06 3.17827e-05 7.27213e-05 0.000105792 0.000142587 -0.000109259 -0.00024685 0.000222842 -0.000191572 2.92409e-05 -4.65029e-05 -0.000153447 0.00015186 -6.08388e-05 -3.07176e-05 0.000397498 -6.32601e-05 4.97454e-05 0.000210238 9.4011e-05 -7.65771e-05 5.1323e-05 0.000224211 -7.30416e-05 -0.000107715 0.000250217 -7.9665e-05 -0.000161176 -5.36017e-05 7.03339e-05 -9.67696e-05 0.000176897 6.26152e-05 -2.84363e-05 6.38557e-05 -0.000107777 -0.00017285 3.11229e-05 -3.19546e-05 -0.000123233 -3.56525e-05 -3.5917e-05 -0.000129563 -4.02573e-05 3.31796e-05 -6.67213e-06 8.13477e-05 0.000137978 -2.87953e-05 8.40398e-05 1.59059e-07 0.000110855 1.66231e-05 -4.01899e-05 -4.96271e-06 -4.25623e-06 -3.39583e-05 -1.97105e-05 -5.64328e-05 1.34841e-05 -0.000103105 8.88335e-06 3.59263e-05 2.62261e-05 -1.14876e-05 3.93275e-05 3.30649e-05 -1.94542e-05 -1.4317e-06 -3.95728e-05 -2.62842e-05 -8.98773e-06 0.000109852 -1.98491e-05 4.19408e-06 -6.3495e-06 1.636e-05 5.8991e-05 -3.1958e-06 -3.69852e-05 5.74247e-05 8.04583e-05 -3.31969e-05 1.99877e-07 -7.14778e-06 -2.6062e-05 -1.43559e-05 2.8585e-05 -4.19977e-05 2.96344e-05 3.5733e-06 1.90352e-06 -2.50843e-05 -2.18958e-05 -6.88427e-05 -2.19638e-05 -7.59462e-06 6.90437e-05 1.58801e-05 7.06384e-05 -1.02266e-07 3.002e-05 1.19226e-05 -1.35636e-05 -1.14899e-05 2.6749e-05 -3.46852e-06 -1.87058e-05 3.42487e-05 -1.66187e-05 3.85652e-05 3.74624e-05 -3.34045e-05 3.6006e-07 -7.07401e-07 -8.64579e-05 -8.314e-07 -5.31963e-06 4.61701e-05 -5.96754e-06 4.55238e-05 2.47142e-06 2.76202e-05 -1.37655e-06 3.87293e-05 1.19167e-05 2.10399e-05 0.000111295 4.78912e-05 -1.12449e-05 1.92177e-05 1.43114e-05 -2.26045e-05 3.33742e-06 9.96606e-07 -1.68023e-05 -6.20009e-06 -2.26212e-06 3.48323e-05 2.67969e-05 4.66023e-07 -1.03077e-05 4.74841e-05 4.15018e-06 5.99703e-06 3.5919e-05 -7.10443e-06 -8.47229e-06 -1.3315e-05 -4.09158e-06 -3.91853e-05 1.51959e-05 2.75837e-05 -4.27759e-05 1.6577e-05 2.71795e-05 -4.11366e-05 -2.44913e-05 2.01375e-06 -3.86179e-05 1.85443e-05 8.04294e-05 -1.60834e-05 2.12614e-05 -2.0094e-07 -5.19209e-05 -1.71766e-05 -2.52758e-05 7.53455e-05 -7.63529e-07 5.21783e-05 -6.44482e-06 4.72902e-05 3.19893e-06 3.12113e-05 2.06665e-05 8.63535e-06 0.000125848 3.36116e-05 -7.9746e-07 -2.84535e-06 2.09455e-05 -1.70786e-05 8.16413e-06 4.04309e-06 -3.31148e-05 -3.13916e-05 1.63126e-05 2.72125e-05 1.86886e-05 2.1866e-05 -7.70659e-06 2.95892e-05 -1.5482e-05 4.46916e-05 7.93856e-06 2.35696e-06 -2.88995e-05 -9.78345e-06 -1.24845e-05 -3.09384e-05 4.00254e-06 8.90802e-05 -2.45464e-05 -6.34962e-05 9.83545e-05 9.53812e-05 -9.78957e-05 0.000170331 -2.38931e-05 2.21453e-06 0.000333508 -0.00019257 9.0218e-05 3.03122e-05 -0.000318646 -9.07259e-05 -2.82813e-06 4.11551e-05 -0.000103149 6.00056e-07 -1.18165e-05 -6.00985e-05 5.33864e-05 6.02048e-05 -6.81857e-05 7.84782e-05 4.0544e-06 2.86159e-05 -2.41439e-05 5.00905e-05 -6.13765e-05 -5.40225e-05 6.02488e-05 -2.87376e-05 2.81242e-05 1.94781e-05 -3.28688e-05 0.000153699 0.000108619 0.000127467 2.97234e-05 0.000166775 0.000157282 9.67215e-05 4.89724e-05 -7.19139e-05 -0.000137399 6.42523e-05 -9.07916e-05 1.15452e-05 -0.000162138 4.14574e-05 -2.7202e-05 3.75394e-06 2.46531e-05 -3.96214e-05 -2.52097e-05 3.84513e-05 -4.34095e-05 5.11833e-05 8.53394e-05 -5.68886e-05 1.86738e-05 2.64619e-06 -0.000123745 -3.52318e-05 -2.53626e-05 5.92696e-05 9.8507e-06 6.15296e-05 6.88924e-06 3.40065e-05 7.4818e-07 5.83372e-05 2.10501e-05 1.82354e-05 0.000165144 7.90681e-05 -3.09604e-05 2.34989e-05 5.67418e-05 -2.63677e-05 -6.00239e-07 1.05126e-05 -4.64977e-05 -7.05405e-06 -1.13726e-05 6.61946e-05 3.49849e-05 2.20814e-05 -9.10228e-06 7.02177e-05 4.45522e-06 5.39306e-05 4.16926e-05 -3.5915e-06 -3.78722e-05 -1.50205e-05 -2.33072e-05 -4.89771e-05 -3.76265e-06 -5.85749e-05 2.62182e-05 6.91935e-05 -4.45847e-05 -8.87095e-05 5.58358e-05 -6.92092e-05 3.81507e-05 -2.54727e-05 -1.77286e-05 8.94271e-05 -6.56715e-05 7.16736e-06 0.000142437 2.11638e-05 7.11086e-05 1.62685e-05 -2.02609e-05 -2.3729e-05 -1.59099e-05 7.0917e-05 1.52431e-05 -6.77152e-05 -1.89558e-05 -4.87528e-05 -0.000166034 1.85095e-05 1.06466e-05 -7.5518e-06 -2.10031e-05 -1.19754e-05 -7.78306e-06 7.15942e-08 -2.50059e-05 -2.82661e-05 -3.9258e-08 -7.45995e-05 -4.22076e-05 2.74186e-05 -3.08992e-05 -1.73977e-05 5.32072e-06 -3.8145e-06 -3.29134e-05 6.07739e-05 9.98373e-05 1.93355e-05 2.90653e-05 -3.62267e-05 6.22226e-05 -4.67307e-05 3.09924e-05 -8.55273e-07 -1.70079e-05 -5.11057e-05 3.53701e-05 -5.03374e-05 8.42714e-05 1.85425e-06 -2.64402e-05 0.000124476 -7.33703e-05 3.31e-06 0.000127345 4.6446e-05 3.37368e-05 1.85504e-05 -2.26687e-06 -3.86324e-05 -1.78368e-05 8.26603e-05 2.44198e-05 -5.84713e-05 2.73182e-05 -4.22584e-05 -0.000129249 2.03173e-06 1.21319e-05 -1.45796e-05 5.21006e-06 -1.71204e-05 2.14501e-06 -6.54721e-06 -2.68528e-05 3.53003e-06 1.46372e-05 -3.18156e-05 1.55522e-06 -2.20106e-05 -1.48449e-05 -3.1676e-05 -4.51599e-05 1.90115e-05 3.34201e-05 3.17594e-05 8.76106e-05 1.09245e-05 4.33606e-05 -3.96955e-05 5.94497e-05 4.48063e-05 -0.000100751 -0.000147442 0.000109112 0.000262213 -8.39109e-05 0.000182442 -0.000127013 -6.22489e-05 0.00014097 -0.000123938 8.85964e-05 4.89606e-05 -0.000341949 -9.15053e-08 -5.92509e-05 -0.000167883 -5.76568e-05 0.000103116 -7.81229e-06 -0.000190331 -1.47489e-05 0.000141949 -0.000204014 9.51656e-05 0.000165343 -1.63354e-05 -7.48621e-05 0.000128713 -4.13101e-05 4.49103e-05 2.05415e-05 2.58638e-05 0.000204008 0.00010863 2.3735e-05 0.000192451 3.49245e-06 3.73917e-05 8.37318e-05 0.000106203 0.000209696 -6.86846e-05 4.24019e-05 -3.85772e-05 -5.80973e-05 5.24685e-05 -0.000168388 7.71789e-06 -0.000201165 3.6299e-05 -2.01721e-05 -2.68781e-05 -6.55861e-06 -0.00014811 3.62465e-05 -0.00014051 0.000112258 -7.03534e-05 4.88633e-06 0.000209019 -6.1671e-05 1.84834e-05 0.000290625 8.27162e-05 5.19755e-05 0.000103223 -4.02995e-05 -5.86815e-05 -2.25485e-05 0.00019149 1.864e-05 -9.97329e-05 -1.30353e-05 -4.24276e-05 -0.000190897 -3.18931e-05 5.38897e-05 -1.78939e-05 8.75937e-05 -7.09602e-05 6.22794e-05 -1.79536e-05 -6.17297e-05 -9.7104e-05 4.89366e-05 -0.000147938 2.75154e-05 -6.43793e-05 -2.38044e-05 -8.472e-05 -9.70926e-05 -0.000118876 -1.59502e-05 7.45083e-05 0.000144579 2.2962e-05 8.63948e-05 -7.43734e-05 0.000134471 -6.27786e-06 5.74297e-06 -1.4614e-05 -7.84033e-06 -3.71172e-05 -5.03172e-06 5.02049e-08 -3.78366e-06 1.4393e-05 2.1779e-06 -1.65262e-05 -2.53373e-05 -1.22242e-05 -6.29295e-05 -2.28126e-05 1.45141e-05 -1.1948e-05 1.29434e-05 -2.41946e-05 7.44255e-06 5.30596e-06 -4.56572e-06 1.27634e-05 -3.91377e-05 1.60679e-05 1.73435e-05 -1.05308e-05 -3.25945e-06 3.82891e-05 -1.62845e-05 -2.96119e-05 4.49986e-06 -9.58734e-06 7.86482e-06 -5.11678e-06 -5.60475e-06 -1.41539e-05 3.1782e-06 2.74115e-05 1.51195e-05 4.615e-05 -7.90432e-06 2.06865e-05 1.38734e-05 -1.26961e-05 3.15105e-05 8.02468e-06 -2.68614e-05 -2.51825e-09 1.38904e-05 -5.23642e-06 -2.36963e-05 1.81782e-06 -2.14034e-05 -4.91499e-05 -3.31698e-05 -6.18949e-05 1.36132e-05 2.04145e-05 -1.09208e-05 -1.52281e-06 -0.000123713 -1.79578e-05 -1.19459e-05 -1.88148e-06 -7.44331e-06 6.10472e-05 6.97687e-06 -3.94864e-05 1.61488e-05 5.9783e-05 -2.5978e-05 -3.35136e-06 -3.24606e-05 -6.6562e-06 9.9769e-06 -1.13352e-05 4.48737e-07 2.82736e-05 7.10304e-06 -7.02273e-05 -1.0448e-05 -3.40306e-05 -6.46147e-05 -2.15329e-05 1.80845e-05 -3.48969e-05 2.61814e-05 -4.77455e-06 1.13336e-05 2.83662e-05 -2.1916e-05 3.07647e-06 2.9576e-05 -1.50034e-05 3.33702e-05 -3.2724e-06 -1.40911e-05 4.84942e-06 2.96908e-05 0.000117218 0.000105216 4.05887e-05 -7.97062e-05 -0.000168911 0.000156728 -0.000138167 -7.44922e-06 5.69555e-05 -0.000118838 8.49242e-05 1.5982e-05 -4.67753e-05 0.000187397 -4.8241e-05 9.7355e-05 0.00016475 0.000158577 4.2865e-07 4.08674e-05 9.09707e-05 -7.10984e-05 -3.64193e-05 0.000276702 -1.43575e-05 5.74757e-05 9.79664e-05 2.10306e-05 -8.78242e-05 -3.43535e-06 7.64417e-05 -9.20605e-06 6.05503e-05 -0.000165376 -0.000133443 -7.2655e-06 -3.23494e-05 -8.84361e-05 -1.15582e-05 2.32058e-05 -5.4564e-05 -0.000143923 8.1175e-05 4.22802e-05 4.19671e-05 1.09676e-05 -3.24599e-05 6.71136e-05 -9.12825e-05 0.00013762 3.84374e-05 1.98116e-06 4.33991e-05 -2.88645e-05 -0.000122643 2.89101e-05 -8.18002e-05 8.22479e-05 -9.17718e-07 -1.24126e-05 6.25372e-05 -0.00014348 -1.70773e-05 7.67086e-05 2.22649e-07 1.45786e-05 5.12921e-05 2.09967e-05 -3.76435e-05 4.18937e-06 0.000118578 2.28896e-06 -3.16005e-05 1.77569e-05 -1.73273e-05 -4.85768e-05 -1.82491e-05 2.34253e-06 1.62585e-05 2.14908e-05 -4.42594e-05 -1.21196e-05 -1.28058e-05 -6.32613e-05 -4.41654e-05 1.21901e-05 -4.76825e-05 -1.28985e-05 -3.14787e-06 -9.45475e-06 -6.11709e-06 -3.5635e-05 6.51572e-06 2.69119e-05 2.42834e-06 0.000107583 3.27995e-06 5.38913e-06 -3.07707e-05 8.35981e-05 -8.87348e-05 -3.44789e-05 2.04353e-05 -1.84051e-05 8.3581e-07 -3.4296e-05 -2.39082e-05 -1.33445e-05 -5.87289e-05 -7.07939e-05 5.43798e-05 -8.0362e-05 2.64273e-05 6.56733e-05 1.89332e-05 -5.14459e-05 3.71681e-05 -2.71885e-05 -7.91493e-06 5.18882e-07 4.52576e-05 7.09087e-05 -2.01565e-05 3.20228e-05 -2.47342e-05 -2.26934e-05 -5.98855e-05 -6.35057e-06 1.41794e-05 -4.58772e-05 3.59052e-06 -3.59867e-06 -4.70588e-05 -2.19918e-05 5.85389e-05 -2.83469e-05 -5.03096e-05 -5.18938e-06 -5.44367e-05 -5.82229e-05 -3.2631e-05 4.19827e-05 -4.98873e-05 -7.66556e-05 -1.05564e-06 2.93313e-05 1.16516e-05 -6.05345e-07 3.13947e-05 -2.14328e-06 -6.64379e-06 -1.2414e-05 -8.35188e-06 1.30968e-06 2.52785e-07 -6.93143e-06 -1.64372e-05 -1.20271e-05 -2.26048e-05 -1.94317e-05 1.59187e-05 -9.62168e-06 1.65428e-05 3.02457e-05 3.53529e-06 -1.17791e-05 1.98933e-05 -1.34506e-05 -2.27593e-05 -1.0354e-05 7.43441e-06 1.20448e-05 -1.03362e-05 -1.4824e-05 -7.95698e-06 -2.14964e-06 -2.93382e-05 5.9994e-06 -6.77268e-07 -7.57437e-07 -8.15211e-06 -1.43204e-07 -1.3662e-05 4.67866e-07 -7.42858e-06 2.74734e-07 -2.46359e-05 -1.6762e-05 -3.99637e-05 -3.47126e-05 -2.80402e-05 -7.47533e-06 -3.44986e-05 -3.44765e-05 -2.38128e-06 1.51832e-05 3.51591e-06 1.34505e-05 -5.49907e-07 -1.288e-06 7.2782e-06 -6.32226e-05 -0.000103259 -1.41586e-05 -0.000145363 -0.000164705 6.76553e-05 3.97963e-05 8.84954e-06 1.96685e-05 -0.000131328 4.40024e-05 -0.000121378 -0.000310869 1.38363e-05 -8.47151e-05 -3.43734e-05 3.12597e-05 2.66294e-06 9.7702e-05 5.22473e-05 -1.00773e-05 0.000133844 -4.86127e-05 0.000118897 0.000365704 0.000196478 -0.000136689 0.000146843 0.000104369 -0.000125789 4.3947e-06 -4.91177e-05 -0.000147233 -1.72718e-05 9.5837e-06 5.02542e-05 4.44805e-05 0.000113898 0.000112522 0.000155185 7.02821e-06 0.000150574 8.41202e-05 -8.38603e-05 -4.73342e-05 0.000113695 1.06819e-05 6.14015e-05 -3.24137e-05 2.37706e-06 3.13977e-06 3.65051e-06 1.10762e-05 -1.08852e-05 2.74137e-05 -8.10078e-06 4.92991e-06 9.32648e-06 -1.1453e-05 3.76091e-06 2.63683e-05 -1.08352e-05 1.70168e-05 -1.28715e-05 -2.50875e-05 1.74632e-05 5.19551e-06 6.19295e-07 -3.27709e-06 -1.063e-05 -2.16579e-05 1.392e-05 1.83643e-05 2.05212e-05 5.62467e-05 2.39504e-05 -1.4701e-06 4.51745e-06 1.8253e-05 1.3277e-05 -8.26465e-06 2.61093e-05 -5.13121e-06 -2.16234e-05 9.59305e-06 1.1425e-05 -7.67681e-06 -2.11199e-05 -3.68922e-06 6.59764e-06 -2.29442e-05 -2.11838e-05 -1.525e-06 -3.4749e-06 5.44263e-06 -4.56095e-06 2.86556e-05 2.52914e-05 2.97481e-06 -0.000104568 8.89248e-05 0.000254234 4.05859e-05 -0.000114807 0.000160402 -9.27706e-05 0.00021736 -3.39431e-05 -3.35814e-05 0.000115475 -2.02752e-05 3.4401e-05 0.000421609 8.1849e-05 0.000195575 -4.64754e-05 9.83428e-05 7.48076e-05 -7.8917e-05 4.35894e-05 -0.000167868 -0.00012794 9.90636e-05 -0.000112062 -0.000335505 0.000121054 -8.92962e-06 -0.000132714 0.000155668 5.49295e-05 -2.25705e-05 4.26142e-05 -6.57877e-05 -3.83077e-05 0.000160458 1.69366e-06 1.16985e-06 4.08311e-05 -8.39986e-06 -0.000117802 -5.82996e-06 3.00754e-05 4.1449e-05 0.000161833 5.57096e-05 1.92128e-05 1.80082e-05 0.000142681 0.000134775 -5.38133e-05 0.000121252 0.000216339 -7.75394e-06 -0.000239123 0.000251054 -0.000278723 0.000417404 -8.73019e-05 -0.000112215 0.000268111 -0.000107376 3.17252e-05 0.000927675 0.000164201 0.000214676 9.83819e-05 0.00013298 -8.7621e-05 -6.53695e-05 0.000191633 -9.45892e-05 -0.000270839 0.000129042 -0.000163836 -0.000518891 1.02531e-05 0.000124507 -0.000152599 0.000146163 -3.15017e-05 1.21508e-05 2.62789e-06 -0.000194439 -0.000217493 0.000124987 -0.00021289 -0.000131684 9.23757e-06 -6.48928e-05 -0.000196118 -9.95475e-05 3.73112e-05 4.77825e-05 0.00018451 0.000179786 1.39578e-05 7.88989e-05 -7.81937e-05 0.000243385 4.07206e-05 -0.000112182 -0.000308142 0.000112201 0.000297859 -0.000194861 0.00037485 -0.000188972 -1.01252e-06 0.000366985 -0.000289493 0.000145387 2.36133e-05 -0.000565259 -0.000102549 -0.000132955 -0.000197733 -0.000104916 0.000148851 -1.4295e-05 -0.000253242 0.000115705 0.000281071 -0.000323514 0.000119788 0.000339911 6.70902e-05 -9.60494e-05 0.000191239 -6.09074e-05 -4.67717e-07 0.000126721 4.69333e-06 0.00016333 0.000155456 2.21848e-05 0.000302343 4.75221e-05 3.81953e-06 6.77362e-05 0.000150022 0.000305607 1.36125e-05 6.92265e-05 -9.52279e-05 -0.000193106 5.20692e-05 -0.000151565 -2.93475e-05 -0.000307847 -2.84696e-05 3.60469e-05 0.000138543 -2.97481e-05 -0.000130065 5.49716e-05 -0.000235598 0.000248974 -5.28427e-05 2.88494e-05 0.000136371 1.57511e-05 3.25085e-05 0.00062939 9.71813e-05 4.66175e-05 7.1015e-05 1.3075e-05 -0.000123276 -4.4256e-05 0.000138498 -0.000107837 -0.000139573 0.000190489 -9.60144e-05 -0.000181556 -8.45096e-05 6.58131e-05 -3.77299e-05 0.000170034 -0.000157966 1.61259e-05 -3.99276e-05 -1.00674e-05 -0.000257025 0.000216965 -0.000231027 -0.000176698 -2.15574e-05 -8.4972e-05 -0.000233416 -7.23187e-05 -5.92887e-05 -4.07216e-05 9.13944e-05 8.71993e-05 3.41528e-05 0.000205262 9.69457e-05 8.80717e-05 -7.56066e-06 2.21596e-06 2.96934e-05 -1.39663e-05 -1.2466e-05 1.13761e-05 -1.32619e-05 3.77904e-05 -1.00428e-05 -1.85954e-05 1.40231e-05 -2.08037e-06 5.19445e-06 4.45671e-05 2.67781e-05 1.35645e-05 -4.32877e-06 1.18297e-05 -1.68542e-05 3.99038e-06 1.00419e-05 4.35144e-06 -1.11651e-05 -7.15393e-06 -4.7932e-06 -1.70433e-05 1.76106e-05 -2.72885e-06 -4.36513e-06 3.21488e-05 3.99366e-06 4.37435e-06 6.9253e-06 -2.58142e-05 3.85537e-06 2.11081e-06 -5.69445e-06 -2.09039e-05 -1.69669e-05 1.8177e-05 -2.23063e-05 -6.22617e-06 -1.046e-05 7.66291e-06 2.82157e-06 1.01581e-05 4.54432e-07 3.60878e-05 -3.92712e-06 1.70753e-05 -1.05485e-05 6.23194e-06 1.42155e-05 -5.58855e-06 -3.24156e-05 7.37717e-06 -6.47168e-06 2.97806e-05 -9.74731e-06 -2.55791e-05 2.49766e-05 1.45904e-07 1.27643e-05 4.04027e-05 3.73913e-05 5.09886e-06 5.58096e-07 -4.04047e-06 -5.36773e-06 -1.13602e-05 4.97715e-06 1.05949e-05 -7.82041e-06 -1.87443e-05 -1.36171e-07 -1.07798e-05 2.27745e-05 2.33151e-06 -3.1298e-06 2.15172e-05 1.07169e-05 1.45446e-05 7.97712e-06 -4.26928e-05 1.21754e-05 5.48101e-06 -1.76805e-05 5.15023e-06 -2.13651e-05 1.30555e-05 -7.52993e-06 -1.19476e-05 -3.75083e-07 4.44023e-06 7.44312e-06 1.19232e-05 5.98647e-06 1.77029e-05 -1.42144e-05 2.37407e-05 8.73735e-05 8.26889e-06 -6.78171e-05 3.33369e-05 6.70504e-05 -1.40235e-05 0.000125158 5.16113e-07 9.74807e-05 0.000189258 -0.000149392 1.90996e-05 -2.3057e-05 -0.000219817 -2.32318e-05 3.51092e-06 -0.000120896 1.66153e-05 9.00668e-05 2.71556e-05 -6.57413e-05 6.84972e-08 8.07396e-05 -0.000109086 6.05428e-05 0.000114411 4.89915e-05 -6.23838e-05 5.78407e-05 1.07791e-05 3.12626e-05 3.03068e-05 3.4407e-05 1.78772e-05 3.72185e-05 1.11905e-05 0.000133117 4.0517e-05 5.28625e-05 7.08996e-06 8.15447e-05 4.5551e-05 3.46385e-05 1.02205e-05 -5.51569e-05 -6.34017e-05 7.4094e-06 -6.35512e-05 -1.27754e-05 -7.38352e-05 -1.45718e-05 8.07823e-06 3.33008e-05 -1.45204e-05 -2.78704e-05 1.90595e-05 -1.48817e-05 5.34152e-05 -9.03922e-06 -3.57982e-05 2.07431e-05 7.90495e-07 1.10284e-05 5.70382e-05 2.87754e-05 2.87865e-06 -6.11661e-06 1.46542e-05 -1.83751e-05 -3.93155e-06 4.37847e-06 -9.34774e-07 -1.15271e-05 -1.05867e-05 -3.2762e-06 -2.1748e-05 1.74201e-05 2.43202e-07 -5.29128e-06 3.79675e-05 1.65057e-05 8.55421e-06 1.33707e-05 -4.62235e-05 4.69465e-06 1.35733e-05 -5.40935e-06 -1.52346e-05 -2.61411e-05 1.45458e-05 -2.26644e-05 -1.12505e-05 -1.40171e-05 2.267e-06 6.09769e-06 8.54275e-06 4.22387e-06 3.55759e-05 7.69203e-06 1.96499e-05 6.7886e-05 1.68512e-05 -5.15103e-05 1.05731e-05 -4.36525e-05 1.41347e-05 -2.96645e-06 5.45837e-07 1.05567e-05 -9.04761e-08 9.6066e-06 3.21731e-05 -1.39148e-05 3.20752e-05 -2.18643e-05 6.29241e-05 2.08343e-05 1.4703e-05 -4.32769e-06 -2.17273e-05 -2.83294e-05 -2.9593e-05 -1.1838e-05 1.38325e-05 -1.4673e-05 -1.40994e-06 -2.26236e-06 1.17771e-05 -2.43947e-05 2.03882e-05 -2.00445e-05 6.06585e-06 -1.59928e-05 -5.68315e-06 -4.68756e-05 3.96387e-06 -1.72688e-05 -8.72249e-06 -8.62953e-06 -2.49162e-05 -2.50437e-05 -2.80086e-05 6.49653e-05 5.2843e-06 2.80069e-05 -1.24777e-05 1.32412e-05 2.30776e-05 -4.90116e-06 3.25363e-05 4.92861e-05 1.02744e-05 -5.89308e-05 -1.14968e-05 -3.4727e-05 1.32715e-05 -1.41215e-05 2.26208e-05 1.8092e-05 -1.23106e-05 1.83574e-05 -4.20258e-07 -8.92444e-06 5.36171e-05 -2.89914e-06 8.95506e-05 1.26133e-05 2.95741e-05 -1.60681e-05 -1.45207e-05 -1.31102e-05 -3.34399e-05 -1.45655e-05 3.40911e-05 -1.6089e-05 -8.17951e-06 3.33806e-05 1.00401e-05 -1.10736e-05 1.1873e-05 -1.52075e-05 2.80034e-06 -1.1066e-05 -5.14324e-06 -3.80105e-05 8.11913e-06 -3.57958e-05 -4.2122e-05 -1.82444e-05 -1.93942e-05 -2.83151e-05 -3.80373e-05 5.17961e-05 1.14792e-05 3.20731e-05 -3.3821e-06 5.81507e-06 1.06539e-05 -3.51214e-05 5.06751e-05 3.25284e-05 -4.94378e-05 -0.000125204 4.52272e-05 0.000217475 -6.51668e-05 0.000133473 -0.000130036 2.71842e-05 0.000141067 -0.000117842 3.91286e-06 3.04604e-05 -0.00023796 -1.84507e-05 -2.82519e-05 -5.60539e-05 -8.30138e-05 0.000105442 -1.5532e-05 -0.000190568 2.26608e-05 6.92686e-05 -0.000116195 4.64625e-05 2.6238e-05 -5.24707e-05 -1.5047e-05 1.69954e-05 -6.48645e-05 1.79161e-05 3.23694e-05 1.09244e-05 0.000126192 9.33479e-05 4.04635e-05 9.48028e-05 7.15039e-05 2.28758e-05 -3.84394e-05 8.43814e-05 0.00013177 2.27181e-05 -8.11572e-06 -3.22526e-05 -0.00010676 1.14538e-05 -0.000133375 5.85626e-05 -0.000159125 6.8504e-05 3.73375e-05 -3.85647e-05 -2.0706e-05 -2.61765e-05 8.54933e-05 -1.14173e-05 7.21418e-05 -2.35155e-06 -2.78904e-05 4.00651e-05 2.88585e-06 -1.19358e-05 0.000141717 3.12315e-05 0.00013031 2.50998e-05 4.98317e-05 1.61977e-05 -1.65766e-05 -1.39647e-05 -6.98522e-05 -1.694e-05 7.58093e-05 -2.49518e-05 -3.01387e-05 0.000102431 2.76844e-06 -1.02119e-05 1.99909e-05 1.9453e-05 -1.71181e-06 3.88728e-05 -3.56463e-05 -4.19464e-05 8.01814e-05 6.00773e-06 -4.33401e-05 -2.86222e-05 -3.31306e-05 -5.42247e-05 -1.99354e-05 6.38378e-05 3.00224e-05 4.04644e-05 1.71241e-05 -4.48829e-06 -1.29272e-06 -1.55113e-05 7.60788e-05 -3.63177e-05 4.05781e-05 3.53582e-06 -2.91904e-06 1.79579e-05 7.3595e-06 2.50198e-05 6.73802e-06 -1.88059e-05 -3.62788e-05 -5.11856e-06 3.01529e-05 -1.9757e-05 2.28163e-05 1.68138e-05 -7.39101e-06 -4.92619e-05 1.74678e-05 -2.29513e-05 -1.06222e-05 -3.75801e-05 -4.50849e-06 2.76965e-06 2.60617e-05 4.38554e-07 8.34424e-06 -1.93817e-06 -6.08034e-06 9.33222e-06 -3.19241e-06 8.92444e-06 -4.66992e-06 1.06031e-05 2.21411e-05 1.98206e-05 -1.36659e-05 -1.84843e-05 -2.83672e-05 -2.27037e-05 -7.15402e-06 -1.63176e-05 1.11174e-05 4.57244e-06 -1.72573e-05 2.50921e-06 -2.63542e-05 5.09153e-06 1.69539e-05 4.69641e-05 -8.32098e-06 -5.33196e-05 2.91829e-05 1.92338e-05 9.03521e-06 -1.6882e-05 -1.07422e-05 3.1468e-05 -2.68983e-06 -5.79767e-06 -5.9198e-05 -1.09208e-05 2.01354e-05 -1.663e-05 -3.43767e-05 6.22103e-06 -6.57898e-06 -7.00273e-05 2.11196e-05 -6.95915e-06 -4.73339e-06 -2.72954e-06 -3.3893e-05 1.99129e-05 2.59697e-05 1.56401e-05 5.6634e-05 3.08911e-05 -1.56997e-05 2.19922e-05 -1.49149e-06 3.41373e-06 -6.54525e-06 2.35443e-06 -1.91427e-05 3.44605e-05 -2.71064e-05 -7.06711e-06 -2.6773e-06 1.4664e-05 8.99562e-06 4.05318e-05 3.58846e-05 4.30935e-07 2.89089e-05 -4.4636e-06 -2.74712e-06 1.94754e-05 1.15166e-05 -1.22737e-06 8.48813e-06 -4.726e-05 5.00863e-06 7.98797e-05 -1.22464e-05 -0.000180352 4.43415e-05 -0.000105442 3.03143e-05 -2.1461e-05 -0.000159617 5.47154e-05 2.32133e-05 -6.02161e-05 0.000228009 3.07451e-06 5.6607e-06 0.000122251 4.68534e-05 -4.09896e-05 -1.49387e-05 8.98942e-05 -0.000112952 -1.75908e-05 6.6314e-05 -1.27286e-05 7.59224e-05 6.14078e-05 3.08408e-05 -3.74796e-05 4.68773e-05 -1.0582e-05 -1.9722e-05 -1.15434e-06 -0.000137142 -9.83876e-05 9.27816e-05 -3.10709e-05 -8.38307e-05 -3.28775e-05 5.40477e-06 -2.29372e-05 -8.16579e-05 -4.56509e-07 -1.26095e-05 4.90526e-05 4.24426e-05 5.82354e-06 0.000159485 5.88853e-05 0.000117034 -6.39222e-05 5.23693e-05 1.34507e-05 -1.2887e-06 7.62771e-06 -5.74355e-06 5.03278e-05 7.01114e-06 -9.3367e-06 -5.25854e-05 -3.7083e-05 3.92092e-05 -1.77981e-05 -4.16537e-05 1.76773e-05 -5.52874e-06 -0.000112543 3.04805e-05 -1.70205e-06 -1.73938e-05 -5.82288e-05 -1.27381e-05 2.02666e-05 3.84052e-05 1.25299e-05 4.76724e-05 3.99717e-05 -1.76844e-05 2.64004e-05 -4.85078e-06 1.24937e-05 -1.05842e-05 4.42702e-06 -1.90212e-06 5.35502e-05 -2.65037e-05 -9.81187e-06 -5.54112e-06 1.08143e-05 1.37238e-05 2.70075e-05 4.28703e-05 2.55495e-05 1.14614e-05 -1.19224e-05 -3.95966e-05 2.99588e-05 1.87216e-05 3.96016e-05 -6.09755e-06 1.40511e-07 2.93868e-06 1.30816e-05 1.06108e-05 -1.32606e-05 -2.5404e-06 2.30901e-05 4.3657e-06 1.63949e-05 -9.36688e-06 -1.61781e-05 9.90627e-06 1.97879e-06 -1.54668e-05 -1.08231e-05 -3.26268e-06 1.111e-05 8.21089e-07 2.42264e-05 -5.82671e-06 1.06345e-05 -1.4704e-05 1.19426e-05 -6.71094e-06 9.50247e-06 2.26482e-05 1.36737e-05 1.04178e-06 -2.66888e-06 1.29973e-05 1.15014e-06 7.72742e-06 7.37866e-06 -2.15365e-05 -6.15273e-06 9.45672e-06 1.67858e-05 1.62957e-05 -4.46606e-07 -6.02375e-06 2.70618e-05 -1.87339e-06 -1.66511e-05 1.37195e-05 2.2279e-07 6.3021e-06 3.1476e-06 -6.6153e-06 -2.39251e-06 -1.96712e-07 4.70833e-06 -5.39575e-06 -1.25585e-05 6.5786e-06 -9.59742e-06 -2.07444e-05 9.95844e-06 1.80811e-05 1.80218e-05 -2.5435e-06 -9.6097e-06 6.14275e-06 -5.03572e-06 -2.33858e-05 -6.91341e-08 -3.23839e-06 1.30119e-05 -1.06413e-05 2.24376e-06 2.91714e-06 1.68253e-05 -9.93408e-06 1.2525e-05 -5.44264e-06 1.54257e-05 4.45663e-05 8.25523e-06 3.14183e-06 7.27012e-06 6.16337e-06 -2.29728e-05 1.41779e-05 -9.94982e-06 -2.17647e-06 -8.46935e-06 8.94627e-06 9.62482e-07 9.93153e-06 -3.98748e-06 -1.04199e-05 2.70112e-05 -9.04875e-06 -1.51102e-05 3.11198e-06 -1.03575e-05 2.95505e-06 2.60767e-06 1.57603e-07 -5.71512e-06 -1.28029e-06 -9.63117e-05 -2.0497e-05 9.3792e-05 -1.37801e-05 5.08766e-05 9.16527e-05 -6.22516e-05 1.68564e-05 -9.50673e-05 -6.57695e-05 0.000138265 -4.16543e-05 4.86841e-05 0.000170267 1.83646e-05 3.96751e-05 1.27171e-05 2.85717e-05 4.49074e-05 -3.29321e-05 -6.09785e-05 5.83739e-06 -7.47482e-05 2.75748e-05 -9.49698e-05 -0.000242649 -3.5394e-05 8.76341e-06 -6.12939e-05 -6.74256e-05 0.000102712 -5.98561e-05 4.89653e-05 -1.57046e-05 5.84376e-05 8.62003e-06 4.72355e-05 1.51269e-05 7.8553e-06 -1.69456e-05 -9.86866e-05 -1.39578e-05 2.55459e-05 -5.99286e-05 0.000102127 3.88685e-05 -1.8957e-05 -3.34133e-05 -3.35978e-06 3.20172e-06 7.79295e-06 1.557e-06 8.48562e-06 7.35959e-06 -1.83363e-05 -6.15713e-06 2.5617e-05 1.86902e-06 1.52223e-05 -5.03921e-06 -1.41721e-05 1.99585e-05 -1.19018e-06 -3.01314e-05 -7.95458e-06 -8.53289e-06 1.18504e-05 -4.37501e-06 1.81151e-05 1.37387e-06 1.19262e-05 -1.54223e-05 1.30097e-05 -6.19652e-06 1.43389e-05 2.95652e-05 1.17313e-05 3.55679e-06 5.0757e-06 1.41676e-05 -7.49502e-06 8.92932e-06 4.18421e-06 -2.80676e-05 -1.4038e-05 4.49549e-06 1.52421e-05 7.67386e-06 -7.92242e-07 -7.45882e-06 2.99299e-05 4.24251e-06 -2.07161e-05 3.71331e-06 -6.56597e-06 7.08013e-06 5.83329e-06 -8.62536e-06 8.5472e-07 -1.84015e-06 5.23738e-05 2.29427e-05 4.00562e-05 -4.5461e-06 -2.92071e-05 3.71275e-05 6.01334e-06 -2.14337e-05 6.18173e-07 2.41418e-05 -2.47083e-05 2.44461e-05 6.51447e-06 2.82069e-06 -1.10303e-05 4.36708e-06 -2.59983e-06 -3.24915e-06 2.52333e-05 7.38365e-07 -1.98722e-05 -2.66702e-06 3.97406e-06 2.2111e-05 1.3899e-05 1.69354e-05 1.48698e-05 5.12738e-06 -1.44391e-05 1.72616e-05 4.29772e-05 -6.34944e-06 3.45528e-05 7.09403e-06 -9.32851e-06 2.04285e-06 2.89561e-05 -4.65305e-06 6.74172e-06 -6.21593e-06 5.06661e-06 2.41045e-05 1.78046e-06 -1.22402e-06 -4.41063e-06 -5.62827e-06 -1.3171e-06 9.02279e-07 2.80898e-05 8.88516e-06 4.60877e-05 1.80481e-05 3.94917e-05 3.27787e-06 -5.37976e-05 4.08792e-05 9.16635e-06 -2.0336e-05 2.14993e-06 2.88435e-05 -9.22566e-06 3.47382e-05 -1.31909e-06 3.22824e-06 1.34337e-05 2.88501e-05 -1.30349e-06 -5.34511e-06 7.96846e-05 -7.78898e-06 -1.46991e-05 1.16024e-05 -7.41115e-06 3.28134e-05 1.21096e-05 -1.59459e-06 3.71503e-05 5.36416e-07 -3.35672e-05 7.72624e-06 4.54567e-05 -1.30931e-05 1.96795e-05 7.57395e-06 -1.10745e-05 -6.16921e-06 -1.31329e-06 -5.09564e-06 2.85947e-05 -1.06204e-05 -8.30666e-06 1.57127e-05 1.20647e-05 -1.36949e-06 -2.90708e-06 -1.23435e-05 -1.43877e-06 -1.47724e-06 -9.04465e-06 2.96338e-05 -9.44254e-05 -4.27315e-05 5.58222e-06 2.54881e-05 0.000144207 -2.96181e-05 -1.13963e-05 7.54769e-05 -2.8608e-05 1.60482e-05 5.195e-05 -3.12666e-05 5.95581e-05 8.07308e-05 6.84906e-05 7.85842e-07 -2.01351e-05 -3.51586e-05 -2.6644e-05 -2.91829e-05 -2.12477e-05 2.91205e-05 -5.6667e-05 -8.31546e-05 -7.05315e-05 -0.000213535 -8.22271e-05 3.3803e-05 -3.23203e-05 -3.37965e-05 -4.27454e-05 1.25825e-05 -4.10779e-05 8.20185e-05 2.63669e-05 2.29985e-05 -6.13309e-06 -1.24074e-05 2.2908e-05 3.67205e-06 -4.79922e-05 7.26136e-05 -6.635e-05 -4.43019e-05 1.19893e-05 -2.02393e-05 -5.25493e-06 -3.00074e-06 4.20288e-05 -2.81248e-05 6.44532e-05 2.38013e-05 6.36681e-05 -3.99083e-06 -4.3074e-05 6.81487e-05 5.03022e-08 -1.19746e-06 6.13657e-06 1.91162e-05 -9.72863e-06 2.6954e-05 1.6957e-06 2.74059e-05 9.5502e-06 2.99455e-05 -9.52724e-06 8.58034e-06 6.45081e-05 7.54723e-08 -1.45129e-05 -8.32853e-06 -4.48762e-06 4.84461e-05 1.14828e-05 -3.17066e-06 4.05578e-05 7.79767e-06 -2.58471e-05 2.35967e-05 6.37661e-05 -1.94284e-05 4.10989e-05 1.35729e-05 -5.66379e-06 9.30439e-06 1.33522e-05 -1.61092e-05 1.60803e-05 -6.11459e-06 -8.56076e-06 1.54178e-05 1.3566e-05 6.89984e-06 2.1364e-06 -3.41715e-06 -7.27692e-06 -5.75339e-06 2.47404e-05 3.02766e-05 -1.6435e-05 4.92935e-06 4.30034e-06 1.37539e-05 -1.15591e-05 6.62311e-06 3.51069e-06 1.66932e-05 -3.83737e-06 -4.17254e-05 2.17804e-05 3.21115e-05 1.16629e-05 -5.60343e-06 5.11482e-06 2.64857e-06 -1.08454e-05 1.67737e-05 5.91535e-06 -2.6892e-05 3.09182e-05 -1.20414e-05 1.42955e-07 3.39674e-05 8.04925e-06 2.89287e-05 3.03133e-05 -4.33069e-06 -6.09992e-06 -1.06423e-05 3.94079e-06 -9.83901e-06 4.28341e-06 -9.98763e-06 -9.72704e-06 -4.57787e-06 -1.42739e-05 2.59811e-05 2.80897e-05 1.76741e-05 -9.08371e-07 -1.69465e-05 2.11873e-05 3.25983e-05 7.73516e-06 -7.24083e-06 3.33022e-06 1.25644e-05 -2.03079e-05 2.4048e-05 7.49072e-06 3.11345e-06 -6.80413e-06 8.17138e-06 -1.10604e-05 7.68079e-06 -4.78771e-06 3.98797e-05 9.24603e-06 -1.50979e-06 -4.47365e-06 1.52106e-05 9.03028e-06 -1.09399e-05 -1.12924e-05 7.991e-06 -2.61557e-05 1.96453e-05 2.25319e-06 -3.89184e-05 1.13577e-05 -2.22587e-05 -6.31627e-07 1.09746e-05 -1.61786e-06 2.23191e-05 2.62007e-05 -5.64151e-06 -1.24719e-05 1.17796e-05 -4.42513e-06 -4.95189e-06 -5.31182e-07 -1.9894e-05 -2.23525e-05 3.90576e-06 2.8774e-06 2.78774e-05 3.3057e-05 2.76555e-05 1.29141e-05 -1.93019e-05 5.30539e-05 3.19465e-05 1.32904e-05 -4.43046e-06 -3.69581e-06 1.06876e-05 -1.12389e-05 2.29529e-05 3.72381e-05 3.84752e-05 7.60459e-05 -5.50146e-05 -0.000150301 3.62851e-05 -9.67166e-05 8.03477e-05 2.34031e-05 -0.000213838 5.16448e-05 -9.23583e-06 -2.65938e-05 7.45991e-05 -1.26246e-05 -2.70805e-05 6.48936e-05 7.70434e-05 -4.82366e-05 4.39519e-05 0.000127916 -6.60122e-05 9.54234e-06 8.44737e-05 1.75536e-05 0.000142528 9.07197e-05 5.90273e-06 5.62713e-06 4.96246e-05 -4.02564e-06 -2.23988e-05 1.93662e-05 -0.000110358 -5.54461e-05 2.84305e-05 -3.35774e-05 -5.57723e-05 -4.40639e-05 5.14741e-05 -6.8653e-06 -0.000106383 1.56594e-05 5.84908e-05 -2.24833e-05 8.24243e-05 -3.81347e-05 9.90241e-05 -7.03429e-06 0.000120864 -4.97893e-05 -5.35413e-06 2.02674e-05 2.78668e-05 -3.21433e-05 2.5493e-05 7.67935e-07 3.97485e-05 -3.06279e-05 -1.08055e-06 5.42566e-05 1.8379e-05 1.78681e-06 0.000114111 3.17906e-05 2.00011e-05 -8.08493e-06 1.02615e-05 4.68447e-05 -9.37544e-05 6.54466e-05 -3.72265e-05 -1.96486e-05 -1.14444e-05 -1.7354e-05 -3.3423e-05 3.75303e-05 7.9539e-06 -3.93121e-05 2.44273e-05 1.25879e-05 -7.88313e-06 4.47212e-06 -3.79434e-05 -4.76196e-05 4.20988e-05 -3.0369e-05 6.09982e-05 2.47497e-05 -2.38682e-05 -1.86354e-05 -4.35425e-05 -1.83138e-05 3.65355e-05 4.97735e-05 2.16715e-05 2.42944e-06 4.88959e-06 -4.44766e-05 6.05764e-05 1.2063e-05 3.16268e-06 2.57533e-05 6.55784e-06 -3.19104e-06 1.17636e-05 6.89501e-06 -1.54998e-05 1.73239e-05 -2.90511e-05 1.12928e-05 6.2106e-06 1.39756e-06 9.8355e-07 -1.95428e-05 -2.10572e-05 4.16913e-06 6.10404e-06 1.75236e-05 1.4303e-05 2.60259e-05 2.89666e-06 6.18681e-06 1.73728e-05 7.8476e-06 1.07716e-05 2.11295e-05 -4.01035e-06 1.04205e-06 -7.93158e-06 5.72164e-06 -4.39117e-06 1.09755e-05 -2.27771e-05 2.98849e-06 6.13055e-06 1.13626e-05 1.52518e-05 -7.2379e-06 -2.56089e-06 1.43304e-05 -1.51948e-05 -1.79281e-05 9.54539e-06 8.64111e-06 1.17235e-05 2.12374e-06 5.78295e-06 -1.02692e-06 9.3463e-06 4.17238e-06 -1.14689e-05 -9.00549e-06 1.49129e-05 -2.61841e-06 -2.52013e-05 2.35012e-05 3.90699e-06 2.95524e-05 -4.44447e-05 1.35724e-05 1.99932e-05 -2.80165e-06 -1.3183e-05 5.46276e-06 -2.06579e-05 1.37406e-05 7.11149e-06 -1.03173e-06 1.31435e-05 3.10751e-05 -2.89046e-06 1.46178e-05 4.94289e-06 1.40053e-05 5.66771e-05 1.43279e-05 1.50943e-07 -1.90995e-06 -1.83515e-05 -1.54386e-05 -4.08714e-06 -1.62531e-05 -1.68513e-05 -1.1457e-05 -6.06614e-06 -1.12552e-05 2.50641e-05 2.78694e-06 -6.22318e-06 1.73889e-05 -6.24311e-06 -5.41641e-05 2.42783e-05 -9.20712e-06 -5.20103e-06 -1.95706e-06 1.49333e-05 -2.47459e-05 1.81703e-05 3.21857e-05 2.62286e-05 -3.93337e-05 -1.70433e-05 -2.36944e-05 3.73243e-05 -5.41202e-05 -4.83097e-05 1.11355e-05 -0.000106527 -4.90234e-05 4.32268e-05 -5.86432e-05 -7.57767e-05 -8.66746e-05 -6.09102e-06 2.84515e-05 0.000107214 2.96535e-05 5.35051e-05 3.92774e-05 -2.65762e-05 7.79242e-05 0.000109075 4.37251e-05 0.000280698 7.52003e-05 -3.97717e-05 2.22814e-05 1.42911e-05 0.000116508 -1.37339e-05 5.96691e-05 -9.53356e-06 -1.93752e-05 7.62164e-06 0.000128907 -8.71196e-05 -8.83106e-05 1.84068e-05 -2.56971e-05 -2.58098e-05 0.000111471 1.93047e-05 -3.99134e-06 1.84479e-05 1.36655e-05 3.28652e-05 7.93418e-06 -9.16947e-06 2.39903e-05 2.96002e-06 3.46658e-05 -1.29125e-05 -4.0932e-05 4.62901e-05 2.95269e-06 -1.59531e-05 1.60176e-05 -4.31834e-05 1.87433e-05 2.58211e-05 -1.07689e-05 -4.0308e-06 -2.6308e-05 -2.46649e-05 1.27233e-05 1.99744e-05 2.32131e-05 1.06815e-06 2.97985e-05 -9.80795e-06 1.52691e-05 6.31084e-05 2.19417e-05 6.65188e-05 2.01457e-05 -2.16741e-05 6.06434e-06 6.89878e-06 4.36456e-05 -3.04101e-05 3.82668e-05 -1.68511e-05 -2.15819e-05 -6.4215e-06 1.5749e-05 -3.19493e-06 2.33125e-07 -2.05071e-05 1.69409e-05 -2.17558e-05 -2.16497e-05 6.51027e-06 1.56173e-06 3.56789e-05 1.28958e-06 1.04866e-05 -9.51259e-06 1.82309e-05 -5.46031e-06 -9.31966e-06 3.84567e-05 2.89318e-05 3.98963e-05 -3.43111e-06 -1.35437e-05 -3.18122e-05 -9.17343e-06 1.79402e-05 -3.47103e-05 1.36189e-05 -2.03394e-06 -1.30201e-05 -9.21574e-06 1.54973e-06 -2.74255e-05 -6.73399e-06 -4.32614e-06 -3.0227e-05 -6.90619e-06 -3.6254e-05 6.24229e-06 -5.67229e-07 1.2344e-05 3.90379e-05 -1.67347e-05 4.26303e-06 5.6019e-06 -3.16021e-05 1.44414e-05 -5.07404e-06 9.74556e-06 7.45145e-05 -5.86114e-06 1.34932e-05 1.09961e-05 1.02402e-05 1.63681e-05 -1.44906e-05 -9.76324e-06 -6.48236e-06 -1.17976e-05 -2.65137e-05 -7.08475e-06 -2.12173e-05 -2.47871e-06 1.20463e-07 2.25185e-05 -2.36292e-06 1.98697e-05 -1.4524e-05 8.89202e-06 1.47854e-05 2.72475e-05 2.93715e-05 -1.06123e-05 -9.09279e-07 -1.23239e-05 9.30041e-06 -1.51194e-05 -1.66891e-05 -2.14019e-06 4.85659e-05 -1.70348e-05 4.52682e-05 -2.80495e-05 -5.71485e-06 -3.00726e-05 -3.96294e-05 -2.33098e-05 -0.000108661 -2.02582e-05 -3.63353e-07 -1.29742e-05 -3.31488e-05 -9.64843e-06 2.69708e-06 -2.06404e-05 -1.96537e-05 6.30456e-06 -1.45188e-05 1.91479e-05 7.64866e-05 -4.52166e-07 1.0222e-05 -3.32159e-06 -9.2581e-06 2.40431e-06 -3.91011e-05 -1.81674e-05 -1.25716e-05 -1.02937e-05 -1.16252e-06 2.02425e-05 -1.33356e-05 -2.14893e-05 -4.46831e-05 1.89283e-05 8.85737e-06 -7.94949e-06 4.52071e-05 0.000119409 -1.73034e-05 -7.19848e-05 3.5193e-05 -0.000137945 0.000111826 -3.09164e-05 -0.000234168 7.10289e-05 -4.76558e-05 -3.52233e-05 0.000258843 7.82458e-05 6.30516e-05 0.000112259 7.00171e-06 -0.000114235 8.77385e-06 0.000156035 -7.86121e-05 -7.42846e-05 8.86594e-05 -3.57039e-05 -4.07877e-05 -3.45735e-05 1.74365e-05 -6.88193e-05 1.64156e-05 -4.25171e-05 -2.05579e-05 -3.24435e-05 8.83369e-05 -5.9419e-05 2.27321e-05 -0.000101169 -1.29934e-05 1.25594e-05 -2.96895e-05 -8.34287e-05 -0.00010116 -8.45827e-05 -1.39767e-05 1.14596e-05 8.48149e-05 -4.06802e-05 0.00011166 -3.33873e-05 0.000115374 1.06846e-05 -2.05317e-05 8.02951e-06 2.94895e-05 5.48862e-05 6.93425e-06 8.85085e-06 -3.83289e-05 -9.60311e-06 1.23876e-05 -3.03159e-05 4.61027e-06 -4.90378e-06 1.95503e-05 -1.59415e-05 2.61953e-05 -3.99008e-05 -1.14378e-05 -1.65974e-06 -4.63651e-05 -1.84076e-05 -9.95713e-05 -2.39341e-06 3.11017e-06 -1.16825e-06 1.78451e-05 -2.51366e-05 2.77448e-06 -2.07991e-05 -1.9187e-05 1.55057e-05 -1.17286e-05 1.40564e-05 8.96083e-05 -8.61419e-06 1.76134e-05 6.2387e-06 -3.21068e-06 1.19115e-05 -3.06531e-05 -1.85962e-05 -1.33185e-06 -3.2268e-05 -2.2839e-05 1.00425e-05 -2.20615e-05 -1.94596e-05 -2.2815e-05 2.97801e-05 -5.20724e-06 1.2359e-05 -1.28739e-05 3.6263e-05 -1.45765e-06 -7.36593e-05 -2.25891e-05 -5.41071e-05 4.46765e-05 6.25157e-05 9.91196e-06 2.19749e-06 -6.19224e-05 4.75223e-05 -9.53858e-05 3.01461e-06 2.55993e-06 9.18505e-06 1.10404e-05 6.33019e-05 3.55967e-06 5.30735e-05 1.02367e-05 -1.48958e-05 5.46e-05 -9.31522e-06 9.80013e-05 3.45148e-05 1.15977e-05 -1.2497e-06 -0.000105086 -4.17137e-05 -2.87266e-05 -1.15597e-05 -3.67217e-05 -3.77358e-05 -1.60771e-05 -5.026e-05 6.02637e-05 4.28027e-05 1.17828e-05 5.94127e-05 -6.30617e-05 4.12826e-05 -4.89978e-05 -4.39177e-05 -4.43635e-06 1.70303e-05 -5.23041e-05 -2.14142e-05 4.34467e-05 3.3143e-05 -2.15702e-05 -7.8414e-06 3.53647e-05 -4.46125e-05 -5.74254e-05 -3.21027e-05 3.10817e-05 6.21708e-05 -1.88062e-05 -5.54824e-05 -2.25518e-05 1.29429e-05 -0.00021557 -3.25724e-05 -3.683e-05 4.48974e-05 -3.70634e-06 4.36498e-05 1.64035e-05 4.70241e-05 4.86072e-05 1.51143e-05 6.92942e-06 1.38156e-05 0.000133632 4.29187e-05 2.20211e-06 3.19577e-05 -0.000142491 -6.81787e-05 -3.2664e-05 -2.09196e-05 -9.26782e-05 -3.38052e-06 -8.20016e-05 -2.21184e-05 0.000106436 6.33587e-05 3.25115e-05 0.00015546 -1.77944e-05 2.55872e-05 4.7696e-06 -7.82506e-05 -3.38192e-05 8.47933e-07 -5.49525e-05 -5.96523e-05 1.17754e-05 2.10196e-05 -9.38675e-06 7.95415e-06 -6.38086e-05 -3.15521e-05 -6.16162e-05 -0.000146164 -1.64853e-05 4.74403e-05 -0.000200701 -6.18774e-05 -5.6489e-05 -7.60248e-05 -8.51885e-05 -3.65951e-05 -5.90727e-05 0.000164733 -4.04293e-05 -0.000123822 0.000102447 0.000113648 0.000114526 2.16261e-05 5.33799e-05 3.53274e-05 0.000178268 -2.045e-05 5.29135e-05 6.74327e-06 -9.15339e-05 -7.09505e-05 -6.2638e-05 -2.51672e-05 -1.27829e-05 -2.87945e-05 -0.000124667 -9.93527e-05 6.76354e-05 5.93194e-06 7.60412e-05 8.10934e-05 -0.000113712 -5.48141e-05 4.92242e-06 -9.36806e-05 -4.46958e-05 -5.34659e-05 8.93311e-05 8.32186e-06 3.02925e-05 -6.96273e-05 8.65391e-06 0.000153453 -5.08553e-05 -9.42547e-05 -9.94001e-07 -0.000414283 0.000239748 -6.70426e-06 -0.000104646 0.00030311 2.39897e-06 5.22452e-05 0.000908309 0.000196152 5.86327e-05 -4.60483e-06 9.00759e-05 -0.000293405 -5.81151e-05 0.000207071 -0.000104196 -0.000219711 0.000269395 -0.0001602 -0.000132468 -0.000215781 0.000150408 -0.000121024 9.77945e-05 -0.000164367 5.91754e-05 -8.91332e-05 0.000126556 -0.000306473 0.000267695 -0.00040919 -0.000302526 -0.00018857 -0.000125584 -0.000532802 -0.000307615 -4.87859e-05 -0.000218432 0.000118858 5.41863e-05 -1.06289e-05 0.000325373 0.000176299 0.000137226 2.74079e-05 5.2491e-06 7.23337e-06 6.03697e-06 -4.95555e-05 1.19614e-05 -2.9219e-05 -3.44312e-05 -1.24401e-05 -1.49306e-05 6.61263e-06 2.3893e-05 -6.42903e-06 1.88048e-05 -1.39317e-05 5.12668e-06 2.08212e-05 -8.65223e-06 2.71693e-05 -1.02441e-05 5.272e-05 -1.44194e-05 7.67366e-06 5.58338e-05 -9.75115e-07 3.44681e-05 1.28416e-05 -1.22672e-05 2.73347e-06 3.75121e-05 1.6967e-05 -7.29779e-06 2.44477e-05 -3.67486e-05 -2.00495e-05 1.99218e-06 4.62436e-06 9.55466e-06 5.5078e-07 -2.319e-05 9.95325e-06 -5.6003e-07 -8.2523e-06 2.10567e-06 1.38304e-05 2.98317e-05 4.67771e-06 1.52675e-05 -3.45158e-05 2.1577e-05 2.79519e-05 1.49483e-05 2.8083e-06 1.23009e-05 -3.43535e-05 6.22377e-06 -2.90534e-05 -7.9332e-06 9.04726e-06 1.09139e-05 -2.58329e-05 2.60559e-05 -1.72809e-05 1.54108e-06 -7.33986e-06 -5.53658e-06 -1.18853e-06 1.21414e-05 1.89593e-05 3.36487e-06 6.46827e-05 -3.35922e-05 7.80982e-06 8.88532e-05 2.63036e-06 4.41262e-05 6.02464e-06 -2.34325e-05 -7.09778e-06 3.36367e-05 -1.64182e-06 -1.29288e-05 1.55651e-05 3.02917e-06 -2.30463e-05 2.08167e-05 1.99462e-06 4.10184e-06 1.40465e-05 -3.77306e-06 4.93558e-06 9.95525e-06 -2.35769e-06 -2.73529e-06 -1.65914e-06 1.45018e-05 5.62699e-06 3.20738e-05 7.04811e-06 2.35558e-05 -9.77469e-05 3.6926e-06 -7.59744e-05 -3.09923e-05 0.000205643 -6.82179e-05 6.98722e-05 -0.000136158 5.08476e-06 -0.000173315 -0.00012148 0.000105198 -2.45522e-05 -0.000275525 -1.08175e-05 -8.4789e-05 -0.000108468 4.06333e-05 -2.10163e-06 -7.77821e-07 -0.000226302 2.0734e-05 0.000129061 -4.75823e-05 4.78163e-05 0.000239469 5.00764e-05 -0.000120069 7.11293e-05 -8.35756e-05 7.59592e-05 -2.79286e-05 2.6898e-05 0.000153598 0.000176198 2.03646e-05 0.000104844 -0.000121054 -7.74619e-05 5.39444e-05 -2.10775e-05 8.20833e-05 8.84815e-05 -5.88015e-05 -4.3156e-05 -0.000123068 1.72854e-05 -7.9772e-06 0.000155408 -0.000115193 5.81976e-05 3.32351e-05 1.8093e-05 9.34247e-06 -4.61464e-05 4.53306e-05 -1.98506e-05 -2.54768e-05 2.46589e-06 -3.09316e-06 -1.69884e-05 5.72524e-05 -9.54789e-06 1.30627e-05 -1.93705e-05 5.45278e-06 2.53806e-06 7.27093e-06 3.51205e-05 -7.1478e-06 3.77752e-05 -2.64516e-05 6.68698e-06 8.93206e-05 1.54747e-07 3.01646e-05 1.76127e-05 -1.16204e-05 -1.01444e-05 4.87592e-05 2.91515e-05 -1.08686e-05 3.71405e-05 -2.45559e-05 -3.9595e-05 2.0134e-05 1.27287e-05 -1.50158e-05 1.05576e-05 -1.71176e-05 3.55644e-06 8.38751e-06 2.3053e-06 -5.26371e-06 1.08413e-05 1.96945e-05 7.06838e-06 3.97141e-05 1.72498e-05 3.06995e-05 5.23741e-05 -2.10732e-05 -2.49516e-06 1.44569e-05 5.25931e-06 -2.74433e-05 4.26781e-06 5.01403e-05 2.49023e-05 -1.10242e-05 -2.93776e-05 -2.10056e-05 -2.50195e-05 -0.000150864 -1.32722e-05 -1.23306e-05 2.70977e-05 -1.7354e-05 2.64625e-05 2.33312e-05 9.63594e-06 4.59503e-06 2.68517e-05 -1.42022e-05 7.8454e-06 5.78814e-05 6.66e-05 -8.18724e-06 5.17655e-05 -3.97829e-05 -4.73307e-05 -4.2981e-05 -1.37453e-05 -3.38119e-05 4.31378e-05 -5.50973e-05 8.11279e-06 0.000109861 1.40521e-05 1.72278e-05 0.000122218 -2.07683e-05 1.34467e-05 3.21908e-05 -3.60851e-05 7.91713e-06 8.85934e-06 -2.33196e-05 -3.76779e-05 -4.09417e-06 4.31554e-05 -9.58515e-06 -4.83176e-05 1.94e-06 1.34684e-05 -7.00435e-05 -1.79809e-05 0.000110163 6.08517e-05 -2.05203e-05 -2.82082e-05 -1.18509e-05 -2.73762e-05 -0.000128447 -7.70548e-06 -1.95691e-05 -1.47526e-06 2.77083e-05 -7.04279e-05 2.49674e-05 5.20595e-06 4.13891e-06 1.68872e-05 -2.89735e-06 6.1346e-06 8.13103e-05 3.71039e-05 -5.40029e-06 6.85848e-05 -8.38355e-06 -9.79436e-05 -2.49467e-05 -4.52974e-05 -2.67441e-05 2.50243e-05 -6.14435e-05 -3.68443e-05 3.91586e-05 -6.62193e-06 1.50138e-05 9.37839e-05 -1.72286e-05 2.76463e-06 3.13261e-05 -7.22835e-05 1.79751e-05 1.22917e-06 1.87524e-05 -3.35712e-05 -5.20853e-07 7.19834e-05 2.82068e-05 7.98674e-05 -6.17831e-05 -7.95561e-05 0.000115152 -5.08746e-05 -8.53775e-05 1.99605e-05 -9.83236e-05 -6.87032e-06 -3.61151e-05 1.23389e-05 2.04161e-05 -6.82355e-05 2.69236e-05 5.79136e-05 5.23536e-05 -3.22592e-06 1.55304e-05 2.02145e-05 -2.80378e-05 1.33276e-05 0.000207967 4.03103e-05 0.000145987 1.38808e-05 2.00491e-05 -5.75716e-05 -1.57303e-05 0.000144446 -4.11823e-05 0.000101055 3.3349e-05 -1.72796e-05 -4.03464e-05 4.25322e-05 -1.2333e-05 1.94449e-05 -9.0236e-06 2.81173e-05 -8.81521e-05 5.97606e-05 -1.13167e-05 1.2091e-05 3.15892e-05 -1.78714e-05 -2.10453e-05 -1.3438e-05 5.42227e-05 3.0258e-05 1.88607e-05 5.40192e-05 -1.20399e-05 -0.000111084 5.88277e-05 -0.000161111 0.000214885 1.92094e-05 -2.2146e-06 7.83201e-05 -2.80909e-05 -3.08519e-05 0.000295508 6.64421e-05 3.35855e-05 5.61868e-05 2.58183e-05 -4.82706e-05 -2.93216e-05 0.000142099 -4.80631e-05 -7.68098e-05 4.79254e-05 -6.95835e-05 -0.000118332 3.22607e-05 2.93009e-05 -8.10082e-06 0.000119313 -8.95149e-05 -1.0423e-05 -1.95781e-05 -7.12065e-05 -0.000134878 0.000102266 -0.000131021 -3.28682e-05 -4.46095e-05 -5.63202e-05 -0.000105903 -0.000124172 -1.26513e-05 -2.99259e-05 5.01639e-05 7.47964e-05 2.05245e-05 0.000113992 1.65541e-05 9.65546e-05 0.000149545 0.000123178 0.000210142 -5.71518e-05 -0.000237576 0.000373842 -2.37417e-05 7.695e-05 -9.57149e-06 0.000176132 -3.40539e-05 9.30696e-05 -8.63867e-06 0.000217691 -8.41297e-05 -1.19744e-05 0.000107848 -2.99524e-05 0.000130543 1.62519e-05 0.000150354 -0.000161815 -1.05777e-05 0.000167817 6.88754e-05 -0.000192703 6.66214e-06 3.56378e-06 -1.02448e-05 0.000464756 0.000174291 5.97952e-06 0.000246133 -0.000193386 -0.000243177 0.00016083 0.000212147 -0.000184893 -3.85201e-05 -3.33265e-05 7.46037e-05 0.00011472 -6.67228e-05 6.05591e-05 8.16873e-05 0.000279017 8.04839e-05 0.000168656 0.000136297 8.85549e-05 4.74567e-05 -5.87126e-05 0.000289146 -3.83189e-05 -0.000405583 0.000487239 -0.000529979 0.000308481 -3.58688e-05 -0.000394531 0.000412025 -4.23074e-05 4.80058e-06 0.00101561 5.7959e-05 0.000106479 0.000242854 0.000293943 8.90724e-05 -8.96073e-05 0.000541178 -0.000191221 -0.000137515 0.000327364 -0.000164154 -0.000133788 0.000101122 0.000115705 -7.13192e-05 0.000287575 0.00019169 -0.00016536 0.000187232 -0.00029929 -0.000447881 0.000388703 -2.06545e-06 -0.000276002 -0.000301982 -0.000268932 -0.000378114 -0.000407679 1.49204e-05 -3.00228e-05 0.000282972 0.000441508 -7.10704e-05 0.000207468 1.69634e-05 0.000339928 0.000308414 8.15941e-05 0.000184488 -4.87077e-05 -0.000223328 0.000275496 -0.000165112 9.70424e-05 -2.3284e-05 -5.99753e-05 6.2702e-05 -3.7379e-05 -5.73884e-05 0.000366806 -0.000200112 6.05738e-05 0.000213583 0.000189098 5.85288e-05 2.54686e-05 0.000112418 -0.000127647 -9.0016e-05 0.000463739 -3.60479e-05 -8.47989e-05 0.000184921 -0.000106252 -5.49974e-05 0.000141765 0.00017885 -0.000115209 0.000151081 -0.00014171 -0.000105767 7.86447e-05 0.00010189 -0.000154762 -5.30353e-05 -1.61196e-06 -4.3168e-05 -3.65757e-05 5.73357e-05 -7.35515e-05 7.07818e-05 0.000113617 -2.90726e-05 0.000153539 6.33857e-05 7.5961e-05 -6.08849e-05 4.22292e-05 0.000159931 -4.8155e-05 -0.000208667 0.00017606 -0.00031742 0.000228687 -1.80182e-05 -0.000278408 0.000305149 -0.000112141 1.86328e-05 0.000804286 6.07128e-05 0.000100519 0.000125608 0.000178916 -8.03725e-05 -8.49662e-05 0.000186588 -7.22167e-05 -0.000189362 0.000261919 -0.000173103 -0.000254103 -1.22697e-05 2.89666e-05 -0.000177521 -1.69446e-05 -1.57e-05 -4.94268e-05 4.65046e-06 -4.92632e-05 -0.000257339 0.000150924 -0.000202673 -0.00015902 -0.000115913 -0.000138994 -0.000318693 -0.000284442 7.97747e-05 -8.3241e-05 0.000181076 0.000144202 -2.36395e-05 0.000181441 1.63399e-05 0.000186412 -1.18727e-05 -4.50063e-05 -1.32383e-05 4.59183e-05 -0.000150695 -5.95323e-05 -3.94399e-05 4.70414e-05 2.53136e-05 -3.57075e-05 6.35889e-05 -8.36813e-06 -1.28013e-05 0.000146633 7.5844e-06 -2.72175e-05 0.000121894 -3.46029e-05 5.87101e-05 -4.04095e-05 0.000109061 -2.45925e-05 -6.06285e-06 6.5323e-05 1.81864e-05 4.85618e-05 -5.45312e-05 2.62856e-05 -4.2711e-05 -7.05857e-06 -1.55592e-05 4.94598e-05 -6.59845e-05 -3.74292e-05 -0.000123752 2.46409e-05 -0.000112665 3.88892e-05 -2.4458e-05 -5.53329e-05 2.32677e-05 -6.98833e-05 -3.46969e-05 5.52928e-05 6.78804e-05 0.000107454 2.86139e-05 6.14778e-05 -6.60376e-05 7.29521e-05 -3.23887e-05 -1.08176e-05 -1.88525e-06 -6.08849e-05 -0.000153453 -1.37912e-05 -1.96137e-05 -3.5357e-05 -2.1052e-05 -2.49795e-05 -1.60653e-05 -2.97656e-05 -9.46857e-06 4.88885e-06 -7.18335e-05 -5.10022e-05 0.000129047 -4.30006e-05 -7.5628e-06 3.61682e-05 9.1471e-05 -3.26718e-05 1.38183e-05 2.19314e-05 3.13616e-05 5.24262e-05 -0.000127247 8.78369e-06 9.05467e-07 4.66047e-05 -3.58246e-05 1.82589e-05 -1.65002e-05 -1.43221e-05 -9.63079e-05 1.18503e-05 -2.55323e-05 -2.17091e-05 1.34957e-05 4.6329e-05 5.5346e-05 1.68713e-07 -4.20727e-05 6.68876e-05 8.82496e-06 8.8543e-05 3.03062e-05 6.84476e-05 4.35416e-06 1.19827e-05 4.45673e-05 3.67298e-05 0.000123203 -0.000105976 -0.000183328 0.000126103 -0.00019713 0.000125102 4.56937e-05 -0.000144745 0.000104845 1.78184e-05 -2.53821e-06 0.00023253 2.09186e-05 1.65426e-05 9.24111e-05 8.56081e-05 -9.50708e-05 7.50411e-05 0.000199879 -0.000121031 -9.75776e-06 0.000229003 -1.91738e-05 0.000164477 0.000120233 5.92654e-05 4.60638e-05 0.000145652 -1.73907e-05 -3.78503e-05 5.91092e-05 -0.000195807 -0.000148295 0.000157079 -2.11605e-05 -0.000138854 -5.07278e-05 7.32478e-06 -9.99346e-05 -0.000128409 -2.11179e-05 3.62509e-05 1.76362e-05 0.000161346 -3.60888e-05 0.000154016 4.63279e-05 0.000147819 -6.83408e-05 -8.09774e-06 -6.43629e-06 -3.28884e-05 -0.000157508 -2.75299e-05 -2.13867e-05 -1.72826e-05 -8.35434e-06 -8.75702e-05 4.76922e-05 -2.683e-05 -3.29352e-05 0.000104886 -3.79081e-05 -8.45583e-05 0.000125276 -1.86964e-05 -4.90379e-05 1.10308e-05 0.000120033 -4.12475e-05 -1.70949e-05 7.52361e-05 1.66296e-05 3.30667e-05 -0.000133285 2.36711e-05 -2.16258e-05 3.93205e-05 -2.19082e-05 1.73454e-05 -4.5686e-05 -6.23169e-06 -0.000115794 1.90251e-05 -7.42312e-05 -3.41356e-06 2.93813e-06 -7.21113e-06 6.17049e-06 -4.35635e-05 -5.37839e-05 1.81469e-05 9.13956e-06 6.89723e-05 3.19352e-05 0.000110895 1.37278e-05 1.90356e-05 3.2511e-05 -1.18127e-05 4.88987e-05 1.8796e-05 4.31584e-05 4.45493e-06 4.97113e-06 4.06208e-05 -3.22696e-05 1.20964e-05 2.48781e-05 1.66859e-07 -2.55833e-05 0.00010645 3.02488e-05 3.51536e-05 -8.52674e-05 -5.41286e-05 8.5163e-05 -1.4489e-05 -3.33851e-05 7.38572e-05 -1.70445e-05 -2.57357e-05 1.72023e-05 -4.41416e-05 4.0305e-05 9.59521e-05 -2.12194e-07 -6.68911e-05 -8.38142e-05 -2.25814e-05 -5.25987e-05 3.98323e-05 -5.09606e-05 1.98299e-05 -2.02573e-05 4.6759e-05 2.99141e-05 3.27989e-05 -8.36657e-07 -2.34989e-05 -4.99916e-05 2.05913e-05 1.06604e-05 9.73946e-05 1.88488e-05 1.57152e-05 -5.29779e-05 5.75507e-05 7.65559e-06 7.97001e-06 1.92368e-05 4.11076e-06 -3.30742e-05 4.95729e-06 -1.16749e-05 1.45985e-05 -5.32758e-07 4.23059e-05 2.19505e-05 -1.34972e-05 4.28002e-06 5.82922e-05 7.0775e-06 -1.01072e-05 3.13051e-05 -9.68795e-06 1.60257e-05 -1.31289e-05 -7.12297e-07 3.23504e-05 -1.26747e-05 3.72696e-05 -6.76613e-06 -6.60023e-06 1.91151e-07 2.57493e-05 -3.02527e-05 -4.74968e-05 -1.81607e-05 9.23048e-06 -3.77973e-05 3.42112e-05 -4.98822e-05 1.19408e-05 -5.31116e-05 -8.15189e-06 3.81122e-05 -7.5883e-06 -1.22893e-05 -1.0137e-06 9.49807e-06 -1.75336e-05 1.51798e-05 -5.2446e-06 1.52774e-05 1.93832e-05 6.24931e-06 2.04302e-05 5.64479e-05 -6.54584e-05 -4.57329e-05 4.57968e-05 5.8739e-05 -0.000227089 0.000177841 -1.20835e-05 6.88347e-05 0.000165544 -0.000142745 2.16421e-05 -9.92355e-05 -0.000229905 -9.72533e-05 -1.20359e-05 1.89443e-05 -0.00010391 0.000108796 2.05224e-05 -0.000147978 0.000144777 0.000137946 2.18665e-05 0.000181734 0.000159516 0.000109423 -0.000484685 1.19145e-05 -0.000281948 -3.85824e-05 -1.00523e-05 -0.000170716 0.00020526 -1.42402e-05 -3.62215e-05 5.44692e-05 -3.32728e-05 8.9729e-05 0.000123472 6.59194e-05 0.000133138 3.93353e-05 -4.43916e-05 -0.000129596 -5.74626e-05 0.000255896 3.80629e-05 -3.25094e-05 -6.4992e-05 -7.5777e-05 5.45523e-05 4.53965e-05 -4.74374e-05 -0.000132437 0.000136148 -0.000107113 5.92866e-05 1.75649e-05 -5.58939e-05 0.000149933 -5.35423e-06 4.38909e-05 0.000372635 3.95043e-05 5.10038e-05 7.16516e-05 0.000111563 -5.35187e-05 -3.71259e-05 8.56363e-05 -5.04429e-05 -9.79477e-05 2.58929e-05 -8.00305e-05 -0.000172718 -9.84076e-05 0.00015469 -0.000110711 2.73397e-05 4.26243e-05 4.49549e-05 5.98641e-05 -3.0086e-05 -0.000150853 9.49735e-05 -7.31932e-05 -0.000124056 -7.46206e-05 -1.82314e-05 -0.000195467 -0.000118268 4.74059e-05 -4.99923e-05 0.000102767 5.55236e-05 -5.15087e-05 3.34794e-05 3.56491e-05 6.69822e-05 4.18684e-05 5.39782e-05 -1.80363e-05 5.10421e-05 -1.15356e-05 -1.29667e-06 5.34718e-05 3.05692e-05 0.000104281 1.73644e-06 -2.59148e-05 6.41102e-05 3.54336e-05 4.61311e-05 2.63371e-05 1.10495e-05 -3.50161e-05 4.49198e-05 5.84151e-05 -2.75461e-05 -7.16273e-05 -2.46705e-05 3.30047e-06 6.7371e-05 2.95783e-05 5.17788e-05 4.16618e-05 2.77329e-05 -6.98285e-05 -4.00057e-05 3.2701e-05 2.64626e-05 -1.52126e-05 -2.95573e-06 -2.33745e-05 -3.30455e-07 -1.2734e-05 5.36449e-05 1.76858e-05 -7.56693e-06 2.4696e-05 -1.69089e-05 1.57827e-05 5.61473e-05 5.03828e-06 -2.83964e-05 1.47509e-05 -2.35038e-05 -4.25604e-05 6.13175e-05 2.34461e-05 4.96215e-05 -1.09567e-05 -3.52918e-05 -4.4671e-05 1.99182e-05 -1.22898e-05 2.89061e-05 4.78975e-05 1.98945e-05 -1.87747e-05 4.42076e-05 -3.25895e-06 9.86093e-05 1.04269e-05 -5.2709e-06 -7.98209e-06 3.17008e-05 -2.71268e-06 -8.89626e-06 -5.08401e-06 -2.21482e-05 -1.10945e-05 8.233e-05 2.32167e-05 5.02573e-05 1.50116e-05 3.01708e-05 -3.78677e-05 1.85566e-05 -8.9498e-06 5.9028e-06 -2.21539e-05 1.72928e-05 -0.000101746 3.42282e-05 -7.08081e-05 -1.22862e-05 4.89565e-06 8.22152e-06 -2.5305e-05 -2.20154e-05 7.74875e-06 -1.65378e-05 -5.03617e-06 -1.08733e-05 5.79486e-06 3.08272e-05 1.45915e-05 4.82554e-05 8.87941e-05 4.16093e-05 -4.36936e-05 -4.63524e-05 -0.000164262 6.17676e-05 -0.000114955 4.75515e-05 7.43762e-05 -0.000118141 2.45128e-06 -2.06326e-05 -6.1173e-05 4.19797e-05 1.88146e-05 1.8336e-06 9.48203e-05 8.15405e-05 -6.85581e-05 5.23745e-05 0.000136106 -7.19732e-05 3.17321e-05 0.000116518 2.59383e-05 0.000229138 0.000125191 1.51521e-06 3.69452e-05 0.000100384 4.14542e-07 -5.80938e-05 9.99005e-05 -9.54967e-06 -3.02356e-05 1.37224e-05 -3.08289e-05 1.09112e-05 -3.66039e-05 -4.52834e-05 3.74264e-06 -0.000103117 0.000130262 8.78739e-05 3.33981e-06 -9.28725e-07 -3.29515e-05 2.36037e-05 -2.86707e-05 8.13425e-05 2.822e-05 2.81819e-05 3.13988e-05 3.41684e-05 -7.98744e-05 7.60606e-06 -4.90646e-05 8.51598e-05 8.59014e-05 1.16447e-06 5.57946e-06 3.73136e-05 -2.66042e-06 0.000227405 2.55205e-05 1.32721e-05 6.69367e-05 2.61803e-05 -9.84186e-06 -4.22571e-05 6.69322e-05 -5.18631e-05 -3.86576e-05 0.000102035 7.68932e-06 4.88248e-05 -2.28807e-05 6.21881e-05 -7.41015e-05 3.38387e-05 -5.47902e-05 3.47761e-05 -5.99132e-05 -1.97624e-05 -0.000190806 6.87449e-05 -0.000122418 -1.45137e-05 5.49491e-06 -2.80096e-05 -6.42466e-05 -0.00011061 -3.22999e-06 5.14803e-06 3.69375e-05 2.20557e-08 8.37023e-06 6.52009e-05 -3.13807e-05 8.53695e-05 3.90179e-05 -1.88571e-05 1.88458e-06 7.58577e-06 3.62047e-05 -1.87869e-05 3.83374e-05 -1.41278e-05 1.53798e-05 4.12608e-05 -3.08201e-05 3.74509e-06 -5.82935e-06 -5.13461e-05 -6.33205e-07 -8.51335e-06 5.38369e-06 -1.7802e-05 2.69636e-05 9.37872e-06 -2.39759e-05 1.60953e-06 1.70778e-05 -1.63352e-05 4.99362e-06 2.70494e-05 5.10529e-05 -9.75259e-06 1.84476e-05 3.56143e-05 -9.83091e-06 -9.51433e-06 5.16385e-06 -7.18825e-07 2.17028e-07 7.38293e-06 3.54677e-05 5.64018e-06 -2.49955e-06 1.21464e-05 2.33211e-05 2.84897e-05 -1.22076e-05 1.88048e-05 -8.13106e-06 -1.94214e-05 -8.41683e-06 -4.49612e-06 -1.1817e-06 -1.462e-05 3.45576e-05 -2.35667e-05 -8.5924e-06 1.83975e-05 4.13055e-05 -3.7036e-05 4.10851e-05 -9.13407e-06 1.45307e-05 3.53946e-05 -1.37567e-05 -7.14746e-06 1.34559e-06 -1.94424e-05 2.6407e-05 -1.38793e-05 9.74228e-06 -2.14848e-05 5.89758e-06 -1.04352e-05 1.07708e-05 1.47316e-05 1.17212e-05 -4.48775e-05 9.53328e-06 2.59297e-05 2.05924e-05 -8.21962e-06 1.93012e-06 2.99409e-05 -3.92188e-05 3.23319e-05 -1.6868e-05 1.01183e-05 -1.00616e-05 5.11547e-06 -1.05528e-05 2.44526e-05 -1.24627e-05 -2.59363e-05 1.06765e-05 -8.11461e-07 -4.21634e-05 -1.91008e-05 -2.62658e-05 -2.04358e-05 -1.09974e-05 1.23359e-06 1.08428e-05 6.12114e-06 -5.55186e-05 -1.00125e-05 1.75439e-05 4.89286e-05 -5.20396e-06 -1.35875e-05 2.84811e-05 -3.09286e-05 -5.09821e-06 0.000143064 -4.22764e-05 0.000121144 1.3112e-05 -0.000145654 -7.12933e-06 -0.000117314 -8.66401e-05 -2.3456e-05 9.10654e-05 -6.69288e-05 -1.71358e-05 5.31579e-05 7.88238e-05 -7.23239e-05 4.53513e-05 0.000153568 5.69696e-05 -3.24107e-05 7.77851e-05 3.7917e-06 4.54791e-05 -4.67084e-06 4.9074e-05 -8.71633e-05 -2.00274e-07 3.88461e-05 6.82122e-05 -9.14257e-06 3.7088e-05 -3.82403e-05 2.86649e-05 -1.28733e-05 5.59792e-05 -5.70591e-05 9.06701e-06 -1.58531e-05 0.000105102 1.20238e-06 2.49069e-06 -4.89617e-05 3.94281e-05 -1.78461e-05 -1.80152e-05 2.21698e-05 5.56305e-05 -3.24995e-05 4.43547e-05 -6.56651e-07 2.94517e-05 4.82351e-05 -3.35695e-05 -6.81119e-06 -6.70881e-06 -3.30597e-05 2.07783e-05 -7.75268e-06 4.19304e-06 -3.21821e-05 2.18553e-05 4.32536e-06 -7.64039e-06 6.14265e-06 2.06873e-05 -3.40251e-05 5.70892e-06 3.5019e-05 3.09475e-05 -1.73707e-05 1.50159e-05 3.15994e-05 -3.32316e-05 1.61028e-05 -5.81272e-06 2.64231e-05 3.23338e-06 9.12609e-06 1.9776e-05 2.08887e-05 -1.33518e-05 -1.12629e-05 2.25306e-06 9.73494e-06 -2.23521e-05 -2.11678e-06 -1.6606e-05 -1.51563e-05 -1.62363e-05 -9.37255e-06 1.29153e-05 -8.05153e-06 2.6932e-05 1.80583e-05 2.06058e-05 -3.61828e-05 -3.44208e-05 3.74574e-05 8.55516e-06 -3.12017e-05 7.86515e-06 3.24411e-05 -2.26397e-05 1.51876e-05 1.44738e-05 -5.92148e-05 -4.67281e-05 -1.01245e-06 -1.43658e-05 -1.23922e-05 2.47739e-05 1.11274e-05 -1.95948e-05 1.00711e-06 1.56054e-05 2.7185e-05 3.29763e-05 2.60424e-05 -1.35886e-05 -1.57691e-05 1.6759e-05 3.54183e-05 6.57932e-05 8.91284e-06 4.42899e-05 3.14396e-05 7.50357e-06 -3.47983e-05 1.87367e-05 -2.01865e-05 1.93088e-05 4.31003e-05 1.02381e-05 3.49396e-05 4.289e-05 3.1229e-05 -1.13693e-05 -1.97789e-05 7.19242e-06 -2.85964e-05 3.93308e-05 -3.8428e-05 5.99833e-06 3.74947e-05 3.95334e-05 -1.40741e-05 -4.05198e-05 5.76096e-05 -4.30932e-06 2.33065e-05 1.86174e-05 -4.05446e-07 -2.78294e-05 6.64948e-05 -3.29238e-06 -3.16258e-05 7.30449e-06 -1.92712e-05 -3.97283e-05 -1.02038e-06 7.53831e-05 1.31966e-05 -5.25504e-06 1.36958e-05 1.49952e-05 6.73957e-05 3.80424e-05 5.66847e-05 -4.91613e-06 -2.22498e-06 3.02682e-05 -1.13282e-05 0.000100012 -2.09126e-05 1.65912e-05 2.37207e-05 -3.48936e-05 1.98173e-05 -3.43388e-06 4.88046e-06 1.56249e-05 2.62621e-05 2.9864e-05 2.58733e-05 2.76139e-05 1.84208e-05 -3.59848e-05 6.82386e-06 -6.78234e-07 1.7651e-05 4.69213e-05 -4.21938e-06 -5.58739e-05 -0.000108803 -0.000175758 0.000100701 0.00020421 -0.000274331 0.000153914 -0.000104187 -4.19658e-05 0.00012391 -6.55471e-05 7.79264e-05 5.38825e-05 -0.000376554 3.87034e-05 -5.55613e-05 -0.000121088 -0.000145368 6.29781e-06 -1.41688e-05 -9.901e-05 0.000112636 0.000104948 -0.000264898 8.12961e-05 0.000143414 1.33842e-05 -7.79015e-05 0.000105084 -6.04953e-05 -9.82453e-05 7.19599e-05 -5.71476e-05 6.73751e-05 0.000164086 -0.000107693 4.9524e-07 0.000110134 2.49507e-05 4.89859e-05 0.000114175 0.000116588 -8.90218e-05 -2.16278e-05 -7.53877e-05 -0.000108774 5.60577e-05 -0.000111533 8.79567e-07 -0.000105878 3.09442e-06 6.25783e-05 4.05069e-05 -1.61836e-05 -9.47444e-06 5.90564e-05 7.05396e-06 -6.74876e-06 4.87218e-05 -9.33745e-07 -3.92647e-05 9.23349e-05 4.74705e-06 -2.51882e-05 6.79182e-06 1.11246e-06 -5.03906e-05 5.89301e-06 5.01337e-05 -8.19145e-06 -2.8978e-05 -1.57621e-05 2.21034e-05 0.000104102 5.70934e-05 8.60576e-05 7.61645e-06 6.27188e-06 8.18207e-06 -2.31211e-05 9.72455e-05 -9.01404e-06 4.09518e-05 1.98021e-05 -2.59779e-05 6.31971e-06 -3.95051e-06 -2.3648e-05 1.24446e-05 2.65833e-05 3.16889e-05 1.28428e-05 2.04401e-05 2.38253e-05 -2.93163e-05 -1.8592e-05 9.15605e-07 -1.67104e-05 6.52815e-05 3.42224e-06 -1.35566e-06 -3.82391e-06 -3.227e-06 3.73769e-06 -8.3655e-06 -7.18494e-06 -2.6831e-06 1.41252e-05 8.29889e-08 1.02352e-06 4.51022e-06 8.00707e-06 5.05369e-06 1.69931e-05 1.62785e-05 6.86028e-06 4.79155e-06 2.42475e-06 5.66431e-06 -2.29497e-06 2.848e-06 5.57007e-06 -1.38391e-06 -1.51407e-05 -8.19395e-08 4.07675e-06 3.72148e-06 6.83145e-06 -4.80879e-06 1.2699e-06 -3.55246e-06 1.14161e-05 -3.84282e-06 -1.01007e-05 -8.93382e-06 4.76894e-06 -9.16478e-06 -4.50237e-06 -3.32655e-06 -1.00014e-06 -1.08178e-05 -1.01229e-05 1.7336e-06 -1.84066e-06 6.34429e-07 -2.651e-06 2.07168e-06 3.88726e-06 -6.85686e-06 1.32113e-05 -2.54594e-06 -1.302e-06 -5.71139e-06 1.93778e-06 -1.64178e-05 -9.90496e-06 5.19415e-08 5.18924e-06 9.27619e-07 3.17366e-06 7.80314e-06 4.11786e-06 3.95485e-06 9.29227e-06 9.31314e-06 -8.38783e-07 7.49861e-06 -3.5941e-06 2.74982e-06 8.04647e-07 5.38421e-06 1.02625e-05 6.52987e-07 -9.54307e-06 1.71569e-06 1.28494e-05 -5.90154e-07 4.90589e-06 -3.49752e-06 -2.57214e-07 -7.49278e-06 1.69871e-05 -4.09856e-06 -1.14882e-05 -1.25706e-05 2.11087e-07 -1.21291e-05 -6.88574e-07 -2.14541e-06 5.53299e-07 -8.14775e-06 -1.1796e-05 1.89075e-06 -3.58669e-06 -3.20853e-07 -2.38747e-06 2.70581e-06 3.51e-06 -4.84782e-06 8.27597e-06 4.29573e-05 -6.39873e-05 -0.000108638 5.19193e-05 0.000100209 -0.000119527 0.000105474 -0.000131606 3.17275e-05 9.03103e-05 -9.3727e-05 6.56384e-05 1.265e-06 -0.00023099 -2.88159e-05 -4.70174e-05 -3.91143e-05 -5.43046e-05 1.6934e-05 2.75976e-05 -5.4198e-05 4.83231e-05 8.18414e-05 -4.67625e-05 6.23493e-05 0.000187994 -9.25604e-06 -4.92364e-05 4.1937e-05 -0.000102338 -1.68599e-05 1.81141e-05 -2.88674e-05 7.59237e-05 2.26721e-05 -4.63401e-05 2.67781e-05 4.65102e-05 4.5634e-05 6.14429e-06 4.62862e-05 4.83132e-05 -1.20191e-05 -1.46625e-06 -5.03268e-05 -0.000103062 1.78963e-05 -8.23498e-05 -3.32922e-05 -0.000107145 -2.62779e-07 -3.58253e-06 -2.39126e-06 3.05067e-06 -1.62371e-05 -5.6191e-06 -3.96313e-06 9.19464e-06 6.34527e-07 1.95928e-06 5.08039e-06 6.03178e-06 5.70567e-06 1.37223e-05 1.16042e-05 5.08325e-06 8.56539e-06 5.65927e-07 6.08539e-06 -5.29886e-07 4.47712e-06 7.7964e-06 -9.01683e-07 -1.32443e-05 3.60544e-07 6.37318e-06 2.4602e-06 7.77733e-06 -4.59685e-06 -1.25036e-06 -2.14071e-06 1.22596e-05 -3.15134e-06 -1.23594e-05 -1.16688e-05 3.92413e-06 -1.05536e-05 -5.62485e-08 -1.70782e-06 9.96394e-07 -8.7142e-06 -1.29544e-05 1.4445e-06 -3.16448e-06 9.25478e-07 -3.12577e-06 2.46163e-06 9.87424e-07 -4.15107e-06 1.11029e-05 3.713e-05 3.50225e-05 1.93721e-05 1.26643e-05 -1.8672e-05 3.29976e-05 -1.1553e-05 1.53868e-06 2.16779e-05 2.29613e-05 -2.07156e-05 2.18681e-05 9.31295e-06 -1.06096e-06 -1.14654e-05 1.69551e-05 -6.41089e-06 -1.51765e-05 3.76884e-05 -5.35011e-07 -1.71787e-05 -2.56324e-05 4.04116e-06 3.73482e-05 4.62491e-06 3.57765e-05 1.48705e-05 7.06219e-06 7.02394e-06 9.42352e-06 2.46245e-05 6.45961e-06 3.52927e-05 2.43687e-05 -7.87454e-06 2.70337e-06 6.02698e-07 -5.20586e-06 9.01577e-06 -9.09084e-06 1.35677e-05 1.48261e-05 1.28428e-05 5.95378e-07 -5.16034e-06 -1.3278e-06 -2.54842e-06 -3.03594e-05 1.14029e-05 7.89508e-07 8.72841e-05 5.55264e-05 3.42268e-05 3.32261e-06 -1.17499e-05 9.24214e-05 -1.62945e-05 -1.80159e-07 2.88498e-05 1.39933e-05 -1.27411e-05 4.29922e-05 1.20637e-05 1.46643e-06 -2.78836e-05 2.00166e-05 -1.74227e-05 -1.54269e-05 4.37187e-05 1.02459e-05 -1.39322e-05 -2.06773e-05 2.38903e-06 8.63325e-05 7.76249e-06 3.71785e-05 3.83927e-05 -1.26242e-05 1.07196e-05 1.48483e-05 6.42912e-05 -1.37657e-05 8.35874e-05 2.17814e-05 -1.72226e-07 -1.13452e-05 2.72875e-05 -1.82348e-05 1.91562e-05 -7.34469e-07 1.45744e-05 3.03336e-05 2.71052e-05 2.98212e-06 -7.23432e-06 -2.42931e-06 -1.33065e-05 -3.05417e-05 7.21467e-06 -9.19928e-06 -8.86737e-05 -7.7716e-05 -7.21013e-05 -4.45934e-06 5.07565e-05 -0.000108412 3.41455e-05 5.61025e-05 -3.88379e-05 4.54034e-05 5.76309e-05 -5.709e-05 2.57404e-07 1.15946e-05 6.49812e-05 -1.89645e-05 6.98908e-06 -2.79827e-05 -7.64857e-05 -2.18876e-05 1.46011e-05 4.16484e-05 -2.09246e-05 -0.000123253 -3.26605e-05 -7.21446e-05 -1.90125e-05 -1.41619e-07 6.28686e-06 1.164e-05 -0.000127138 3.75757e-05 -0.000114264 -2.6167e-05 8.31537e-06 2.18955e-05 -4.15692e-05 1.26102e-05 -2.76522e-05 1.27793e-05 -4.28385e-05 -4.23584e-05 -5.09113e-05 -3.75595e-05 1.57025e-05 2.61495e-05 6.55825e-06 3.51733e-05 -2.94887e-05 1.34967e-05 7.26482e-05 3.64896e-05 2.88134e-05 2.68067e-06 -1.98247e-05 2.86453e-05 -2.65067e-05 -1.96159e-06 2.42195e-05 2.61765e-05 -1.25757e-05 3.14457e-05 1.71927e-05 -3.39549e-06 -1.87731e-05 1.04368e-05 -1.41632e-05 -1.41728e-05 1.7509e-05 9.52148e-06 1.44198e-05 -2.20053e-05 5.22325e-06 7.27533e-05 1.48567e-05 8.30599e-05 1.11125e-06 8.60466e-06 2.13752e-05 7.39074e-06 2.58196e-06 1.12837e-05 3.18079e-05 2.33377e-05 -3.1021e-05 -5.22575e-06 -3.19074e-05 -1.87297e-05 1.91124e-05 -5.7541e-06 4.71292e-06 2.88935e-05 7.94973e-06 -3.69591e-06 -1.86121e-05 -4.01625e-06 -1.14565e-05 -1.20408e-05 1.35774e-05 -2.46096e-06 1.12052e-05 -5.59679e-05 -8.56084e-05 3.46687e-05 -5.7873e-05 -6.37578e-05 1.43986e-05 -3.8157e-05 2.43509e-05 -9.89374e-06 -5.71645e-06 0.000128486 -4.628e-06 -7.26485e-05 1.54478e-05 -6.21538e-05 6.94458e-06 1.57785e-05 -1.65262e-05 -3.23091e-05 3.17703e-05 9.86829e-06 4.67123e-05 -2.35546e-05 1.97192e-05 0.000112717 -1.18986e-05 4.85724e-06 -3.66983e-06 -7.68235e-07 -9.89131e-06 2.56804e-05 -1.62242e-05 -1.12379e-05 -7.30334e-05 1.4557e-05 -4.51129e-05 3.06158e-05 4.35215e-05 3.30802e-05 -2.07237e-06 -2.90098e-06 -1.84022e-05 2.71679e-05 4.80655e-06 -1.13957e-05 1.82359e-05 2.42628e-05 -1.09584e-05 1.33089e-05 -2.01593e-05 -1.60947e-05 5.38951e-06 -1.08817e-05 -4.26801e-05 -3.40761e-05 2.40725e-05 1.40216e-05 7.10707e-06 -4.88787e-05 -1.6588e-05 2.99931e-05 2.29093e-06 -5.73252e-05 1.93624e-06 -2.49183e-05 -8.92398e-06 2.66307e-05 7.31693e-06 1.58216e-05 -4.7883e-06 -4.04071e-05 4.05711e-05 2.12607e-06 2.56391e-05 0.00011173 5.50903e-06 2.45102e-06 2.18146e-05 3.91044e-06 5.37887e-07 -3.28696e-06 -3.53723e-06 1.95149e-05 -3.05324e-05 3.14006e-06 -2.23847e-05 -3.54255e-05 3.66174e-05 1.85902e-05 1.08997e-05 -2.26696e-06 -7.61185e-06 4.08017e-05 -2.02326e-07 -1.72337e-05 2.09278e-05 1.16063e-05 2.34264e-05 1.57369e-05 0.000118531 -8.79587e-06 -0.000100381 -2.17878e-05 3.44932e-05 -6.50846e-05 6.24662e-05 9.31616e-05 0.000140938 0.00011745 -9.79617e-05 1.78964e-05 8.67368e-06 -0.000153861 2.27907e-06 5.10729e-05 -8.77339e-05 2.71371e-06 3.21089e-05 5.59494e-05 7.39175e-06 3.85094e-06 6.30738e-05 -0.000118403 5.84837e-05 6.06903e-05 1.29075e-06 -9.55517e-05 6.25948e-05 2.26335e-05 -5.1278e-05 1.60881e-05 2.62566e-05 -0.000275802 -0.000124859 -8.08472e-06 9.5608e-06 -0.000100123 1.07523e-05 4.29545e-05 1.85534e-06 -1.57722e-05 6.20596e-05 3.73881e-05 -5.27067e-05 -1.87466e-05 5.30465e-05 3.06042e-05 3.06651e-05 -6.57757e-06 -2.03919e-05 -1.37822e-05 -3.00867e-05 -1.06739e-05 -1.87051e-05 -2.09836e-05 2.49616e-05 -5.32367e-05 -8.33329e-06 -6.39924e-05 -2.34475e-05 4.061e-05 -1.81579e-05 -4.59566e-05 -3.30619e-05 -1.32089e-05 7.31851e-06 1.84799e-05 -2.13574e-05 8.74521e-06 -1.07075e-05 -2.58531e-05 2.64909e-05 5.03713e-05 2.53636e-05 8.65905e-05 -1.84135e-06 5.11098e-06 1.17552e-07 -1.14204e-05 6.68666e-06 -2.54862e-06 -5.71275e-06 0.000100982 -1.42079e-05 1.45589e-05 -2.36023e-06 -5.21002e-05 2.38821e-05 6.19487e-06 -7.5677e-06 1.51858e-05 5.10034e-06 7.66526e-06 8.22056e-06 -1.29865e-05 1.16225e-05 1.8597e-05 2.05602e-05 -1.18625e-05 -7.75717e-06 1.5852e-05 1.79948e-05 -1.09526e-05 -2.46475e-05 4.38589e-06 -1.27813e-05 3.82639e-06 3.48242e-06 -3.46136e-05 6.378e-07 5.26059e-06 1.53038e-06 2.31671e-06 -1.67892e-05 -1.52041e-07 -2.30892e-05 2.65024e-05 -1.55211e-05 3.39087e-06 -8.47381e-06 4.12627e-06 2.51634e-06 7.62487e-06 -1.92446e-06 4.61043e-06 -1.81026e-05 3.41874e-06 -8.09793e-06 -2.85611e-06 1.5571e-05 -9.05253e-06 3.74421e-06 -1.03581e-05 -2.92741e-06 -1.9242e-06 1.34889e-05 -2.28151e-05 -7.12837e-07 2.26639e-05 1.16407e-06 -2.90493e-06 3.50148e-05 9.24732e-06 5.58309e-06 5.83059e-06 5.24397e-06 -3.63933e-06 3.98671e-06 -2.58689e-07 -1.34371e-06 8.42938e-06 1.68616e-05 -4.39811e-06 -2.40444e-05 -1.21296e-05 -1.89374e-05 2.47596e-05 9.43437e-06 -3.21523e-05 -9.5907e-06 3.36064e-06 -5.40486e-07 9.06304e-06 5.21337e-06 -2.69776e-06 -3.11419e-05 2.67201e-05 -2.92745e-06 5.43802e-07 -1.30895e-05 -3.44733e-06 6.05665e-06 -2.43272e-06 1.90755e-06 1.91883e-05 -8.79195e-06 2.44135e-06 -8.82964e-06 -2.9606e-06 6.03212e-06 -1.8952e-06 9.30162e-07 -1.3223e-05 -3.16731e-06 1.39678e-05 5.46819e-06 -8.90992e-06 -4.9415e-06 1.47237e-05 1.5182e-06 -6.86669e-06 2.43489e-05 9.71288e-06 -2.46401e-06 -1.08185e-06 2.63395e-06 -1.58839e-06 6.69907e-06 9.09262e-06 2.71983e-05 3.23381e-05 -1.34355e-05 2.87954e-05 8.79694e-05 -6.71959e-05 9.21746e-05 -1.5956e-05 5.1161e-05 0.000148034 -0.000122131 -1.87256e-06 3.91787e-05 -0.000168009 3.04599e-05 5.36985e-05 -4.67295e-05 -9.55234e-05 -2.8442e-05 2.60521e-05 -6.4426e-05 3.14119e-05 -9.19194e-06 -0.000115267 2.52895e-05 -9.15284e-05 -2.51838e-05 2.67625e-05 1.89395e-05 9.70089e-06 -7.5877e-05 5.14525e-05 -1.81575e-05 6.03229e-05 2.97333e-05 -5.77424e-05 -1.61469e-05 8.16402e-05 7.62772e-05 3.45516e-05 0.000120999 0.000102586 -5.59916e-05 3.60811e-05 -7.36867e-05 -6.46581e-05 9.62485e-06 -6.40383e-05 2.63247e-05 -4.57589e-05 -7.84201e-06 1.28005e-05 3.47665e-05 -1.48922e-05 -2.14616e-05 1.99841e-05 -1.99286e-05 5.65809e-06 -9.40575e-06 -3.97737e-05 5.37444e-06 5.51765e-06 -9.96706e-07 1.61949e-05 -1.74126e-05 4.15446e-06 -2.46337e-05 3.891e-05 -2.60526e-07 1.62083e-07 -1.87327e-05 -6.53799e-06 1.51438e-06 2.25217e-05 -4.66509e-06 -3.62502e-06 -1.15314e-05 -2.38707e-07 -1.55829e-05 1.51163e-07 3.93822e-05 -1.41547e-05 1.97789e-05 -1.90054e-05 7.94894e-06 7.57054e-06 3.60295e-05 -3.23339e-05 -6.60412e-06 2.22121e-05 -8.26272e-06 -3.94678e-06 3.82597e-05 6.75205e-06 1.25804e-05 1.66263e-05 5.04491e-07 -6.26847e-06 7.62875e-06 4.16918e-06 -3.39956e-05 -1.27507e-05 4.96613e-05 -6.37024e-06 1.11711e-05 5.61058e-06 -2.36563e-05 4.69668e-05 -7.70679e-06 -1.1649e-05 1.14634e-05 -1.72849e-05 1.43642e-06 7.91008e-05 2.054e-05 1.42156e-06 9.00864e-06 2.95822e-07 -1.90822e-05 -1.60452e-05 2.14889e-05 -2.74812e-05 -1.19292e-05 -1.31169e-05 -1.04015e-05 -2.57818e-05 -1.1513e-05 4.18375e-06 -1.33196e-05 1.83421e-05 -7.3632e-06 3.30876e-06 -7.78498e-06 2.01983e-05 1.09656e-05 4.73718e-05 -1.61672e-05 -1.57867e-05 -2.17079e-05 4.51599e-06 -3.21324e-05 -1.06913e-05 -5.43835e-05 -1.68716e-05 1.0069e-05 1.01189e-06 -2.38487e-06 -2.68757e-06 2.4723e-05 8.80475e-06 -5.70085e-05 -8.2589e-06 3.67295e-05 4.06166e-06 3.48462e-05 1.02118e-05 -2.94282e-05 4.47192e-05 -8.58556e-06 -1.94903e-05 8.45454e-06 -2.42156e-06 -2.10703e-07 0.000119421 2.25239e-05 1.68247e-05 3.16465e-06 5.52272e-07 -2.80634e-05 -1.95559e-05 3.21655e-06 -2.84863e-05 -2.09116e-05 5.36294e-06 -1.36625e-05 -3.9727e-05 -2.42152e-05 1.08933e-05 -1.08067e-05 1.41149e-05 -7.88271e-06 9.28373e-06 -4.31955e-06 5.5715e-05 3.0772e-06 6.53465e-05 -1.47749e-05 -2.69823e-05 -2.47176e-05 3.42182e-06 -5.57014e-05 -2.45229e-05 -3.94074e-05 -3.77955e-05 1.6094e-05 -8.70223e-06 -1.13962e-05 1.34806e-05 4.00967e-05 1.6277e-06 9.60824e-05 -4.49462e-05 -0.000176983 3.52759e-05 7.32979e-05 -9.45218e-05 0.000160319 -0.000163664 1.9942e-05 0.000101991 -7.34923e-05 5.53032e-05 -3.4073e-05 -0.000356222 -6.58406e-05 -3.52978e-05 -3.51048e-05 -7.6294e-05 7.93792e-05 3.26892e-05 -7.01854e-05 5.30486e-05 0.000117609 -9.92521e-05 6.88735e-05 0.000214106 8.00872e-05 -5.38913e-05 9.74113e-05 -8.24069e-05 -2.35652e-05 -6.07706e-06 -1.56676e-05 5.11072e-05 6.23952e-05 -8.08056e-05 0.000121827 8.48979e-05 3.17059e-06 7.75447e-06 0.000119102 7.74695e-05 4.01104e-05 1.27425e-05 -4.87327e-05 -4.82469e-05 1.976e-05 -7.47608e-05 -0.000149652 -6.92329e-05 -3.30895e-05 -2.9215e-05 9.53358e-06 8.1011e-06 2.0137e-05 -7.8841e-06 -1.18832e-05 1.68937e-05 5.44395e-06 2.28337e-05 -4.4863e-06 3.19088e-06 8.90057e-06 3.049e-05 -1.37069e-06 8.9715e-06 2.54713e-05 -1.11472e-05 8.73637e-06 -4.73046e-06 -8.09385e-06 -1.89701e-05 4.27651e-06 -2.53074e-06 3.94722e-07 1.20072e-06 -1.11813e-05 1.08265e-06 -1.22727e-06 2.67834e-05 -1.75349e-05 8.4058e-06 -8.73919e-06 1.03078e-05 8.45853e-07 4.6455e-05 1.38728e-05 -6.9497e-06 -1.78111e-05 -2.89731e-06 -1.61199e-05 4.30232e-06 -1.98297e-05 8.3854e-06 1.04874e-05 5.24127e-06 3.80393e-06 -5.96078e-06 1.5239e-05 -1.48863e-05 -1.53761e-06 6.90133e-06 2.60038e-05 -8.27262e-07 -4.40431e-05 1.98372e-05 -1.67396e-05 -1.759e-06 -5.40181e-07 -5.38054e-06 1.51603e-05 -1.02609e-06 7.70499e-06 2.31323e-05 -1.47112e-05 1.10335e-05 1.28191e-05 1.10925e-05 5.08424e-06 8.07248e-07 3.14563e-05 -7.55938e-06 -7.49208e-06 3.22295e-05 1.95453e-06 -9.64003e-07 1.8692e-05 1.08722e-05 -7.4985e-06 1.16384e-05 2.52881e-05 3.33676e-06 1.56108e-05 -1.67292e-05 -1.73167e-05 -3.18653e-06 3.7541e-06 1.01733e-06 8.7598e-06 -7.93903e-06 1.03616e-05 -2.69598e-06 8.4947e-06 1.37646e-05 1.25588e-05 1.80439e-05 -3.96151e-07 -5.21598e-06 -1.46313e-05 1.96651e-05 4.50379e-06 1.34647e-05 1.52922e-05 9.94767e-06 -2.66935e-05 2.10128e-05 -9.35751e-06 1.2584e-05 1.62797e-05 -4.50505e-06 1.22952e-05 4.58312e-06 7.60129e-06 1.71573e-05 -1.15316e-05 1.30836e-05 4.92803e-06 8.35782e-06 1.25102e-05 2.55137e-06 1.87375e-05 -1.56692e-05 -5.47356e-06 1.00334e-05 7.87833e-06 6.89627e-06 1.65615e-05 9.16302e-06 -9.44699e-06 3.66691e-06 1.98197e-05 8.7524e-06 1.41181e-05 -8.12805e-06 -1.63012e-05 -1.82174e-06 5.59305e-06 1.05268e-06 -1.26329e-06 -4.15328e-06 1.23533e-05 -1.00085e-05 1.52481e-06 2.25126e-05 7.9605e-06 1.2654e-05 -1.12462e-06 -1.01017e-05 -8.9446e-06 2.13229e-05 -1.54198e-05 -1.89547e-05 4.37644e-05 1.65569e-05 -4.93947e-05 3.39402e-05 -5.04765e-06 2.80104e-05 -4.21605e-05 5.47395e-05 9.57726e-05 -3.43413e-05 6.74979e-05 0.000124335 4.0176e-05 2.24516e-05 5.1039e-05 -2.57809e-05 1.25006e-06 -1.28341e-05 5.9882e-05 -2.87493e-06 -6.55134e-05 -6.01952e-05 -6.21437e-05 -0.000145643 -1.93322e-05 0.000127788 -3.27545e-05 1.05126e-05 6.08013e-06 1.50661e-05 1.15406e-05 -9.0088e-05 -4.3311e-05 3.86464e-05 -1.62182e-05 1.4995e-05 -8.13941e-06 -8.77775e-06 -1.92471e-05 5.39326e-06 -7.73836e-05 1.31204e-05 6.27019e-05 8.64942e-05 -3.25558e-05 -1.43866e-05 -2.55469e-05 5.93773e-05 2.74922e-05 1.20685e-05 3.64366e-05 9.14148e-06 -3.01599e-05 3.4619e-05 -2.36395e-05 1.00042e-06 9.26299e-06 -8.72447e-06 1.53426e-05 1.21154e-05 9.9589e-06 2.77204e-05 -2.06733e-05 1.65431e-05 1.69045e-05 9.24175e-06 2.18128e-05 -2.12312e-06 2.31059e-05 -1.72524e-05 -8.15199e-06 4.47385e-05 6.31497e-06 4.5963e-06 1.62266e-05 9.66484e-06 -7.74617e-06 8.57955e-06 4.36471e-05 -1.31764e-06 2.59342e-05 -2.02494e-05 -2.07676e-05 -5.29849e-06 1.47007e-05 3.51275e-07 6.76859e-06 -1.3801e-05 9.56029e-06 -8.05641e-06 1.02569e-05 2.00944e-05 1.11711e-05 1.67081e-05 -3.53275e-06 -5.68778e-06 -1.99312e-05 2.09448e-05 -2.58192e-05 3.11818e-05 4.16801e-05 -1.77121e-05 -6.3345e-05 5.18791e-05 1.41265e-05 -4.02057e-06 5.52764e-06 -9.40625e-06 -7.78333e-06 -1.5435e-05 9.15815e-07 6.53975e-05 -2.57283e-05 4.81337e-05 9.23019e-06 1.94104e-05 -4.82072e-07 6.53086e-06 -4.02607e-06 -8.97602e-05 -2.19758e-05 7.733e-05 -2.99391e-06 -3.50521e-05 2.56306e-05 2.39038e-05 -3.54756e-05 7.72704e-05 3.25897e-05 1.39442e-05 2.59377e-05 -1.80167e-07 -3.92049e-05 3.75338e-06 -6.55279e-06 -3.35551e-05 2.18651e-05 -1.60603e-06 9.30585e-07 -2.89769e-05 2.52504e-05 4.12437e-05 4.43528e-05 1.04281e-05 3.03979e-05 -1.64841e-05 2.73299e-05 1.82484e-05 8.17176e-06 3.02222e-05 3.10429e-05 -1.22386e-05 -1.79786e-05 3.38047e-05 -1.41385e-05 6.12744e-05 6.45428e-05 1.29125e-05 -4.29094e-05 -1.89718e-05 -2.02811e-06 2.65454e-05 -1.89984e-05 1.12348e-05 2.62591e-05 4.76181e-06 -5.92912e-06 3.66113e-05 -3.65855e-05 -4.89853e-05 -1.05056e-05 5.3793e-05 1.74856e-05 -2.5251e-05 3.03637e-05 1.40035e-05 8.99418e-06 5.89714e-05 -1.2476e-05 1.18191e-05 2.1925e-05 7.38165e-06 -3.90607e-05 1.30752e-05 -5.35479e-07 -9.87169e-05 1.45864e-05 1.94566e-05 4.82723e-05 -3.21144e-05 2.60271e-05 2.22161e-05 -5.17973e-06 1.55223e-05 2.34491e-05 1.94191e-05 5.0561e-05 4.91013e-06 3.59568e-05 5.08548e-05 9.2015e-05 -4.25497e-05 -0.000232645 0.0001668 -0.000124773 1.46921e-05 4.36617e-05 -0.000136027 8.92301e-05 2.61252e-05 -5.64547e-05 0.00033906 -1.78422e-05 1.75021e-05 0.000154829 9.65974e-05 -4.86736e-05 6.2692e-06 0.00010818 -0.000132351 -5.737e-05 0.000308739 -2.0568e-06 5.28886e-05 6.69061e-07 8.26962e-05 -0.000120424 6.02385e-05 7.48725e-05 1.84615e-05 3.68194e-05 -5.48373e-05 -0.000210701 0.00010622 -3.81701e-05 -0.000151352 -5.13403e-06 -5.10394e-05 -2.23406e-05 -8.814e-05 -6.0773e-05 -3.90375e-05 9.11458e-05 3.72345e-05 -3.75049e-05 0.000130959 3.3763e-06 0.000152073 -2.42132e-05 2.66778e-05 3.03254e-05 -1.60441e-05 1.06652e-05 3.96388e-05 2.86022e-05 1.67559e-05 3.44621e-05 -4.74137e-06 -3.08301e-05 1.70548e-05 -1.00504e-06 1.01601e-05 -2.53314e-05 2.42549e-05 -1.95784e-05 2.30252e-05 3.05095e-06 1.65036e-05 -7.63494e-05 -5.38071e-05 -2.21356e-06 3.12805e-05 1.43845e-05 -2.65294e-05 2.28968e-05 8.36878e-06 -1.66316e-06 4.43259e-05 1.54461e-05 8.8701e-06 2.39133e-05 -3.66333e-06 -1.79197e-05 1.51301e-05 2.11987e-05 -9.76858e-05 1.85828e-05 3.45666e-05 1.95735e-05 1.84077e-05 2.54738e-05 1.44715e-05 6.88382e-06 -3.70886e-05 2.74172e-05 6.1381e-06 5.07134e-05 -1.16878e-05 -5.21876e-06 -1.19895e-06 -2.519e-05 -3.01986e-05 -5.66317e-05 5.90263e-06 -1.25494e-05 4.95843e-05 7.1881e-07 -3.33626e-05 3.58676e-05 -2.20458e-05 2.51718e-05 4.70043e-05 5.2318e-05 2.50106e-05 2.51629e-05 -3.02254e-05 1.22302e-07 2.43218e-05 -4.78492e-06 1.00588e-05 -1.36499e-05 -3.3095e-05 -4.64132e-06 -3.95981e-05 1.28246e-06 1.54191e-05 -6.49257e-06 3.00348e-05 -2.6903e-05 2.29033e-05 -7.94114e-06 -4.29506e-05 -7.23198e-06 1.01407e-05 -1.8981e-05 -4.88013e-06 -5.9941e-05 9.3448e-06 -1.71271e-05 3.80577e-06 -3.28153e-05 1.2202e-05 4.71328e-06 5.37541e-05 3.52211e-06 2.54583e-05 -1.72141e-05 2.53961e-05 -8.57742e-06 -9.79339e-06 -3.49488e-05 -1.89569e-05 -3.82991e-05 -8.10698e-06 -1.89446e-05 2.78667e-05 1.5907e-05 -3.42863e-05 3.92657e-05 -6.38364e-06 2.21104e-05 4.9862e-05 4.74419e-05 2.33765e-05 2.50034e-05 -2.10536e-05 3.0193e-06 2.42642e-05 1.54205e-05 8.74978e-06 -1.35079e-05 -4.06989e-05 -8.21487e-06 -3.99569e-05 5.3776e-06 1.41676e-05 4.23114e-06 3.37925e-05 -1.7251e-05 2.08241e-05 -1.10575e-05 -6.18011e-05 -6.44184e-06 1.48396e-05 -2.4779e-05 1.04807e-05 -6.80999e-05 -2.34985e-06 -1.33633e-05 -1.21616e-05 -4.04336e-05 3.38516e-05 9.81582e-06 3.56859e-05 6.55318e-06 1.24671e-05 -3.08863e-05 2.10862e-05 -1.21496e-05 -4.66414e-06 2.60097e-05 -6.95305e-05 -0.000154164 -2.23488e-05 -0.000121259 9.5098e-05 -4.73261e-07 -0.000155105 5.95416e-05 -6.83475e-06 1.44318e-05 0.00014715 6.6499e-05 -4.8749e-06 0.000152763 -3.88158e-05 -0.000123567 5.38715e-05 0.000158425 -1.16857e-05 -5.26082e-05 1.13944e-05 -1.56157e-05 -3.87564e-05 8.56097e-07 4.18181e-05 -2.48379e-05 3.76027e-05 -9.25201e-05 1.26346e-05 -3.34707e-05 -0.000110871 -7.66718e-05 -1.69419e-06 -0.000143626 -1.92925e-05 -2.74747e-05 1.54932e-06 -4.70757e-05 -0.000108899 -8.50581e-05 2.33008e-07 -1.95136e-06 7.90878e-05 -3.5403e-05 0.000102875 5.34205e-06 9.82213e-05 -1.57304e-05 -5.53152e-06 -4.10786e-05 -3.81548e-05 -3.37475e-05 -1.08221e-05 -4.65546e-06 2.66205e-05 1.75707e-05 -3.74377e-05 5.3083e-05 -6.41227e-06 2.49983e-05 4.49196e-05 5.98572e-05 2.55664e-05 3.64547e-05 -1.65639e-05 -1.11081e-06 3.4218e-05 -7.63948e-07 8.2666e-06 -5.22959e-06 -3.60858e-05 -6.87897e-06 -2.7221e-05 1.02954e-05 4.85682e-06 3.7037e-06 3.39951e-05 -2.26024e-05 1.69741e-05 -1.33562e-05 -5.60844e-05 7.01664e-06 3.08862e-05 -1.05669e-05 2.70408e-06 -0.000100676 3.83087e-06 -2.30741e-05 -4.97662e-07 -3.81436e-05 1.98195e-05 1.4632e-06 4.05248e-05 1.37626e-05 3.02704e-05 -1.65269e-05 1.51635e-05 -4.15673e-05 3.30617e-05 8.44222e-06 5.16224e-05 1.74116e-05 1.60595e-05 1.13136e-05 9.2725e-08 6.56977e-06 -3.23492e-05 1.78961e-05 2.57467e-05 1.89741e-05 9.72654e-05 1.13282e-05 2.3068e-05 -1.38617e-05 -2.65649e-05 8.82551e-05 -3.33124e-05 -1.05545e-05 -2.87036e-05 -1.72938e-05 1.84885e-06 -2.57153e-05 -9.99526e-05 1.54265e-05 -3.8163e-06 -3.01486e-05 2.00176e-05 2.7425e-05 -3.12446e-05 1.012e-05 -5.11378e-05 1.47141e-05 2.84949e-05 5.00064e-05 3.68121e-05 -2.3125e-05 -8.54469e-05 -7.09587e-07 -3.83979e-05 -6.41459e-06 2.43236e-05 4.68807e-05 2.86963e-05 -6.38798e-06 -6.95983e-06 -1.22136e-05 1.19253e-05 8.35107e-06 -1.10947e-05 -2.39646e-06 3.28918e-05 2.46941e-06 1.09856e-06 4.00134e-05 -4.51982e-05 5.39503e-06 9.00566e-06 2.38486e-05 3.0523e-06 5.77444e-06 3.83473e-05 -3.6345e-05 1.79528e-05 2.55829e-05 -4.75653e-05 7.5577e-05 -1.10063e-05 1.70933e-05 -3.01807e-05 -7.50322e-06 1.20307e-05 -1.77203e-05 -4.43142e-05 1.65992e-05 -1.54625e-05 1.19258e-05 5.08883e-05 -1.23295e-05 -2.94084e-05 3.24749e-06 -2.05513e-05 1.58465e-05 1.25986e-05 6.89597e-07 4.57462e-05 -2.15939e-05 -0.000161934 2.01709e-06 -4.47717e-05 -5.08931e-05 9.02126e-06 4.37943e-05 2.88629e-05 -9.41186e-06 -4.65909e-05 -1.00854e-05 5.71164e-06 -0.000112354 1.40034e-05 7.56734e-05 -7.77141e-05 -0.000119244 8.07275e-05 -0.000193236 8.88539e-05 -2.61397e-05 -0.000148716 0.000276047 -3.31315e-05 2.75829e-05 0.000442164 6.82605e-05 3.64592e-06 7.16317e-05 4.03353e-05 -7.00489e-05 -4.35894e-05 0.000134083 1.35952e-05 -0.000146088 5.96679e-05 -9.96715e-05 -0.000223497 -0.000112954 0.000102358 -0.000111375 4.77044e-05 2.16132e-05 7.11686e-06 -9.91362e-06 -0.000152623 -0.00010511 6.74552e-05 -0.000193017 -2.91316e-05 -5.59458e-05 -6.91059e-05 -0.000252506 -0.000245551 -7.12425e-05 -4.47688e-05 9.47591e-05 8.32866e-05 -5.8238e-05 0.000141119 1.14811e-05 0.000135211 -6.4054e-06 9.29424e-06 1.74414e-06 3.38731e-05 6.61433e-06 -5.08707e-06 3.1847e-05 -2.65704e-05 2.27263e-05 8.25113e-06 3.55565e-06 1.61336e-05 -7.16863e-06 3.05072e-05 -9.93641e-06 1.20499e-05 -1.00956e-05 -9.75669e-06 5.96076e-05 -5.7588e-06 1.1366e-05 -1.68245e-05 1.14575e-05 9.52319e-06 -6.01037e-07 -4.06882e-06 1.41727e-05 -1.88268e-05 6.66046e-06 3.52784e-05 2.93774e-06 -1.17022e-05 2.92492e-06 -2.28661e-05 7.97819e-07 2.40533e-05 3.59159e-05 3.67911e-05 4.26043e-06 -7.41023e-05 3.09774e-06 -3.15393e-05 -1.02896e-05 2.87995e-05 3.09064e-05 1.02272e-05 2.8428e-06 -5.2579e-06 -2.01739e-05 2.35354e-06 1.59259e-06 -1.52536e-05 9.47427e-05 -2.6877e-06 -0.000222337 4.75983e-05 -0.000111474 9.15868e-05 -0.000129571 -4.38028e-05 0.000147768 1.80459e-05 2.87089e-05 0.000347679 4.08405e-05 9.91385e-05 6.20936e-05 5.94189e-05 -5.74283e-05 -5.68694e-05 8.23364e-05 -4.30124e-05 -0.000107819 -4.61925e-05 -9.21082e-05 -0.000227949 1.57018e-05 5.32798e-05 -0.000124736 0.000160895 1.39885e-05 5.04781e-05 6.32014e-07 -0.000124201 -2.98838e-05 7.75256e-05 -7.40179e-05 1.59176e-05 -9.44545e-05 5.98688e-06 -0.000145135 -4.57284e-05 -1.65208e-05 -1.93953e-05 0.000118234 -8.9265e-06 1.93603e-05 2.58945e-05 -1.44088e-05 0.000110568 -5.60726e-05 -3.33222e-05 5.53423e-05 -1.83709e-05 -0.00013313 3.94473e-05 -0.000102626 0.000118621 -9.00745e-05 -9.24926e-06 0.000161531 3.50101e-05 1.11984e-05 0.00046598 9.0641e-05 6.56197e-05 8.45811e-05 -7.63232e-06 -7.61325e-05 -5.14004e-05 0.000100533 -2.31399e-05 -0.00011162 -2.76028e-05 -7.09057e-05 -0.000165721 -8.0421e-06 6.3444e-05 -9.76467e-05 0.00015103 -3.7661e-05 8.59608e-05 -2.10182e-05 -9.36355e-05 -0.00014479 0.000140622 -0.000162105 -6.28354e-05 -3.1519e-05 1.31751e-05 -0.000297626 -0.000173691 -1.79802e-05 -5.88169e-05 0.000149806 1.77262e-05 4.79797e-05 0.000121517 -6.05966e-05 0.000118005 -7.0124e-05 8.07095e-05 0.000134418 -0.000105989 -0.000245701 0.000136781 -0.000288431 0.000179472 -1.09204e-05 -0.00027432 0.000150326 -9.49041e-05 -4.66451e-05 0.000541386 1.19729e-05 4.96398e-05 0.000165371 0.000107049 -0.000208482 -2.72626e-05 0.000252398 -0.000181361 -0.000176159 0.000267428 -6.24992e-05 -0.000224603 -9.62312e-05 0.00011008 -0.00017483 0.000147827 -6.99763e-05 -4.85806e-05 -1.08165e-05 -4.0173e-05 -0.000239924 0.000104923 -0.000279473 -0.00013474 5.74311e-06 -9.58611e-06 -9.61624e-05 -0.00022532 6.21226e-05 -3.22767e-05 7.07509e-05 6.50519e-05 -5.40266e-05 0.000188071 0.000108752 0.000236604 -2.86989e-06 -2.29237e-05 -1.51011e-05 1.09902e-05 -9.56914e-05 -2.16712e-05 -8.81022e-05 0.000118716 -1.9933e-05 4.49976e-05 0.000101224 3.10957e-05 -4.36121e-06 0.000311502 9.35939e-05 8.28399e-05 9.17436e-05 -5.93525e-05 -3.46606e-05 -4.30664e-05 0.000129219 -5.98008e-05 -7.43632e-05 -2.25527e-05 -3.61235e-05 -0.000130588 5.11629e-05 2.75728e-05 -4.20903e-05 0.000202299 -0.000108745 8.45352e-05 -2.96374e-05 -8.79957e-05 -0.00010402 0.000118809 -0.000111877 5.04361e-05 -7.36683e-05 -6.00676e-05 -0.000182463 -0.000113241 -5.84536e-05 -1.71419e-05 9.83997e-05 5.35097e-05 0.000101124 0.00011991 -1.28517e-05 0.000107488 -1.6966e-06 8.26894e-06 -2.6134e-05 -6.80089e-06 4.37918e-05 6.484e-06 2.58743e-05 -2.92068e-05 7.22509e-06 -1.28384e-05 -2.19279e-05 2.59381e-05 9.16958e-06 -4.24264e-05 -4.56351e-06 6.15838e-06 -2.39611e-05 -2.34229e-05 2.72571e-05 5.46914e-06 -2.19671e-05 1.2684e-06 1.45878e-05 3.56142e-05 1.20913e-05 4.34491e-05 2.1245e-05 -1.83019e-05 -6.90851e-06 2.75837e-05 2.3708e-05 7.31685e-07 3.16802e-05 3.73807e-05 1.95289e-05 9.51148e-06 2.7192e-05 -9.47135e-07 3.25171e-06 -5.98404e-07 -4.54802e-06 3.93841e-06 3.06981e-05 1.09133e-06 2.4555e-06 -2.35634e-05 6.41303e-06 -9.33121e-06 2.13099e-05 -7.40223e-06 2.88987e-06 2.85453e-06 6.91568e-06 6.22504e-06 4.9723e-05 1.97893e-05 1.9337e-05 -2.04404e-06 9.4513e-06 1.88534e-05 -2.98507e-06 1.62506e-05 -7.05382e-06 1.38681e-05 -1.0433e-05 -1.07442e-05 -1.61e-05 -1.86826e-05 1.75943e-05 -4.14392e-06 4.34012e-06 -5.84946e-06 -2.7727e-07 3.07544e-05 9.08002e-06 1.51646e-05 5.5502e-06 -4.3378e-06 2.11687e-06 2.15908e-05 1.34353e-05 -7.44155e-06 1.68498e-05 3.06375e-05 -8.86955e-07 2.18265e-05 4.44959e-06 8.24521e-06 8.3528e-06 -3.83792e-05 -2.90831e-05 -2.00291e-05 2.44643e-06 -2.94945e-05 1.98022e-05 1.4927e-05 -3.72694e-06 -3.81921e-06 1.22103e-05 -1.09504e-05 -0.000117976 -6.04653e-05 0.000205378 -2.82838e-05 0.000164224 4.90828e-05 -4.10714e-05 1.14092e-05 -0.000111596 2.67992e-06 5.60284e-05 -0.000126452 5.02427e-05 0.000246893 6.02113e-06 2.98794e-05 -6.12623e-05 -4.63545e-05 3.64807e-05 -3.82811e-05 -2.07361e-05 -9.3138e-06 -7.93579e-05 5.30225e-06 -4.64479e-05 -0.000182421 -4.64758e-05 1.45144e-05 -5.85038e-05 3.0865e-05 2.6336e-05 -7.1951e-05 -3.84947e-06 0.000264927 3.17226e-05 0.000122505 -5.20085e-05 -4.49311e-05 1.60508e-05 -4.18035e-05 -0.000132538 0.000101012 -6.90579e-05 -9.57624e-05 7.65674e-05 3.55717e-05 -6.68504e-05 3.80239e-05 7.27085e-05 2.25849e-05 2.79034e-07 1.71053e-05 5.64114e-06 -1.18161e-05 -3.20449e-05 2.73573e-05 -3.95424e-05 3.23414e-05 -3.41126e-07 -2.14557e-05 4.83331e-05 4.38354e-05 -1.18582e-05 6.99386e-05 1.32675e-05 5.12964e-06 4.06303e-06 3.86062e-06 -1.16724e-05 -7.98197e-06 2.06364e-05 -4.05762e-06 -1.78964e-05 4.23845e-05 2.78227e-06 -1.0815e-05 -7.68022e-06 2.46688e-05 -2.15848e-05 -9.00234e-07 2.31986e-05 1.22017e-05 2.44259e-05 -3.50509e-05 -2.75188e-05 1.84926e-05 -2.4381e-05 8.84915e-06 -2.13414e-05 -2.2512e-05 -5.44982e-05 -9.83661e-05 2.78046e-05 -1.316e-05 2.61215e-05 2.36004e-05 1.25753e-05 1.24038e-05 4.02281e-07 3.14677e-05 -2.5436e-05 6.78864e-06 6.38241e-05 -1.19437e-05 -3.56575e-06 1.16658e-05 -1.88041e-05 8.3727e-06 2.65949e-06 -6.01056e-05 8.99428e-06 -2.20387e-05 3.29806e-06 1.54957e-05 6.13334e-06 -1.50142e-05 2.1523e-05 1.18637e-05 -1.6473e-05 3.03758e-05 4.97986e-05 -2.49591e-05 -4.40785e-06 -2.79016e-06 -3.88707e-06 -2.08857e-05 4.66192e-06 -9.14263e-06 1.25372e-05 2.41072e-05 2.65172e-06 -1.73537e-05 8.40472e-06 -1.24702e-05 1.64319e-05 -2.98538e-07 -6.59134e-07 -2.70584e-06 -2.02339e-05 9.07837e-06 -2.31512e-06 8.39381e-06 -3.88961e-05 -2.55214e-06 1.12701e-06 2.59386e-05 -3.62595e-06 1.11141e-05 6.94212e-06 -1.56121e-05 -1.29494e-05 -8.5746e-06 3.22629e-05 -1.59137e-05 -9.05909e-06 1.79557e-06 2.24378e-05 -1.89578e-05 1.17528e-05 -4.68006e-05 -1.28889e-05 -1.79913e-05 6.36165e-06 -4.45776e-05 -8.56254e-07 -3.13582e-05 2.1985e-05 -2.26509e-05 6.70247e-06 3.8514e-05 2.88243e-05 -3.4176e-06 1.39682e-05 -1.86039e-05 1.65754e-05 2.63607e-05 1.05344e-05 -1.8199e-05 1.8812e-05 3.27748e-05 -9.48496e-07 -1.68744e-05 1.35023e-05 3.03287e-06 4.72107e-06 -9.74024e-07 6.28144e-06 2.03878e-05 -1.67369e-06 2.15771e-05 2.65168e-05 3.60476e-05 -6.39918e-05 7.93909e-06 -2.19839e-05 3.42976e-06 -1.33746e-06 7.52416e-06 2.18699e-06 -2.73426e-05 -0.000223025 3.7587e-05 0.000187522 -2.45356e-05 3.4243e-05 6.81608e-05 -0.000215051 0.000120433 -8.93918e-05 -0.000258805 0.000232972 -0.000170392 3.69808e-05 0.000400833 5.55096e-05 -7.22377e-06 0.00014113 4.73522e-05 -9.41312e-05 -7.4841e-05 5.25564e-05 7.5337e-06 -0.000161908 0.000122877 -0.000136342 -0.000414289 -0.000161261 3.95611e-05 -9.93623e-05 5.75609e-05 3.86904e-05 -5.47701e-05 -2.15859e-05 -5.09366e-05 8.91392e-05 2.54195e-05 -8.8735e-05 -1.63404e-05 -8.22975e-05 -0.00011026 -9.32376e-05 -4.77214e-05 -0.000123028 -5.53736e-05 9.97002e-05 0.000100489 -4.57128e-05 0.000135909 6.61865e-05 3.48125e-05 -5.4996e-06 4.53494e-06 5.24227e-05 -8.19469e-06 -2.70938e-05 4.04419e-05 3.02703e-05 -2.4273e-05 -9.14795e-06 -4.75571e-05 -1.25168e-05 2.21271e-06 7.22623e-07 -3.02344e-05 -1.50973e-05 -2.56542e-05 2.73595e-05 -1.21322e-05 2.3625e-05 1.67132e-05 3.55427e-05 -1.01034e-05 1.24705e-05 -9.24022e-06 1.10619e-05 1.57228e-05 1.99941e-05 -2.64336e-05 1.33302e-05 4.57069e-05 4.27071e-05 -2.05085e-05 4.2379e-05 -1.19577e-05 1.40928e-05 1.97874e-06 4.6078e-05 2.59732e-05 -1.90993e-05 -5.38186e-06 2.14557e-05 2.33948e-05 -4.87479e-05 -1.02796e-05 -6.25205e-06 1.51256e-05 2.73864e-07 -4.94056e-06 2.23268e-05 -3.07815e-05 1.59869e-05 -6.04732e-06 3.99152e-05 -1.55797e-05 -6.11015e-05 9.05866e-07 -2.7515e-05 -2.03383e-05 -4.88643e-06 1.16721e-05 -1.3802e-05 3.56008e-05 -3.59968e-06 4.2727e-06 -6.95858e-06 -1.20346e-05 4.20441e-05 -5.66374e-06 -1.6426e-05 1.49118e-05 3.2176e-05 1.78109e-05 -2.70378e-07 -2.77845e-06 2.76346e-06 1.013e-06 2.33707e-05 1.04177e-05 -4.08372e-06 4.63215e-05 -6.61142e-06 1.20437e-05 -7.7775e-06 -5.12797e-05 -4.72679e-05 1.14173e-05 -3.30812e-05 -9.8931e-06 1.55792e-05 2.27995e-05 -4.15939e-06 -2.67904e-06 -1.68401e-05 -3.74061e-05 -1.02299e-05 -9.22304e-06 1.31683e-05 -1.3088e-05 4.18784e-05 -3.95815e-06 -1.00536e-05 -6.5866e-06 3.9046e-05 -7.67858e-06 -7.16985e-05 1.10594e-05 -6.27415e-05 -7.83984e-06 -2.53164e-05 2.21624e-05 3.34526e-05 3.40847e-05 7.02768e-06 6.77491e-05 1.28831e-05 6.33527e-06 4.42738e-05 7.67359e-07 -3.93256e-05 1.13455e-05 6.99231e-05 -3.66212e-06 -1.56528e-05 2.4092e-05 -1.68912e-06 -1.07527e-05 -5.61686e-06 1.09166e-05 -1.45984e-05 6.05021e-05 -1.08425e-05 2.00991e-05 -7.77497e-06 -5.42837e-05 -5.30997e-05 1.41142e-05 -3.03017e-05 -1.79757e-05 1.00837e-05 1.61158e-05 -3.93429e-05 -1.77631e-05 -3.56792e-05 -6.7774e-05 2.56469e-05 3.12348e-05 1.0568e-05 2.66245e-05 2.66411e-05 1.64184e-05 -0.00011738 3.08181e-05 0.000120648 -2.30396e-05 -0.000156238 0.000123546 -0.000263173 6.51483e-05 -2.16131e-05 -0.000217508 0.000275605 3.09472e-05 4.31807e-05 0.000661758 0.000129008 -3.13138e-05 8.39088e-05 8.43966e-05 -7.37397e-05 -6.84706e-05 0.000229171 -5.61418e-05 -0.000159064 0.000159356 -0.000114782 -0.00020877 -0.000103875 0.000137281 -0.000120928 9.44448e-05 4.19885e-05 -4.19635e-06 1.82976e-05 -0.000171901 -0.000136465 0.000113505 -0.000200648 -7.38198e-05 -9.61548e-05 -6.94754e-05 -0.000265715 -0.000209684 -0.000167911 -0.000148645 0.000142955 0.000110439 -4.80632e-05 0.000184091 3.25422e-05 0.000166398 -2.8238e-06 6.08316e-06 4.64095e-05 -3.92502e-05 -8.78244e-05 1.13267e-05 -5.74827e-05 -3.76418e-05 -8.97458e-06 -1.56181e-05 2.45435e-05 4.89032e-05 -1.87736e-06 8.40356e-06 -3.07783e-05 -2.367e-05 6.82054e-05 8.76763e-06 -3.51748e-05 4.25973e-05 5.67012e-05 -7.44662e-06 -9.42966e-06 4.38699e-05 2.48743e-06 -2.45674e-06 2.53989e-05 1.77957e-05 -4.69352e-06 6.16755e-05 -9.08519e-07 5.05964e-06 -1.61641e-06 -7.46239e-05 -6.51289e-05 2.36786e-05 -1.67883e-05 -4.95401e-05 2.64106e-05 4.62971e-05 -2.43242e-05 -1.05995e-05 -1.27803e-05 -5.20895e-05 -3.8926e-06 -2.11248e-06 1.07094e-05 3.98868e-05 3.12777e-05 4.89007e-07 -5.10857e-05 2.70545e-05 5.89663e-05 4.57519e-05 1.20582e-05 4.74585e-05 -0.000103385 6.2782e-05 -3.16369e-05 2.17196e-06 9.82579e-05 6.68229e-06 5.95472e-06 0.00035968 7.20575e-05 9.53784e-05 -7.88814e-06 -2.48051e-06 2.15967e-05 -0.000101991 5.61381e-05 -5.78967e-05 -7.3311e-05 2.61157e-05 -5.71931e-05 -0.00018874 -9.55234e-06 5.19649e-05 -7.78389e-05 1.47746e-05 3.38729e-05 1.10917e-06 1.01936e-05 2.75669e-05 -4.127e-05 8.59623e-05 -6.96114e-05 1.25205e-06 -2.96549e-05 -7.39985e-05 -0.000144641 -0.000112726 -9.13317e-07 -8.65228e-07 0.000133183 4.65392e-05 4.97421e-06 3.60915e-05 -3.56053e-05 6.91534e-05 -2.45628e-05 1.16627e-05 1.93184e-05 2.22008e-05 2.19114e-05 4.08498e-05 -6.96948e-05 6.64312e-05 -1.64676e-05 1.25516e-05 8.16707e-05 4.15992e-06 1.00802e-05 0.000287728 5.12236e-05 4.42128e-05 -1.65999e-05 -6.26445e-06 -1.25339e-05 -5.83689e-05 3.99041e-05 -4.05856e-05 -6.05962e-05 6.84548e-05 -4.66436e-05 -0.000127731 -1.42387e-05 4.00284e-05 -4.90148e-05 9.44562e-06 2.16111e-05 -1.20579e-05 2.47526e-06 7.27445e-05 -3.21737e-05 6.41318e-05 -9.09073e-05 -9.81416e-06 -1.0365e-05 -8.46648e-05 -0.000119837 -9.04985e-05 -3.22255e-06 5.97208e-06 0.000145756 4.3947e-05 -8.04808e-06 -1.07113e-06 -1.88227e-05 3.78457e-05 -4.48329e-05 -6.92182e-05 -0.000163708 2.88037e-05 0.000239214 -0.000192803 0.000238756 -0.000121635 8.11939e-05 0.000166944 -0.000247132 5.94698e-05 -9.73635e-06 -0.000559268 -4.69e-06 -8.80317e-05 -0.000113146 -8.5737e-05 6.16496e-05 7.24042e-05 -0.000205385 4.07933e-05 0.000178441 -0.00015185 9.58434e-05 0.000326649 7.77087e-05 -9.65167e-05 0.000136202 -2.19181e-05 -4.97124e-05 3.11434e-05 -2.92698e-05 0.00011832 0.000184601 -4.24796e-05 0.00016325 6.29832e-05 1.20953e-05 2.58383e-05 0.000159436 0.000160215 6.74638e-06 1.26725e-05 -0.000121874 -0.000119184 3.76187e-05 -0.000121616 5.73547e-05 -0.000173072 -1.12003e-05 3.06251e-06 1.96512e-05 3.43699e-05 2.05422e-05 1.84687e-05 -2.23432e-05 3.98392e-05 -1.36425e-05 4.26523e-05 6.61598e-05 3.18855e-05 2.21414e-05 0.000217925 3.17755e-05 3.63316e-05 -2.50413e-05 -1.55973e-05 2.34403e-05 -5.02113e-05 1.44508e-05 -1.92666e-05 -3.956e-05 2.73548e-05 -2.6008e-05 -0.000104847 -2.52831e-06 1.42924e-05 -4.30523e-05 1.24319e-05 9.78088e-06 -2.99178e-06 -8.9237e-07 1.86932e-05 -4.34043e-05 4.90157e-05 -6.03917e-05 -1.78402e-05 -9.42164e-07 -4.90475e-05 -9.20652e-05 -2.79108e-05 9.04127e-06 9.57987e-06 0.000111375 -5.15795e-07 2.08579e-05 -2.41402e-06 -1.60956e-05 1.3388e-05 -5.76418e-06 2.07299e-06 2.63664e-05 -7.23028e-06 -4.3077e-05 9.75183e-07 7.21813e-06 -1.49082e-05 -1.95936e-05 -1.39544e-05 2.94426e-05 -2.90495e-05 4.90068e-06 6.4829e-06 -6.97767e-06 -3.13462e-05 6.61941e-06 -2.42729e-05 2.83129e-05 4.7474e-06 3.36122e-05 3.67033e-05 1.20554e-06 7.26502e-06 -2.90992e-06 -1.89548e-05 -2.59191e-05 -1.03824e-05 1.19576e-05 -7.04297e-06 1.22311e-05 -1.77601e-05 -1.21143e-05 5.79225e-06 -2.59414e-07 -2.77582e-06 -1.91746e-05 3.48847e-05 6.87715e-06 -9.08798e-06 2.59426e-05 2.65254e-06 -1.22062e-05 1.19267e-05 -4.65566e-06 8.84271e-05 2.61542e-06 2.76663e-06 -2.00184e-05 2.22999e-05 7.9627e-06 7.34147e-06 6.42026e-05 6.23215e-06 -4.90808e-05 2.62056e-05 -3.25286e-05 1.85196e-05 -3.03373e-05 -1.84669e-05 6.92902e-05 -5.50691e-05 9.79206e-06 7.40328e-05 8.17756e-06 -1.24525e-05 4.01797e-05 -2.85671e-05 3.7661e-05 -7.35497e-07 7.88432e-05 1.79635e-05 -1.46385e-05 1.27655e-05 -1.71634e-05 -7.20867e-05 -2.02541e-05 -1.17553e-06 1.07568e-05 -1.1779e-05 2.17174e-06 -2.43488e-05 -4.06055e-06 -3.72783e-06 1.48239e-05 5.0876e-06 -2.86021e-07 6.11886e-05 -1.83536e-05 -2.43922e-05 1.42025e-05 -3.47621e-06 -4.20073e-05 -2.73446e-06 -4.13894e-06 0.000160414 -2.85871e-07 2.15748e-05 -3.80635e-05 3.93185e-05 4.56543e-05 -1.98753e-05 -0.000125687 8.08582e-05 0.000164615 -9.53746e-05 0.000144465 -5.99639e-05 7.41056e-06 0.000125688 -0.000105789 0.000131577 -2.07662e-05 -0.000265476 -2.82317e-05 -4.04691e-05 -0.000137863 -4.20137e-05 8.68134e-05 1.88548e-06 -9.64667e-05 2.03771e-05 0.000100641 -0.000141294 5.2506e-05 0.000132362 2.33787e-05 -2.6909e-05 8.10244e-05 -3.69281e-06 -2.26821e-05 2.68346e-05 -3.62672e-06 9.29464e-05 9.7187e-05 -2.94004e-05 0.000109211 0.000102349 1.12173e-05 -1.24591e-05 7.45989e-05 7.28205e-05 2.72734e-05 4.67976e-06 -2.66089e-05 -6.25114e-05 3.10142e-05 -7.51325e-05 3.26444e-05 -0.000119544 1.55926e-05 -1.46541e-05 4.92311e-05 7.44068e-06 -7.12039e-05 1.08459e-05 -4.4296e-05 6.13861e-06 -5.35581e-05 -2.75427e-05 8.69343e-05 -5.60123e-05 1.02981e-05 7.83433e-05 1.04281e-05 -2.82437e-05 3.43721e-05 -4.4404e-05 1.44319e-05 4.35217e-06 0.000111095 3.15761e-05 -1.23064e-05 1.40308e-05 -1.06879e-05 -6.42583e-05 -4.97153e-05 1.21154e-06 2.09743e-05 -1.25966e-05 -8.03043e-06 -2.23217e-05 -1.30197e-05 6.67276e-06 8.95399e-07 4.34284e-06 -2.92095e-05 6.45069e-05 -3.33319e-05 -3.3536e-05 2.90108e-05 4.40293e-07 -5.72519e-05 9.31311e-06 5.105e-06 0.000196616 2.85996e-06 8.27747e-06 -5.1996e-05 4.3201e-05 -3.38948e-06 -5.91933e-06 -3.28303e-08 -5.92332e-06 2.14468e-05 2.50333e-05 -8.18355e-07 -8.2905e-06 -2.13532e-05 -1.4859e-05 1.13335e-05 -6.08815e-07 -1.04352e-05 8.55806e-06 5.90775e-06 -9.13401e-07 -7.62703e-06 -4.9272e-06 -8.52976e-06 1.21978e-05 6.60515e-06 -5.50662e-06 -2.20232e-06 -9.93161e-06 -9.75692e-06 -2.40989e-06 -9.96887e-06 1.47539e-05 -1.39129e-06 6.66096e-06 7.47041e-06 4.42533e-06 7.4397e-06 2.87854e-05 2.37615e-05 -3.96682e-06 1.37322e-05 -1.18871e-05 -7.27734e-06 -8.98552e-06 -1.19348e-05 8.50512e-06 -1.06235e-05 7.50061e-06 1.31853e-05 8.07861e-06 -1.84644e-05 -1.26453e-05 -5.24262e-06 -5.16394e-06 1.99986e-06 -2.93251e-06 9.68317e-06 5.7667e-06 1.25841e-05 1.2535e-05 1.16505e-05 -1.23547e-05 -1.32885e-05 7.38389e-07 -8.76418e-06 1.09111e-06 7.17766e-07 -1.65282e-05 -1.37751e-05 4.20512e-06 2.72397e-06 1.07512e-05 -1.12193e-05 5.3653e-06 -4.36812e-08 -5.86464e-06 2.87355e-06 -1.81214e-05 -5.72591e-06 -6.30262e-06 2.49362e-06 1.16356e-05 -3.64715e-06 -4.13094e-06 1.25271e-05 6.33496e-06 2.21441e-06 1.74721e-05 8.44509e-06 5.9304e-07 2.96487e-05 -2.41432e-05 1.27577e-05 -1.4034e-06 5.66239e-06 2.44577e-05 -1.05075e-05 2.69211e-05 4.86827e-06 -2.69405e-06 -1.20516e-05 -1.59502e-05 2.1045e-05 -6.80388e-06 6.7392e-05 7.16738e-05 6.45255e-06 -5.80867e-05 -0.000130358 5.15289e-05 5.19188e-05 -7.68505e-05 -1.39604e-05 -7.73681e-05 -4.75399e-06 1.0789e-05 6.01123e-05 3.92335e-05 -3.66925e-05 0.000144234 1.07306e-05 5.46095e-05 -1.16192e-05 5.68223e-06 -7.21595e-06 -4.43063e-05 -3.36168e-06 1.02195e-06 -5.49671e-06 -6.57781e-05 4.2981e-05 -8.76237e-05 -7.49822e-05 -3.35496e-05 9.24632e-05 1.95165e-05 2.94777e-05 6.29126e-06 -6.78949e-05 -2.00569e-06 8.1061e-05 -0.000111727 -3.01099e-05 6.04828e-07 -2.33262e-05 2.804e-05 7.28439e-05 1.40097e-05 -1.63936e-06 2.53242e-05 5.31673e-06 -2.06444e-05 2.30473e-05 4.60583e-05 -2.36425e-06 -8.51445e-06 -7.7364e-06 3.30687e-06 1.38736e-05 4.45231e-06 2.04747e-05 1.00483e-05 1.88844e-05 5.6446e-06 -2.94038e-05 1.78342e-05 -2.36548e-05 -6.04679e-05 1.0703e-05 -1.94592e-05 1.9869e-05 -1.00661e-05 2.36861e-06 1.46912e-05 1.62577e-05 -2.8242e-05 1.81043e-05 -3.01627e-05 1.52664e-05 2.97765e-05 3.87725e-05 1.85911e-06 1.81453e-05 4.25422e-05 -8.03129e-06 4.12031e-06 8.5755e-06 -1.86893e-05 7.18194e-06 -8.10625e-08 3.42258e-05 1.77247e-05 2.23011e-06 1.4997e-05 6.37939e-05 -4.72096e-06 -3.36819e-05 2.1906e-05 -8.25615e-06 1.5087e-05 2.24451e-05 1.04527e-05 1.34815e-05 -7.59873e-06 5.39119e-06 4.97834e-06 1.99306e-05 2.82991e-06 -1.86573e-06 2.12993e-05 -7.02807e-06 1.34502e-05 6.27208e-06 4.70902e-07 -3.00074e-06 1.03679e-07 3.10241e-06 6.54096e-06 -2.31224e-07 -9.97784e-07 1.76675e-06 4.89713e-06 2.36301e-05 -7.75952e-06 -2.34063e-06 -4.50496e-06 2.9414e-06 2.82959e-05 1.13571e-05 1.23171e-05 9.70567e-06 -8.89918e-06 -1.04429e-06 1.10531e-05 1.86975e-05 -7.02238e-06 1.93846e-05 5.75387e-06 4.09295e-06 4.78738e-08 1.66727e-05 5.20343e-06 4.88673e-06 -9.94252e-06 8.11777e-06 -4.53514e-06 7.13e-06 -3.3865e-06 7.13649e-07 1.32302e-06 -2.28916e-06 -3.08503e-06 1.23489e-05 1.53968e-06 -1.31298e-05 7.36357e-06 -1.79991e-06 1.3464e-06 9.11249e-06 3.86417e-06 -7.07033e-07 1.62075e-05 2.10997e-06 -1.1156e-05 -2.67125e-06 5.78216e-06 -1.55408e-06 7.44468e-06 5.17486e-06 4.47949e-06 -9.5696e-06 -3.05716e-06 6.67912e-06 -5.02929e-06 -1.37206e-05 -3.1197e-06 2.06856e-06 1.1781e-05 1.11042e-05 1.2855e-05 -6.18683e-06 1.15636e-06 6.61819e-06 -1.04749e-05 1.07246e-05 -2.91366e-06 1.15081e-05 1.59874e-05 6.20999e-06 -2.78264e-06 5.64062e-06 9.48581e-07 -9.25802e-06 -7.46624e-06 9.45184e-07 -1.34413e-05 -1.11247e-06 5.05953e-07 -4.16014e-06 -6.22322e-06 -6.80742e-07 1.36505e-05 7.68073e-06 1.26873e-06 7.15505e-05 1.09327e-05 9.83152e-06 3.51707e-05 -1.82064e-05 2.81166e-05 1.1196e-05 -4.58184e-05 -6.53761e-05 2.69344e-05 -1.40441e-05 8.24468e-05 -4.13479e-05 -9.18939e-05 -5.33299e-05 -2.22345e-06 -1.62858e-05 5.95543e-06 5.07254e-05 -3.47811e-06 1.83879e-06 -3.03914e-05 3.19926e-05 7.30947e-05 2.29949e-05 9.08843e-05 0.000112192 -7.68215e-05 3.59459e-05 5.01004e-05 5.23754e-05 -8.16176e-06 4.92609e-05 -4.06915e-05 1.74613e-05 -4.88639e-06 5.91807e-05 1.53528e-05 1.15884e-05 2.2034e-05 5.47588e-05 3.69838e-05 4.71198e-05 -4.07021e-06 1.36154e-05 3.3203e-06 6.03053e-05 -2.11869e-05 4.90385e-07 -2.26718e-05 -9.37939e-06 -3.90272e-06 1.09272e-06 3.88633e-07 5.69924e-06 4.19399e-06 -1.76858e-05 2.91747e-05 2.32989e-06 -9.35596e-06 3.07944e-06 -5.1009e-06 -1.0345e-06 1.94785e-05 1.29389e-05 -2.0577e-06 -7.92244e-06 1.89066e-06 1.66758e-05 -8.22246e-06 -9.26375e-07 -8.13125e-07 1.73986e-06 2.42424e-05 1.23498e-05 1.88407e-05 -1.05591e-05 9.07179e-07 7.63593e-06 4.54962e-06 3.09307e-06 -3.27969e-06 8.23455e-06 2.31102e-05 4.45174e-06 4.70684e-06 3.05771e-06 6.30089e-06 -6.76799e-06 -1.67948e-05 -2.64567e-06 -2.24741e-05 -6.50547e-07 -5.62666e-07 -2.43672e-06 2.3356e-06 1.57284e-06 6.36078e-06 1.52345e-05 4.69885e-06 2.43186e-05 -9.31299e-06 1.31443e-05 -2.6886e-05 -1.2901e-07 -1.98156e-06 -1.64647e-05 -5.13017e-05 2.29534e-05 -4.35738e-06 -5.58442e-05 1.46483e-05 1.02958e-05 -0.00013597 -5.43855e-05 -3.43483e-05 6.07826e-06 2.29432e-05 -4.28106e-06 2.14676e-05 -4.11414e-05 -1.19681e-05 2.42628e-05 6.7975e-05 1.75227e-05 6.49854e-05 -1.19061e-05 -9.88108e-06 5.90839e-06 2.47514e-05 2.19172e-05 -8.03848e-06 5.34092e-06 4.0664e-05 1.03885e-05 -1.5776e-05 3.41034e-05 -2.38671e-05 2.96651e-05 1.7118e-05 2.59236e-05 3.70474e-05 6.33959e-06 1.67723e-05 -1.89554e-05 -5.83254e-05 9.4134e-07 2.51429e-06 9.11769e-05 -6.24426e-05 -2.04116e-05 2.08186e-05 3.55591e-05 -3.92002e-05 1.40184e-05 1.87569e-05 1.03046e-05 -4.7101e-05 1.20117e-05 -1.12054e-05 -8.6151e-05 2.3751e-05 1.01161e-05 -0.00010483 -4.88092e-05 -1.81995e-05 -3.41632e-05 3.27129e-05 -1.44607e-05 3.38994e-05 -5.58772e-05 1.19634e-05 1.4555e-05 4.10089e-05 1.07642e-05 1.21787e-05 -5.11344e-06 -4.75379e-06 2.32793e-05 2.91416e-05 3.49549e-05 -2.82033e-05 1.49651e-05 4.29532e-05 1.72674e-05 8.87936e-06 3.61802e-05 -4.8061e-05 5.09019e-05 3.07171e-05 2.71594e-05 6.02252e-05 1.75983e-05 -5.89128e-06 -3.7443e-05 -3.72859e-05 -7.28083e-06 3.74091e-05 0.000203321 -6.10744e-05 9.32069e-05 -1.24432e-05 -0.0001688 4.69742e-05 0.000202213 -0.000126877 0.000214685 -0.000166393 3.05696e-05 0.000224651 -0.000167074 0.00010326 -1.93135e-05 -0.000416086 -9.79984e-06 -1.96661e-05 -0.000195216 -8.16368e-05 5.77453e-05 -1.01759e-05 -0.000229626 2.56069e-05 0.000120334 -0.000140969 9.8985e-05 0.00015443 2.47908e-05 -0.000115995 8.47979e-05 -7.8543e-05 -6.78303e-06 -1.37591e-05 -6.56959e-06 0.000186674 0.000152392 -6.30235e-05 7.0167e-05 6.26926e-05 1.23577e-05 3.8462e-05 0.000134855 0.000161784 1.00482e-05 -2.98192e-05 -0.000103668 -0.000105412 7.29053e-05 -0.000133161 4.27418e-05 -0.000131819 -4.52862e-07 1.43458e-05 4.55281e-05 -3.19554e-05 1.22887e-05 9.30785e-06 -9.47303e-06 -1.26881e-05 1.5568e-05 -5.4642e-06 -7.79913e-05 1.88249e-05 6.58338e-06 -9.77254e-05 -3.90681e-05 -1.90633e-05 -2.74117e-05 3.22579e-05 -2.18482e-05 3.43055e-05 -4.12514e-05 -2.13519e-05 1.4911e-05 7.55326e-05 1.38363e-05 2.84379e-05 -1.31521e-05 -4.95271e-06 1.77647e-05 7.29107e-05 2.29531e-05 -6.8458e-06 3.00805e-06 5.40982e-05 2.77197e-05 1.00146e-05 4.91111e-05 -4.7945e-05 4.81472e-05 3.94846e-05 2.49539e-05 5.98522e-05 1.81493e-05 9.2683e-06 -2.30273e-05 -6.10614e-05 -1.07233e-05 3.78269e-05 0.000197303 -6.55638e-05 -9.92508e-06 7.96148e-06 2.19909e-05 7.53883e-06 -1.73481e-05 2.52566e-05 -1.77009e-05 9.70199e-06 -2.14681e-05 7.96665e-06 5.46924e-05 -1.13436e-05 3.12284e-06 0.000131504 2.38948e-05 4.34059e-05 -7.37173e-06 3.02843e-05 5.08298e-06 -3.03121e-05 -1.39785e-05 -1.01364e-05 -4.28384e-05 2.46153e-05 -2.81611e-05 -8.38479e-05 -1.5111e-05 1.78353e-05 -4.09139e-05 -2.5997e-06 8.36288e-06 2.38132e-06 -1.28145e-05 1.24376e-05 -1.54093e-05 1.24417e-05 -3.8482e-05 -1.45101e-05 -1.12116e-05 -2.82753e-05 -5.57504e-05 -2.39054e-05 -2.01245e-05 -1.06515e-05 2.43056e-05 2.41971e-05 1.23355e-06 7.89871e-06 -3.94892e-05 4.57994e-05 1.51772e-05 8.4279e-08 2.94183e-05 2.1185e-06 -1.88971e-05 3.35163e-05 -2.32576e-05 2.33143e-05 -2.32875e-05 8.8921e-06 5.70959e-05 -3.29906e-05 6.23005e-06 9.42623e-05 1.48398e-05 2.63019e-05 1.8846e-05 3.22583e-06 -6.59272e-06 -1.93258e-05 3.10174e-06 -1.6264e-05 -3.95717e-05 1.92431e-05 -2.28621e-05 -7.38062e-05 3.42448e-06 1.94408e-05 -2.7988e-05 8.34486e-06 7.01353e-06 7.26668e-06 2.66862e-06 -9.09246e-06 -6.18759e-06 3.16014e-07 -1.30687e-05 -3.29794e-06 -2.357e-05 -1.45049e-05 -3.76577e-05 -2.31198e-05 -1.47678e-05 -1.12243e-05 2.34917e-05 4.39814e-05 -6.03628e-06 2.43525e-06 -3.69885e-05 5.20451e-05 -6.95304e-05 -1.42735e-05 -5.80406e-05 1.08826e-05 0.000102246 -1.35751e-05 0.000103777 -0.000101269 -1.33186e-05 0.000126705 -4.16768e-05 4.92067e-05 2.37915e-05 -0.000139018 -1.97575e-05 4.09772e-07 -4.7597e-05 -3.73911e-05 0.000133344 -6.85746e-06 -0.00014983 3.75108e-05 2.73465e-05 -7.09974e-05 4.11366e-05 -4.92423e-05 -1.70613e-05 -3.33589e-05 -2.73779e-05 -5.31966e-05 9.53332e-05 3.78442e-05 1.99138e-05 3.95718e-05 7.51968e-05 -1.20984e-05 0.000111436 1.83315e-05 -2.15253e-05 -1.437e-05 1.82671e-05 4.12187e-05 6.01066e-05 -3.45522e-05 1.07099e-05 -4.19894e-05 4.32045e-05 -6.81508e-05 -1.24756e-05 -6.56949e-05 1.46074e-05 1.01973e-05 5.30898e-05 -7.71149e-06 -2.75384e-05 6.16261e-05 -5.92153e-05 1.60843e-05 -5.38694e-05 -1.53373e-05 0.000128556 -4.13292e-05 9.07065e-06 0.000223028 2.85516e-05 6.78282e-05 -5.35509e-06 3.09465e-05 -1.05483e-05 -5.47015e-05 1.22826e-05 -1.95995e-05 -7.12969e-05 6.05471e-05 -4.14995e-05 -0.000142017 -1.71811e-05 2.4287e-05 -6.17919e-05 7.90332e-07 3.56435e-05 3.50259e-06 1.00788e-05 2.22437e-06 -1.3577e-05 1.15724e-05 -4.52137e-05 -2.55489e-05 -4.43251e-05 -5.9304e-05 -9.29627e-05 -5.88081e-05 -4.28141e-06 -2.67734e-05 5.40994e-05 9.06922e-05 -5.29528e-06 1.98062e-05 -5.89032e-05 0.000100016\nweightContainer_hidden_0_0_to_hidden_0_0_delay_-1_plasticities 10000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\nweightContainer_hidden_0_0_to_hidden_0_0_delay_-1_weights 10000 0.0225559 -0.0834278 0.074425 -0.0665444 0.0390622 -0.0930986 -0.0312984 0.0716682 0.0652826 -0.0432128 -0.032084 -0.00340282 -0.0233996 0.059465 0.0672438 0.0699626 0.0371355 -0.0848568 -0.0245627 0.0953146 0.0620708 -0.0326974 -0.0181711 0.0200607 0.0428656 -0.0417634 -0.128443 -0.087839 -0.0873404 0.0525392 0.0814224 -0.00250657 -0.102991 0.000692845 0.0310506 0.0847679 -0.0646384 -0.0836361 -0.0978995 -0.117981 -0.00650177 0.01632 0.0664051 0.000841302 0.026553 0.0904983 0.0819325 -0.0225098 0.0761695 0.0723762 -0.0192743 0.00246078 0.00631449 0.0699602 -0.0501134 0.0573235 -0.115921 -0.00907862 -0.0487564 -0.0282942 -0.0385174 -0.0268694 0.0551461 -0.0155797 0.031022 0.0354184 0.0616295 0.0152533 0.0693255 0.040828 0.0885757 -0.0427651 0.0723907 -0.0168034 -0.0713851 -0.0151962 -0.0591876 -0.0977424 -0.0226203 -0.090572 0.0486771 -0.0703777 0.0489453 0.10739 -0.0262975 -0.0404792 -0.00925907 -0.0706976 0.054167 -0.0874241 0.0853732 -0.0327167 -0.0411694 0.040436 0.0477533 -0.0213643 0.0607821 0.0198868 -0.0245706 -0.056593 -0.00144621 0.0955856 -0.0106349 0.0226632 -0.0669201 -0.0905972 0.0664112 0.17334 0.117812 -0.0683726 0.0391128 0.108911 0.144903 -0.0519203 -0.054049 -0.0493519 0.0405721 0.0351337 -0.0860544 -0.0147049 0.0692322 -0.00247423 0.0143611 -0.0173101 -0.0540886 -0.0839737 -0.0146833 -0.244227 0.08607 -0.0778768 -0.108025 -0.0536126 -0.00874333 0.0433998 -0.0301507 -0.0150074 -0.00812568 0.0737225 -0.0699318 -0.0753749 0.054189 -0.0504824 0.155667 -0.000312775 -0.144185 -0.00602161 -0.150663 0.133544 0.0264197 0.0357808 -0.0972003 -0.0456422 0.0853743 -0.085524 0.00129838 0.0528964 -0.0889704 -0.0310013 -0.0476066 -0.00839949 -0.0695024 -0.00241046 -0.0755877 0.0878534 -0.0554496 -0.0787673 -0.0817862 -0.1018 -0.0171671 -0.0185931 0.0175022 0.0501383 -0.0805675 0.0174483 0.0401557 -0.0698294 -0.125563 -0.041307 -0.0551775 -0.0597102 0.00820667 -0.036304 0.0599352 -0.0330933 0.10822 -0.0686297 -0.00021418 0.0306932 -0.00100445 0.057433 -0.038437 -0.0473987 0.000607897 0.027513 -0.053085 -0.039354 0.0112729 0.0325228 0.0680105 -0.0886059 0.0896943 -0.0461663 -0.0404637 0.0288543 0.0874247 0.0229529 0.0923994 -0.0847482 0.0110882 0.112793 0.0127307 -0.00255769 0.0682825 0.0336826 0.0928361 -0.068105 0.0951481 -0.0553415 0.0803153 0.0293406 0.0620497 -0.10151 -0.0778398 -0.0534229 0.0243996 -0.121396 -0.0499124 -0.115897 -0.110849 0.0124666 0.0733544 -0.0679067 0.0915499 -0.0343285 -0.00623861 0.0611073 -0.0726365 -0.0259196 0.0117636 -0.102775 -0.0836776 0.0322497 -0.0280555 -0.0653978 0.0388702 -0.0846668 -0.0911762 -0.055396 0.0479972 0.0951833 -0.0542703 -0.063538 -0.0167043 0.0326976 -0.111045 -0.0471415 -0.0816848 -0.0041394 0.0528552 -0.0334747 -0.0912348 -0.0608362 0.0368161 -0.0431438 -0.0988422 -0.086645 -0.0351745 0.0678832 0.0853085 -0.0243032 0.0659037 -0.0750022 -0.0296681 0.0832162 0.0979451 -0.0631905 0.0432224 0.0407943 -0.00590802 -0.0706283 -0.0200653 -0.0476 -0.0152914 0.0881371 0.0863316 0.0706511 0.042855 0.0136767 0.0337803 0.0636804 -0.0533139 -0.00663536 -0.0591874 -0.0996075 0.0825125 -0.00950726 0.0222521 -0.0376535 -0.0715288 0.0511697 -0.0515156 -0.0179974 -0.0957016 -0.117857 -0.0420829 0.0666225 0.00197125 -0.0301522 -0.0315318 -0.00711852 -0.0927452 -0.00360615 0.00511427 0.0131701 -0.0755343 0.107903 0.152196 -0.0379494 -0.221199 -0.0240562 0.0459175 0.0415356 -0.169429 -0.0146591 -0.0804656 -0.0487458 -0.0881813 -0.0373449 -0.180076 0.0345995 -0.0932572 0.0550739 0.00312234 0.0798554 -0.107625 -0.0440581 -0.182602 0.0318425 0.0565794 0.0752204 -0.0383331 -0.0758832 -0.00472496 0.0505995 -0.0589545 0.0352904 -0.0176178 0.149355 0.0496379 0.0183766 0.0477121 -0.0381241 -0.0420753 0.0414008 0.0548123 -0.137254 0.0323832 -0.113038 0.022986 -0.0883728 0.0338721 0.049683 -0.111895 0.0861598 0.0103317 0.00847486 0.0672484 0.061383 -0.0525601 -0.0476424 -0.0407407 0.0683191 0.0045812 -0.00349195 0.0469951 0.0187869 -0.0621464 -0.00774324 -0.0679422 -0.0972243 0.034835 -0.135087 -0.0828717 0.0712822 0.0479155 0.0604312 -0.0657241 0.170918 0.0442724 -0.0813633 0.0867228 -0.0637734 -0.118138 0.0260605 0.113952 0.0188158 0.0803886 -0.0415656 -0.109229 0.0333877 -0.0551596 -0.0344247 -0.122201 0.0224667 0.0938467 0.0117199 -0.0374013 0.16671 0.155006 0.100832 -0.106742 0.0090645 -0.17326 -0.071016 0.0760887 0.0996136 0.101035 -0.0505442 -0.116349 -0.0281245 0.087401 -0.0430033 0.0293739 -0.104939 -0.0273954 -0.148078 -0.0688562 -0.0682807 0.14922 0.291358 -0.182828 0.0523283 -0.0134317 0.223801 0.0668564 0.0383693 -0.133664 0.149402 -0.0386767 -0.242649 0.0718326 -0.154678 0.108826 -0.0503838 -0.0355565 0.057873 -0.0554315 -0.101681 -0.0661704 -0.0624139 -0.0637751 0.0374887 -0.0814188 0.0962322 0.13636 -0.206978 -0.0888249 0.206944 0.0921264 0.153668 -0.0463519 0.0782229 -0.208512 -0.134557 0.181684 -0.237157 0.00423228 -0.125516 -0.00696799 -0.0679303 -0.0407429 0.141795 -0.125846 0.0689487 0.140001 0.0832676 -0.0371733 -0.101374 0.124865 0.00781553 -0.239967 -0.0388628 -0.102467 0.133505 0.111898 -0.129352 -0.139731 0.0640514 0.031486 -0.160425 0.0288676 -0.0758886 0.0459359 -0.161279 -0.0353332 -0.00558501 0.100305 -0.0305539 0.0766795 -0.0585858 -0.0307512 0.0269536 0.0161426 0.0574823 -0.142476 0.232828 -0.0773038 -0.256514 -0.0613669 -0.0266868 0.158829 -0.196261 0.243027 0.0889655 -0.410823 0.105787 -0.0392743 -0.0247819 0.305263 -0.0689563 -0.196513 0.015182 0.0527517 0.315433 -0.0988594 -0.0999348 -0.073497 -0.0204339 -0.209181 -0.0125981 0.283755 -0.126382 0.0201421 0.00374731 -0.0722963 -0.0748289 0.0979533 -0.304587 0.0218755 0.140393 -0.219376 0.0112896 -0.0248639 0.0813686 0.0519464 0.0765595 0.107289 -0.166626 0.153474 -0.223888 -0.0559903 0.0915512 -0.0835337 0.148642 0.134682 -0.0756729 0.0438894 0.0892607 0.0137364 0.0359545 0.000109005 0.0698972 -0.222031 -0.0456165 0.0201275 0.0842448 -0.101295 -0.146429 0.171509 -0.0533956 -0.0384996 -0.0457724 0.0525022 -0.0207979 0.0926667 -0.157874 0.0289664 -0.0377934 -0.0456519 0.181707 0.039754 0.0710901 0.0667784 0.178874 -0.066584 -0.0714827 -0.123404 -0.0217982 -0.11251 -0.2304 0.0216472 -0.135976 -0.0140503 -0.1361 0.0825956 -0.102648 0.0952593 0.0622051 0.108821 -0.117802 0.0414339 -0.132686 0.04561 0.0956872 -0.01848 0.112791 0.0500763 -0.0943362 0.167875 -0.103801 0.0494839 -0.119537 0.0993541 -0.0889589 0.0170325 -0.000695475 -0.0355416 0.0428184 0.0309751 -0.0494222 0.0634932 -0.185283 0.0405514 0.0235994 0.0344139 0.121177 0.0502695 0.0914826 0.0142998 0.00260332 0.0365394 0.0875643 -0.176546 -0.145116 0.0629972 -0.0492806 -0.0376404 0.0402906 0.0162241 0.0916654 -0.120773 -0.0697554 0.00382228 0.0375895 0.113725 0.10503 -0.0418801 0.0663869 0.0102507 0.0213373 0.0631052 0.0169462 -0.00673753 -0.00682506 -0.033714 -0.0802541 0.0552409 0.107695 0.105124 -0.0292883 -0.0699177 0.110428 0.045032 -0.114503 0.0283493 -0.0102115 -0.0460593 -0.0535283 0.0756041 0.0629215 -0.0398346 -0.0965432 0.118406 -0.0164436 -2.17103e-05 0.134217 0.109096 -0.117105 -0.154383 -0.102808 0.0665562 0.0356235 -0.102096 0.00367701 -0.0790902 0.0745591 0.0572153 0.192001 0.0930538 0.010363 -0.0090896 -0.0522286 0.0141689 -0.0279156 -0.0997941 -0.0742814 0.15954 0.0486407 0.00531171 0.0259459 0.0210692 0.0538037 -0.000942563 -0.262646 0.122613 -0.138612 -0.215146 0.266424 0.0216659 0.0844176 0.0281371 0.0728627 -0.149924 0.0212907 0.149599 -0.0865264 -0.365446 -0.114167 -0.0273151 -0.0927532 0.0157149 0.0984064 0.0545818 -0.0207693 0.0430084 0.0987858 -0.0587363 0.090881 0.460215 0.0109917 -0.080789 0.0293679 -0.394209 0.0339463 0.178517 -0.0259172 0.0594595 -0.111778 0.0348441 -0.251182 0.124681 -0.0192038 -0.0266 0.00664767 0.111203 0.0157075 -0.0881086 -0.215244 0.0883453 -0.0601349 -0.0760366 -0.0769217 0.0124876 0.0655715 -0.0363111 0.0101537 -0.151028 0.0546058 0.0515461 -0.0697585 -0.0477335 -0.0112409 0.0926283 0.00998641 0.0734658 -0.0379235 0.0286179 -0.0100413 0.0336184 -0.031437 -0.0494182 -0.0925607 0.0755105 0.0376272 -0.0162302 0.0600381 0.00741478 -0.0271921 -0.238643 -0.0960489 0.0447607 0.0318979 -0.0656715 -0.00332372 -0.000527756 -0.0323549 0.129081 0.0687356 -0.0547247 -0.0316321 0.022404 -0.00184703 0.0628296 0.0964838 0.0399955 0.0168549 -0.0384122 0.0183099 0.0198439 0.0701291 -0.0663372 -0.00946628 0.153248 -0.0803005 -0.0161353 -0.138037 -0.0806587 -0.0849793 -0.111583 -0.0590482 -0.0159801 0.027477 0.0826132 0.16945 -0.108779 -0.0704421 -0.0243743 0.117535 0.0569838 0.015461 0.184541 0.056398 0.110965 0.23908 0.0389221 0.00357745 -0.022593 -0.114845 0.0747135 0.0327388 -0.0225259 -0.0454644 0.0931793 -0.160058 0.059292 -0.0651308 0.138859 0.0810553 -0.131213 0.033089 0.00794119 0.037553 0.0332789 -0.0309187 0.0167584 0.102805 -0.00551495 0.158089 -0.0423091 -0.0302643 -0.0710645 -0.0757942 -0.0511589 -0.114908 0.151156 0.114487 -0.171808 0.0198058 -0.0198176 -0.220074 0.0480179 -0.000307668 -0.0743223 0.267207 0.073492 -0.0430634 0.103564 0.168485 -0.116063 0.0821628 0.134912 0.0474068 0.0677532 0.296471 0.1047 0.0568023 0.107236 -0.0619522 0.0412599 0.168605 -0.0974431 -0.0222112 0.0692466 -0.215993 0.033214 0.203632 -0.0219112 -0.192686 -0.0547422 -0.0319674 -0.0839585 0.0820985 0.0902876 0.0863166 -0.00261925 0.11111 -0.1276 0.128865 0.00327978 -0.0299774 -0.229476 -0.0746146 0.0938986 -0.00601632 0.268962 0.10968 0.0285828 -0.141574 -0.00554248 0.176466 -0.151229 -0.0195917 -0.181274 0.0180406 -0.0500427 -0.0129466 -0.159055 -0.183823 -0.149747 -0.00118917 -0.259298 0.0699463 0.108305 -0.120453 0.226347 -0.456246 0.0249588 0.222162 0.180395 0.0439628 -0.0283877 0.190332 -0.082147 0.0623309 0.375195 0.0237049 0.248243 0.144943 -0.0254376 -0.0273415 0.0783653 0.0318528 -0.199098 -0.0466393 0.151248 -0.00480484 0.107006 -0.166243 0.0706829 -0.428421 -0.0285147 -0.0852053 0.0848495 -0.0541942 -0.0610098 0.00582213 -0.131287 -0.100738 -0.052288 -0.218755 0.127877 0.0722714 -0.0412132 0.102117 -0.11046 -0.15404 0.0431363 -0.01969 -0.136115 0.065429 0.212519 0.126728 -0.0407296 0.308748 0.0168266 0.141193 0.0424618 0.00869889 0.0123388 0.119093 -5.17082e-05 -0.071438 -0.0015355 -0.255008 -0.0863692 0.111821 0.0230629 -0.0384772 -0.0915264 0.0233537 0.0839539 0.0443871 0.0575737 0.0880874 0.132984 -0.0210701 -0.00224915 0.0638907 0.00934875 -0.0123486 0.0608242 0.123704 0.021731 -0.284657 0.0461343 0.0898078 -0.014752 -0.163654 0.0960011 0.0436185 -0.232335 -0.0764332 0.145291 0.0364674 0.138827 0.128576 0.130732 -0.180847 -0.0663263 0.0212074 0.0626746 0.0831375 -0.149592 -0.0826684 0.0789937 -0.338194 0.0593712 0.0918723 0.114596 -0.28993 0.222493 -0.0871773 0.0129937 0.117361 0.146577 -0.0640117 -0.0304068 0.292708 0.0949907 -0.265053 0.35367 -0.178519 -0.0547755 -0.0330856 0.161677 0.0729662 0.092226 -0.0270949 -0.0423384 -0.271642 -0.121046 0.113762 -0.172637 0.0378492 0.387603 -0.16393 -0.378288 0.312177 0.211481 0.0966079 0.0147554 -0.111043 -0.300007 0.354339 -0.0242722 0.00581122 -0.261791 -0.100939 -0.0626664 0.043094 0.152686 0.0368626 -0.121973 0.0139292 0.287902 -0.00626178 -0.0371036 0.174512 0.451781 0.131574 -0.390478 -0.19975 -0.249386 0.31769 0.360486 0.0400791 -0.0470985 -0.134178 -0.0267013 -0.352182 -0.161211 0.147505 -0.0482762 0.0176707 0.130421 -0.126298 0.124415 0.139938 0.21575 -0.120872 -0.227038 -0.000221393 0.440876 0.0557476 -0.0985377 0.184579 -0.131449 -0.382474 -0.47894 0.126341 0.795666 -0.50071 0.294733 0.666437 0.119083 0.276591 -0.200589 0.206846 0.225127 -0.253542 -0.341272 -0.469657 -0.316138 0.376408 -0.39762 -0.957246 -0.300206 0.0722174 -0.658568 0.553233 0.386965 0.116291 0.293966 -0.111295 0.134951 0.350213 0.0703597 -0.487298 -0.48262 -0.227083 -0.572245 0.152783 0.0356146 -0.194354 0.659588 0.601235 -0.216895 0.290698 0.210585 0.222588 0.17881 -0.0644158 0.0190038 0.251437 0.155572 -0.250527 0.162068 -0.00983851 0.06523 0.143702 -0.177142 -0.181307 0.052931 0.53403 0.104133 -0.0675727 -0.0656783 -0.139921 -0.139719 0.0128851 0.0171275 -0.137403 0.393946 -0.135657 0.158236 -0.174072 -0.130811 0.0337868 0.153276 0.014793 -0.344288 0.0561006 -0.696717 0.363872 0.222811 0.155725 -0.360842 0.00786254 0.0327737 -0.161416 0.143139 0.132403 -0.166483 -0.0715202 0.257303 -0.0203341 0.219274 0.016331 0.220496 0.126908 0.0362358 -0.0460337 0.00788762 0.0450866 -0.0207731 0.119289 0.146078 -0.0813135 -0.0340319 -0.0752625 0.0463327 -0.0216293 0.0981194 0.074133 -0.036203 0.12987 0.0197003 0.0451561 0.0167589 0.122602 0.0313193 0.0471919 -0.0518988 0.0617049 -0.0923218 -0.125252 -0.0474757 -0.0538396 -0.0412657 -0.00677445 0.00664687 -0.0151709 0.0660873 0.0057746 -0.0669237 -0.0571354 0.0148141 -0.0553458 -0.0237498 0.0813175 -0.112942 -0.0722139 0.108488 -0.0436871 -0.00899112 0.0125104 -0.00420743 -0.0824601 -0.0149692 -0.0443743 0.0178737 -0.0108101 -0.00443378 -0.0115478 -0.0305833 -0.0638423 0.00839289 0.031425 0.0687215 0.0516734 -0.113032 0.0261829 0.0231924 0.0222469 0.010898 0.0573968 -0.0774943 0.0243819 -0.0717332 -0.0510219 -0.11233 0.0241285 -0.0395361 -0.116272 0.051247 0.00186886 0.140815 -0.0322275 0.0253629 -0.0643931 -0.118764 0.0637549 -0.0473133 0.00263862 0.106968 0.0412805 0.134282 -0.067881 0.0196571 -0.0146352 -0.0453542 0.0840814 0.0333041 0.038283 0.00965624 -0.0771132 -0.0669334 -0.0119719 0.0688867 -0.0768234 -0.0653682 -0.147494 -0.0461344 0.260666 0.0530371 0.0604321 0.0813161 0.0330039 -0.0596974 0.0807001 -0.120932 -0.0255009 0.0526412 -0.273463 0.0298817 -0.094887 0.113355 0.101123 0.0479593 0.112492 -0.165565 -0.0147938 0.155462 -0.11453 -0.0771729 0.0535977 0.093739 0.026167 -0.0727845 0.126543 0.052828 0.180248 -0.0309316 0.176733 0.101542 -0.0536345 0.0830723 0.12838 0.0579676 -0.0547704 0.0791261 0.104352 0.0762147 0.115914 -0.0166327 -0.0921488 -0.112504 0.0150712 -0.159892 -0.101996 0.0286739 0.0690563 0.101393 -0.107072 0.0816845 0.0243264 0.0517614 -0.0878367 0.00596662 0.0207759 -0.210193 -0.00571706 0.00703018 -0.108444 -0.0553119 0.0617895 -0.0967622 -0.0149193 0.0767027 -0.026416 -0.152223 -0.0573211 0.0624795 -0.0842631 -0.00962938 -0.0452435 0.100261 -0.0994503 0.113934 0.0454612 0.0256471 -0.116642 -0.0122179 0.0584408 0.13132 -0.0266012 -0.00439076 -0.0882843 0.00706615 0.0303411 -0.00237889 -0.0228107 0.0402323 0.120983 -0.0610805 0.0304656 -0.0211942 -0.137649 -0.0341322 -0.00300559 -0.0577401 0.0504402 -0.0224978 -0.108863 -0.120217 -0.111754 -0.10929 -0.00181541 0.00900673 0.0376632 -0.0513273 0.0721853 0.00620672 0.160626 -0.042768 0.03365 0.0252542 -0.0191588 -0.112571 0.0420388 -0.101721 -0.124765 -0.00931446 -0.0814377 0.0143328 0.124621 0.0609083 -0.0654533 -0.06485 -0.0402986 -0.0586811 -0.0933334 0.0929507 0.0279256 -0.0595865 -0.0287275 -0.0589449 -0.0772701 0.0196837 -0.0514534 -0.00279817 -0.0843971 -0.0378871 0.0351689 0.0423357 0.0259507 -0.0906054 0.0503451 0.0794232 0.116328 -0.0202132 0.130412 0.00345852 -0.0824822 0.0372667 -0.279099 -0.262586 -0.0195019 0.281984 -0.0794313 -0.0390719 0.179887 -0.260791 -0.0170302 0.0159802 -0.0483273 0.00689396 0.0795776 -0.058341 0.0428239 0.0147975 -0.0289376 0.014583 -0.00321427 0.187541 0.199909 0.155806 -0.054856 0.270811 -0.0877174 -0.0914755 -0.107115 -0.0367664 -0.0421752 -0.10228 0.105654 -0.0301954 0.0766125 0.0171391 -0.0376684 0.0901678 -0.0711664 -0.15209 -0.0513925 0.0306796 0.0801738 -0.00622782 0.160307 -0.0507721 -0.16011 -0.0587559 0.122965 -0.136258 -0.395479 0.0486671 -0.062891 -0.373491 0.244108 0.333686 0.149687 -0.15743 0.0672478 -0.445534 0.100147 0.278824 0.149092 -0.267806 -0.132318 -0.0696039 0.0416772 -0.0619127 -0.0661323 -0.124443 -0.244732 0.266811 -0.302555 0.368853 0.0249066 0.452628 0.218366 -0.0952989 0.107959 -0.0784074 0.168314 -0.012654 -0.00859513 0.210616 0.225977 -0.335122 -0.110681 -0.0113063 -0.275962 -0.15503 0.0747187 0.0685278 0.295621 0.0394735 0.206119 0.0971091 0.127949 0.0265083 0.067926 -0.0419337 -0.0670205 0.0286206 -0.176064 -0.0938827 0.0293676 0.128743 -0.110233 -0.161084 0.111599 -0.0670273 0.110634 0.0787887 -0.152722 0.00124008 -0.0251625 -0.179648 0.02798 0.0122425 -0.0368546 -0.0400183 -0.00596326 -0.0052632 -0.0118226 -0.048028 -0.00386447 0.0728785 -0.021555 -0.0827767 -0.0181424 0.168531 0.03089 0.0689467 0.0034752 -0.0983271 -0.00288939 -0.0794833 -0.122439 0.122202 0.0221366 -0.0438863 -0.130289 -0.059328 -0.00957422 0.0590521 0.00302806 0.0876558 -0.155738 -0.137515 -0.0428468 0.0025112 0.0513144 -0.114856 0.00984866 0.0770487 -0.0516899 0.00130607 -0.0594796 -0.200688 -0.0461537 0.00178487 0.0187368 -0.0607223 0.0227804 0.0722518 -0.0186254 -0.0993941 0.0446379 -0.209524 0.075506 -0.106424 0.0697603 -0.0105218 -0.118047 0.096357 0.0607021 -0.0984051 0.0541504 0.0531922 -0.0250464 0.129932 0.111753 -0.0453865 -0.0486882 0.134354 0.193761 0.102108 0.131676 0.153886 -0.0806421 -0.10216 0.162266 0.0753637 -0.147265 0.016921 -0.083779 0.0427887 -0.0541174 -0.0494104 0.00437658 -0.0563142 0.0356936 -0.0219131 -0.0608615 0.0195301 0.117398 0.08469 0.0998479 -0.0717583 -0.0860619 0.0308005 -0.0853515 0.0622796 0.00157009 0.0173876 -0.10811 -0.141722 0.0619668 0.0584986 0.0746851 0.012365 -0.213675 0.140345 -0.101484 0.00539599 0.0467686 0.00657335 0.155604 -0.122094 -0.0248689 -0.0203471 0.186182 0.0815926 0.158921 -0.114823 0.284661 -0.0684989 0.0619063 0.0957074 -0.128417 -0.0860986 0.0317424 0.0512534 0.00506691 -0.00281445 0.0627478 0.0532419 0.0579155 0.0216229 0.0314477 -0.0461603 -0.11247 -0.168022 -0.0967315 0.116519 0.145851 -0.130278 -0.0227623 -0.227901 0.156482 -0.278297 -0.274541 -0.180478 0.158878 0.0255689 0.130859 0.0437257 0.328471 0.0821736 -0.108651 0.177224 -0.0583749 0.097005 0.0792727 0.301682 -0.0335332 0.066262 0.218504 -0.299938 0.0430682 -0.214591 -0.128717 -0.182967 -0.0558904 0.116951 0.0481144 -0.137522 0.0685007 0.103637 -0.0465801 0.0838619 0.306108 -0.126563 0.128801 -0.180387 0.169513 -0.00276409 0.151864 -0.168592 0.055574 0.00810353 0.109745 -0.0863801 0.0284094 0.126906 0.0514177 0.0208531 0.10549 -0.0232633 -0.000111431 0.0637887 -0.163986 0.0675514 -0.047365 0.162892 0.00616905 -0.104681 -0.0234667 -0.0485302 -0.0719692 -0.029303 -0.0452699 0.0672023 -0.0738171 -0.0592046 0.00877504 -0.0960639 -0.0153916 -0.0620192 0.0321488 -0.0521208 -0.00815894 0.0134589 0.00308953 0.015498 0.0631957 0.012617 0.0992892 0.0102633 -0.127141 -0.0343411 0.0611012 0.0517544 -0.00768593 0.0139787 0.0383223 0.0285016 -0.0896721 -0.0312413 0.0591928 -0.0154728 -0.0904479 -0.190637 -0.0425781 -0.0522118 0.123824 0.00506423 0.0225552 0.0971006 0.0502881 0.0866277 0.227375 -0.0842618 -0.0886323 -0.00343725 -0.020397 -0.024129 -0.0918417 0.144889 0.0521524 -0.124264 0.143229 0.107163 0.142731 -0.0164289 -0.155848 -0.027035 0.00163632 -0.00295949 -0.0414405 -0.00446661 -0.0616246 0.00781846 0.0444876 0.0518891 0.0268738 0.0490019 0.0052068 -0.145498 -0.0161346 0.0113497 0.0500101 0.0752772 0.0528135 -0.105184 0.111497 0.0573313 -0.0132733 0.140839 0.0736711 0.0697517 -0.0692621 -0.163372 -0.00284996 -0.101707 -0.0647676 0.00234366 -0.0588077 -0.0405965 0.0603901 0.00478522 0.156996 -0.121063 -0.0612902 0.095476 0.0198467 0.0787077 0.14051 0.158739 0.0397739 -0.110028 0.0434777 -0.0397474 0.156987 -0.020232 -0.122616 -0.0537159 0.0163745 0.0910267 0.0189302 0.0585046 -0.200071 -0.167584 0.126878 0.0640361 0.0434492 0.135692 0.131151 0.115466 0.138371 0.150215 0.109601 0.0534305 -0.0846108 -0.0723201 0.071153 0.0218644 -0.0391426 -0.0401761 -0.0383078 0.0153915 0.275781 0.118296 0.013516 -0.0318111 0.118944 -0.0788634 0.185848 -0.211092 -0.0410423 -0.162981 -0.0718108 0.0562123 0.00495615 -0.161056 -0.219598 0.100195 -0.165994 -0.224093 -0.0797765 0.0961149 -0.373985 0.110355 -0.295233 0.134082 0.34588 0.162148 0.0601226 -0.0263055 0.101126 -0.114139 0.371621 0.21858 0.0256294 -0.0892305 -0.00427938 0.201951 0.0926605 0.0759727 0.211518 -0.160312 -0.0666 0.232491 0.0323483 0.430213 -0.0990442 -0.0858519 0.0885112 0.0892017 0.0747918 0.0102874 -0.0156371 -0.125773 -0.0195977 -0.195492 0.0420991 -0.028728 0.039219 0.167608 0.00899125 0.0149798 0.18548 -0.139358 -0.000755041 0.0580631 0.105441 0.051605 -0.0486001 -0.0378208 -0.120161 -0.101462 0.203369 -0.0610169 0.1424 0.0741876 -0.118242 -0.126281 0.166487 0.112931 0.00385381 0.0167204 -0.0872284 -0.0280746 0.119532 0.0233607 -0.00738418 0.0607864 -0.0408491 -0.084393 0.0838368 0.00979514 0.0742726 0.119478 0.0326908 -0.0858477 0.145494 -0.034123 -0.0550072 -0.013509 0.0622947 -0.0181884 0.0497557 -0.150536 0.189618 0.0437046 -0.0658824 0.0373698 -0.0324622 -0.142468 -0.0232374 0.0556315 -0.0563363 -0.232494 0.0595413 0.10526 0.0458921 0.0346522 -0.0324541 -0.137979 -0.117969 -0.0761513 -0.0987735 -0.0152991 -0.0949111 0.0734524 0.0069767 -0.187848 0.100121 0.046117 -0.0402105 0.0988317 0.131902 0.0576434 -0.0211162 0.134174 0.0789648 0.172763 -0.111851 0.0894288 0.0861796 0.172179 0.116564 0.245133 -0.0213267 0.0246208 -0.0776205 -0.178147 -0.0550329 0.0686357 0.0812525 -0.0737915 0.0126149 0.0531137 -0.245729 0.0325997 0.0913756 0.0857469 0.171143 -0.361252 -0.0535379 -0.0240519 -0.00947136 0.0880425 0.0341178 -0.159063 -0.0354812 0.191967 0.0384402 -0.143084 -0.0896873 0.00487393 -0.263687 0.131537 0.0345986 0.172242 -0.166313 0.257943 0.113924 -0.143228 -0.0534317 0.0578986 0.232513 0.138836 0.0888322 0.0487582 0.147695 0.104933 0.114046 0.0535523 0.0751774 0.0641379 0.0339131 -0.103559 0.125564 0.0984372 -0.265983 -0.0155781 -0.00181045 -0.01799 0.00434719 0.139516 0.0650253 0.0408237 0.209094 -0.327855 0.198045 -0.284044 0.115767 0.347635 -0.0787429 -0.295481 0.543785 0.103458 0.200056 -0.165342 0.142399 -0.0840974 -0.191135 0.614243 -0.153678 -0.11901 0.192443 0.170447 -0.512084 -0.180475 0.173858 0.0964875 0.252671 -0.0456495 0.0338928 -0.0363676 0.0894621 -0.0328376 0.0977813 -0.183061 -0.339528 -0.379203 -0.0546789 -0.451001 -0.132378 -0.0319487 0.0132161 0.153846 0.145479 0.0304704 0.24801 0.265903 0.193105 0.120028 0.00253845 0.0423582 -0.209992 -0.0124837 -0.00517895 0.232418 -0.0501618 0.217926 -0.154233 -0.379729 -0.0701316 0.10941 -0.136544 -0.195424 0.141471 -0.0881616 0.121145 0.250322 0.18215 -0.414803 0.114778 0.0207809 -0.212483 0.172716 -0.173541 0.37122 -0.329713 -0.00613568 -0.0890092 0.151885 0.0852415 0.0455268 -0.0571654 -0.0665315 0.0177476 0.308055 -0.2698 0.219065 0.173723 -0.0842391 0.0849212 0.114961 0.306042 0.0608654 -0.107096 0.107053 -0.159378 -0.0223825 -0.0976262 -0.107547 -0.00115634 0.0616492 0.0523871 0.117898 -0.0333532 -0.0419907 -0.0589592 0.0373136 -0.0910495 -0.0887972 0.0233576 -0.148932 -0.0364523 0.0609766 0.0309982 0.0210435 -0.115045 -0.0169646 0.0284228 -0.0326051 -0.0205705 -0.156207 -0.0279263 0.14903 -0.00611927 -0.0450058 -0.00148063 0.0170261 0.0248791 -0.120821 0.0597642 0.000911023 0.229736 0.0147088 -0.0317092 0.0297634 -0.0946419 -0.0534624 0.0670659 -0.0861664 0.0488408 0.105124 -0.0841511 -0.0990926 0.0729263 -0.0690575 0.00602481 -0.0238438 -0.110618 0.00814094 0.085875 0.0274634 -0.0510032 0.0353729 -0.0231166 -0.107601 -0.0303378 0.0442966 0.0426301 -0.0743007 0.136763 -0.148618 -0.0492663 -0.0206904 -0.0553688 0.141697 -0.0231704 -0.0298672 0.108636 0.19205 0.0575862 -0.108471 -0.0134308 0.0669115 0.0266727 -0.0203531 -0.0407184 0.142425 -0.0728708 -0.208163 -0.116109 -0.0999293 0.0288319 0.0319433 -0.0942295 -0.0382471 -0.0175728 0.0545713 -0.144612 0.0406902 -0.0597588 -0.00621942 -0.0605834 -0.101927 0.0632213 -0.127553 0.016669 -0.00913432 -0.134273 0.131404 -0.0208481 -0.193382 -0.121981 0.0661991 -0.109049 -0.0378357 0.0585929 0.0792029 -0.0263756 -0.245304 0.161872 -0.140941 -0.0603649 0.161681 -0.34125 0.0179176 -0.0361997 -0.323006 0.0461627 0.220533 -0.00980775 0.0523809 -0.142201 0.207178 0.235513 -0.0465623 0.032497 -0.068087 0.0055175 -0.149961 -0.0319354 0.143881 -0.145569 -0.0314563 0.0848285 0.119583 0.17891 0.0125725 0.0622705 0.0680556 -0.0177214 -0.106181 -0.208875 -0.149653 -0.165903 -0.0378626 0.0434891 0.0873838 0.10094 -0.0561427 0.0183295 -0.0156952 0.0576485 -0.00558096 -0.0068706 -0.145573 0.0130163 -0.202642 -0.0154053 0.0363295 0.00257545 -0.064872 0.164456 -0.00448367 0.106549 0.0372343 -0.221475 -0.0966503 0.0578069 0.107598 -0.0694679 -0.144104 0.0151995 0.091413 -0.257959 0.0279335 -0.10809 0.15704 0.106992 0.0376708 -0.0880873 0.117361 0.126284 -0.0811904 0.0204573 0.0581358 0.019257 -0.120181 -0.140173 -0.0601189 -0.093511 0.0180074 -0.0745539 0.0515532 0.111997 -0.16436 0.0244277 -0.000252055 -0.0832975 0.0150349 0.0232091 0.253932 -0.0501886 -0.0771338 0.00706967 0.0845696 -0.324707 -0.0715598 -0.350973 -0.0569704 -0.169432 -0.0238685 0.269978 -0.0359782 0.0818053 -0.0591928 -0.0744371 -0.0187622 0.119179 -0.115399 0.267324 -0.124444 0.239179 0.0364286 -0.515475 -0.28108 0.0480291 -0.102539 0.0140012 0.166728 0.15013 -0.13753 -0.0269624 -0.0429127 -0.312157 0.0547201 -0.161309 0.134023 -0.0110382 0.267152 0.316255 -0.0446013 -0.018126 0.017729 0.0121554 -0.121181 -0.197451 0.0632411 0.048276 -0.0779833 -0.00846231 -0.266271 -0.048697 0.119883 -0.25189 0.0735092 0.252682 0.206995 0.0404021 -0.082991 0.0641098 -0.603639 0.00235876 0.0470217 -0.159156 -0.0671075 -0.0296664 -0.257323 0.06866 0.145386 0.0621663 0.0166946 -0.0758052 0.272792 0.244366 0.157059 -0.0747901 0.114771 0.0468677 -0.270828 -0.132211 -0.154795 -0.10301 -0.0965573 0.0740206 0.0126953 -0.0352657 -0.132304 0.174455 0.0437746 -0.112285 -0.0612181 0.0912767 -0.287882 0.00110061 0.182242 0.0153346 0.0490634 -0.0745801 -0.279177 -0.0181728 0.0367365 0.107864 0.188837 0.412325 -0.233153 -0.0349652 -0.162252 0.1413 0.557691 -0.0856507 0.771742 -0.0234968 0.274701 0.0399431 0.0651164 -0.118721 0.0022977 -0.190743 0.289588 -0.156718 -0.0844113 0.112947 -0.176741 -0.473871 -0.359687 0.0145464 -0.273322 0.38959 0.079434 0.0809957 0.0405909 0.0198203 -0.085399 -0.0426398 -0.0512631 -0.133114 -0.270281 -0.540944 -0.260347 -0.0286519 -0.201027 -0.360808 0.479403 0.371766 0.0133953 0.324567 0.204725 0.162981 0.206236 -0.0283153 -0.20557 -0.027016 0.0857045 -0.208064 -0.216125 0.219884 -0.0072968 0.0760694 -0.266222 0.0105601 -0.18564 -0.28627 0.106256 -0.205734 0.215185 -0.299435 0.0288552 -0.0651548 0.252956 0.163942 -0.249497 0.000719055 0.250757 -0.0238725 0.0581321 0.110419 0.361104 0.0452978 -0.330583 -0.164465 -0.0353701 -0.06941 0.0292395 0.133494 -0.119793 0.427192 -0.130925 -0.196075 0.141463 -0.141619 -0.0920065 -0.0382031 -0.014695 -0.0350728 0.139408 0.123936 -0.0604933 -0.0372924 0.249302 0.0360275 -0.0730581 -0.0014631 -0.517574 0.226907 -0.0347045 -0.515181 0.0599535 -0.604099 0.0757385 0.151857 0.0948191 -0.38536 -0.474127 -0.535824 0.368248 0.284419 -0.0820914 0.179509 -0.00793595 0.676815 -0.219914 0.205298 0.00156668 0.0630627 -0.173289 -0.0440801 -0.266441 -0.246513 -0.0827833 -0.19328 0.0669683 -0.42346 -0.109498 -0.315693 -0.208888 0.0618727 0.401485 0.290784 0.428511 0.356606 0.511368 0.156976 -0.175746 -0.236872 0.481227 0.244135 -0.370369 -0.0588719 0.129043 -0.243649 -0.61571 0.277633 0.116895 -0.0656274 0.0292381 0.537326 0.303983 0.0667828 -0.38266 0.394192 -0.434646 -0.870265 0.0113421 -0.590139 -0.0564464 -0.0448822 0.00452621 -0.0013558 -0.312282 0.416999 0.0337872 -0.533032 0.10868 0.478837 0.539329 -0.672978 0.472522 -0.277439 -0.31178 -0.0627171 0.199281 0.0176377 0.259017 -0.410846 0.145243 0.266602 0.188511 0.0987224 0.158833 -0.010692 0.187868 0.148763 -0.491014 -0.672244 0.626513 0.0512532 -0.628652 -0.383248 -0.352213 -0.14875 0.127202 -0.111127 -0.0331688 0.636979 -0.110896 0.411162 -0.182743 0.582462 0.667025 -0.380111 0.0868744 -0.552562 0.386327 0.564691 -0.447868 -0.117619 -0.0466493 -0.224414 0.329071 -0.807517 -0.0301216 0.124854 -0.432271 -1.02058 -0.0847213 0.334423 -0.167145 0.567987 0.547013 0.086891 0.146712 0.246062 -0.149439 0.458346 -0.00833917 -0.197608 -0.374314 -0.680737 -0.80273 -0.371172 -0.472908 -0.615392 0.834749 0.629269 -0.339398 -0.0530538 0.5649 0.470884 -0.0105076 -0.151179 0.0684144 0.29041 -0.206448 0.561593 0.5671 -0.301252 0.0800996 0.226724 -0.185701 -0.198632 0.410714 -0.729089 -0.289485 -0.22315 0.0243673 0.39531 0.587798 0.086181 -0.373529 -0.2065 0.695042 -0.798663 0.0970971 -0.0185565 0.470698 -0.435211 -0.0597532 0.0318634 0.254509 0.217595 0.325146 0.114056 0.181061 -0.0384322 0.360087 0.0842089 0.264229 0.328357 0.425192 0.264116 0.380952 0.243893 -0.0403147 -0.0516265 0.271995 -0.182546 -0.333318 -0.274542 0.0260572 0.0729651 -0.127758 -0.0304936 -0.0666121 -0.167625 -0.13429 -0.0960357 0.0261247 -0.180226 -0.0381835 0.00727938 0.00228508 0.269001 0.127949 0.0658395 0.139627 0.0206838 0.0205178 -0.00910397 0.0767261 0.0554548 0.0409828 0.0563862 0.0654757 -0.00253827 -0.0396943 -0.140258 0.00340365 -0.0215488 0.0641142 -0.1185 0.0966902 -0.0616214 -0.0754234 0.0715277 0.0416091 0.0543326 0.00195841 -0.00137021 -0.020071 -0.00151477 -0.0755361 0.0128905 0.0750545 -0.0906916 -0.0361396 0.12708 0.0339287 0.0629176 -0.0459105 0.051392 -0.0883728 0.0294115 -0.134694 0.0522158 -0.067232 0.0211783 -0.051055 -0.0449494 -0.0509788 0.0315663 0.0323705 0.0964807 0.09418 0.0511834 0.0136998 0.0155723 0.0891021 -0.0222454 -0.0541347 0.00325233 0.0339637 -0.0562447 0.023867 -0.0481187 0.121177 -0.043365 0.14851 0.164237 0.0152995 -0.0305923 0.142773 -0.121204 0.0513969 -0.0277039 -0.0118904 0.0774934 0.0350593 -0.0327942 0.155108 -0.032616 0.106804 0.150575 0.0447129 0.0732615 -0.0548081 0.0570573 0.0657552 0.0411815 -0.0609155 -0.0274382 -0.184403 0.0894899 0.222613 -0.000598107 -0.0950622 -0.027867 0.0671643 0.251342 -0.0253139 -0.00465791 -0.151384 0.0573348 0.11687 0.0114902 0.0367856 -0.0743112 -0.133717 -0.179327 -0.130729 0.068703 0.0457956 -0.187678 0.00318627 -0.131055 -0.0311807 0.253453 0.00506676 0.104513 -0.0559343 0.0164203 0.117131 0.0937615 0.0830025 0.0509967 -0.0648195 0.114485 -0.00646818 -0.173459 -0.028777 -0.121384 -0.0923967 -0.158973 0.145977 -0.0690019 0.244427 -0.0553334 0.227979 0.0371914 -0.0642471 0.0503896 0.0104237 0.0601098 -0.174471 -0.150447 -0.136025 -0.18109 0.0624095 -0.204863 0.0499892 0.0068855 0.0499395 0.184038 0.129622 -0.0328746 0.112414 0.0758942 0.0432595 0.126189 0.118962 0.0363167 -0.0338937 0.0516219 -0.026814 0.0385465 0.0171413 -0.0658591 -0.0365425 0.0690431 -0.0884248 -0.0870367 -0.0800765 -0.160321 -0.0974364 0.0302193 -0.113006 -0.029596 0.106981 0.0562732 0.131098 0.0553539 -0.0142125 -0.0219836 0.0691879 -0.0156153 -0.0466291 0.0755294 0.0554611 0.0211093 -0.0539065 -0.0730231 0.119644 0.00024197 0.158401 -0.161714 -0.100069 0.141483 -0.0804851 0.0783088 -0.0603194 -0.137801 -0.0290126 0.00963043 0.0283291 0.00147452 0.0932043 -0.0820044 -0.144531 0.0106633 -0.0577699 -0.102478 -0.0711715 0.0896663 0.148304 -0.0508219 -0.110218 -0.0764508 0.0951547 0.0114364 -0.292771 0.0222123 -0.11171 0.152924 0.0710531 0.0802185 -0.172371 0.00292263 -0.0188054 -0.253026 0.101254 0.0547944 -0.0305518 -0.0170823 0.0219536 -0.038918 -0.0970854 -0.0814108 0.049858 -0.107362 -0.0171749 0.0706307 -0.183099 0.0175287 -0.0374491 -0.217445 -0.127113 0.0497958 0.11309 -0.0151149 0.0279583 0.092408 -0.0742246 -0.021154 0.0573534 0.0915905 -0.0713246 0.029291 -0.137061 -0.016568 0.135007 0.0502658 0.0251958 0.0687815 0.08298 0.255085 0.0691042 -0.164069 0.188324 0.0658562 -0.179249 -0.0545169 0.0166984 -0.039511 -0.0921373 0.0327868 -0.123748 -0.0807686 0.0203413 -0.170008 -0.0379554 -0.00282535 -0.0507883 0.0944856 -0.150936 -0.138731 -0.0230321 -0.00634533 0.03212 -0.0139862 0.0645869 -0.0648941 -0.122395 0.0482804 -0.0626769 0.55485 0.0416626 -0.0815131 -0.112904 0.152026 -0.0440378 0.0961862 0.0627347 -0.120422 -0.0412009 0.0795481 -0.102507 -0.0169318 0.0705564 -0.0410316 -0.485446 -0.149297 -0.0172996 -0.25759 -0.110254 -0.421199 0.190977 0.182787 -0.314869 0.0974036 0.176047 0.044126 0.165497 0.137627 0.0459661 0.0952281 0.302031 -0.331811 0.238583 0.0764899 -0.226069 -0.117443 0.337868 0.0965911 0.419926 -0.148379 0.269849 -0.0784054 -0.238689 0.0923343 0.135901 -0.0848268 -0.0908422 0.065617 0.0772915 0.000130333 -0.0362408 0.216675 -0.0952513 0.0946475 0.0661848 -0.0366271 -0.074597 0.0763248 0.0106413 -0.0317314 0.104996 -0.0431466 -0.138542 -0.00754052 0.266311 -0.14978 -0.0821173 0.192545 0.177773 -0.159098 0.000256834 -0.12045 0.0830382 0.219729 -0.281956 -0.0919906 -0.172651 0.146573 -0.0613336 0.0595537 -0.080972 0.0270849 -0.00354529 -0.366079 -0.0709429 0.0631113 0.0121906 -0.152888 0.0112183 0.126344 -0.0310441 0.188518 0.194582 -0.058614 0.0541133 0.0569898 0.0510475 0.0911803 0.0476278 0.104184 0.0458322 0.0386119 -0.121988 -0.099599 0.146236 -0.0463278 -0.0378929 0.148601 -0.0309548 -0.076369 0.00666738 0.11205 0.0543753 -0.161391 -0.00475848 -0.0387852 0.0577411 0.247937 -0.0704853 -0.0288065 0.0498372 -0.0556437 -0.00230436 -0.0183832 0.0240361 -0.107073 -0.016009 -0.111787 0.0922439 0.036879 -0.174 0.0541763 -0.161254 -0.0393716 -0.0815869 -0.0379049 0.0463167 -0.127537 0.0686927 0.00888112 -0.0905957 0.00909658 0.0777024 -0.00103774 -0.0818224 -0.0638718 0.105948 0.064653 -0.258888 0.0341175 -0.109436 0.0312709 0.0472716 -0.100427 0.0888017 0.0429908 0.00337546 0.067018 -0.00593358 -0.0715138 0.0791384 0.169452 -0.0189701 0.0178391 0.0708108 -0.0257953 0.0431379 0.212171 0.0120126 0.192613 -0.0307502 0.0306791 -0.051259 0.00367182 -0.082069 -0.0360204 -0.0271234 -0.184071 0.00162957 -0.00440962 -0.0485027 0.0424302 -0.0542261 0.0410995 -0.0268945 0.0744759 0.124895 -0.00659533 -0.0122389 0.106065 -0.00517194 0.0754256 -0.0102824 0.0434542 0.0314925 -0.0960779 -0.115813 -0.0531375 -0.181593 -0.0294978 -0.129274 -0.0155849 -0.220955 0.0271734 0.077606 0.0611792 0.143902 -0.0800223 -0.010617 -0.0962171 0.090394 -0.0309611 -0.176077 -0.136316 0.28574 0.0709219 0.0533569 0.139075 -0.19008 0.0199514 -0.00646877 0.0836452 0.0344433 -0.0131106 -0.126285 -0.0509713 -0.0158919 -0.24069 -0.153081 -0.0701199 -0.187155 0.193822 -0.234169 -0.16431 0.144188 -0.0905528 -0.00878951 -0.031693 0.00653839 0.150112 -0.15552 0.145522 -0.00299942 0.143276 -0.101548 0.086618 0.153546 -0.0620444 -0.145889 -0.089181 -0.0825684 0.0444279 -0.0663393 -0.180904 0.116361 -0.130034 0.12057 0.0516095 -0.140271 0.0189152 -0.0159256 0.105427 0.135654 0.112447 0.0332846 -0.00592114 0.0408678 0.141468 -0.0340469 0.0870967 0.030699 0.032125 -0.0222262 0.110704 -0.05909 -0.123325 -0.0658034 -0.195371 -0.0100206 0.0253442 0.0695545 0.0840033 -0.141156 -0.115307 0.00375094 0.0094032 0.0790252 -0.0324317 -0.0268667 0.100036 0.0507566 0.180478 0.0394361 0.109164 0.14248 0.104183 -0.0589042 -0.18091 -0.070941 0.00470207 0.029949 0.0172561 -0.0117568 0.0429155 -0.112595 0.0707159 0.0155774 0.0139606 -0.105889 0.0271292 -0.0239009 -0.107268 -0.0600894 -0.0187403 0.034291 -0.0523297 0.0131697 0.118502 0.126936 0.0433326 0.0398049 -0.0459931 -0.0281949 -0.110061 -0.0503213 -0.113773 -0.129087 0.00480633 -0.00960563 0.0407206 -0.079855 -0.0625346 -0.0427101 0.0640015 0.00570077 0.0473526 -0.0566421 -0.0624687 -0.0659263 0.0394966 -0.0500998 0.0706881 0.0798548 -0.00111206 -0.0102227 0.00587318 -0.090134 -0.0838902 -0.131793 0.0545046 -0.0190777 -0.189881 -0.059611 -0.0406859 -0.0491499 -0.0428906 0.0115725 -0.00944542 0.0518223 0.0360752 0.00464838 -0.0653478 0.0654726 0.0487151 0.15787 -0.0321699 -0.0721909 0.0340359 -0.0882922 0.0305511 -0.0373516 -0.0500817 -0.156775 -0.106752 0.0678135 -0.0711136 -0.0956449 0.0353445 -0.00139485 0.113489 -0.0893311 0.0870011 -0.0502837 -0.098801 0.0237992 -0.0715332 -0.0981253 -0.0375269 -0.0225687 -0.0656865 -0.0419919 -0.0117286 -0.0887932 0.0597801 0.0842643 -0.0028788 0.0505633 0.163815 -0.284348 0.0712354 0.0137491 -0.21016 0.0179859 -0.106877 0.232696 -0.116444 -0.101187 -0.0436242 -0.130194 0.105458 -0.0503805 0.156029 0.0356539 0.0997699 0.0556814 -0.207578 0.00312049 0.082424 0.118789 0.155672 -0.0739407 0.120517 -0.153967 0.164664 0.0609555 0.0165421 -0.128248 -0.0921161 -0.339014 0.00521269 -0.0598536 -0.376273 0.152429 0.219133 -0.256646 0.152685 0.147279 0.0761276 -0.180575 -0.0400983 -0.209941 0.0459301 0.0166386 0.0111198 0.0262283 -0.100331 0.0891219 -0.0873216 -0.0807579 0.0719847 -0.0866527 -0.158076 -0.103152 -0.0665983 -0.0767871 -0.023462 -0.0487501 -0.0318702 -0.0335148 0.0645397 0.105537 -0.0141673 -0.0953382 0.0760122 -0.0323926 0.100005 -0.0732822 0.113218 -0.00899565 -0.0184694 -0.10925 -0.019741 -0.0887836 -0.016798 -0.00198384 -0.0670181 -0.128177 -0.0685043 -0.137866 0.0896355 -0.0959262 -0.060203 -0.0469226 -0.0542753 0.0542035 -0.0818764 -0.182596 -0.0268116 -0.0199609 -0.0331591 0.0478181 0.173669 0.0126663 0.0625991 -0.0223764 -0.057111 -0.055999 0.0119644 0.0665332 -0.0535354 -0.035097 0.0311034 0.0177449 0.0670773 0.156392 -0.0398525 -0.0559925 -0.0186572 -0.0264617 -0.0559897 0.0647477 -0.0148408 -0.135273 0.0657288 0.167498 -0.14728 0.0453733 0.0631911 8.26149e-05 -0.0201963 0.0551231 -0.01263 0.0785214 0.144323 -0.157376 -0.0438573 -0.0878586 0.0335374 -0.0674568 0.0918257 0.0750625 0.122849 0.0516652 -0.103941 -0.0873784 -0.0495308 0.0611236 0.0487279 0.148402 0.0442216 -0.0013193 0.091423 0.00431542 -0.0904891 0.030776 0.0132887 -0.0427633 0.175839 0.134668 -0.00486272 0.0157378 0.137418 0.167227 -0.0523212 0.160568 0.0112978 -0.103835 0.100791 0.12457 -0.207713 -0.134566 0.0144343 -0.191776 -0.0926485 0.00383363 -0.131114 -0.101647 0.156337 0.0376633 0.132439 0.115295 0.0231507 0.055533 0.0418899 -0.120626 -0.0659861 0.0336112 -0.0440109 -0.0478732 -0.00938933 -0.118661 -0.126833 -0.0504266 -0.11694 -0.0547605 0.0521914 -0.0632325 -0.109323 -0.0247294 -0.121473 -0.0702963 -0.00358818 0.0622774 -0.183509 -0.00828263 -0.158527 0.03485 0.179092 -0.080111 0.0122208 0.12823 -0.147885 -0.0493934 -0.0376124 0.144831 -0.19094 0.171306 0.00333661 -0.150284 0.0419071 -0.115253 0.0195947 0.158405 -0.0784261 -0.245335 0.217936 0.109443 -0.0852311 -0.0707288 0.18952 0.0376668 -0.189012 -0.0124321 -0.0366742 0.230418 -0.127078 0.0922257 0.0260401 0.0463696 -0.126468 -0.0102262 -0.171889 0.036839 0.132088 0.163919 0.140016 0.19489 0.108563 0.0578559 -0.130987 0.227507 -0.187933 -0.176112 -0.0506967 0.0378561 0.105777 0.0662986 0.0992952 0.104076 -0.147019 -0.165892 0.114498 0.0841702 -0.0797851 0.128896 0.156387 0.0217051 0.187629 0.0373545 -0.15142 -0.13787 -0.0412597 -0.0215204 0.0301253 0.202367 -0.0108128 -0.0909873 0.0117714 -0.0685439 0.0499815 0.101431 0.0369632 0.202182 0.146336 -0.12116 -0.0782515 -0.0846522 0.0666001 0.0113655 -0.0716639 0.00402791 0.00627195 -0.10764 -0.165623 -9.5641e-05 -0.217787 0.0509665 0.0220376 -0.0357085 -0.0759704 -0.153628 0.0455821 0.0813483 -0.0768874 0.0227549 -0.0181426 -0.025045 -0.113107 -0.206337 0.0593259 -0.139067 -0.166282 -0.0850962 0.0473894 -0.046605 -0.0971228 -0.117213 0.042737 -0.112991 -0.0573659 0.0838575 0.0718031 -0.10614 -0.0351648 -0.0728097 -0.0563291 -0.0746857 0.0324464 -0.0352445 -0.00595984 -0.027024 -0.0836836 -0.0602997 0.127378 0.0745006 -0.0342232 0.0784397 -0.0373289 -0.0324618 -0.0572336 -0.126211 -0.0188811 0.0322521 0.159723 -0.0397018 0.0664092 0.0754695 0.0602695 0.0967839 0.147891 -0.12265 0.060511 0.0252399 0.0126004 0.127748 -0.000330938 0.00667894 0.0353996 -0.0925919 -0.067255 -0.0931198 0.160279 0.0678901 0.0252938 -0.178119 0.0144598 -0.043025 0.0574733 0.000186267 -0.123289 -0.00386903 0.0426295 0.0758428 0.102624 -0.139041 -0.0381949 0.0243351 -0.021731 0.0176204 0.123795 -0.0509073 -0.139328 -0.0249352 -0.077681 -0.104408 -0.0487684 0.0988045 -0.120563 -0.0155694 -0.0327504 0.0261973 -0.102908 0.187495 0.223559 0.0616036 0.0791603 0.0221417 0.182823 0.0196371 0.0528702 0.037053 -0.0129981 0.0327219 -0.136052 0.0777652 0.0805051 -0.0631927 -0.156958 -0.153434 -0.100085 0.197625 -0.0431586 0.17549 -0.0054333 -0.327877 0.13361 0.14703 -0.0666467 -0.180593 -0.00962111 0.156387 -0.0702089 -0.275614 0.117844 -0.0586362 0.034863 0.0562407 0.154007 0.0831657 0.269893 0.300077 -0.14648 0.0646504 0.301018 -0.145694 -0.0991234 -0.11602 -0.115083 -0.15061 0.0373782 -0.0233359 0.00427875 0.0927737 0.110792 0.082019 0.14801 -0.02022 0.26397 -0.235932 -0.118631 -0.173612 0.178213 0.0249816 -0.122218 -0.071003 0.139349 -0.00533753 -0.0218031 -0.205903 0.0337964 0.0560189 0.140434 -0.0276297 -0.0319141 -0.0103323 0.0135054 -0.0567239 0.371746 -0.198314 -0.0949214 0.160432 0.10086 -0.00300069 0.0287675 0.0984896 -0.00664335 0.0150926 0.0568818 -0.104586 -0.0562356 -0.00646174 0.0445531 -0.130784 0.149624 0.0300799 -0.173307 0.142463 -0.0839648 -0.260468 0.120441 -0.0972632 -0.130965 0.110105 0.277831 -0.148307 0.171983 0.0828265 0.0906912 0.0913021 -0.0440591 -0.234799 -0.0619487 0.0535734 -0.0939784 0.0551908 0.0320818 -0.0410745 -0.0698979 0.0496215 -0.00729328 0.0849305 0.0661737 0.0322428 -0.130814 0.057394 -0.0114716 0.103604 0.0872557 -0.0913145 0.0559422 0.00522052 0.0482179 0.00134834 -0.00950982 -0.0557623 -0.0747752 -0.0466781 0.112852 0.169884 0.00345385 0.0951205 -0.0356814 -0.00800131 -0.014323 -0.0815211 0.0703496 0.0189507 -0.0866715 0.130088 -0.0628694 -0.0767306 0.0697864 -0.0640442 -0.0238303 -0.0633137 -0.0331158 -0.0428687 -0.0245807 0.0272509 0.0739446 -0.171073 0.101162 0.176953 0.123801 -0.0381061 0.0335156 -0.0496188 -0.0392005 0.169313 -0.014512 0.00242616 0.167509 0.218932 -0.131779 0.167882 0.0411728 0.0281387 0.0748322 0.0589531 -0.137215 0.0316996 0.0369107 -0.170603 -0.0885698 -0.0573879 -0.0282702 -0.0873698 0.12123 -0.00508393 0.107954 -0.0839987 0.0932091 0.114211 0.0417569 -0.136911 -0.0198496 -0.0458466 -0.0852073 0.0946373 -0.102153 -0.0754491 0.00850011 -0.0246476 0.00387533 -0.150304 -0.00894447 0.0512854 0.000803436 0.0109857 -0.121708 0.0270844 -0.0080712 0.0586091 -0.000219072 0.117426 -0.0103735 -0.0216829 -0.0869975 -0.0297285 -0.415317 -0.316257 0.234482 0.0802669 -0.190306 -0.0504125 0.212234 -0.121167 -0.00759835 0.0540431 0.0401992 0.0390398 -0.0286428 -0.211521 0.15676 0.109961 0.00303335 -0.017668 0.0472225 0.27225 0.161723 -0.119456 0.130136 0.0884632 -0.0634966 -0.0734683 -0.011659 -0.10088 -0.219762 -0.235699 0.0198189 0.000329748 0.260126 -0.0710988 -0.208559 0.221267 -0.0689275 -0.245509 -0.0609967 0.0378821 0.238071 -0.0427391 0.238578 -0.0465881 0.204597 0.0876925 0.0897589 -0.0309803 -0.0188588 0.166404 -0.0594063 -0.0932331 0.202812 0.161609 -0.0623485 0.0943465 0.0669606 -0.0576965 0.109751 -0.0158391 -0.101601 -0.0762911 -0.0754423 -0.137787 0.0661221 -0.0328896 -0.121111 -0.179491 0.00112341 0.151153 -0.0549749 0.17236 0.0080807 0.160105 0.0286745 -0.167003 0.0508326 0.0451523 0.0154299 -0.0474958 0.126275 -0.017356 -0.0341259 -0.0480204 -0.104584 -0.0496857 0.00923185 -0.109446 0.0938787 -0.00643035 -0.0118361 -0.127123 0.067915 0.120329 -0.0608125 0.08913 -0.101545 -0.00817918 -0.0920343 -0.00109386 -0.0421743 -0.165029 0.0923862 0.0987069 0.094103 0.0590666 -0.11853 0.0336641 0.023 0.0616117 -0.0134789 -0.0512224 -0.0334314 0.0869345 -0.128736 0.167866 -0.0733749 -0.0557867 0.16403 0.134564 0.127336 0.0742612 0.0126513 -0.0585566 0.172422 -0.0664867 0.00229096 -0.070076 0.0221719 -0.0760447 0.0901856 -0.119435 -0.0938508 -0.00104039 -0.019119 0.0854495 -0.123329 0.0149242 -0.029531 -0.00440053 0.00396666 0.0680107 -0.0536722 -0.0254647 0.00544501 -0.0165311 0.071334 0.00791537 -0.0163788 -0.0138602 -0.121925 0.00959846 0.0533931 0.0519576 -0.0193048 0.0239257 0.0879859 0.028319 0.00230181 0.0209614 -0.0167713 0.0376022 -0.0725612 0.02658 -0.104531 0.0967973 0.0245572 0.0232312 -0.0179512 -0.0286572 0.0817869 -0.0413206 0.113204 -0.00344138 -0.100203 -0.279834 0.0837395 -0.121088 0.0853552 -0.0967642 -0.094632 -0.0939199 -0.0409039 -0.0552802 -0.0332297 0.0384666 -0.0630742 -0.000715625 -0.00163675 -0.0389109 0.0843633 0.166475 0.0980146 0.084045 0.0276562 0.104562 0.0467382 0.0682937 -0.0128994 -0.167041 -0.369282 0.0601264 0.0566078 0.0724199 -0.105255 -0.106512 -0.16586 0.222475 0.184555 -0.0134801 -0.105921 -0.0188201 0.098637 0.0347706 -0.0688311 0.0256209 -0.0988419 -0.134404 0.188749 -0.0774154 -0.143794 0.00243056 -0.283483 0.0173619 -0.251413 -0.15709 0.0537285 -0.0815009 0.143772 0.0477255 -0.177111 -0.278969 -0.0829726 -0.0549622 -0.129905 0.0685785 -0.00710021 -0.0152198 -0.177022 -0.114979 -0.0239969 -0.329635 0.157272 0.0588555 -0.120895 -0.0437808 0.0403449 -0.0123932 0.0752695 0.102663 -0.0145164 -0.0244921 0.0953155 -0.00491083 0.13517 -0.0522751 -0.0714745 -0.0968799 -0.0264105 0.0443911 -0.0340823 -0.136721 -0.0661116 -0.0211591 0.00924317 0.0810832 0.0826517 0.0485873 0.010632 -0.0549632 -0.0599152 -0.184627 -0.0347435 0.0529729 -0.0289354 -0.174074 0.134699 -0.0855159 0.193773 -0.0972331 0.0732255 -0.00512302 -0.0765008 -0.0962919 -0.0353175 0.105443 -0.105594 0.0668657 -0.0218021 -0.00974661 -0.0138604 0.0365459 0.0078876 0.124591 0.135733 0.224396 -0.144312 -0.0832486 -0.0612453 -0.135186 -0.428277 0.191399 -0.035593 0.188198 -0.163181 -0.295671 0.0961293 -0.0186302 -0.347025 -0.220154 -0.160502 -0.0895552 0.150945 0.0435263 0.209022 -0.0438256 0.217461 0.280909 -0.0134506 0.275733 0.687004 0.0921724 -0.151173 0.113589 -0.296465 -0.0674658 0.0438151 0.0658242 -0.181695 0.218896 -0.269454 0.236423 0.139338 0.11292 0.254909 0.303566 0.0147936 0.0659998 0.207395 -0.17402 -0.249001 0.351552 -0.0659695 -0.224417 -0.156246 0.0299456 -0.143753 -0.14276 0.413153 0.0948229 -0.237135 0.175873 0.0932324 0.220663 0.0662547 -0.0686228 0.104288 0.00269622 -0.0209591 -0.189962 -0.179125 0.00768901 0.0659986 0.121345 0.0237372 0.0414935 0.066295 0.334936 -0.315029 0.118581 0.623103 0.116751 0.0493073 0.09865 -0.121267 -0.0613087 0.225853 0.14847 -0.0841265 0.208341 -0.0574156 0.113398 0.0334469 0.0247227 0.119562 0.0588428 -0.0932762 0.0245878 0.18199 -0.0919412 -0.259678 0.175747 0.0450204 -0.144468 -0.0826472 0.122037 -0.425306 -0.265942 0.806822 -0.177679 -0.646395 0.328227 -0.34895 0.179884 -0.172537 -0.270136 0.133153 -0.0159889 0.0998809 -0.151382 -0.523915 0.136086 0.390745 0.178748 0.122719 -0.0642136 0.156039 0.511309 -0.611304 0.466235 1.55359 0.348706 -0.373472 0.566082 -0.19733 -0.137957 -0.0869482 0.0485866 -0.106467 0.141552 -0.0182833 0.0818303 0.245982 0.326126 0.501402 0.222324 0.106952 0.506134 0.37235 -0.119528 -0.328387 0.052047 -0.223087 -0.484317 -0.0329413 -0.0406518 0.0704292 0.0859909 -0.359458 0.11681 0.238896 0.0383146 0.0919998 -0.0166112 -0.0592834 0.2306 -0.0307317 0.031417 0.00679504 0.143059 0.0170435 -0.0598669 0.062508 0.200179 -0.0899821 -0.0164459 -0.0796313 -0.0109306 0.0734416 0.0192424 -0.177094 -0.0881184 0.407835 0.00274624 0.120131 0.216671 -0.165639 0.500208 -0.0181941 -0.0303135 0.133602 0.52236 0.00419628 -0.250363 -0.116657 -0.0834477 -0.0147752 -0.0644091 0.0043017 0.315023 0.192585 -0.196107 0.013461 0.165047 -0.0611616 0.00258179 -0.0916048 0.0904429 0.00655144 -0.0408041 -0.00558115 0.0487306 -0.0544977 0.109801 -0.0406107 0.0452482 0.0612143 0.0812863 -0.154777 -0.108588 -0.0646677 0.122319 -0.0844778 0.0121828 0.0843744 0.136366 0.118199 -0.0422816 0.0117529 -0.0283637 0.073946 -0.0521272 -0.126864 0.0169339 -0.0128603 -0.0567112 -0.0531415 -0.0339507 -0.0432384 -0.0426435 -0.0757574 0.0634145 0.0861028 -0.0592473 0.0372314 -0.0500919 -0.0629336 -0.116274 0.0479781 0.0419006 0.0255364 -0.0496214 -0.0287735 -0.01809 -0.0325578 -0.138666 -0.0355663 0.0863383 0.115243 0.0250321 0.127449 0.0157837 -0.0712159 -0.0128964 -6.29831e-05 0.0925008 -0.0383408 0.0694854 0.140149 0.0265308 0.089116 -0.130677 0.0226716 0.00633239 0.0634939 0.0848563 -0.108259 0.0932704 -0.163619 -0.0912252 -0.0497011 -0.0753667 0.0145409 0.0173656 -0.0101508 0.106658 -0.0442703 -0.0654551 0.114295 0.0871827 0.107349 -0.0622056 -0.105634 -0.10949 -0.0373859 -0.126895 -0.0775199 0.0895741 0.0616688 0.103098 0.102852 0.0208322 -0.0173235 -0.0509502 0.00802431 0.0506277 0.148404 0.0963649 -0.137601 0.00171412 0.0204068 -0.0295608 -0.0107363 -0.0570239 -0.0786009 0.193373 0.0427275 0.197831 0.187174 -0.0492763 0.0806331 -0.03478 0.000404971 -0.16872 -0.0951977 0.324568 -0.10691 -0.145891 0.291013 -0.0817826 0.290838 0.135123 -0.490947 0.0263723 -0.00607891 0.140314 -0.14347 0.102496 -0.0409508 -0.0509172 0.110892 -0.0701533 -0.0963727 -0.115988 -0.266464 -0.196553 -0.0596324 0.0572749 -0.0813118 -0.0445223 0.316911 -0.163776 0.114642 0.27485 0.0933044 0.0474544 -0.0380088 -0.0647832 0.0890944 0.0401383 0.00213829 0.1123 -0.0460914 0.0562092 0.0180487 0.145829 -0.014285 -0.0572274 -0.0656556 -0.0491222 0.115885 0.105861 0.0196146 0.0557831 0.0877911 0.0645837 -0.0192531 0.160577 0.0831608 0.0512138 0.028595 -0.0192218 -0.0725667 -0.0801632 -0.0153171 0.0316277 -0.0670894 -0.0468867 -0.0410763 0.0504355 0.0448659 0.10349 -0.078774 0.00849011 -0.125212 -0.0521107 -0.148869 -0.0686045 0.113948 -0.00646695 0.0991603 -0.119742 0.0951824 0.124248 0.0460645 0.0807699 0.122814 0.0434483 -0.0295529 0.0518233 0.00698732 0.258578 -0.074395 -0.106606 0.0856658 -0.24835 0.0331291 0.158602 -0.140592 0.0596991 0.0386222 -0.0440249 -0.0768994 -0.00513794 0.120407 -0.233311 0.17936 0.0119777 -0.0596343 0.0477189 -0.287546 -0.0817478 0.0818314 -0.0699391 -0.255731 0.0599976 -0.0241107 -0.0651183 -0.0676865 0.00951121 -0.25142 0.00537509 -0.00725901 0.171156 0.235878 0.346131 0.151532 -0.115495 -0.0107732 -0.138679 -0.113033 0.059888 -0.228589 -0.015662 -0.040268 0.132104 0.0900305 -0.189937 0.0666652 -0.0124248 -0.221125 0.0214709 0.0185378 0.133954 -0.0618049 -0.178656 0.101269 -0.181865 -0.147365 -0.00390798 -0.242187 -0.0353943 -0.164743 -0.214606 0.0232207 0.148708 0.0314574 -0.105394 -0.0726775 0.18799 0.0295973 -0.0676214 0.102011 0.0174259 -0.0189357 -0.10832 -0.0200582 -0.0478568 -0.0239375 -0.000336214 0.0318726 -0.0353997 -0.00201887 0.204993 0.136887 0.0698995 0.142013 -0.00443925 0.0111821 -0.222583 -0.0782357 0.199006 0.0445668 -0.033366 0.0781097 0.166636 0.0124987 -0.0544299 -0.0252264 0.0871256 -0.482893 0.332149 -0.237765 0.278919 -0.393636 -0.524193 0.285637 0.0787929 -0.401396 -0.105842 -0.286107 -0.0457287 0.0552488 -0.100013 0.144559 0.0339117 0.14373 0.126044 0.0454934 0.527577 0.534745 0.00878306 0.0840567 -0.0260505 -0.213764 -0.0478203 -0.000324541 -0.143572 -0.173282 0.000238654 -0.312924 -0.0218379 0.0325404 0.0563688 0.331349 0.271496 0.111092 0.00168633 0.0327075 -0.487918 -0.0207199 0.305598 -0.229189 0.114374 -0.0608406 0.0763959 -0.0389271 -0.0926733 -0.0789701 -0.0764587 -0.0246105 0.00915825 0.0540965 0.0747981 0.0318933 0.0102355 0.165355 -0.318151 0.110159 0.11611 -0.0993355 -0.00379803 2.15161e-05 -0.0694131 0.0404464 0.111494 0.0568305 -0.098875 -0.0297444 0.102361 -0.201992 0.0962703 0.029078 0.00932816 0.148643 -0.077413 -0.15801 0.0600764 -0.0659885 -0.0328672 0.170811 -0.0731981 0.112561 0.0829766 0.0118813 0.0693345 -0.146998 -0.10214 -0.0619491 -0.0195115 0.0516637 -0.0188541 0.134143 0.144882 0.111157 -0.159312 -0.130153 -0.143192 0.242709 0.345204 -0.0752804 0.399197 -0.119521 -0.0221427 0.582884 -0.580021 0.102926 -0.747535 -0.594902 0.242478 0.116403 0.19535 -0.577114 -0.190568 -0.0684914 0.0383096 -0.218435 0.0890778 -0.459972 0.536088 -0.544846 0.271779 0.353448 0.312972 0.229165 -0.0988539 -0.121197 -0.352736 0.243286 0.242472 0.279174 -0.0430411 0.700657 0.322701 -0.20081 0.842724 -0.390354 -0.164224 -0.148184 0.199632 -0.00552685 1.17223 0.0885598 0.043887 -0.0168104 -0.182444 -0.168442 -0.299299 0.117878 0.163712 -0.308824 -0.112791 0.153494 0.22088 0.118306 0.006111 0.277361 -1.65857 -0.10094 0.165007 -0.468164 -0.137047 0.0456827 0.00782772 0.201077 0.425472 -0.210086 0.244227 0.0233531 0.982372 0.248952 0.591456 -0.119226 0.564849 0.48348 -0.342415 0.120764 0.0812444 -0.0264322 -0.406525 0.276574 0.0161415 0.0364011 -0.11263 -0.132324 -0.196437 -0.321016 -0.282647 0.045018 -0.199728 -0.0712222 0.902763 -0.278272 -0.128252 -0.233022 0.350146 0.0642622 -0.751587 -0.121215 0.123376 -0.698813 0.237073 0.186025 0.525012 -0.320743 -0.655549 0.579618 -0.408811 -0.761642 0.06896 -0.507002 0.39951 -0.0938892 -0.330329 0.479769 0.396088 0.525842 0.0588857 -0.262914 0.00245793 0.17586 0.54332 -0.221008 0.327783 -0.774132 -0.396309 -0.0107386 -0.242206 -0.00101837 -0.353233 -0.370201 -0.183254 0.66803 0.310824 0.282421 0.612195 -0.122776 0.0241601 0.225354 -0.676572 -0.409827 0.0991413 0.172977 -0.245337 -0.088682 -0.194777 -0.0777902 -0.0194521 0.148548 -0.176299 0.220056 -0.0552805 -0.0287006 -0.119395 0.0170077 0.20219 0.178425 -0.413368 0.422442 0.0019308 -0.098025 0.0726176 0.295076 0.106982 0.119041 0.230569 -0.46471 0.179725 0.191733 0.555452 0.637805 -0.0372624 -0.496028 -0.00425939 0.661957 -0.0702814 -0.00744365 0.0233242 0.0370397 -0.399033 0.100343 -0.0953372 -0.299677 -0.0927 -0.112353 -0.536802 -0.106363 -0.184117 -0.114728 0.391069 -0.0242633 0.0991141 -0.0157649 -0.171543 -0.131802 -0.101075 -0.0432565 -0.0990532 -0.0641121 -0.208902 0.101996 0.0575599 0.0514927 0.0169289 -0.0452404 0.100942 0.107723 -0.190924 -0.0455197 -0.143977 -0.0266816 0.07414 -0.0662767 -0.0631994 0.163869 0.0616196 -0.0228587 -0.103025 -0.00634982 0.0496446 -0.00833104 -0.00391257 -0.0547138 -0.0532725 0.134694 0.0655862 0.0338149 -0.0438202 -0.331554 -0.0676151 -0.0159392 0.0408844 -0.00421335 0.115765 -0.0656247 0.157489 -0.00605611 0.158103 0.0745526 0.0837205 0.00210858 -0.0286283 0.0431352 -0.175188 0.0347267 -0.015324 0.0315668 0.0475105 0.0610017 -0.0149692 -0.263269 0.226012 -0.029114 0.185314 -0.0329042 -0.0539218 -0.0575115 -0.238606 -0.311209 -0.124075 -0.126172 0.132854 0.133449 0.0378545 0.124818 0.0520501 -0.12399 0.160317 -0.195124 0.0972717 0.282464 -0.0839292 -0.132595 -0.0266898 0.085094 -0.128281 0.068362 -0.0623855 -0.13361 -0.127179 -0.045938 0.110594 0.0578222 0.119261 0.207417 0.14681 -2.77113e-05 0.0104057 0.227297 -0.0171961 -0.0203153 0.0633157 -0.0496122 -0.0384735 -0.0986559 0.0223059 -0.083887 -0.191838 -0.226999 -0.0975454 -0.042734 0.127633 0.212749 0.210274 -0.0856962 -0.119141 0.0982093 -0.0707292 -0.190175 -0.205167 -0.232511 -0.027577 -0.0529134 0.0723042 0.418671 -0.0290775 -0.104368 0.0821678 0.143425 0.0366405 0.513745 0.375526 -0.390009 0.26085 0.333562 -0.11826 -0.0186144 0.199593 -0.0023966 -0.0940348 0.0219657 0.156441 0.0454781 0.0150175 0.160087 0.133278 0.0160712 0.0878969 0.0485335 -0.171146 0.0155892 -0.150953 0.0128486 -0.178595 -0.210297 -0.107232 -0.088043 0.0766925 0.144517 -0.218906 -0.00717943 0.266672 0.0546476 0.0149002 0.0773614 0.0233474 0.0356307 -0.134138 -0.127488 -0.123826 -0.00615785 -0.0592061 0.157499 -0.00440381 0.00901953 -0.0942652 -0.0862943 -0.00385214 0.0338389 -0.00357792 0.0914158 -0.105109 -0.103862 -0.0533277 0.16087 0.0577096 0.00414212 -0.043855 -0.210144 -0.123469 0.114002 0.0976103 0.0791865 0.142704 0.075574 0.0657486 -0.0512837 0.0573381 0.0871337 0.00758187 -0.0121509 0.0501256 -0.0196351 -0.0256652 0.133569 0.113746 -0.0472743 0.0212559 0.0422996 -0.130475 -0.0919828 0.281692 -0.0905204 -0.0398809 -0.0787509 -0.140678 -0.132702 -0.0988451 -0.358695 -0.257994 -0.343814 0.064575 -0.0370384 0.0527425 0.240374 -0.228068 0.21874 0.0457751 0.0321485 0.153407 0.304489 0.0958161 -0.127248 -0.038858 -0.209254 -0.238494 -0.0755181 -0.214004 -0.297421 0.10791 -0.218166 0.0613975 0.0432572 0.319436 0.148008 0.464888 0.468136 0.00606954 0.248886 -0.141318 -0.100656 0.257831 -0.0693424 -0.0984101 -0.0161642 -0.0762711 0.0256932 -0.0679538 -0.0383019 0.042013 -0.0407424 -0.0448644 0.0812813 0.0569629 0.160841 -0.153602 0.115143 -0.0886957 -0.155036 0.0659725 -0.124275 0.00755692 0.0681491 -0.0921661 0.125944 -0.213492 -0.0221049 0.0435361 -0.100335 0.104854 0.129971 0.0538727 0.0245649 -0.0905554 0.0437374 -0.0361647 0.0211203 0.0892313 -0.0451882 -0.0256295 0.0264686 0.0799799 0.00321952 0.103867 0.146798 0.0687762 0.103969 0.124094 0.0608512 -0.00250301 -0.000619322 0.047152 -0.0967294 0.120516 -0.1072 0.227849 -0.00478602 0.411248 -0.108401 -0.230268 0.52363 -0.0778883 -0.130152 -0.199601 -0.0119952 0.177294 0.0853135 -0.0013283 0.74259 -0.145813 -0.0591256 -0.00415996 0.0553091 0.11993 -0.0225923 0.0768579 0.104771 -0.363893 0.299534 0.225059 -1.00301 -0.488354 -1.03025 -0.352598 0.0331832 0.354589 0.0860717 -0.275036 -0.0310748 -0.107369 -0.00162845 -0.311761 -0.231894 -0.0356669 -0.182723 -0.144892 0.251963 0.0972634 -0.22591 0.29883 0.0915037 0.216823 0.244512 0.240198 0.200391 -0.0471338 -0.0459815 0.0557189 -0.255391 -0.103687 0.14607 -0.0181467 -0.176438 0.0329659 -0.0511686 -0.100171 0.0039901 0.0927949 0.120756 -0.122354 -0.00176809 0.0272772 0.0536356 -0.0158553 0.252433 -0.166318 -0.0300557 -0.0348488 0.227282 0.0478966 0.0359438 0.0428668 -0.473212 -0.0647572 0.199222 0.199055 -0.0627412 0.207331 -0.147853 -0.124024 -0.0481617 0.243129 -0.04291 -0.0727091 0.112228 -0.0384079 0.0353933 -0.126565 -0.0299332 0.121295 0.0146286 0.101565 -0.00544405 0.0803006 -0.0751255 -0.0557834 0.1682 -0.0457105 -0.0957495 -0.0173354 -0.029045 0.0958118 0.00368848 0.0128362 0.103531 -0.244261 0.00113693 -0.101996 -0.0646698 -0.0930235 -0.0576519 0.0416904 -0.0122818 0.0299141 0.0457028 -0.117165 0.0341142 -0.00177538 0.0251365 0.168763 0.19755 0.00301584 -0.147009 0.00908408 -0.0479205 0.0407758 -0.00879861 0.0630821 -0.0105583 0.0865418 -0.0197485 0.069348 0.0296526 0.104468 0.161676 0.264543 0.0468094 -0.115959 0.022417 0.00141033 -0.032231 0.189121 -0.173517 0.070044 -0.0508055 -0.0171609 0.0353144 -0.156701 -0.136487 0.104199 -0.234706 -0.16408 0.186112 0.163745 0.0338737 -0.229844 0.234283 -0.387176 -0.0207053 0.0623886 -0.0789909 -0.0405706 -0.178851 -0.0681747 0.0622794 0.188127 -0.119025 -0.0705422 -0.0461539 0.0828408 0.266639 0.069033 0.0493797 0.202492 0.0544917 -0.128521 -0.205715 0.227547 -0.0905082 -0.0552919 -0.0562061 0.121412 0.219886 0.0488695 -0.154682 0.169105 0.0474442 -0.159736 0.05577 -0.0437201 -0.0978751 0.0290318 -0.023313 -0.0812411 0.104108 -0.0709746 0.0768366 -0.265029 -0.250608 0.129857 -0.434957 -0.149993 -0.00930713 0.282115 0.0684907 -0.402369 0.222418 -0.0743815 -0.243661 -0.0199442 0.0536323 -0.228991 -0.280372 -0.215889 0.381396 0.105695 0.237688 0.144485 -0.0477104 0.153286 0.305818 0.344884 -0.276357 0.110503 -0.0334966 -0.18261 -0.0730394 0.0802935 -0.194633 0.241235 -0.144721 0.166567 0.402981 0.164463 -0.0294789 0.323037 -0.0240338 -0.194353 0.0778028 -0.122873 -0.0746425 0.0478128 -0.112875 0.00459276 -0.266938 -0.0614614 -0.0199057 -0.128646 -0.0937145 0.0303094 -0.0233831 -0.0301753 0.116523 0.0612913 -0.0764786 0.0342589 0.0819889 -0.24969 0.31254 0.123659 -0.0267631 0.127027 -0.205278 -0.297571 0.00884569 0.105475 -0.277861 -0.0639424 -0.20553 -0.00694912 0.0315713 -0.0633689 0.28141 -0.111121 0.0525707 -0.0611029 -0.109267 0.104519 -0.00122859 -0.066657 0.133 0.133923 0.0468259 -0.134785 -0.200795 -0.00360537 -0.0835172 -0.32148 -0.033972 0.144532 0.0583421 -0.0513527 0.173686 0.0936309 0.198129 -0.00705312 -0.0498694 -0.0786925 0.0647046 0.0173613 -0.117742 0.152953 -0.0289238 0.070261 -0.00252326 -0.00457267 0.056352 -0.0562164 -0.0438087 -0.0599172 0.0445399 -0.0152416 -0.129612 -0.0484369 0.0258135 0.0609887 0.109252 0.135585 0.00243257 0.0291115 0.128752 0.0240625 -0.0431134 0.140821 0.0396528 -0.0822868 0.0396407 -0.00530653 0.118777 -0.0193619 0.0191379 0.0190762 0.0249416 0.159879 -0.0133894 0.0500737 0.0242061 -0.00159638 -0.100623 -0.128276 0.0751022 0.0753951 0.00225646 0.00024085 -0.00181692 -0.119563 -0.0942157 0.0250345 0.1155 0.163165 -0.0741971 0.00436885 -0.00329877 0.13281 0.11245 0.0114012 0.0464564 -0.00955233 -0.163721 0.0436082 0.0132821 -0.100622 -0.0564159 -0.0690185 -0.0444445 -0.0347574 0.0692243 -0.0644568 0.0579884 0.0801648 0.0183416 -0.0623587 0.100673 -0.0509654 -0.101213 -0.121632 0.0379968 -0.146337 0.0794073 0.114045 0.0387604 -0.0637192 -0.0610688 0.0601459 -0.0637776 0.143861 0.0327855 0.1193 -0.0107124 0.0583667 0.0140536 0.0960681 0.015239 0.0935989 -0.15713 0.022976 -0.101791 -0.20088 0.0978862 0.0727993 0.14459 0.0730286 0.0682701 -0.175925 0.213056 -0.00417943 -0.159057 -0.244068 0.115252 0.075541 0.0437953 0.0539988 -0.155263 0.0199321 -0.0432158 0.0562888 -0.0507444 0.102856 -0.0798246 0.242692 -0.228956 0.177443 -0.0086073 0.174236 0.0328668 -0.22891 0.00902237 0.0411664 -0.113049 0.0874333 0.0160855 -0.087756 0.148944 -0.0864163 -0.152133 -0.0583384 -0.0364503 -0.259283 0.174149 0.166233 0.102158 0.227329 -0.0126502 0.0323745 -0.022577 0.0572231 0.0387903 0.025771 0.121109 -0.00925353 0.0524683 -0.0467125 -0.103691 -0.0405729 0.106103 -0.0795292 -0.051708 -0.0684522 -0.0805708 0.0779856 0.102599 -0.0491144 -0.100536 0.0133751 0.0641287 -0.0671323 -0.0234535 0.00869382 -0.0253607 0.0688331 0.0831109 0.0437582 -0.0514655 -0.00470702 0.0236384 -0.15353 0.182182 -0.130564 0.156629 0.0702415 -0.102376 -0.132561 0.080672 0.129662 -0.0614687 0.0417354 0.0193692 0.0797362 -0.126338 0.044369 -0.122031 0.0450116 -0.0355082 0.0267015 -0.0681621 -0.0478326 0.00153208 -0.10554 -0.00313236 0.145152 -0.191598 0.0366513 0.0668276 0.0432833 0.0246423 -0.144599 0.0336966 -0.112141 0.0302621 0.0848255 0.0247169 0.0552572 -0.155457 -0.05814 0.0868161 0.0867319 0.0229631 -0.111615 -0.236056 0.137112 0.0196668 -0.0626627 0.0581232 0.11629 -0.0665669 -0.17303 -0.0876016 -0.0318693 0.0162063 -0.00301651 -0.0683817 -0.0962163 0.413188 0.0346579 -0.0651759 0.171807 -0.158648 -0.130589 0.0121922 0.0841697 0.0366666 0.117529 0.0289648 0.0789208 0.141178 0.0931054 -0.0360492 -0.161167 0.123205 0.0275036 -0.19487 -0.111838 0.292847 0.134167 -0.0521319 0.0440497 0.224431 -0.407263 0.236671 0.0932283 -0.117348 0.147823 -0.0759699 -0.30478 0.0185838 0.540157 -0.0356686 -0.0574816 0.125119 0.0794125 -0.0736544 -0.0292762 0.198934 0.391403 0.0378328 -0.160906 -0.0458652 -0.158256 0.133827 -0.0441288 0.0898452 -0.201919 0.109474 -0.0169836 -0.259521 -0.149875 -0.237862 -0.117489 -0.0281337 0.0975442 0.0154956 -0.0143717 0.260797 0.139932 0.0448551 -0.213486 0.0128312 0.216867 0.12423 -0.294818 0.342717 -0.0182963 -0.453237 -0.207178 -0.124042 0.460257 -0.111547 0.254345 0.190181 -0.215676 0.0656878 0.0618831 0.137118 0.295823 -0.237185 0.0286801 -0.102302 0.156212 -0.0597932 -0.190727 0.0789076 -0.109033 0.213876 -0.50111 -0.258913 0.26291 0.0640854 0.271828 -0.129814 -0.15052 -0.0252624 0.0827389 -0.186846 0.113896 0.268468 -0.205767 0.113584 0.268351 -0.079011 0.315083 0.127425 0.149216 0.0934499 -0.182079 0.0427633 0.0260012 0.120533 -0.1186 -0.0825931 0.205482 -0.107612 -0.00862829 0.315581 0.0291539 -0.0573297 0.0307609 0.0975398 -0.256756 -0.0122659 0.110386 -0.0402573 -0.0211809 -0.0146099 -0.329868 0.00207895 0.398626 -0.0409176 0.0937287 0.0339443 0.0704538 -0.127989 -0.0805293 0.153485 0.0651222 0.0753531 -0.239779 0.0249604 -0.309946 0.127284 -0.0750141 0.0903949 -0.20919 -0.0145521 -0.138897 -0.0880605 0.036733 -0.225446 -0.210035 -0.252557 0.141073 0.0668155 -0.0134821 0.154301 0.233929 0.199908 -0.0428432 0.0910167 -0.0310736 -0.0609592 -0.0320574 -0.0284472 -0.0538933 -0.0271147 0.146737 -0.0307236 -0.0281841 -0.0280475 -0.00451646 -0.0660752 -0.07914 -0.0184014 -0.038779 -0.115821 -0.00190338 0.00132329 -0.0615793 0.146789 0.051077 0.0605795 0.106996 -0.00540499 -0.00408788 0.13881 -0.050866 -0.0820061 -0.0031115 0.061287 -0.078868 -0.126247 0.0581161 -0.056862 -0.0215878 -0.035816 -0.0925792 -0.108631 -0.0449505 0.0825456 -0.092239 0.0238606 0.0437063 0.0880514 -0.0187492 -0.0400702 0.0628112 0.0359709 0.00419085 0.0835801 -0.063659 -0.0213084 -0.0738589 -0.0532611 0.0340452 0.105486 -0.0278962 -0.0360192 -0.102155 0.133111 -0.0750224 0.0555668 0.0917801 0.106384 0.061057 -0.0624888 -0.0110091 -0.0752682 -0.0134603 0.0405719 0.0161309 -0.0187334 -0.0526708 0.0884086 -0.080495 -0.0470735 -0.073205 -0.0346043 0.0305336 0.0306465 0.121504 -0.051908 -0.028619 0.0705754 0.148158 0.0581305 -0.0600246 0.060913 0.0453244 0.0628571 0.0111776 0.0364076 -0.11282 -0.0976289 -0.0423139 0.0410885 0.0765067 -0.0365822 0.0346358 0.07156 -0.208423 0.202308 0.0467435 0.250125 0.0334153 0.0254021 0.0707383 0.0392837 -0.0616658 0.0188271 -0.0525345 -0.0373431 0.0709321 0.212009 -0.0400631 0.0038253 0.127697 -0.117504 0.00483841 -0.228015 0.202882 -0.274723 0.249848 -0.163327 0.0260811 0.13218 -0.0275962 0.0345189 0.111079 0.0130651 -0.533786 0.0989688 0.0636679 0.0758711 -0.0195579 -0.0315637 0.00568211 0.0284278 -0.113636 -0.0226904 0.0287266 0.0560183 0.0158445 0.0322117 -0.0380981 0.0359573 -0.0184742 0.174221 0.110638 0.0439906 -0.106374 -0.0101683 -0.0829108 -0.200443 -0.145075 -0.0309937 0.00215026 -0.131542 0.0355042 0.104527 -0.0691578 -0.0946658 -0.0417778 0.00337481 -0.0848732 -0.00545733 0.0166572 -0.00625214 0.0169612 0.16757 -0.098795 0.0775762 0.113715 -0.0478573 -0.0208191 0.0865522 0.0435845 -0.133279 -0.0512651 -0.0844801 0.0910199 0.0290888 0.0327786 -0.0469385 -0.0387225 0.0263087 -0.0770189 -0.0198411 0.0523682 0.0751992 0.0302618 -0.0424008 0.0777737 -0.0423515 0.061472 0.0862593 -0.0212203 0.0200887 0.129146 0.0579424 -0.0426299 -0.058408 -0.00709578 -0.0329751 -0.143087 0.128586 0.172256 0.0924571 0.0909468 0.0777975 -0.00395966 0.242256 0.00700179 0.0172907 0.0229322 -0.00310772 -0.164074 0.122476 0.330535 0.194545 -0.0766795 0.169655 0.128569 0.0135608 0.0245931 0.0619425 0.0552625 -0.0498182 -0.0132328 -0.127622 -0.0807721 0.0211308 -0.0588396 -0.0191875 -0.153502 -0.0242419 0.072 -0.0329483 -0.0921871 -0.0579809 -0.0104004 -0.0947475 0.000726399 -0.0678967 0.0431242 -0.0468306 0.0651328 -0.0660573 -0.0108557 0.0345998 -0.0811489 0.231646 -0.0723383 -0.225837 -0.0459744 -0.115083 0.143649 0.0401539 0.0566938 0.0182795 0.298185 0.251111 0.0547589 0.00988857 0.0853562 0.177253 -0.119128 -0.0835833 0.197159 0.013455 0.0260823 -0.108272 -0.0422564 0.00660907 -0.026572 0.220616 0.0186583 -0.165122 -0.23115 0.0432753 -0.254529 0.070935 0.0761268 -0.0810656 -0.359549 0.0453059 -0.000313294 -0.0784795 -0.0770298 -0.120175 -0.0673327 0.0301927 0.0731051 0.0383396 -0.0140489 0.150094 -0.0694679 0.0531946 -0.206679 0.0389833 0.260611 -0.506077 0.0408864 0.324096 -0.142801 -0.153184 -0.00359601 -0.231207 0.174577 -0.16449 0.0949133 0.234505 0.318008 0.0219781 -0.349084 0.249081 -0.0822928 -0.232455 -0.339891 -0.158145 -0.29901 0.0729508 -0.237266 -0.40467 -0.0399533 0.264387 -0.265783 0.192738 0.307753 -0.349006 0.403492 -0.0440297 0.144791 0.344831 0.637459 -0.0745313 -0.135703 -0.0726115 0.110836 0.416521 0.265264 -0.132591 0.0443751 -0.0423314 0.140859 -0.330668 -0.0605348 -0.031378 0.106911 0.0271082 0.0324284 0.0261477 -0.0752829 -0.135225 -0.132983 0.135008 0.116155 0.0966441 0.0324897 0.107881 0.227123 0.390186 0.129563 0.127126 0.0281313 0.187526 -0.205445 -0.178428 0.262233 0.0542813 0.00290443 -0.0520864 -0.0225244 0.0513703 0.033167 0.273884 0.128978 -0.12596 -0.17735 0.0629122 -0.191543 -0.0691501 -0.0183384 0.188325 -0.421152 -0.00895832 -0.156066 -0.242649 -0.205013 -0.280968 -0.21773 -0.109705 0.164446 0.100685 -0.120717 0.257344 -0.0167063 0.221176 -0.1042 0.0367782 0.159772 -0.159693 -0.202318 0.115298 -0.0851938 0.00063357 -0.0984818 -0.0529961 0.125389 -0.12875 0.127881 0.128348 0.130296 0.0539979 -0.0392974 0.111155 0.00325646 -0.0257205 0.124084 -0.0696572 -0.0154784 0.174976 0.0752765 0.0829443 -0.0844274 -0.197399 0.0824012 0.203619 0.029039 -0.0467726 0.0902751 0.0567429 -0.141332 3.03186e-05 0.0357478 -0.00524589 -0.141375 -0.104782 0.0574656 0.0941958 -0.0774288 -0.0865373 -0.0288673 0.143815 -0.00127144 0.0721509 0.140391 0.0942654 0.000950355 -0.0293143 0.124053 -0.131978 -0.204374 0.098158 0.128249 -0.050433 -0.0327168 0.0132854 0.0895259 -0.0903283 0.11299 -0.0341059 -0.197662 -0.089442 0.0838368 -0.0168832 0.187046 0.0746123 0.0975577 -0.0089459 0.0559802 0.194465 0.116636 0.143871 0.0223812 -0.00881951 0.0810002 0.00761877 0.0501886 -0.0362203 -0.0127432 0.0888853 -0.0412954 0.0319059 0.121481 0.0638254 0.194432 -0.0327926 0.204726 0.0897237 0.0131027 0.101747 -0.10381 0.086183 -0.0163753 -0.0403388 0.0663909 0.0128197 -0.149268 0.0433829 -0.0911555 0.257684 0.221278 0.148814 0.0616222 -0.162366 -0.150476 0.0228549 -0.0174782 0.12239 -0.0675205 0.0194176 0.072803 0.297915 -0.0181179 -0.118057 -0.0255193 0.0679946 -0.182162 -0.113616 -0.0462817 0.0127519 0.173207 -0.124524 0.127857 0.117966 0.015492 0.0554325 0.243753 0.0374351 0.0401129 -0.0813799 0.151119 0.0203537 -0.0675818 -0.281384 0.194744 -0.0451044 -0.0980708 -0.0759618 -0.119025 -0.0535081 0.232993 -0.243802 0.298052 -0.173019 0.0570319 -0.125155 0.0139488 -0.0337241 0.0833172 -0.165591 -0.220617 0.0509869 -0.0046455 0.0147568 -0.0589306 -0.20602 0.0664702 -0.132374 0.0270715 0.0975442 -0.10139 0.171153 0.0258994 -0.04634 0.0774872 0.149221 0.180693 -0.0180899 -0.0558372 0.313795 -0.0132642 -0.0586609 0.129038 -0.152662 -0.0338457 -0.00252817 -0.00367236 -0.0620119 -0.0682298 -0.039707 0.0118033 -0.0463613 -0.114408 -0.0749865 0.0614984 -0.0780417 0.0417187 0.191019 0.000942519 0.0030455 0.0516047 0.147605 0.0350228 0.111976 0.116282 0.0277203 -0.0963923 0.0225237 -0.0924984 -0.00441624 -0.100792 -0.0379019 -0.115181 0.0284118 -0.0489855 -0.0335256 0.14079 -0.0136554 -0.0958372 0.104763 0.0246411 -0.0889753 0.0198938 0.0628537 0.00263571 0.024123 0.0753516 0.0749279 -0.0925506 0.146604 0.0230036 0.0348463 0.0857825 0.0588736 0.136616 0.0843724 -0.0139203 -0.0486669 0.0594343 -0.0729949 0.0821798 0.101477 -0.0848127 0.0567486 -0.09726 0.00797444 0.00761125 0.0150304 -0.04633 -0.112528 -0.0145338 0.0227201 -0.110777 -0.0483662 0.133165 -0.00236134 -0.0705739 -0.0977119 0.0214892 0.0849941 0.0515414 -0.00419505 -0.0693218 -0.0451997 0.00154312 0.0666871 0.093002 -0.00576996 -0.0621371 0.0457544 0.143551 -0.0975468 -0.0380173 -0.0237782 -0.0228006 0.044457 -0.00403939 -0.0701643 0.105603 0.0348652 -0.0369664 0.0236004 0.0374366 -0.0637437 -0.00253125 -0.0577653 0.056314 0.00666177 -0.042813 -0.0212078 0.0491934 0.0655431 -0.0157318 -0.0373216 -0.0903824 0.0794726 -0.152926 -0.0117902 -0.0611411 0.0522572 -0.0625964 0.0355567 0.0599464 -0.0277532 0.0221101 0.14453 -0.0919083 -0.0196458 0.0226583 0.0166669 0.0385316 -0.0891391 -0.0418588 -0.130509 -0.0886362 0.195282 -0.198404 -0.186009 0.0562689 -0.0946951 0.106864 0.0330207 -0.0164295 -0.0679397 0.0343185 -0.153246 -0.162444 0.0855316 0.180471 -0.0559181 -0.10809 -0.0190104 -0.0706079 -0.0240418 0.24565 -0.0649355 0.152614 -0.1152 0.107859 0.182477 0.219851 -0.0490987 0.173804 -0.00797021 0.0321293 -0.0215665 0.166687 -0.0707155 0.0963786 -0.0368822 -0.0122181 -0.0670072 0.0684148 -0.104766 0.158889 -0.104358 -0.168462 -0.0251626 0.0340947 -0.0380026 0.0814838 -0.0789998 -0.0148221 -0.0852159 0.0249116 -0.00700716 0.0620856 0.0589079 -0.0784203 0.00608574 0.141458 0.104777 0.123892 0.0290674 -0.134882 0.110372 0.0570427 -0.110698 -0.0732784 0.114486 0.0274586 0.0312504 0.000999804 -0.0438695 0.117864 0.0911996 0.0221258 -0.0872592 0.0532981 0.0295568 -0.0380623 0.0551677 -0.0416542 -0.00132625 -0.138926 -0.0442431 0.00128615 0.000515368 -0.00983061 0.0783997 -0.0321562 -0.0223432 -0.0112712 -0.0766651 -0.00374253 0.132992 0.136188 0.0459825 0.0582053 0.102236 -0.106794 0.0148679 -0.00917732 -0.0797709 -0.00505234 -0.0405228 0.0920553 -0.00571329 -0.0301657 -0.0269687 0.0595971 -0.0112903 -0.0257759 -0.00817843 -0.0614078 0.0204687 -0.144732 -0.0397064 0.00923353 0.0032402 -0.0572766 0.00864202 -0.0357178 -0.0616395 -0.0707055 -0.111984 -0.110409 -0.0921426 0.0555853 -0.0843735 -0.00542834 0.072311 -0.078563 -0.031545 -0.0136004 -0.0261508 0.0426462 -0.0147451 0.0743281 0.0481058 0.0633787 -0.000731614 -0.00314045 0.157754 -0.0956116 0.029477 0.00110238 0.000373592 -0.11592 0.0204777 0.0297833 -0.0192318 0.110888 0.0603214 0.00910999 0.112647 -0.120862 0.0755035 -0.198431 -0.323574 0.0245099 -0.166637 0.0947345 -0.0795969 0.123679 0.0923128 0.0297118 0.0567073 0.0476758 -0.1639 0.154487 0.153457 -0.00346679 -0.0578547 0.015202 -0.103594 -0.0816388 0.0125758 -0.0373858 -0.0880797 0.151057 -0.262731 0.0147577 0.0965015 0.0336415 0.154791 0.089297 0.0202871 -0.0202921 0.0675732 -0.033687 -0.00663187 0.334151 -0.056744 -0.023929 0.0510239 -0.0730848 0.0609799 0.197561 0.00780662 0.0518123 0.415857 -0.269024 0.0409967 -0.208236 0.119962 0.112425 0.0218166 0.0900635 0.191259 0.00261164 0.259939 -0.0726796 -0.0405078 0.0398888 -0.0822186 -0.0409629 -0.333955 -0.0327218 -0.227782 -0.423344 -0.394055 -0.176575 0.193284 0.0217407 0.241859 0.259575 -0.00972489 0.235813 0.0560823 -0.00687288 -0.0120582 0.204889 0.0236053 -0.129971 -0.156282 -0.0770872 -0.137672 -0.0980262 -0.167673 0.195265 0.22859 0.0907742 -0.0159122 0.0304936 0.119614 0.0254547 -0.0497887 0.00270273 -0.0528475 -0.117549 -0.0460348 0.0773015 -0.0570093 0.00408615 0.106233 -0.0751144 -0.000652545 -0.125131 -0.184533 -0.0855848 -0.0140212 0.133014 -0.030741 0.0205189 0.0125788 -0.0409234 0.0550949 0.177914 -0.0990548 0.224113 0.154669 0.0136699 0.00331668 0.0133881 -0.0258154 -0.0274791 0.0297731 -0.0575078 0.00748463 0.0913557 -0.24854 -0.196882 0.055177 0.0203665 0.0446646 0.161116 0.080967 0.0793641 0.0775283 0.0218351 0.0253795 0.165806 -0.0190101 -0.150146 -0.0459391 0.0769631 0.0325921 -0.150466 0.10373 -0.198761 -0.0218114 0.0906944 0.0927717 0.0966891 0.0708339 -0.0142364 0.0241752 -0.0192512 -0.010377 -0.0276111 -0.0654687 0.123093 -0.0239264 -0.023341 0.0916603 0.215729 -0.0267273 0.064372 0.0217056 0.0816371 0.123145 -0.0111937 -0.215986 0.0499683 0.0373657 -0.0745139 -0.0976653 -0.101814 0.0818411 -0.104383 0.0586557 -0.125311 0.0359596 0.181748 0.0038638 -0.0930744 -0.0178277 0.0660947 0.12936 -0.00736462 -0.0628821 -0.0451441 0.0270166 -0.0348011 -0.0782856 0.0577839 0.0334828 -0.0948265 0.000474698 -0.0877204 -0.0117315 0.133164 -0.00689275 0.0424297 0.0661623 -0.00680889 -0.0582277 0.000590837 0.0967968 -0.0258475 -0.0184627 -0.0465977 -0.0391099 0.0418387 -0.0276958 0.0710511 0.0490049 -0.0152369 -0.102398 0.12107 -0.0626695 0.0331716 0.00709541 0.0650314 -0.0580555 -0.00161461 0.0348041 -0.115792 0.0863055 0.0104958 0.106405 0.000111824 -5.74613e-05 0.0739156 0.0185762 -0.0149926 0.0393448 0.0839025 0.108728 -0.111123 -0.135348 -0.104004 0.0434693 0.000152289 0.0276119 -0.0894108 -0.120667 0.0879409 0.100058 -0.0598043 0.214537 0.208973 -0.0987304 0.0399955 0.0979821 0.219447 -0.091703 -0.174559 -0.206987 -0.153414 0.0285751 -0.0418382 0.126161 0.290149 0.0854081 -0.253298 -0.112979 0.198238 -0.193871 -0.080946 0.0854056 0.153542 0.0100182 -0.308315 0.0792893 0.158741 0.156395 -0.0337339 0.0104773 0.122186 -0.070388 0.1001 -0.201232 0.134885 0.267443 0.0401605 0.0669986 0.105079 0.096869 -0.124038 0.0438138 0.0874223 -0.115518 -0.0113285 -0.174334 0.130958 0.0795234 0.00934604 0.0248559 -0.088026 -0.19796 0.0378303 0.161778 0.0847748 0.037626 -0.0579636 0.0799051 0.042006 -0.135897 0.0785834 -0.0177011 0.0130929 -0.123592 -0.0434174 0.135958 0.0867224 -0.0384672 -0.0285279 -0.041515 0.144956 0.050399 0.0996322 -0.00850629 0.083821 -0.0328495 -0.0896214 -0.0362922 -0.0981177 0.0292505 0.0112354 0.0550351 0.0936569 0.16005 0.16265 0.0693954 -0.0328024 -0.114995 -0.0331703 0.113393 -0.156059 -0.0689135 0.0747424 0.0627026 -0.151646 0.00149835 0.0223138 -0.0655884 -0.088929 -0.192774 -0.0845885 -0.0315238 0.164885 -0.0441637 0.0727539 -0.186663 -0.140091 -0.0587088 0.0460933 -0.0924494 -0.158187 0.196287 0.0400161 -0.111768 0.194732 -0.045019 -0.0270294 0.148438 0.0251933 0.128956 0.0408736 -0.0911392 -0.0361424 -0.107351 -0.0812141 -0.0430181 0.0338194 -0.0116146 0.110091 -0.0964386 -0.055894 -0.0082468 -0.0553301 0.0875183 -0.0969372 0.0681497 0.202198 -0.0472439 0.0906274 0.131644 -0.00689152 0.141005 0.102588 -0.101466 -0.0670807 0.104762 0.173178 0.111991 0.0247067 -0.0506503 -0.0690184 0.0311204 -0.0135046 -0.0189768 0.140434 -0.221409 -0.0238673 -0.113805 -0.0509556 -0.126152 -0.14143 0.121962 0.0665416 0.053009 0.110207 0.00962362 0.167549 -0.0081139 0.0715789 -0.0182441 0.115908 -0.0153122 0.10935 0.0233249 0.0771387 0.0670199 -0.0687543 -0.133923 0.0911059 -0.0800875 0.102596 -0.0158134 0.165275 0.056097 -0.152579 -0.110681 0.174214 -0.122767 -0.108277 0.0404507 -0.0817072 0.105231 0.212935 -0.0130271 0.15561 0.112213 -0.106597 -0.0817959 -0.105645 -0.0324514 -0.214766 -0.159472 0.0112706 0.139823 0.115194 -0.0202259 -0.275316 0.00456108 -0.0630542 -0.314139 0.220197 -0.341985 0.305103 -0.200594 0.233774 -0.0956078 0.036432 0.30414 0.0417269 0.037892 -0.00414309 0.0312668 -0.00392316 0.206027 0.0208703 -0.194766 -0.167743 0.067711 0.0817862 -0.197123 -0.0254429 -0.0333173 0.0526368 0.11665 -0.00401006 -0.070587 0.693973 0.0450763 -0.0390175 -0.0606976 -0.131987 0.109431 -0.0116412 -0.0124637 -0.114291 0.184924 -0.0569085 -0.102259 -0.0288037 -0.0168423 -0.0900165 -0.0409136 -0.0108623 0.0633577 -0.0344135 -0.073342 -0.0507879 -0.181904 -0.085964 -0.164118 -0.0819442 0.0238232 -0.0098715 -0.131346 0.119633 -0.125245 0.0246153 -0.076375 0.166207 0.0974198 -0.0451452 -0.160514 0.0978077 0.0318592 -0.00737722 -0.00281391 -0.0212704 -0.160527 -0.00233371 -0.0367531 0.146968 0.0240758 0.0341473 0.220578 -0.118191 -0.0406265 0.165928 -0.10404 0.0301745 0.122987 0.0598669 0.0405026 0.193615 0.0358582 -0.0170903 0.0152625 0.0264493 -0.089979 0.0367402 0.0427087 -0.297976 0.117189 -0.0401599 -0.158606 -0.0976651 -0.0642499 0.159162 -0.013811 0.0248213 0.0605209 -0.194648 -0.121439 0.0707267 -0.0229959 0.0339787 0.0108049 0.0164762 0.161519 -0.100301 0.174524 -0.0333924 0.0286987 0.101046 0.0732922 -0.0455636 -0.0520685 0.114334 -0.00794464 -0.0829841 -0.228406 -0.0850638 0.0131737 0.0087752 -0.00978463 -0.0574614 0.0571391 0.0274807 0.0205881 0.183267 0.099181 0.141069 0.117968 -0.00586439 -0.0197321 -0.191277 0.0997767 0.093889 0.035513 0.0201035 0.0245628 -0.0029223 0.023933 0.0351567 0.0459982 0.0559319 -0.0382744 -0.0190334 0.0794577 0.071396 -0.00519079 -0.0848962 -0.0998054 0.00601248 0.0715846 0.110165 0.164481 0.0439092 0.0671238 0.0479383 -0.146832 -0.00659778 -0.108923 0.110125 -0.00492026 0.0342352 -0.110871 -0.0616729 -0.0674211 0.0466226 -0.0999608 0.0887343 -0.0927721 0.0984056 -0.169367 0.0862305 0.213633 -0.0142478 0.10731 0.0401333 0.126767 0.049832 0.120162 -0.0327067 0.00646398 -0.0590005 0.0528285 -0.0107208 -0.0413363 0.183571 0.0732705 -0.0816043 0.0682899 0.216812 -0.159565 0.11664 -0.0275853 -0.203052 0.0848579 0.0966667 -0.195667 0.00727976 -0.144464 0.315779 -0.085318 0.103782 0.0558793 0.173544 0.0566981 0.017111 0.101553 -0.13387 0.265814 0.152196 -0.163152 -0.23343 0.0476901 -0.106613 -0.211155 0.0922986 -0.0408236 -0.00208268 -0.121977 0.0662 -0.00666845 0.0266141 0.0330512 0.218322 0.119082 0.129218 0.124495 0.0922872 -0.0725022 -0.250868 -0.139534 -0.138204 0.0725037 -0.0191244 0.0656915 0.177043 -0.00918546 -0.0164803 0.0651615 -0.0307661 -0.0130203 0.0394181 -0.0309668 -0.0543555 -0.0675255 0.0893441 -0.0943772 -0.127572 -0.0559133 0.0783165 0.0127635 0.107093 0.151641 -0.0645064 -0.0706544 0.0465148 -0.0693626 -0.0161612 0.045925 0.133232 -0.158574 -0.124455 0.0763939 0.158767 0.020023 -0.0617052 -0.0431838 -0.00857059 -0.010965 0.120342 -0.0404499 0.173153 0.0607043 -0.034012 0.00846877 0.11411 -0.00264524 0.0869843 0.00310781 -0.0628299 -0.0468131 -0.0458253 -0.0669297 0.149937 -0.0367729 0.0117302 -0.181987 -0.217585 0.0920481 0.0510609 -0.0861638 0.0550504 -0.108056 -0.130718 -0.142433 -0.0198656 -0.06239 -0.287876 -0.027767 0.0115721 -0.0204687 0.157238 0.19421 -0.0755211 -0.105021 -0.00976183 0.152878 -0.0132652 0.209423 0.0976951 -0.0285162 -0.0280966 0.000726208 0.0238138 -0.0599174 -0.109248 -0.137416 -0.0419182 -0.0966949 0.0300221 -0.0645585 0.19653 0.0726836 0.174665 0.0289548 0.13928 0.208486 0.118644 0.0893215 -0.163517 -0.0354361 -0.137125 -0.0281109 0.0728253 0.0336844 -0.0343238 -0.0767073 -0.176206 -0.0114671 0.295766 0.22219 0.324922 -0.0509034 -0.21839 0.0811283 -0.00989251 -0.0380808 -0.0219277 -0.017789 -0.063171 0.0924988 0.0552814 0.163668 -0.195803 0.012778 -0.0291165 -0.205884 0.0593461 0.191401 0.184963 -0.230317 0.00874273 0.0648595 -0.120954 -0.0264684 0.090412 -0.114053 -0.00366035 0.0244916 0.184471 0.0982578 0.141901 0.289879 0.217233 0.157205 0.103288 0.305048 -0.102008 -0.00368837 -0.0826616 -0.0098433 -0.0851023 -0.110168 -0.0113899 -0.0105044 -0.0935836 -0.0243404 -0.167401 -0.176478 0.142801 0.0144004 0.00743044 -0.0964249 -0.136986 0.187875 -0.0125305 -0.22733 -0.094788 -0.107107 0.112503 0.2752 -0.166045 0.230213 -0.0648451 -0.0575242 -0.0127553 -0.187718 0.0394454 0.252299 0.0253407 -0.0587707 -0.0870937 -0.144587 -0.121364 0.0769471 -0.144486 -0.0802716 -0.140988 -0.0924102 -0.0183067 -0.141229 0.225301 0.271148 0.0440165 0.163694 0.16317 0.0690652 -0.0937775 -0.122093 -0.151766 0.0746791 -0.144068 0.113965 0.0449945 0.00440147 0.0541966 -0.0955643 -0.0808528 0.129903 0.0643875 -0.0469113 -0.0317044 0.0241309 -0.29567 -0.0214241 -0.042698 0.0370416 -0.110311 0.21068 0.0661051 -0.0782583 -0.0733642 0.22091 -0.0831232 -0.00180045 -0.0850571 0.15582 -0.0554523 -0.108081 0.0705394 -0.177651 -0.109917 0.177786 0.0880044 0.0212113 -0.0276355 0.188676 -0.076449 -0.061453 0.179209 -0.0409984 0.30827 0.164406 0.0861832 0.179375 0.0080234 0.202072 0.117906 0.0111932 -0.188046 -0.0370009 -0.119881 -0.122261 0.0247424 -0.0852487 -0.113703 -0.234175 -0.456974 0.115345 -0.168577 -0.198975 0.12185 -0.177887 -0.0607485 0.101276 0.181229 0.185065 -0.227117 -0.287174 0.119588 0.0586674 -0.0340368 0.165461 -0.0561393 0.365809 -0.0685839 0.0642534 0.0583475 0.0259364 0.143532 -0.194401 -0.166948 -0.213995 0.116054 -0.141095 0.0112399 -0.264947 -0.121773 -0.178793 -0.0829784 -0.119668 0.161271 0.112249 -0.0676869 0.151304 0.152384 0.0583035 -0.0580566 0.0535676 0.0208994 0.158578 -0.148287 -0.0440813 -0.0592587 -0.0880338 -0.233051 -0.00832879 -0.107322 -0.214981 0.255887 0.259806 0.232005 -0.0099415 -0.17096 0.0114268 -0.121765 -0.301949 -0.0838964 -0.0745146 0.000337582 -0.0485133 0.0469369 0.048349 0.186797 0.258644 0.190146 -0.226209 0.238785 0.252473 0.31039 -0.286511 0.15648 0.0424885 -0.292411 0.00184356 0.0651092 -0.13406 0.0923528 -0.14357 0.0804802 0.242833 0.120276 0.143532 0.189345 -0.12968 -0.0158332 0.320385 -0.221312 -0.128074 0.339764 0.0842923 -0.133292 0.048926 0.159553 0.210597 -0.00122919 -0.250627 -0.301832 -0.179205 0.289671 -0.239744 -0.0378524 -0.096882 -0.574981 -0.144192 0.0238684 -0.564798 -0.231217 -0.00695598 0.206556 -0.0995321 0.29234 0.22861 -0.291242 0.229995 0.00795485 0.226804 0.0230749 0.288636 0.144405 -0.242295 -0.0553678 -0.0847569 0.0344761 -0.0953848 -0.00566138 0.11115 -0.10823 -0.189543 -0.0481734 0.0788337 0.384176 0.19621 0.117675 0.293347 0.19245 0.19053 -0.439131 0.138826 -0.0882118 -0.153959 0.0988569 -0.0195963 0.119116 -0.0906907 0.0391994 -0.142872 -0.210886 -0.00606538 0.0571539 -0.0529168 0.0590318 -0.0765498 0.100676 -0.160735 0.122347 -0.0752973 -0.160996 0.0390832 -0.0570664 0.0911945 0.187176 0.013466 -0.0329687 0.108016 0.107227 -0.065522 0.147914 -0.0785747 0.307199 -0.294449 0.067334 -0.01106 0.0966914 0.0149348 0.23585 -0.404648 -0.062802 -0.0741526 0.171884 0.191387 -0.156268 0.0389783 0.174993 -0.139842 0.0240656 0.13271 0.0502454 0.139048 0.16901 0.142282 -0.202579 0.0788849 0.105472 0.0772325 -0.0487205 -0.0599469 0.0301912 0.0919861 0.0184369 0.112132 0.117002 0.0642382 -0.120022 -0.0256194 -0.0320538 0.104647 0.0848173 -0.0231218 0.0358991 -0.0924125 0.00142071 0.0320519 -0.0235955 -0.0804866 -0.0662119 -0.0167535 0.0691856 -0.195373 -0.0566189 -0.00835798 -0.0223188 0.0257777 -0.129155 -0.0166489 -0.115085 0.0161051 -0.0910653 -0.0405348 0.0711379 0.0314165 -0.0617645 0.00656229 0.0349238 -0.07517 0.00795697 0.00908689 -0.0747734 0.121719 -0.0193621 0.159206 -0.0865339 -0.0844572 0.0889763 0.00699714 -0.0447441 0.0576925 0.0996097 -0.183824 0.192358 -0.00744144 0.110664 0.0395126 -0.104482 -0.0676229 0.101462 -0.23871 -0.0563791 0.0608308 0.00266888 0.0434593 0.0822929 0.0462445 0.0237408 0.112666 -0.0430364 -0.0591299 0.104889 0.131689 -0.000680445 -0.0705514 0.129012 -0.0859148 -0.116732 -0.00550401 0.0870221 0.00546593 0.0413448 -0.0790691 0.0773839 0.17414 0.145541 0.0109615 0.132906 0.0455152 -0.0047377 0.163651 -0.0984038 -0.0832369 0.0262188 0.0309657 -0.0290912 0.0310813 0.34232 0.102048 0.0331681 0.035709 0.0938138 0.161348 0.217774 -0.00139384 -0.0151972 -0.157345 -0.00410166 -0.0556735 0.454594 0.189684 -0.134048 0.180231 0.207222 -0.0656981 0.0626754 0.104123 -0.184181 0.135141 -0.116132 0.218649 -0.169546 -0.212996 -0.0735877 -0.351878 0.00571737 -0.104754 0.0203444 -0.12637 0.0206389 0.110967 0.0510687 -0.222433 0.0424639 -0.173526 0.0518695 0.0387815 0.0953037 -0.116309 0.148432 0.0811471 -0.18796 -0.232278 -0.27967 -0.227116 -0.141113 -0.254314 0.00810018 0.0114646 -0.108261 -0.0152267 -0.0070795 -0.0831617 0.0224555 0.0853178 0.222373 -0.00444696 -0.0960117 -0.0809334 -0.0552307 0.0110734 -0.00439525 0.0772344 0.0679678 -0.0588479 0.00082806 0.000529116 0.000968922 0.00565319 -0.00924397 -0.0238703 -0.0435177 0.113416 0.22346 -0.209495 0.0252558 0.171689 -0.00693431 0.0784726 0.0408935 -0.155523 0.0264315 0.0750071 0.10178 0.109549 -0.06843 0.138953 0.0873861 -0.0952189 -0.0650598 0.202198 -0.0657164 -0.0399682 -0.0330979 0.0220974 -0.0581963 0.0191493 -0.0477787 -0.0496662 0.094942 -0.0815551 -0.1784 -0.11955 0.139185 -0.0665828 0.00918236 0.0119199 -0.0276243 0.0999579 0.0986793 -0.027716 -0.0414888 -0.137094 0.00117304 -0.0534303 -0.109615 0.0814769 0.0801073 0.104653 0.110529 0.0381957 -0.036379 0.0951207 -0.0117416 0.0338141 0.0843954 0.0686674 -0.0159269 -0.069378 0.0279248 -0.0552449 -0.0613252 -0.0319008 -0.0316602 -0.151797 0.0102079 0.14955 -0.13483 -0.0954071 0.127305 -0.0763689 0.0327667 0.062947 -0.143508 0.151668 -0.0731556 -0.0184106 0.0230923 -0.0477451 -0.0515971 0.0290478 -0.097508 -0.0518504 -0.0219784 -0.0867354 0.00255253 0.0237334 0.00367934 0.0255104 -0.0446232 -0.0724037 -0.12283 0.0267004 0.00790881 0.110203 0.0653532 0.128506 0.0394361 0.17402 0.112721 0.05031 -0.0791964 0.148198 0.0605766 0.0472224 0.0144843 -0.12408 0.019987 -0.0425876 -0.145627 -0.0584298 -0.0595093 0.00856961 0.168291 -0.0281988 -0.0796723 0.0304552 0.160599 0.0578142 -0.00925709 -0.0161011 -0.0208475 0.065122 -0.07731 -0.0612316 -0.171806 -0.0759402 0.0249075 0.151507 0.0644551 -0.106199 -0.210774 -0.113302 -0.0469051 0.16861 -0.0148374 -0.00481363 0.0176388 -0.0272203 0.151422 0.0227766 -0.00231141 0.115283 0.00765608 0.0960547 0.106099 -0.0967926 0.229217 -0.170099 0.0571103 0.0749438 -0.236657 0.40835 0.0164495 -0.467499 -0.00299054 0.15892 0.112133 -0.18441 0.324827 0.0539382 -0.0794118 -0.0324305 0.0440197 -0.126757 0.139358 0.198663 -0.0803072 0.0285928 -0.0367501 -0.0111097 -0.0089683 -0.0513647 -0.274274 -0.0199597 -0.00361313 0.300497 0.0174824 0.0692032 0.0220861 -0.0263082 -0.135604 -0.0650937 4.0913e-05 -0.0116016 0.11237 -0.17814 -0.0146487 0.0403977 0.0553429 0.0597143 -0.0119705 -0.112824 0.074951 -0.0180109 0.042248 0.160463 -0.0749427 0.101345 -0.0406712 0.170412 0.12127 0.164957 0.103427 -0.0457544 0.111558 -0.0526668 0.0921632 0.0837136 0.0274201 -0.20456 -0.0537456 -0.00925395 0.0318427 -0.099033 0.0874317 0.148794 -0.0578747 -0.0645286 0.163861 0.0517462 -0.0309595 -0.0426594 0.0516001 0.0157314 0.0527159 0.0247323 -0.0265112 -0.0774902 0.0810374 0.0507763 -0.259728 0.0290892 0.0703159 -0.00554315 -0.103583 -0.0850755 0.018641 -0.0411717 0.139347 -0.0297309 -0.0882917 -0.00923638 0.19143 0.00813075 -0.0137663 0.138765 -0.0407844 -0.108413 0.0429761 0.162042 0.00947059 0.0259915 0.0449625 -0.126338 -0.161944 -0.00860066 -0.012941 -0.00729432 0.00712826 -0.234058 -0.0256471 -0.0214185 0.06713 -0.0296558 0.089047 0.191075 -0.000657104 0.0278784 0.122851 0.0303692 0.025779 -0.0965027 0.0236212 0.0899535 -0.210363 0.0260307 -0.0807432 0.0165159 0.098578 0.0426006 -0.215837 0.0113929 0.184865 -0.0454864 -0.0573467 -0.0628625 -0.141589 -0.103528 0.0259737 -0.055552 -0.0701423 0.0933322 0.053941 0.119475 0.00585132 0.0738618 -0.119037 -0.0013367 0.0979312 -0.0300699 0.0370564 0.0466465 0.141073 -0.0846979 -0.0716634 0.0366908 0.0217853 0.0420725 0.0557187 -0.127601 -0.0633499 0.00903533 0.052616 0.117233 0.14367 0.229665 0.133048 0.121683 0.163681 -0.0491467 -0.0720992 0.0736895 -0.0109053 -0.00793476 -0.142793 -0.105156 0.149605 0.104451 -0.0917578 0.081363 -0.115603 -0.0979221 0.0207818 0.1039 0.0633631 -0.28495 -0.0550032 0.169964 0.159809 -0.0139964 -0.119871 -0.16984 0.082508 0.155918 0.210671 0.0267688 0.0711621 -0.0233876 0.0971149 0.245336 0.0813422 0.315179 0.120628 -0.154247 -0.0335572 0.0176225 -0.128336 -0.118139 0.0711633 -0.151185 -0.0507637 -0.237158 0.0145264 0.109944 0.0883118 -0.0134203 0.0724862 0.0362578 0.181455 0.0840854 -0.242896 -0.0523724 -0.273453 -0.00414532 -0.0695838 0.0910057 -0.0729211 0.00135327 0.0760848 -0.0282379 -0.301745 0.175096 0.136349 -0.178108 -0.121177 -0.102259 0.0229973 -0.0959463 0.158804 0.081071 -0.15304 0.0413377 0.0724804 0.182794 0.0197375 0.162405 -0.0894462 -0.0245813 0.0149201 0.0786644 -0.137473 -0.127675 0.0170659 0.125363 -0.158565 0.140205 0.20246 0.0190101 0.0334338 -0.238146 -0.0767433 0.00120181 0.0676786 -0.0818391 -0.0463626 0.186671 -0.0638118 -0.0306459 0.0156605 0.0791835 0.228736 -0.0412352 -0.103645 0.043911 -0.0591928 -0.0471427 -0.00634436 0.020489 -0.136344 -0.100562 0.145398 0.158154 0.0997253 0.000554217 -0.0130124 -0.034162 -0.104566 0.0549258 -0.00739206 -0.0369332 0.0290971 0.176111 0.0741856 -0.0104006 0.00564902 0.126626 -0.110317 0.0492032 -0.0717439 -0.0036075 -0.0858183 -0.210364 -0.00919604 0.228259 -0.195652 0.0526133 -0.145369 0.0132102 0.00751124 0.105657 -0.0365376 0.182996 -0.125685 -0.101182 0.0165028 -0.0263801 0.0160642 0.00196827 -0.143491 -0.0718493 0.124762 -0.0127503 0.0790749 -0.0827091 0.0452554 0.0787628 0.0681629 -0.0256808 -0.096979 0.165226 0.0812313 0.0531949 0.0731494 0.214582 -0.0393139 0.112668 0.0273821 0.092732 -0.138341 0.0821224 0.113149 -0.0701251 -0.00292032 -0.0436945 -0.0896976 -0.151529 -0.134469 -0.121194 0.0401092 -0.139591 0.0396596 -0.0716609 0.0929945 -0.0545573 0.124986 -0.00498682 0.135742 0.120423 0.0688381 0.114603 -0.09437 0.220334 0.00873545 -0.231128 -0.0826937 -0.0837699 -0.124847 0.121663 -0.242452 -0.149692 0.136563 -0.177212 0.120054 0.0468214 0.0681971 -0.0272669 -0.229709 -0.0590153 0.375207 -0.244415 0.00572813 0.585794 -0.276426 -0.254826 -0.432255 0.1747 0.386787 -0.281835 0.545777 0.51341 0.106635 0.445013 -0.39608 -0.0946152 0.255846 -0.270033 -0.14132 -0.27635 0.0284759 0.138158 -0.659131 -0.350616 -0.178156 0.0348819 -0.382411 0.322389 0.595555 -0.00488353 0.366272 0.0131526 0.211791 0.300044 0.123491 -0.195515 -0.198966 -0.349922 -0.314511 -0.0536809 -0.0179607 -0.232888 0.676954 0.216302 -0.224969 -0.24791 0.128532 0.160354 0.10149 0.00847301 -0.0302267 0.17578 -0.0965226 -0.146172 -0.0234415 0.0261919 -0.0351295 0.0209765 0.0622873 0.100457 -0.147359 -0.100955 -0.125854 -0.0590234 0.112433 0.0145801 -0.00848957 0.14119 -0.197512 0.120654 0.201186 0.0181273 0.158429 -0.0103922 -0.15695 -0.0743204 -0.0270574 0.0320122 -0.0669559 -0.00721661 -0.0686452 0.0728646 0.0806181 0.231174 -0.137292 -0.0273126 0.0056963 0.0400531 0.153186 0.228851 -0.203128 -0.0256348 0.071153 -0.220257 0.253868 -0.0761929 -0.0932261 -0.0778631 0.115036 -0.0622257 -0.0262207 -0.0214879 0.0690512 0.0209489 0.0731055 -0.0425733 -0.0359306 -0.0448674 0.0659565 0.0865719 9.75103e-05 -0.0624747 -0.0842548 0.0373691 0.0408321 -0.117461 -0.0157923 0.0204159 0.110933 -0.0493983 0.0316566 -0.0711276 0.107916 -0.0764492 0.14404 -0.0313113 -0.049516 0.0585124 -0.0305467 0.054784 -0.0251959 0.133322 0.0292559 -0.00307063 0.0484701 0.0550362 0.0523232 -0.0544546 0.0604896 -0.0559875 -0.0601698 0.0651512 -0.0982244 0.020072 -0.0468181 -0.0500114 -0.0732602 -0.170313 -0.00969601 -0.0145812 -0.0617696 -0.0703933 0.192527 -0.0808401 -0.0571309 0.166415 -0.0217985 0.0397629 0.0282618 0.136248 0.114784 -0.150841 0.0514784 -0.0766725 -0.0195818 0.0925979 -0.135967 0.0693915 0.00635923 -0.14129 0.0301597 -0.0876649 -0.00917308 0.0269001 0.102411 -0.176056 0.0236241 0.0593654 -0.110521 -0.0604335 0.0187647 0.204747 0.0782073 0.0294341 0.108798 -0.127006 -0.00728226 -0.172738 -0.0706098 0.0454335 0.00390408 0.0852032 -0.0901907 -0.1377 -0.00144425 -0.0524609 -0.0712229 -0.180105 -0.151311 -0.106072 0.126468 0.0111195 -0.210371 0.0715966 0.00369409 -0.196137 -0.12239 0.125437 0.0786162 -0.125734 0.137779 -0.0981374 -0.0604214 0.108835 -0.234827 -0.0249287 0.126259 -0.0523678 0.0860808 0.100138 0.0854343 -0.0138859 0.158789 -0.255623 -0.0635942 0.212375 -0.0764734 -0.0949793 0.204199 0.132326 -0.0955925 0.121554 -0.106239 -0.0763844 -0.104777 0.0146084 0.0153864 -0.0949115 0.0306047 -0.0404789 -0.198477 0.0878524 0.0402079 0.121191 0.304294 0.101059 -0.0437496 -0.02473 -0.0706343 -0.0807523 0.16414 0.0587644 0.00349266 0.0303205 0.0903459 -0.0078058 -0.0220835 -0.0117466 0.100295 0.0593093 0.113105 0.0862721 -0.113102 -0.0294126 -0.0377413 0.0174957 -0.0576629 0.0451328 0.0429632 0.00198221 0.0708792 -0.0515316 -0.056539 -0.190867 0.0712991 -0.14024 -0.128517 0.00344286 0.0971942 -0.0371714 -0.132565 0.228011 -0.0621693 -0.0524206 -0.0165572 -0.170495 -0.0335119 -0.301051 -0.132863 -0.0395643 0.113664 -0.128653 0.0339402 -0.0152244 -0.0249651 -0.167569 -0.0511568 -0.215177 0.0884599 -0.0882129 -0.0396941 -0.103997 -0.28535 -0.103653 -0.0885068 -0.187292 -0.0185811 -0.137416 -0.176251 0.0362844 -0.0713207 -0.0448806 -0.109152 -0.148402 0.182255 -0.0670543 0.10474 0.168356 -0.0573503 0.257799 -0.103911 0.186124 0.090132 -0.16542 0.0360291 -0.104546 -0.0127572 -0.117749 -0.101405 -0.116461 0.0630571 -0.231787 -0.130539 -0.303729 -0.12393 0.00348104 0.130954 0.117229 0.214201 0.188806 -0.0117409 0.120749 0.0621172 -0.0739483 0.137778 0.0621903 -0.0669127 -0.107425 -0.0352103 0.082213 -0.108635 0.160344 0.0549772 -0.408107 -0.0396278 0.070843 0.209864 -0.1183 -0.237694 0.119988 -0.298741 -0.369259 -0.141714 -0.196801 0.042864 -0.155838 0.0188351 0.0464285 0.0689042 0.149622 0.117914 -0.128877 0.143748 0.32839 0.0619086 -0.146177 0.209581 -0.133313 -0.148041 -0.0782948 -0.0194403 -0.0914661 0.036588 -0.349916 -0.00684698 0.105866 0.0958592 0.22224 0.0955872 0.0325544 -0.0675338 0.0944266 -0.0492112 -0.127177 0.32963 -0.124419 -0.051529 -0.0290464 0.12424 0.0521014 -0.170561 0.0881884 0.2285 -0.558985 0.0847402 -0.0026672 0.0806298 -0.208435 -0.790242 0.0563626 -0.0642151 -0.598774 -0.109389 -0.200957 0.0404287 -0.00101255 -0.00339003 0.112636 -0.54626 0.47323 0.0304637 -0.0931217 -0.0170604 0.387209 -0.0990845 0.0315949 0.0884204 -0.678055 -0.223018 0.0598398 -0.35924 -0.208201 0.26122 -0.296941 -0.0155344 0.193532 0.44848 0.55135 0.49173 0.442365 0.116007 0.267906 -0.194792 -0.322427 0.0495854 -0.222994 -0.363656 -0.282515 0.00960341 0.0725749 -0.017604 -0.0815438 -0.0622444 -0.0463336 -0.0240905 -0.0213032 0.0398722 0.0532315 0.114766 -0.134132 0.225218 -0.1063 -0.122987 -0.0138105 0.16532 -0.0943367 0.0686262 0.0363152 0.155267 0.0277984 0.265164 -0.000387784 0.115783 -0.0241797 0.167648 -0.0821855 0.0421885 -0.0185175 0.0148791 0.0360266 0.0172068 -0.0962498 0.062563 -0.0828604 0.190361 0.132999 -0.115606 0.00431248 0.184169 -0.0549732 0.015562 0.135315 0.0880799 0.0923824 0.278137 0.134275 -0.092404 -0.0625512 0.0654395 0.0955775 -0.00123816 -0.0152703 -0.157371 -0.00700542 0.096599 -0.0375178 -0.0212846 0.0965174 -0.0530948 -0.0571727 0.0410979 0.0559062 0.0926682 0.1289 -0.0153186 -0.042358 -0.0530091 0.0101418 0.0948849 -0.034818 -0.0850054 0.0536646 0.121616 -0.0926039 -0.0921673 0.127275 0.0740461 -0.0571146 -0.14816 -0.0467813 -0.0490392 0.0142316 0.103847 0.0372433 -0.186792 -0.0354086 0.0369252 -0.0527195 0.073801 -0.0433866 0.080514 -0.0624833 -0.0927434 0.119095 0.0104386 -0.0151938 -0.0903289 0.0510787 -0.0294307 0.0786073 0.0718916 -0.0265134 -0.0707969 -0.0646285 0.0440872 -0.0184075 -0.0798704 0.0204629 0.0069304 -0.106299 -0.0572142 0.179001 0.0150129 0.0112751 -0.0535359 0.0190569 -0.0410476 -0.109749 0.0794939 0.012637 -0.0155607 -0.122732 -0.0123276 -0.0362691 0.0593566 0.08455 -0.0294108 0.106021 -0.0884292 -0.0696544 -0.00860933 0.0716587 -0.0371555 0.0966008 -0.0833498 0.0987104 0.0555932 0.00692551 -0.0483999 -0.0818977 -0.0856639 -0.0405623 0.0470718 0.104409 -0.028464 -0.0842186 0.087903 0.0361166 -0.0240089 0.0401548 0.0126185 0.0904796 0.0609915 -0.0552555 -0.199736 0.223208 0.210395 -0.148532 0.0457414 0.0518014 -0.0486101 -0.151672 0.0672996 -0.077227 0.0674962 0.0823707 -0.144883 -0.141056 0.134979 0.00277754 -0.00808819 -0.0484723 0.0442209 -0.194533 0.106848 -0.0426532 0.151794 0.0429038 -0.177739 0.106868 -0.187142 0.0765226 -0.173931 0.0225858 -0.18725 -0.0325454 -0.212109 0.0259061 -0.046614 -0.0380538 -0.196031 -0.0327915 -0.0749205 0.157864 -0.00648713 -0.0342289 0.223407 0.13303 0.0516224 0.0122361 0.0370577 -0.0809022 -0.1023 -0.0564394 0.00727282 0.146511 -0.0226461 0.0896419 0.0180549 -0.073685 -0.0142393 0.131032 -0.0125953 0.0617784 0.017727 0.0571594 -0.0118043 -0.00157755 0.0216156 0.106258 -0.0749274 -0.0952324 0.0963812 0.0326013 0.0566559 0.106655 -0.0284421 0.0715399 -0.0569831 -0.0969606 -0.162913 0.0746586 0.0413258 -0.127999 -0.0842517 0.068846 0.0113905 0.0342418 -0.100912 -0.109475 -0.0534501 -0.106011 -0.0513011 -0.0740825 -0.0430779 -0.0342349 -0.120753 0.105046 -0.0567702 0.000884777 0.0988322 0.0386571 -0.0882957 0.0414094 0.0325421 0.0922922 0.0464888 0.0777474 0.048194 -0.147469 0.0295533 -0.168375 -0.0420883 0.044844 0.0671859 0.0495589 0.11215 0.127329 0.0674048 0.00119896 0.0973584 0.0513524 0.128684 0.0510072 -0.0887039 0.0476611 0.00328122 0.0179858 0.0902677 0.077717 -0.143732 0.0221515 0.10612 -0.0574231 -0.0379161 -0.0585359 -0.0976733 -0.0104098 0.00722141 -0.054656 0.117417 -0.0113155 0.0446833 0.0400667 -0.0851082 -0.00568308 0.0195031 0.159972 -0.0748724 -0.0453592 0.0913236 0.0774962 -0.0762356 0.0147292 -0.0714437 -0.078115 0.0489179 -0.0307709 0.0021764 -0.003573 0.0573158 -0.154369 0.116541 0.000927433 0.0031033 -0.0221346 -0.000468142 0.0578646 0.0169472 -0.117615 0.0377082 0.113949 0.0885715 0.0572244 0.0662584 0.00204813 0.0059646 -0.040794 0.0585389 9.14068e-05 -0.0964496 -0.0656245 0.0174116 -0.0967428 -0.0670357 -0.0873784 0.0416333 -0.0575563 0.0144465 -0.0674554 0.00858376 0.0224516 0.0274695 -0.0434828 -0.00349304 -0.0613754 0.0760872 0.0262463 -0.182494 -0.0393716 -0.0844681 -0.0942289 0.204751 0.0433651 -0.0600735 -0.154943 -0.0237369 0.110394 -0.0308946 0.0929533 -0.17371 0.0874508 -0.0925381 0.040365 -0.226863 -0.0235671 -0.177054 -0.0183897 -0.000356353 -0.0972516 0.0852908 -0.0469744 0.0958242 -0.157652 -0.0673493 0.0959459 0.09902 0.102255 0.0598695 0.0398719 -0.00848658 0.0982438 -0.0311751 0.17028 -0.00435497 -0.0576475 -0.196119 -0.108648 -0.0240918 0.0028277 0.032683 -0.0847929 0.0489105 -0.00328814 0.0501617 -0.00611222 0.0922728 -0.0588841 -0.12222 -0.0604481 0.0507268 -0.00457824 0.070427 0.0733151 -0.12358 -0.067154 -0.0993606 -0.00614104 0.0479327 -0.0496611 0.0959011 -0.132703 -0.00600752 0.13758 -0.0367547 0.040454 0.112681 -0.0188522 0.0866458 -0.170191 0.0706927 0.162226 -0.00993967 -0.0229674 0.0199133 -0.00311464 -0.0626307 0.0126819 0.0201009 -0.0707357 -0.0928622 -0.0195716 -0.000385749 -0.0131961 -0.0355863 -0.0176691 -0.0812291 -0.106757 0.0945454 -0.0392731 0.0891344 -0.0117754 0.0391194 0.147976 -0.0142048 0.00755716 0.100515 -0.0124872 0.0965972 -0.0337821 -0.0194179 0.0859766 -0.0426259 -0.173338 -0.106136 -0.163928 0.0516217 -0.18507 -0.0449498 0.179385 -0.0656467 0.112681 -0.0461285 -0.146329 0.00873537 0.15786 -0.0811932 0.0848078 -0.00809212 0.13742 0.0218878 -0.0285929 0.00983361 0.114583 -0.0358765 0.0169672 -0.115961 -0.0353984 -0.075162 -0.0474984 -0.113633 -0.0438898 -0.083871 -0.00523095 -0.0129252 -0.0452215 -0.0270177 0.18404 -0.0789226 -0.00208064 -0.0660888 0.0654112 -0.02219 -0.0985931 0.0364897 0.110742 -0.142177 -0.0318105 0.097443 -0.0149425 -0.105515 -0.00857713 0.0567796 -0.0354314 0.0234631 -0.0856695 0.0872737 -0.00888697 0.0312585 0.0343133 0.0384203 0.00812554 0.0549812 -0.0593593 0.00130109 0.138374 -0.102408 0.0844617 0.0208227 -0.0167006 0.116688 0.000793773 -0.0336198 0.227743 0.0298622 -0.193986 0.00193704 -0.0551854 0.12891 0.0430214 0.145816 0.0335863 -0.142219 -0.00222504 0.200268 -0.0271456 0.0938258 0.126893 -0.00901622 -0.055079 -0.00579413 -0.0801331 -0.10587 -0.0498488 0.0504886 0.0281619 -0.0441138 -0.0930673 -0.0609704 -0.0999151 0.0342046 -0.0160101 -0.0635404 0.0326375 -0.29943 0.203883 0.0461149 0.0138742 0.250369 0.0788035 -0.0510726 0.00961942 0.090193 0.118737 0.00966737 0.0552316 0.200713 -0.0506987 0.155062 -0.15442 -0.00788679 0.0463548 -0.0213697 -0.0877051 -0.201097 0.132094 -0.0509906 -0.133616 0.129004 0.0949488 -0.117534 0.0304364 0.0310239 0.0713777 -0.187408 0.00825075 -0.332452 -0.145429 -0.10864 -0.052704 0.261454 -0.101896 0.0501914 0.087605 0.168518 0.158346 0.117976 0.0526273 -0.102622 0.101932 0.118009 -0.0612855 0.00243779 -0.0112297 0.0486951 -0.38972 -0.198357 -0.217178 0.116863 0.0564758 -0.0317786 0.219382 0.00427171 -0.0014368 -0.0816063 0.214925 -0.0914646 -0.0665221 -0.136507 -0.118754 -0.0296787 0.0610437 0.0763167 0.100168 -0.309799 0.018299 -0.0396707 -0.026655 0.209109 0.000790093 0.153618 -0.0398877 -0.164153 0.125154 0.0890386 -0.218298 -0.0230482 0.0202779 -0.179263 0.198398 -0.0114064 -0.220415 0.0616645 -0.0421711 0.0140657 0.0472695 0.15199 -0.111378\nweightContainer_hidden_0_0_to_output_deltas 50 -0.000270421 -0.000207879 -0.000354244 -0.000240481 0.000497344 -0.00162769 -0.00265719 0.000711668 0.000316384 -0.00231867 0.00134312 0.000797465 -0.00070355 0.00468708 0.00125893 -0.000548033 0.000682621 5.62173e-05 -0.00384231 0.000333699 0.00161013 -0.000216694 -0.00065047 0.00177588 -0.000279621 0.00160348 -0.00233056 0.000942209 -0.000318372 1.97684e-05 -0.0021463 0.000493356 -0.00178824 0.00158348 -0.00194487 0.000870129 -0.00400466 -0.00213001 -0.00135814 -0.000546375 -0.00319357 -0.00204631 -0.00102206 -0.000599156 -0.00010308 -0.00047158 -0.00040159 0.00362342 0.00108968 0.000648589\nweightContainer_hidden_0_0_to_output_plasticities 50 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\nweightContainer_hidden_0_0_to_output_weights 50 0.018331 -0.0865791 -0.053692 0.0914351 -0.174866 -0.483997 -0.0297877 0.00339773 0.0753778 -0.0124048 -0.126507 0.0171024 -0.0637052 -0.671093 -0.0722282 -0.0626882 0.012409 -0.0596263 -0.0160657 0.0515984 -0.0568621 0.108657 1.11513 0.00590559 0.115777 0.159473 0.0495451 -0.267678 0.180788 -0.0870261 -0.159353 0.0313966 -0.317018 -0.088328 0.0734796 -0.106597 -0.0882449 0.0704977 0.138618 0.0794593 0.273421 0.0397432 0.0839295 0.0418557 -0.170016 -0.0959572 -0.187629 -0.0361972 -0.078782 -0.25085\nweightContainer_input_to_hidden_0_0_deltas 7200 -7.52859e-05 -1.9703e-05 -1.33206e-05 1.86766e-05 2.02159e-05 5.46696e-05 5.66951e-05 3.59237e-05 0.000144497 5.85831e-05 -2.47005e-05 -0.000111725 -6.0841e-06 -5.6877e-05 -7.36838e-05 0.000243191 0.000123374 -0.000174706 -8.85434e-06 3.0463e-05 -2.63755e-06 0.000100479 -2.51818e-05 -5.67563e-05 7.41244e-05 -0.000118988 9.12121e-05 3.45885e-05 1.81747e-05 -3.47924e-05 -6.54357e-05 2.45731e-05 -8.22835e-05 5.41013e-05 2.15176e-05 5.6382e-05 -0.000105662 1.30241e-06 2.55149e-05 7.80953e-05 2.22063e-05 3.22445e-05 0.000110688 -1.16187e-05 0.000112521 6.46409e-05 -0.000112477 -9.91688e-05 -3.62233e-05 -9.10354e-05 -0.000124315 0.000333669 0.000189185 -0.0002685 4.30233e-05 3.8741e-05 2.32374e-05 6.24772e-05 -6.37166e-05 -7.02688e-05 9.18487e-06 -3.97447e-05 -6.45683e-05 1.44983e-05 -3.33751e-05 4.53656e-05 -2.24336e-05 -2.24287e-05 6.58211e-05 -2.686e-06 -5.7042e-05 2.17986e-06 -8.76244e-05 -1.50416e-05 0.000116103 -0.000180861 -3.38102e-05 -0.000208475 0.000111507 0.000158377 0.000121568 -0.000125768 0.000428533 0.000155742 0.000231764 0.000225714 -0.000209219 -0.00055952 -0.000457656 0.000854178 -0.000199311 0.000170037 -0.000231347 3.35246e-05 0.000122903 -3.18001e-05 0.000214887 -0.000303139 -0.000142825 -2.22746e-05 0.000101418 -9.79885e-06 -5.10205e-05 -4.02745e-05 1.23153e-05 0.000206168 -0.000259242 9.77403e-05 -0.000120585 1.12393e-06 9.5555e-07 8.28065e-06 1.68376e-05 2.92893e-05 8.02568e-05 2.34389e-05 0.000193061 6.46729e-05 -4.40157e-05 -0.00010151 -2.32053e-05 -2.70374e-05 -0.000105795 0.000299472 0.000127862 -0.000190068 -2.20558e-05 7.17262e-05 -1.21086e-05 8.83916e-05 6.22856e-06 -5.47698e-05 2.58363e-05 -0.000130732 4.95549e-05 3.73806e-05 -1.98085e-05 -2.85175e-05 -5.20301e-05 4.22582e-05 -1.16379e-06 2.74154e-05 -4.28278e-06 3.87629e-05 -8.6824e-06 -2.78695e-05 -2.22106e-05 -2.20376e-05 1.49978e-05 5.10414e-05 -1.58218e-05 3.19193e-05 7.43827e-05 -1.08449e-05 -3.67516e-05 -7.36251e-05 -3.73852e-05 3.93268e-05 8.37972e-06 -3.19348e-06 2.22534e-05 7.46213e-06 -1.653e-05 -1.53079e-05 -4.1192e-06 2.5043e-05 -1.20445e-05 7.28181e-06 6.29848e-06 1.18684e-05 1.40099e-06 -1.63426e-05 -1.32186e-05 -8.72946e-06 1.16591e-05 2.89441e-05 -2.98038e-06 -1.47825e-05 8.45491e-06 1.48347e-05 -2.37831e-05 -4.99157e-05 -3.01172e-05 -1.73007e-06 1.23752e-05 1.5627e-05 -3.09408e-07 3.78604e-05 7.34925e-05 -4.24424e-05 -2.23606e-05 -3.55137e-05 -2.27731e-05 3.71102e-05 1.04837e-05 3.27915e-06 1.95218e-05 1.29518e-05 -1.42799e-05 1.00539e-05 3.97645e-06 3.54099e-05 -8.08294e-06 -1.2693e-05 4.53722e-05 -1.13469e-05 -1.90106e-05 -1.22507e-05 8.45765e-06 2.50302e-05 1.37155e-05 -1.92309e-05 -1.98142e-06 -2.02774e-05 -1.36595e-05 1.85956e-05 0.000297057 -7.01269e-05 7.13166e-05 7.73586e-05 -3.92434e-05 8.13019e-05 -0.000136612 -0.00019406 -0.000189924 0.000216913 8.03833e-05 -6.41457e-05 -5.36132e-05 1.71363e-05 -6.78542e-05 -3.86318e-05 6.48835e-05 -6.02323e-05 -4.08831e-06 1.25274e-05 -9.12531e-06 2.28187e-05 -3.91695e-05 -3.71081e-05 -1.73025e-05 -2.0121e-05 -1.68575e-05 -6.29519e-05 5.26938e-05 8.5439e-05 -4.80253e-05 -3.28205e-06 5.08048e-05 8.08619e-05 -9.48421e-06 -6.82486e-05 -1.93115e-05 -5.45206e-05 -5.59564e-05 -1.31152e-05 1.79181e-05 3.7598e-05 -5.64777e-06 4.58976e-05 8.36304e-05 -2.94779e-05 -2.25729e-05 -6.5758e-05 -5.86165e-05 1.91733e-05 2.28829e-05 2.23703e-05 4.08834e-05 -4.42818e-06 -4.51009e-06 -1.43841e-06 1.17682e-05 2.98386e-05 -2.04275e-05 -1.7546e-05 2.41122e-05 -1.40543e-06 -8.96936e-06 -1.53654e-05 3.93282e-06 7.33758e-06 1.72782e-05 7.30289e-06 6.52025e-06 -9.68328e-06 -7.54987e-06 9.39407e-06 8.59689e-05 -7.58824e-05 -6.57348e-05 -7.71478e-06 -3.87523e-05 -6.0111e-05 -0.000140946 0.000166678 0.000252804 0.000108489 -3.08022e-05 -3.16921e-05 -7.19598e-06 -0.000106509 3.34214e-05 -5.72389e-05 4.18545e-05 -5.19332e-05 -6.17551e-05 -6.96288e-05 0.000116552 6.5683e-05 -0.000210529 2.35381e-05 3.66536e-05 0.000234228 5.05601e-05 -0.000211858 0.000107397 5.40241e-05 4.50837e-05 3.13905e-05 -0.00014998 -0.000273981 0.000249431 9.19205e-05 1.30167e-05 -8.15598e-05 -6.67499e-05 -2.83944e-05 -0.000221171 -6.48727e-05 4.36589e-05 0.00027129 0.000100831 -5.56145e-05 2.89529e-05 6.67736e-05 0.0001114 -6.78153e-05 -0.000195035 -9.59478e-05 0.000186386 4.44116e-05 -5.35767e-05 2.48905e-05 -2.51646e-05 -5.03397e-05 0.000105303 6.89855e-05 7.7972e-05 -0.000100729 -0.000176774 -5.40654e-05 9.41094e-06 5.94059e-06 9.30623e-05 0.000165292 -3.02472e-05 6.38814e-05 -4.89917e-05 -0.000101666 0.000196308 -0.00011196 0.000116122 0.000308697 0.000134968 9.45779e-05 -3.65187e-05 6.005e-05 6.81176e-05 -2.29159e-05 -8.8213e-05 -0.000234097 -0.000156329 -0.000196659 -0.000331592 -0.000194812 3.54697e-05 6.74773e-06 -8.20539e-05 -0.000105923 3.6691e-05 -0.000211686 5.33021e-05 0.000129168 -0.000119646 -3.54039e-05 3.98112e-06 9.53799e-05 2.30525e-05 3.67606e-06 -3.15781e-05 7.73523e-05 -0.000216121 -4.67416e-05 0.000226098 2.66104e-05 0.000209217 -3.76197e-05 -0.000113584 -2.05122e-05 -0.000336058 -9.71093e-05 -0.000258799 0.000522932 0.00075671 -6.74467e-05 6.37868e-05 -0.000164128 -7.65062e-05 0.000274681 0.000141395 -0.000439489 -0.000153303 0.00019346 -0.000231317 9.36752e-06 -7.61224e-05 2.10544e-05 -4.45978e-05 8.89228e-06 0.000138944 0.000100186 1.75687e-05 -0.000212223 4.20011e-06 0.000192707 6.63149e-05 -6.34548e-05 -0.0001376 0.000130533 4.25867e-06 -0.000115304 -1.95776e-05 -4.04775e-05 -4.38847e-05 8.00598e-06 6.35869e-05 5.37247e-05 2.7475e-05 2.6185e-05 -2.70285e-05 2.22176e-05 1.44315e-05 1.07866e-06 -2.97419e-05 1.11902e-05 4.59875e-05 -1.23627e-06 -9.7036e-06 -2.52858e-05 -1.86015e-06 -3.45549e-05 3.78418e-06 -4.01596e-06 -4.07293e-05 -6.46861e-06 -1.72646e-05 2.83266e-05 3.84074e-05 5.86865e-05 2.54564e-05 -2.85054e-05 -5.48213e-05 -1.65936e-05 1.70747e-05 3.75542e-06 -1.33222e-05 1.34164e-05 -1.40192e-05 -4.17157e-05 -2.69127e-05 2.03297e-06 -1.53169e-06 3.47094e-05 2.86553e-05 5.08163e-05 3.37086e-05 8.66908e-06 1.33479e-05 1.02605e-05 -2.54477e-05 -3.95143e-05 2.46914e-05 2.08643e-05 2.44174e-06 -1.33437e-05 3.65184e-05 -2.66263e-05 1.11346e-05 -2.04951e-05 -6.7077e-05 9.29469e-06 -1.88527e-05 -3.86381e-06 1.8741e-05 -2.81065e-05 7.29729e-06 8.14043e-06 -3.65237e-05 -2.14951e-05 8.47516e-06 -9.09265e-06 4.65224e-06 5.22952e-05 -0.000123498 3.50522e-05 -8.93988e-05 -3.39006e-05 -4.17371e-05 -5.89341e-05 0.000187768 0.00023838 0.000273628 -9.40016e-05 6.60995e-06 0.000216158 0.000101894 -0.000147848 8.08873e-05 3.03774e-05 -0.000197469 -5.66734e-05 -5.75001e-05 -9.88275e-05 -5.4227e-05 4.82693e-05 -2.72953e-05 4.04319e-05 1.78892e-05 0.000132624 -4.31539e-05 4.89276e-05 8.08552e-05 1.31348e-05 4.27437e-05 -5.13963e-05 -4.24177e-05 -8.38169e-05 -9.87617e-06 -5.84001e-06 -3.37236e-05 -5.76283e-05 -6.19649e-05 2.96778e-05 5.3166e-05 5.76575e-05 3.7072e-05 2.50981e-05 1.17361e-05 7.16897e-07 3.73133e-05 -8.21559e-06 -5.91258e-05 -1.78605e-05 1.36325e-05 2.07844e-05 3.83484e-05 -6.19796e-06 3.60741e-06 1.21612e-07 1.91175e-06 -6.52528e-06 -5.77935e-05 -3.20512e-05 -1.05771e-05 1.27422e-05 2.55375e-05 1.34586e-05 2.07121e-05 -2.22385e-05 -7.59188e-05 -2.51562e-05 3.73868e-06 -1.30765e-05 -2.75628e-05 1.97103e-05 0.000145153 0.000131951 -3.31818e-05 0.000149889 4.27035e-05 6.32353e-05 3.46908e-05 -7.7727e-05 -0.000288686 -7.96924e-05 -6.01648e-05 -0.000101101 -8.72442e-05 -1.68942e-05 8.07395e-05 -0.000186295 -3.27099e-05 0.000102553 0.000139334 0.000120536 -2.37845e-05 4.64091e-05 -0.000103928 -0.000200513 -0.000110165 -2.44987e-05 0.000103406 1.79136e-05 -5.78388e-05 -3.47772e-05 -0.000108373 -0.000115493 0.000154295 0.000129643 -0.000164877 -0.000166119 0.000390454 0.000130987 -2.43105e-05 0.000136338 3.12853e-05 0.000118827 -0.000109825 -0.000123963 -0.00026746 -0.000126685 -0.000188368 -0.000267926 -0.000102807 -0.000108036 1.99539e-05 -0.000151887 -0.000139576 -7.6643e-05 4.9822e-05 2.22352e-05 8.79496e-05 1.27901e-05 -0.000104916 -8.78093e-05 -8.5751e-05 4.27798e-05 9.17007e-05 2.99897e-05 -6.12184e-05 1.75573e-05 -3.46035e-05 -2.17933e-05 6.28256e-05 0.000113136 -0.000101264 -7.36914e-05 0.00116782 0.000146849 -0.000290861 -0.000144049 -0.000405329 0.000123191 -0.00050905 -7.44054e-05 -0.000416813 -0.0002711 -0.000149727 0.000108681 0.000258518 0.000357483 7.78321e-05 -0.000839495 -0.000590455 0.000142894 0.000220628 -9.84917e-06 0.00013112 7.53828e-06 -0.000277224 -0.000121116 0.000175909 0.000122212 -2.60924e-05 -0.000290336 0.00017005 0.000451708 -2.68229e-06 -2.0772e-05 8.91956e-05 0.00015991 -0.000211089 4.77648e-05 0.000231278 3.80603e-05 3.19117e-05 0.000204367 1.09917e-05 4.25357e-06 -8.84151e-05 -3.95671e-05 -0.000175158 -0.00013971 -7.00427e-05 -0.000129098 -0.000164108 1.72395e-05 0.000130856 -6.51459e-05 -0.000104133 1.12478e-05 5.68265e-06 0.000113673 -2.24134e-05 3.22728e-05 1.98796e-05 -8.37967e-05 -8.81506e-05 -5.88179e-05 7.99428e-05 4.2639e-05 -4.78772e-05 6.61661e-05 -7.60628e-05 -9.73964e-05 7.71491e-05 9.73276e-05 -9.84175e-05 -5.41789e-05 1.91933e-05 0.000177143 -0.000382837 3.6233e-05 -8.99396e-05 0.000303309 -0.000198662 0.000159014 0.000553258 -0.0001606 -4.37685e-06 2.42906e-05 5.56719e-05 0.000632367 0.000420544 5.79445e-05 -0.000379878 -5.37982e-05 -0.000163999 -0.000430724 0.000162795 -3.04648e-05 9.04187e-05 0.000223687 2.54294e-05 9.40554e-05 0.000162913 0.00013783 -0.000116817 -4.08418e-05 0.00017775 -0.00016505 -0.000104676 -6.49083e-05 0.000137243 0.00015228 -1.02192e-05 6.5139e-05 -0.000293416 -0.000197057 -0.000102747 0.000199498 -8.09576e-05 0.000346266 0.000724212 4.34182e-05 0.000151168 6.43126e-05 0.000309799 0.000414206 0.000124302 -0.000102403 -0.000188745 -0.000100243 -0.000204778 -0.000305246 0.000197073 -8.73772e-05 -0.000143249 1.9657e-05 3.02543e-05 1.55768e-05 -4.09764e-05 0.000109343 0.000219947 5.65552e-05 0.000281259 -0.000448908 -5.65272e-05 -9.38618e-05 0.000101212 0.000138988 -0.000119492 -0.00017858 0.000188784 -1.74221e-05 0.000178033 3.06751e-05 0.000201699 0.000336554 -6.67518e-05 -0.000203436 -0.000793032 6.86623e-05 0.000626118 0.000271888 -3.74518e-05 -0.000352486 0.000225964 0.000447513 -0.000525871 0.000289717 -1.40628e-05 -0.000257038 0.000192191 -5.86926e-05 0.000183187 -0.000374689 -0.000393368 -9.27384e-05 0.00020023 -8.32341e-05 0.00016754 -0.000382552 -0.000189413 0.000133481 0.000280494 6.76594e-05 -0.000144403 5.94397e-05 -0.000542134 -5.58836e-05 -4.0358e-05 0.000288972 9.12589e-06 0.000472955 0.000736689 -0.000141744 0.000224533 0.000159767 0.000190024 0.000584039 0.000228437 -0.000467028 -0.000609482 0.000163511 -6.08284e-05 -0.000305031 0.000104565 -0.000207291 -0.000141203 -0.000153011 4.86709e-05 3.94757e-05 -3.43201e-05 0.000179865 0.00013367 2.30375e-05 0.000166593 -0.000230856 -0.000117371 5.75343e-05 9.05302e-05 5.00502e-05 -0.000154657 0.000124573 4.08506e-05 -5.66771e-05 -1.05161e-06 -8.72019e-05 5.5717e-05 3.75015e-05 0.000131777 6.26847e-05 0.000125394 8.36719e-05 0.000117009 -1.53012e-05 -0.000149381 -4.01352e-05 -0.000124688 -3.76817e-05 -2.10769e-05 2.53534e-05 3.01022e-05 6.34235e-05 1.56381e-05 -1.02298e-05 2.91463e-05 0.000159757 0.000107336 -1.33839e-05 6.25801e-06 -1.92014e-05 -7.68085e-05 -3.95227e-05 -3.86876e-05 -5.72159e-05 2.31675e-05 5.88649e-06 -0.000104818 0.000135971 0.000105181 -7.47898e-05 -4.57571e-05 -0.000104889 2.11694e-05 5.70288e-05 0.000183908 4.05242e-05 0.000120821 5.25972e-05 2.42552e-05 -2.1574e-05 -0.000131806 -5.95479e-05 -0.00010684 -2.11692e-05 1.34256e-05 -1.12602e-05 1.51925e-06 2.08038e-05 2.34518e-05 6.66326e-06 -7.91307e-05 -9.37615e-06 9.23259e-05 -4.58383e-05 2.78068e-05 -1.35651e-05 -5.08807e-05 3.978e-05 1.91066e-05 9.63725e-06 1.72417e-05 5.62517e-06 -0.00028399 0.000325885 0.000177116 -0.000147685 -0.000221159 -0.000443633 0.000188869 0.000252589 0.000376346 0.000118875 0.000317235 -4.18188e-05 -0.00019412 -8.82264e-05 0.000111829 0.000297194 -0.000261933 -9.71767e-06 -7.2504e-05 -0.000324739 -1.22279e-05 -0.000174022 -0.000244273 -0.000317033 -6.01375e-05 -4.75635e-05 3.07631e-05 -5.96447e-05 0.000124385 0.000420947 0.000266016 0.000108413 -4.54292e-05 5.42599e-05 7.39691e-07 -0.000245654 -0.000106057 0.000104964 8.16577e-05 -3.43889e-05 -4.19768e-05 -9.42375e-05 3.80219e-05 6.81077e-06 0.00014387 1.49359e-05 0.000128997 3.53867e-05 6.20714e-05 -8.40463e-06 -0.000199038 -4.96433e-05 -9.74495e-05 -6.18721e-06 6.21107e-06 4.4991e-05 -3.15454e-05 4.84574e-05 3.07152e-05 -9.81776e-06 -1.61796e-05 3.62016e-05 9.66659e-05 -3.58551e-05 4.46291e-06 1.32817e-05 -6.70944e-05 1.61101e-05 -3.74972e-05 -5.15152e-06 -2.78527e-05 -3.29817e-05 -9.36762e-05 9.25535e-05 -4.15658e-05 0.000111904 0.000102176 4.35994e-06 2.31408e-05 -8.62077e-05 -0.000195081 8.83475e-05 3.27786e-05 1.55724e-05 -5.71324e-05 -4.77775e-05 6.76169e-05 7.30993e-05 -3.26706e-05 2.56803e-05 0.000187485 -0.000193919 0.00011364 -1.45845e-05 -0.000124546 -1.42546e-06 -8.05674e-05 7.45289e-05 3.17806e-05 7.74192e-05 5.67551e-06 -3.25344e-06 0.000171434 8.62409e-05 -5.17539e-05 -8.46279e-05 4.19574e-05 -7.01743e-06 0.00023676 2.11102e-05 -2.78486e-05 0.000124428 -3.56684e-05 9.23316e-05 -0.000127014 0.000105255 7.13002e-05 -1.20185e-05 -1.66062e-05 5.02061e-05 -2.57757e-05 0.0001775 4.12031e-05 -0.000201123 -0.000138553 8.57411e-05 7.83434e-05 -4.39621e-05 1.75547e-05 2.31576e-07 -6.26069e-05 3.18499e-05 -5.65442e-05 5.77659e-05 0.000123566 -9.86611e-05 2.21931e-05 6.16107e-05 6.54958e-05 0.000128174 -3.13021e-05 -0.000105863 -9.6236e-05 -1.51887e-05 0.000304418 0.000189375 -0.000227459 -0.000214745 -0.000217658 0.000205417 -0.000640498 0.000134265 0.000754449 -0.000174605 9.24091e-05 -2.14605e-06 0.000323523 0.000599041 0.000418786 -0.000483241 -0.000385201 0.0002976 9.7456e-05 -0.000293346 -2.16985e-05 7.00088e-05 -0.00011316 -0.000147901 0.000114542 1.556e-05 -6.13565e-05 -5.0305e-05 0.000158665 0.000168921 0.000170073 -4.25059e-05 -8.44372e-05 0.000141009 0.000124207 4.91285e-05 4.97268e-05 2.78152e-05 -6.56422e-05 0.000181671 3.04418e-05 3.97415e-05 3.6362e-05 1.66041e-05 -0.000117893 -3.17617e-05 -7.71759e-06 9.62578e-05 2.86919e-05 6.82149e-05 1.62303e-05 -0.000107465 -0.000148121 4.35284e-05 4.59951e-05 5.758e-07 5.28627e-05 -2.20147e-05 -7.48559e-05 -7.2335e-06 -3.42648e-05 1.26611e-05 4.69104e-05 -1.85773e-05 2.45615e-05 5.04834e-05 4.73123e-05 8.16177e-05 -5.20292e-05 -5.86767e-05 -3.98476e-05 2.7769e-06 -0.000130047 0.000102108 0.00021782 7.34221e-05 -7.2001e-06 1.1836e-05 0.000276277 2.45222e-05 -2.22381e-05 3.26277e-05 7.1537e-05 0.000151455 2.35871e-05 -0.000250809 1.93849e-06 0.00015627 3.35308e-06 -0.000427901 1.0639e-05 -0.000103306 6.04414e-05 -0.000206991 1.67569e-05 0.000148603 -4.57456e-05 0.000102229 0.000156173 -8.00003e-05 7.2741e-05 -0.000127769 -4.34441e-05 0.00029574 -5.40879e-05 -8.76072e-06 -8.13445e-06 3.71546e-05 -6.4651e-05 -5.57453e-05 0.000197529 -1.24106e-05 -1.75908e-05 0.000119045 0.000158089 0.000237774 4.39836e-05 -1.78495e-05 0.000112106 0.000103671 -3.01869e-05 2.53849e-05 4.08358e-05 1.6264e-05 5.01414e-05 -0.000184309 -3.08922e-05 -7.00303e-05 6.60086e-06 -0.000100609 3.85884e-05 0.000126124 -9.50293e-05 3.53404e-05 3.82012e-05 -1.38249e-05 -3.52618e-05 -6.02228e-05 6.93445e-05 0.000215627 -1.19015e-05 4.66854e-05 -4.96871e-05 5.34834e-05 -6.56646e-05 5.36515e-05 -3.80483e-05 -0.000334472 -0.000265642 -7.55615e-05 1.19091e-05 0.000317824 0.000216129 -0.000185864 0.000156743 9.27834e-05 0.000124056 0.00031787 0.000196324 -0.000208656 0.000210195 0.000535805 5.00296e-05 -0.000311667 9.47457e-05 -0.00017748 -0.000163142 1.39137e-05 7.07156e-05 0.000157632 4.6295e-05 -9.48657e-05 9.18613e-05 0.00011359 0.000148583 3.84584e-05 -0.000151329 -1.00711e-05 0.00011832 -3.11402e-05 -0.000126021 -4.93424e-05 0.000277233 2.81047e-05 -3.47715e-05 7.70905e-05 0.000260423 0.000230071 4.78094e-06 -6.94932e-05 9.38159e-05 0.000200181 -4.17903e-05 -4.6359e-05 5.59126e-05 3.56062e-05 -7.4646e-05 -0.000341337 -2.44241e-05 -6.69401e-05 -1.20189e-05 -0.000124624 -9.80895e-06 0.000143026 -5.92243e-05 0.000122895 3.57415e-05 -0.000104932 3.52088e-05 -0.000109384 -9.51705e-07 0.000189173 1.93504e-05 2.066e-05 -1.54834e-05 0.000147313 5.81822e-06 9.61959e-05 -6.16594e-06 5.0309e-05 -5.90682e-05 -8.71273e-05 -1.26114e-05 -2.38499e-05 -0.000133664 -3.52772e-05 -1.75063e-05 0.000116842 0.000130011 4.84603e-05 -5.16719e-05 -0.000206909 -1.12579e-05 0.000397141 -2.23131e-05 4.58473e-06 5.02666e-05 -7.37181e-05 -4.18793e-06 3.56762e-05 4.89587e-06 0.000129671 -6.06586e-06 -6.26618e-05 -1.84255e-05 -0.000159175 4.21474e-05 2.74568e-05 -1.86697e-05 -4.20713e-05 3.57638e-05 -3.66673e-06 -1.77054e-05 0.000121966 -2.60311e-06 4.26947e-05 -7.14096e-05 -8.40894e-05 -4.90579e-06 2.02995e-05 -7.80249e-06 -6.13437e-06 1.52537e-05 3.28565e-05 0.000180535 2.49215e-05 -0.000102239 -0.000175716 -8.24416e-05 0.000145949 6.67226e-05 2.15898e-05 -5.12165e-08 -7.71955e-05 3.75145e-05 7.86399e-05 -4.49469e-05 1.90396e-05 7.92758e-05 -1.43464e-05 1.59192e-07 -2.46073e-05 -4.71827e-05 -0.000118277 -6.47807e-05 6.21338e-05 -4.36631e-05 -0.000239781 0.000319514 1.78737e-05 -0.000316547 7.66488e-06 -0.000170418 -5.00845e-05 -0.000111567 9.25686e-06 3.11667e-05 -0.000446011 -0.000424107 9.80651e-05 0.0003359 0.000272437 -5.30827e-05 -0.000206132 -0.000309877 -2.83554e-05 0.000345776 -0.000110069 -0.000173097 -0.000115222 0.000160616 0.000164543 -0.000225583 4.70694e-06 0.00025705 -0.000188467 -1.27785e-05 5.16075e-06 -0.000110941 0.000188247 -1.73202e-05 -3.33011e-05 0.000121001 0.00031985 3.68938e-05 8.35429e-05 1.30382e-05 4.68824e-06 -5.96287e-05 -9.51803e-05 -4.46688e-05 -9.41293e-06 -0.000155587 -8.15737e-05 -6.91982e-05 -2.64838e-06 0.000173779 6.22351e-05 3.18108e-07 -0.000300547 -1.74232e-05 0.000401059 5.2792e-05 -5.35e-06 5.52906e-05 -4.73351e-05 -2.80795e-05 5.55376e-05 -3.66885e-05 0.000148536 6.92888e-05 -4.37391e-05 7.48674e-06 -0.000163438 -5.80401e-05 -3.72194e-05 -4.08603e-05 4.92984e-05 8.70324e-05 -0.000140601 -0.000103133 -2.69023e-05 0.000246386 -0.000277832 -0.000113338 8.35151e-05 0.000203168 3.64675e-05 0.000167052 -8.46539e-05 0.000101281 6.64291e-05 5.25172e-05 4.498e-05 -0.000261783 0.000227593 0.000278839 5.35661e-05 -0.000127627 9.07952e-05 0.000172048 -0.000129074 5.63215e-06 1.22097e-05 2.79286e-05 -7.80362e-05 -0.000103368 -8.31301e-05 0.00014218 4.89396e-05 -0.000137437 -7.55416e-06 0.000214919 -5.12525e-05 -6.49822e-05 -3.17177e-05 -9.61997e-05 -1.63118e-05 4.61497e-05 -0.000191481 -9.49895e-05 7.12972e-05 0.000124082 2.10109e-05 0.000213193 2.53884e-05 7.77666e-05 2.17481e-05 -6.90435e-05 0.000106555 6.63372e-05 0.000115786 9.16179e-05 8.01413e-05 -6.77484e-05 0.000119057 -0.000134936 9.92664e-05 5.01124e-05 -3.92317e-05 -1.98146e-05 -2.72368e-06 3.03123e-05 5.19677e-06 -9.32314e-05 4.56713e-05 -5.49779e-06 5.55113e-05 0.000213393 -7.06639e-05 -0.000152756 9.75634e-05 0.000541555 -0.000234191 -3.46866e-05 0.000304047 -6.09969e-05 0.000402261 2.16342e-05 -3.91023e-06 -0.00065014 -0.000457409 -0.00056238 0.000233632 8.93838e-06 -0.000306042 0.000499374 2.85636e-05 0.000344673 -0.000332862 4.57542e-05 -0.000268719 0.000286123 -0.000224844 2.6496e-05 0.000106604 -6.17883e-05 3.55179e-05 8.21081e-05 -0.000188583 -7.70923e-05 2.33396e-05 0.000167678 -0.000197444 -0.000190118 -0.000196119 0.000221069 0.000409926 -0.000523799 0.000282599 0.000361188 -0.000187846 4.13134e-05 4.50552e-05 0.000221738 -1.01296e-05 4.35185e-05 -6.64412e-05 0.000223087 0.000149938 0.000132293 -1.97017e-05 5.18791e-05 4.21452e-05 -7.23511e-05 -0.000223716 -7.51256e-05 -8.26761e-05 -7.67782e-05 -1.62046e-05 0.000142403 -1.81483e-05 -0.000130227 -9.79476e-05 0.000105097 7.61723e-05 0.000111579 3.74023e-05 -3.49654e-05 2.8803e-05 0.000145015 -5.89562e-05 -3.69072e-05 0.000198019 -1.28607e-05 -3.40895e-05 5.38643e-05 -3.99171e-05 -0.000101793 0.000100601 6.486e-05 -8.76822e-05 -0.000159636 2.61949e-05 9.85078e-05 0.00014116 0.000174767 1.10787e-05 -2.14453e-05 0.000116168 8.5292e-05 -0.000187111 -8.56714e-05 -6.05729e-05 0.000152898 -9.71293e-05 -1.2471e-05 -0.00010051 0.000100402 0.000195838 1.19373e-05 9.43207e-05 -0.000174832 5.93853e-05 0.000130571 -0.000193208 4.20828e-06 -3.31956e-05 9.63227e-05 0.000153751 -0.000161444 -4.02212e-05 0.000132758 -3.74353e-05 1.06129e-05 -4.98904e-05 0.000272731 4.91902e-05 -0.000210204 0.000206579 7.00662e-05 0.000156861 0.000217904 -8.73172e-05 -0.000156279 -5.61247e-05 0.000130559 -4.59426e-05 -3.25175e-05 -3.02627e-05 -2.63261e-05 3.08162e-06 0.000104081 9.97341e-06 -1.19071e-05 -2.63378e-05 7.32353e-05 7.89152e-07 -0.000168846 -9.279e-05 -4.31765e-05 -3.83287e-05 9.60732e-05 -1.12347e-05 -6.52573e-05 0.000102924 -8.67994e-05 0.000161742 -0.000157174 -0.000243108 -0.000101177 2.17649e-05 -0.000323227 2.34957e-05 0.000343448 -3.54738e-05 0.000320518 -0.00027318 -0.0001561 0.000760158 0.000239015 -0.000578173 -0.000414621 0.000604211 1.05955e-06 0.00010273 6.3047e-05 -1.95891e-05 -1.26675e-05 -0.000183266 -0.000118552 -0.00021252 -0.000177392 0.000366037 -0.0001561 -0.000178677 -5.84976e-05 -1.18013e-05 0.00032321 6.04556e-05 5.0181e-05 -0.00025232 -0.000129261 7.34995e-05 0.000173355 -0.000245359 -0.000250276 -3.9221e-05 0.000229426 0.000136756 -4.35362e-05 0.000132998 0.00021228 0.00015599 0.00025718 -2.54268e-05 -1.60603e-05 -5.29398e-05 2.20399e-05 -1.94908e-06 -5.01857e-05 -3.24313e-05 2.37934e-05 -1.72166e-06 6.99893e-06 -0.000105976 5.12557e-05 9.51648e-05 5.97928e-05 0.000108301 -0.000138772 3.95766e-06 4.41802e-05 -0.000204125 2.96868e-06 -3.51449e-05 4.32496e-05 0.000184187 -0.000159287 -0.000107359 0.000225444 -5.25995e-06 -0.000216 -0.000346321 -4.09213e-07 7.19855e-05 5.94458e-05 6.04747e-05 0.000167604 -7.6036e-05 5.99962e-05 -0.000262742 -0.000142559 0.000298763 0.000515564 -8.55431e-05 0.000154854 6.57155e-05 -0.000115946 5.41483e-05 -0.000146448 -7.41438e-05 6.04084e-05 3.37799e-05 0.000105541 -1.25996e-05 -0.000111262 -8.92044e-06 4.89232e-05 -5.79734e-05 4.76001e-05 -4.51212e-06 1.17738e-05 -8.43558e-05 -7.03504e-05 -1.9667e-05 6.42014e-05 3.03398e-05 2.08679e-05 -5.6895e-05 4.42172e-05 1.30945e-05 -5.94825e-05 -1.96798e-05 5.49434e-06 4.96695e-05 0.000135238 -2.36384e-05 -7.70231e-05 3.29343e-05 3.46793e-05 2.27108e-05 2.32213e-05 9.69223e-07 -1.90389e-05 -1.23099e-05 -5.63651e-06 -1.83417e-05 1.17792e-05 2.24631e-06 9.23223e-06 2.4125e-05 -2.06947e-05 -5.40899e-05 2.28541e-05 1.10128e-05 -5.27451e-06 -4.88445e-05 -3.69072e-05 4.81701e-05 4.2669e-05 -2.2887e-05 6.52275e-05 -2.54602e-05 0.00013546 6.81642e-05 -2.66915e-05 0.000120476 0.000100787 2.1667e-05 -0.000291353 -0.000396503 -0.000117772 -0.000353717 -0.000144537 -1.93251e-05 0.000199181 -0.000165701 9.01838e-05 -1.32826e-06 0.000126911 -9.66658e-06 -7.85154e-05 -3.95716e-05 -0.000158599 6.39687e-05 7.71249e-05 2.34782e-05 -2.2266e-05 -0.000139824 5.88479e-06 3.33895e-05 -0.000192136 -2.84877e-05 0.000231817 8.6191e-05 5.63613e-05 -5.21872e-05 -3.43381e-05 0.000119573 1.24175e-05 -2.96933e-06 -9.55259e-05 6.89284e-05 8.6702e-05 -7.56177e-05 -2.85859e-06 -8.79328e-06 6.22767e-06 5.43466e-05 -1.71057e-05 -3.64424e-05 -6.06855e-05 1.3165e-05 -3.38281e-05 2.09733e-05 -2.64232e-05 1.84727e-06 1.30312e-05 -1.52425e-05 1.48218e-06 -5.37054e-05 1.21777e-06 6.81578e-05 7.6146e-06 3.36771e-05 4.16375e-05 -2.8539e-05 -4.4083e-06 3.07154e-05 -2.32227e-06 9.11429e-06 -2.80173e-05 0.000353037 -0.000175194 -0.000305447 -8.82926e-05 6.19679e-05 -9.27347e-05 0.000319227 0.000891985 0.000171445 -0.000309401 -0.000658181 -9.91884e-05 0.000554855 0.000134168 -3.91792e-06 -9.35391e-05 -0.000210661 -0.000596967 0.000611437 -0.000312503 5.47454e-05 0.00038362 -7.00553e-05 0.000295865 -0.000316146 -0.000178529 6.89542e-05 -0.000282668 6.22589e-05 0.000113456 -0.000219077 7.73632e-05 0.000210134 -6.35614e-05 9.63174e-05 -0.000485042 0.000493737 -0.000168434 -0.000975206 -0.000575511 -0.000366084 0.000101598 0.000396869 0.00123473 0.000377845 5.60991e-05 -0.000324214 0.000548224 0.000449552 0.000186048 9.30264e-05 -2.07717e-05 3.12159e-05 -0.000459669 0.000403658 -5.35814e-05 4.05254e-05 0.000291634 -9.17574e-05 0.000138354 -0.000431732 -0.000401597 -9.95059e-05 6.69555e-06 0.000113809 0.000203488 -0.00015196 7.94026e-05 8.73151e-05 8.48428e-05 -0.000110396 0.000629651 -0.000582567 -0.000145352 0.000248003 -0.000137753 0.000411963 -0.000123034 7.07219e-05 -0.000894105 -0.000820478 -0.00101635 -0.000176368 0.000396584 -2.06991e-05 0.00021621 -0.000366564 0.00065128 -1.5432e-05 0.000461779 -0.000378016 0.000173016 -0.00021373 -0.000299361 7.01855e-05 -0.000193964 0.000506899 0.000384171 0.000181443 0.000123386 -9.20758e-05 -0.000353217 0.000177108 6.80834e-05 -0.000210937 0.000399946 0.000150376 -0.000500068 -1.18516e-05 -0.000350081 -0.000146142 9.1367e-05 5.35848e-05 0.000198414 0.000538337 0.000902725 8.01736e-05 -4.33401e-05 -9.44627e-06 0.000321374 0.000364428 0.0002084 1.6806e-05 -9.02571e-05 -2.48078e-05 4.44602e-05 -0.000211292 -0.000111742 -0.000306258 -8.02586e-05 0.000111542 -8.36588e-05 -0.000156901 -7.76191e-05 0.000153879 4.22398e-05 -9.41884e-05 0.000196767 -4.04032e-05 2.67297e-07 0.000141246 0.000195631 -0.000128955 -2.22014e-05 -4.19082e-05 2.82617e-05 -7.61443e-05 -2.93676e-05 4.23168e-05 1.48754e-05 7.93814e-05 8.14959e-05 6.92739e-06 -7.02012e-05 -4.79671e-05 -5.17677e-05 -6.87964e-05 -1.63562e-05 2.5822e-05 9.59062e-05 2.45033e-05 -4.07824e-05 0.000117749 -1.73343e-05 3.55288e-05 -6.34012e-05 -3.08096e-05 2.63797e-05 -2.73532e-05 -2.62539e-05 -8.22348e-06 5.39674e-05 -3.74276e-05 -1.31615e-05 -6.72535e-06 -5.07343e-05 7.39838e-05 1.2843e-05 -3.26038e-05 -5.95364e-06 2.77769e-05 5.80435e-05 -1.96511e-05 -2.74232e-05 5.10583e-05 -2.68844e-05 3.32322e-05 5.51208e-05 7.89438e-06 -8.48264e-06 -9.79248e-05 -4.76089e-05 -2.6036e-05 -1.12896e-05 4.89317e-05 7.37905e-05 -6.24564e-05 -4.63208e-05 6.26139e-05 -1.64157e-05 4.49008e-05 4.50981e-06 -2.73047e-05 1.75414e-05 -4.90741e-05 -1.51202e-05 3.99713e-05 3.58244e-05 9.59794e-07 1.79864e-05 5.20828e-05 1.209e-05 4.03265e-05 -3.33285e-05 -7.29291e-05 0.000237589 -0.000160719 -0.000264486 -3.3508e-06 -0.000204483 4.29227e-05 -1.56099e-05 6.59562e-05 -3.19338e-05 -0.000150838 -0.000302537 1.60361e-05 0.000117394 0.000144916 0.000349802 -0.000230191 -5.95158e-05 4.61058e-05 7.74231e-06 -0.000153502 3.13102e-05 0.000118287 -0.000101331 -9.04359e-05 3.60155e-05 0.000372602 0.000145081 -0.000171317 -1.95228e-05 -5.35498e-05 1.14014e-05 3.15448e-05 0.000105378 8.50944e-05 0.000190341 0.000147154 -2.8411e-06 -4.08977e-05 1.98943e-05 -3.61858e-05 -2.874e-05 3.45305e-05 -3.45161e-05 9.79279e-05 0.000125575 -2.45255e-05 -8.19631e-05 -0.000123131 -7.31377e-05 -1.44598e-06 2.46527e-05 7.0179e-05 0.000112098 -6.35492e-05 -3.19485e-05 9.34219e-05 -1.29944e-05 5.97346e-05 -1.14437e-05 -2.05785e-05 8.56408e-06 -5.13452e-05 2.60754e-06 -2.19851e-05 2.97331e-05 -4.94551e-05 -1.49418e-05 1.71143e-05 -1.92951e-06 9.98554e-05 -1.87764e-05 -7.58655e-05 4.01423e-05 7.82321e-05 -0.000108252 -8.59029e-05 0.000222001 0.000205311 3.75155e-05 -0.000148354 -0.000274998 -4.36046e-05 4.73704e-05 8.09841e-06 0.000124591 0.000168299 -6.14551e-05 -0.000201227 -8.67136e-05 3.75214e-05 5.94815e-05 7.26843e-05 8.94635e-05 -0.00017518 0.000122233 0.000113494 4.99934e-05 -0.000242497 -0.00010932 0.000106912 0.000146224 3.80823e-05 -5.30098e-05 2.72191e-05 -3.55064e-05 -2.3562e-05 -0.000133407 0.000131532 8.43114e-06 3.93367e-05 -1.49502e-05 -0.000164963 0.000244149 0.00015064 8.88675e-05 -0.000140463 -0.000240471 -2.53109e-05 0.00013871 5.27228e-05 7.01389e-05 7.79907e-05 6.03797e-06 -0.000138834 -5.38517e-05 5.15489e-05 -2.67703e-05 7.15023e-05 0.000109036 -5.09535e-05 -5.71806e-05 -1.44253e-05 7.25265e-05 -3.22433e-05 -2.52956e-05 0.000103896 6.82645e-05 -1.22321e-05 -0.00010266 -0.000124132 0.000126021 2.75617e-05 -8.9874e-05 7.1362e-05 0.000242734 -5.36034e-05 -0.000158265 0.000381574 7.12131e-05 2.24271e-05 -0.000181208 -0.000354575 -0.00040846 2.10415e-05 -0.000327968 0.000338553 0.000268274 -9.68387e-05 -0.000137419 -0.000286869 0.000106252 0.000107172 0.000147979 -7.39545e-05 5.36982e-05 0.000119594 1.55525e-05 -7.81564e-05 -0.000163761 0.000271895 0.000132799 -0.000133714 4.24136e-05 4.96464e-05 -4.72162e-05 0.0002427 -3.47063e-05 -0.000345848 0.000162029 4.66844e-05 0.000116002 -4.06435e-05 -0.000122225 -0.000248498 0.000106354 0.000267799 6.67903e-05 0.000126578 -0.000151397 -0.000245328 0.000178893 -3.08143e-05 0.000211658 0.000297909 -0.00015116 -0.000388985 -7.16383e-05 0.000302441 -0.000229129 0.000182677 -1.88138e-05 -0.000182377 0.000191816 -7.07156e-05 4.93038e-05 -0.000280536 -0.000150757 0.000190294 8.41764e-05 9.77873e-05 -0.000131035 -8.97183e-05 0.000120691 0.000139047 -8.92485e-05 0.000133121 6.41663e-05 -0.00011291 7.84029e-07 -2.63477e-05 7.60657e-05 0.000162039 -0.000190047 1.54624e-05 0.000174012 1.64093e-05 -6.73875e-05 -0.000312016 -0.000193899 0.000141088 3.31472e-05 5.21599e-05 0.000205398 -2.31265e-06 -1.98245e-05 6.2171e-05 2.51204e-05 -5.4512e-05 -5.74916e-05 -2.60907e-05 5.11185e-05 -9.24584e-05 -2.52227e-05 -9.21374e-06 2.02471e-05 7.22635e-05 -3.93772e-05 -4.81707e-05 1.74039e-05 5.57179e-05 -4.0622e-05 2.85302e-06 3.62337e-05 -4.65796e-05 5.48735e-05 -4.71571e-05 2.37295e-05 0.000103893 -0.00010505 -4.23983e-05 0.00010508 -5.15562e-06 -0.000111049 -0.000244863 -0.000245933 -1.69859e-05 0.000133976 0.00016338 0.000137833 -6.75972e-05 -3.24619e-05 0.000111235 -1.19623e-05 -4.27686e-05 -3.22988e-05 -3.82615e-05 0.000138458 8.55151e-06 -8.99504e-05 -6.4754e-07 -4.79937e-06 0.000119178 0.00012234 -0.000125087 -7.38347e-05 -4.79613e-05 -3.23106e-05 -3.45355e-05 -0.000150252 0.000154015 4.2989e-05 -1.57397e-05 0.000124533 -6.27718e-05 0.000360548 0.000356574 0.000206503 -0.00018455 -0.000107208 -0.000207123 -1.94564e-05 1.96407e-05 -0.000270502 0.000206163 -1.37993e-05 0.000197069 -6.03088e-05 1.74075e-05 -4.21372e-05 -2.88044e-05 0.000181771 6.76008e-05 -6.02487e-05 -0.000376366 -0.000183999 0.000197735 -1.07199e-05 -0.000130032 6.79318e-05 6.16436e-05 -9.87592e-05 -7.82571e-05 -3.22838e-05 -0.000154988 0.000117281 -0.000143485 5.30718e-05 -5.09126e-05 0.000101486 0.000162874 -0.000262135 1.96263e-05 0.000279766 6.37832e-05 -0.000127206 -0.000461491 -0.000320715 0.000122874 0.000121989 5.05596e-05 0.000189488 -4.50292e-05 -7.79388e-05 0.000103786 9.15974e-06 -4.20956e-05 -7.41934e-05 -0.000112103 0.000100829 -7.33134e-05 -6.4954e-05 3.83071e-06 3.00797e-05 0.00012088 6.47974e-05 -0.00010471 1.8066e-05 7.75648e-06 -2.842e-05 -5.46107e-05 2.45133e-05 1.46736e-05 -3.92451e-05 7.21636e-05 -2.05416e-05 -6.84161e-05 -2.77447e-05 -2.10056e-05 -1.58218e-05 -8.56062e-05 -7.78395e-06 -3.58117e-05 -2.34796e-05 2.37444e-05 -1.15816e-05 3.89671e-05 3.44572e-05 -6.34242e-06 -5.08676e-05 -4.33123e-05 6.48424e-06 6.61816e-07 -6.83848e-06 3.22999e-05 7.41732e-05 -2.2404e-05 -5.01993e-05 -1.67452e-05 2.47971e-05 3.39933e-05 -1.95379e-06 -1.46715e-05 4.47678e-05 1.5816e-05 -1.6679e-05 -2.19197e-05 -1.85089e-05 -2.75323e-05 -6.85744e-05 6.27093e-05 8.02814e-06 -2.24574e-05 1.90844e-05 -3.97245e-05 -6.20226e-05 -4.22465e-05 3.43246e-05 4.30093e-05 -1.81799e-05 -1.06933e-05 -7.31793e-06 3.77469e-05 1.67968e-05 -4.42822e-06 1.79895e-05 -3.31317e-05 -1.10187e-05 -2.18159e-06 -3.14865e-05 2.13339e-05 1.22246e-05 1.56581e-05 -2.84501e-06 9.7899e-06 1.38724e-05 1.01819e-05 -1.54512e-05 2.01458e-05 6.33596e-05 -2.1764e-05 -2.23823e-05 -1.52211e-05 9.89104e-05 2.62431e-05 0.000205914 -4.02936e-06 -0.000123161 -0.000192688 -5.44045e-05 -0.000145477 6.67534e-05 0.00016554 9.4015e-05 -1.84196e-05 1.2655e-05 -0.00025338 -0.000328895 8.9703e-05 3.96551e-05 5.11512e-05 -0.000245927 0.000228825 8.55699e-05 -4.00903e-05 0.000232693 4.23995e-06 7.72396e-06 -0.000111739 -0.000177709 -2.07561e-05 -4.79505e-05 -8.5014e-05 -3.31068e-05 -0.000134003 -8.13173e-05 0.000165239 -4.17431e-05 -0.000135112 3.53032e-05 -1.55837e-05 -3.52384e-05 9.50727e-05 -3.10474e-05 -6.55082e-05 -5.89911e-06 -1.10357e-05 -3.71561e-05 -0.000102137 -2.49557e-05 -2.48687e-05 -2.04814e-05 1.77367e-05 -2.18897e-05 1.19018e-05 1.33005e-05 -1.21571e-05 -1.30394e-05 -2.82885e-05 1.34346e-05 -1.68659e-05 -4.59771e-05 3.72853e-05 5.02246e-05 2.50837e-07 -2.49004e-05 -3.96073e-06 6.02621e-06 5.04657e-05 -1.30222e-05 -3.19984e-05 5.3008e-05 6.29723e-07 -6.17528e-05 -2.22838e-05 0.000137124 3.60812e-05 -5.37468e-05 2.3791e-05 1.36581e-05 9.57187e-05 -0.000133507 0.000107781 0.000123835 7.10676e-06 -6.05856e-05 -8.4623e-05 7.64133e-06 0.000208354 0.000141715 -0.000166824 -0.000156096 4.76199e-05 -4.75819e-05 -1.92966e-05 -6.69957e-05 -6.95599e-05 2.60174e-05 5.72474e-05 -3.23248e-05 3.43788e-05 7.0868e-05 -0.000126859 8.81004e-05 1.0533e-05 -8.9984e-06 0.000124698 1.21104e-05 5.84639e-05 1.627e-06 3.18937e-05 8.46918e-05 0.00012688 -6.00491e-05 4.74155e-05 6.51393e-05 0.00010481 -0.000124748 5.7666e-05 5.93905e-05 -6.45679e-05 3.65223e-05 -2.06328e-05 -8.94866e-06 0.000127383 5.93026e-05 -0.00014622 -0.000118682 4.26986e-05 -0.000108386 2.85875e-05 3.51524e-06 -1.97034e-05 -5.04104e-05 -1.29472e-05 3.60869e-05 -8.78123e-05 -5.03111e-05 -8.77312e-05 0.000108798 5.23246e-05 -2.04921e-05 -6.26904e-07 -1.54449e-05 4.27055e-05 2.12243e-05 -4.8339e-05 -0.000123373 4.81346e-05 3.70789e-05 -1.04413e-05 -1.17116e-05 -0.000259365 0.000139044 3.0395e-05 0.0001546 -7.88751e-05 -2.59605e-05 7.73541e-05 2.68803e-05 -0.00021466 -0.000161116 0.000264064 0.000166038 9.57932e-05 -0.000149728 4.17176e-05 -8.90429e-05 -2.79755e-05 0.00010712 1.52752e-05 3.65722e-05 -6.8575e-05 -4.74078e-05 4.62388e-05 2.11992e-06 -7.52617e-05 2.02483e-05 1.67505e-05 -0.000172502 -8.99073e-05 5.27999e-05 6.03385e-05 0.000150385 7.79572e-05 -9.35873e-05 -1.3159e-05 -1.23601e-05 8.52937e-05 -0.000159705 0.000144065 0.000173532 -4.18942e-05 -5.61672e-06 -1.3034e-05 1.88947e-05 0.000181645 0.000129754 -0.000176125 -0.000140264 5.8167e-05 -0.000111315 1.65545e-05 -3.6807e-05 -3.7865e-05 -5.49446e-06 -1.01334e-06 5.35661e-05 -1.75489e-05 -2.98067e-06 -9.58206e-05 9.12022e-05 3.56906e-05 2.53603e-05 3.12519e-06 -6.83911e-05 5.6557e-05 5.00442e-05 -6.16216e-06 -2.73432e-05 6.82499e-05 1.6925e-06 -4.20911e-05 -2.73872e-05 -1.4603e-05 -7.56638e-05 -8.19672e-05 0.000172262 0.000147293 2.61197e-05 -4.56876e-05 -7.46068e-05 0.000105398 6.35816e-05 7.57543e-05 -0.000171004 -0.000181094 -5.21387e-05 0.00012232 -0.000103305 -8.90638e-05 1.65104e-05 -1.48287e-05 1.13038e-05 -0.000104378 -9.58782e-05 6.63517e-05 5.53269e-05 -1.04274e-05 -2.63287e-05 -3.97319e-05 8.82453e-05 5.25599e-05 -4.0851e-05 -6.74279e-05 -1.76114e-05 6.1225e-05 -6.69982e-05 -0.000124212 -5.22955e-05 -1.68603e-05 -6.0016e-05 -4.41297e-05 0.000143548 0.00017319 2.77372e-06 -1.95635e-05 4.66502e-05 6.58895e-05 0.000124166 6.07286e-05 -0.000203586 -0.000164193 -1.34051e-06 1.82888e-05 2.80231e-05 -5.10647e-05 2.93041e-05 5.68112e-05 1.0098e-05 1.4813e-05 -5.18495e-05 -2.18951e-05 2.82701e-05 2.02481e-05 4.47269e-05 -4.84951e-05 -1.20642e-05 -9.71251e-06 7.04157e-05 -4.29345e-05 -0.00015662 -5.42645e-05 5.50979e-05 -7.06127e-05 -0.000100513 -0.000100811 0.000159087 0.000190623 0.000148062 0.000100145 0.000157132 -0.000118037 -0.000190489 0.000208957 0.000158696 9.30154e-05 8.12109e-05 0.000173447 -0.000208715 4.7189e-05 -3.30994e-06 6.68414e-05 1.08448e-05 2.76958e-05 0.00015688 -0.000102501 2.62991e-05 6.01762e-05 -4.78783e-05 5.02939e-05 -2.67917e-05 -5.59488e-06 0.000151859 8.43312e-05 -0.000146246 8.39337e-05 -9.85549e-05 0.000288021 2.56548e-05 1.68674e-05 -8.12945e-05 -0.000134885 -7.93961e-05 -0.000158023 0.000181242 0.00018701 7.34995e-05 8.9682e-06 1.88687e-05 -9.08705e-05 0.000131229 0.000178496 -0.000282969 -0.000285695 -0.00010788 0.000162834 -5.69926e-05 -4.65737e-05 0.000119711 2.71536e-05 1.10799e-05 -0.000126868 -0.000158963 4.09665e-05 5.25241e-05 3.39076e-05 -1.49463e-05 -5.32206e-05 0.00011619 9.68908e-05 -1.90916e-05 -0.000135055 1.52453e-05 1.72669e-05 -1.09946e-05 5.6289e-05 -4.40777e-05 -5.31411e-05 -3.53813e-05 1.38224e-06 4.43502e-05 -3.12417e-05 3.72802e-05 4.40761e-05 1.59906e-05 -2.91072e-05 1.09958e-05 -3.64756e-07 -6.94672e-06 7.58569e-06 -3.21622e-05 4.96934e-05 -0.000104272 -2.84735e-05 1.91403e-05 -1.64506e-06 0.000126945 1.8067e-05 -8.23275e-05 2.96678e-06 2.61578e-06 2.26018e-05 2.21001e-05 -9.51767e-06 2.42998e-05 0.000137554 1.04165e-05 -9.97651e-06 -5.9849e-05 3.18303e-05 -3.83861e-05 0.000119057 4.8712e-05 -2.1923e-06 4.65404e-05 -1.27473e-06 2.34019e-05 3.94579e-06 9.85393e-06 6.16847e-06 -7.75926e-05 -8.18712e-05 -1.79165e-05 8.98096e-05 6.24219e-05 6.21139e-05 -4.64153e-05 7.94927e-05 -1.36457e-05 -4.52658e-05 3.71952e-05 2.13301e-05 3.27245e-05 -5.61782e-05 -2.16424e-05 4.69007e-05 4.53013e-06 1.73559e-05 -2.93586e-05 2.56415e-05 1.89913e-05 1.005e-05 -2.97413e-05 -7.2061e-05 0.000295645 -0.000266795 -5.38714e-06 -6.52258e-05 -8.74834e-05 0.0002434 -0.000161933 7.50284e-05 -0.000167311 -0.000335936 -0.000146548 -0.000134811 9.83513e-05 0.000316768 0.000192387 -0.000281859 0.000155275 0.000148126 0.000390849 0.000129664 -3.44654e-05 0.000189921 -0.00013341 -0.000126545 -0.000191464 -3.0292e-05 0.000264875 -7.96946e-05 -0.00010619 -9.55395e-05 -0.000131987 4.63355e-05 1.90502e-05 -5.20644e-05 -7.49607e-05 -2.57237e-05 0.000122459 1.95984e-06 -1.96926e-05 6.56262e-05 -0.000124122 -1.74855e-06 -0.000105215 3.91607e-05 0.00012965 -6.70959e-06 6.72063e-05 9.55822e-05 -2.95723e-05 -7.96161e-06 0.000108777 4.18587e-06 -7.13957e-05 1.91457e-05 -1.46215e-06 4.55167e-05 3.80478e-05 -7.07643e-05 -5.37135e-05 4.79274e-05 0.0001172 3.19238e-05 -3.3873e-05 1.19734e-05 4.50434e-05 -6.08432e-06 -3.82568e-05 -2.88523e-05 -3.5709e-05 2.48367e-06 -3.95314e-05 -2.40348e-05 7.43874e-05 -3.65256e-06 -0.000122885 0.000217263 4.44724e-05 8.25725e-05 4.75971e-05 0.000137609 -1.18513e-05 -9.47368e-05 4.48558e-05 -2.89136e-05 -0.000123906 5.149e-05 6.38667e-05 8.68689e-05 -0.000104209 3.03366e-05 5.7601e-05 2.65436e-05 -2.21114e-05 -0.000122473 0.000192466 6.91311e-05 9.18016e-05 3.18772e-05 -0.000275264 0.000124317 -0.000162089 5.10353e-05 0.000103019 -8.96474e-05 6.82277e-05 6.21064e-05 -3.2833e-05 -0.000116081 9.23266e-05 6.62925e-05 -6.73791e-05 7.43252e-05 0.000100216 4.76814e-05 0.000108958 6.12987e-05 -0.00021793 9.30342e-06 4.85413e-05 5.30741e-05 9.23171e-05 -5.02963e-05 -5.12364e-05 -1.3913e-06 -7.11316e-05 -1.22793e-05 -2.34443e-05 2.20505e-05 1.78323e-05 -7.56922e-05 8.19089e-05 -3.04126e-06 1.95856e-06 -8.29658e-05 -9.12863e-05 7.05224e-05 -7.43101e-05 2.36187e-05 0.00016285 -0.000106145 -6.01936e-05 2.71384e-05 5.59559e-05 -5.79704e-05 -0.000234795 0.000264234 -7.55854e-05 6.0187e-05 6.78339e-05 0.000180527 0.000366405 0.000285659 0.000212751 4.68177e-05 0.00048681 0.000136962 -0.00045751 -0.000136893 2.01625e-05 8.38294e-05 -6.44488e-05 0.000380844 -0.000161878 0.000229389 -0.000339349 0.000163605 0.000471894 9.79201e-06 2.79538e-05 -0.000298907 -0.000494789 0.000300272 -8.64467e-05 0.000214832 6.42253e-05 -0.000124993 0.000138393 0.000188552 -0.000314119 -0.000431825 8.61826e-05 2.4044e-05 -0.000102731 0.000232826 0.000111825 7.00375e-05 9.79875e-05 8.77952e-05 -0.000172676 -4.30125e-05 1.54962e-05 5.87746e-05 -4.01612e-05 -1.38169e-05 5.46315e-05 3.37808e-05 -0.000123673 -5.25373e-05 3.87129e-05 -2.90497e-05 3.23193e-06 -7.94957e-05 0.000139665 6.66581e-05 1.90183e-05 -4.57867e-05 -0.000181069 0.000100182 -3.64251e-05 6.6345e-05 0.000100529 -0.000113508 -4.18706e-05 2.21051e-05 5.73258e-05 -0.000165589 -8.22286e-05 9.65431e-05 -6.92117e-06 -6.44547e-05 -6.2688e-05 -2.03618e-05 -9.62141e-06 -6.38233e-05 0.000158834 0.000244489 0.000418114 -2.54403e-05 0.000118336 -1.47638e-05 -0.000256586 -0.000118912 -0.000257396 6.22184e-05 -0.000100604 -0.000132861 3.27409e-05 -5.63142e-05 0.000118995 -9.25683e-05 0.000135765 9.63646e-05 1.05067e-05 -0.000158633 -7.28229e-05 7.06945e-05 1.16339e-05 1.98547e-05 -2.02726e-05 -8.88044e-05 1.85727e-05 -6.01398e-05 -1.43933e-05 9.43247e-05 2.7667e-05 -2.63921e-05 -0.00015289 -0.000128977 3.02248e-05 -9.94431e-06 4.78451e-05 7.37607e-05 0.000334658 -2.3944e-05 0.000186266 -1.29423e-05 -0.000175428 -5.49695e-05 -0.000206814 2.95114e-05 -9.31933e-05 -3.93304e-05 1.71386e-05 6.08049e-06 4.84768e-05 -4.47943e-05 0.000118779 6.74455e-05 -6.18574e-05 -9.91005e-05 -3.0064e-05 5.09097e-05 6.4106e-05 -2.69493e-05 1.5794e-05 -7.43658e-05 1.72308e-05 -1.43092e-05 -0.000308316 -4.11789e-05 -0.000127985 0.000152266 0.000131377 -0.000191077 0.000151245 0.000354887 0.000328391 -2.02064e-06 0.000627131 0.000248395 -0.000268558 -0.000618196 -0.000219516 7.03631e-06 -0.000117418 0.000439399 -0.000154487 -0.000120896 -0.000187657 2.91537e-05 6.53009e-05 0.000180999 9.68049e-05 -1.59847e-05 -2.50243e-05 9.69754e-05 -8.92274e-05 7.00002e-05 9.27644e-05 -0.000171776 -0.000101388 6.93628e-05 -5.20466e-05 -0.000179202 -0.00135717 -4.84148e-05 -0.000407487 -0.000169249 0.000673507 0.000215846 0.000176625 0.000373035 0.000973968 9.11866e-05 0.000164919 0.000106278 0.000174123 0.000191081 -2.49231e-05 6.23419e-05 -5.62551e-05 -5.44894e-05 8.30375e-05 5.73131e-05 2.26706e-05 -0.000144536 -9.62216e-05 9.83096e-05 0.000118726 -8.78485e-05 -0.000163142 -2.5026e-05 -4.85029e-05 -0.000109166 0.000216603 -5.22162e-05 -4.4493e-05 1.6054e-05 2.63609e-05 -0.000217678 6.52158e-05 0.000123314 5.46377e-05 5.00619e-05 7.15102e-06 1.35245e-05 -1.50265e-05 -1.35902e-05 -2.99235e-05 -7.85298e-05 4.99201e-05 1.99132e-05 -5.32664e-05 0.000157315 0.000170142 -0.000166697 -0.000185195 9.35309e-05 4.23697e-05 -3.64293e-05 -6.75755e-05 4.9634e-05 -4.34089e-05 -4.69071e-05 -1.02449e-05 0.000109291 8.30011e-05 -6.40095e-05 9.63156e-06 -2.81889e-06 -9.50164e-05 8.94786e-06 6.54764e-05 -0.000108711 -8.77644e-05 0.000101491 -2.19781e-05 6.21088e-05 -3.23013e-06 8.98479e-05 -2.40943e-06 -3.05333e-05 1.8145e-05 2.85173e-05 0.000106173 -0.000109808 5.64665e-05 2.63691e-05 -0.000116583 0.00014861 0.000187499 -0.000210045 -0.000222778 0.000151348 -3.40485e-05 -0.00010798 -7.46705e-05 2.46395e-05 -1.41469e-05 9.90452e-06 2.68982e-05 0.000104829 0.000137795 -8.11991e-05 -7.17692e-05 -1.56876e-05 -1.67637e-05 -4.87482e-05 -5.61896e-05 -4.28609e-05 8.26923e-06 8.40213e-05 0.000338039 -0.000627314 1.17072e-06 0.000524524 0.000341679 0.000353934 -9.5154e-05 -1.56239e-05 -0.000357244 -8.65852e-05 -0.000296958 -0.000277098 -0.000445115 -9.98697e-05 -4.15251e-05 0.000118683 0.000429252 0.000183558 2.40953e-05 0.000371412 0.000196981 0.000191759 0.000116108 3.06493e-05 -3.20083e-05 5.7018e-05 0.000143967 2.31173e-05 3.44848e-05 -0.000233716 -0.000178879 -8.05872e-05 -0.000284742 1.47497e-05 -1.5444e-06 -0.000229391 7.14585e-05 8.76023e-05 -2.2593e-05 9.27497e-05 3.91013e-05 4.93485e-05 -7.8802e-05 3.21205e-05 8.99838e-05 -0.000210563 -2.50494e-05 -5.86829e-05 -0.000189254 0.000274458 0.000291726 -0.000204886 -0.000268954 0.000181157 -1.46333e-05 -0.000136588 -1.55763e-06 -4.14071e-05 -0.000119237 2.97064e-05 6.43565e-05 5.58208e-05 8.77643e-05 1.71377e-06 2.15435e-05 -5.67844e-05 -1.07646e-05 -4.1921e-05 -3.98033e-05 -5.56684e-05 3.87165e-05 0.000105546 0.000150762 -7.02309e-06 0.000198851 6.95971e-05 -4.93461e-05 2.18321e-05 6.36662e-05 -7.47995e-07 -7.91587e-05 8.98029e-05 0.000196054 7.07527e-05 0.000153475 -0.000128831 -0.000180862 -0.000163407 -0.000160474 6.07077e-05 -0.000180498 7.62865e-05 -5.74613e-05 3.00334e-05 0.000164239 -3.50401e-05 5.69066e-05 -4.96883e-05 -0.000138276 2.85135e-05 -0.00010477 -4.75289e-05 -5.86438e-05 -3.60603e-05 4.41723e-05 6.51126e-05 3.82781e-05 -4.41489e-05 -6.592e-05 -0.0001946 8.69494e-05 -8.5351e-05 -2.60785e-05 -4.83045e-05 6.55225e-05 4.92252e-06 -8.41233e-05 6.20502e-05 0.000194839 2.49825e-05 8.93659e-05 1.25085e-05 0.000101565 1.87575e-06 -0.000110642 -4.55996e-05 1.68363e-05 5.9342e-05 8.58933e-05 2.40111e-05 -5.9018e-05 -5.15245e-05 -3.0915e-05 -5.09449e-05 -0.000101206 4.57461e-05 3.13179e-05 1.86896e-05 -1.32449e-06 -1.56122e-05 4.5987e-05 -5.72143e-05 -2.98907e-05 9.15983e-06 0.00027 5.91028e-05 -0.000163665 6.50751e-05 -0.000192265 8.21175e-05 -0.000227116 1.78463e-05 0.000248062 7.57189e-05 0.000515255 0.000236643 -0.000362151 0.000259544 5.4011e-05 -0.00029258 -0.000454467 1.47914e-05 9.87342e-05 1.06842e-06 -2.15614e-06 1.65441e-05 -6.01589e-05 6.80333e-05 -8.92533e-05 7.16951e-06 0.00020701 -0.000160679 -7.90413e-05 -3.0885e-05 -3.76027e-07 0.000161599 0.000124814 9.41606e-05 -9.7479e-05 -1.6452e-05 -0.000240561 9.22695e-05 -3.27233e-05 -0.000250016 9.10409e-05 -3.68854e-05 0.00010692 0.000277501 0.000391479 7.86184e-05 0.000109781 -6.29918e-05 0.000317579 0.000155134 -7.13057e-05 -0.00021267 -8.51623e-05 -0.000108526 -7.20426e-05 -3.64857e-05 -8.38308e-05 0.000101381 4.86715e-05 4.3969e-05 6.12234e-05 -0.00011397 -3.56234e-05 1.03062e-05 0.000102581 2.72608e-05 -7.15541e-05 -8.70616e-05 8.79823e-05 0.000142317 -1.50895e-05 -0.0001288 0.000819531 0.00019903 -0.000161682 2.71682e-05 -0.00100536 -0.000516388 -0.000207498 0.000739684 0.000620625 -0.000646358 -0.000345408 0.000511396 -5.18499e-06 0.000648093 0.000121461 -0.000361103 -0.000548309 0.000104554 0.000324197 -0.000786759 -0.000470877 0.000321773 -0.000635691 1.98419e-05 -0.000125651 -0.000326085 0.000674878 0.000235591 0.000463755 0.000248659 0.000198081 -4.98014e-05 -0.000225609 0.000152501 0.000306959 0.000154754 5.88782e-05 0.000436137 0.000520599 -0.000577957 -0.00111789 -0.00139854 0.000405199 0.000685148 0.000979626 -0.000241591 0.000481589 0.00123808 0.00140348 -0.000159919 -0.000681105 -0.000503906 0.000177326 -0.000601098 -0.000539891 0.000497875 -0.000129505 0.000287532 0.000317166 -1.73664e-05 1.82586e-05 -0.000232049 0.00015846 5.15127e-05 2.48729e-05 -0.000333922 -0.00016194 -0.000279436 0.000133574 0.000388159 -0.000179749 9.25213e-06 0.000246197 -5.66688e-05 -4.81844e-05 -0.000218768 5.59302e-05 -0.000137343 -0.000467773 0.000625269 0.00011515 -0.000672759 0.000328801 0.000127807 0.00035465 0.000142269 0.000165 -0.000678093 -0.00116699 0.00061578 -0.000133776 -0.00014419 -3.73459e-05 0.000226026 0.000178377 -1.04347e-05 -0.000117849 -0.000273819 -1.49365e-05 3.66758e-06 -5.49509e-05 0.0004323 0.000117769 -0.000538791 -8.31812e-05 0.000327293 0.000264121 -0.000152869 -0.000611118 0.000136793 2.73554e-05 -0.000351673 -9.8152e-05 -0.0001675 -0.000116116 9.60009e-05 0.00067107 0.000138577 0.000555963 8.48894e-05 0.000532197 1.85718e-05 -0.000269871 -1.38011e-05 -0.000141232 0.000108447 -0.000278354 0.000313087 7.97837e-05 4.5059e-05 0.000389914 9.47114e-05 -3.39306e-05 -0.000389097 -0.000280248 2.04395e-05 -5.15244e-05 -3.02219e-05 -6.5824e-05 -0.000169132 7.45184e-05 0.000107831 2.44815e-05 -8.49694e-05 -0.000254169 0.000542686 5.08149e-05 0.00025415 -8.56299e-05 -0.000165746 0.000118262 -0.00036669 -0.000198228 8.3999e-05 0.000115515 0.000477386 -0.000232007 -0.000400014 0.000139191 0.000346759 -0.000151445 -0.000222667 0.000239904 -0.000308005 -5.03329e-05 -5.53559e-05 9.24311e-05 -1.23959e-05 -7.01445e-05 8.7147e-05 -0.00010113 0.000157314 -5.7784e-05 -3.85779e-06 0.00023105 -1.22012e-05 -7.09905e-05 1.72737e-05 0.000330078 -7.99873e-05 -7.49982e-05 1.43846e-05 1.56859e-05 0.000120528 -0.000162675 -0.000181712 0.000162729 -6.50577e-05 -0.000182545 0.000150681 0.00010944 0.000217442 -7.47182e-05 -0.000421024 7.02779e-05 0.000528949 3.00706e-05 -0.000163802 0.000129258 -0.000385025 8.896e-06 -0.000223407 -4.03467e-06 3.66738e-05 -0.000104988 0.000131209 0.000221508 0.000162629 2.31754e-05 -1.54846e-05 0.000278015 0.000154035 -0.000249898 -0.000124851 0.000172268 -0.000107262 -0.000194084 -9.00796e-05 0.000108579 -0.000381479 -0.000143088 -0.000258823 0.00020481 0.000534624 0.000593712 4.49836e-05 8.2407e-05 0.000375513 0.000171178 8.77753e-05 -6.63985e-05 -0.000216902 -0.000312424 0.000268639 -0.00030968 2.58352e-05 0.00014239 9.81395e-05 -6.42719e-05 0.000101498 9.82745e-05 1.02263e-05 0.000297928 -5.00339e-05 -0.000116732 -1.663e-05 -5.62002e-05 -4.61188e-05 3.94017e-05 -4.3154e-05 -0.000115743 0.000127187 -0.000236506 0.000192285 4.82353e-05 0.000153864 -3.34148e-05 -0.00028587 3.74367e-05 -0.000184331 3.24123e-06 0.00019384 3.63269e-05 0.000129322 -0.000279373 -0.000487241 0.000150046 0.000605673 7.37737e-05 -0.000195119 0.000217217 -0.000304285 2.7535e-05 -0.000193505 -1.47592e-05 -3.48814e-05 -1.54014e-05 0.00018941 1.88461e-05 9.19313e-05 -6.18711e-05 -2.47391e-05 0.000274146 0.000134015 -0.000158567 -0.000119949 0.000103682 -0.000115238 1.46249e-05 0.000140525 0.000202949 -0.000103624 -5.92917e-05 -6.29994e-05 -3.44135e-06 -2.92406e-05 0.000364937 -3.04501e-05 0.000344222 0.000262979 3.08447e-05 -0.000496671 -0.000494767 2.28657e-05 -0.000499774 0.00019186 -0.00010187 0.000241014 0.000165489 5.429e-05 -2.24066e-05 6.98181e-05 -0.000338388 -0.000386856 -0.000310498 0.00029591 0.000322944 0.000337847 0.00011207 -0.000728805 -0.000582929 -0.000525498 0.000172117 0.000541874 -0.000127038 0.000153615 -5.98494e-05 -1.0042e-05 -1.77373e-05 -3.63576e-05 -5.48075e-05 -7.3019e-05 0.000164216 6.75757e-05 0.000114818 -7.78407e-05 0.000146309 -2.04672e-05 -0.000139427 -8.91419e-06 -0.000164576 0.000122515 -2.66692e-05 -6.57793e-05 6.38023e-05 -0.000174049 2.46037e-06 -2.47958e-05 -2.36071e-05 -4.90503e-05 -4.49933e-05 8.74315e-05 -6.44524e-05 -1.15055e-05 6.51964e-05 -4.35995e-05 8.96743e-05 2.97233e-05 2.44301e-05 -5.44775e-05 -2.07656e-05 0.000279801 -0.000480566 0.000375023 -0.00024221 0.000109067 8.58646e-05 -0.00031572 -0.000376491 -0.00047602 7.58039e-05 0.00083278 0.000733653 -0.000247125 -0.000863336 3.57239e-05 -0.000766689 6.05643e-05 0.000206653 7.72056e-05 -4.88961e-06 -9.82053e-05 -0.000339992 -0.000290667 -0.000352839 2.73127e-05 -0.00023701 -0.000157309 -6.5283e-05 -0.000208226 4.01205e-05 0.000361387 0.000121462 -0.000374293 0.0001985 0.000336927 -0.000219006 2.95475e-05 -0.00025029 -0.000219055 -0.00011924 -0.000123636 -0.000117303 -0.000244315 0.000241915 6.76379e-05 -1.33787e-05 -6.58876e-05 0.000159107 0.000157011 -7.2757e-06 0.000205957 0.000282554 -5.05148e-05 9.99402e-05 -4.9879e-05 4.16645e-05 2.12398e-05 8.81716e-05 4.50709e-05 8.07002e-05 -0.000103282 -3.41334e-05 -1.07917e-05 -4.6799e-05 -6.36488e-05 -4.08625e-05 -0.000108092 -3.03967e-05 -7.51374e-06 -3.83619e-05 -7.33384e-05 -0.000101261 0.000203379 -0.000412961 0.000100228 5.53789e-05 -3.74373e-05 -0.000212892 -0.000247646 0.000281434 5.15759e-05 4.51033e-05 -4.01491e-05 -0.000243415 0.000376014 0.000482334 -3.41572e-05 -0.000368905 0.000154171 -0.000117414 0.000148597 -2.39129e-05 8.42604e-05 4.03101e-05 -3.01684e-05 -2.56222e-05 -0.000167842 -6.8721e-05 2.97915e-05 0.000107446 0.000169327 3.57082e-06 -7.36014e-05 -1.50403e-05 0.000239762 -1.72504e-05 -5.72974e-05 -0.000148403 4.63964e-05 -0.000256103 -0.000102573 5.03158e-05 7.52055e-05 -0.000255469 -7.31608e-05 0.000387006 0.000235136 0.000160724 -4.79419e-05 -0.000149815 0.000227003 0.000255624 -3.92131e-05 -0.00016915 0.000196061 -1.51951e-05 -0.000136651 0.0002106 -0.000174364 -8.11679e-05 5.34486e-05 -0.000128468 0.000110276 3.20695e-05 3.50287e-05 0.000107771 -1.16321e-05 9.21006e-05 -2.62515e-05 -0.000114226 -1.18549e-05 0.000107995 2.48717e-05 -1.07674e-05 8.24814e-06 4.58486e-06 -0.000222362 6.53479e-05 0.000191618 -0.000150573 2.22237e-05 0.000329762 0.000184247 0.000336765 0.000151992 -0.000100255 0.000151519 0.000451166 -0.000146929 -3.08778e-05 0.000169664 0.000106772 -0.000122257 -0.00012064 0.000123517 0.000126747 0.000177128 -6.02199e-05 9.56331e-05 0.000280246 6.32511e-05 5.86923e-05 -0.00014436 -0.000157863 1.35506e-05 3.69933e-05 4.26318e-05 -0.000108581 -4.33348e-05 -0.000398044 0.000342455 -0.000426616 -1.30979e-05 0.000166473 -7.62396e-05 2.2164e-06 -4.01959e-05 0.000270533 8.5032e-05 0.000138689 0.000127869 4.09537e-05 0.000149707 0.000248794 1.86921e-05 -0.000376561 3.44172e-05 6.58289e-06 -7.37007e-05 -6.82026e-05 5.41005e-05 3.22237e-05 6.04498e-05 -3.04744e-05 -6.5249e-05 -5.3941e-05 1.60774e-05 9.13583e-05 7.14572e-05 4.43515e-05 -5.43351e-05 -9.71313e-05 9.40275e-05 0.000102016 -3.71041e-05 7.00559e-05 4.28237e-06 -4.98999e-06 3.62195e-05 4.06495e-05 -5.66132e-05 -4.29859e-05 0.000105775 -9.05917e-05 -6.25499e-05 -0.000112703 -1.79398e-05 8.38114e-05 -2.5041e-06 5.49142e-05 -0.000149002 -8.74748e-05 0.000138875 -4.53887e-05 6.59399e-06 1.51736e-05 1.17848e-05 1.16877e-05 4.4325e-05 -0.00011455 9.22997e-05 4.60936e-06 8.44035e-05 6.93004e-05 -0.000117716 6.25432e-05 3.51911e-05 -8.01965e-05 -0.000143352 -8.53731e-06 -5.46251e-05 -3.37585e-05 4.56707e-05 -1.82986e-05 0.000136053 7.60036e-05 -4.66217e-05 -7.91193e-05 4.80605e-05 -9.01409e-05 -2.81094e-05 9.6342e-05 -0.000168122 7.08064e-05 -3.7299e-05 -2.26216e-05 -9.45106e-05 -8.5837e-05 -3.25291e-05 -8.2729e-05 5.78452e-06 -1.02527e-06 -5.40742e-05 2.77937e-05 0.000100573 -1.85811e-05 5.51145e-06 2.43156e-05 5.21159e-05 1.69015e-05 -5.15985e-05 7.53051e-06 8.96353e-05 -7.15938e-05 -2.57713e-05 4.00744e-05 -0.000106333 0.000156787 -3.90272e-05 0.000202739 0.000109885 -0.000220526 -3.57421e-06 -0.000168527 9.76114e-05 0.00042149 -9.9564e-05 -0.000239521 -0.000170722 0.000146714 0.000367999 -7.47092e-05 6.56006e-05 -2.37718e-05 -0.000199712 0.000180762 -1.67469e-05 0.000171671 8.23738e-06 -0.000264589 -0.000181838 0.00016048 0.000184159 0.00019543 -0.000274555 3.02145e-05 8.5698e-05 -0.000174636 -0.000241462 -8.82469e-05 0.000237814 8.70947e-05 6.23123e-05 7.05064e-06 1.31201e-05 -3.98053e-05 9.50553e-05 5.75213e-05 -4.64461e-05 -2.49029e-05 6.51216e-05 -0.000151728 -5.2981e-05 3.36761e-07 -5.91082e-05 0.000112515 1.46884e-05 2.59389e-05 -0.00016558 -6.24623e-05 0.000110838 -3.95711e-05 -7.13836e-06 -8.63093e-06 -1.97415e-05 -1.23797e-05 7.93101e-05 -4.47733e-05 3.1825e-05 1.03086e-05 5.12904e-05 1.74113e-05 -4.18178e-05 4.32656e-05 3.64423e-05 -5.78641e-05 -5.62965e-05 3.97789e-06 -6.97736e-05 0.000208691 9.7559e-06 -9.33615e-06 -3.40323e-05 -6.49281e-05 0.00013556 -0.00018887 7.18607e-06 0.000116195 8.50216e-05 -0.000158334 -1.20972e-05 -0.000112184 0.000120357 0.000318485 5.58045e-05 -9.75963e-05 -0.000246141 0.000161937 -9.26959e-05 -5.10356e-05 6.67781e-05 -0.000187507 -0.000172404 1.06816e-05 0.000137218 0.000311609 -2.07792e-05 5.29304e-05 -1.86636e-05 -0.000123758 0.000111124 0.000114005 4.99978e-05 -0.000125147 8.04853e-06 0.000208841 2.71582e-05 -0.000154346 4.65665e-05 -0.000165657 8.89374e-05 -0.000158662 0.000244755 0.000561311 1.61853e-05 -9.11766e-06 -8.35664e-06 -2.05851e-05 0.000165143 0.000303055 -1.0132e-05 -0.000242637 -0.000147529 -1.88137e-05 1.82441e-05 -3.80078e-06 3.35629e-05 -2.40079e-05 -5.03066e-05 6.71879e-05 3.844e-05 -7.05894e-05 -4.09407e-05 0.000223108 1.96786e-05 -2.11178e-05 2.04096e-05 -7.79666e-05 -5.73395e-07 -3.41424e-05 -3.39681e-05 -2.65782e-05 -9.71504e-05 0.000289743 0.000417568 0.000269081 0.000424511 -7.82565e-05 -0.000443768 -0.000554801 -4.11646e-05 -0.00032598 -0.000352881 -3.86361e-05 -0.000272726 -0.000101209 0.000334226 0.000421936 -0.000307352 0.000161149 -0.000135683 0.000121947 -0.000227789 -8.38259e-05 0.000133052 -0.00011861 0.000336661 0.000367415 -7.29042e-06 -0.000293127 -0.000312706 -5.09497e-05 0.000160028 0.000224314 -3.23033e-05 0.000132322 0.000216404 0.000214461 -8.10017e-05 -0.000352776 0.000186712 -5.40509e-05 0.000234669 -0.000275096 0.000146363 0.000529035 -6.99115e-05 -6.02152e-05 -8.70209e-05 -0.000202155 0.000365806 0.000570709 1.17402e-05 -0.000268158 -0.000137456 -5.05494e-05 7.75295e-05 -4.26897e-05 8.08486e-05 -0.000140951 -0.000171452 3.53027e-05 0.000128188 0.000146247 -0.000106945 0.000138157 0.000160333 -3.70764e-06 -4.62907e-05 7.54581e-05 8.40072e-05 -0.000180718 -7.29519e-05 -4.0017e-05 3.47985e-05 -9.51e-06 -1.27866e-05 1.36501e-05 2.85083e-05 1.89606e-05 1.09051e-05 -1.64399e-05 -2.18675e-05 -1.04827e-05 -4.78814e-05 2.24108e-05 2.56934e-06 -4.78189e-05 2.5796e-05 2.22584e-05 -2.66745e-06 -1.50889e-05 1.27344e-05 3.49782e-06 -1.5876e-07 3.01409e-06 1.31837e-05 -2.38651e-05 -2.02987e-05 -6.69632e-06 5.78365e-06 1.76204e-05 -4.80694e-05 -1.15417e-05 2.697e-05 -2.11718e-05 5.94259e-06 2.84285e-05 -1.99043e-05 -3.55265e-05 3.35594e-05 -5.73069e-07 -4.56233e-06 7.85231e-06 2.53978e-05 3.478e-06 -8.60905e-06 -1.9481e-05 -3.59782e-06 9.40422e-07 -5.12253e-05 1.1683e-05 1.34195e-05 -3.62218e-05 2.35372e-05 1.30905e-05 -1.17811e-05 1.93796e-05 -2.42116e-05 -1.69337e-06 1.89551e-06 -1.99559e-06 -1.82087e-06 -3.92942e-05 -7.67646e-06 9.97637e-06 1.17439e-05 -3.14001e-06 -1.18366e-05 -1.93114e-05 1.49956e-05 8.779e-06 -6.17035e-06 5.15868e-07 -2.42399e-05 3.94286e-05 6.4726e-05 -0.000181467 0.000329821 8.58334e-05 0.000111051 -2.86851e-05 -0.000132423 -0.0003028 -0.000130839 -5.78656e-05 0.000142173 6.48385e-05 -0.000106672 8.48012e-05 -8.56967e-05 -0.00012982 -0.000115893 0.000292384 -0.000149393 -2.51687e-06 -2.79606e-05 -0.000102623 1.48533e-05 -1.69843e-05 0.000181814 -5.77663e-05 -0.00012197 -5.37013e-06 -6.98993e-06 6.22003e-05 0.000105498 2.26592e-05 -1.70997e-05 3.20362e-05 -6.04469e-05 -3.03891e-05 3.98006e-05 -8.18099e-06 -6.24303e-06 1.36991e-05 2.87516e-05 7.11768e-06 7.68231e-06 -1.17494e-05 -1.72788e-05 5.7867e-06 -4.75247e-05 2.34068e-05 1.14912e-05 -5.30595e-05 2.56923e-05 9.52596e-06 -2.04061e-05 -1.32975e-06 -9.55133e-07 -5.24623e-07 7.58091e-06 4.58849e-06 1.15484e-05 -2.90693e-05 -1.79636e-05 -1.50222e-07 6.72075e-06 1.7279e-06 -4.17291e-05 -2.01023e-05 1.63521e-05 -4.99472e-06 1.22607e-05 9.09943e-06 -2.49491e-05 0.000158026 1.38778e-05 -0.00012543 0.000111401 -2.08277e-05 0.000193599 -9.94598e-05 4.58105e-05 4.97672e-05 -6.07761e-05 1.44199e-05 -7.1542e-05 -3.19676e-05 0.00017669 0.000121415 -0.00021305 -0.000158136 0.00014698 -9.36734e-06 -7.92613e-05 -2.80173e-05 1.16623e-05 9.87596e-06 2.33629e-05 3.50821e-05 0.00010564 7.09127e-05 1.66674e-05 4.06094e-05 3.3226e-05 -5.25418e-05 1.52811e-05 -2.03733e-05 -3.13351e-05 -6.54151e-06 -4.97917e-05 0.000305629 2.72719e-05 -0.000173038 5.96186e-05 -7.95279e-05 0.000232316 -0.000237608 0.000179858 0.000226525 -0.000140372 2.2707e-05 -6.96522e-05 -7.7495e-05 0.000344405 0.000219909 -0.000421457 -0.000293009 0.000263144 -8.83646e-06 -1.53618e-05 2.1805e-05 -1.73114e-05 -4.76789e-05 -4.53496e-05 3.72057e-05 9.04284e-05 1.87169e-05 -3.2506e-05 2.12701e-05 5.10363e-05 3.0582e-06 4.80868e-06 -3.14575e-05 -2.39775e-05 -6.91996e-06 -9.35802e-05 -0.000378917 -1.31356e-05 0.000302428 -0.000225474 7.60412e-05 -0.00020915 0.000288599 -0.000187051 -0.000325916 0.000232528 2.13132e-05 5.18696e-05 0.000219438 -0.000402789 -0.000428889 0.000356924 0.000393 -0.000170571 4.95821e-05 0.000171172 4.95038e-05 -2.24289e-05 -2.43434e-05 -2.42844e-05 -0.000194492 -7.39099e-05 9.5961e-06 -5.26578e-05 -4.31898e-05 -0.000114345 -5.0866e-06 -3.01332e-05 1.40539e-05 2.93778e-05 0.000103719 0.00011838 0.000139244 -1.05273e-05 -0.000163693 0.000131302 -1.61955e-06 0.000276064 -0.000120928 0.000172751 0.000124535 -0.000114528 5.59749e-05 -5.34591e-05 -6.11806e-05 0.000233979 0.0001965 -0.000314814 -0.0002196 0.000189088 3.45219e-05 -0.000112344 1.71847e-05 -7.25096e-05 -5.60157e-05 -4.45942e-05 4.43974e-05 0.000105665 7.10564e-05 1.93417e-05 3.37955e-05 6.01785e-05 -1.63638e-05 -4.46014e-05 -3.80033e-05 1.08146e-05 -7.00045e-06 -7.05421e-05 -0.000183689 0.000276047 -3.20356e-05 0.000182101 0.000141981 4.08066e-05 -2.51561e-05 -7.29032e-05 3.138e-05 -0.00018587 -4.36834e-05 0.000272562 -8.83401e-05 -0.000127013 0.000152422 0.000150858 -0.000168166 -0.000376278 0.00010622 -6.56284e-05 3.44434e-05 -7.73455e-05 7.62257e-05 -3.96124e-05 -0.000105941 4.27552e-05 0.000158122 8.07135e-05 -3.00384e-05 -1.40094e-05 -9.67658e-05 -4.32806e-05 1.68807e-05 7.72233e-05 2.1408e-05 -9.91955e-05 8.05123e-05 9.03586e-05 -0.000123443 0.000145812 0.000110312 2.28651e-05 9.51557e-05 5.97541e-05 -3.30454e-05 6.4838e-06 -2.27089e-05 7.62291e-05 -0.000246987 -7.82715e-06 -1.36002e-05 3.09635e-05 0.000117962 -0.000166388 -2.04336e-05 3.60354e-06 6.8614e-05 -0.000125023 -7.91322e-05 -8.36734e-05 2.27691e-05 5.96612e-05 3.42626e-05 5.3184e-05 -0.0001215 -4.70677e-05 5.34879e-05 -1.38793e-05 -5.00389e-06 1.43534e-05 3.1123e-05 -7.44807e-05 0.00023462 -6.78357e-05 -0.000456663 0.000140073 -0.000230615 0.000280081 0.000461917 -1.87896e-05 -0.00047046 -0.000189816 -0.000186401 0.000889372 0.000421706 0.000251074 0.000199289 -0.000321219 1.05382e-05 -0.000457437 0.000145552 -7.09417e-05 0.000171997 -2.12046e-05 -0.000195115 -3.49485e-05 4.30917e-05 0.000219978 0.000178543 -8.20616e-05 0.000149437 2.06244e-05 -0.000144393 7.87163e-06 -2.85348e-05 -1.66314e-06 7.42614e-05 4.81707e-05 3.35181e-05 -4.75839e-06 -9.60042e-05 0.00013281 0.00017802 9.2236e-05 -1.95093e-05 -9.94446e-05 -8.25033e-05 -3.49384e-05 3.01373e-05 3.03709e-05 -0.000233438 -3.7331e-05 6.42767e-05 0.000105043 4.77519e-05 -0.0001215 8.36633e-05 1.39028e-05 3.71796e-05 -8.71901e-05 -2.9205e-05 -4.04324e-05 2.24006e-05 4.56093e-05 2.5795e-05 8.48668e-05 -8.78214e-05 -0.00012425 -3.48173e-05 -9.19312e-06 -1.8307e-05 3.79088e-05 4.47556e-05 -1.89436e-05 4.33064e-05 -5.00875e-05 -6.33423e-05 -4.28919e-05 -6.04863e-06 4.68242e-05 -5.48943e-06 2.88545e-05 3.7699e-05 -5.71676e-06 -3.74418e-05 -4.00156e-05 -7.40838e-05 0.000113586 9.29717e-05 4.97315e-05 5.62951e-05 -8.81881e-05 -5.55939e-06 4.27688e-05 2.1084e-05 3.10973e-05 2.77416e-05 2.79974e-06 -1.40412e-05 1.77029e-05 -2.66942e-05 -4.47099e-05 -1.70558e-05 2.87218e-05 5.27025e-05 -8.96111e-05 -8.60729e-05 -1.65696e-05 -6.25746e-05 -1.33432e-05 7.23288e-07 -6.18756e-05 -9.09539e-05 -2.21353e-06 2.45707e-05 6.7467e-05 6.73565e-06 5.59054e-05 5.71763e-05 3.33798e-06 -3.78171e-05 -3.48882e-05 -3.84503e-05 4.53466e-05 1.62812e-05 4.64164e-05 5.33438e-05 -9.77037e-05 -2.10493e-05 1.3958e-05 -2.58476e-05 2.80486e-05 2.01352e-05 1.38857e-05 -3.81849e-06 1.28671e-05 -1.93371e-05 -2.73803e-05 -4.08774e-05 4.71247e-05 5.00805e-05 -8.02917e-05 -4.68571e-05 3.07426e-06 -5.95243e-05 3.63007e-05 -2.8839e-05 9.42099e-06 -0.000234621 3.87473e-05 9.31101e-05 0.000222748 8.73525e-05 -8.13944e-06 0.00012759 -8.12143e-05 -0.000202387 -3.93424e-05 -0.000218075 0.000189775 8.91468e-05 -9.08384e-05 -8.33836e-05 -8.30475e-05 -0.000115704 -0.000140045 -0.000134918 -6.30076e-05 4.41909e-05 0.000144209 6.73997e-05 6.33597e-05 0.000175585 5.75772e-05 -4.95529e-06 0.000123322 0.000123955 -6.07744e-05 -4.12742e-05 -5.16777e-05 -4.28431e-05 0.000152886 8.03512e-05 -7.26836e-05 -5.91339e-05 -4.58707e-05 -5.27946e-05 3.56188e-05 -3.1278e-05 5.37819e-05 5.24351e-05 -3.39513e-05 -5.08703e-05 -2.02544e-05 -7.00317e-05 8.61674e-05 6.33864e-05 4.12383e-05 4.09492e-05 -0.000120978 -6.18063e-06 4.49527e-05 2.26915e-05 1.54573e-05 -1.33149e-05 3.7727e-06 3.76385e-06 2.04987e-06 -3.24613e-05 -5.32374e-05 -3.96029e-05 1.72824e-05 5.89723e-05 -0.000108084 -6.88891e-05 -5.18054e-06 -6.69289e-05 1.64831e-05 -0.000106442 1.20358e-05 -8.42655e-05 3.04903e-05 1.61341e-06 -8.78367e-05 0.000140429 7.34798e-05 5.55542e-05 1.94179e-05 -2.74079e-05 0.000118161 -3.72297e-05 -0.000106731 5.99181e-05 0.000186079 0.000101857 2.36726e-05 -0.000113023 3.40035e-05 -0.000129632 3.98519e-05 8.29065e-05 -0.00011591 -0.000114758 6.00109e-05 0.000107047 -6.67914e-05 -5.34763e-05 1.65817e-05 2.03244e-05 6.17119e-05 5.13636e-05 9.93614e-05 1.30239e-05 -9.62899e-05 -0.00014255 -3.34438e-05 -0.000128996 4.71569e-05 -3.60635e-05 -0.000114932 0.00010674 9.29576e-05 9.57796e-05 1.36163e-05 4.36987e-05 0.000105283 -6.25294e-05 -1.20629e-05 1.42957e-05 0.000147517 9.28573e-05 4.29419e-06 -3.11756e-05 3.82772e-05 -7.16457e-05 -3.3637e-06 4.96508e-05 8.31333e-06 -6.21433e-05 -3.61875e-05 2.14416e-05 2.94408e-05 -2.71867e-06 -6.13052e-05 -9.75596e-07 6.04557e-05 -6.31712e-05 -3.39344e-05 5.31373e-05 6.77003e-06 0.000222214 -7.38842e-05 0.000226371 7.309e-05 6.48015e-05 0.000201569 8.19433e-05 -0.000282046 -0.000824876 -0.000284652 -1.93253e-05 0.000295361 0.000239151 0.000149338 3.84254e-05 -0.000363464 -0.000131354 0.000255413 0.000286329 -0.000160131 8.14076e-05 -0.000241219 -0.000144356 8.56677e-05 -1.30702e-05 -4.26837e-06 -0.00019034 0.000189917 0.000209666 0.000107881 4.75159e-05 0.000151436 6.25423e-05 -0.000340064 0.000100375 8.53378e-05 -5.81985e-05 1.97272e-05 -0.000109526 1.11288e-05 -3.82468e-05 -0.000116403 0.000117977 -6.79473e-06 -5.47421e-05 2.37693e-05 -2.30614e-05 0.000220763 8.86052e-05 -5.17632e-05 -1.83529e-05 1.93755e-05 2.24977e-05 4.83816e-05 7.45817e-06 2.37823e-05 -2.58716e-05 -4.76518e-06 -7.78958e-06 -2.57415e-05 -5.42792e-05 -9.3459e-06 4.07355e-05 -2.77695e-05 -2.09847e-05 -6.94172e-05 -4.38376e-05 -3.69879e-06 2.2843e-05 3.3652e-05 -1.04388e-05 4.56307e-05 1.69553e-05 7.79512e-05 -5.11372e-06 -4.55331e-05 -5.42798e-05 -4.9396e-06 -5.16302e-05 -1.22599e-05 6.91535e-05 -4.96022e-05 2.97121e-05 -1.09956e-05 1.12517e-05 8.4237e-05 7.91038e-05 -3.68693e-05 -6.86315e-05 -3.41263e-05 1.97138e-05 -2.12992e-05 3.51821e-06 5.10791e-06 -1.8525e-05 1.40602e-05 6.21119e-06 4.17569e-05 6.25441e-06 -2.12483e-05 1.18255e-05 -4.78185e-06 2.25407e-05 2.53294e-05 3.02656e-05 -1.21012e-07 -2.03111e-05 -2.98739e-05 3.23388e-05 6.43717e-05 -5.8618e-05 -1.56588e-05 -5.3982e-05 3.77364e-06 -5.95183e-05 -1.56476e-05 3.30958e-05 -3.27776e-05 1.59901e-05 -2.83419e-05 3.67857e-05 9.56654e-05 8.00342e-05 1.1703e-05 -2.09126e-05 -4.12837e-05 3.45618e-06 -3.49743e-06 -6.95876e-06 -4.08436e-06 8.84675e-06 3.23584e-06 3.24042e-05 3.4712e-05 -1.85464e-05 9.89852e-06 1.40551e-05 1.1063e-05 -1.29502e-07 1.7227e-05 -9.95715e-06 -3.02767e-05 -1.98965e-05 -6.24762e-06 -8.48515e-05 0.000207508 0.000235767 -0.000234171 -0.000160593 -0.000220009 0.000194374 2.33904e-05 -4.05865e-05 4.04375e-05 -5.51769e-06 -1.85135e-06 0.00023238 -6.99461e-05 -0.00021883 0.000148489 4.56164e-05 -5.66426e-05 -8.43289e-05 -1.67965e-05 -4.25127e-05 -9.71028e-05 2.94984e-05 -0.000149044 -3.01995e-05 -5.87065e-05 -3.31988e-05 4.89915e-05 5.39133e-05 0.00013944 0.000134373 -0.00011473 -3.64418e-05 -6.39302e-05 5.04694e-05 4.85839e-05 8.77207e-05 8.95187e-05 -6.70389e-05 -1.17829e-05 -7.05982e-05 -9.91702e-06 -7.26015e-05 4.36063e-05 8.30095e-05 -8.1501e-05 2.39666e-05 2.84602e-05 2.0179e-05 0.000130816 0.000103845 -8.52338e-05 -0.000144689 -2.44917e-05 8.16149e-07 -2.06883e-06 -8.23953e-06 -8.50007e-06 -8.35846e-06 -7.04451e-07 3.83987e-05 3.22662e-05 -8.74961e-06 -6.02727e-06 2.49105e-06 -1.32353e-05 8.78265e-06 5.54771e-05 1.07905e-05 6.68097e-06 -3.88792e-05 -1.90409e-05 8.27953e-05 9.42946e-05 -0.000214553 -0.00010473 0.000108236 9.39017e-05 1.11802e-05 -2.79123e-05 -2.86052e-05 -0.000184446 -2.33672e-05 -0.000122784 -0.000165922 7.32994e-05 -0.000149563 0.000139171 -1.42366e-05 -0.000201817 1.43849e-05 -0.000115457 -2.34242e-06 1.37946e-05 -9.10183e-05 -5.04554e-05 0.000119538 6.71321e-05 -8.79213e-06 -6.07078e-05 -2.71052e-05 0.000187496 0.000122738 -0.00019629 -0.000114766 1.78362e-05 4.80471e-05 2.81369e-05 3.03437e-05 -2.42523e-05 -0.000155708 -7.32859e-05 1.66743e-05 -5.73879e-05 -4.43923e-05 9.74797e-05 0.000153105 -0.000100401 -2.31062e-06 3.99351e-05 -9.16778e-05 1.26632e-05 -0.000143744 3.04181e-05 9.00581e-05 5.4337e-05 -2.04831e-05 -5.07356e-05 5.72707e-05 0.000137143 -0.000133054 -6.94328e-05 2.74081e-05 8.59449e-05 0.000105545 1.55994e-05 4.63799e-05 0.00012501 6.95334e-05 -0.000135336 7.37973e-05 1.92851e-05 -2.15385e-05 7.39677e-05 -0.000143739 0.000455861 -0.000449786 0.000261145 -8.8419e-05 -0.000118272 0.000233498 0.000343322 0.000213223 -0.000482525 0.000406381 2.12711e-05 -0.000535114 0.000201453 0.000498148 9.04735e-05 -0.000658137 0.00026986 3.11999e-05 -6.86188e-05 -3.09918e-05 -0.000335634 5.03487e-05 -0.000130874 -4.82768e-05 0.000112824 -4.39293e-05 9.47669e-05 -0.000181977 -1.27065e-05 -6.93819e-05 -4.20862e-05 -0.000142842 -3.25649e-05 0.000354684 -4.519e-05 0.000129079 -0.000102726 -0.00021671 -2.29589e-05 0.000127854 8.71975e-05 -2.56516e-05 7.09413e-05 0.000105759 -0.000186685 -0.000105853 -0.000149765 -0.000153361 6.30349e-05 -0.00015857 6.90174e-05 0.000102297 1.64054e-05 -6.8651e-05 -4.33355e-05 -6.96115e-07 3.52737e-05 -5.30987e-05 -0.00010192 6.9517e-05 1.26469e-05 9.60047e-05 4.58439e-05 -4.50059e-05 0.00012459 1.13615e-05 -0.000226482 1.98508e-05 6.12143e-05 2.06271e-05 8.63447e-05 -0.000127754 -5.8486e-05 0.000129299 -0.000131452 -2.29872e-05 9.16762e-05 9.489e-05 -5.13034e-05 -0.000188464 4.13486e-05 -0.000104036 8.03041e-05 0.000133475 -0.000160178 -0.000166862 -4.95825e-07 0.000216158 8.38477e-05 -7.99841e-05 7.55323e-05 3.80292e-05 0.000102852 -2.22837e-05 -8.52877e-05 3.87633e-05 -0.000166936 1.61705e-05 8.89828e-05 8.50797e-06 7.78125e-05 4.4221e-05 9.31923e-05 0.000134344 -0.000102733 -0.000194772 5.43499e-05 -0.000152946 2.94027e-05 0.000107222 -9.06688e-05 3.56088e-05 2.28576e-05 0.000188536 -0.000141187 -8.78364e-05 8.46889e-05 -0.000102223 0.000118418 7.63826e-05 -0.000118151 -8.08425e-05 -3.31197e-05 4.30689e-05 0.000103921 -5.04736e-05 5.1785e-05 -1.05361e-05 7.58097e-05 4.29588e-05 -1.90964e-05 -9.16293e-06 -0.000106475 4.04056e-05 3.24382e-05 -1.01468e-05 -2.71e-06 -2.19927e-05 8.21488e-05 0.000131903 -8.27691e-05 -0.000147525 3.59953e-05 -0.000513844 0.000113635 0.000105288 -0.000202892 8.99606e-05 -0.000124992 0.000292694 8.06769e-05 0.000271284 2.42502e-05 5.0777e-05 0.000198914 9.29388e-05 -0.000256841 -0.000334795 0.000262482 7.07335e-05 7.01225e-06 -0.000196599 2.17539e-05 -0.00021665 0.000137826 8.7984e-05 -9.73702e-05 -0.000186072 -0.000108284 -1.09445e-05 3.5031e-05 -1.01252e-05 2.59006e-05 3.56881e-05 0.000225725 0.000204249 4.68529e-05 -0.000129146 -0.000217579 -0.000175572 -9.82668e-05 9.66277e-05 -9.79608e-05 6.18266e-05 5.6587e-05 0.000150149 -0.000156142 -0.000230262 7.21355e-06 -0.000123084 0.000190613 0.000121049 -0.000178494 -0.0001546 -5.33533e-05 0.000141116 0.000234177 -6.16209e-05 0.000106603 -6.44127e-05 0.00013881 2.63859e-05 -0.000130962 2.97053e-05 -0.000161475 3.69917e-05 6.61087e-05 2.96657e-05 7.31185e-05 -9.46116e-06 5.70492e-05 0.000142278 -5.79628e-05 -0.000164846 6.53747e-05 2.51882e-05 0.000255921 0.000219309 0.000111006 -2.19945e-05 -0.000223562 -0.000105792 -0.000232616 7.398e-05 0.000196843 4.64689e-05 9.53216e-05 -1.95046e-05 0.000132369 -9.08574e-05 -0.000146771 -0.000133092 0.00014948 -6.96434e-06 0.000115067 0.00010519 9.57729e-05 0.000244494 0.000102597 -0.000110959 -0.00049543 -0.000243797 -5.1802e-05 1.36554e-05 0.000201312 0.000151051 5.09199e-05 0.000143861 -0.000101002 -0.000259512 -0.00014999 -1.77986e-05 0.000121294 0.000172144 0.000160529 0.000123354 -0.00016873 1.13338e-05 -0.000312052 -0.000185628 0.00014757 8.51726e-05 0.000214939 0.000144477 5.81133e-05 -0.000116961 -0.000131832 -0.00015868 9.37061e-05 1.64503e-05 -6.60746e-06 -7.86107e-05 -6.2748e-05 5.06867e-05 9.04778e-05 1.47304e-05 8.09661e-05 -6.5268e-05 -6.00446e-05 1.27813e-05 9.41345e-05 5.55275e-05 -8.55981e-05 0.000147017 3.3831e-05 -1.45839e-05 -4.40674e-05 -0.000632672 0.000238935 0.000185393 -0.000109327 -1.22586e-05 -0.00044059 2.43984e-06 -0.000136346 0.000646161 0.000684673 0.00019695 -0.00014511 -0.000117637 -6.96412e-05 -0.000104474 0.00028667 -0.00011744 -7.30589e-07 -0.000124049 0.000117396 -7.09024e-05 8.05995e-05 7.73964e-05 -0.000139963 -0.000231036 -0.000304184 6.08458e-05 0.000360759 0.00016219 -8.93793e-05 -0.000101309 5.45273e-05 0.000123333 7.26867e-05 -0.000155737 -0.000251016 -3.97415e-06 9.79617e-05 6.85109e-05 9.68714e-05 1.16126e-05 -0.00011903 1.10632e-05 -0.000163379 -1.45686e-05 5.50985e-05 -2.46421e-05 0.00011533 -3.87955e-05 8.64431e-05 9.87923e-05 -0.00012118 -0.000155797 0.000116706 1.37064e-05 2.07292e-06 -1.0894e-07 4.03968e-05 7.34765e-05 6.03035e-05 3.57066e-05 -9.36925e-06 -2.43724e-05 2.66826e-05 -1.35494e-05 6.03671e-06 2.29344e-06 -1.04753e-05 5.97731e-05 -2.36757e-05 -4.05586e-05 3.11575e-05 -0.000399002 0.000422801 0.000222019 -0.000446082 0.000561229 0.000182118 7.21143e-05 0.000144753 5.85594e-05 -1.0272e-05 -0.000397036 -0.00052354 0.000243066 0.000186921 -0.000316813 -0.000140262 0.000156303 -0.00022795 -0.000135898 0.000239741 -0.000592039 0.000175973 0.000605666 -8.33522e-05 -5.47594e-05 -0.000327458 0.000145187 -1.05581e-05 5.69203e-05 -0.000158703 3.94679e-05 -8.96184e-05 -0.000253215 0.000226277 8.82027e-05 -0.000142848 -0.000413519 0.000521016 1.73956e-05 -0.000295903 0.000287991 0.000119748 0.000215809 8.44711e-05 0.000432513 0.000167564 -0.000131742 -0.000338447 9.42168e-05 0.000161796 -0.000179764 7.35001e-05 -5.57931e-05 -0.000251264 4.86437e-05 0.000124993 -0.000347642 0.000199198 0.000195295 -0.000159316 -0.000109843 -0.000257839 1.33663e-05 1.92856e-05 8.9779e-05 7.95344e-05 3.51538e-05 1.69884e-05 0.000109612 0.000269251 -5.00144e-05 -0.000223732 -0.00041479 0.000273149 -0.000330131 -6.56931e-06 0.000114561 -0.000217446 0.000180852 -1.89703e-05 0.000416579 0.000532935 0.000743853 7.21687e-05 -0.00029369 3.49518e-05 8.15907e-05 0.000254124 -0.000225014 -0.000163038 -0.000170467 -0.000157789 -4.06991e-05 -0.000475895 0.000626486 0.000512754 -0.000102627 -0.000378831 0.000104854 0.000109993 -0.000352558 4.7087e-05 3.16282e-05 -0.000292653 -0.000355635 0.000284429 9.81108e-05 -0.000306074 -0.000470102 0.000461641 0.000218543 -0.000101663 0.000405438 0.000143358 0.000176181 -7.67416e-05 -4.48392e-05 2.24437e-05 -2.37162e-05 -0.000125048 2.94052e-05 0.000224828 -0.00016237 -4.19679e-05 -6.52636e-05 -1.46798e-05 1.97772e-05 2.56611e-05 -0.000257937 6.5963e-05 0.000201089 6.26268e-05 -0.000116714 -0.000258539 0.000106557 0.000200321 5.74939e-06 4.75824e-05 3.73452e-05 -4.71378e-06 8.23489e-05 0.000144317 1.20827e-06 -9.63851e-06 0.000113458 2.65944e-05 -2.45159e-05 0.000100797 0.000116805 0.000125153 -9.53943e-05 -8.40578e-05 -7.92155e-06 1.96202e-06 7.54273e-05 -6.91146e-05 -0.000125318 0.000113196 9.06237e-05 -3.3491e-05 -2.72805e-05 -2.35799e-05 4.0581e-05 -3.43113e-05 -6.37715e-05 0.000167357 -8.11521e-06 7.53357e-06 -1.34706e-05 1.37905e-07 0.000147424 4.34482e-05 2.97585e-05 -6.31429e-05 1.77253e-05 8.37562e-05 -7.9145e-05 -6.34436e-05 8.71986e-06 -8.11078e-05 7.14504e-05 2.54145e-05 -4.96314e-05 0.000117779 2.41428e-05 9.3524e-06 -8.32334e-05 -6.67337e-05 9.16559e-05 4.3161e-06 4.04842e-05 8.1689e-05 3.33508e-05 6.09074e-05 2.63767e-05 -8.85434e-05 -8.90131e-05 1.51749e-05 1.62741e-05 -8.41204e-05 -1.36673e-05 4.33017e-05 -9.33754e-05 -4.69722e-05 4.32593e-05 0.000112727 6.39955e-05 -8.20341e-05 -5.50435e-05 -1.11308e-05 3.44348e-05 4.51546e-05 4.08222e-05 -2.45151e-05 -4.97862e-05 -1.81085e-05 0.000153842 -7.38006e-05 5.74441e-06 0.00032883 0.000299578 -0.000326443 0.00012426 0.000220392 0.000242646 0.000374954 0.000436982 0.000106425 -0.000128992 -0.000204456 -0.000490124 -1.26441e-05 -0.000108778 -0.000113198 -0.000347693 0.000341189 -9.78462e-05 0.000107437 0.00027231 0.000169527 -6.23016e-05 -0.00013125 0.000124876 8.75366e-05 -0.000192339 -0.000213307 -0.000184409 0.000115587 1.97717e-05 -3.31466e-06 -6.25312e-05 -0.000173819 -5.66481e-05 7.62677e-05 -6.37037e-05 1.11227e-05 1.99222e-05 1.50359e-05 -9.63256e-05 -3.45717e-05 0.00017277 8.56624e-05 9.10939e-05 -6.76404e-05 -2.32833e-05 0.000158177 4.68918e-06 -1.27936e-05 -0.000121843 -8.66166e-05 2.37318e-05 3.74113e-05 4.9067e-06 3.22161e-05 -3.9729e-05 -7.96104e-06 2.36996e-05 -7.58532e-05 -1.11672e-05 -2.01311e-06 3.07016e-05 7.32071e-05 1.60195e-05 -1.21929e-05 3.55639e-05 -8.76715e-06 -5.16995e-05 -7.90775e-05 3.33873e-07 -5.45612e-05 7.9505e-05 5.42046e-05 -8.43958e-05 -0.000113227 0.000102866 7.89133e-05 -5.46009e-05 -4.62803e-05 -0.000149552 7.48651e-05 -2.35163e-06 -0.00018478 -4.02377e-05 0.000101159 0.000201962 0.000169522 -4.4267e-05 -6.04735e-05 -1.30175e-05 0.00012255 -4.5913e-05 -0.000101368 0.000113311 0.000145449 -5.29261e-05 -4.6149e-05 -5.84372e-05 9.06295e-05 0.000108376 -0.000118094 3.9043e-05 0.000103312 -2.37418e-05 -3.23303e-05 9.18544e-05 -2.69919e-05 -1.80404e-05 8.82938e-05 -0.000121537 -6.63788e-05 5.33723e-05 6.58773e-05 -6.65699e-05 2.99923e-05 -5.67567e-05 0.000133127 1.84141e-05 -0.000149501 2.52742e-05 0.000167241 0.000125169 7.71338e-05 -6.05819e-06 9.79814e-06 -6.21813e-05 1.88324e-05 3.82318e-06 6.99551e-06 -3.64471e-05 2.67986e-05 4.44848e-05 1.77636e-05 3.51001e-05 2.80902e-05 1.7059e-05 8.78875e-05 6.9922e-05 1.09915e-05 -7.45625e-05 -8.91208e-05 -0.000321593 3.87601e-05 0.000360883 0.000131948 -0.000225768 -0.000726407 5.12382e-06 2.9071e-05 0.000512759 0.000337247 0.000215851 3.18532e-05 -0.000618685 -0.000380415 -3.21017e-05 0.000551711 7.93382e-05 0.000298294 -0.000242477 0.000317308 -9.39734e-05 0.00029738 0.000155769 -9.78397e-05 0.000141016 6.63517e-05 3.32538e-06 0.000127112 -0.000316679 -0.000164689 1.08315e-05 -0.000148864 4.56213e-05 9.68986e-05 -0.000267604 0.000110061 0.000181315 -2.73274e-05 3.36679e-05 9.773e-05 -0.000235772 -0.000119226 9.17647e-06 0.000101752 -2.12044e-05 -6.8345e-05 -0.000150218 6.38762e-05 1.64955e-05 -0.000121612 3.83841e-05 0.000115843 0.000109813 9.36493e-05 4.96365e-06 -5.90021e-05 -3.83288e-05 3.00598e-05 -2.20259e-05 -1.01613e-05 -4.42285e-06 7.02707e-05 1.82895e-05 -8.22008e-05 7.06997e-05 6.15538e-05 7.25196e-05 4.66947e-05 3.44652e-05 7.22337e-05 -8.72988e-05 -4.59624e-05 -0.000125878 0.000100931 1.42857e-05 8.43843e-05 -1.63644e-05 1.3368e-05 2.01212e-05 3.63234e-05 0.000135044 -2.82645e-05 -9.87975e-05 -7.98337e-05 0.000101424 1.4686e-05 -0.000127195 2.01971e-05 6.73094e-05 -2.03186e-05 2.66171e-05 -0.000147722 0.000156879 -1.68654e-05 -0.000208043 4.70535e-05 6.773e-05 0.000129381 0.000175985 -0.000227478 4.50733e-05 3.42314e-06 -8.8554e-05 7.09136e-05 -0.000109936 9.04183e-05 0.000115391 -6.54366e-05 -0.000195229 0.000130922 3.0696e-05 -3.24617e-05 -7.1993e-05 4.23182e-05 1.7536e-05 7.04444e-05 8.11514e-05 -8.56366e-05 2.5281e-06 -9.17554e-06 1.72376e-05 5.92815e-05 -5.43856e-05 6.32462e-05 -1.79705e-05 -9.10398e-05 -1.72584e-05 -9.53224e-05 -1.9377e-05 -2.09e-06 -7.09568e-05 -3.69667e-05 3.66547e-07 3.62197e-05 0.000114362 -0.00012248 -3.81007e-05 3.17251e-05 -7.40521e-05 5.92776e-05 0.00010419 0.000100511 -2.61512e-05 -3.48326e-05 -0.000598721 0.000255009 0.000210824 5.66154e-05 -0.000200944 -0.000497635 3.36778e-05 0.000130074 0.000735559 0.000276348 0.000239917 -0.00027906 -0.0004793 -1.60579e-05 0.000351616 0.000397936 -0.000163498 -4.42889e-05 -9.21153e-05 0.000126038 -3.37541e-05 3.95308e-05 2.60869e-05 5.5194e-05 -0.000103997 -0.000178534 0.000131235 -0.000174356 -2.74433e-05 -7.75529e-05 -4.38433e-05 9.31755e-05 9.05053e-06 -5.99266e-06 -8.36072e-05 -0.000253695 -0.000137291 1.91408e-05 4.79785e-05 6.43084e-05 7.21278e-05 -1.7777e-06 -3.67721e-06 8.70681e-05 0.00017285 -0.000149875 -0.000106805 -8.48437e-05 -4.43282e-05 9.61978e-05 -9.53805e-05 -1.10184e-05 5.21335e-05 4.84225e-05 2.51144e-05 -0.00012628 3.53816e-05 -7.73243e-05 -0.000126704 2.46987e-05 8.75191e-05 0.000108019 8.46889e-05 -0.0001038 3.39963e-05 -6.51623e-06 -0.000112342 7.85456e-05 -3.80135e-05 2.27938e-05 5.48942e-05 -2.98444e-05 -0.000159196 0.000355726 -7.66521e-05 -2.8264e-05 0.000183387 4.25933e-05 7.73358e-05 -0.000117981 0.000215367 0.000139503 0.000214544 2.33089e-05 -4.97771e-05 0.000219711 0.000125294 -0.000103205 -0.000216723 -6.81569e-05 3.20576e-07 0.000169022 -0.000181824 0.000141158 0.000260488 0.000283844 -5.1926e-05 -0.000607474 -7.15267e-05 0.000163356 7.29574e-06 8.14809e-05 -9.94375e-05 -0.000102145 0.000322628 0.000454793 -0.000223141 -0.000183266 -0.000116899 0.000253968 -0.000105356 -6.23302e-05 9.77184e-05 3.38681e-05 6.6556e-05 -4.36553e-05 0.000350906 0.000198302 0.000142333 0.000174119 5.29485e-05 0.000181274 0.00021425 -7.62675e-06 -0.000252428 -9.56078e-05 -5.68966e-05 -3.22481e-05 -7.86952e-05 6.85906e-05 4.47486e-05 -2.6963e-05 -6.51048e-05 -7.10889e-05 2.50279e-05 1.57889e-05 5.91183e-05 9.29291e-05 4.14245e-05 -6.65369e-05 0.000163348 0.000184921 -3.46695e-05 -0.000130354 0.000293958 -0.000381075 -9.36063e-05 0.000363637 0.000124508 0.000190029 7.43917e-06 -0.00015293 -0.000490928 -0.000149126 -0.000419458 5.4329e-05 -3.34607e-05 -0.00015143 -7.92885e-05 -9.67739e-05 0.000432976 0.000287981 0.000139079 -0.000124603 0.000184333 0.000107584 -0.000238845 -0.000146684 1.8308e-05 0.000560324 0.000261294 -0.000193643 -0.000219639 -7.07901e-05 0.00024338 1.09578e-05 -0.000117283 -9.6763e-05 0.000173162 6.95494e-05 -4.62905e-05 0.000241044 -9.65591e-05 -6.56309e-05 8.28205e-05 5.58656e-05 -1.70572e-05 -7.71075e-05 0.000227413 5.19566e-05 -5.18841e-05 4.31715e-05 0.000103923 0.000129104 0.000177469 -6.56931e-05 -0.000169314 -0.00011469 2.79277e-05 7.34223e-05 -4.75543e-05 1.12853e-05 -2.93234e-05 -6.16852e-06 -8.67089e-05 -0.000134166 -5.50944e-05 -0.000103231 -5.74132e-06 0.000140096 2.13594e-05 -5.2473e-05 0.000103932 0.000100971 -4.33116e-05 -2.17487e-05 -3.29363e-06 2.37052e-05 0.000176296 -6.93992e-06 -0.000201005 -0.000101949 4.28781e-05 -2.70638e-05 -9.39755e-07 4.23208e-05 0.000112663 0.000218603 -2.58681e-05 -9.40934e-05 4.98023e-06 6.64335e-05 -4.04834e-05 -6.17758e-05 -3.24675e-05 -6.47112e-05 0.000153825 2.77046e-05 -0.000134147 -1.15614e-05 8.3335e-05 -4.8577e-05 -7.18451e-05 -0.000115484 5.74764e-05 0.00019094 0.000119856 -1.55309e-05 -5.68116e-05 -0.000125167 -0.000101616 0.000164332 -3.041e-05 4.51183e-05 0.000238941 -3.85524e-05 -0.000233313 -0.000127007 0.000109658 3.07119e-05 -7.87781e-06 -7.75303e-05 0.000138104 0.000324422 7.11076e-05 -0.000103248 -4.05551e-05 -0.000103505 -7.46644e-05 0.000121755 -7.11736e-05 1.59061e-05 -1.3619e-05 9.91798e-06 0.000103833 2.31742e-05 7.32087e-05 9.90379e-06 -7.97828e-05 -2.73978e-05 -6.34852e-05 6.64897e-06 2.88528e-05 -3.13698e-05 4.26738e-06 -6.98074e-05 -0.000105785 0.000120454 0.000239877 -0.000159806 0.000101613 2.97535e-05 0.000120239 0.000356412 -0.000305795 -0.000147678 -0.000204772 7.40185e-06 -0.000412183 -0.000119581 5.65362e-05 0.000165342 4.96078e-05 -0.000283885 8.44812e-05 -3.46532e-05 0.000187361 -7.28431e-05 2.3418e-05 -6.52135e-05 0.000148887 0.000242534 -9.63095e-05 9.29109e-05 2.05935e-06 4.11431e-05 -2.47534e-05 -0.000195399 -0.000104782 0.000114453 -0.000112695 -0.000123056 0.000162143 0.000153294 -5.16251e-05 7.8319e-05 0.00032942 -1.52237e-05 -0.000326402 -0.000122544 0.000162137 -2.6529e-05 -0.000110224 2.89001e-06 0.000184372 0.000450966 6.61085e-05 -0.000171345 3.2662e-05 2.06974e-05 -7.26222e-05 -7.92114e-05 -3.53766e-05 -1.91938e-05 6.14039e-05 -2.09328e-05 -1.79521e-06 3.07714e-05 0.000107821 3.00117e-06 -0.000117703 -7.28713e-05 -1.62941e-05 7.28842e-05 7.45202e-05 3.40877e-06 3.91525e-05 -0.000122929 -9.04465e-05 0.000190672 2.36637e-05 -4.50159e-05 6.39864e-07 -1.77311e-05 -4.20859e-05 -5.17723e-06 5.00778e-05 2.41444e-05 -2.26317e-05 -4.57662e-05 2.12058e-05 5.31042e-05 -3.32915e-05 -8.47528e-05 -1.37217e-05 1.8454e-05 2.98637e-05 1.86562e-05 1.44808e-05 -1.39395e-05 -4.16982e-05 9.71777e-06 2.9653e-07 -4.75687e-05 5.31119e-06 2.55936e-05 -8.53873e-07 -1.53866e-05 -5.10001e-06 -1.97346e-05 3.43247e-05 1.98767e-05 3.58508e-05 4.34316e-05 -3.14412e-05 -1.51947e-05 3.79626e-05 -1.15147e-05 -4.16073e-05 -3.44198e-05 -2.62217e-05 -2.85341e-05 4.32768e-05 4.14954e-05 -3.74964e-05 -0.000101668 -3.00017e-05 1.09047e-05 3.78315e-05 3.11517e-05 -3.24977e-05 3.67384e-05 2.41916e-05 -7.75935e-05 1.77865e-06 -7.90551e-06 -4.05229e-05 1.31679e-05 1.65948e-05 -2.18616e-06 3.55207e-06 1.94737e-05 3.29965e-05 2.23583e-05 -1.94308e-05 -3.09623e-05 9.92237e-06 6.24017e-05 2.12172e-06 3.47953e-05 7.97025e-06 1.81188e-05 0.00018274 -7.8887e-05 -0.000242578 -9.87785e-05 -4.95043e-05 0.000296165 9.55516e-05 0.000140719 -0.000307812 -0.00037905 8.11612e-05 -6.67713e-05 6.1966e-05 0.000363009 -5.07841e-05 0.000133982 0.000107889 -0.000102486 -3.55753e-05 -1.27175e-05 -4.45572e-05 0.000120015 0.000128453 7.44886e-05 -6.14885e-05 -6.85174e-05 -7.66369e-05 -7.84222e-05 6.82445e-06 5.57951e-06 1.49977e-05 0.000179864 0.000100707 -4.54273e-05 2.26306e-05 0.000155115 4.00763e-05 -3.83327e-06 9.1624e-06 2.8462e-05 -1.30129e-05 -7.56409e-05 -5.77437e-07 3.60291e-05 -4.54674e-05 -9.78059e-05 -4.97122e-05 2.3273e-06 -4.97274e-05 -9.30827e-05 2.82562e-05 5.84271e-05 -1.87832e-05 -1.59217e-05 -3.80031e-05 9.32686e-06 -1.19155e-05 3.80805e-05 -1.34025e-05 -2.63415e-05 1.93234e-05 -1.6547e-05 3.27015e-05 3.37767e-05 3.326e-05 -6.62365e-06 -2.75618e-06 2.73026e-05 2.18218e-05 3.90334e-05 -3.56502e-05 7.84471e-06 9.40322e-05 -8.65425e-06 -3.24512e-05 3.12479e-05 -2.96861e-05 2.60176e-05 -9.30316e-05 5.42578e-05 8.17682e-05 -6.1582e-06 6.18628e-05 3.47611e-05 -7.09982e-06 3.40289e-05 -6.53925e-06 -7.60455e-05 -5.94539e-05 8.14774e-06 -2.00674e-05 -9.44847e-06 -2.08671e-05 1.40332e-05 -1.54811e-05 -1.10821e-05 -2.47569e-06 -2.19659e-05 5.25729e-06 6.98146e-06 1.09541e-05 -1.8196e-05 1.0975e-05 1.50545e-05 9.22109e-06 3.20021e-05 2.48254e-05 1.08221e-05 4.74122e-05 -1.91583e-05 -4.22503e-05 3.1707e-05 -8.0591e-06 3.3832e-05 -4.062e-05 -6.97081e-06 3.82001e-05 -3.44568e-06 5.13207e-05 1.99733e-05 -2.7311e-05 9.56996e-06 3.25231e-05 2.57544e-05 -1.04821e-05 1.04882e-05 -1.46371e-05 -3.9441e-06 2.66295e-06 -3.06433e-06 -5.11208e-07 -1.49058e-05 1.63191e-05 -6.05232e-05 -2.77543e-05 2.4115e-05 5.75459e-06 -3.37141e-05 1.79754e-05 4.61394e-05 1.28364e-06 -3.04579e-05 1.61101e-05 1.84004e-05 0.000305757 3.59654e-05 0.000112654 0.000111823 7.62933e-05 0.000268223 -0.000333673 7.08099e-05 -9.7889e-05 -0.000210518 -0.000244066 -0.00031579 3.87998e-06 0.000204496 1.13064e-05 -0.00035526 -0.000219796 0.000120354 0.000141511 8.76412e-05 8.08944e-05 -2.91667e-05 -6.17456e-05 -7.05456e-05 -4.71316e-05 -1.80831e-05 -3.5122e-05 -7.03147e-05 -3.75161e-05 -0.00011692 -3.579e-05 6.87721e-05 -1.79007e-05 -4.11068e-05 -0.00011377 -1.67573e-05 2.02129e-05 -3.67616e-05 -3.93392e-05 1.70143e-05 6.18179e-06 -2.93895e-05 -5.6243e-05 3.10251e-05 6.53026e-05 4.07499e-05 0.000100119 5.74369e-05 -4.71638e-05 -3.86822e-05 -3.26396e-05 -2.13992e-05 -1.55696e-05 -5.62029e-05 -1.93876e-05 -6.54759e-07 8.12647e-06 -1.65984e-05 -5.0711e-07 -1.09975e-05 3.06164e-06 -3.7772e-05 -5.85529e-06 2.36018e-05 -2.22471e-05 -4.91881e-05 2.8216e-06 4.35977e-05 2.51899e-05 -2.23123e-05 -1.4845e-05 2.77444e-05 0.00013295 -0.000153662 -9.49401e-05 0.000134705 0.000103349 3.71238e-05 -0.000126715 0.000138102 9.13067e-05 7.28059e-05 -0.000197402 -1.9093e-05 -0.000133502 -7.52066e-05 -3.72665e-05 5.8139e-05 1.9847e-05 -0.000111425 8.78536e-05 -0.000135776 6.31138e-05 -2.9513e-05 -6.54721e-05 -6.5711e-05 -9.25675e-05 0.00025987 0.00026815 -4.69828e-05 -0.000104416 -0.000174353 0.000177985 4.77971e-05 -0.000184627 9.1373e-05 0.000157963 -0.000120923 0.000222631 -0.000309449 -0.000121001 6.25241e-05 1.90685e-05 -3.27796e-06 -0.000120535 0.000235809 0.000329917 7.27324e-05 -0.000167298 -0.00022565 -0.000129352 7.21457e-05 -0.000144449 5.00734e-05 0.00021036 -7.68433e-05 -2.49181e-05 -3.10188e-07 4.96299e-05 -7.51719e-05 -6.9754e-05 -1.76654e-05 0.000125281 -5.14878e-05 9.88623e-05 -0.000115589 3.13452e-05 -8.84881e-05 3.39094e-05 7.43214e-05 -0.000113067 -4.15016e-06 8.55874e-05 4.44485e-05 0.000376362 -0.000287275 -0.000100021 0.000391882 0.00022171 0.000483046 -8.02203e-05 -0.000400845 -0.000775187 -0.000138413 -0.000169552 0.000197529 -9.65486e-05 0.000147773 0.000419445 -0.000131774 -8.15249e-05 -3.83332e-05 0.00017027 -0.000192764 0.000277414 2.83693e-05 -0.000151213 0.000139794 0.000260264 0.000162219 -9.41979e-05 -0.000337712 8.38401e-05 0.00014989 -0.000127949 -4.2168e-05 5.45357e-05 -5.7857e-05 -0.000232888 0.000104564 0.000195615 -0.000281939 -0.00014464 -3.47774e-06 6.95881e-05 5.49439e-05 -0.000131414 0.000328198 0.000261106 3.80429e-05 -0.00027469 -0.000174947 -0.00019616 8.79752e-05 -6.26257e-05 8.20719e-05 0.00025308 -0.000128989 3.66126e-05 -0.000113984 7.8341e-07 -5.87335e-05 -4.54183e-05 -1.52354e-05 -5.17482e-05 0.000151193 0.00019732 -0.000128755 -9.6251e-05 -0.000126408 0.000142172 0.000119799 -0.000197024 4.24109e-05 0.000238296 -2.8831e-05 -0.000108154 0.00014005 -5.88161e-05 -2.10069e-05 1.41483e-05 -8.32922e-05 -7.57881e-06 -0.000106109 -1.75964e-05 -5.87047e-05 0.000111757 6.17622e-05 -3.39805e-05 2.82218e-05 9.34093e-05 5.26757e-05 -0.000131176 -4.98984e-05 -8.60076e-05 0.000143524 -6.4829e-07 -0.000102599 7.04636e-06 -4.29773e-05 6.0807e-05 -3.9528e-05 -0.000170031 -2.07171e-05 2.88261e-05 7.04133e-05 5.11554e-05 1.93486e-05 3.22711e-05 1.37006e-07 -2.01783e-05 -3.54564e-05 -0.000117232 6.11056e-05 4.24637e-05 -0.000123954 -6.07133e-05 -7.28703e-05 2.12519e-05 5.4682e-07 -4.25336e-05 1.36741e-05 0.000123843 0.000118788 5.87181e-05 1.58793e-05 7.1501e-06 2.2204e-05 -9.43109e-05 -2.23923e-05 -4.64158e-05 3.95591e-05 -8.9765e-06 -7.82104e-05 1.94046e-05 3.08982e-05 6.94188e-05 5.63049e-06 -8.54725e-05 4.72088e-05 -4.48986e-05 6.00349e-06 7.20219e-05 -1.58138e-05 2.10569e-05 1.85799e-05 3.62359e-05 3.20023e-05 0.00025772 -6.03879e-06 -3.63278e-05 4.60923e-05 -9.08817e-05 -8.37474e-05 -0.000166808 -0.000443623 -0.000287616 9.66268e-05 -0.000129642 4.4758e-08 -0.000117523 -2.63084e-05 -0.000284991 -5.1872e-05 5.97032e-05 0.000196543 0.000153807 6.98443e-05 3.38415e-05 2.25829e-05 -0.000111338 9.70318e-06 -3.60602e-05 3.10453e-05 1.87794e-05 -1.21318e-05 8.32814e-05 -0.000118966 -0.000102875 0.000155916 -0.000185398 -0.00020117 0.000154116 0.00016638 -0.000168535 0.000177591 0.000106997 -0.000185937 -0.000106899 -0.000113991 5.59421e-05 -0.000104775 1.4962e-05 0.00011885 0.000277719 6.97312e-05 -5.33913e-05 9.00851e-05 7.54964e-05 5.26346e-05 -0.000253269 -4.12694e-05 -7.7641e-05 0.000202718 0.00010863 -0.000161807 5.25457e-05 5.27397e-05 8.48029e-05 -8.27206e-05 -0.000195058 3.35578e-05 3.63453e-05 1.63016e-05 6.78494e-05 -6.25527e-05 1.28651e-05 1.29541e-05 4.68622e-06 3.55982e-05\nweightContainer_input_to_hidden_0_0_plasticities 7200 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\nweightContainer_input_to_hidden_0_0_weights 7200 -0.024238 0.0831481 0.156692 0.088098 -0.117357 0.0654326 -0.127868 0.0123384 0.0963387 0.147643 0.0461988 0.0300506 -0.0926132 -0.123047 0.0515269 0.109034 0.282002 0.00276459 0.0769242 -0.178259 0.134785 0.0584939 -0.0207822 0.0884894 -0.281889 0.339503 -0.236911 0.0268272 0.0195066 -0.0398158 0.0633983 -0.0948887 0.101622 0.0427896 0.0654147 -0.0201197 0.0162434 -0.0388198 -0.0325715 -0.00638709 -0.0485469 0.13943 -0.134437 0.0600339 -0.0751849 0.158209 0.054945 -0.0535397 -0.0478103 -0.114309 -0.106045 0.00380376 0.290631 -0.0667401 -0.062905 -0.040305 0.0953553 -0.16666 0.0623389 0.0608631 -0.266438 0.172362 -0.101537 0.0246391 -0.0155682 -0.116084 0.0554795 -0.0790821 -0.00242237 0.170256 -0.00500894 0.0196135 -0.00856626 0.148979 -0.0147421 -0.0478496 -0.04072 0.0792305 0.0266857 0.165001 -0.228722 -0.0740218 -0.132372 -0.0275719 0.102505 -0.052908 0.129423 -0.467646 -0.346637 -0.0930085 -0.00830274 -0.0312964 0.208424 -0.196012 -0.168658 0.255865 -0.372061 0.443386 -0.371216 0.0985864 0.0746252 0.0133168 0.269279 -0.222878 0.154501 -0.111337 -0.211272 -0.0947324 0.0980318 -0.0649341 -0.0415206 0.081539 0.060061 0.141366 -0.249821 0.13896 0.00158639 0.164464 0.00717421 -0.0817531 -0.0331921 -0.201946 0.059302 0.232805 0.348103 -0.0643145 -0.067715 0.0593452 0.19236 -0.0608023 0.00999742 0.0898059 -0.43672 0.264335 -0.276477 0.0716894 0.0305134 -0.0237455 0.095437 -0.249389 0.137905 0.0388086 0.000506887 0.0115 0.0441528 -0.0631134 -0.10637 -0.219446 0.000275399 0.104984 -0.0154293 0.0456343 0.11074 -0.00589192 0.0748011 0.0478567 0.0471559 -0.0651854 -0.0215303 -0.0389655 0.0265106 -0.0775011 0.00229157 -0.11824 -0.0392629 0.0973311 0.0765289 0.0398239 -0.118903 0.00754683 0.131903 -0.108567 0.0386298 0.0982188 0.0422125 -0.155919 -0.0219562 0.187459 -0.00319048 -0.160286 0.186862 -0.106099 0.0421935 0.0145788 0.0354287 -0.0193222 0.0894451 0.144621 -0.0341902 -0.129587 -0.0370165 0.146898 0.0703497 -0.141085 -0.0749964 -0.0486298 -0.0335555 -0.189769 -0.166559 0.117215 0.0925124 0.123961 -0.0109449 -0.0873365 0.164419 0.0354077 0.0158984 -0.0354769 -0.0751876 -0.150888 -0.0389705 -0.0201987 0.0751914 0.00302783 0.0442398 0.0526447 0.23316 -0.123961 -0.0921809 -0.0272516 -0.174961 0.130758 -0.157733 -0.0928758 -0.00507385 -0.00199975 -0.0167253 -0.165767 -0.0822499 0.139355 0.0164261 0.0180308 -0.039593 0.114932 -0.121375 -0.10195 0.0206709 0.172376 0.00712142 0.0545062 -0.0778576 -0.0354972 -0.00620943 0.00205971 0.011526 0.0460488 0.0512683 0.171687 -0.0549667 -0.00291178 -0.0333187 0.180175 0.133409 0.124977 0.0480537 0.0752474 0.171897 -0.121168 0.107319 -0.061878 -0.0161923 -0.0353867 -0.0916533 -0.0188307 0.0236704 -0.0121815 0.0535039 -0.00879707 -0.0629193 -0.0468586 0.0851812 0.0223738 0.019961 0.059851 0.0604635 -0.100048 0.0237208 -0.0635694 -0.0254584 -0.0305908 -0.0153272 -0.0565349 0.0799136 -0.045804 -0.00545311 0.0055979 0.0954241 -0.067463 0.366713 0.280324 -0.0938689 -0.320981 -0.0638368 -0.0652613 0.0608536 0.0231677 -0.00820484 -0.0843875 0.130346 0.0551896 0.0165765 0.041611 -0.301735 0.00120671 0.0568084 -0.0609585 -0.0713654 0.0746309 -0.165904 -0.144355 0.216227 0.246629 0.268845 0.112863 0.169203 -0.0489627 -0.0577621 -0.0690545 -0.172051 0.0438924 -0.127301 -0.0218893 0.189088 -0.0599913 -0.0119863 0.108425 -0.242845 0.202654 0.318978 0.302832 -0.00129704 -0.105631 -0.246548 -0.215676 -0.244276 -0.039137 0.0237464 -0.133758 0.0281677 -0.0294849 0.176013 0.0494105 -0.0702797 -0.0321255 0.235073 0.202946 0.13015 -0.0251707 -0.10069 -0.322977 -0.0335861 0.0728559 -0.175303 -0.111213 0.157505 0.115741 0.0469247 -0.140108 -0.0297352 -0.124117 0.588742 0.110156 0.0821631 0.242432 -0.331429 -0.400222 -0.0078338 0.615668 0.344971 0.31025 -0.0978686 -0.242453 0.0698129 0.101094 0.0648747 -0.210506 0.0638267 -0.0112411 -0.120247 -0.181467 0.346315 0.127672 -0.726777 -0.366026 0.371432 0.490899 0.12721 -0.404653 -0.0890296 -0.0231745 0.0495622 -0.194307 -0.0585312 0.0711346 0.151125 -0.168525 0.233643 0.0504848 -0.0190115 -0.0692618 0.162402 -0.245185 -0.130757 -0.236218 0.087821 0.0177981 -0.040424 -0.0930957 0.0512351 0.0428793 -0.102606 0.107012 0.0111653 0.16178 -0.254363 0.115105 0.343697 -0.225066 -0.039833 -0.0874128 -0.321706 -0.417751 -0.00452597 0.411669 -0.0193136 -0.0904361 -0.0251434 0.160089 -0.00248408 -0.228877 -0.0553096 -0.0550377 -0.24633 0.017232 -0.0819724 -0.0343877 -0.184408 -0.106878 0.0319913 0.164859 0.137871 0.0121447 -0.110544 -0.17591 -0.162042 -0.00255422 -0.0494011 0.0209591 0.128395 -0.0548997 -0.238544 0.178973 0.180071 -0.0832519 -0.244698 -0.179079 -0.0248562 0.329708 0.205298 0.0593644 0.0935221 -0.00895935 -0.0378961 -0.0734575 -0.14069 -0.0587738 0.0804551 0.0485188 -0.14864 0.210962 -0.0763817 0.106472 0.111881 0.0548297 -0.0302409 0.104917 -0.0158781 -0.116635 0.0291957 0.036353 0.0881758 0.157817 0.216611 0.00651386 -0.0534016 -0.0577201 -0.193107 0.226657 0.121272 0.195167 0.226612 0.13517 -0.00862345 -0.091808 0.0199437 -0.0533296 -0.0330363 0.00999867 0.0888316 0.110222 0.00296701 -0.0158799 0.0581277 0.114276 0.0298602 0.386922 0.115208 0.0861395 -0.0307885 -0.157265 -0.112682 0.099203 0.00601897 -0.234063 -0.0647323 0.0137964 0.0305806 0.0801108 0.0709332 0.0258639 -0.0152458 -0.038069 -0.0481275 0.247041 -0.074413 0.126133 0.238719 0.2324 0.14052 -0.1523 -0.0473711 -0.190158 -0.196133 0.010963 0.0859141 0.0788597 0.0575578 -0.0520606 -0.00612423 0.0187522 -0.0276099 0.248538 -0.110616 0.104808 -0.114198 0.0996467 -0.232891 -0.032359 -0.0302989 0.00485466 0.0734009 0.0805478 0.0410229 0.104905 0.00106349 0.0830592 -0.0980939 0.0446764 -0.399278 0.181327 -0.346852 0.156575 0.367244 0.403913 0.0662146 -0.298671 -0.036637 -0.097938 -0.107505 0.0937143 0.013648 0.0495948 0.129375 0.103696 -0.0810295 -0.0070509 -0.077499 -0.00713937 0.359918 0.0320135 -0.0946247 -0.169921 0.145781 0.0961233 -0.162513 -0.123713 0.149906 0.105494 0.040244 -0.113942 -0.0824022 -0.117534 0.0478359 -0.0254023 0.284464 0.276999 -0.0284357 0.107224 -0.0548911 -0.0844645 0.254052 -0.113599 0.0331692 0.107645 0.0455201 -0.161176 0.0697245 0.0294018 -0.15256 0.0207951 -0.0626805 0.0117525 -0.122365 -0.0475792 -0.0949739 -0.0724207 0.052915 -0.0343631 0.138529 0.142146 -0.073044 -0.147292 0.000162088 -0.0129956 -0.00867623 -0.172071 0.179372 -0.0186394 0.137067 -0.00581786 -0.0354694 0.400251 -0.0600193 -0.249869 -0.269211 -0.107568 0.118211 -0.00186958 0.108692 0.0984119 -0.173087 0.0866795 0.031925 0.12353 -0.0611282 -0.0329764 -0.153244 0.0716542 0.0775352 -0.623792 -0.0912691 -0.00976556 0.329462 -0.336463 -0.0504377 0.149846 -0.0802974 -0.0670837 0.181895 0.120943 -0.122448 -0.0693468 0.173589 -0.149918 -0.019868 0.110232 -0.15523 0.039106 -0.384181 0.298043 0.21084 0.218739 0.00104856 -0.0682396 -0.0843486 0.162903 0.14623 0.111895 -0.0750203 -0.00414001 0.180735 -0.00829317 0.000838893 0.00894623 0.0229288 0.0725331 -0.0709031 -0.165814 0.0681159 0.108959 -0.0936259 -0.0469289 0.20539 0.0470994 -0.222804 -0.0927579 -0.0191309 0.129474 -0.0656783 0.147791 -0.10353 -0.129194 0.45096 0.12614 -0.154312 -0.294219 -0.304594 -0.0905819 -0.0313037 0.0466014 0.188525 -0.0616584 -0.0681954 0.0199963 -0.025839 -0.0957905 0.0765171 -0.0691832 -0.0316108 -0.0918585 0.125721 -0.252993 0.218178 -0.323196 0.175085 -0.395231 0.220759 0.0188161 0.0823609 -0.0771299 0.00686 -0.0429338 0.249766 -0.0614495 -0.0764658 0.0412098 -0.023395 -0.00365725 -0.89781 0.462511 0.0341432 -0.340697 0.125868 -0.201811 0.164183 -0.181523 -0.0937034 -0.145218 0.217185 -0.148456 0.165168 0.0480315 -0.0347093 0.0563788 0.0484874 0.0235814 -0.0878702 0.114313 -0.0458599 0.127747 0.0849883 -0.0494404 -0.0524839 -0.0866802 -0.0233556 -0.23232 0.0284776 -0.157009 -0.172731 -0.198698 0.188346 -0.116186 0.107772 -0.0390953 0.31784 -0.103165 0.0134395 0.0137509 -0.0216969 0.0963469 0.130231 0.109646 0.0108912 -0.0740266 -0.185806 0.00812022 -0.0993809 -0.0883866 0.0207792 0.0638841 -0.0255738 -0.0627268 0.170748 -0.13514 -0.357452 0.0525704 -0.151338 0.140761 -0.0775363 -0.0233547 -0.0837511 0.0193042 0.0207092 0.0476196 0.005573 0.0365868 -0.0442171 -0.0471757 -0.0133315 0.118219 -0.0617684 -0.257304 -0.253901 0.0378481 -0.192902 -0.0259089 -0.193322 -0.000617127 -0.110365 0.116059 -0.0623604 0.102738 -0.0124913 0.0126592 0.0392589 0.0743933 -0.0442269 0.057998 -0.574807 0.0623915 0.0714593 0.144265 0.298248 -0.0132642 0.0471096 0.00498736 0.0526886 0.0718506 0.0985395 -0.0231198 -0.0486939 0.0480024 0.0758911 -0.0573129 0.0746279 0.0306062 -0.201627 0.12919 0.0750555 0.251152 0.238256 0.0910866 0.0367766 -0.140406 -0.00187014 -0.0319176 0.121345 0.0398942 0.0205151 -0.00331213 0.0247593 -0.0134848 0.0527451 -0.00123081 0.0761651 0.0840602 0.0322083 0.159379 0.0800246 0.0245784 -0.099803 -0.200291 0.0857814 -0.0988517 0.188808 -0.133632 0.110131 -0.150878 0.0389279 -0.118825 0.0185862 -0.0938511 0.1046 0.0659034 0.175143 0.335107 0.271449 0.239296 0.196038 0.0104804 -0.0479451 0.0199175 -0.238528 -0.306193 -0.286303 -0.177233 -0.261668 -0.0919173 -0.000214449 0.0294447 -0.110077 -0.0559021 -0.163364 0.0823053 0.127263 0.0341123 0.0892356 -0.183569 -0.133113 -0.0170664 -0.137975 -0.0697119 -0.0231682 0.00952845 0.101845 0.0453667 -0.162597 -0.0699552 -0.187741 0.0776718 0.0183297 -0.012416 0.163488 0.21095 -0.0589849 0.0290422 0.0242462 0.0821638 -0.0583499 -0.0902166 -0.162956 0.00417101 -0.0909735 0.0683343 -0.00579114 0.1167 0.250434 0.173498 0.0897062 0.125591 -0.0562924 -0.0821127 -0.0288288 -0.108169 -0.0207397 -0.157973 -0.112642 -0.246757 -0.090299 -0.164901 0.0599672 0.0464611 0.0540327 -0.000793813 -0.1431 -0.332582 -0.33542 -0.355349 -0.252583 -0.375177 -0.241497 -0.317584 -0.0988317 0.0365095 0.162527 0.222032 0.266937 0.221831 0.144771 0.161035 0.0332971 0.0228562 0.227366 0.0135941 -0.200058 0.0928482 0.042835 0.150483 0.0571342 -0.21018 -0.0742853 0.0134514 -0.00714563 -0.113551 0.12425 -0.0466925 0.0863328 0.040779 -0.052799 0.0548529 -0.245863 0.335175 0.00316636 0.296424 0.329087 0.207206 0.108315 -0.145772 0.0833857 0.103894 0.0347765 -0.0156121 -0.168755 -0.0127698 -0.0553354 -0.0529411 -0.0862301 -0.0560175 -0.194563 -0.149686 0.0958659 -0.0180887 0.287869 -0.0233292 0.0756905 -0.120728 -0.0987482 -0.165926 -0.0146358 -0.129221 0.0591822 -0.0399636 -0.0196319 -0.0183073 0.00370414 0.0543926 -0.214447 0.284206 0.221558 0.0839868 0.161147 0.0491741 0.0688882 0.0492508 0.0209688 -0.0318319 -0.0119905 0.0435696 -0.00326126 -0.0777898 -0.0548172 0.115109 0.0977897 -0.0379416 -0.37609 0.0534254 -0.0210033 0.254764 0.151704 -0.0417505 -0.101555 0.0340679 0.0844496 0.0329509 -0.0286671 0.122794 0.0321034 -0.185482 0.167449 -0.079748 0.0766215 0.217559 0.117022 0.115866 0.0286581 0.204209 -0.034073 0.198037 -0.0437011 -0.0721075 -0.0859998 -0.0397244 0.00785915 -0.0110282 -0.0298051 0.0947298 -0.0328737 -0.0416322 -0.0689493 -0.0358416 0.15502 -0.106494 -0.209695 -0.483332 -0.282287 -0.16444 -0.0155049 0.142573 0.121438 -0.000717262 0.0789736 -0.0302178 0.0773526 0.0314766 -0.0927042 0.0312027 0.0865817 -0.149389 -0.877062 0.345902 -0.186323 -0.0294075 0.0486802 -0.0176892 -0.00202708 0.139805 0.104203 -0.00876829 -0.0298823 0.00701443 0.05965 -0.0336346 -0.0596571 0.0496323 0.0619121 0.00509505 -0.239968 0.279355 0.153091 0.375139 0.331141 -0.0661301 0.02094 -0.229585 -0.0838515 -0.033561 -0.0724115 -0.0883053 0.0721396 -0.0248273 -0.0274175 -0.0879868 -0.108795 -0.00932981 0.510212 -0.0389731 -0.00750731 -0.0774664 -0.179297 0.119783 0.0234812 -0.155223 0.026804 0.00824763 0.100114 0.0479733 0.0531191 0.0486741 0.154162 -0.0778476 0.0339301 -0.0954922 0.226656 0.217862 -0.0727609 0.185286 0.295848 -0.184288 -0.111082 -0.0630491 0.0877769 -0.00945723 -0.244429 -0.203672 -0.0464313 -0.258739 -0.100501 -0.127699 -0.231139 -0.216911 -0.0713769 0.234302 -0.346149 0.108975 0.214487 -0.137214 -0.00444387 -0.136979 -0.0790572 -0.0227218 -0.253024 0.0229847 0.192614 0.105316 0.102208 0.020922 -0.0104385 -0.0733168 -0.100559 0.0490276 0.0669721 0.14613 -0.142093 0.162865 0.252204 -0.196452 0.0271191 0.044067 -0.177132 -0.0541028 -0.245336 -0.0276417 0.00791751 0.00613267 -0.107844 -0.110019 0.256312 -0.121317 -0.171683 0.297778 0.163574 -0.155942 -0.203402 0.0197452 0.114733 -0.0547466 -0.0296394 -0.250832 0.282213 -0.134422 -0.0282324 0.17835 0.0633753 0.0960454 -0.381536 -0.262867 -0.513456 -0.108566 -0.107859 -0.182482 -0.33709 -0.159566 -0.0886036 0.23771 -0.0122844 0.164319 0.0352479 0.349512 0.0770061 0.0627991 0.0877133 0.356693 -0.649177 -0.138868 -0.22282 0.378489 0.378319 0.017756 0.229676 0.0957227 0.330766 0.534568 -0.10468 0.518083 -0.0176573 0.080148 0.124607 -0.11407 0.0680819 0.0269233 -0.317646 0.157259 -0.256984 -0.0583682 -0.117967 -0.0232311 -0.133577 0.115898 0.186762 -0.0102522 -0.00701095 0.114022 -0.37428 0.0141632 -0.231701 -0.144186 -0.0902303 -0.351809 -0.110171 0.341815 0.110514 0.273217 -0.145741 0.0421338 0.142556 -0.0240655 0.0520397 0.133976 -0.0574689 0.0121876 -0.22809 -0.0534381 0.0610279 -0.133389 -0.0324974 -0.0181874 0.119899 0.0307696 0.0267087 -0.053299 -0.0659223 0.0693893 0.00388578 0.00931885 -0.0129846 -0.0374135 -0.159361 -0.251404 -0.0177682 0.125616 -0.0408687 -0.102978 -0.18903 0.158083 -0.128775 0.0836136 -0.0257395 0.252861 0.198604 -0.171946 -0.177668 -0.00615935 0.106431 -0.0579232 0.0599856 -0.130727 -0.169122 -0.14258 0.0877172 0.225133 0.0934763 0.0517297 0.27826 0.0413213 -0.125204 0.064578 0.0278934 -0.0830492 -0.0565897 0.0268532 -0.0880178 -0.10686 -0.103821 0.0112467 0.0732129 0.0502277 -0.0891591 -0.248898 -0.170865 0.0886083 0.24703 0.0619775 -0.110599 -0.129802 0.0431855 -0.139315 -0.0541727 -0.125848 0.0540588 0.130214 -0.0445483 -0.167049 0.00226904 0.00832049 -0.0135072 -0.0295835 0.132839 0.0194889 -0.128418 0.516136 -0.023735 -0.0381176 -0.135319 0.0496575 0.00945731 0.106298 -0.112815 0.11097 -0.191482 0.0703283 0.0317941 0.10134 -0.0643303 -0.306428 -0.265885 0.140365 -0.530438 -0.506514 0.164201 -0.185502 -0.259344 0.0600271 -0.129889 0.198367 -0.057035 0.0743254 -0.0433704 -0.0748593 0.0349683 -0.0377938 -0.0209367 -0.0538798 -0.0512008 0.0429807 0.204056 -0.0376964 -0.299724 -0.068228 -0.0324318 -0.255758 0.0190302 0.102969 0.149169 -0.181934 0.035391 0.0247575 0.012695 0.152943 -0.234347 -0.21881 -0.222988 -0.0656424 0.129118 0.324198 -0.151182 0.0226718 0.050798 -0.0754103 0.0209436 -0.109186 0.029247 -0.109908 -0.140098 -0.187902 -0.0933169 0.186924 -0.0755407 -0.0415981 -0.159711 -0.0797964 0.694232 0.253598 -0.533514 -0.114819 -0.132495 -0.0123605 0.0359674 -0.0513083 0.0585394 -0.047001 -0.0960617 0.147711 -0.085924 0.00580715 0.0363797 0.000277488 0.0139967 -0.0222674 -0.0231078 -0.166618 0.00097242 -0.195454 0.235459 0.0374126 -0.012227 -0.126375 0.0471344 -0.314059 -0.184513 -0.0396354 0.153759 0.00116119 0.42545 0.146418 0.234497 0.0144031 0.177144 0.18549 -0.319468 0.00156475 -0.133733 0.0588021 0.133136 0.248991 -0.0612309 -0.0476031 -0.17811 0.0123184 0.00590625 0.176027 -0.0800362 0.0090133 -0.137798 0.141868 -0.674222 -0.191053 0.359529 0.315224 -0.03509 -0.0281697 0.132598 -0.23386 -0.0582587 0.07529 0.0551525 0.0416298 0.148227 -0.0642761 -0.11282 -0.114481 -0.194221 0.00487634 -0.496286 -0.0687881 0.741367 -0.0489026 -0.0133862 -0.0235388 0.00873436 -0.0596186 -0.00960799 -0.0757325 0.155022 0.104713 0.116108 0.0266001 -0.0305222 0.0558614 0.115283 -0.0442663 0.0741008 0.229441 0.486218 -0.451044 -0.266201 -0.169992 -0.0312682 -0.1062 -0.0100644 0.00903123 0.0798082 0.120344 -0.248306 -0.0248754 -0.0483819 -0.00731089 0.0380034 -0.0727823 0.545938 -0.0813682 -0.262278 0.228364 0.166432 0.0792646 -0.0657012 0.126805 -0.00407468 -0.103278 0.0954531 -0.0174983 0.0512513 -0.14106 0.0842332 -0.150103 0.115981 -0.0235967 -0.340845 -0.421529 0.068928 0.578989 0.243422 0.213307 0.00204067 0.0590502 0.310425 -0.222182 0.158104 -0.0953741 0.171308 -0.0893278 -0.200587 -0.0214176 0.0167229 -0.00618162 0.0543929 -0.257325 -0.313341 0.396814 0.287168 0.216504 0.0816621 -0.239837 -0.111641 0.167534 0.0290944 0.202438 -0.0513814 -0.0840328 0.03473 0.0625967 0.159915 0.120815 0.0141571 0.181864 0.177789 0.14759 -0.0511322 0.123987 0.0714574 -0.193833 -0.0074548 -0.348783 0.0913701 0.0993557 -0.191389 -0.0613623 0.0938027 0.0027341 0.10006 0.187833 0.0360087 -0.184373 0.0774311 0.421256 0.294871 0.205671 -0.143987 -0.233667 -0.0139916 -0.112008 0.0479594 0.0175781 0.228717 -0.100401 -0.120062 0.230771 0.228716 -0.106146 -0.0199438 -0.0288759 -0.0635058 -0.131495 0.0210488 0.138608 0.0157507 -0.22682 -0.0378673 -0.15705 0.0154595 0.0193348 0.103308 0.0287765 -0.0915438 0.00360683 -0.0589638 0.0469937 -0.423173 -0.0410451 -0.292472 0.349101 0.541122 0.0856671 0.0705769 0.102131 0.185039 -0.129154 -0.51279 0.0680818 -0.21611 0.179252 0.17031 -0.1355 -0.0530428 0.0637283 0.262424 0.064763 0.0336953 0.295578 0.131504 0.261225 -0.0450029 -0.522505 -0.160948 -0.292565 0.308783 -0.253913 -0.105378 0.14183 0.0101347 0.250136 -0.0743936 -0.00758074 0.427943 -0.123071 -0.00729987 0.19672 -0.202863 -0.0492088 0.0205579 -0.170229 -0.000121788 -0.027076 -0.0967094 0.073449 0.172839 -0.128196 -0.0194812 -0.0732399 -0.13424 -0.286658 -0.184497 0.065826 -0.306795 -0.0574908 0.0243192 0.0387761 -0.119609 -0.175867 -0.00289854 -0.371698 0.149077 -0.258427 0.0185824 0.0382651 -0.246851 0.110859 -0.0963393 0.0111769 0.113471 0.464166 0.465241 0.151715 -0.0182246 0.0373046 0.0273846 -0.0115642 0.0369683 -0.147568 -0.0315068 -0.100215 -0.336833 -0.211655 -0.180573 0.105157 0.0612095 0.0257308 -1.01085 -0.320639 -0.0847427 -0.330503 -0.193563 0.0391683 0.0664143 -0.0401303 0.444313 -0.0832009 -0.2306 0.2738 -0.0738526 -0.167662 0.203426 0.123616 -0.15294 -0.261679 -0.244881 -0.140675 0.153326 0.0603034 0.328974 0.0497627 0.187702 -0.0146561 -0.113677 -0.258171 0.0530143 -0.0635792 0.0985763 -0.000635326 -0.0552713 -0.0033738 0.0749584 0.191354 -0.00694705 -0.106831 -0.0256127 -0.0257453 -0.112335 -0.140874 0.0233805 0.172839 0.0556517 0.0231894 0.0522727 -0.0287152 -0.0650501 -0.0833001 -0.0657665 -0.0105148 0.0169963 -0.023152 -0.0699006 0.0568768 -0.555576 -0.577227 -0.628741 -0.507039 -0.192581 0.385591 0.249013 0.194629 0.213457 0.0349348 0.135501 0.036268 0.045629 -1.31985e-05 0.584106 -0.382301 1.08731 0.130907 -0.326389 -0.0914419 -0.422595 -0.479729 -0.253673 -0.114897 -0.0181818 0.223204 -0.175979 0.0853184 0.023208 -0.0423706 -0.028891 0.0670488 0.157491 -0.370643 0.0371154 0.710815 0.440047 0.840975 0.400389 0.0499925 0.101243 -0.357722 -0.30849 -0.180609 -0.284732 0.0388575 -0.00633045 0.0161891 0.117943 -0.181083 -0.377323 -0.269212 0.123541 -0.232331 -0.273004 -0.137823 -0.0283919 0.0440493 0.0711015 0.167137 0.0739107 -0.00494333 0.0243752 -0.186491 -0.126799 -0.0101467 -0.0685583 -0.22025 0.178701 0.153932 0.0510439 -0.141203 -0.0262942 -0.195179 -0.192786 -0.0695845 0.0414523 -0.0252566 -0.1522 -0.0180156 -0.164491 -0.0595736 -0.10024 -0.0871258 -0.098258 -0.0562009 0.0468179 -0.0552517 0.647738 -0.499684 -0.166974 -0.171914 -0.251733 0.0161008 -0.235867 0.00847337 0.00706891 -0.00331271 -0.00299924 -0.0338166 0.0409945 -0.151564 -0.0170833 -0.0283917 0.010349 -0.0707336 0.357097 -0.133442 0.210183 -0.0450635 0.000393728 -0.0744447 -0.00332304 -0.0317979 -0.0202789 -0.0574927 0.0198746 -0.0172648 0.0498621 -0.0863941 0.0307207 -0.0554309 0.0302759 -0.0203416 -0.441922 -0.034034 -0.0112972 -0.0380946 0.157469 -0.0470087 0.102682 -0.0575572 0.0407647 0.0332675 -0.0501978 0.00784559 0.0108887 -0.018894 -0.00516572 -0.0316335 0.00220007 -0.000349774 -0.218788 0.00439093 -0.12677 0.0951307 0.121337 0.0317339 -0.0654089 0.0539912 0.159557 0.0398743 0.153714 -0.0123725 -0.0183154 0.0608491 0.076366 0.0195074 -0.00408015 0.0805816 -0.605841 0.251621 0.109162 0.278335 0.24868 0.0369328 0.123438 -0.0269623 -0.0127454 0.0633571 0.0509826 0.0815508 -0.0112323 0.123853 -0.00757301 0.0196002 0.0252491 0.0645522 0.506327 -0.238212 0.0676912 -0.143826 -0.0740062 -0.0505544 -0.0654515 0.00847796 0.0273298 -0.00518086 0.013874 0.0122774 0.0127647 -0.0579879 -0.0157013 -0.0579825 -0.0261315 -0.0201964 0.798131 -0.0164766 -0.0231309 -0.198849 -0.122721 -0.0323859 -0.00496166 -0.00348791 0.0108625 -0.0473496 -0.0661195 -0.0511084 -0.0300391 0.0245797 0.00211133 0.00659337 0.0064156 -0.00632644 0.00513316 0.0847764 0.111202 0.126756 0.180457 -0.0387135 0.187516 -0.158308 0.0598278 0.0133507 0.133 -0.0312383 -0.164382 -0.106181 -0.117826 0.132647 0.00762435 0.147434 0.306396 0.261434 -0.12767 -0.276352 0.0103665 -0.211007 -0.106041 0.104837 0.0473103 0.126944 -0.0508836 -0.0895867 -0.0146479 0.0263911 -0.023885 0.0384882 0.0854025 0.0565903 0.249777 -0.111862 -0.158735 0.0468168 0.0842608 -0.104796 0.0964849 0.0986799 0.108269 0.0595543 -0.0424054 -0.0196979 0.0137548 -0.152129 -0.13127 -0.0856146 0.117157 -0.0106996 -0.22016 -0.0157277 -0.231685 0.0498426 0.082483 0.134296 0.0709351 0.267529 0.17784 -0.103307 -0.0228711 0.0318831 -0.0147726 -0.0737202 0.0267483 -0.136565 -0.0107117 0.0718384 -0.335219 0.040411 0.0347034 -0.0119342 -0.200974 0.304135 -0.0879287 0.131443 -0.0267247 0.0630792 -0.0459766 0.0426209 -0.163947 -0.14548 0.0618483 0.0213735 0.159698 0.112743 -0.974183 0.376075 -0.0425644 0.10422 -0.0894774 0.0855218 -0.0351145 -0.0209485 0.0660785 -0.0587439 0.0883196 0.0244079 -0.0619741 -0.0169052 0.0158919 0.0374794 0.145309 -0.0176948 0.0101959 0.13186 -0.129841 0.0976769 0.229837 -0.266894 0.0659126 0.00823888 0.232701 0.0104413 0.12039 -0.0997295 -0.229297 0.0497844 -0.034332 0.152438 0.0645699 0.0429688 0.15483 -0.166319 -0.164956 -0.218385 0.100682 -0.143678 -0.149193 0.0886365 0.193895 0.162091 -0.120635 -0.00486288 -0.0595731 -0.0615885 -0.0133664 0.0944259 0.0178611 0.0201577 -0.0713798 0.105261 -0.159743 0.116959 -0.113392 -0.00892442 0.0302805 -0.154701 -0.0743032 0.0670623 0.187788 0.152562 0.350758 -0.117338 -0.0232441 -0.0651483 -0.0690427 0.117778 0.158609 -0.121891 -0.175633 -0.0957448 -0.191135 -0.0428844 0.0244134 0.176302 -0.0201488 -0.228701 0.0658814 0.202516 0.300077 -0.16208 -0.308083 -0.0876494 0.127286 0.0360735 -0.166244 -0.00805838 -0.100302 0.329323 0.110102 0.105192 0.141772 -0.263418 0.147672 0.0367144 -0.0470765 -0.0305402 -0.113399 0.11033 0.0754458 0.0179201 0.0123168 0.0631464 0.178019 -0.0910919 0.0809741 -0.0403543 -0.0843598 0.133267 -0.0858885 -0.242485 -0.177163 0.0794046 0.0223306 -0.0323055 -0.172836 0.02821 -0.0705095 -0.0626693 -0.080249 0.0246209 0.498298 -0.0246713 -0.284876 -0.599181 -0.132138 0.419314 0.246546 -0.16407 -0.278896 -0.00198975 0.0244008 0.169219 -0.0426332 0.159518 -0.0435945 -0.0800095 -0.0265564 0.0699315 0.165779 0.0959997 -0.312989 -0.498674 0.26074 0.436475 0.27944 -0.383614 -0.153394 -0.00690337 0.239867 0.0312492 -0.0602188 -0.000606651 0.0684262 -0.141259 -0.0193251 0.135205 0.137471 0.150631 0.0300052 0.0441684 -0.282115 -0.536243 -0.245586 0.270881 0.286902 0.0658838 -0.147801 0.119941 -0.110393 0.0313528 -0.0787207 -0.061321 0.113353 -0.100945 0.502152 -0.158998 0.250777 0.239538 -0.2442 -0.485284 -0.478688 0.146174 0.0222339 0.026712 -0.06932 0.0613119 -0.0744498 -0.0729277 -0.0274306 -0.0187585 -0.0212793 -0.106062 0.246411 0.0815619 0.200273 0.133511 0.0697571 -0.210098 -0.348154 -0.206343 0.156102 0.217614 0.286583 0.0574319 -0.230062 0.165342 0.00744225 -0.179026 -0.0402819 -0.263144 -0.0327359 0.14941 -0.00911902 0.0979971 -0.116699 -0.273026 -0.15703 0.210287 0.0594695 -0.0550099 -0.0381631 0.00262171 -0.0238062 -0.107483 -0.0959004 0.107548 -0.076804 0.0587557 0.151414 0.0630485 -0.0800093 0.0447372 0.00186359 -0.0460519 -0.0589348 -0.0387255 0.134329 -0.0076888 -0.115644 -0.137218 -0.135412 0.0279537 -0.078109 -0.0592436 -0.0923389 -0.0448507 -0.265566 0.135547 -0.212457 0.0591987 0.0866288 -0.0878697 0.268413 0.268308 0.0163764 -0.0139885 0.0508451 -0.0341506 0.00792905 -0.0754503 0.0325324 0.16503 -0.0579411 0.122897 -0.216025 0.469053 0.158902 0.145884 -0.0999809 -0.360334 0.0256889 0.0621599 -0.381748 -0.14358 0.183169 0.298987 0.306703 -0.304609 -0.200195 0.00767054 -0.0651717 0.112072 0.692655 0.171517 -0.318177 -0.196619 -0.0807002 -0.166259 0.0185335 0.22669 0.141748 -0.0661658 -0.119561 -0.116589 0.0228387 -0.00746383 -0.0185802 0.0389472 0.28983 -0.0203499 0.131841 0.126047 0.146099 0.110875 -0.105803 -0.199472 -0.0461762 0.176694 -0.129689 0.062189 0.141218 -0.183148 -0.0646356 -0.0451281 0.113766 0.211371 0.00377784 -0.295344 -0.197576 0.261405 -0.188084 0.195176 0.0927691 -0.12629 0.165892 0.131168 0.196916 0.01202 0.0563768 -0.0429448 0.0062314 -0.0269453 0.0476194 0.0221539 -0.0707513 -0.00738128 -0.0149123 0.140291 -0.214325 0.294425 0.121547 0.295776 -0.00830103 0.179082 0.127415 0.149887 0.129057 0.11483 -0.178316 -0.00620377 -0.00626184 0.099295 -0.072034 0.042662 -0.137387 0.0290435 -0.0299751 0.123412 0.133036 0.156146 0.0640463 -0.030992 0.035989 -0.0315892 -0.0128495 0.138452 -0.0567846 0.0375338 -0.0842569 -0.0163649 -0.0837317 -0.0549161 0.148279 -0.0603713 0.00547592 0.147041 0.0948078 0.016326 0.0735484 0.0485767 0.0136147 0.154013 0.198828 0.118866 0.049541 -0.00133288 -0.0193642 0.0411211 0.0103611 -0.0539195 0.257841 0.0286607 0.18986 -0.0378361 -0.0763011 -0.0112912 0.0369525 0.0201886 -0.148201 -0.303223 0.100593 0.10084 0.0414247 0.0325322 -0.0942887 -0.0900252 -0.00103879 0.027242 -0.145273 -0.356506 -0.139289 -0.126973 -0.0687448 -0.0790193 -0.341077 -0.0258775 -0.00607998 0.0205505 0.0335373 0.0736514 -0.0546791 0.161878 0.0311126 0.0485519 -0.0376505 -0.0688151 -0.213707 0.203819 -0.117622 0.000473458 -0.003242 -0.0131685 -0.0809289 0.000485036 -0.00530658 -0.0616835 -0.21157 -0.164727 -0.174839 -0.0726749 -0.0656506 0.103005 0.0232492 -0.0892438 0.0736397 0.0723687 -0.0225891 0.305336 0.359042 0.247418 -0.129927 0.0894906 0.273383 0.20979 0.0233173 0.0926554 -0.114977 0.0658344 -0.0629331 0.0389857 0.0655794 0.0230177 -0.0336141 -0.188146 -0.0396072 -0.00484002 0.122321 0.191362 0.0725619 -0.039697 0.12929 0.0422301 0.0517358 -0.148405 -0.0971274 -0.155008 0.036063 0.00578603 -0.0973758 -0.164117 0.032674 -0.00155808 0.0915968 0.0466229 -0.086682 0.111808 -0.00800216 -0.145524 -0.218544 -0.0367262 0.0236805 -0.0201494 0.12856 0.166935 0.288578 0.0270399 -0.0594374 0.0233597 -0.0505762 -0.0750828 0.0303089 0.0817711 -0.0244834 0.154314 -0.103405 -0.0407434 0.026578 0.118821 0.100112 -0.182669 -0.104737 0.0186634 -0.0544434 -0.105355 0.129631 0.0582785 -0.209714 -0.205457 0.161842 0.0680213 0.0667555 -0.352357 -0.188487 -0.0671663 0.00805673 -0.225255 -0.0954198 0.0512034 -0.0302194 -0.0669237 0.0295943 0.0607582 0.0286105 0.150186 -0.206974 -0.3972 0.0141827 -0.114805 -0.134124 -0.0864526 0.117013 0.0859012 0.0181937 -0.0139992 0.146171 0.0337084 -0.211909 -0.029774 -0.0308754 -0.0201204 0.117195 0.103344 0.803816 0.561896 0.307871 0.286546 -0.164686 -0.278665 0.0525608 -0.121407 0.147928 0.0548279 -0.0365577 -0.0360091 0.021428 -0.0395969 0.0068324 -0.222437 -0.0305511 0.0358957 -0.344721 0.287988 0.0426794 0.383041 0.112086 -0.116901 -0.27269 -0.193061 0.147322 0.160352 0.456688 0.189882 -0.128238 -0.176205 -0.128273 -0.196301 -0.0631153 0.111 -0.216097 -0.0860495 0.0593879 -0.00782516 -0.0280071 -0.278475 -0.297004 -0.127333 0.0593735 -0.0715713 0.150556 0.0579815 0.0878492 -0.0137254 -0.0985724 -0.0835977 -0.0813621 0.00327585 -0.288627 -0.170233 0.162098 0.193195 0.044979 -0.0384532 -0.160121 -0.0438449 -0.129587 -0.0927847 -0.0023727 0.0245451 -0.0607467 -0.0572926 0.0282049 0.0254312 -0.0698632 0.0646109 0.0618674 -0.269396 0.0625829 -0.32987 -0.207722 -0.0356152 -0.230337 -0.0503929 -0.0335833 -0.117872 0.111952 0.152578 0.180183 0.302225 0.320623 0.0111159 -0.128088 -0.408731 0.187047 -0.306939 0.0360648 -0.262394 -0.406167 0.0765263 -0.0526761 -0.00783317 -0.131362 -0.0194942 -0.0143381 -0.153619 -0.105404 -0.00454133 0.118694 0.216066 0.101125 -0.0238309 0.161649 -0.336815 -0.241292 -0.170464 -0.289319 -0.116548 -0.0266807 -0.117236 0.105665 0.0140275 -0.164628 -0.159091 0.129728 0.182418 0.0101841 0.12865 0.0219859 -0.147646 -0.081037 -0.0763679 -0.0131999 -0.205483 0.105865 -0.0502311 0.195319 -0.105357 -0.0322315 -0.0036876 0.250249 0.185138 0.109095 0.134229 0.0688935 -0.146047 -0.203754 -0.114671 0.184001 -0.456702 -0.13482 -0.316432 -0.0312928 0.00698603 0.137665 0.0358432 -0.0651593 0.0558311 0.106579 0.00749095 -0.224842 -0.238135 -0.242381 -0.0721735 0.251204 0.485238 0.368938 -0.713186 -0.193174 -0.287712 -0.351227 -0.0159932 -0.140785 0.0174985 0.152954 -0.103304 -0.0559908 0.196454 0.0505816 -0.0324825 -0.358786 -0.0624277 -0.091983 0.221232 -0.183217 0.0482828 -0.182517 -0.172162 0.164212 -0.0232669 0.203097 0.117376 0.310116 -0.185916 -0.163921 -0.0976453 0.0691213 -0.13794 -0.229476 -0.0127778 -0.263915 -0.0415743 0.0301771 -0.280225 -0.276498 -0.143195 -0.196684 0.0297871 0.0374617 -0.0442477 0.250452 -0.0835495 0.04406 0.090295 0.109452 0.020481 -0.0297148 0.0473985 -0.00563129 -0.016259 -0.239415 -0.044407 -0.153863 -0.0910467 0.188196 0.25793 0.0217088 0.0372324 -0.22181 0.148135 0.15572 0.0593023 -0.0912922 0.0949748 0.00490421 0.0263703 -0.0911997 -0.0559765 -0.0561375 0.328638 -0.139444 0.102206 0.0538803 0.0804712 -0.07992 -0.0143253 0.0219362 0.0940451 -0.176061 -0.0892635 0.0180609 0.054922 -0.0602355 0.0269891 0.0239371 0.0667877 -0.0858524 0.058399 -0.122228 0.120392 0.387046 0.127217 -0.0629314 -0.365437 -0.126528 0.133673 -0.167943 0.072309 -0.00597585 0.120712 0.179951 -0.0370867 -0.0406462 -0.0802689 -0.0280939 0.0314294 -0.014054 -0.225735 -0.0482502 -0.11886 0.106768 0.0504694 0.0751365 -0.030301 0.0503517 0.0385138 -0.0690362 -0.187492 0.0301329 0.130332 -0.0617992 0.0750933 -0.376218 0.571037 0.294777 -0.0813501 -0.181476 -0.24999 -0.022106 0.00397737 0.0590586 -0.0534154 0.0271072 0.0355562 -0.0780782 0.0396398 0.117336 -0.117674 0.158735 0.103988 0.389192 -0.279643 -0.276823 -0.481229 0.0638163 0.0998049 0.311959 0.318558 -0.0185298 -0.310204 0.0113575 0.0334291 -0.0300096 -0.0559768 0.194648 0.0899677 -0.0761535 0.136001 0.0250883 -0.0757457 -0.167817 0.0454937 0.204415 0.0990877 0.0786257 0.0258433 0.0682242 0.0928803 0.0122114 -0.161669 -0.0371185 0.0143105 0.0309096 0.168915 0.147219 -0.0814893 -0.61337 0.342097 0.174318 -0.015576 0.0499082 -0.0411192 0.101671 -0.0972296 -0.0644964 0.167379 -0.136577 0.0173226 -0.0824653 -0.053072 -0.0501974 -0.0787873 0.0517932 0.100107 0.0482925 0.0391849 0.143271 -0.162705 -0.178867 -0.000766868 -0.0817972 0.112899 0.00298917 -0.0183514 0.0596742 0.00676655 -0.025325 -0.0403513 0.178444 -0.0357615 -0.0188541 -0.0617353 0.126001 -0.0196404 0.0694711 0.20675 -0.393778 0.216215 -0.00268804 -0.0384649 0.335175 -0.491807 0.266423 -0.232426 0.162973 -0.0936664 0.0909089 0.0431594 0.171289 -0.097565 -0.341506 -0.0660495 -0.133134 0.0150274 -0.436267 0.175179 -0.124054 -0.0618332 0.148159 -0.0848194 0.115363 -0.0831405 0.17336 0.00967097 -0.135311 -0.103788 0.0121435 0.0709118 0.206447 -0.0104296 0.221109 0.147015 -0.0540772 -0.0248004 -0.103533 -0.179418 0.0706914 -0.033148 0.0345904 -0.000966819 0.126249 -0.0564014 0.061789 -0.0836859 0.00649576 0.0054537 -0.0751254 0.230368 0.168781 -0.150791 -0.0513894 0.148243 -0.0747798 0.04198 0.11581 -0.019515 0.155447 -0.169027 0.215086 -0.130319 0.0543228 -0.138301 0.0976121 0.0196869 -0.0921582 0.352331 0.187571 0.335896 -0.643042 -0.0343998 -0.296974 -0.170323 0.531932 -0.22589 0.591167 -0.435497 0.203167 -0.223886 -0.0761574 -0.174392 -0.0104626 0.173526 -0.178606 0.0334193 -0.0905539 0.0914296 -0.194953 0.270186 -0.105547 -0.0221951 0.0521352 -0.00860182 0.0455863 -0.198023 0.107546 0.0492892 -0.0131295 -0.0587969 -0.121512 -0.00414923 0.388942 0.0499602 0.328018 0.0605106 -0.235918 -0.0185974 -0.222663 -0.149602 0.32873 -0.0187216 0.267927 -0.281322 0.041857 0.0331867 0.048955 -0.0825005 -0.131616 -0.0312951 0.0999468 -0.00450746 0.162791 0.0344254 -0.0547923 -0.0374789 -0.117899 -0.0692937 -0.102684 0.0664844 -0.0127431 -0.022053 -0.00304965 -0.0130777 -0.0376987 -0.0488238 0.0368022 -0.0166646 0.39264 0.0964916 0.0877005 0.0300813 -0.0903715 -0.0213464 -0.0108616 -0.062805 0.0469093 -0.0179769 -0.00075409 -0.0366806 -0.0236476 0.0439536 0.0150912 0.0611322 0.0426701 0.0466895 0.0239238 -0.116985 -0.0249856 -0.0189068 -0.00189994 -0.0211352 0.0898603 0.0314812 0.0891495 -0.0205849 0.096541 0.0487188 0.0691097 0.00970126 0.0400176 0.0151607 -0.0494678 0.0138437 0.00247811 -0.0399653 0.0444036 -0.0683233 0.0132025 -0.0349287 0.0640359 0.0925876 -0.00346191 -0.0290051 -0.00520027 0.0107336 0.0364858 -0.0294481 -0.0524256 -0.0972591 -0.0282102 -0.0762165 0.175258 -0.133173 -0.0170167 -0.0373337 -0.132648 -0.123664 -0.0400552 -0.0175484 -0.0313768 -0.091539 -0.0325589 -0.0276535 -0.0291243 -0.048734 -0.00204659 -0.0837145 -0.0143172 -0.0254641 -0.0157401 -0.0510966 0.0218516 -0.0367572 -0.126105 -0.0990673 -0.0601547 -0.0464409 -0.0218409 0.0172716 -0.0372226 -0.0349322 0.00611188 -0.00650958 0.0107772 -0.00742059 -0.00895961 -0.0269014 0.113815 0.0944881 -0.0229815 0.0668634 0.039089 -0.0210079 0.0759928 -0.0334926 -0.0246132 -0.0537328 -0.0440075 -0.0295821 0.00739142 -0.0487333 0.0250794 -0.00561746 0.0014074 0.00461801 -0.179729 -0.0588758 -0.00158605 -0.00876918 0.0168003 -0.0273115 -0.0212363 -0.00162431 0.0223185 0.0290998 0.0141904 0.0139179 0.0411099 -0.0074382 0.0383637 -0.00466698 -0.0122213 -0.0147104 0.312567 0.0178622 0.126022 0.110228 -0.156891 -0.237366 0.0297628 0.0390416 -0.0952678 -0.0215535 -0.186778 0.00260428 0.0241997 0.0173268 0.0256534 -0.0578269 0.0712924 -0.0127166 0.203557 -0.052284 -0.102835 0.224419 0.045233 -0.0759402 -0.228385 -0.0917024 0.0166029 -0.11588 0.0369916 0.0926309 0.149679 0.00996919 0.0856976 0.0903764 0.106641 -0.139955 0.00499009 -0.0878177 -0.0468987 -0.0584263 -0.155313 0.115119 0.188652 -0.0748055 0.0492947 0.105332 0.075273 -0.00809269 0.0594039 0.0514428 -0.0667542 0.000263121 0.108999 0.0125297 0.106604 -0.00808864 -0.0182403 0.0185737 0.086653 -0.0381906 -0.0785727 0.0227547 0.00656579 0.0117066 0.0196557 0.0161769 -0.183914 -0.145464 -0.141849 -0.0698373 -0.0731759 -0.00955521 0.294896 -0.129036 -0.0987547 -0.0187095 0.0843862 0.0039861 -0.267534 0.0270568 0.118507 -0.0669385 0.165667 0.166016 -0.310829 0.0304865 0.126015 -0.123854 -0.235573 0.220973 0.837017 0.0863444 -0.163148 -0.408987 -0.236586 -0.274841 -0.272336 0.00434433 0.0699029 -0.105955 -0.0433364 0.142435 -0.187149 -0.129488 0.188203 -0.0715323 -0.145138 0.0318052 0.254562 0.139239 -0.250522 -0.132662 -0.0300058 0.14818 0.233213 -0.074085 0.0585349 0.2804 0.048981 -0.228023 0.138604 0.0574621 -0.165885 0.0880044 0.0434044 -0.125056 0.381677 -0.0713957 0.1092 -0.176342 -0.240929 -0.00370018 0.241969 -0.165889 -0.0804317 0.15973 -0.0292384 -0.141206 0.0211153 -0.114788 -0.204466 -0.0170963 -0.00911315 -0.0267745 0.569355 0.115334 0.342378 0.00447226 -0.0748735 -0.139848 0.148674 -0.110073 -0.244053 -0.142796 -0.11235 -0.0441801 -0.116321 -0.239269 0.0545984 -0.134028 -0.0451491 0.0809848 -0.544522 -0.0362521 0.0239713 0.161623 0.153898 0.135923 0.0540306 0.0119716 -0.18436 0.0255573 -0.0394318 -0.00444535 -0.0690799 0.0623169 0.0906459 -0.0556715 -0.115547 -0.0243085 0.161999 0.0676146 0.0621123 0.131117 0.211149 -0.00700326 0.0917189 -0.153143 -0.139689 -0.116551 -0.0496194 0.0486905 -0.0194863 -0.0353216 0.120309 -0.0077151 0.00102057 -0.111272 -0.134252 -0.0917866 -0.166886 0.0953524 0.170224 0.125437 0.0468254 0.0685908 0.00446458 0.0155124 0.0774717 0.0527132 0.00365326 -0.051306 -0.00940316 -0.0540456 0.0094608 -0.0252058 0.283566 0.0244438 0.131936 0.146744 -0.0720758 0.0713354 0.142237 0.0271652 -0.201666 0.0446226 0.0161002 0.0423159 -0.151282 -0.00200867 0.0916789 0.034383 -0.0708367 -0.0899668 -0.153994 -0.00438925 0.0370434 0.0349368 -0.0175262 0.0618484 -0.043718 -0.0164531 -0.069791 -0.104572 0.0596929 0.102478 -0.0773961 -0.0305246 0.00660834 -0.0123642 -0.0420706 -0.0295025 -0.0224763 0.00734526 0.0260345 0.0934902 -0.097924 0.0295236 -0.0437551 -0.0330113 0.0182991 -0.0037314 0.0342614 0.133083 0.0172641 0.0324415 -0.0413209 0.123247 -0.00240345 -0.0315566 -0.13889 0.028054 0.0969322 -0.0527096 -0.0577664 -0.149321 -0.129456 0.0586488 0.0494739 0.0993518 -0.0552739 0.00675513 0.0267491 0.0183901 -0.0532495 -0.0279832 0.0202917 0.0463063 -0.168432 0.0543619 -0.189591 -0.100393 0.0789489 -0.00408454 -0.0259166 0.0116912 0.112501 0.0549982 0.087612 -0.0989549 -0.0141358 0.101813 0.196748 0.0495617 0.107726 -0.0780873 0.190949 0.330772 0.158446 -0.321104 0.123276 -0.122447 0.0150361 0.114445 -0.297381 -0.127064 0.0869791 -0.0686221 -0.0438053 0.15266 0.00104262 -0.147304 0.0436372 0.0376962 0.214894 0.0755083 0.163423 -0.0559403 0.0135125 -0.269308 0.16747 -0.0635882 0.167059 -0.253434 0.204592 -0.148289 0.182338 -0.256631 0.00674426 -0.104163 -0.0414875 -0.134197 -0.120559 -0.0206157 -0.0581666 0.053164 -0.0346616 -0.134809 -0.0011038 -0.0432978 0.0202431 -0.0531003 0.0501928 -0.0749746 0.120018 -0.161085 -0.0174228 0.0707048 -0.0273773 0.05217 -0.0362473 0.0449666 0.0711924 0.0312465 0.119751 0.0230409 0.0626034 0.0543431 0.0545849 -0.007767 -0.00396528 0.0877578 0.0311001 -0.0844305 0.129219 -0.0698585 0.0542236 -0.0286556 -0.504615 -0.0407948 -0.0404361 0.0446157 0.208578 -0.164763 -0.0388199 -0.0860717 0.0241557 0.0888214 -0.0485491 0.0923382 -0.114415 -0.223021 -0.0685509 0.0198727 0.0104284 -0.0436651 -0.451473 0.060738 -0.130895 0.0756926 0.0375304 0.110592 0.0674053 0.0603931 0.0596321 0.0415275 0.0788618 0.188907 -0.0395103 0.0489059 -0.0921771 -0.0107375 -0.047137 0.00466637 0.0122086 0.107983 -0.142248 -0.162261 -0.00781544 -0.124009 0.00804381 0.115133 -0.0200123 -0.0541566 -0.00981601 0.0456828 -0.00748708 -0.0276934 -0.0152454 0.00376821 -0.0157506 -0.018966 0.0707072 -0.0356542 0.147876 -0.267135 -0.0794781 -0.0575371 0.101789 -0.0224188 -0.10755 -0.0403375 0.163606 0.0209735 0.239321 0.0427998 -0.114137 -0.0568678 0.0841091 -0.134065 0.59145 -0.132526 0.171351 0.187468 0.21299 0.398067 0.303934 0.165592 0.0778583 -0.106324 0.0782205 -0.142444 -0.272373 0.00256554 -0.419944 -0.143177 -0.0708987 -0.296145 -0.207039 0.0479508 -0.123951 -0.368385 -0.119659 -0.263093 -0.0856879 0.0242959 0.0196109 -0.00856245 0.243874 0.0299072 0.0966033 -0.0259764 0.166621 0.104281 0.107547 0.0834185 0.445716 0.258107 0.249727 0.482885 -0.0294553 0.0739953 -0.00379493 0.15699 0.0245101 -0.0902078 -0.322793 -0.0366849 -0.0338425 -0.0523436 -0.0335717 0.143275 0.095793 -0.0220207 0.825289 -0.318602 0.286817 -0.353292 0.240738 -0.10741 -0.0396391 -0.164031 -0.23532 -0.248577 0.0172911 -0.330731 0.118503 -0.147636 -0.39545 -0.261319 -0.0792707 0.0711148 -0.557208 0.502959 -0.139846 -0.165131 -0.226046 0.181162 -0.152325 -0.0799276 -0.135124 -0.280172 0.19739 -0.151046 -0.126089 0.105019 0.248187 0.338117 0.0625087 0.364646 -0.490017 0.0730616 -0.278814 -0.103576 0.16258 -0.0638771 -0.0757354 0.0443474 0.118744 -0.120741 0.294617 -0.172937 -0.123015 0.00831951 0.123504 0.142973 -0.0430393 -0.0346843 -0.0645523 -0.093476 -0.231601 -0.152871 -0.12909 -0.0140783 0.111827 -0.0762277 -0.122217 0.217753 0.224589 0.0498481 0.197054 0.200592 0.352276 0.318803 -0.156136 0.0376243 -0.524929 -0.342185 -0.0647748 0.12406 0.129985 -0.314325 0.103765 -0.00859581 -0.127811 0.0771023 0.0180316 -0.121444 -0.0742671 0.0107682 0.111646 0.0510689 0.00978137 -0.0329803 -0.220256 -0.122328 0.227085 -0.116568 -0.226191 0.0193129 -0.313416 0.186784 -0.318257 -0.0121528 -0.207466 -0.0955595 0.00884221 0.202488 0.0531668 -0.0400112 0.0366807 0.0826333 -0.416492 -0.0288337 -0.362233 0.275096 0.125542 0.421131 0.000574831 0.0592216 -0.0731219 -0.292521 -0.0549936 0.152151 -0.221417 0.150992 -0.0863691 -0.0957123 0.0480574 0.110457 0.191792 0.052726 0.0702266 0.058743 0.16713 -0.241277 -0.112952 -0.0502574 0.164467 -0.164856 -0.0462388 -0.166831 -0.00321226 0.0991217 -0.00751651 0.0242796 0.149166 0.0428854 -0.805713 0.544252 -0.596595 0.303311 -0.0413322 0.123146 0.0659661 -0.0814185 0.133232 -0.172062 -0.0282099 0.122829 -0.0615019 0.120799 -0.0799832 -0.0634344 0.233743 0.0968285 -0.561942 0.283782 -0.0401467 -0.00299908 0.191179 -0.196094 0.225201 -0.150606 0.232043 -0.122561 -0.00331921 -0.0921037 0.0943569 0.267752 0.136366 0.172996 -0.0569499 -0.0515545 -0.00594715 0.176424 0.0381194 0.255666 -0.0916532 0.269209 -0.0767338 0.149898 -0.121861 0.0125024 -0.0173862 0.153752 -0.0541249 0.110712 0.00980171 0.0182749 0.00939194 0.0860998 -0.297702 0.276901 -0.28238 0.232447 -0.196197 0.183184 -0.00200459 0.0895679 -0.00614255 0.11818 -0.0100065 0.124408 -0.0341187 -0.000932673 -0.0100305 -0.00555827 0.0160597 0.0492126 0.0503603 -0.518485 0.162463 -0.0430098 -0.241385 0.262697 0.02297 0.0558154 -0.0194154 0.0905861 0.108192 -0.00960369 -0.090676 0.135216 0.00939703 -0.00182408 -0.190157 0.0271535 -0.562319 0.00374465 0.324932 0.164486 0.0130191 0.299129 0.0501195 -0.0465597 -0.154144 -0.0834853 -0.000348987 0.0772778 -0.0964293 0.0342438 0.0232629 -0.000310488 0.0169615 0.0310004 -0.0583186 -0.242866 0.261936 0.177315 0.201215 -0.0351545 -0.0438803 0.00560521 0.155601 0.144336 -0.15311 -0.0502384 -0.233354 -0.00868896 0.0870168 0.0457729 0.00963087 -0.0241303 0.208625 0.325793 0.0744343 0.111275 0.12058 0.106705 0.072526 -0.1003 0.0172442 -0.136374 -0.294736 -0.115813 -0.128693 0.12102 0.0761149 0.00869704 -0.0419123 -0.0712093 0.541092 -0.628957 0.931951 -0.258289 0.153377 -0.0136785 0.141568 -0.0637993 0.0658593 -0.0844052 0.0929996 0.153964 -0.00823791 0.0918472 -0.00302266 -0.0962602 0.230585 -0.153886 0.0483773 -0.536375 0.797212 -0.00148872 0.000771769 0.0177346 0.075474 -0.021811 -0.0376043 -0.0282791 -0.000794901 0.102299 -0.00367195 0.153457 0.0778651 0.0169971 0.0391536 0.13005 -0.36106 -0.177097 0.150376 -0.0653458 -0.202681 -0.0726052 0.0493469 -0.0347877 0.191937 -0.0611839 0.0276016 0.311417 0.0940558 0.00189498 -0.104033 0.0950375 0.0927085 -0.00920851 -0.230884 -0.519349 0.298746 -0.146745 -0.0970489 -0.0834371 0.0944531 0.085114 0.0509687 0.0875537 -0.0327689 0.0259859 0.0627039 -0.0111399 0.00719268 -0.0866638 -0.0188094 0.0937511 0.0356559 0.0918933 -0.0825765 0.296126 -0.13807 -0.0130523 0.0136769 -0.336564 0.158495 -0.220176 0.338972 -0.258141 0.217578 0.0018225 -0.181271 0.0447486 -0.155401 0.143873 0.0542325 -0.158148 -0.329486 0.0522569 0.100439 -0.154111 0.326404 -0.0149051 0.307784 -0.146219 0.0413436 0.109012 -0.103157 -0.0412715 -0.0456008 0.214235 -0.0521757 -0.155157 0.0851777 0.0428077 -0.20484 -0.0512946 -0.236217 0.10126 0.287455 0.138663 0.284989 -0.0407187 0.0308831 -0.120223 -0.0725222 0.0341242 -0.0346155 0.184557 -0.169207 0.0571814 0.227951 0.071492 0.198208 -0.114273 0.136063 -0.150258 -0.136864 0.141355 -0.304636 0.0600085 -0.298 0.0663748 -0.131526 -0.108774 0.0173536 -0.059313 0.0748895 0.116427 0.185801 0.0139949 0.0557756 -0.331806 0.197639 -0.300105 -0.222516 0.325102 -0.467979 0.308576 -0.470986 0.130797 -0.186564 -0.0470568 0.00753617 -0.200152 0.113976 -0.00693871 -0.110057 -0.154441 -0.280224 -0.258285 -0.179729 0.238251 -0.373983 0.373178 -0.0866635 0.193979 -0.0874048 -0.132024 0.0180042 -0.109304 0.00784317 -0.203449 0.0251231 -0.123062 0.0935465 0.143563 -0.266013 0.146286 -0.224211 0.198431 0.234609 -0.000290014 0.31794 -0.34844 0.0562523 -0.156822 -0.14084 0.109322 -0.0556877 0.0104185 -0.180729 0.223837 0.150158 0.181874 0.37034 0.0507387 0.125452 -0.111138 -0.00564298 -0.198089 -0.158956 -0.111146 -0.117935 -0.0475872 -0.053349 0.110513 -0.00588794 0.0430358 -0.155502 0.0821507 -0.218504 0.116958 0.294799 0.0770573 0.0224202 -0.168873 -0.0467219 -0.100717 -0.261949 -0.137456 0.042182 -0.136605 0.0122804 -0.0614511 0.027883 0.0913899 -0.0525449 -0.164916 -0.299473 -0.31574 -0.0118593 -0.0457259 0.0675336 0.03555 -0.270044 0.290746 0.183267 0.163714 0.188319 -0.0260251 0.10856 0.047408 -0.0151552 -0.166567 -0.0576337 0.025377 0.0856706 0.299349 0.205008 0.0454866 0.206102 0.100474 0.0844876 0.0509666 0.000752418 -0.0675357 0.0156663 -0.0432232 0.0420222 -0.014371 0.09922 -0.151072 0.0381514 -0.0646461 0.157684 -0.298647 -0.0708436 -0.000173108 -0.147823 -0.0258458 0.227264 -0.0340875 -0.0514811 0.390189 0.013694 -0.114941 -0.088326 0.0280318 -0.0465034 -0.0308882 -0.0355335 0.0741518 0.575374 -0.0288563 0.0532454 -0.00108795 0.0862796 0.286044 -0.173987 -0.0134526 0.0801591 0.0749838 -0.204796 0.0408839 -0.184418 -0.0475712 0.0434631 0.0536234 -0.106511 -0.0515272 1.15508 0.741339 0.353123 0.272812 -0.081578 -0.634086 0.0413221 -0.24029 0.314644 -0.185174 0.0324115 -0.154334 -0.151204 -0.0684484 0.0545255 0.0335756 -0.0271374 -0.0476512 -0.539413 -0.151526 -0.201007 -0.0374052 -0.0563368 0.231335 -0.174705 0.0878734 -0.0628054 0.0973614 0.0370528 0.0731248 -0.217688 0.0334329 -0.0363217 0.176878 0.132215 0.1056 -0.216521 0.00100411 0.149794 -0.186651 -0.0610915 0.477957 0.0710678 0.119094 -0.112335 -0.191719 -0.206181 0.0439583 -0.136822 -0.170091 0.213481 0.229575 -0.0107079 -0.0300039 -0.0735076 0.19939 -0.0196926 0.209383 0.0670265 -0.0144627 -0.139061 0.00110933 -0.0670106 -0.0295996 0.0391765 0.0611205 -0.0422732 0.00373045 0.00776601 -0.0722637 -0.0414421 0.0321749 0.00408789 -0.012116 -0.0920461 0.112503 0.00333588 0.0230601 -0.00928017 0.0391064 0.00839114 -0.116377 -0.00686855 -0.10857 -0.0314397 0.0502427 -0.0363783 0.0172646 0.0751795 -0.0435952 0.0565889 -0.0670986 -0.146668 0.11446 -0.00683086 0.237752 -0.126146 0.0872486 0.00170062 -0.0242106 -0.0825325 -0.0754243 -0.0880368 0.0137197 -0.0201357 0.0679326 0.134731 0.0582976 -0.0811129 0.0271671 -0.034956 -0.182738 0.0501442 0.1214 0.254534 0.0092504 0.066143 0.130549 -0.0845733 -0.00447458 0.018546 -0.0485039 0.0180187 -0.0124464 -0.0240386 0.0207111 -0.316123 0.0589742 -0.13793 -0.0716833 -0.142851 0.0347254 -0.00523805 -0.0281389 -0.0897305 -0.0926704 -0.0578454 -0.0758919 -0.0904668 -0.0284361 -0.115334 -0.033062 0.0275913 -0.0465096 -0.0176048 0.0388559 -0.0208405 -0.00190538 -0.0592707 0.0510554 0.00656715 0.0760651 0.0830014 0.00197137 0.0743302 -0.0176104 -0.00929492 0.0602265 -0.00936344 -0.00552712 0.0536554 -0.0266826 -0.0191343 0.211458 -0.167108 0.441023 0.0403327 0.16872 -0.0807284 -0.00253435 -0.0523338 -0.0706856 -0.143071 0.0674584 -0.15348 -3.90066e-05 0.0817589 0.0567258 0.0844296 -0.0405935 0.124106 -0.096544 -0.0372987 0.0212435 0.0930455 0.0115567 -0.160748 0.0328032 0.0817004 0.0448361 0.00910748 0.00946978 -0.000570596 -0.0164439 -0.00372486 -0.0415296 0.00846501 -0.061918 -0.332343 -0.19554 -0.180896 -0.146199 0.191245 0.0571907 0.0269391 0.0217833 0.146009 0.215954 0.0787621 0.0187443 0.0135049 -0.108423 -0.0667623 -0.0350658 0.0615908 0.00165448 -0.560697 0.0523437 -0.486411 -0.102616 -0.0289398 0.151621 -0.0323319 -0.0650587 0.0304769 0.1586 0.171155 0.0913186 -0.075223 -0.0335123 -0.0602471 0.0299264 -0.0358479 -0.0148394 -0.0762482 0.420645 -0.210745 -0.221062 -0.0289429 -0.17875 0.175949 0.0760275 -0.0320505 -0.329723 -0.0402851 -0.139092 0.0591384 -0.0738161 -0.0661102 -0.0975614 0.00188609 -0.0637518 0.395852 -0.0466833 0.0211632 0.00101845 -0.184471 -0.19254 -0.167087 0.0590608 -0.0157031 0.0257138 0.0145273 -0.13556 0.0657993 0.0542869 -0.0543365 -0.0248384 -0.000486939 -0.0272606 0.36242 0.110792 0.09414 0.143442 0.028205 0.196883 0.0227753 -0.116107 -0.0620009 -0.0164984 -0.0140813 0.00950729 0.0754193 0.0027037 0.103661 0.00213206 -0.0303398 -0.00742899 0.698834 -0.306998 0.0885804 -0.0430881 0.102577 0.180787 -1.77445e-05 -0.11477 0.04719 -0.0189978 0.00760255 -0.0382022 0.00478847 -0.0865111 0.0914736 0.0240899 0.00270574 -0.0113627 -0.449157 0.266914 0.0263643 -0.0620438 0.0526707 -0.146843 0.0867263 0.0355629 -0.0454152 -0.0925637 -0.0641849 0.0346697 0.0294993 0.0256108 0.0433476 -0.0249995 -0.00833175 -0.0122965 -0.657407 -0.0536899 0.109214 0.0656339 0.143954 -0.064156 0.0648258 0.123597 0.125951 -0.0315583 -0.0472979 0.031754 0.0500555 0.0491696 0.038106 -0.027903 0.0087914 0.00684266 0.0603479 0.164251 0.165423 0.110399 -0.0349456 0.0507896 0.0139389 0.143179 -0.157763 -0.0241374 -0.103421 0.202621 -0.118918 0.0141984 -0.106676 0.168724 0.141406 0.224834 0.235021 -0.279375 0.251264 0.361615 -0.259709 -0.318857 -0.0145688 -0.0242677 0.291758 -0.131371 -0.175347 -0.251201 0.0563524 0.0477667 -0.0545288 0.0252192 0.0268256 -0.095301 0.586479 0.147018 0.102304 -0.0578635 -0.380135 -0.166839 -0.0577772 -0.147512 -0.154322 -0.0471552 0.365575 0.101513 -0.259279 -0.0172949 0.118924 0.0790666 -0.064732 -0.0353593 0.154311 -0.200738 -0.148053 -0.18183 -0.0400629 -0.130989 -0.0593038 0.0215229 0.133686 0.0122566 0.115152 -0.0919082 -0.0792216 -0.0808386 0.17713 0.0763935 0.0315306 -0.0151888 0.532517 0.0274238 -0.390451 0.189653 0.269541 0.369249 -0.100669 -0.279149 0.165087 -0.134127 0.392419 0.322168 -0.245113 -0.237317 0.108739 0.219678 -0.037155 0.108496 -0.301864 -0.626799 -0.0523864 0.100146 0.539623 0.303725 -0.0739295 0.0446588 -0.0879373 0.424925 0.0701205 0.0311797 -0.217313 0.0594558 0.0142305 0.0505473 0.136606 -0.0903106 0.633861 0.120006 0.0684832 -0.0605775 -0.236825 -0.0597716 -0.147742 0.0185596 0.02269 -0.0530305 0.0508676 -0.0134972 -0.126969 -0.172903 -0.0501483 0.0315373 0.00103502 0.0546934 -0.0745796 0.053314 0.104318 0.132321 -0.311562 -0.359525 0.211541 0.000594782 -0.108956 -0.113369 0.0461666 0.0751137 -0.0777433 -0.0947384 -0.0682904 0.175775 0.142953 -0.0653753 -0.173566 -0.136968 0.0880674 -0.0484785 -0.00211854 0.0980478 0.00402503 -0.014135 -0.035046 0.0440022 0.0775809 0.0855016 -0.0728874 0.111748 0.0128008 -0.0534822 -0.0510731 0.109626 0.0384742 0.0499806 -0.190085 0.0332993 0.235182 0.0591925 -0.137664 -0.121854 0.11671 -0.0169987 -0.0401064 0.0329428 0.0923855 -0.0597885 -0.177348 -0.109103 -0.0590156 -0.0151763 -0.254673 -0.0709109 0.0312014 -0.0652366 -0.100529 0.128606 0.109088 0.0703447 -0.0600539 -0.00470008 -0.0142321 -0.00346926 -0.136081 -0.049586 -0.0805649 0.0925227 -0.0825643 0.169619 0.0985659 0.0210756 -0.0745315 -0.0238228 -0.224237 -0.251339 -0.0516473 0.108886 -0.0822554 0.00367609 0.0333304 0.00252371 0.109358 -0.0391713 0.0763835 0.0625809 -0.00253433 0.056174 0.306562 -0.493196 0.542681 -0.332412 -0.0760011 0.081516 -0.00546318 -0.113964 -0.0669717 0.0380036 0.155996 0.0606986 -0.26947 0.0271799 0.0815785 0.0182487 -0.0371381 0.0860665 -0.233016 0.260443 -0.100989 0.052316 0.0917698 -0.00211579 0.0312586 -0.0497563 -0.0153006 -0.14733 0.0492269 -0.0205591 0.0874082 0.0882376 -0.058289 0.128763 0.0503012 -0.00330489 0.0518264 -0.168168 0.176424 0.001762 -0.0707937 0.279906 -0.0565057 -0.0592796 0.0199654 0.0713605 0.0978072 -0.00175121 -0.217667 0.13711 -0.0317029 0.0623666 -0.0940363 0.0297523 -0.350827 -0.0437924 -0.14586 -0.0570311 0.119909 0.0538243 0.0108133 0.0839905 -0.0398921 0.0694291 -0.0412033 -0.00217059 -0.0288657 -0.00115903 0.0457418 0.13946 0.0193626 -9.6696e-05 -0.26679 0.0772714 0.143559 -0.0661076 0.0809759 0.0745007 -0.116495 0.0588356 -0.11838 -0.0300845 -0.115008 -0.0261651 -0.0783664 0.0768275 0.0461367 0.0805463 -0.0167991 0.0739141 0.181418 -0.0881166 0.00942596 -0.435385 -0.390551 0.0566313 -0.0321577 -0.0803596 -0.0152357 0.289209 -0.0237065 -0.0919739 -0.0172134 0.0772633 0.0770426 -0.0115599 0.0983214 0.0476574 0.136548 -0.134892 0.0314457 -0.285082 -0.431259 -0.09473 0.00532582 -0.312505 -0.1863 0.0704465 0.0562834 0.0471199 0.131979 0.0616617 0.0661749 -0.0590009 0.0562261 0.104546 -0.126099 -0.27306 -0.113815 0.10315 0.305976 0.135271 0.0181513 -0.130255 -0.18484 -0.0820827 -0.0193871 0.0664598 0.0924492 -0.103258 -0.0782594 -0.066301 -0.124854 -0.0321171 -0.050453 -0.236693 -0.384309 0.260907 0.0764604 -0.00181417 0.157589 0.0336074 0.135512 0.0161823 0.0296644 0.161961 0.162521 -0.142671 -0.0613516 0.0200053 -0.0828338 0.0609099 -0.517488 -0.159504 -0.249924 0.387669 0.469226 -0.0517176 -0.133168 0.0739067 0.165043 -0.0998542 0.0940286 0.107513 0.019671 0.0317338 0.0317524 0.0839626 0.0124566 0.00464982 -0.069814 0.0308934 0.230117 -0.175197 -0.205232 0.144451 0.0134557 -0.200649 -0.299892 0.149482 0.204561 0.090222 0.00844513 0.00569229 0.000935842 -0.116332 -0.117112 0.0362152 0.377091 -0.0425487 0.0749396 -0.130015 -0.277345 -0.0150269 -0.0389178 -0.07466 -0.068594 0.0364878 -0.0172824 0.0260333 0.00401925 -0.0653209 -0.0383554 -0.0443934 -0.0925567 -0.046927 -0.165969 -0.0517096 0.0965856 0.250943 0.0807204 0.1328 0.0526446 0.085909 0.13211 0.00587204 0.119366 0.116869 -0.0182341 0.0970162 -0.0714112 0.0274952 -0.0682101 0.0239336 -0.294961 -0.163806 -0.185485 0.0234831 0.106974 -0.133567 -0.141111 0.257757 0.0669364 0.0509162 -0.00788026 0.0397974 -0.0763799 0.00680433 0.114283 -0.000537495 0.000608899 0.0516275 0.0129448 0.079688 0.0900807 0.0242152 0.184354 0.0204661 -0.0943088 -0.0675444 -0.00447166 0.0776767 0.0531631 -0.0675515 0.0738351 -0.0853867 0.0578983 0.0334688 -0.0453221 0.0224648 -0.359665 0.0951472 0.00212435 -0.0968217 0.0184601 -0.121866 -0.0121074 -0.0895667 -0.163232 0.212924 -0.063323 0.0785786 0.0375447 -0.0557171 -0.158879 -0.0656196 0.0149439 0.150689 0.24224 -0.244496 0.0216921 -0.278839 -0.341068 -0.120132 -0.116931 0.213351 0.0139575 -0.134982 -0.0825014 0.176649 -0.0921517 -0.0079085 -0.0322712 0.0221022 -0.0875418 0.105493 0.295434 0.107212 -0.155597 0.106911 0.0302013 0.190314 -0.123188 -0.0131628 -0.10362 -0.0652164 -0.103635 -0.0535725 0.0188447 0.0894119 0.0458241 0.0508295 -0.0959796 0.0300429 -0.0986824 0.112097 0.0146006 0.116369 -0.00763559 0.0406879 0.115994 0.195981 0.0234928 -0.264702 -0.21414 0.143492 -0.0207255 0.0319306 0.0354118 0.061008 -0.0982885 0.0865729 -0.340411 0.112134 -0.130539 -0.237254 -0.0103252 -0.00520174 0.135087 -0.033832 0.0467878 0.0912849 -0.0111041 0.00216883 0.0284299 -0.109983 0.00797592 -0.0385682 -0.0769956 -0.0241059 0.219131 -0.0753424 0.064628 -0.182144 0.0161726 0.198717 -0.0213781 -0.228639 -0.166882 0.158374 -0.110943 -0.11314 0.150686 0.0510213 0.00155086 0.206332 -0.0164745 -0.161934 -0.00659287 0.207057 -0.0698618 0.176755 -0.112096 0.00790802 -0.335148 -0.469859 -0.125295 0.0338378 0.0621415 0.0645371 0.179136 0.121326 0.224668 -0.0230443 -0.149033 0.165626 0.219483 -0.125755 0.3625 0.00332407 0.0168273 0.143542 -0.34768 -0.281958 -0.0879594 -0.108763 -0.117159 -0.132537 0.250816 -0.0451199 0.124573 0.230219 -0.0869138 0.056355 -0.105065 0.504099 0.134496 0.441324 0.141212 0.405645 0.112008 0.127985 -0.0804288 -0.297371 -0.13413 0.0207554 -0.157077 -0.0895015 0.050491 0.250466 0.0965462 -0.142761 -0.194963 0.682663 0.82716 0.109369 -0.409966 -0.151488 -0.290969 0.230705 0.11802 0.447496 0.13243 0.0441441 -0.0903714 -0.162346 0.0215512 -0.359056 0.026601 0.0461757 0.0877522 0.16143 0.172178 0.270429 0.30614 0.218296 -0.0150418 0.0484542 -0.0605185 0.0434151 0.107557 0.0396379 -0.0219181 0.274215 0.000821984 -0.082004 -0.0249974 0.0520248 0.210962 -0.15727 0.345257 -0.00823571 -0.103742 -0.0137604 -0.174622 -0.033122 0.0783007 0.0462813 0.0466708 -0.249781 0.102466 -0.130464 -0.183264 -0.246864 -0.0116746 0.029649 -0.199759 0.0755447 -0.12531 0.287268 0.20124 0.32103 0.0616534 -0.133926 -0.176273 -0.294436 -0.264107 -0.127467 0.0968805 0.132958 0.236436 0.0788141 0.00372209 0.0624262 -0.0300718 0.23735 0.0575881 0.002061 -0.259858 -0.0865459 -0.141816 0.0568474 0.184865 0.0826282 0.257022 -0.0925439 -0.0894438 -0.070957 0.0166964 -0.0624995 -0.0513126 -0.019251 0.117116 -0.367351 -0.0680362 -0.221255 0.0681109 0.088888 -0.0275856 -0.0452598 0.0486331 0.0541275 0.111342 0.0474706 0.000693079 0.112382 0.0467807 0.0946939 -0.0149819 0.149606 -0.00101244 -0.208567 0.0470385 -0.17312 0.0611894 0.214082 0.23802 0.0420711 0.174587 0.0766657 0.104275 -0.0605427 -0.0603649 -0.0728886 0.300587 -0.00135731 -0.0791746 0.0455143 -0.254204 -0.282581 -0.0351129 -0.209012 0.234971 0.114087 0.165263 0.21346 -0.0521414 0.0227601 -0.089567 0.0830319 0.040053 -0.125362 -0.0407889 0.172341 0.0456444 -0.0807319 0.538724 0.696561 -0.456343 0.267343 0.0745503 0.0887893 0.179168 0.162938 0.509182 0.0403401 0.104878 -0.105167 -0.029366 0.0950945 0.0507264 -0.126042 -0.111362 -0.0933655 0.0196509 -0.0905567 0.12562 -0.468207 -0.0148617 0.0459553 0.191657 0.0995822 0.1342 0.0462253 -0.140099 -0.109752 -0.143901 -0.00353464 -0.0567208 0.0809091 -0.105367 -0.164643 0.123138 0.0732768 -0.503124 0.157651 0.0783188 0.0894153 0.0578102 0.0116896 0.198876 0.106149 0.0986878 0.0410295 0.0780925 0.0952681 0.063896 -0.0184734 0.0651155 0.126474 -0.20959 -0.00538747 -0.238826 -0.288733 0.0375707 0.0961968 0.23774 -0.134819 0.0918536 0.158458 0.050837 0.017788 0.0590008 0.0564985 0.094541 0.0774909 -0.0304891 -0.00900815 0.122511 -0.217551 -0.0228244 -0.271366 -0.37482 -0.18336 -0.136293 -0.215907 -0.107478 0.109005 0.267962 0.168686 0.220513 0.145122 -0.00848397 0.0423112 0.0379542 -0.0835479 -0.305381 -0.205857 -0.00615925 -0.264518 -0.017432 0.178784 0.27803 0.0855791 -0.266606 -0.315983 -0.157443 0.0346354 0.0918554 0.257643 0.110054 0.0726684 0.0481967 -0.101219 0.122055 -0.235134 -0.0559019 0.0427345 -0.00844811 0.104121 0.147791 -0.04536 -0.125748 -0.0775912 -0.0279053 -0.0155415 -0.0672843 0.0119913 -0.0933009 -0.170196 -0.03207 0.0962406 -0.325198 0.0858826 -0.164266 0.0842977 0.23112 0.150369 0.25028 -0.0195274 -0.12085 -0.153951 -0.0975147 -0.0579206 -0.0261243 0.0251013 -0.0546052 -0.0117369 -0.00575005 0.0586769 -0.184273 -0.395171 -0.36086 -0.530864 -0.109572 0.186511 0.221562 0.311655 -0.0271461 -0.122634 -0.187569 -0.0317561 -0.0682304 -0.175166 0.0136675 -0.0524679 -0.0653404 -0.115417 -0.174608 -0.25911 -0.399264 -0.37491 -0.208214 -0.0254744 0.224699 0.399727 0.235792 -0.168349 -0.149466 -0.0662725 -0.267182 -0.226475 -0.0397162 -0.0261684 0.12738 0.0137057 0.307298 -0.114962 -0.162173 -0.105196 0.160087 0.38407 0.485126 0.324118 0.102573 -0.314309 -0.420302 -0.21341 -0.25665 -0.148808 0.0946552 0.153536 0.0792132 0.225851 0.167105 -0.0787178 -0.0959315 -0.117844 0.0394018 0.0273515 0.246837 0.316368 0.244684 0.0469862 -0.116033 -0.136013 -0.26248 -0.199568 -0.0300762 0.0557625 0.117516 0.102549 0.0409209 0.136875 -0.0434196 0.0839042 0.0273692 -0.27622 -0.0126305 0.129621 0.0656939 -0.17914 -0.145186 -0.0455046 0.0184035 -0.131342 -0.04779 -0.0583469 0.158717 0.032404 -0.0183481 -0.0360525 0.306789 0.000695852 -0.530471 -0.391737 -0.0295994 -0.0495065 -0.117727 0.0519633 0.0856655 0.0519793 0.0429306 0.0291838 -0.0277827 0.121749 0.0417665 0.0558113 0.247166 0.396028 0.442412 -0.210877 -0.237199 -0.197525 -0.0167929 -0.0806786 0.0851234 0.0029181 -0.110409 -0.11248 -0.0328546 -0.0764938 0.0796986 0.198657 0.149328 -0.028101 -0.438014 -0.0381066 -0.0871418 0.00555011 -0.0239523 -0.00198173 0.0814083 -0.0869309 0.000389981 0.131215 0.0652716 -0.0253891 0.0830576 0.132846 0.021494 0.073135 -0.030216 -0.0852265 0.958217 0.234181 0.0731243 0.0401579 -0.518939 -0.126294 -0.0576384 0.0993001 -0.0807148 -0.0260706 -0.104678 -0.0878226 -0.0940228 -0.110045 -0.0631681 0.0879148 -0.0182079 -0.0272567 0.495217 0.19924 0.719363 -0.0483477 -0.381826 -0.175924 -0.112066 0.0174284 -0.228415 -0.0568683 -0.0605056 -0.0125383 -0.103132 -0.0936424 -0.0444165 0.0495236 0.0174295 -0.056627 0.910677 -0.011777 0.443815 0.0386955 -0.306143 -0.153968 -0.00737721 -0.0869214 -0.270109 0.0383636 -0.0945486 -0.0679358 0.0660802 0.111717 -0.00410491 0.00690337 -0.128343 -0.0600406 -0.142231 0.24965 0.308208 0.23266 0.0520253 -0.0828694 -0.0334565 0.128223 -0.215427 0.0142981 -0.117156 -0.0564992 -0.156703 -0.0136527 -0.0383912 -0.0179024 -0.0342711 0.0579347 0.333561 -0.109913 -0.292047 -0.020367 -0.0491262 -0.18798 -0.0247658 0.0755908 -0.00766519 -0.0727738 -0.0405941 -0.00658847 -0.0115425 -0.166544 0.0559409 -0.0310851 -0.058849 0.00380344 -0.24117 -0.0719822 -0.0820552 -0.114157 0.0588534 0.245615 0.049023 -0.0785571 0.142826 -0.0248087 0.285052 0.0699102 0.100022 0.0847188 0.090524 0.0197199 -0.00520906 0.0517568 0.376354 -0.00723147 0.095688 0.131127 0.0147843 -0.179688 -0.0772801 -0.160305 -0.0144132 -0.0574858 0.136889 0.113507 0.0560935 -0.0845217 -0.0785592 -0.101778 -0.0842293 -0.0836161 -0.0859494 -0.0592827 -0.0975957 -0.028005 0.108137 0.116407 0.160795 0.0307125 0.0281218 -0.108549 0.0601557 0.00403307 0.00656835 0.0444443 0.222376 -0.00205973 -0.0362298 -0.121302 0.812561 0.00221774 0.237814 0.316045 0.172356 -0.000726804 0.0407577 0.00819434 -0.0840609 -0.26455 -0.281341 -0.0190242 0.0240845 -0.0266649 0.116759 0.0889722 0.0590214 0.0585379 -0.201653 0.0872233 -0.289718 -0.457144 -0.317052 -0.0738113 -0.0603764 0.146265 0.100289 -0.194254 -0.244155 0.00766624 0.0842816 0.0731751 0.0230254 0.114509 -0.0632 0.0189756 0.206379 0.0678411 0.0256787 -0.182593 -0.00608559 -0.190303 -0.0427254 0.133847 -0.0750359 -0.20806 -0.00944696 0.0478108 0.0124722 -0.232867 -0.175049 -0.019309 0.0293643 -0.0814017 -0.293671 0.22981 -0.0104054 -0.136699 -0.0055413 -0.0656998 0.318127 -0.0300018 -0.181007 -0.0437111 -0.0649685 0.147509 0.204009 -0.130125 0.19829 0.100886 0.00626445 -0.0863327 -0.154592 -0.312055 -0.0383216 -0.0865081 0.217963 0.176309 -0.0192059 0.0869867 0.0485337 0.0269649 -0.0297697 0.0831298 0.0946569 -0.0291246 -0.0987588 0.00582951 0.175148 0.105519 0.0944496 -0.185184 0.0181165 -0.236548 -0.0232191 0.0698924 0.0891822 0.121864 -0.0443506 0.00829986 0.163004 0.0108472 0.0283505 -0.181511 -0.0650762 0.0845149 0.0962171 -0.190564 0.10749 0.0939773 -0.0234348 -0.223743 0.10236 0.112693 0.100129 -0.0644053 0.0180405 -0.142215 0.305966 0.0851624 -0.0169614 0.04291 0.0627372 -0.0131749 0.0261668 -0.0633883 0.279467 0.230274 -0.150363 -0.0693517 0.100927 0.119295 0.0356948 -0.0856852 -0.0555285 0.0619101 -0.00146945 -0.0702843 -0.203981 -0.0856431 0.0947453 -0.0793924 -0.109503 -0.017296 0.242396 -0.0641928 -0.305567 -0.293712 -0.123715 0.18374 -0.116372 -0.252151 0.0179801 0.162959 -0.00288657 -0.0208934 -0.0350224 0.15635 0.0258522 -0.0522835 -0.135265 0.076039 0.489693 0.377187 -0.169667 -0.0829182 0.223771 0.130441 -0.13213 -0.151948 0.186407 -0.0800281 0.0691533 -0.127172 -0.00550914 0.0364167 -0.0910068 -0.0767431 0.056986 0.00941525 0.268233 -0.0830731 -0.237192 -0.135812 0.236819 0.281531 0.0287555 -0.0762722 0.11051 -0.0249007 0.197386 0.0505611 -0.0148811 0.102492 0.137345 -0.01075 -0.0219163 -0.155191 0.017922 -0.19235 -0.138305 -0.353044 0.0648529 0.177144 -0.139283 -0.227006 0.13526 0.0743115 0.135356 -0.129395 -0.107466 0.00304908 0.0135733 -0.0191982 0.0610791 -0.0298849 0.330069 0.040014 0.00389974 -0.0763725 -0.0818869 0.0118807 0.150931 -0.00963188 -0.0240398 0.174136 -0.0114336 0.0642045 -0.141171 -0.135121 -0.19397 -0.125707 -0.00523646 -0.122284 0.092907 0.329919 -0.0528091 -0.0457051 0.210247 0.234763 0.274601 0.144384 -0.0581128 0.122856 -0.192228 0.11114 -0.0609331 -0.193515 0.00259363 -0.110397 -0.229842 -0.0590318 0.244321 0.0527196 -0.144256 -0.367605 -0.281714 -0.0960706 -0.140442 -0.00707071 -0.127257 0.172667 -0.0561947 0.0292984 0.0489565 -0.0452082 -0.178461 -0.0120474 0.010209 0.0340465 -0.199646 0.205306 0.097943 0.262355 0.043019 -0.0695479 -0.0226927 0.114929 0.0805469 -0.0883551 -0.0136051 -0.0016808 0.0143139 -0.215833 -0.0286458 0.0710461 0.0465273 0.0864994 0.406736 0.348563 -0.0941463 -0.393989 -0.284865 -0.129725 0.0442062 -0.0535966 -0.234892 0.0972417 -0.285781 -0.0514919 -0.212302 -0.00087499 0.184246 0.0931008 0.013839 -0.172422 -0.305535 0.564938 -0.483718 -0.280091 0.141919 -0.101998 -0.185934 -0.192785 -0.0986174 0.279985 -0.363658 -0.0052367 -0.0163078 -0.0844433 0.133885 -0.0453188 0.00681035 0.0378583 0.0397831 -0.139054 -0.0160363 -0.295454 0.0292263 0.0320583 0.00775532 -0.0472026 -0.0376298 0.313992 -0.167365 0.236145 0.0295398 -0.0993126 -0.271789 -0.266154 -0.045571 0.0991098 0.069383 -0.0429165 -0.293631 -0.223343 -0.0402408 0.0668075 -0.147962 -0.0599618 -0.0215618 0.19598 -0.0872555 0.16412 0.130912 -0.0516799 -0.0351091 -0.0858394 0.079511 0.126206 0.147499 -0.105008 0.0437526 0.00334311 -0.155593 -0.128052 -0.25617 -0.220503 -0.155964 0.16822 0.139196 0.0510098 0.083358 0.031194 0.0796548 -0.00824945 0.0188701 0.00194814 -0.592292 -0.119832 0.172057 0.0854024 0.0200436 0.103208 0.14633 0.230934 -0.118833 -0.00581487 -0.0652085 0.123197 0.0124339 0.0319724 0.0813049 0.134597 0.148948 0.0272596 0.0347649 -0.233163 -0.0303612 0.0556118 0.16519 0.0622524 0.246736 0.216037 0.0441449 -0.21074 -0.0406344 -0.0261562 -0.0198293 -0.0157723 0.0956641 -0.111215 0.110414 0.106349 -0.056217 0.0221296 -0.0964693 -0.0699945 -0.0696948 -0.190964 0.0763363 0.016398 -0.0235602 -0.0132751 0.0898094 0.150693 0.16738 0.085356 -0.13858 -0.182686 -0.0305354 0.0225444 0.0535916 0.255359 -0.102334 -0.0618353 0.139136 0.0826349 0.0308509 -0.172683 0.0758153 -0.0513096 0.0470565 0.0309468 0.0657697 -0.0126726 0.0498616 -0.0793396 0.0522932 0.0456826 0.632042 0.294071 0.0649154 0.159579 0.139544 0.38189 0.0965171 -0.37988 -0.0539192 -0.0809122 -0.093278 0.0402246 0.0147224 0.0635799 0.242198 0.325805 0.0847972 0.11527 0.0285272 -0.000430261 0.189992 0.126215 0.00741998 -0.0914052 -0.0595758 0.191186 0.162207 -0.0834596 -0.152032 -0.0768655 0.0632626 -0.0225199 -0.0879601 -0.007016 0.0747599 0.0405774 0.474316 0.211239 0.128164 0.0289047 -0.124025 -0.295682 -0.1478 0.0291071 0.0196847 -0.16969 -0.0809769 -0.0862648 0.0112549 0.0195121 -0.103755 -0.116085 -0.0102248 -0.034915 0.210896 -0.0104463 -0.0326057 0.0257041 -0.00386209 -0.0690295 -0.0663693 0.03231 0.0108088 -0.183522 0.140274 -0.0802235 0.0737071 -0.13641 0.0970416 0.013265 -0.0485375 -0.110257 0.033317 0.133928 -0.392694 -0.0934875 0.489666 0.031283 0.0654826 -0.0423284 -0.130295 0.143551 0.0526587 -0.0446382 -0.13458 0.019795 -0.0408275 0.0636842 0.0476816 0.134551 0.0951618 -0.121522 -0.270953 -0.168724 0.334443 -0.0593911 -0.220457 -0.0962335 0.0253848 0.0427121 -0.0907547 -0.131499 0.0159227 -0.00249678 0.0301277 -0.0741113 -0.0948609 -0.0914437 -0.133278 -0.0355998 0.0976815 0.140688 0.132693 0.2199 0.160216 -0.147906 -0.0818684 0.2128 -0.175882 -0.0748416 -0.017371 0.134433 0.0237579 -0.102023 -0.179224 -0.042943 0.041963 -0.0967519 0.45462 -0.118356 -0.702984 0.0528589 0.187009 -0.0787802 -0.0975742 0.0337318 0.0988493 0.271396 -0.0697229 -0.00117778 -0.0821759 0.0622327 -0.0723649 -0.0749225 -0.135177 -0.21193 0.542375 0.0986715 -0.782175 0.0960739 0.186603 -0.10651 -0.209715 -0.102128 0.0769135 0.119829 0.180862 0.0273667 -0.106463 -0.129499 -0.218767 -0.0229906 0.192874 -0.110624 -0.155576 -0.0492239 0.394693 -0.13618 -0.464193 -0.118028 0.0790558 0.0443933 0.0286333 -0.150573 0.106851 -0.0677337 -0.0161629 -0.0576436 0.108346 0.00546154 0.281962 -0.118069 -0.206207 -0.110655 0.266896 -0.0393143 -0.0876163 0.0125116 0.119085 0.0509402 -0.0911 -0.128684 -0.103647 0.0449241 -0.0131619 -0.0737869 -0.0636343 0.0158374 0.360293 0.0816556 0.262505 0.0295852 -0.127196 -0.324842 -0.0729737 -0.0259931 0.108417 -0.0981648 -0.0727229 0.0112416 0.153169 -0.093807 -0.15055 0.035216 0.155644 -0.0972454 0.431165 0.0445774 0.35729 -0.238629 -0.761138 -0.203992 0.0620572 0.140433 0.0484328 -0.0760749 0.0663699 -0.0323713 -0.0825792 -0.081931 -0.100433 0.0087554 -0.0294358 -0.122986 0.367566 0.0832562 0.386404 0.0113549 -0.113161 -0.11585 -0.0454134 0.00119299 0.0658329 -0.0551982 0.199972 -0.0726621 0.0404892 -0.143587 0.161663 0.00989744 -0.0583548 -0.0641471 -0.126149 -0.105765 -0.180871 -0.0140971 0.0993396 0.0626786 0.0164829 -0.120393 -0.0120236 0.0267269 0.0369891 -0.0278692 0.0697173 0.00157279 0.0346318 0.0365465 0.0364351 -0.0463293 0.0719872 0.234179 0.0700754 0.0454905 0.0179139 0.00595942 0.00178118 -0.0757482 0.122689 0.0301975 -0.0582152 -0.0393595 0.0426631 -0.0308872 -0.155719 0.0245356 0.0514281 -0.0331139 0.16308 0.147502 0.224563 0.00149026 -0.19422 -0.00245891 0.00201232 0.0104737 0.00952506 -0.087858 6.47322e-05 0.0314169 -0.0510392 -0.0137016 0.0144097 -0.0295847 -0.0166223 -0.0935091 0.132211 -0.0996081 0.297871 -0.0929839 -0.404187 0.00734247 0.0342272 0.0465792 0.10261 0.101541 -0.0710669 -0.0647102 -0.0167732 -0.0792188 0.114399 0.0084752 -0.0984425 0.0487576 0.104527 0.0104202 0.25442 -0.132452 -0.147611 -0.260759 -0.171302 -0.00105613 -0.0352155 0.0471581 0.0503479 -0.0304953 0.0811992 0.0571881 0.0241816 -0.0302046 -0.042417 -0.0158246 0.0789319 0.278062 0.134237 0.0776471 -0.0215679 0.163599 0.00440529 -0.251491 -0.0694608 0.244747 0.0525392 -0.174708 0.0384829 0.186693 -0.0194743 -0.100282 -0.0706602 0.0455089 0.036666 0.0560859 -0.0455239 0.123939 0.0318264 0.0234766 -0.0573187 0.107605 -0.0486884 -0.0651118 0.0378355 -0.0347981 0.00422118 0.0338115 0.0272182 0.00532772 -0.0101238 0.100865 0.137984 0.192333 -0.0230741 0.0145724 0.183426 0.155987 -0.057101 -0.192028 -0.243608 0.302293 0.0796913 -0.293148 0.00127396 -0.019316 0.093773 0.117825 0.0864045 0.0216239 -0.0627421 -0.152207 0.184666 -0.0225224 -0.0524557 -0.0367394 -0.048723 0.100491 0.202537 0.000745996 -0.0288756 0.00148543 0.0784119 -0.0592042 0.0685676 0.134821 -0.0762534 0.0510426 -0.425051 -0.243875 0.0961206 0.206394 0.118967 -0.00696505 -0.0815457 0.342184 0.291138 -0.215723 -0.121786 0.228353 -0.193869 -0.120802 0.0608357 -0.0235667 -0.145194 0.00759666 -0.034862 -0.0469551 0.123362 -0.0226347 -0.00974243 0.117364 -0.0843802 -0.055497 0.0215514 -0.0301978 0.0112418 0.0368944 -0.0893707 0.129628 0.0243118 -0.0220287 -0.0459718 0.0799326 -0.143523 0.471748 -0.012469 -0.0580974 -0.0525712 0.128289 0.149932 -0.00302388 -0.125934 0.0786458 -0.048059 -0.00901601 -0.0404284 0.117521 -0.121534 0.108784 0.126158 -0.114182 0.257331 -0.0310021 0.0695447 0.153758 -0.0636068 -0.0998118 -0.0717972 -0.102052 -0.114542 0.0407005 -0.117379 -0.0749038 -0.0115072 0.0580869 0.0671776 -0.000304893 -0.0538705 -0.117465 -0.00287373 -0.0256009 -0.0636826 -0.0312657 -0.13077 -0.0061836 0.0432434 -0.0595603 -0.163516 0.0870283 0.274406 0.00354131 -0.302371 0.157017 0.236665 -0.147954 -0.196912 -0.111815 -0.0337404 0.0821758 0.0989727 0.175779 0.000249754 -0.25664 0.0464443 -0.0548022 0.0210559 -0.0606205 -0.00415924 0.116475 -0.10726 -0.0444887 0.168687 -0.18906 -0.109001 0.115015 0.155224 -0.0138517 -0.0679595 -0.0751129 -0.0129427 0.0919048 0.172384 -0.00683679 -0.0836871 0.0586344 0.122329 -0.0920789 -0.103059 0.0642979 0.15209 -0.0522484 -0.038811 0.0493885 0.0917311 -0.103801 -0.0485947 0.0726457 -0.0256357 -0.0392485 0.128359 0.133325 -0.0966681 -0.151468 0.150596 0.0487153 0.0293802 0.0944193 -0.0302072 -0.0383394 -0.0784558 -0.0446012 0.181688 -0.503953 -0.234605 0.23727 0.125257 -0.0732608 -0.307531 0.199292 0.100369 -0.0449628 -0.128511 -0.0610341 0.0708762 -0.0824378 -0.15822 0.116048 -0.146321 -0.0616026 -0.149122 -0.690181 0.0923413 0.239125 0.235905 -0.183657 -0.500252 0.223169 0.581313 -0.0424044 -0.33193 -0.118295 0.463475 0.0325293 -0.376496 0.0201681 0.168377 0.0165691 0.211439 -0.37421 -0.0812108 -0.0972299 0.0226568 0.225501 0.204552 -0.121544 0.0419528 -0.101529 0.00181799 0.086009 0.031965 -0.0309837 0.0202111 0.0361025 -0.0279149 0.0476917 -0.117005 -0.116634 0.0720398 -0.373911 -0.254457 0.237642 0.270035 -0.119457 -0.414178 0.15323 0.337276 0.0735205 -0.234025 0.00362945 0.0573864 0.00701362 -0.0361344 0.0402088 -0.417454 0.185565 -0.257488 0.178168 0.256465 -0.0665193 0.0522047 0.0736985 0.00840293 -0.0452689 -0.243279 0.0624759 0.043181 -0.082835 -0.0272137 -0.0719697 -0.032596 0.0147108 0.213514 -0.19047 -0.472857 0.277827 -0.0427543 0.000576973 -0.10838 0.0926987 0.090293 -0.0995884 -0.192612 0.0651771 -0.113166 0.161899 -0.0260323 0.0167942 -0.0327622 0.0281352 0.0844825 -0.417291 -0.353655 -0.119017 -0.169474 -0.0697634 -0.152224 0.214902 0.197915 -0.151216 -0.169451 0.237557 0.120469 0.153692 -0.148378 0.0173856 0.105836 0.0457673 -0.162221 0.3293 -0.11986 0.104763 0.20654 0.032141 0.0980827 0.187595 0.0906171 -0.179668 -0.031349 -0.0915287 -0.0624823 0.0247889 0.0411239 -0.0252026 -0.071556 -0.100806 -0.467319 0.462235 -0.163684 -0.0339773 -0.0815014 0.105674 0.134531 -0.0560339 -0.0560827 0.0136451 0.217139 -0.108433 -0.11713 0.132442 0.0381024 0.0264875 -0.0728866 -0.0141755 -0.996327 0.463087 0.0162716 -0.279275 -0.0785188 -0.0626995 0.117591 0.00260401 -0.0809912 0.0832688 0.168961 -0.117573 0.0153485 0.0387164 0.0114593 -0.0777107 0.0527547 0.00628565 -0.26301 -0.417872 0.0559441 0.16125 -0.0321918 0.105246 -0.304421 0.0210794 0.00638279 0.103374 -0.0240736 0.176431 0.00167034 0.00176263 0.019307 0.0437794 -0.0407008 0.15164 0.256638 -0.243051 -0.0234826 0.0427931 0.0314591 0.150012 -0.102223 -0.0941515 -0.0728122 -0.0252282 -0.0547703 0.0272074 -0.0126805 0.00370477 0.0193586 0.0134075 -0.0187448 -0.0449414\n"
  },
  {
    "path": "scripts/vad/turnDetector.conf.inc",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE LSTM-RNN voice activity detector<              //////////////////\n/////////                                                            //////////////////\n///////// (c) audEERING UG (haftungsbeschränkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\n\n;; turn detector configuration module\n\n[componentInstances:cComponentManager]\ninstance[turn].type=cTurnDetector\n\n[turn:cTurnDetector]\nreader.dmLevel=vad_VAD_voice\nwriter.dmLevel=isTurn\nreadVad=1\nthreshold = -0.1\nthreshold2 = -0.1\nwriter.levelconf.noHang=1\nmsgInterval = 0\nmessageRecp = waveSinkCut\neventRecp = waveSinkCut\nstatusRecp = waveSinkCut\ndebug=\\cm[turndebug{4}:set this to 1 to see turn/speaking debug messages]\n;; examples for constraining the turn length\n;; minTurnLengthTurnFrameTimeMessage=0.9\n;; maxTurnLength=10.0\n; default (0) is infinite maximum length\nmaxTurnLength=0\nmaxTurnLengthGrace=1\nnPre = 8\nnPost = 35\n\n\n"
  },
  {
    "path": "scripts/vad/vad_opensource.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\r\n///////// > openSMILE LSTM-RNN voice activity detector<              //////////////////\r\n/////////                                                            //////////////////\r\n///////// (c) audEERING UG (haftungsbeschränkt),                     //////////////////\r\n/////////     All rights reserverd.                                  //////////////////\r\n///////////////////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[dataMemory].type = cDataMemory\r\ninstance[waveSource].type = cWaveSource\r\n; verbose level stats\r\n; printLevelStats = 6\r\n\r\n[waveSource:cWaveSource]\r\nwriter.dmLevel = wave\r\nfilename = \\cm[inputfile(I){input.wav}:name of input file]\r\nmonoMixdown = 1\r\nstart = 0\r\nend = -1\r\nendrel = 0\r\nnoHeader = 0\r\nbuffersize_sec = 10\r\n\r\n;; includes the VAD module\r\n\\{vad_opensource.conf.inc}\r\n\r\n\r\n[componentInstances:cComponentManager]\r\n; output vad activations\r\ninstance[csvSink].type = cCsvSink\r\n\r\n[csvSink:cCsvSink]\r\nreader.dmLevel=vad_VAD_voice\r\nfilename= \\cm[csvoutput(O){vad.csv}:name of VAD output file]\r\nprintHeader = 0\r\ntimestamp = 1\r\nnumber = 0\r\ndelimChar = ,\r\n\r\n"
  },
  {
    "path": "scripts/vad/vad_opensource.conf.inc",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\r\n///////// > openSMILE LSTM-RNN voice activity detector<              //////////////////\r\n/////////                                                            //////////////////\r\n///////// (c) audEERING UG (haftungsbeschränkt),                     //////////////////\r\n/////////     All rights reserverd.                                  //////////////////\r\n///////////////////////////////////////////////////////////////////////////////////////\r\n\r\n\r\n[componentInstances:cComponentManager]\r\ninstance[framerVAD].type = cFramer\r\ninstance[vectorPreemphasisVAD].type = cVectorPreemphasis\r\ninstance[windowerVAD].type = cWindower\r\n ; magnitude FFT spectrum\r\ninstance[fftVAD].type=cTransformFFT\r\ninstance[fftmagVAD].type=cFFTmagphase\r\n ; compute critical-bands from power spectrum\r\ninstance[melspecVAD].type=cMelspec\r\n ; compute PLP 1-12 from critical-band spectrum\r\ninstance[plpVAD].type=cPlp\r\n ; compute log-energy from raw signal frames \r\n ; (not windowed, not pre-emphasised: that's the way HTK does it)\r\n;instance[energyVAD].type=cEnergy\r\n ; compute delta coefficients from PLP and energy\r\ninstance[deltaVAD].type=cDeltaRegression\r\n ; compute acceleration coefficients from delta coefficients of PLP and energy\r\n;instance[accelVAD].type=cDeltaRegression\r\n ; MVN (2x)\r\ninstance[mvnVAD].type = cVectorMVN\r\n;; experimental MVN adaption, uncomment to enable\r\n;; and also change reader.dmLevel of lstm_vad component\r\n;instance[mn2VAD].type = cVectorMVN\r\n ; LSTM for VAD\r\ninstance[lstmVAD].type=cRnnProcessor\r\ninstance[dataSelectorVAD].type = cDataSelector\r\n\r\n[framerVAD:cFramer]\r\nreader.dmLevel = wave\r\nwriter.dmLevel = framesVAD\r\n// nameAppend = \r\ncopyInputName = 1\r\nframeMode = fixed\r\n// frameListFile = \r\n// frameList = \r\nframeSize = 0.025000\r\nframeStep = 0.01\r\nframeCenterSpecial = left\r\nbuffersize = 100000\r\nnoPostEOIprocessing = 1\r\n \r\n[vectorPreemphasisVAD:cVectorPreemphasis]\r\nreader.dmLevel = framesVAD\r\nwriter.dmLevel = prframesVAD\r\n// nameAppend = \r\ncopyInputName = 1\r\nprocessArrayFields = 1\r\nk = 0.970000\r\nde = 0\r\n   \r\n[windowerVAD:cWindower]\r\nreader.dmLevel = prframesVAD\r\nwriter.dmLevel = winframesVAD\r\n// nameAppend = \r\ncopyInputName = 1\r\nprocessArrayFields = 1\r\ngain = 1\r\noffset = 0\r\nwinFunc = ham\r\n;sigma = 0.400000\r\n;alpha = 0.160000\r\n\r\n[fftVAD:cTransformFFT]\r\nreader.dmLevel=winframesVAD\r\nwriter.dmLevel=fftVAD\r\n\r\n[fftmagVAD:cFFTmagphase]\r\nreader.dmLevel=fftVAD\r\nwriter.dmLevel=fftmagVAD\r\n\r\n[melspecVAD:cMelspec]\r\nreader.dmLevel=fftmagVAD\r\nwriter.dmLevel=melspec_powerVAD\r\n; no htk compatible sample value scaling\r\nhtkcompatible = 0\r\nnBands = 26\r\n; use power spectrum instead of magnitude spectrum\r\nusePower = 1\r\nlofreq = 0\r\nhifreq = 8000\r\nspecScale = mel\r\n\r\n[plpVAD:cPlp]\r\nreader.dmLevel=melspec_powerVAD\r\nwriter.dmLevel=plp_VAD\r\nbuffersize=100\r\nfirstCC = 1\r\nlpOrder = 18\r\ncepLifter = 22\r\ncompression = 0.33\r\nhtkcompatible = 0\r\nnewRASTA = 1\r\nRASTA = 0\r\nrastaUpperCutoff = 29.0\r\nrastaLowerCutoff = 0.9\r\ndoIDFT = 1\r\ndoLpToCeps = 1\r\ndoLP = 1\r\ndoInvLog = 1\r\ndoAud = 1\r\ndoLog = 1\r\n\r\n[energyVAD:cEnergy]\r\nreader.dmLevel=winframesVAD\r\nwriter.dmLevel=energy_VAD\r\nhtkcompatible=1\r\nrms = 0\r\nlog = 1\r\n\r\n[deltaVAD:cDeltaRegression]\r\nreader.dmLevel=plp_VAD\r\nwriter.dmLevel=plpde_VAD\r\ndeltawin=2\r\nblocksize=1\r\n\r\n[accelVAD:cDeltaRegression]\r\nreader.dmLevel=plpde_VAD\r\nwriter.dmLevel=plpdede_VAD\r\ndeltawin=2\r\nblocksize=1\r\n\r\n[mvnVAD:cVectorMVN]\r\nreader.dmLevel = plp_VAD;plpde_VAD\r\nwriter.dmLevel = plpmvn_VAD\r\n// nameAppend =\r\ncopyInputName = 1\r\nprocessArrayFields = 0\r\nmode = transform\r\ninitFile = rplp18d_norm.dat\r\nhtkcompatible = 0\r\nmeanEnable = 1\r\nstdEnable = 1\r\nnormEnable = 0\r\n\r\n; experimental incremental MVN adaptation\r\n; disabled by default\r\n[mn2VAD:cVectorMVN]\r\nreader.dmLevel = plpmvn_VAD\r\nwriter.dmLevel = plpmvn2_VAD\r\nprocessArrayFields = 0\r\nmode = incremental\r\nupdateMethod = fix\r\nfixedBuffer = 30.0\r\nmeanEnable = 1\r\nstdEnable = 0\r\nnormEnable = 0\r\n\r\n[lstmVAD:cRnnProcessor]\r\nreader.dmLevel = plpmvn_VAD\r\n;; enable this, if you enable the \r\n;; experimental incremental adaptaion\r\n; reader.dmLevel = plpmvn2_VAD\r\nwriter.dmLevel = vad_VAD\r\nnetfile = lstmvad_rplp18d_12.net\r\n\r\n[dataSelectorVAD:cDataSelector]\r\nreader.dmLevel = vad_VAD\r\nwriter.dmLevel = vad_VAD_voice\r\nnameAppend = vadBin\r\ncopyInputName = 1\r\nselectedRange = 0\r\nelementMode = 1\r\n\r\n\r\n"
  },
  {
    "path": "scripts/vad/vad_segmenter.conf",
    "content": "///////////////////////////////////////////////////////////////////////////////////////\n///////// > openSMILE LSTM-RNN voice activity detector<              //////////////////\n/////////                                                            //////////////////\n///////// (c) audEERING UG (haftungsbeschränkt),                     //////////////////\n/////////     All rights reserverd.                                  //////////////////\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n[componentInstances:cComponentManager]\ninstance[dataMemory].type = cDataMemory\ninstance[waveSource].type = cWaveSource\n\n[waveSource:cWaveSource]\nwriter.dmLevel = wave\nfilename = \\cm[inputfile(I){input.wav}:name of input file]\nmonoMixdown = 1\nstart = 0\nend = -1\nendrel = 0\nnoHeader = 0\nbuffersize_sec = 10\n\n\n ; inculdes a VAD module\n\\{vad_opensource.conf.inc}\n ; and a turn detector module\n\\{\\cm[turnDetector(T){turnDetector.conf.inc}:filename of turn detector config file]}\n\n\n[componentInstances:cComponentManager]\n ; the wave file segmenter\ninstance[waveSinkCut].type = cWaveSinkCut\n ; optional: CSV output\ninstance[csvSink].type = cCsvSink\nprintLevelStats = 0\n\n[waveSinkCut:cWaveSinkCut]\nreader.dmLevel = framesVAD\nfileBase = \\cm[waveoutput(W){output_segment_}:prefix of WAV output files]\nfileExtension = .wav\nfileNameFormatString = %s%04d%s\nstartIndex = 1\npreSil = 0.1\npostSil = 0.1\nmultiOut = 1\nsampleFormat = 16bit\n; sample rate should be read from the input level\n; automatically. In some cases this does not work due to\n; round-off errors, so you can force it manually here:\n;forceSampleRate = 44100\n;forceSampleRate = 16000\nsaveSegmentTimes = \\cm[saveSegmentTimes{?}:file to save segment times to]\n\n[csvSink:cCsvSink]\nreader.dmLevel=vad_VAD_voice\nfilename= \\cm[csvoutput{?}:name of VAD output file]\nprintHeader = 0\ntimestamp = 1\nnumber = 0\n\n"
  },
  {
    "path": "src/android/jniMessageInterface.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n\n#include <android/jniMessageInterface.hpp>\n#ifdef __ANDROID__\n#ifdef BUILD_COMPONENT_JniMessageInterface\n\n#define MODULE \"cJniMessageInterface\"\n\nSMILECOMPONENT_STATICS(cJniMessageInterface)\n\nSMILECOMPONENT_REGCOMP(cJniMessageInterface)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CJNIMESSAGEINTERFACE;\n  sdescription = COMPONENT_DESCRIPTION_CJNIMESSAGEINTERFACE;\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"sendMessagesInTick\", \"1/0 enable/disable sending of messages synchronized in tick(). If set to 0, a background thread will be started which will send messages from the queue in the background (NOT YET IMPLEMENTED).\", 1);\n    ct->setField(\"JNIcallbackClass\", \"Fully qualified Java name of class in APP which handles callbacks. Must be changed to the app namespace and domain.\", \"java/com/audeering/testapp01/SmileJNIcallbacks\");\n    ct->setField(\"JNIstringReceiverMethod\", \"Name of method which receives string messages in JNIcallbackClass. Default should not need to be changed, if class wasn't changed.\", \"receiveText\");\n    ct->setField(\"debugPrintJson\", \"1 = debug print to smile log the formatted json before sending.\", 0);\n  )\n  SMILECOMPONENT_MAKEINFO(cJniMessageInterface);\n}\n\n\nSMILECOMPONENT_CREATE(cJniMessageInterface)\n\n//-----\ncJniMessageInterface::cJniMessageInterface(const char *_name):\n  cSmileComponent(_name), jvm_(NULL), sendMessagesInTick_(1),\n  env_(NULL) { }\n\nvoid cJniMessageInterface::fetchConfig() {\n  sendMessagesInTick_ = getInt(\"sendMessagesInTick\");\n  JNIstringReceiverMethod_ = getStr(\"JNIstringReceiverMethod\");\n  JNIcallbackClass_ = getStr(\"JNIcallbackClass\");\n  jvm_ = (JavaVM *)getExternalPointer(\"JavaVM\");\n  gFindClassMethod_ = (jmethodID *)getExternalPointer(\"FindClassMethod\");\n  gClassLoader_ = (jobject *)getExternalPointer(\"ClassLoader\");\n  debugPrintJson_ = getInt(\"debugPrintJson\");\n}\n\nint cJniMessageInterface::myFinaliseInstance() {\n  if (!sendMessagesInTick_) {\n    // TODO: create background thread!\n    SMILE_IERR(1, \"background message thread not yet supported! Message sending through JNI disabled.\");\n  }\n  return 1;\n}\n\n// JNI calls for exchange of smile messages\n\nJNIEnv * cJniMessageInterface::AttachToThreadAndGetEnv() {\n JNIEnv * env = NULL;\n if (jvm_ == NULL) {\n   SMILE_IERR(2, \"no JVM pointer! Cannot access Java VM to get environment and exchange JNI data.\");\n   return env;\n }\n // double check it's all ok\n int getEnvStat = jvm_->GetEnv((void **)&env, JNI_VERSION_1_6);\n if (getEnvStat == JNI_EDETACHED) {\n   SMILE_IMSG(4, \"GetEnv: not attached\");\n   if (jvm_->AttachCurrentThread((JNIEnv **)&env, NULL) != 0) {\n     SMILE_IERR(2, \"GetEnv: failed to attach to current thread!\");\n   }\n } else if (getEnvStat == JNI_OK) {\n   //\n } else if (getEnvStat == JNI_EVERSION) {\n   SMILE_IERR(2, \"GetEnv: version not supported\");\n }\n return env;\n}\n\nvoid cJniMessageInterface::DetachFromThread(JNIEnv * env) {\n  if (env == NULL || jvm_ == NULL)\n   return;\n  if (env->ExceptionCheck()) {\n    env->ExceptionDescribe();\n  }\n  jvm_->DetachCurrentThread();\n}\n\n/*\n *\n * JNIEnv * env = getEnv();\n    //replace with one of your classes in the line below\n    jclass randomClass = env->FindClass(\"com/audeering/testapp01/SmileJNI\");\n    jclass classClass = env->GetObjectClass(randomClass);\n    jclass classLoaderClass = env->FindClass(\"java/lang/ClassLoader\");\n    jmethodID getClassLoaderMethod = env->GetMethodID(classClass, \"getClassLoader\",\n                                             \"()Ljava/lang/ClassLoader;\");\n    gClassLoader = env->CallObjectMethod(randomClass, getClassLoaderMethod);\n    gFindClassMethod = env->GetMethodID(classLoaderClass, \"findClass\",\n                                    \"(Ljava/lang/String;)Ljava/lang/Class;\");\n    return JNI_VERSION_1_6;\n}\n\n *\n */\n\n/*\njclass cJniMessageInterface::findClass(JNIEnv *env, const char* name) {\n    return static_cast<jclass>(env->CallObjectMethod(gClassLoader, gFindClassMethod, getEnv()->NewStringUTF(name)));\n}*/\n\nint cJniMessageInterface::sendTextToJava(JNIEnv *env, const char * str) {\n  if (str == NULL || env == NULL)\n    return 0;\n  SMILE_IDBG(2, \"resolving:0 JNIcallbackClass_ %s\", JNIcallbackClass_);\n  jclass app = static_cast<jclass>(env->CallObjectMethod(*gClassLoader_, *gFindClassMethod_, JNIcallbackClassJstring_));\n//  jclass app = env->FindClass(JNIcallbackClass_); //\"com/audeering/testapp01/SmileJNIcallbacks\");\n  jmethodID sendDataToJava = env->GetStaticMethodID(app, JNIstringReceiverMethod_, \"(Ljava/lang/String;)V\");  // \"([B)V\"\n  jstring jstr = env->NewStringUTF(str);\n//  jbyteArray bArray = env->NewByteArray(len);\n//  char *bytes = (char *)env->GetByteArrayElements(bArray, 0);\n//  memcpy( bytes, data, len);\n  //env->ReleaseByteArrayElements(bArray, bytes, JNI_ABORT);\n  //env->CallStaticVoidMethod(app, sendDataToJava, bArray);\n  env->CallStaticVoidMethod(app, sendDataToJava, jstr);\n  env->DeleteLocalRef(jstr);\n  env->DeleteLocalRef(app);\n  return 1;\n}\n\nint cJniMessageInterface::sendMessageToJava(cComponentMessage &msg, JNIEnv *env) {\n  char * json = msg.serializeToJson();\n  if (debugPrintJson_) {\n    SMILE_IMSG(1, \"JSON message:\\n %s\\n\", json);\n  }\n  return sendTextToJava(env, json);\n}\n\nint cJniMessageInterface::sendMessagesFromQueue() {\n  // Sends out all messages in the queue, and remove from queue.\n  int ret = 0;\n  for (std::list<cComponentMessage>::iterator it = in_buffer_.begin(); it != in_buffer_.end(); ) {\n    if (env_ != NULL) {\n      sendMessageToJava(*it, env_);\n      ret = 1;\n    }\n    if (it->custData != NULL)\n      free(it->custData);\n    if (it->custData2 != NULL)\n      free(it->custData2);\n    it = in_buffer_.erase(it);\n  }\n  return ret;\n}\n\nint cJniMessageInterface::myTick(long long t) {\n  if (isEOI()) {\n    SMILE_IMSG(2, \"detaching from thread due to EOI\");\n    if (env_ != NULL) {\n      DetachFromThread(env_);\n      env_ = NULL;\n    }\n  } else {\n    if (env_ == NULL) {\n      SMILE_IMSG(2, \"attaching to thread (env is NULL)\");\n      env_ = AttachToThreadAndGetEnv();\n      if (env_ != NULL) {\n        JNIcallbackClassJstring_ = env_->NewStringUTF(JNIcallbackClass_);\n      }\n    }\n    if (sendMessagesInTick_) {\n      return sendMessagesFromQueue();\n    }\n  }\n  return 0;\n}\n\nint cJniMessageInterface::processComponentMessage(cComponentMessage *msg) {\n  // We copy the component message, as all memory referenced in the\n  // message will be invalid after we call \"return\" here. \n  cComponentMessage c;\n  memcpy(&c, msg, sizeof(cComponentMessage));\n  if (msg->custData != NULL) {\n    if (c.custDataType == CUSTDATA_TEXT) {\n      c.custData = malloc(sizeof(char) * (strlen((char*)msg->custData) + 1));\n      strcpy((char *)c.custData, (char *)msg->custData);\n    } else {\n      c.custData = malloc(msg->custDataSize + 1);\n      memcpy(c.custData, msg->custData, msg->custDataSize);\n    }\n  }\n  if (msg->custData2 != NULL) {\n    if (c.custDataType == CUSTDATA_TEXT) {\n      c.custData2 = malloc(sizeof(char) * (strlen((char*)msg->custData2) + 1));\n      strcpy((char *)c.custData2, (char *)msg->custData2);\n    } else {\n      c.custData2 = malloc(msg->custData2Size + 1);\n      memcpy(c.custData2, msg->custData2, msg->custData2Size);\n    }\n  }\n  // Now we save the message in the FIFO queue.\n  in_buffer_.push_back(c);\n  return 1;\n}\n\ncJniMessageInterface::~cJniMessageInterface() {\n  // Free the message queue:\n  for (std::list<cComponentMessage>::iterator it = in_buffer_.begin(); it != in_buffer_.end(); ) {\n    if (it->custData != NULL)\n      free(it->custData);\n    if (it->custData2 != NULL)\n      free(it->custData2);\n    it = in_buffer_.erase(it);\n  }\n//  JNIEnv *env = AttachToThreadAndGetEnv();\n  if (env_ != NULL) {\n    //env_->DeleteLocalRef(JNIcallbackClassJstring_);\n    //DetachFromThread(env_);\n  }\n}\n\n#endif  // BUILD_COMPONENT\n#endif  // __ANDROID__\n\n"
  },
  {
    "path": "src/android/openslesSource.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n***\n***(c) 2014-2015 audEERING UG. All rights reserved.\n***\n***Fixed and updated by Florian Eyben, fe@audeering.com\n***\n * written by Bernd Huber, 2014\n * berndbhuber@gmail.com\n---\nreads openSL audio buffer input into datamemory\nStill under development, data can be corrupt depending on platform!!!\n*/\n\n\n#include <android/openslesSource.hpp>\n#define MODULE \"cOpenslesSource\"\n\n#ifdef __ANDROID__\n#ifndef __STATIC_LINK\n#ifdef HAVE_OPENSLES\nSMILECOMPONENT_STATICS(cOpenslesSource)\n\nSMILECOMPONENT_REGCOMP(cOpenslesSource)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_COPENSLESSOURCE;\n  sdescription = COMPONENT_DESCRIPTION_COPENSLESSOURCE;\n\n  // we inherit cDataSource configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSource\")\n\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"monoMixdown\", \"Mix down all channels to 1 mono channel (1=on, 0=off)\", 1);\n    ct->setField(\"sampleRate\",\"Set/force the sampling rate that is assigned to the input data.\",16000,0,0);\n    ct->setField(\"channels\",\"Set/force the number of input (recording) channels\",1,0,0);\n\t  ct->setField(\"outFieldName\", \"Set the name of the output field, containing the pcm data\", \"pcm\");\n    //ct->setField(\"selectChannel\",\"Select only the specified channel from 'channels' that are recorded. Set to -1 to grab all channels.\",-1);\n    ct->setField(\"nBits\",\"The number of bits per sample and channel\",16);\n    ct->setField(\"nBPS\",\"The number of bytes per sample and channel (0=determine automatically from nBits)\",0,0,0);\n    ct->setField(\"audioBuffersize\",\"The size of the portaudio recording buffer in samples (overwrites audioBuffersize_sec, if set)\",0,0,0);\n    ct->setField(\"audioBuffersize_sec\",\"size of the portaudio recording buffer in seconds. This value has influence on the system latency. Setting it too high might introduce a high latency. A too low value might lead to dropped samples and reduced performance.\",0.05);\n    ct->setField(\"agcEnabled\", \"1/0 = enable automatic gain control for input audio\", 0);\n    ct->setField(\"agcTarget\", \"Target peak level for AGC, if enabled.\", 0.5);\n    ct->setField(\"agcDebug\", \"1/0 = enable agc debugging output to log.\", 0);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cOpenslesSource);\n}\n\nSMILECOMPONENT_CREATE(cOpenslesSource)\n\n//-----\n\ncOpenslesSource::cOpenslesSource(const char *_name) :\n  cDataSource(_name),\n  audioBuffersize_(0),\n  audioBuffersize_sec_(0),\n  audioDevice_(NULL),\n  sampleRate_(0),\n  warned_(false),\n  threadStarted_(false),\n  threadActive_(false),\n  threadMatrix_(NULL),\n  outFieldName_(NULL),\n  blockSizeReader_(0),\n  agcGainMin_(0.02), agcGainMax_(20.0),\n  agcGain_(1.0), agcPeakLp_(0.0),\n  agcErrorIntegrated_(0.0),\n  agcTarget_(0.5),\n  agcDebugCounter_(0),\n  agcDebug_(false)\n{\n  smileCondCreate(threadCondition_);\n  smileMutexCreate(dataFlagMutex_);\n  smileMutexCreate(threadMutex_);\n}\n\nvoid cOpenslesSource::fetchConfig()\n{\n  cDataSource::fetchConfig();\n  agcTarget_ = getDouble(\"agcTarget\");\n  agcDebug_ = (getInt(\"agcDebug\") == 1);\n  monoMixdown_ = getInt(\"monoMixdown\");\n  if (isSet(\"audioBuffersize\")) {\n    audioBuffersize_ = getInt(\"audioBuffersize\");\n  }\n  if (isSet(\"audioBuffersize_sec\")) {\n    audioBuffersize_sec_ = getDouble(\"audioBuffersize_sec\");\n  }\n  sampleRate_ = getInt(\"sampleRate\");\n  if (sampleRate_ <= 0) {\n    SMILE_IERR(1, \"sampleRate (%i) must be > 0! Setting to 16000.\", sampleRate_);\n    sampleRate_ = 16000;\n  }\n  nChannels_ = getInt(\"channels\");\n  if (nChannels_ < 1) {\n    SMILE_IERR(1, \"channels (%i) must be >= 1. Setting to 1.\", nChannels_);\n    nChannels_ = 1;\n  }\n  agcEnabled_ = (getInt(\"agcEnabled\") == 1);\n/*\n  selectChannel_ = getInt(\"selectChannel\");\n  if (selectChannel_ >= 0) {\n    SMILE_MSG(2, \"only selected %i. channel.\", selectChannel_);\n  }*/\n  nBits_ = getInt(\"nBits\");\n  nBPS_ = getInt(\"nBPS\");\n  if (nBPS_ == 0) {\n    switch (nBits_) {\n    case 8: nBPS_=1; break;\n    case 16: nBPS_=2; break;\n    case 24: nBPS_=4; break;\n    case 32: nBPS_=4; break;\n    case 33: nBPS_=4; break;\n    case 0:  nBPS_=4;\n             nBits_=32;\n             break;\n    default:\n      SMILE_ERR(1, \"invalid number of bits requested: %i (allowed: 8, 16, 24, 32, 33(for 23-bit float))\\n   Setting number of bits to default (16)\", nBits_);\n      nBits_ = 16;\n    }\n  }\n  if (nBPS_ != 2) {\n    SMILE_IERR(1, \"This openSLES interface currently only supports 16-bit (2-byte) per sample PCM formats!\");\n    COMP_ERR(\"aborting\");\n  }\n  outFieldName_ = getStr(\"outFieldName\");\n}\n\nbool cOpenslesSource::setupAudioDevice() {\n  // Opensl initialization for recording\n  SMILE_IMSG(4, \"calling setup audio sr %i, nCh %i, abfs %i\", sampleRate_, nChannels_, audioBuffersize_);\n  if (audioDevice_ == NULL) {\n    audioDevice_ = android_OpenAudioDevice(sampleRate_,\n        nChannels_, 2, audioBuffersize_,\n        false /* playback */, true /* record */);\n    if (audioDevice_ != NULL) {\n      SMILE_IMSG(3, \"Opened OpenSLES audio device.\");\n      return true;\n    } else {\n      SMILE_IERR(1, \"Failed to open OpenSLES audio device! Check your audio settings, sample rate etc.\");\n      return false;\n    }\n  } else {\n    return true;\n  }\n}\n\nbool cOpenslesSource::startRecordingThread() {\n  if (!threadStarted_) {\n    // thread should only be created once, configureWrite could be called multiple times\n    threadStarted_ = true;\n    smileThreadCreate(recordingThread_, recordingThreadEntry, this);\n  }\n  return true;\n}\n\nint cOpenslesSource::configureWriter(sDmLevelConfig &c)\n{\n  double TT = 1.0;\n  c.T = 1.0/(double)sampleRate_;\n  if (c.T != 0.0)\n    TT = c.T;\n  if (audioBuffersize_ > 0) {\n    c.blocksizeWriter = audioBuffersize_;\n    audioBuffersize_sec_ = (double)audioBuffersize_ * TT;\n  } else if (audioBuffersize_sec_ > 0.0) {\n    c.blocksizeWriter = blocksizeW_ = audioBuffersize_ = (long)ceil(audioBuffersize_sec_ / TT);\n  } else {\n    if (audioBuffersize_ != 1024) {\n      SMILE_IMSG(3,\"using default audioBuffersize (1024 samples) since no option was given in config file\");\n      audioBuffersize_ = 1024;\n    }\n    c.blocksizeWriter = audioBuffersize_;\n    audioBuffersize_sec_ = (double)audioBuffersize_ * TT;\n  }\n  blocksizeW_ = audioBuffersize_;\n  blocksizeW_sec = audioBuffersize_sec_;\n  if (setupAudioDevice()) {\n    nChannelsEffective_ = (monoMixdown_ || selectChannel_ ? 1 : nChannels_);\n    c.N = nChannelsEffective_;\n    SMILE_IMSG(3, \"nChannelsEffective = %i\", nChannelsEffective_);\n    return 1;\n  } else {\n    return 0;\n  }\n}\n\nint cOpenslesSource::myConfigureInstance()\n{\n  return cDataSource::myConfigureInstance();\n}\n\nint cOpenslesSource::setupNewNames(long nEl)\n{\n  SMILE_IMSG(4, \"calling setup new names: name = %s ; matrix rows: %i\", outFieldName_, nChannelsEffective_);\n  writer_->addField(outFieldName_, nChannelsEffective_);\n  namesAreSet_ = 1;\n  return nChannelsEffective_;\n}\n\nint cOpenslesSource::myFinaliseInstance() {\n  int ret = cDataSource::myFinaliseInstance();\n  if (ret) {\n    if (threadMatrix_ == NULL)\n      threadMatrix_ = new cMatrix(nChannelsEffective_, audioBuffersize_ / nChannelsEffective_);\n  }\n  return ret;\n}\n\n/*\nint cOpenslesSource::pauseEvent()\n{\n  stopRecording();\n  return 1;\n}\n\nvoid cOpenslesSource::resumeEvent()\n{\n  startRecording();\n}\n*/\n\nint cOpenslesSource::myTick(long long t)\n{\n  if (isPaused() || isEOI())\n    return 0;\n  if (!startRecordingThread())\n    return 0;\n// TODO: need to return 0 if recording thread was stoppped!\n\n  if (blockSizeReader_ <= 0) {\n    const sDmLevelConfig *c = writer_->getLevelConfig();\n    if (c != NULL) {\n      blockSizeReader_ = c->blocksizeReader;\n      SMILE_IMSG(4, \"blockSizeReader = %i, blockSizeWriter = %i\", c->blocksizeReader, c->blocksizeWriter);\n    }\n  }\n  //if (t < 10000)\n    //SMILE_IMSG(4, \"in tick. avail = %i, total = %i  bsReader=%i\", writer_->getNAvail(), writer_->getBuffersize(), blockSizeReader_);\n  // this will always try to fill the buffer as much as possible... for multiple threads this is absolutely ok,\n  //   for single threads the buffer might overflow... thus for single threads we might also want to check for (writer->getNAvail() < audioBuffersize )\n  if ((writer_->checkWrite(audioBuffersize_)) && (writer_->getNAvail() < blockSizeReader_)) {\n    //SMILE_IMSG(4, \"tick wait()\");\n    //smileCondTimedWait(threadCondition_, 1);  // timeout must be greater (smaller?) as expected audio buffersize?\n    // TODO: The logic of timeout depends on the buffersize....\n    //  if the reader only reads \"1\" sample in each tick\n    //   and we receive 1000 samples when threadCond is signalled,\n    //   then something will eventually block!\n    //  in the example config this is due to the waveSink component (500 samples vs. 1024 samples)!\n\n    //smileMutexLock(dataFlagMutex_);\n    //dataFlag_ = false;\n    //smileMutexUnlock(dataFlagMutex_);\n    //SMILE_IMSG(4, \"XXXX tick done\");   // with this in there the sync seems to work.. find out why!\n    return 1;\n  } else {\n    //printf(\"no wait! %i  %i  %i bs=%i\\n\",t,writer->getNAvail(), (writer->checkWrite(audioBuffersize)), audioBuffersize);\n    if (writer_->getNFree() < audioBuffersize_ * 2) {\n      if (!warned_) {\n        SMILE_IWRN(3, \"Audio buffer FULL, processing seems to be too slow. Audio data possibly lost!\\n NOTE: this warning will appear only once!\");\n        warned_ = true;\n      }\n    } else {\n      if (warned_) {\n        SMILE_IWRN(3, \"Audio buffer has space again. Processing back to normal, not slow anymore..\\n\");\n      }\n      warned_ = false;\n    }\n    // this does not work, processing in multi-thread hangs after a while\n  }\n  //SMILE_IMSG(4, \"tick done\");\n  smileMutexLock(dataFlagMutex_);\n  if (dataFlag_) {\n    dataFlag_ = false;\n    smileMutexUnlock(dataFlagMutex_);\n    return 1;\n  }\n  smileMutexUnlock(dataFlagMutex_);\n  return 0;\n}\n\n// TODO: must be called if terminated via component manager! on = 0.. ?\nvoid cOpenslesSource::terminateAudioRecordingThread() {\n  //   1. set threadActive_ = 0 to terminate the thread (while having mutex threadMutex locked, but unlock after)\n  smileMutexLock(threadMutex_);\n  int threadActive = threadActive_;\n  threadActive_ = 0;\n  smileMutexUnlock(threadMutex_);\n  if (threadActive) {  // old state. Do not signal and wait if thread was not active\n    //   2. notify the audioDevice_->recorderCondition_ to unlock the recorder thread waiting for new audio\n    smileCondSignal(audioDevice_->recorderCondition_);\n    // join thread: wait until it terminates\n    smileThreadJoin(recordingThread_);\n  }\n}\n\ncOpenslesSource::~cOpenslesSource() {\n  SMILE_IMSG(3, \"Waiting for audio recording thread to finish.\");\n  terminateAudioRecordingThread();\n  if (threadMatrix_ != NULL)\n    delete threadMatrix_;\n  android_CloseAudioDevice(audioDevice_);\n  smileCondDestroy(threadCondition_);\n  smileMutexDestroy(dataFlagMutex_);\n  smileMutexDestroy(threadMutex_);\n  SMILE_IMSG(3, \"cleanup successful\");\n}\n\n//--------------------------------------------------------------------------------openSLES code from here\n\nSMILE_THREAD_RETVAL cOpenslesSource::recordingThreadEntry(void *param)\n{\n\t//SMILE_IMSG(4,\"Starting Audio Source Thread in OpenSL\");\n  ((cOpenslesSource*)param)->recordingThreadLoop();\n  SMILE_THREAD_RET;\n}\n\n// FLOAT_DMEM peakLp = 0;\n// FLOAT_DMEM agcGain = 1;\n// FLOAT_DMEM agcGainMin = 0.02;\n// FLOAT_DMEM agcGainMax = 20.0;\n\nvoid cOpenslesSource::performAgc(cMatrix * samples)\n{\n  if (samples == NULL)\n    return;\n  // apply gain to audio buffer\n  for (int i = 0; i < samples->nT; i++) {\n    samples->dataF[i] *= agcGain_;\n  }\n  // get frame peak\n  FLOAT_DMEM peak = 0.0;\n  for (int i = 0; i < samples->nT; i++) {\n    if (fabs(samples->dataF[i]) > peak) {\n      peak = fabs(samples->dataF[i]);\n    }\n  }\n  // lowpass of peak and delta\n  FLOAT_DMEM peakLpLast = agcPeakLp_;\n  //agcPeakLp_ = 0.995 * agcPeakLp_ + 0.005 * peak;\n  if (peak > agcPeakLp_) {\n    agcPeakLp_ = 0.4 * agcPeakLp_ + 0.6 * peak;\n  } else {\n    agcPeakLp_ = 0.995 * agcPeakLp_ + 0.005 * peak;\n  }\n  // compute current error and integrate error if not outside gain bounds\n  FLOAT_DMEM error = agcTarget_ - agcPeakLp_ ;\n  if (agcGain_ < agcGainMax_ && agcGain_ > agcGainMin_)\n    agcErrorIntegrated_ += error;\n  FLOAT_DMEM errorDelta = error - (agcTarget_ - peakLpLast);\n  // compute PID output\n  FLOAT_DMEM Kp = 0.1;\n  FLOAT_DMEM Ki = 0.0;\n  FLOAT_DMEM Kd = 0.1;\n  FLOAT_DMEM update = Kp * error + Ki * agcErrorIntegrated_ + Kd * errorDelta;\n  // peakTarget = update + peakCurrent;\n  // == >  peakTarget = peakCurrent * (1 + update/peakCurrent);\n  //       peakTarget = peakCurrent * gain\n  agcGain_ = 1.0 + update/agcPeakLp_;\n  // limit gain\n  if (agcGain_ > agcGainMax_)\n    agcGain_ = agcGainMax_;\n  if (agcGain_ < agcGainMin_)\n    agcGain_ = agcGainMin_;\n  if (agcDebug_) {\n    agcDebugCounter_++;\n    if (agcDebugCounter_ == 100) {\n      SMILE_IMSG(1, \"agcGain: %.4f, agcPeakLp: %.4f, update: %.4f, error: %.4f, errorIntegrated: %.4f\",\n          agcGain_, agcPeakLp_, update, error, agcErrorIntegrated_);\n      agcDebugCounter_ = 0;\n    }\n  }\n}\n\nvoid cOpenslesSource::recordingThreadLoop()\n{\n  int16_t * inbuffer = (int16_t *)calloc(1, sizeof(int16_t) * audioBuffersize_);\n  smileMutexLock(threadMutex_);\n\tthreadActive_ = 1;\n  int threadActive = threadActive_;\n\tsmileMutexUnlock(threadMutex_);\n\tSMILE_IMSG(3, \"OpenSLES audio recording thread initialized\");\n\tif (audioDevice_ == NULL) {\n\t  SMILE_IERR(2, \"No openSLES audio device opened, terminating openSLES audio recording thread.\");\n\t  free(inbuffer);\n\t  return;\n\t}\n\tif (openSLstartRecording(audioDevice_) != SL_RESULT_SUCCESS) {\n\t  SMILE_IERR(1, \"Failed to start recording, terminating openSLES audio recording thread.\");\n\t  free(inbuffer);\n\t  return;\n\t}\n\tsWaveParameters pcmParam;\n\tpcmParam.nBits = nBits_;\n\tpcmParam.nBPS = nBPS_;\n\tpcmParam.nChan = nChannels_;\n  // NOTE: we open device before tick-loop to know whether the settings are supported\n  // However we need to check what happens to audio that is recorded while configuration is still going\n  // buffers discarded?\n\t// TERMINATING:\n\t//   1. set threadActive_ = 0 to terminate the thread (while having mutex threadMutex locked, but unlock after)\n\t//   2. notify the audioDevice_->recorderCondition_ to unlock the recorder thread waiting for new audio\n\t//   3.\n\twhile (threadActive) {\n\t\tint nSamples = android_AudioIn(audioDevice_, inbuffer, audioBuffersize_);\n\t\t//SMILE_IMSG(4, \"read nSamples = %i in thread.\", nSamples);\n\t\t// Convert samples from binary buffer to float array, given the wave parameters\n\t\t//  *buf : the raw data buffer\n\t\t//  *pcmParam : parameter struct specifying the sample format\n\t\t//  *a : The array where the converted buffer will be stored in. It must be pre-allocated to the right size! [nChan * nSamples * sizeof(float)]\n\t\t//  nChan : number of audio channels,\n\t\t//  nSamples : number of audio samples in the buffers\n\t\t//  monoMixdown : 1 = convert from multi-channel recording to mono (1 channel)\n\t\t//  Return value: number of samples processed (= nSamples)\n\t\t//DLLEXPORT int smilePcm_convertSamples(uint8_t *buf, sWaveParameters *pcmParam, float *a, int nChan, int nSamples, int monoMixdown);\n\n\t\t// TODO: check that nT will never exceed the allocated size of the matrix!\n\t\tthreadMatrix_->nT = smilePcm_convertSamples((uint8_t *)inbuffer, (sWaveParameters *)&pcmParam,\n\t\t    threadMatrix_->dataF, nChannels_, nSamples / nChannels_, monoMixdown_/*, selectChannels_*/);\n\t\tif (agcEnabled_)\n\t\t  performAgc(threadMatrix_);\n\t\t// TODO: check for lost data here due to full levels!\n\t\twriter_->setNextMatrix(threadMatrix_);\n\t\tsmileMutexLock(dataFlagMutex_);\n\t\tdataFlag_ = true;\n\t\tsmileMutexUnlock(dataFlagMutex_);\n\t\t// signal the threadCondition_ to show that there is new data.\n\t\tsmileCondSignal(threadCondition_);  // TODO: what happens if we signal twice??\n    // update the thread active status\n\t\tsmileMutexLock(threadMutex_);\n    threadActive = threadActive_;\n\t  smileMutexUnlock(threadMutex_);\n\t}\n\tSMILE_IMSG(3, \"OpenSLES thread was signaled to end.\");\n\topenSLstopRecording(audioDevice_);\n\tSMILE_IMSG(4, \"Recording stopped.\");\n\tfree(inbuffer);\n  smileMutexLock(threadMutex_);\n  threadActive_ = 0;\n  threadStarted_ = 0;\n  smileMutexUnlock(threadMutex_);\n}\n\n\n\n// open the android audio device for input and/or output\nopensl_stream2 * cOpenslesSource::android_OpenAudioDevice(int sr,\n    int inchannels, int outchannels, int bufferSize,\n    bool openPlay, bool openRecord) {\n  opensl_stream2 *p;\n  p = (opensl_stream2 *) calloc(sizeof(opensl_stream2), 1);\n  p->doNotEnqueue_ = false;\n  p->hasNewInputData_ = 0;\n  if (bufferSize <= 0) {\n    SMILE_IERR(1, \"bufferSize must be > 0 in android_OpenAudioDevice()\");\n    android_CloseAudioDevice(p);\n    return NULL;\n  }\n  smileCondCreate(p->recorderCondition_);\n  smileCondCreate(p->playerCondition_);\n  smileMutexCreate(p->newDataMutex_);\n  p->sr = sr;  // sampling rate assignment\n  if (openRecord) {\n    p->inchannels = inchannels;\n    p->inBufSamples = bufferSize * inchannels;\n    p->inBufMSeconds = (int)floor(audioBuffersize_sec_ * 1000.0);  // TODO: compute from bufferSize and sample period!\n    if (p->inBufSamples != 0) {\n      for (int i = 0; i < NUM_RECORDING_BUFFERS; ++i) {\n        p->inputBuffer[i] = (int16_t *)calloc(p->inBufSamples, sizeof(int16_t));\n        if (p->inputBuffer[i] == NULL) {\n          SMILE_IERR(1, \"Failed to allocate audio recording buffer memory # %i.\", i);\n          android_CloseAudioDevice(p);\n          return NULL;\n        }\n      }\n    }\n    p->currentInputIndex = p->inBufSamples;  // this will ensure that we:\n        // a) enqueue the last buffer and wait for the first one in audioIn\n  }\n  if (openPlay) {\n    p->outchannels = outchannels;\n    p->outBufSamples = bufferSize * outchannels;\n    if (p->outBufSamples != 0) {\n      for (int i = 0; i < NUM_PLAYBACK_BUFFERS; ++i) {\n        p->outputBuffer[i] = (int16_t *)calloc(p->outBufSamples, sizeof(int16_t));\n        if (p->outputBuffer[i] == NULL) {\n          SMILE_IERR(1, \"Failed to allocate audio playback buffer memory # %i.\", i);\n          android_CloseAudioDevice(p);\n          return NULL;\n        }\n      }\n    }\n    p->currentOutputBuffer = 0;\n  }\n\n  if (openSLCreateEngine(p) != SL_RESULT_SUCCESS) {\n    SMILE_IERR(2, \"Failed to create openSL engine.\");\n    android_CloseAudioDevice(p);\n    return NULL;\n  }\n  if (openRecord) {\n    if (openSLRecOpen(p) != SL_RESULT_SUCCESS) {\n      SMILE_IERR(2, \"Failed to open openSL audio recording.\");\n      android_CloseAudioDevice(p);\n      return NULL;\n    }\n  }\n  if (openPlay) {\n    if (openSLPlayOpen(p) != SL_RESULT_SUCCESS) {\n      SMILE_IERR(2, \"Failed to open openSL audio playback.\");\n      android_CloseAudioDevice(p);\n      return NULL;\n    }\n  }\n  p->time = 0.0;\n  return p;\n}\n\n// close the android audio device\nvoid cOpenslesSource::android_CloseAudioDevice(opensl_stream2 *p) {\n  if (p == NULL)\n    return;\n  openSLDestroyEngine(p);  // destroys player, recorder, mix, and engine\n  smileCondDestroy(p->recorderCondition_);\n  smileCondDestroy(p->playerCondition_);\n  smileMutexDestroy(p->newDataMutex_);\n  for (int i = 0; i < NUM_RECORDING_BUFFERS; ++i) {\n    if (p->inputBuffer[i] != NULL) {\n      free(p->inputBuffer[i]);\n      p->inputBuffer[i] = NULL;\n    }\n  }\n  for (int i = 0; i < NUM_PLAYBACK_BUFFERS; ++i) {\n    if (p->outputBuffer[i] != NULL) {\n      free(p->outputBuffer[i]);\n      p->outputBuffer[i] = NULL;\n    }\n  }\n  free(p);\n}\n\n// returns timestamp of the processed stream\ndouble cOpenslesSource::android_GetTimestamp(opensl_stream2 *p){\n  return p->time;\n}\n\n// gets a buffer of size samples from the device\nint cOpenslesSource::android_AudioIn(opensl_stream2 *p, int16_t * buffer, int size){\n  int16_t * inBuffer = NULL;\n  //SMILE_IMSG(5, \"waiting for a frame of size %d\", size);\n  int nSamples = p->inBufSamples;\n  if (p == NULL || nSamples ==  0 || size == 0)\n    return 0;\n  int nSamplesRead = 0;\n  inBuffer = p->inputBuffer[p->currentInputBuffer];\n  for (nSamplesRead = 0; nSamplesRead < size; ++nSamplesRead) {\n    if (p->currentInputIndex >= nSamples) {  // jump to next buffer\n      // enqueue buffer and update current buffer to the next one\n      if (!p->doNotEnqueue_) {\n        (*p->recorderBufferQueue)->Enqueue(p->recorderBufferQueue,\n            p->inputBuffer[p->currentInputBuffer], nSamples * sizeof(int16_t));\n        p->currentInputBuffer = (p->currentInputBuffer + 1) % NUM_RECORDING_BUFFERS;\n      }\n      //smileCondWait(p->recorderCondition_);   // TODO: set timeout according to audioBuffersize_sec\n      smileCondTimedWait(p->recorderCondition_, (p->inBufMSeconds * 3) / 2);\n      bool newData = false;\n      int bufferNum = 0;\n      smileMutexLock(p->newDataMutex_);\n      if (p->hasNewInputData_) {\n        newData = true;\n        bufferNum = p->hasNewInputData_;\n        p->hasNewInputData_--;\n      }\n      smileMutexUnlock(p->newDataMutex_);\n      if (newData) {\n        //SMILE_IMSG(4, \"  got buffer (%i)\", bufferNum);\n        // update inBuffer and index\n        // flag buffer for enqueue (after data has been copied!)\n        p->doNotEnqueue_ = false;\n        p->currentInputIndex = 0;\n        inBuffer = p->inputBuffer[p->currentInputBuffer];\n      } else {\n        SMILE_IMSG(4, \"  got timeout\");\n        // timeout reading from device or no more data\n        break;\n      }\n    }\n    buffer[nSamplesRead] = inBuffer[p->currentInputIndex++];\n  }\n  // if at the end of the above loop we have copied all data from the buffer\n  // enqueue right away, to allow audio recording to continue\n  // in case the copying of the data to the datamemory in the thread takes\n  // longer than expected (i.e. thread gets interrupted by scheduler, etc.)\n  if (p->currentInputIndex >= nSamples) {\n    if (!p->doNotEnqueue_) {\n      (*p->recorderBufferQueue)->Enqueue(p->recorderBufferQueue,\n          p->inputBuffer[p->currentInputBuffer], nSamples * sizeof(int16_t));\n      p->currentInputBuffer = (p->currentInputBuffer + 1) % NUM_RECORDING_BUFFERS;\n    }\n    p->doNotEnqueue_ = true;\n  }\n  //if (p->outchannels == 0)  // ???\n    p->time += (double)nSamplesRead / (double)(p->sr * p->inchannels);\n  //SMILE_IMSG(4, \"audioIn: # %i\", nSamplesRead);\n  return nSamplesRead;\n}\n\n\n// puts a buffer of size samples to the device\nint cOpenslesSource::android_AudioOut(opensl_stream2 *p, float *buffer,int size){\n\n  short *outBuffer;\n  int i, bufsamps = p->outBufSamples, index = p->currentOutputIndex;\n  if(p == NULL  || bufsamps ==  0)  return 0;\n  outBuffer = p->outputBuffer[p->currentOutputBuffer];\n\n  for(i=0; i < size; i++){\n    outBuffer[index++] = (short) (buffer[i]*CONV16BIT);\n    if (index >= p->outBufSamples) {\n      smileCondTimedWait(p->playerCondition_, 500000);  // TODO: set timeout according to audioBuffersize_sec\n      (*p->bqPlayerBufferQueue)->Enqueue(p->bqPlayerBufferQueue,\n           outBuffer,bufsamps*sizeof(short));\n      p->currentOutputBuffer = (p->currentOutputBuffer ?  0 : 1);\n      index = 0;\n      outBuffer = p->outputBuffer[p->currentOutputBuffer];\n    }\n  }\n  p->currentOutputIndex = index;\n  p->time += (double) size/(p->sr*p->outchannels);\n  return i;\n}\n\n\n//----------------------------------------------openSL specific code\n\n// creates the OpenSL ES audio engine\nSLresult openSLCreateEngine(opensl_stream2 *p) {\n  SLresult result;\n  // create engine\n  result = slCreateEngine(&(p->engineObject), 0, NULL, 0, NULL, NULL);\n  if (result != SL_RESULT_SUCCESS) {\n    return result;\n  }\n  // realize the engine\n  result = (*p->engineObject)->Realize(p->engineObject, SL_BOOLEAN_FALSE);\n  if (result != SL_RESULT_SUCCESS) {\n    return result;\n  }\n  // get the engine interface, which is needed in order to create other objects\n  result = (*p->engineObject)->GetInterface(p->engineObject, SL_IID_ENGINE, &(p->engineEngine));\n  return result;\n}\n\n// opens the OpenSL ES device for output\nSLresult openSLPlayOpen(opensl_stream2 *p) {\n  SLresult result;\n  SLuint32 sr = p->sr;\n  SLuint32 channels = p->outchannels;\n  if (channels){\n    // configure audio source\n    SLDataLocator_AndroidSimpleBufferQueue loc_bufq = {SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, 2};\n    switch(sr){\n    case 8000:\n      sr = SL_SAMPLINGRATE_8;\n      break;\n    case 11025:\n      sr = SL_SAMPLINGRATE_11_025;\n      break;\n    case 16000:\n      sr = SL_SAMPLINGRATE_16;\n      break;\n    case 22050:\n      sr = SL_SAMPLINGRATE_22_05;\n      break;\n    case 24000:\n      sr = SL_SAMPLINGRATE_24;\n      break;\n    case 32000:\n      sr = SL_SAMPLINGRATE_32;\n      break;\n    case 44100:\n      sr = SL_SAMPLINGRATE_44_1;\n      break;\n    case 48000:\n      sr = SL_SAMPLINGRATE_48;\n      break;\n    case 64000:\n      sr = SL_SAMPLINGRATE_64;\n      break;\n    case 88200:\n      sr = SL_SAMPLINGRATE_88_2;\n      break;\n    case 96000:\n      sr = SL_SAMPLINGRATE_96;\n      break;\n    case 192000:\n      sr = SL_SAMPLINGRATE_192;\n      break;\n    default:\n      return -1;\n    }\n    const SLInterfaceID ids[] = {SL_IID_VOLUME};\n    const SLboolean req[] = {SL_BOOLEAN_FALSE};\n    result = (*p->engineEngine)->CreateOutputMix(p->engineEngine,\n        &(p->outputMixObject), 1, ids, req);\n    // realize the output mix\n    result = (*p->outputMixObject)->Realize(p->outputMixObject, SL_BOOLEAN_FALSE);\n    int speakers = SL_SPEAKER_FRONT_CENTER;\n    if(channels > 1)\n      speakers = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;\n    SLDataFormat_PCM format_pcm = {SL_DATAFORMAT_PCM,channels, sr,\n\t\t\t\t   SL_PCMSAMPLEFORMAT_FIXED_16, SL_PCMSAMPLEFORMAT_FIXED_16,\n\t\t\t\t   speakers, SL_BYTEORDER_LITTLEENDIAN};\n    SLDataSource audioSrc = {&loc_bufq, &format_pcm};\n    // configure audio sink\n    SLDataLocator_OutputMix loc_outmix = {SL_DATALOCATOR_OUTPUTMIX, p->outputMixObject};\n    SLDataSink audioSnk = {&loc_outmix, NULL};\n    // create audio player\n    const SLInterfaceID ids1[] = {SL_IID_ANDROIDSIMPLEBUFFERQUEUE};\n    const SLboolean req1[] = {SL_BOOLEAN_TRUE};\n    result = (*p->engineEngine)->CreateAudioPlayer(p->engineEngine, &(p->bqPlayerObject),\n        &audioSrc, &audioSnk, 1, ids1, req1);\n    if(result != SL_RESULT_SUCCESS) goto end_openaudio;\n    // realize the player\n    result = (*p->bqPlayerObject)->Realize(p->bqPlayerObject, SL_BOOLEAN_FALSE);\n    if(result != SL_RESULT_SUCCESS) goto end_openaudio;\n    // get the play interface\n    result = (*p->bqPlayerObject)->GetInterface(p->bqPlayerObject, SL_IID_PLAY, &(p->bqPlayerPlay));\n    if(result != SL_RESULT_SUCCESS) goto end_openaudio;\n    // get the buffer queue interface\n    result = (*p->bqPlayerObject)->GetInterface(p->bqPlayerObject, SL_IID_ANDROIDSIMPLEBUFFERQUEUE,\n\t\t\t\t\t\t&(p->bqPlayerBufferQueue));\n    if(result != SL_RESULT_SUCCESS) goto end_openaudio;\n    // register callback on the buffer queue\n    result = (*p->bqPlayerBufferQueue)->RegisterCallback(p->bqPlayerBufferQueue, bqPlayerCallback, p);\n    if(result != SL_RESULT_SUCCESS) goto end_openaudio;\n    // set the player's state to playing\n    result = (*p->bqPlayerPlay)->SetPlayState(p->bqPlayerPlay, SL_PLAYSTATE_PLAYING);\n    SMILE_MSG(3, \"playback: set state = playing\");\n  end_openaudio:\n    return result;\n  }\n  return SL_RESULT_SUCCESS;\n}\n\n// Open the OpenSL ES device for input\nSLresult openSLRecOpen(opensl_stream2 *p) {\n  SLresult result;\n  SLuint32 sr = p->sr;\n  SLuint32 channels = p->inchannels;\n  SMILE_MSG(3, \"recording: slrecopen\");\n  if (channels){\n    switch (sr){\n    case 8000:\n      sr = SL_SAMPLINGRATE_8;\n      break;\n    case 11025:\n      sr = SL_SAMPLINGRATE_11_025;\n      break;\n    case 16000:\n      sr = SL_SAMPLINGRATE_16;\n      break;\n    case 22050:\n      sr = SL_SAMPLINGRATE_22_05;\n      break;\n    case 24000:\n      sr = SL_SAMPLINGRATE_24;\n      break;\n    case 32000:\n      sr = SL_SAMPLINGRATE_32;\n      break;\n    case 44100:\n      sr = SL_SAMPLINGRATE_44_1;\n      break;\n    case 48000:\n      sr = SL_SAMPLINGRATE_48;\n      break;\n    case 64000:\n      sr = SL_SAMPLINGRATE_64;\n      break;\n    case 88200:\n      sr = SL_SAMPLINGRATE_88_2;\n      break;\n    case 96000:\n      sr = SL_SAMPLINGRATE_96;\n      break;\n    case 192000:\n      sr = SL_SAMPLINGRATE_192;\n      break;\n    default:\n      return -1;\n    }\n    SMILE_MSG(3, \"recording: sr constant = %i\", sr);\n    // configure audio source\n    SLDataLocator_IODevice loc_dev = {SL_DATALOCATOR_IODEVICE, SL_IODEVICE_AUDIOINPUT,\n\t\t\t\t      SL_DEFAULTDEVICEID_AUDIOINPUT, NULL};\n    SLDataSource audioSrc = {&loc_dev, NULL};\n    // configure audio sink\n    int speakers = SL_SPEAKER_FRONT_CENTER;\n    if(channels > 1)\n      speakers = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;\n    SLDataLocator_AndroidSimpleBufferQueue loc_bq = {SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, 2};\n    SLDataFormat_PCM format_pcm = {SL_DATAFORMAT_PCM, channels, sr,\n\t\t\t\t   SL_PCMSAMPLEFORMAT_FIXED_16, SL_PCMSAMPLEFORMAT_FIXED_16,\n\t\t\t\t   speakers, SL_BYTEORDER_LITTLEENDIAN};\n    SLDataSink audioSnk = {&loc_bq, &format_pcm};\n    // create audio recorder\n    // (requires the RECORD_AUDIO permission)\n    const SLInterfaceID id[1] = {SL_IID_ANDROIDSIMPLEBUFFERQUEUE};\n    const SLboolean req[1] = {SL_BOOLEAN_TRUE};\n    result = (*p->engineEngine)->CreateAudioRecorder(p->engineEngine, &(p->recorderObject),\n        &audioSrc, &audioSnk, 1, id, req);\n    if (SL_RESULT_SUCCESS != result) goto end_recopen;\n    // realize the audio recorder\n    result = (*p->recorderObject)->Realize(p->recorderObject, SL_BOOLEAN_FALSE);\n    if (SL_RESULT_SUCCESS != result) goto end_recopen;\n    // get the record interface\n    result = (*p->recorderObject)->GetInterface(p->recorderObject, SL_IID_RECORD, &(p->recorderRecord));\n    if (SL_RESULT_SUCCESS != result) goto end_recopen;\n    // get the buffer queue interface\n    result = (*p->recorderObject)->GetInterface(p->recorderObject, SL_IID_ANDROIDSIMPLEBUFFERQUEUE,\n\t\t\t\t\t\t&(p->recorderBufferQueue));\n    if (SL_RESULT_SUCCESS != result) goto end_recopen;\n    SMILE_MSG(3, \"recording: got interface\");\n    // register callback on the buffer queue\n    result = (*p->recorderBufferQueue)->RegisterCallback(p->recorderBufferQueue,\n        bqRecorderCallback, p);\n    if (SL_RESULT_SUCCESS != result) goto end_recopen;\n    SMILE_MSG(3, \"recording: registered callback\");\n\n  end_recopen:\n    return result;\n  }\n  return SL_RESULT_SUCCESS;\n}\n\nSLresult openSLstopRecording(opensl_stream2 *p) {\n  SLresult result;\n  if (p->recorderRecord != NULL) {\n    // in case already recording, stop recording and clear buffer queue\n    result = (*p->recorderRecord)->SetRecordState(p->recorderRecord, SL_RECORDSTATE_STOPPED);\n    if (result != SL_RESULT_SUCCESS) {\n      SMILE_ERR(3, \"openSL: failed to set recorder state to stopped.\");\n      return result;\n    }\n    //  (void)result;\n    result = (*p->recorderBufferQueue)->Clear(p->recorderBufferQueue);\n    if (result != SL_RESULT_SUCCESS) {\n      SMILE_ERR(3, \"openSL: failed to clear recorder buffer queue.\");\n      return result;\n    }\n    SMILE_MSG(3, \"openSL: recording: set state = stopped, success\");\n  } else {\n    SMILE_ERR(1, \"openSL: no recorder present, cannot stop recording\");\n    return -1;\n  }\n  return SL_RESULT_SUCCESS;\n}\n\nSLresult openSLstartRecording(opensl_stream2 *p) {\n  SLresult result;\n  if (p->recorderRecord != NULL) {\n    // in case already recording, stop recording and clear buffer queue\n    result = (*p->recorderRecord)->SetRecordState(p->recorderRecord, SL_RECORDSTATE_STOPPED);\n    if (result != SL_RESULT_SUCCESS) {\n      SMILE_ERR(3, \"openSL: failed to set recorder state to stopped.\");\n      return result;\n    }\n    //  (void)result;\n    result = (*p->recorderBufferQueue)->Clear(p->recorderBufferQueue);\n    if (result != SL_RESULT_SUCCESS) {\n      SMILE_ERR(3, \"openSL: failed to clear recorder buffer queue.\");\n      return result;\n    }\n    // for streaming recording, we enqueue at least 2 empty buffers to start things off)\n    for (int i = 0; i < NUM_RECORDING_BUFFERS /* - 1*/; ++i) {\n      result = (*p->recorderBufferQueue)->Enqueue(p->recorderBufferQueue,\n          p->inputBuffer[i], p->inBufSamples * sizeof(int16_t));\n      // the most likely other result is SL_RESULT_BUFFER_INSUFFICIENT,\n      // which for this code example would indicate a programming error\n      if (result != SL_RESULT_SUCCESS) {\n        SMILE_ERR(3, \"openSL: failed to enqueue audio buffer # %i for streaming recording.\", i);\n        return result;\n      }\n    }\n    // the current one will be the first to be enqueued, before we wait for the first buffer to be filled\n    // in audioIn. This is why we don't enqueue it here (NUM_RECORDING_BUFFERS - 1 in above loop).\n//    p->currentInputBuffer = NUM_RECORDING_BUFFERS - 1;\n    p->currentInputBuffer = 0;\n    p->doNotEnqueue_ = true;\n    // start recording\n    result = (*p->recorderRecord)->SetRecordState(p->recorderRecord, SL_RECORDSTATE_RECORDING);\n    if (result != SL_RESULT_SUCCESS) {\n      SMILE_ERR(3, \"openSL: failed to set recorder state to started.\");\n      return result;\n    }\n    SMILE_MSG(3, \"openSL: recording: set state = recording, success\");\n  } else {\n    SMILE_ERR(1, \"openSL: no recorder present, cannot start recording\");\n    return -1;\n  }\n  return SL_RESULT_SUCCESS;\n}\n\n// close the OpenSL IO and destroy the audio engine\nvoid openSLDestroyEngine(opensl_stream2 *p) {\n  // destroy buffer queue audio player object, and invalidate all associated interfaces\n  if (p->bqPlayerObject != NULL) {\n    (*p->bqPlayerObject)->Destroy(p->bqPlayerObject);\n    p->bqPlayerObject = NULL;\n    p->bqPlayerPlay = NULL;\n    p->bqPlayerBufferQueue = NULL;\n    p->bqPlayerEffectSend = NULL;\n  }\n  // destroy audio recorder object, and invalidate all associated interfaces\n  if (p->recorderObject != NULL) {\n    (*p->recorderObject)->Destroy(p->recorderObject);\n    p->recorderObject = NULL;\n    p->recorderRecord = NULL;\n    p->recorderBufferQueue = NULL;\n  }\n  // destroy output mix object, and invalidate all associated interfaces\n  if (p->outputMixObject != NULL) {\n    (*p->outputMixObject)->Destroy(p->outputMixObject);\n    p->outputMixObject = NULL;\n  }\n  // destroy engine object, and invalidate all associated interfaces\n  if (p->engineObject != NULL) {\n    (*p->engineObject)->Destroy(p->engineObject);\n    p->engineObject = NULL;\n    p->engineEngine = NULL;\n  }\n}\n\n\n// TODO: the callbacks should not be class members, because they cannot access class members due to missing this pointer\n// this callback handler is called every time a buffer finishes recording\nvoid bqRecorderCallback(SLAndroidSimpleBufferQueueItf bq, void *context) {\n  opensl_stream2 *p = (opensl_stream2 *) context;\n  //SMILE_MSG(3, \"opensles: recorder callback triggered\");\n  smileMutexLock(p->newDataMutex_);\n  p->hasNewInputData_++;\n  smileMutexUnlock(p->newDataMutex_);\n  smileCondSignal(p->recorderCondition_);\n}\n\n// TODO: the callbacks should not be class members, because they cannot access class members due to missing this pointer\n// this callback handler is called every time a buffer finishes playing\nvoid bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context) {\n  opensl_stream2 *p = (opensl_stream2 *) context;\n  SMILE_MSG(3, \"opensles: player callback triggered\");\n  smileCondSignal(p->playerCondition_);\n}\n\n\n#endif // HAVE_OPENSLES\n#endif // !__STATIC_LINK\n#endif // __ANDROID__\n"
  },
  {
    "path": "src/classifiers/julius/juliusSink.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*\n * Some code in this file is taken from the Julius LVCSR engine, which is copyright by:\n *\n * Copyright (c) 1991-2007 Kawahara Lab., Kyoto University\n * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology\n * Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology\n * All rights reserved\n *\n * See the file JULIUS_LICENSE for more details\n *\n */\n\n\n#include <classifiers/julius/juliusSink.hpp>\n#define MODULE \"cJuliusSink\"\n\n#ifdef HAVE_JULIUSLIB\n\nSMILECOMPONENT_STATICS(cJuliusSink)\n\nSMILECOMPONENT_REGCOMP(cJuliusSink)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CJULIUSSINK;\n  sdescription = COMPONENT_DESCRIPTION_CJULIUSSINK;\n\n  // we inherit cDataSink configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSink\")\n\n    SMILECOMPONENT_IFNOTREGAGAIN_BEGIN\n    ct->makeMandatory(ct->setField(\"configfile\",\"Julius configfile to load (path is relative to smile executable)\",\"kws.cfg\"));\n    ct->setField(\"logfile\",\"Julius logfile (default=(null) : no log file)\",(const char*)NULL);\n    ct->setField(\"debug\",\"1 = show julius debug log output, 0 = don't show\",0);\n    ct->setField(\"preSil\",\"extra (silence) amount of data at beginning of turn to keep (in seconds)\",0.3);\n    ct->setField(\"postSil\",\"extra (silence) amount of data at end of turn to keep (in seconds)\",0.4);\n    ct->setField(\"nopass2\",\"1 = do not perform pass2 (you must also set the '-1pass' option in the julius config file!)\",0);\n    ct->setField(\"printResult\",\"print output packages to console (1/0=yes/no)\",1);\n\n    ct->setField(\"juliusResultRecp\",\"component(s) to send 'juliusResult' messages to (use , to separate multiple recepients), leave blank (NULL) to not send any messages. The 'juliusResult' message contains the full julius result package, which includes the full word string, alignments (if available) and the word scores as well as am and lm scores.\",(const char *) NULL);\n    ct->setField(\"kwsResultRecp\",\"component(s) to send 'asrKeywordOutput' messages to (use , to separate multiple recepients), leave blank (NULL) to not send any messages. The keyword result package only contains selected keywords (given in 'keywordList') from the full julius result package.\",(const char *) NULL);\n    ct->setField(\"keywordList\",\"name of text file to load keyword list from. The file must contain the keywords (all uppercase) sorted in alphabetical order, each keyword on a line.\",(const char*)NULL);\n    ct->setField(\"excludeWords\",\"array of strings (words) to exclude from result packages. Typically you would use this to exclude sentence start and end marks such as <s> or </s>. The default is an empty list, i.e. nothing will be excluded.\",(const char *)NULL,ARRAY_TYPE);\n\n    ct->setField(\"noTurns\",\"1 = don't use turn segmentation info, simply pass all available input data to julius (you can either do VAD with julius then, or use this feature in offline mode when you use presegmented turns) (0 = segment input based on cTurnDetector messages).\",0);\n    ct->setField(\"offlineMode\",\"1 = off-line evaluation mode (this changes the exit behaviour of the decoder; in online mode the decoder will always return 1 (busy) when decoding; in off-line mode it will return 0 if it is processing if not in the EOI processing loop. This option will also set maxTurnQue=0 (infinite).\",0);\n    ct->setField(\"maxTurnQue\",\"maximum number of speech turns to hold in que, set this to 0 (infinite) for offline evaluations, and 2 (or more) for online mode\",2);\n    ct->setField(\"decoderThreadPriority\",\"the thread priority of the decoder thread (currently only supported on windows), values -15 (idle) to 15 (real-time), while 0 is normal. This should be lower as or equal to the priority of the openSMILE main thread!\",0);\n\n  SMILECOMPONENT_IFNOTREGAGAIN_END\n\n    SMILECOMPONENT_MAKEINFO(cJuliusSink);\n}\n\nSMILECOMPONENT_CREATE(cJuliusSink)\n\n//-----\n\ncJuliusSink::cJuliusSink(const char *_name) :\ncDataSink(_name),\nconfigfile(NULL),\nlogfile(NULL),\nprintResult(0),\njuliusIsSetup(0), juliusIsRunning(0),\ndataFlag(0),\nturnEnd(0), turnStart(0), isTurn(0), endWait(-1),\nlag(0), nPre(0), nPost(0),\ncurVidx(0), vIdxStart(0), vIdxEnd(0), wst(0), writelen(0), juliusResultRecp(NULL), kwsResultRecp(NULL), period((FLOAT_DMEM)0.0),\nturnStartSmileTimeLast((FLOAT_DMEM)0.0), turnStartSmileTime((FLOAT_DMEM)0.0), turnStartSmileTimeCur((FLOAT_DMEM)0.0),\ndecoderThread(NULL), running(0),\nsendKwsResult(0), sendJuliusResult(0), numKw(0),\nkeywordList(NULL), keywords(NULL),\nexcludeWords(NULL), nExclude(0),\npurgeQue(0), midx(0)\n{\n  smileMutexCreate(terminatedMtx);\n  smileMutexCreate(dataFlgMtx);\n  smileCondCreate(tickCond);\n}\n\nvoid cJuliusSink::fetchConfig()\n{\n  cDataSink::fetchConfig();\n\n  configfile = getStr(\"configfile\");\n  SMILE_IDBG(2,\"ASR configfile to load = '%s'\",configfile);\n\n  logfile = getStr(\"logfile\");\n  if (logfile != NULL) { SMILE_IDBG(2,\"Julius logfile = '%s'\",logfile); }\n\n  keywordList = getStr(\"keywordList\");\n  if (keywordList != NULL) { SMILE_IDBG(2,\"keyword selection list to use = '%s'\",keywordList); }\n\n  juliusResultRecp = getStr(\"juliusResultRecp\");\n  SMILE_IDBG(2,\"juliusResultRecp = '%s'\",juliusResultRecp);\n  if (juliusResultRecp != NULL) sendJuliusResult = 1;\n\n  kwsResultRecp = getStr(\"kwsResultRecp\");\n  SMILE_IDBG(2,\"kwsResultRecp = '%s'\",kwsResultRecp);\n  if (kwsResultRecp != NULL) sendKwsResult = 1;\n\n  printResult = getInt(\"printResult\");\n  SMILE_IDBG(2,\"printResult = %i\",printResult);\n\n  nopass2 = getInt(\"nopass2\");\n  noTurns = getInt(\"noTurns\");\n  offlineMode = getInt(\"offlineMode\");\n  maxTurnQue = getInt(\"maxTurnQue\");\n  if (offlineMode) maxTurnQue = 0;\n\n  nExclude = getArraySize(\"excludeWords\");\n  if (nExclude>0) {\n    excludeWords = (const char**)calloc(1,sizeof(const char*)*nExclude);\n    int i;\n    for (i=0; i<nExclude; i++) { \n      excludeWords[i] = getStr_f(myvprint(\"excludeWords[%i]\",i)); \n      //SMILE_IDBG(2,\"excludeWords[%i] = '%s'\",i,excludeWords[i] );\n    }\n  }\n\n  decoderThreadPriority = getInt(\"decoderThreadPriority\");\n  if (decoderThreadPriority < -15) decoderThreadPriority = -15;\n  if (decoderThreadPriority > 15) decoderThreadPriority = 15;\n\n}\n\n\n/********************************** Julius callback loaders ***********************************/\n\nint external_fv_read_loader(void * cl, float *vec, int n) \n{\n  // retval -2 : error\n  // retval -3 : segment input\n  // retval -1 : end of input\n  if (cl!=NULL) return ((cJuliusSink*)cl)->getFv(vec, n);\n  else return -1; \n}\n\n\nstatic void result_pass2_loader(Recog *recog, void *dummy)\n{\n  cJuliusSink * cl = (cJuliusSink *)(recog->hook);\n  if (cl!=NULL) cl->cbResultPass2(recog, dummy);\n}\n\n\n\nstatic void status_pass1_begin_loader(Recog *recog, void *dummy)\n{\n  cJuliusSink * cl = (cJuliusSink *)(recog->hook);\n  if (cl!=NULL) cl->cbStatusPass1Begin(recog, dummy);\n}\n\nstatic void result_pass1_loader(Recog *recog, void *dummy)\n{\n  cJuliusSink * cl = (cJuliusSink *)(recog->hook);\n  if (cl!=NULL) cl->cbResultPass1(recog, dummy);\n}\n\nvoid result_pass1_current_loader(Recog *recog, void *dummy)\n{\n  cJuliusSink * cl = (cJuliusSink *)(recog->hook);\n  if (cl!=NULL) cl->cbResultPass1Current(recog, dummy);\n}\n\n\n\n/********************************** Julius output formatting functions ******************************/\n\nvoid cJuliusSink::juAlignPass1Keywords(RecogProcess *r, HTK_Param *param)\n{\n//  int n;\n  Sentence *s;\n  SentenceAlign *now;//, *prev;\n\n\n  s = &(r->result.pass1);\n  /* do forced alignment if needed */\n  if ((r->config->annotate.align_result_word_flag)&&(s->word_num>0)) {\n    //now = result_align_new();\n    //if (s->align == NULL) \n      now = result_align_new(); //else now = s->align;\n    word_align(s->word, s->word_num, param, now, r);\n    if (s->align == NULL) //result_align_free(s->align);\n      s->align = now;\n    else {\n      result_align_free(s->align);\n      s->align = now;\n    }\n//    else prev->next = now;\n//    prev = now;\n  }\n} \n\n/*\nvoid cJuliusSink::juPutHypoPhoneme(WORD_ID *seq, int n, WORD_INFO *winfo)\n{\n  int i,j;\n  WORD_ID w;\n  static char buf[MAX_HMMNAME_LEN];\n\n  if (seq != NULL) {\n    for (i=0;i<n;i++) {\n      if (i > 0) printf(\" |\");\n      w = seq[i];\n      for (j=0;j<winfo->wlen[w];j++) {\n        center_name(winfo->wseq[w][j]->name, buf);\n        printf(\" %s\", buf);\n      }\n    }\n  }\n  printf(\"\\n\");  \n}\n*/\n\nint cJuliusSink::excludeWord(const char *w) \n{\n  int i;\n  if (w==NULL) return 1;\n  for (i=0; i<nExclude; i++) {\n    //SMILE_IDBG(3,\"word='%s'   excludeWords[%i]='%s'\",w,i,excludeWords[i]);\n    if ((excludeWords[i] != NULL) && (!strcmp(w,excludeWords[i]))) return 1;\n  }\n  return 0;\n}\n\njuliusResult * cJuliusSink::fillJresult(Sentence *s, WORD_INFO *winfo, int numOfFrames)\n{\n  juliusResult * res = NULL;\n  static char buf[MAX_HMMNAME_LEN];\n  int i,wi;\n\n  if (s->word != NULL && s->word_num > 0) {\n    res = new juliusResult(s->word_num);\n    wi=0;\n    for (i=0;i<res->numW;i++) {\n      if (!excludeWord(winfo->woutput[s->word[wi]])) {\n\n        res->word[i] = strdup(winfo->woutput[s->word[wi]]);\n        if (s->align != NULL) {\n          res->start[i] = (float)(period * (double)(s->align->begin_frame[wi]));\n          res->end[i] = (float)(period * (double)(s->align->end_frame[wi]));\n        }\n        if (s->confidence != NULL) {\n          res->conf[i] = s->confidence[wi];\n          if (res->conf[i] <= 0.0) res->conf[i] = 0.2;\n        } else {\n          res->conf[i] = 0.2;\n        }\n\n        // allocate temporary phoneme string\n        int len = sizeof(char)* winfo->wlen[s->word[wi]] * MAX_PHONEME_STRLEN - 1;\n        char * ph = (char*)malloc(len+1);\n        char * phc = ph; *ph = 0; size_t ptr = 0; \n  /*      // copy phoneme sequence to string\n        for (j=0;j<winfo->wlen[s->word[wi]];j++) {\n          center_name(winfo->wseq[s->word[wi]][j]->name, buf);\n          strncpy(phc,buf,MIN((unsigned)(len-ptr),strlen(buf)));\n          size_t x = strlen(buf);\n          phc += x;\n          ptr += x;\n          if (len-ptr > 0) { *(phc++) = ' '; ptr++; }\n          if (len-ptr >= 0) *(phc) = 0;\n          //printf(\"strlen(buf) = %i\\n\",strlen(buf));\n        }*/\n        // save phoneme string for word i\n        res->phstr[i] = ph;\n      } else { \n        i--; \n        res->numW--; \n      }\n      wi++;\n    }\n    res->duration = (double)numOfFrames * period;\n    res->amScore = s->score_am;\n    res->lmScore = s->score_lm;\n    res->score = s->score;\n  }\n  return res;\n}\n\nint cJuliusSink::makeKwIndex(const char *kw)\n{\n//printf(\">>-<< word : '%s' \\n\",kw);\n  int idx= -1;\n  int lt = ((int)kw[0]-(int)'A');\n//printf(\">>-<< lt : %i \\n\",lt);\n  if ((lt >= 0)&&(lt<26)) {\n    idx = lt * 27;\n    if (kw[1] != 0) {\n      int lt2 = ((int)kw[1]-(int)'A');\n//printf(\">>-<< lt2 : %i \\n\",lt2);\n      if ((lt2 >= 0)&&(lt2<26)) {\n        idx += lt2 + 1;\n      }\n    }\n  }\n//printf(\">>-<< idx : %i \\n\",idx);\n  return idx;\n}\n\nvoid cJuliusSink::loadKeywordList()\n{\n  // load keyword list\n  if (keywordList != NULL) {\n    FILE *kwl = fopen(keywordList,\"r\");\n    if (kwl != NULL) {\n      char *line=NULL; size_t len=0; size_t r=-1;\n      r = smile_getline(&line, &len, kwl);\n      if ((r != (size_t)-1)&&(line!=NULL)) {\n        char *tmp=NULL;\n        numKw = strtol(line,&tmp,10);\n        if ((tmp == NULL)&&(*tmp == 0)) {\n          SMILE_IERR(1,\"expected the number of keywords in keyword list file on the first line in the keyword list file '%s'. The first line of the file must be a number, we found the following: '%s' (make sure to remove any whitespaces from the line, so it contains only a digits).\",keywordList,line);\n          numKw = 0;\n        }\n      }\n      if (numKw > 0) { \n        keywords = (char**)malloc(sizeof(char *)*numKw);\n        long kwNum = 0;\n        do {      \n          r = smile_getline(&line, &len, kwl);\n          char *tmp = line;\n          if (tmp != NULL) {\n            // remove newline:\n            size_t x = strlen(tmp);\n            if (tmp[x-1] == '\\n') { tmp[x-1] = 0; x--; }\n            if (tmp[x-1] == '\\r') { tmp[x-1] = 0; x--; }\n            // space removal code:\n            while ((*tmp==' ')||(*tmp=='\\t')) { tmp++; x--; }\n            while ( (x>0)&& ((*(tmp+x-1) == ' ')||(*(tmp+x-1) == '\\t')) ) { *(tmp+x-1)=0; x--; }\n            if (x>0) { // add keyword:\n              keywords[kwNum] = strdup(tmp);\n              kwNum++;\n            }\n          }\n        } while ((r != (size_t)-1) && (kwNum<numKw)); \n        SMILE_IMSG(3,\"loaded %i of %i expected keywords from '%s'.\",kwNum,numKw,keywordList);\n      }\n      fclose(kwl);\n      if (line != NULL) free(line);\n    } else {\n      SMILE_IERR(1,\"cannot open keyword file '%s', check the filename and the file permissions!\",keywordList);\n    }\n\n    // create index for first two letters to speed up search\n    int i; char lastw[2]; lastw[0] = 'A'; lastw[1] = 0; int lastIdx = -1;\n    for (i=0; i<26*27; i++) { kwIndexStart[i] = -1; }\n    for (i=0; i<26*27; i++) { kwIndexEnd[i] = -1; }\n    \n    for (i=0; i<numKw; i++) {\n      if (keywords[i][0] != 0) {\n        if ((keywords[i][0] != lastw[0])||(keywords[i][1] != lastw[1])) { \n          if (lastIdx >= 0) {\n            kwIndexEnd[ lastIdx ] = i;\n          }\n          int idx = makeKwIndex(keywords[i]);\n          if ((idx >= 0)&&(idx<27*26)) {\n            kwIndexStart[ idx ] = i;\n            lastIdx = idx;\n          }\n          lastw[0] = keywords[i][0]; \n          lastw[1] = keywords[i][1];\n        }\n      }\n    }\n\n  }\n}\n\nint cJuliusSink::isKeyword(const char *word)\n{\n  int iskw = 0;\n  if ((word != NULL)&&(word[0] != 0)) {\n    int i;\n    int idx = makeKwIndex(word);\n    int s=0, e=numKw; // the word index in the keyword list\n    if ((idx >= 0)&&(idx<27*26)) { \n      s = kwIndexStart[idx]; \n      e = kwIndexEnd[idx];\n      //printf(\"ISKWW: w='%s' idx=%i s=%i  e=%i\\n\",word,idx,s,e);\n      if (s>=0) {\n        for (i=s; i<e; i++) {\n          //printf(\"  ISKWW: kw[%i]='%s' idx=%i  s=%i  e=%i\\n\",i,keywords[i],idx,s,e);\n          if (!strcmp(word,keywords[i])) { iskw = 1; break; }\n        }\n      }\n    }\n  }\n  return iskw;\n}\n\n\n// return value: number of keywords\nint cJuliusSink::tagKeywords(juliusResult *r)\n{\n  int nkw = 0;\n  if (r==NULL) return 0;\n  if ((keywordList != NULL)&&(keywords != NULL)) {\n    int i; \n    for (i=0; i<r->numW; i++) {\n      if (isKeyword(r->word[i])) {\n        r->wordFlag[i] |= JULIUSRESULT_FLAG_KEYWORD;\n        nkw++;\n      }\n    }\n  }\n  return nkw;\n}\n\n// you must call tagKeywords before calling this function\n// this function removes all non keywords, and updates r->numW\n// all unused word/phoneme strings are freed\nvoid cJuliusSink::keywordFilter(juliusResult *r)\n{\n  if (keywordList != NULL) {\n    int i; int kwc = 0;\n    for (i=0; i<r->numW; i++) {\n      if (r->wordFlag[i] & JULIUSRESULT_FLAG_KEYWORD) {\n        if (kwc != i) { // copy to left...\n          r->conf[kwc] = r->conf[i];\n          r->start[kwc] = r->start[i];\n          r->end[kwc] = r->end[i];\n          r->wordFlag[kwc] = r->wordFlag[i];\n\n          if (r->word[kwc] != NULL) free(r->word[kwc]);\n          r->word[kwc] = r->word[i]; r->word[i] = NULL;\n          if (r->phstr[kwc] != NULL) free(r->phstr[kwc]);\n          r->phstr[kwc] = r->phstr[i]; r->phstr[i] = NULL;\n        }\n        kwc++;\n      }\n    }\n    for (i=kwc; i<r->numW; i++) {\n      if (r->word[i] != NULL) free(r->word[i]);\n      r->word[i] = NULL;\n      if (r->phstr[i] != NULL) free(r->phstr[i]);\n      r->phstr[i] = NULL;\n    }\n    r->numW = kwc;\n  }\n}\n\n\n/************************************ Callback handlers ************************************************/\n\n\nvoid cJuliusSink::cbStatusPass1Begin(Recog *recog, void *dummy)\n{\n  if (!recog->jconf->decodeopt.realtime_flag) {\n    VERMES(\"### Recognition: 1st pass (LR beam)\\n\");\n  }\n  wst = 0;\n}\n\n\nvoid cJuliusSink::cbResultPass1Current(Recog *recog, void *dummy)\n{\n  RecogProcess *r;\n  r=recog->process_list;\n  if (! r->live) return;\n  if (! r->have_interim) return;\n  Sentence *s = &(r->result.pass1);\n\n  if ((s->word_num>0)&&(!isAbort())) {\n    //juAlignPass1Keywords(r, r->am->mfcc->param);\n\n    // this call creates a new class instance which will be freed after sending the message\n    // since the message can be sent to multiple receipients, the receivers may not free the object!\n    juliusResult *jr = fillJresult(s, r->lm->winfo, r->result.num_frame);\n    if (jr == NULL) return;\n\n    tagKeywords(jr);\n\n    //create smile message:\n    if (juliusResultRecp != NULL) {\n      cComponentMessage msg(\"juliusResult\");\n      msg.intData[0] = 0; // pass: 0=current, 1=pass1, 2=pass2\n      msg.custData = jr;\n      msg.userTime1 = turnStartSmileTimeCur;\n      msg.userTime2 = turnStartSmileTimeCur + ((double)(jr->duration));\n      sendComponentMessage( juliusResultRecp, &msg );\n      SMILE_IDBG(3,\"sending 'juliusResult' message to '%s'\",juliusResultRecp);\n    }\n\n    //output content of r:\n    if (printResult) {\n      int kc = 0;\n      printf(\"--- current hypothesis:  \");\n      for (kc=0;kc<(jr->numW);kc++) {\n        if (jr->wordFlag[kc] & JULIUSRESULT_FLAG_KEYWORD) {\n          printf(\"!%s! \",jr->word[kc]);\n        } else {\n          printf(\"%s \",jr->word[kc]);\n        }\n      }\n      printf(\"\\n\"); fflush(stdout);\n    }\n    if (kwsResultRecp != NULL) {\n      // filter keywords based on previous keyword 'tagging':\n      //keywordFilter(jr);\n\n      cComponentMessage msg(\"asrKeywordOutput\");\n      msg.intData[0] = 0; // pass: 0=current, 1=pass1, 2=pass2\n      msg.custData = jr;\n      msg.userTime1 = turnStartSmileTimeCur;\n      msg.userTime2 = turnStartSmileTimeCur + ((double)(jr->duration));\n      sendComponentMessage( kwsResultRecp, &msg );\n      SMILE_IDBG(3,\"sending 'asrKeywordOutput' message to '%s'\",kwsResultRecp);\n    }\n    delete jr;\n\n  }\n}\n\n\n\nvoid cJuliusSink::cbResultPass1(Recog *recog, void *dummy)\n{\n  int pass = 1;\n  RecogProcess *r;\n  r=recog->process_list;\n  if (! r->live) return;\n  if (r->have_interim) return ;\n  Sentence *s = &(r->result.pass1);\n  if (r->result.status < 0) return;\t/* search already failed  */\n  //if (r->config->successive.enabled) return; /* short pause segmentation */\n  //  int len;\n//  boolean have_progout = TRUE;\n//  if (isAbort()) return;\n\n  if (nopass2) {\n    lockMessageMemory();\n    if (tsq.empty()&&(!noTurns)) running = 0;  // TODO: check this condition &&(!noTurn) ...\n    unlockMessageMemory();\n  }\n\n  if ((s->word_num>0)&&(!isAbort())) {\n    juAlignPass1Keywords(r, r->am->mfcc->param);\n\n    // this call creates a new class instance which will be freed after sending the message\n    // since the message can be sent to multiple receipients, the receivers may not free the object!\n    juliusResult *jr = fillJresult(s, r->lm->winfo, r->result.num_frame);\n    tagKeywords(jr);\n\n    //create smile message:\n    if (juliusResultRecp != NULL) {\n      cComponentMessage msg(\"juliusResult\");\n      msg.intData[0] = pass; // pass: 0=current, 1=pass1, 2=pass2\n      msg.custData = jr;\n      msg.userTime1 = turnStartSmileTimeCur;\n      msg.userTime2 = turnStartSmileTimeCur + ((double)(jr->duration));\n      sendComponentMessage( juliusResultRecp, &msg );\n      SMILE_IDBG(3,\"sending 'juliusResult' message (pass %i) to '%s'\",pass,juliusResultRecp);\n    }\n\n\n//output content of r:\n    if (printResult) {\n      int kc = 0;\n\n      printf(\"--- PASS %i :  \",pass);\n      for (kc=0;kc<(jr->numW);kc++) {\n        if (jr->wordFlag[kc] & JULIUSRESULT_FLAG_KEYWORD) {\n          printf(\"!%s! \",jr->word[kc]);\n        } else {\n          printf(\"%s \",jr->word[kc]);\n        }\n      }\n      printf(\"\\n\"); fflush(stdout);\n\n      printf(\" confidence:  \");\n      for (kc=0;kc<(jr->numW);kc++) {\n        printf(\"%.3f \",jr->conf[kc]);\n      }\n      printf(\"\\n\"); fflush(stdout);\n\n      printf(\"   phonemes:  \",pass);\n      for (kc=0;kc<(jr->numW);kc++) {\n        if (jr->phstr[kc] != NULL) {\n          if (jr->wordFlag[kc] & JULIUSRESULT_FLAG_KEYWORD) {\n            printf(\"!%s! | \",jr->phstr[kc]);\n          } else {\n            printf(\"%s | \",jr->phstr[kc]);\n          }\n        }\n      }\n      printf(\"\\n\\n\"); fflush(stdout);\n\n    }\n\n    if (kwsResultRecp != NULL) {\n      // filter keywords based on previous keyword 'tagging':\n      //keywordFilter(jr);\n\n      cComponentMessage msg(\"asrKeywordOutput\");\n      msg.intData[0] = pass; // pass: 0=current, 1=pass1, 2=pass2\n      msg.custData = jr;\n      msg.userTime1 = turnStartSmileTimeCur;\n      msg.userTime2 = turnStartSmileTimeCur + ((double)(jr->duration));\n      sendComponentMessage( kwsResultRecp, &msg );\n      SMILE_IDBG(3,\"sending 'asrKeywordOutput' message (pass %i) to '%s'\",pass,kwsResultRecp);\n    }\n\n#if 0\n    if (debug2_flag) {\n    /* logical HMMs */\n      printf(\"pass1_best_HMMseq_logical:\");\n      for (i=0;i<num;i++) {\n        for (j=0;j<winfo->wlen[seq[i]];j++) {\n          printf(\" %s\", winfo->wseq[seq[i]][j]->name);\n        }\n        if (i < num-1) printf(\" |\");\n      }\n      printf(\"\\n\");\n    }\n#endif\n  } \n\n}\n\n\n\n\n\nvoid cJuliusSink::cbResultPass2(Recog *recog, void *dummy)\n{\n  int pass = 2;\n  RecogProcess *r;\n  r=recog->process_list;\n  if (! r->live) return;\n  //Sentence *s = &(r->result.pass1);\n  //if (r->result.status < 0) return;\t/* search already failed  */\n  //if (r->config->successive.enabled) return; /* short pause segmentation */\n  //  int len;\n//  boolean have_progout = TRUE;\n//  if (isAbort()) return;\n\n  lockMessageMemory();\n  if (tsq.empty()&&(!noTurns)) running = 0;  // TODO: check this condidition &&(!noTurn) ...\n  unlockMessageMemory();\n\n  if (printResult) {\n\n    if (r->result.status < 0) {\n      switch(r->result.status) {\n    case J_RESULT_STATUS_REJECT_POWER:\n      printf(\"<input rejected by power>\\n\");\n      break;\n    case J_RESULT_STATUS_TERMINATE:\n      printf(\"<input teminated by request>\\n\");\n      break;\n    case J_RESULT_STATUS_ONLY_SILENCE:\n      printf(\"<input rejected by decoder (silence input result)>\\n\");\n      break;\n    case J_RESULT_STATUS_REJECT_GMM:\n      printf(\"<input rejected by GMM>\\n\");\n      break;\n    case J_RESULT_STATUS_REJECT_SHORT:\n      printf(\"<input rejected by short input>\\n\");\n      break;\n    case J_RESULT_STATUS_FAIL:\n      printf(\"<search failed>\\n\");\n      break;\n      }\n      return;\n    }\n\n  }\n\n  /* get sentence */\n  //  num = r->result.sentnum;\n//assume just one sentence:\n  //num = 1;\n//consider just sentence with index n=0\n  //n = 0;\n  Sentence *s = &(r->result.sent[0]);\n\n\n  if ((s->word_num>0)&&(!isAbort())) {\n    //juAlignPass1Keywords(r, r->am->mfcc->param);\n\n    // this call creates a new class instance which will be freed after sending the message\n    // since the message can be sent to multiple receipients, the receivers may not free the object!\n    juliusResult *jr = fillJresult(s, r->lm->winfo, r->result.num_frame);\n    tagKeywords(jr);\n\n    //create smile message:\n    if (juliusResultRecp != NULL) {\n      cComponentMessage msg(\"juliusResult\");\n      msg.intData[0] = pass; // pass: 0=current, 1=pass1, 2=pass2\n      msg.custData = jr;\n      msg.userTime1 = turnStartSmileTimeCur;\n      msg.userTime2 = turnStartSmileTimeCur + ((double)(jr->duration));\n      sendComponentMessage( juliusResultRecp, &msg );\n      SMILE_IDBG(3,\"sending 'juliusResult' message (pass %i) to '%s'\",pass,juliusResultRecp);\n    }\n\n    //output content of r:\n    if (printResult) {\n      int kc = 0;\n\n      printf(\"--- PASS %i :  \",pass);\n      for (kc=0;kc<(jr->numW);kc++) {\n        if (jr->wordFlag[kc] & JULIUSRESULT_FLAG_KEYWORD) {\n          printf(\"!%s! \",jr->word[kc]);\n        } else {\n          printf(\"%s \",jr->word[kc]);\n        }\n      }\n      printf(\"\\n\"); fflush(stdout);\n\n      printf(\" confidence:  \");\n      for (kc=0;kc<(jr->numW);kc++) {\n        printf(\"%.3f \",jr->conf[kc]);\n      }\n      printf(\"\\n\"); fflush(stdout);\n\n      printf(\"   phonemes:  \",pass);\n      for (kc=0;kc<(jr->numW);kc++) {\n        if (jr->phstr[kc] != NULL) {\n          if (jr->wordFlag[kc] & JULIUSRESULT_FLAG_KEYWORD) {\n            printf(\"!%s! | \",jr->phstr[kc]);\n          } else {\n            printf(\"%s | \",jr->phstr[kc]);\n          }\n        }\n      }\n      printf(\"\\n\\n\"); fflush(stdout);\n    }\n\n    if (kwsResultRecp != NULL) {\n      // filter keywords based on previous keyword 'tagging':\n      //keywordFilter(jr);\n\n      cComponentMessage msg(\"asrKeywordOutput\");\n      msg.intData[0] = pass; // pass: 0=current, 1=pass1, 2=pass2\n      msg.custData = jr;\n      msg.userTime1 = turnStartSmileTimeCur;\n      msg.userTime2 = turnStartSmileTimeCur + ((double)(jr->duration));\n      sendComponentMessage( kwsResultRecp, &msg );\n      SMILE_IDBG(3,\"sending 'asrKeywordOutput' message (pass %i) to '%s'\",pass,kwsResultRecp);\n    }\n\n  }\n\n\n\n//  int i, j;\n//  int len;\n//  char ec[5] = {0x1b, '[', '1', 'm', 0};\n\n/*  \n  if (verbose_flag) {\n    if (r->lmtype == LM_DFA) {\n      if (multigram_get_all_num(r->lm) > 1) {\n\t      printf(\"grammar%d: %d\\n\", n+1, s->gram_id);\n      }\n    }\n  }*/\n\n\n}\n\n\n\n\nvoid cJuliusSink::setupCallbacks(Recog *recog, void *data)\n{\n  //  callback_add(recog, CALLBACK_EVENT_PROCESS_ONLINE, status_process_online, data);\n  //  callback_add(recog, CALLBACK_EVENT_PROCESS_OFFLINE, status_process_offline, data);\n  //  callback_add(recog, CALLBACK_EVENT_SPEECH_READY, status_recready, data);\n  //  callback_add(recog, CALLBACK_EVENT_SPEECH_START, status_recstart, data);\n  //  callback_add(recog, CALLBACK_EVENT_SPEECH_STOP, status_recend, data);\n  //  callback_add(recog, CALLBACK_EVENT_RECOGNITION_BEGIN, status_recognition_begin, data);\n  //  callback_add(recog, CALLBACK_EVENT_RECOGNITION_END, status_recognition_end, data);\n  //  if (recog->jconf->decodeopt.segment) { /* short pause segmentation */\n  //    callback_add(recog, CALLBACK_EVENT_SEGMENT_BEGIN, status_segment_begin, data);\n  //    callback_add(recog, CALLBACK_EVENT_SEGMENT_END, status_segment_end, data);\n  //  }\n\n  callback_add(recog, CALLBACK_EVENT_PASS1_BEGIN, status_pass1_begin_loader, data); //sets wst=0\n\n  //  {\n  //    JCONF_SEARCH *s;\n  //    boolean ok_p;\n  //    ok_p = TRUE;\n  //    for(s=recog->jconf->search_root;s;s=s->next) {\n  //      if (s->output.progout_flag) ok_p = FALSE;\n  //    }\n  //    if (ok_p) {      \n  //      have_progout = FALSE;\n  //    } else {\n  //      have_progout = TRUE;\n  //    }\n  //  }\n  //  if (!recog->jconf->decodeopt.realtime_flag && verbose_flag && ! have_progout) {\n  //    callback_add(recog, CALLBACK_EVENT_PASS1_FRAME, frame_indicator, data);\n  //  }\n\n  callback_add(recog, CALLBACK_RESULT_PASS1_INTERIM, result_pass1_current_loader, data);\n  callback_add(recog, CALLBACK_RESULT_PASS1, result_pass1_loader, data);\n\n  //#ifdef WORD_GRAPH\n  //  callback_add(recog, CALLBACK_RESULT_PASS1_GRAPH, result_pass1_graph, data);\n  //#endif\n  //  callback_add(recog, CALLBACK_EVENT_PASS1_END, status_pass1_end, data);\n  //  callback_add(recog, CALLBACK_STATUS_PARAM, status_param, data);\n  //  callback_add(recog, CALLBACK_EVENT_PASS2_BEGIN, status_pass2_begin, data);\n  //  callback_add(recog, CALLBACK_EVENT_PASS2_END, status_pass2_end, data);\n\n  callback_add(recog, CALLBACK_RESULT, result_pass2_loader, data); // rejected, failed\n\n  //  callback_add(recog, CALLBACK_RESULT_GMM, result_gmm, data);\n  //  /* below will be called when \"-lattice\" is specified */\n  //  callback_add(recog, CALLBACK_RESULT_GRAPH, result_graph, data);\n  //  /* below will be called when \"-confnet\" is specified */\n  //  callback_add(recog, CALLBACK_RESULT_CONFNET, result_confnet, data);\n  //\n  //  //callback_add_adin(CALLBACK_ADIN_CAPTURED, levelmeter, data);\n}\n\n\nint cJuliusSink::setupJulius()\n{\n  try {\n\n    int argc=3;\n    char* argv[3] = {\"julius\",\"-C\",NULL};\n    if (configfile != NULL)\n      argv[2]=strdup(configfile);\n    else\n      argv[2]=strdup(\"kws.cfg\");\n\n    \n    /* create a configuration variables container */\n    jconf = j_jconf_new();\n    if (j_config_load_args(jconf, argc, argv) == -1) {\n      COMP_ERR(\"error parsing julius decoder options, this might be a bug. see juliusSink.cpp!\");\n      j_jconf_free(jconf);\n      free(argv[2]);\n      return 0;\n    }\n    free(argv[2]);\n\n    /* output system log to a file */\n    if (getInt(\"debug\") != 1) {\n      jlog_set_output(NULL);\n    }\n\n    /* here you can set/modify any parameter in the jconf before setup */\n    /* we add our external feature callback here */\n    jconf->input.type = INPUT_VECTOR;\n    jconf->input.speech_input = SP_EXTERN;\n    jconf->decodeopt.realtime_flag = TRUE; // ??? \n    jconf->ext.period = (float)(reader_->getLevelT());\n    jconf->ext.veclen = reader_->getLevelN();\n    jconf->ext.userptr = (void *)this;\n    jconf->ext.fv_read = external_fv_read_loader;\n\n    /* Fixate jconf parameters: it checks whether the jconf parameters\n    are suitable for recognition or not, and set some internal\n    parameters according to the values for recognition.  Modifying\n    a value in jconf after this function may be errorous.\n    */\n    if (j_jconf_finalize(jconf) == FALSE) {\n      SMILE_IERR(1,\"error finalising julius jconf in setupJulius()!\");\n      j_jconf_free(jconf);\n      return 0;\n    }\n\n    /* create a recognition instance */\n    recog = j_recog_new();\n    /* use user-definable data hook to set a pointer to our class instance */\n    recog->hook = (void *)this;\n    /* assign configuration to the instance */\n    recog->jconf = jconf;\n    /* load all files according to the configurations */\n    if (j_load_all(recog, jconf) == FALSE) {\n      SMILE_IERR(1, \"Error in loading model for Julius decoder\");\n      j_recog_free(recog);\n      return 0;\n    }\n\n    loadKeywordList();\n\n    /* checkout for recognition: build lexicon tree, allocate cache */\n    if (j_final_fusion(recog) == FALSE) {\n      fprintf(stderr, \"ERROR: Error while setup work area for recognition\\n\");\n      j_recog_free(recog);\n      if (logfile) fclose(fp);\n      return 0;\n    }\n\n    /* set-up the result callback hooks */\n    setupCallbacks(recog, NULL);\n\n    /* output system information to log */\n    j_recog_info(recog);\n\n    terminated = FALSE;\n  }\n  catch (int) { }\n\n  juliusIsSetup=1;\n\n  return 1;\n}\n\nint cJuliusSink::myFinaliseInstance()\n{\n  int ret = cDataSink::myFinaliseInstance();\n  if (ret==0) return 0;\n\n  // setup pre/post silence config:\n  float _preSil = (float)getDouble(\"preSil\");\n  float _postSil = (float)getDouble(\"postSil\");\n  double _T = reader_->getLevelT();\n  if (_T!=0.0) preSil = (int)ceil(_preSil/_T);\n  else preSil = (int)(_preSil);\n  if (_T!=0.0) postSil = (int)ceil(_postSil/_T);\n  else postSil = (int)(_postSil);\n\n  period = _T;\n\n  // setup julius, if not already set up (-> myFinaliseInstance could be called more than once...)\n  if (!juliusIsSetup) ret *= setupJulius();\n\n  return ret;\n}\n\n/* code to receive and process turnStart and turnEnd messages */\nint cJuliusSink::processComponentMessage( cComponentMessage *_msg )\n{\n  if (noTurns) return 0;\n\n  if (isMessageType(_msg,\"turnEnd\")) {\n    if (( teq.size() > (unsigned)maxTurnQue )&&(maxTurnQue > 0))  {\n      // note, if this happens, we must terminate the current turn!?\n      if (isTurn) {\n        purgeQue = 1;\n        SMILE_IMSG(3,\"forced end of asr processing due to turn start/end que overflow (id=%i) [maxQue = %i]\",teq.front().midx,maxTurnQue);\n      } else {\n        SMILE_IMSG(3,\"discarded whole last turn due to turn start/end que overflow (s_id=%i e_id=%i) [maxQue = %i]\",tsq.front().midx,teq.front().midx,maxTurnQue);\n        tsq.pop();\n      }\n      teq.pop();\n    }\n    TurnMsg tem;\n    tem.time = _msg->userTime1;\n    tem.vIdx = (long)(_msg->floatData[1]);\n    tem.isForcedTurnEnd = _msg->intData[1];\n    tem.midx = midx++;\n    teq.push(tem);\n    \n    /*turnEnd=1;\n    nPost = (long)(_msg->floatData[0]);\n    vIdxEnd = (long)(_msg->floatData[1]);\n    turnStartSmileTimeLast = turnStartSmileTime;*/\n    return 1;\n  }\n  if (isMessageType(_msg,\"turnStart\")) {\n    TurnMsg tsm;\n    tsm.time = _msg->userTime1;\n    tsm.vIdx = (long)(_msg->floatData[1]);\n    tsm.isForcedTurnEnd = 0;\n    tsm.midx = midx++;\n    tsq.push(tsm);\n    vIdxStart = tsm.vIdx;\n    /*\n    turnStart=1;\n    nPre = (long)(_msg->floatData[0]);\n    vIdxStart = (long)(_msg->floatData[1]);\n    turnStartSmileTime = _msg->userTime1;*/\n    return 1;\n  }\n  return 0;\n}\n\nint cJuliusSink::checkMessageQueue()\n{\n    int end = 0;\n\n    lockMessageMemory();\n\n    // TODO: check size of message queue in online mode:\n    // if messages at the front of the queue are too old, throw them away\n\n    // handle pre/post silence and turn detector interface\n    // turn start message received?\n    if (!tsq.empty() && !isTurn) {\n      SMILE_IDBG(4, \"turn start message retrieved from queue\");\n      // process old turnEnd message first...\n/*      if (!teq.empty() && teq.front().vIdx < tsq.front().vIdx && \n           ( (teq.front().vIdx <= curVidx + postSil) ||\n              (!teq.front().isForcedTurnEnd && teq.front().vIdx <= curVidx) )) {\nprintf(\"XXXX TEMrFO %i (cur=%i) [%i]\\n\",teq.front().vIdx,curVidx,teq.front().midx);\n        teq.pop();\n        end = 1;   // stop waiting\n        SMILE_IDBG(3,\"processed turn end message!\");  \n      }*/\n      running = 1;\n      turnStartSmileTimeCur = tsq.front().time;\n      vIdxStart = tsq.front().vIdx;\n      curVidx = tsq.front().vIdx - preSil;\n      isTurn = 1; // begin decoding\n//printf(\"XXXX TSMr %i (cur=%i) [%i] (%s)\\n\",vIdxStart,curVidx,tsq.front().midx,getInstName());\n      SMILE_IMSG(3,\"processed turn start message! (midx=%i)\",tsq.front().midx); \n      tsq.pop();\n      \n    }\n    // turn end message received?\n    if (!teq.empty() || purgeQue) { \n      SMILE_IDBG(4, \"turn end message retrieved from queue!\"); \n      // end of turn reached?\n      // if turn end is \"forced\" (end of input), then don't wait for silence at turn end\n      // - otherwise we will wait forever ...\n//printf(\"XXXX TEMx %i (cur=%i) [%i]\\n\",teq.front().vIdx,curVidx,teq.front().isForcedTurnEnd);\n      if (( (!teq.front().isForcedTurnEnd) && curVidx >= teq.front().vIdx + postSil) || \n          ( (teq.front().isForcedTurnEnd) && curVidx >= teq.front().vIdx ) || purgeQue)\n      { \n//printf(\"XXXX TEMr %i (cur=%i) [%i] (%s)\\n\",teq.front().vIdx,curVidx,teq.front().midx,getInstName());\n        isTurn = 0; \n        end=1; \n        SMILE_IMSG(3,\"turn end reached! purgeQue=%i (midx=%i)\",purgeQue,teq.front().midx);  \n        if (!purgeQue) teq.pop();\n        purgeQue = 0;\n      }\n      // if no frames have been written...\n      /*if (curVidx == vIdxStart) { \n        SMILE_IWRN(2,\"turn (vIdx %i - vIdx %i) has 0 frames (curVidx = %i)!\",vIdxStart,vIdxEnd,curVidx);\n        turnEnd=0; isTurn=0;\n      }*/\n    }\n//printf(\"XXX isTurn=%i\\n\",isTurn);\n    unlockMessageMemory();\n\n    return end;\n}\n\n\n// this is called from julius decoder thread... \nint cJuliusSink::getFv(float *vec, int n)\n{ \n  int ret=0;\n\n  smileMutexLock(dataFlgMtx);\n\n  if (terminated) { \n    smileMutexUnlock(dataFlgMtx);  \n    recog->process_want_terminate = TRUE;\n    return -1; \n  }  \n\n  // we should wait for main thread to provide data, then set a flag that data was read..\n  //SMILE_IDBG(4,\"yes... julius requests features from us (n=%i)!\",n);\n\n  // wait for turn start\n  int end=0;\n  if (!noTurns) {\n    // Here we have to use a do loop, because otherwise turn end messages\n    // will never be detected.\n    do {\n\n      end = checkMessageQueue();\n      if (end) ret = -3;\n\n      if (!isTurn && !end) {\n        smileCondWaitWMtx( tickCond, dataFlgMtx ); // wait one smile tick for things to change\n      }\n\n      if (terminated) { \n        smileMutexUnlock(dataFlgMtx);  \n        recog->process_want_terminate = TRUE;\n        return -1; \n      }  \n\n    } while ((!isTurn)&&(!end));\n  } else { \n    // if noTurn option == 1, we always set isTurn to true (1)\n    isTurn = 1; \n  }\n\n  if (isTurn && !end) {\n    int result=0;\n    curVec = NULL;\n    while (curVec == NULL)  {\n      curVec = reader_->getFrame(curVidx, -1, 0, &result);\n      // check if curVidx is behind ringbuffer storage space!!\n      if (result & DMRES_OORleft) {\n        long tmp = reader_->getMinR()+10;\n        if (tmp > curVidx) {\n          SMILE_IWRN(2,\"ASR processing tried to get feature data behind beginning of ringbuffer, which is no more available! Skipping a few frames to catch up... (%i) : %i -> %i\",tmp-curVidx, curVidx, tmp);\n          curVidx = tmp;\n        }\n      }\n      if (curVec == NULL) { \n        if (noTurns) {\n          if (isEOI()) { // TODO: test this condition!\n            ret = -3; break;\n          }\n        } else {\n          if (checkMessageQueue()) {\n            ret = -3;\n            break;\n          }\n        }\n        smileCondWaitWMtx( tickCond, dataFlgMtx );  \n\n        if (terminated) { \n          smileMutexUnlock(dataFlgMtx);  \n          recog->process_want_terminate = TRUE;\n          return -1; \n        }  \n      }\n      else {\n        curVidx++;\n      }\n    } // while (curVec == NULL) \n\n  }\n\n  //printf(\"turn: %f n=%i\\n\",curVec->dataF[curVec->N-1],curVec->N);\n  smileMutexUnlock(dataFlgMtx);\n\n  int i;\n  if (curVec != NULL) {\n    for (i=0; i<MIN( curVec->N, n ); i++) {\n      vec[i] = (float)(curVec->dataF[i]);\n    }\n  } else {\n    for (i=0; i<n; i++) {\n      vec[i] = 0.0;\n    }\n  }\n\n  return ret;\n}\n\n/**** Julius Decoder Thread *****/\n\nSMILE_THREAD_RETVAL juliusThreadRunner(void *_obj)\n{\n  cJuliusSink * __obj = (cJuliusSink *)_obj;\n  if (_obj != NULL) {\n    __obj->juliusDecoderThread();\n  }\n  SMILE_THREAD_RET;\n}\n\nvoid cJuliusSink::juliusDecoderThread()\n{\n  bool term;\n  smileMutexLock(terminatedMtx);\n  term = terminated;\n  smileMutexUnlock(terminatedMtx);\n\n  /* enter recongnition loop */\n  int ret = j_open_stream(recog, NULL);\n  switch(ret) {\n      case 0:\t\t\t/* succeeded */\n        break;\n      case -1:      \t\t/* error */\n        /* go on to next input */\n        //continue;\n      case -2:\t\t\t/* end of recognition process */\n        if (jconf->input.speech_input == SP_RAWFILE) {\n          //          fprintf(stderr, \"%d files processed\\n\", file_counter);\n        } else if (jconf->input.speech_input == SP_STDIN) {\n          fprintf(stderr, \"reached end of input on stdin\\n\");\n        } else {\n          fprintf(stderr, \"failed to begin input stream\\n\");\n        }\n        return;\n  }\n  \n  /* start recognizing the stream */\n  ret = j_recognize_stream(recog);\n}\n\nint cJuliusSink::startJuliusDecoder()\n{\n  juliusIsRunning = 1;\n  int result = (int)smileThreadCreate( decoderThread, juliusThreadRunner, this );\n  /* TODO: set thread priority ... */\n#ifdef __WINDOWS\n  SMILE_IMSG(3,\"current decoderThread priority = %i\",GetThreadPriority(decoderThread));\n  SetThreadPriority(decoderThread, decoderThreadPriority);\n  SMILE_IMSG(3,\"julius decoderThread priority now set to %i\",GetThreadPriority(decoderThread));\n#endif\n  return result;\n}\n\nint cJuliusSink::myTick(long long t)\n{\n  if (!juliusIsRunning) {\n    if (!startJuliusDecoder()) return 0;\n  }\n  smileCondSignal( tickCond );\n  reader_->catchupCurR();\n\n  // tick success?\n  lockMessageMemory();\n  int res = running;\n  unlockMessageMemory();\n\n  // TODO: smile request SLEEP... if asr is processing data, request a sleep if all other components retun 0 (i.e. if processing would end if we return 0...)\n\n  if ((getLastNrun() == 1) && res) {\n    // we are the only component running...\n    // --> sleep some time in this thread!\n    if (isEOI()) {\n      smileSleep((int)(reader_->getLevelT()*5000.0));\n    } else {\n      smileSleep((int)(reader_->getLevelT()*1000.0));\n    } \n    // in offline mode we have to return 0 to enter EOI processing loop\n    // (this enables us to access CMN data produced by a cFullinputMean component\n    if (offlineMode && !isEOI()) res = 0;\n  }\n/*\nsmileMutexLock(terminatedMtx);\n  if (terminated == FALSE) res = 1;\n  smileMutexUnlock(terminatedMtx);\n*/\n\n  return res;\n}\n\n\ncJuliusSink::~cJuliusSink()\n{\n  int i;\n\n  smileMutexLock(dataFlgMtx);\n  terminated = TRUE;\n  smileCondSignal( tickCond );\n  smileMutexUnlock(dataFlgMtx);\n  \n  if (!(decoderThread == NULL)) smileThreadJoin(decoderThread);\n\n  /* release all */\n  j_recog_free(recog);\n\n  \n  //if (logfile) fclose(fp);\n\n  smileMutexDestroy(terminatedMtx);\n  smileMutexDestroy(dataFlgMtx);\n  smileCondDestroy(tickCond);\n\n  if (excludeWords != NULL) free(excludeWords);\n  if (keywords != NULL) {\n    for (i=0; i<numKw; i++) {\n      if (keywords[i] != NULL) free(keywords[i]);\n    }\n    free(keywords);\n  }\n}\n\n\n#endif // HAVE_JULIUSLIB\n\n"
  },
  {
    "path": "src/classifiers/libsvm/COPYRIGHT",
    "content": "\nCopyright (c) 2000-2008 Chih-Chung Chang and Chih-Jen Lin\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n\n1. Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright\nnotice, this list of conditions and the following disclaimer in the\ndocumentation and/or other materials provided with the distribution.\n\n3. Neither name of copyright holders nor the names of its contributors\nmay be used to endorse or promote products derived from this software\nwithout specific prior written permission.\n\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR\nCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\nEXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\nPROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\nPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
  },
  {
    "path": "src/classifiers/libsvm/svm.cpp",
    "content": "/*\nLibSVM source code\n\nCopyright (c) 2000-2008 Chih-Chung Chang and Chih-Jen Lin\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n\n1. Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright\nnotice, this list of conditions and the following disclaimer in the\ndocumentation and/or other materials provided with the distribution.\n\n3. Neither name of copyright holders nor the names of its contributors\nmay be used to endorse or promote products derived from this software\nwithout specific prior written permission.\n\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR\nCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\nEXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\nPROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\nPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n***************************\nChanges from original code:\n***************************\n\n2009:\n\n* Functions for saving and loading binary SVM model files were added\n  by Florian Eyben\n\n*/\n\n\n\n\n#include <math.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <ctype.h>\n#include <float.h>\n#include <string.h>\n#include <stdarg.h>\n#include <classifiers/libsvm/svm.h>\n\n#ifdef BUILD_LIBSVM\n\n\ntypedef float Qfloat;\ntypedef signed char schar;\n#ifndef min\ntemplate <class T> inline T min(T x,T y) { return (x<y)?x:y; }\n#endif\n#ifndef max\ntemplate <class T> inline T max(T x,T y) { return (x>y)?x:y; }\n#endif\ntemplate <class T> inline void swap(T& x, T& y) { T t=x; x=y; y=t; }\ntemplate <class S, class T> inline void clone(T*& dst, S* src, int n)\n{\n\tdst = new T[n];\n\tmemcpy((void *)dst,(void *)src,sizeof(T)*n);\n}\ninline double powi(double base, int times)\n{\n        double tmp = base, ret = 1.0;\n\n        for(int t=times; t>0; t/=2)\n\t{\n                if(t%2==1) ret*=tmp;\n                tmp = tmp * tmp;\n        }\n        return ret;\n}\n#define INF HUGE_VAL\n#define TAU 1e-12\n#define Malloc(type,n) (type *)malloc((n)*sizeof(type))\n#if 1\nstatic void info(const char *fmt,...)\n{\n\tva_list ap;\n\tva_start(ap,fmt);\n\tvprintf(fmt,ap);\n\tva_end(ap);\n}\nstatic void info_flush()\n{\n\tfflush(stdout);\n}\n#else\nstatic void info(char *fmt,...) {}\nstatic void info_flush() {}\n#endif\n\n//\n// Kernel Cache\n//\n// l is the number of total data items\n// size is the cache size limit in bytes\n//\nclass Cache\n{\npublic:\n\tCache(int l,long int size);\n\t~Cache();\n\n\t// request data [0,len)\n\t// return some position p where [p,len) need to be filled\n\t// (p >= len if nothing needs to be filled)\n\tint get_data(const int index, Qfloat **data, int len);\n\tvoid swap_index(int i, int j);\t\nprivate:\n\tint l;\n\tlong int size;\n\tstruct head_t\n\t{\n\t\thead_t *prev, *next;\t// a circular list\n\t\tQfloat *data;\n\t\tint len;\t\t// data[0,len) is cached in this entry\n\t};\n\n\thead_t *head;\n\thead_t lru_head;\n\tvoid lru_delete(head_t *h);\n\tvoid lru_insert(head_t *h);\n};\n\nCache::Cache(int l_,long int size_):l(l_),size(size_)\n{\n\thead = (head_t *)calloc(l,sizeof(head_t));\t// initialized to 0\n\tsize /= sizeof(Qfloat);\n\tsize -= l * sizeof(head_t) / sizeof(Qfloat);\n\tsize = max(size, 2 * (long int) l);\t// cache must be large enough for two columns\n\tlru_head.next = lru_head.prev = &lru_head;\n}\n\nCache::~Cache()\n{\n\tfor(head_t *h = lru_head.next; h != &lru_head; h=h->next)\n\t\tfree(h->data);\n\tfree(head);\n}\n\nvoid Cache::lru_delete(head_t *h)\n{\n\t// delete from current location\n\th->prev->next = h->next;\n\th->next->prev = h->prev;\n}\n\nvoid Cache::lru_insert(head_t *h)\n{\n\t// insert to last position\n\th->next = &lru_head;\n\th->prev = lru_head.prev;\n\th->prev->next = h;\n\th->next->prev = h;\n}\n\nint Cache::get_data(const int index, Qfloat **data, int len)\n{\n\thead_t *h = &head[index];\n\tif(h->len) lru_delete(h);\n\tint more = len - h->len;\n\n\tif(more > 0)\n\t{\n\t\t// free old space\n\t\twhile(size < more)\n\t\t{\n\t\t\thead_t *old = lru_head.next;\n\t\t\tlru_delete(old);\n\t\t\tfree(old->data);\n\t\t\tsize += old->len;\n\t\t\told->data = 0;\n\t\t\told->len = 0;\n\t\t}\n\n\t\t// allocate new space\n\t\th->data = (Qfloat *)realloc(h->data,sizeof(Qfloat)*len);\n\t\tsize -= more;\n\t\tswap(h->len,len);\n\t}\n\n\tlru_insert(h);\n\t*data = h->data;\n\treturn len;\n}\n\nvoid Cache::swap_index(int i, int j)\n{\n\tif(i==j) return;\n\n\tif(head[i].len) lru_delete(&head[i]);\n\tif(head[j].len) lru_delete(&head[j]);\n\tswap(head[i].data,head[j].data);\n\tswap(head[i].len,head[j].len);\n\tif(head[i].len) lru_insert(&head[i]);\n\tif(head[j].len) lru_insert(&head[j]);\n\n\tif(i>j) swap(i,j);\n\tfor(head_t *h = lru_head.next; h!=&lru_head; h=h->next)\n\t{\n\t\tif(h->len > i)\n\t\t{\n\t\t\tif(h->len > j)\n\t\t\t\tswap(h->data[i],h->data[j]);\n\t\t\telse\n\t\t\t{\n\t\t\t\t// give up\n\t\t\t\tlru_delete(h);\n\t\t\t\tfree(h->data);\n\t\t\t\tsize += h->len;\n\t\t\t\th->data = 0;\n\t\t\t\th->len = 0;\n\t\t\t}\n\t\t}\n\t}\n}\n\n//\n// Kernel evaluation\n//\n// the static method k_function is for doing single kernel evaluation\n// the constructor of Kernel prepares to calculate the l*l kernel matrix\n// the member function get_Q is for getting one column from the Q Matrix\n//\nclass QMatrix {\npublic:\n\tvirtual Qfloat *get_Q(int column, int len) const = 0;\n\tvirtual Qfloat *get_QD() const = 0;\n\tvirtual void swap_index(int i, int j) const = 0;\n\tvirtual ~QMatrix() {}\n};\n\nclass Kernel: public QMatrix {\npublic:\n\tKernel(int l, svm_node * const * x, const svm_parameter& param);\n\tvirtual ~Kernel();\n\n\tstatic double k_function(const svm_node *x, const svm_node *y,\n\t\t\t\t const svm_parameter& param);\n\tvirtual Qfloat *get_Q(int column, int len) const = 0;\n\tvirtual Qfloat *get_QD() const = 0;\n\tvirtual void swap_index(int i, int j) const\t// no so const...\n\t{\n\t\tswap(x[i],x[j]);\n\t\tif(x_square) swap(x_square[i],x_square[j]);\n\t}\nprotected:\n\n\tdouble (Kernel::*kernel_function)(int i, int j) const;\n\nprivate:\n\tconst svm_node **x;\n\tdouble *x_square;\n\n\t// svm_parameter\n\tconst int kernel_type;\n\tconst int degree;\n\tconst double gamma;\n\tconst double coef0;\n\n\tstatic double dot(const svm_node *px, const svm_node *py);\n\tdouble kernel_linear(int i, int j) const\n\t{\n\t\treturn dot(x[i],x[j]);\n\t}\n\tdouble kernel_poly(int i, int j) const\n\t{\n\t\treturn powi(gamma*dot(x[i],x[j])+coef0,degree);\n\t}\n\tdouble kernel_rbf(int i, int j) const\n\t{\n\t\treturn exp(-gamma*(x_square[i]+x_square[j]-2*dot(x[i],x[j])));\n\t}\n\tdouble kernel_sigmoid(int i, int j) const\n\t{\n\t\treturn tanh(gamma*dot(x[i],x[j])+coef0);\n\t}\n\tdouble kernel_precomputed(int i, int j) const\n\t{\n\t\treturn x[i][(int)(x[j][0].value)].value;\n\t}\n};\n\nKernel::Kernel(int l, svm_node * const * x_, const svm_parameter& param)\n:kernel_type(param.kernel_type), degree(param.degree),\n gamma(param.gamma), coef0(param.coef0)\n{\n\tswitch(kernel_type)\n\t{\n\t\tcase LINEAR:\n\t\t\tkernel_function = &Kernel::kernel_linear;\n\t\t\tbreak;\n\t\tcase POLY:\n\t\t\tkernel_function = &Kernel::kernel_poly;\n\t\t\tbreak;\n\t\tcase RBF:\n\t\t\tkernel_function = &Kernel::kernel_rbf;\n\t\t\tbreak;\n\t\tcase SIGMOID:\n\t\t\tkernel_function = &Kernel::kernel_sigmoid;\n\t\t\tbreak;\n\t\tcase PRECOMPUTED:\n\t\t\tkernel_function = &Kernel::kernel_precomputed;\n\t\t\tbreak;\n\t}\n\n\tclone(x,x_,l);\n\n\tif(kernel_type == RBF)\n\t{\n\t\tx_square = new double[l];\n\t\tfor(int i=0;i<l;i++)\n\t\t\tx_square[i] = dot(x[i],x[i]);\n\t}\n\telse\n\t\tx_square = 0;\n}\n\nKernel::~Kernel()\n{\n\tdelete[] x;\n\tdelete[] x_square;\n}\n\ndouble Kernel::dot(const svm_node *px, const svm_node *py)\n{\n\tdouble sum = 0;\n\twhile(px->index != -1 && py->index != -1)\n\t{\n\t\tif(px->index == py->index)\n\t\t{\n\t\t\tsum += px->value * py->value;\n\t\t\t++px;\n\t\t\t++py;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(px->index > py->index)\n\t\t\t\t++py;\n\t\t\telse\n\t\t\t\t++px;\n\t\t}\t\t\t\n\t}\n\treturn sum;\n}\n\ndouble Kernel::k_function(const svm_node *x, const svm_node *y,\n\t\t\t  const svm_parameter& param)\n{\n\tswitch(param.kernel_type)\n\t{\n\t\tcase LINEAR:\n\t\t\treturn dot(x,y);\n\t\tcase POLY:\n\t\t\treturn powi(param.gamma*dot(x,y)+param.coef0,param.degree);\n\t\tcase RBF:\n\t\t{\n\t\t\tdouble sum = 0;\n\t\t\twhile(x->index != -1 && y->index !=-1)\n\t\t\t{\n\t\t\t\tif(x->index == y->index)\n\t\t\t\t{\n\t\t\t\t\tdouble d = x->value - y->value;\n\t\t\t\t\tsum += d*d;\n\t\t\t\t\t++x;\n\t\t\t\t\t++y;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif(x->index > y->index)\n\t\t\t\t\t{\t\n\t\t\t\t\t\tsum += y->value * y->value;\n\t\t\t\t\t\t++y;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tsum += x->value * x->value;\n\t\t\t\t\t\t++x;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\twhile(x->index != -1)\n\t\t\t{\n\t\t\t\tsum += x->value * x->value;\n\t\t\t\t++x;\n\t\t\t}\n\n\t\t\twhile(y->index != -1)\n\t\t\t{\n\t\t\t\tsum += y->value * y->value;\n\t\t\t\t++y;\n\t\t\t}\n\t\t\t\n\t\t\treturn exp(-param.gamma*sum);\n\t\t}\n\t\tcase SIGMOID:\n\t\t\treturn tanh(param.gamma*dot(x,y)+param.coef0);\n\t\tcase PRECOMPUTED:  //x: test (validation), y: SV\n\t\t\treturn x[(int)(y->value)].value;\n\t\tdefault:\n\t\t\treturn 0;  // Unreachable \n\t}\n}\n\n// An SMO algorithm in Fan et al., JMLR 6(2005), p. 1889--1918\n// Solves:\n//\n//\tmin 0.5(\\alpha^T Q \\alpha) + p^T \\alpha\n//\n//\t\ty^T \\alpha = \\delta\n//\t\ty_i = +1 or -1\n//\t\t0 <= alpha_i <= Cp for y_i = 1\n//\t\t0 <= alpha_i <= Cn for y_i = -1\n//\n// Given:\n//\n//\tQ, p, y, Cp, Cn, and an initial feasible point \\alpha\n//\tl is the size of vectors and matrices\n//\teps is the stopping tolerance\n//\n// solution will be put in \\alpha, objective value will be put in obj\n//\nclass Solver {\npublic:\n\tSolver() {};\n\tvirtual ~Solver() {};\n\n\tstruct SolutionInfo {\n\t\tdouble obj;\n\t\tdouble rho;\n\t\tdouble upper_bound_p;\n\t\tdouble upper_bound_n;\n\t\tdouble r;\t// for Solver_NU\n\t};\n\n\tvoid Solve(int l, const QMatrix& Q, const double *p_, const schar *y_,\n\t\t   double *alpha_, double Cp, double Cn, double eps,\n\t\t   SolutionInfo* si, int shrinking);\nprotected:\n\tint active_size;\n\tschar *y;\n\tdouble *G;\t\t// gradient of objective function\n\tenum { LOWER_BOUND, UPPER_BOUND, FREE };\n\tchar *alpha_status;\t// LOWER_BOUND, UPPER_BOUND, FREE\n\tdouble *alpha;\n\tconst QMatrix *Q;\n\tconst Qfloat *QD;\n\tdouble eps;\n\tdouble Cp,Cn;\n\tdouble *p;\n\tint *active_set;\n\tdouble *G_bar;\t\t// gradient, if we treat free variables as 0\n\tint l;\n\tbool unshrink;\t// XXX\n\n\tdouble get_C(int i)\n\t{\n\t\treturn (y[i] > 0)? Cp : Cn;\n\t}\n\tvoid update_alpha_status(int i)\n\t{\n\t\tif(alpha[i] >= get_C(i))\n\t\t\talpha_status[i] = UPPER_BOUND;\n\t\telse if(alpha[i] <= 0)\n\t\t\talpha_status[i] = LOWER_BOUND;\n\t\telse alpha_status[i] = FREE;\n\t}\n\tbool is_upper_bound(int i) { return alpha_status[i] == UPPER_BOUND; }\n\tbool is_lower_bound(int i) { return alpha_status[i] == LOWER_BOUND; }\n\tbool is_free(int i) { return alpha_status[i] == FREE; }\n\tvoid swap_index(int i, int j);\n\tvoid reconstruct_gradient();\n\tvirtual int select_working_set(int &i, int &j);\n\tvirtual double calculate_rho();\n\tvirtual void do_shrinking();\nprivate:\n\tbool be_shrunk(int i, double Gmax1, double Gmax2);\t\n};\n\nvoid Solver::swap_index(int i, int j)\n{\n\tQ->swap_index(i,j);\n\tswap(y[i],y[j]);\n\tswap(G[i],G[j]);\n\tswap(alpha_status[i],alpha_status[j]);\n\tswap(alpha[i],alpha[j]);\n\tswap(p[i],p[j]);\n\tswap(active_set[i],active_set[j]);\n\tswap(G_bar[i],G_bar[j]);\n}\n\nvoid Solver::reconstruct_gradient()\n{\n\t// reconstruct inactive elements of G from G_bar and free variables\n\n\tif(active_size == l) return;\n\n\tint i,j;\n\tfor(j=active_size;j<l;j++)\n\t\tG[j] = G_bar[j] + p[j];\n\n\tfor(i=active_size;i<l;i++)\n\t{\n\t\tconst Qfloat *Q_i = Q->get_Q(i,active_size);\n\t\tfor(j=0;j<active_size;j++)\n\t\t\tif(is_free(j))\n\t\t\t\tG[i] += alpha[j] * Q_i[j];\n\t}\n}\n\nvoid Solver::Solve(int l, const QMatrix& Q, const double *p_, const schar *y_,\n\t\t   double *alpha_, double Cp, double Cn, double eps,\n\t\t   SolutionInfo* si, int shrinking)\n{\n\tthis->l = l;\n\tthis->Q = &Q;\n\tQD=Q.get_QD();\n\tclone(p, p_,l);\n\tclone(y, y_,l);\n\tclone(alpha,alpha_,l);\n\tthis->Cp = Cp;\n\tthis->Cn = Cn;\n\tthis->eps = eps;\n\tunshrink = false;\n\n\t// initialize alpha_status\n\t{\n\t\talpha_status = new char[l];\n\t\tfor(int i=0;i<l;i++)\n\t\t\tupdate_alpha_status(i);\n\t}\n\n\t// initialize active set (for shrinking)\n\t{\n\t\tactive_set = new int[l];\n\t\tfor(int i=0;i<l;i++)\n\t\t\tactive_set[i] = i;\n\t\tactive_size = l;\n\t}\n\n\t// initialize gradient\n\t{\n\t\tG = new double[l];\n\t\tG_bar = new double[l];\n\t\tint i;\n\t\tfor(i=0;i<l;i++)\n\t\t{\n\t\t\tG[i] = p[i];\n\t\t\tG_bar[i] = 0;\n\t\t}\n\t\tfor(i=0;i<l;i++)\n\t\t\tif(!is_lower_bound(i))\n\t\t\t{\n\t\t\t\tconst Qfloat *Q_i = Q.get_Q(i,l);\n\t\t\t\tdouble alpha_i = alpha[i];\n\t\t\t\tint j;\n\t\t\t\tfor(j=0;j<l;j++)\n\t\t\t\t\tG[j] += alpha_i*Q_i[j];\n\t\t\t\tif(is_upper_bound(i))\n\t\t\t\t\tfor(j=0;j<l;j++)\n\t\t\t\t\t\tG_bar[j] += get_C(i) * Q_i[j];\n\t\t\t}\n\t}\n\n\t// optimization step\n\n\tint iter = 0;\n\tint counter = min(l,1000)+1;\n\n\twhile(1)\n\t{\n\t\t// show progress and do shrinking\n\n\t\tif(--counter == 0)\n\t\t{\n\t\t\tcounter = min(l,1000);\n\t\t\tif(shrinking) do_shrinking();\n\t\t\tinfo(\".\"); info_flush();\n\t\t}\n\n\t\tint i,j;\n\t\tif(select_working_set(i,j)!=0)\n\t\t{\n\t\t\t// reconstruct the whole gradient\n\t\t\treconstruct_gradient();\n\t\t\t// reset active set size and check\n\t\t\tactive_size = l;\n\t\t\tinfo(\"*\"); info_flush();\n\t\t\tif(select_working_set(i,j)!=0)\n\t\t\t\tbreak;\n\t\t\telse\n\t\t\t\tcounter = 1;\t// do shrinking next iteration\n\t\t}\n\t\t\n\t\t++iter;\n\n\t\t// update alpha[i] and alpha[j], handle bounds carefully\n\t\t\n\t\tconst Qfloat *Q_i = Q.get_Q(i,active_size);\n\t\tconst Qfloat *Q_j = Q.get_Q(j,active_size);\n\n\t\tdouble C_i = get_C(i);\n\t\tdouble C_j = get_C(j);\n\n\t\tdouble old_alpha_i = alpha[i];\n\t\tdouble old_alpha_j = alpha[j];\n\n\t\tif(y[i]!=y[j])\n\t\t{\n\t\t\tdouble quad_coef = Q_i[i]+Q_j[j]+2*Q_i[j];\n\t\t\tif (quad_coef <= 0)\n\t\t\t\tquad_coef = TAU;\n\t\t\tdouble delta = (-G[i]-G[j])/quad_coef;\n\t\t\tdouble diff = alpha[i] - alpha[j];\n\t\t\talpha[i] += delta;\n\t\t\talpha[j] += delta;\n\t\t\t\n\t\t\tif(diff > 0)\n\t\t\t{\n\t\t\t\tif(alpha[j] < 0)\n\t\t\t\t{\n\t\t\t\t\talpha[j] = 0;\n\t\t\t\t\talpha[i] = diff;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(alpha[i] < 0)\n\t\t\t\t{\n\t\t\t\t\talpha[i] = 0;\n\t\t\t\t\talpha[j] = -diff;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(diff > C_i - C_j)\n\t\t\t{\n\t\t\t\tif(alpha[i] > C_i)\n\t\t\t\t{\n\t\t\t\t\talpha[i] = C_i;\n\t\t\t\t\talpha[j] = C_i - diff;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(alpha[j] > C_j)\n\t\t\t\t{\n\t\t\t\t\talpha[j] = C_j;\n\t\t\t\t\talpha[i] = C_j + diff;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tdouble quad_coef = Q_i[i]+Q_j[j]-2*Q_i[j];\n\t\t\tif (quad_coef <= 0)\n\t\t\t\tquad_coef = TAU;\n\t\t\tdouble delta = (G[i]-G[j])/quad_coef;\n\t\t\tdouble sum = alpha[i] + alpha[j];\n\t\t\talpha[i] -= delta;\n\t\t\talpha[j] += delta;\n\n\t\t\tif(sum > C_i)\n\t\t\t{\n\t\t\t\tif(alpha[i] > C_i)\n\t\t\t\t{\n\t\t\t\t\talpha[i] = C_i;\n\t\t\t\t\talpha[j] = sum - C_i;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(alpha[j] < 0)\n\t\t\t\t{\n\t\t\t\t\talpha[j] = 0;\n\t\t\t\t\talpha[i] = sum;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(sum > C_j)\n\t\t\t{\n\t\t\t\tif(alpha[j] > C_j)\n\t\t\t\t{\n\t\t\t\t\talpha[j] = C_j;\n\t\t\t\t\talpha[i] = sum - C_j;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(alpha[i] < 0)\n\t\t\t\t{\n\t\t\t\t\talpha[i] = 0;\n\t\t\t\t\talpha[j] = sum;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// update G\n\n\t\tdouble delta_alpha_i = alpha[i] - old_alpha_i;\n\t\tdouble delta_alpha_j = alpha[j] - old_alpha_j;\n\t\t\n\t\tfor(int k=0;k<active_size;k++)\n\t\t{\n\t\t\tG[k] += Q_i[k]*delta_alpha_i + Q_j[k]*delta_alpha_j;\n\t\t}\n\n\t\t// update alpha_status and G_bar\n\n\t\t{\n\t\t\tbool ui = is_upper_bound(i);\n\t\t\tbool uj = is_upper_bound(j);\n\t\t\tupdate_alpha_status(i);\n\t\t\tupdate_alpha_status(j);\n\t\t\tint k;\n\t\t\tif(ui != is_upper_bound(i))\n\t\t\t{\n\t\t\t\tQ_i = Q.get_Q(i,l);\n\t\t\t\tif(ui)\n\t\t\t\t\tfor(k=0;k<l;k++)\n\t\t\t\t\t\tG_bar[k] -= C_i * Q_i[k];\n\t\t\t\telse\n\t\t\t\t\tfor(k=0;k<l;k++)\n\t\t\t\t\t\tG_bar[k] += C_i * Q_i[k];\n\t\t\t}\n\n\t\t\tif(uj != is_upper_bound(j))\n\t\t\t{\n\t\t\t\tQ_j = Q.get_Q(j,l);\n\t\t\t\tif(uj)\n\t\t\t\t\tfor(k=0;k<l;k++)\n\t\t\t\t\t\tG_bar[k] -= C_j * Q_j[k];\n\t\t\t\telse\n\t\t\t\t\tfor(k=0;k<l;k++)\n\t\t\t\t\t\tG_bar[k] += C_j * Q_j[k];\n\t\t\t}\n\t\t}\n\t}\n\n\t// calculate rho\n\n\tsi->rho = calculate_rho();\n\n\t// calculate objective value\n\t{\n\t\tdouble v = 0;\n\t\tint i;\n\t\tfor(i=0;i<l;i++)\n\t\t\tv += alpha[i] * (G[i] + p[i]);\n\n\t\tsi->obj = v/2;\n\t}\n\n\t// put back the solution\n\t{\n\t\tfor(int i=0;i<l;i++)\n\t\t\talpha_[active_set[i]] = alpha[i];\n\t}\n\n\t// juggle everything back\n\t/*{\n\t\tfor(int i=0;i<l;i++)\n\t\t\twhile(active_set[i] != i)\n\t\t\t\tswap_index(i,active_set[i]);\n\t\t\t\t// or Q.swap_index(i,active_set[i]);\n\t}*/\n\n\tsi->upper_bound_p = Cp;\n\tsi->upper_bound_n = Cn;\n\n\tinfo(\"\\noptimization finished, #iter = %d\\n\",iter);\n\n\tdelete[] p;\n\tdelete[] y;\n\tdelete[] alpha;\n\tdelete[] alpha_status;\n\tdelete[] active_set;\n\tdelete[] G;\n\tdelete[] G_bar;\n}\n\n// return 1 if already optimal, return 0 otherwise\nint Solver::select_working_set(int &out_i, int &out_j)\n{\n\t// return i,j such that\n\t// i: maximizes -y_i * grad(f)_i, i in I_up(\\alpha)\n\t// j: minimizes the decrease of obj value\n\t//    (if quadratic coefficeint <= 0, replace it with tau)\n\t//    -y_j*grad(f)_j < -y_i*grad(f)_i, j in I_low(\\alpha)\n\t\n\tdouble Gmax = -INF;\n\tdouble Gmax2 = -INF;\n\tint Gmax_idx = -1;\n\tint Gmin_idx = -1;\n\tdouble obj_diff_min = INF;\n\n\tfor(int t=0;t<active_size;t++)\n\t\tif(y[t]==+1)\t\n\t\t{\n\t\t\tif(!is_upper_bound(t))\n\t\t\t\tif(-G[t] >= Gmax)\n\t\t\t\t{\n\t\t\t\t\tGmax = -G[t];\n\t\t\t\t\tGmax_idx = t;\n\t\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(!is_lower_bound(t))\n\t\t\t\tif(G[t] >= Gmax)\n\t\t\t\t{\n\t\t\t\t\tGmax = G[t];\n\t\t\t\t\tGmax_idx = t;\n\t\t\t\t}\n\t\t}\n\n\tint i = Gmax_idx;\n\tconst Qfloat *Q_i = NULL;\n\tif(i != -1) // NULL Q_i not accessed: Gmax=-INF if i=-1\n\t\tQ_i = Q->get_Q(i,active_size);\n\n\tfor(int j=0;j<active_size;j++)\n\t{\n\t\tif(y[j]==+1)\n\t\t{\n\t\t\tif (!is_lower_bound(j))\n\t\t\t{\n\t\t\t\tdouble grad_diff=Gmax+G[j];\n\t\t\t\tif (G[j] >= Gmax2)\n\t\t\t\t\tGmax2 = G[j];\n\t\t\t\tif (grad_diff > 0)\n\t\t\t\t{\n\t\t\t\t\tdouble obj_diff; \n\t\t\t\t\tdouble quad_coef=Q_i[i]+QD[j]-2.0*y[i]*Q_i[j];\n\t\t\t\t\tif (quad_coef > 0)\n\t\t\t\t\t\tobj_diff = -(grad_diff*grad_diff)/quad_coef;\n\t\t\t\t\telse\n\t\t\t\t\t\tobj_diff = -(grad_diff*grad_diff)/TAU;\n\n\t\t\t\t\tif (obj_diff <= obj_diff_min)\n\t\t\t\t\t{\n\t\t\t\t\t\tGmin_idx=j;\n\t\t\t\t\t\tobj_diff_min = obj_diff;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (!is_upper_bound(j))\n\t\t\t{\n\t\t\t\tdouble grad_diff= Gmax-G[j];\n\t\t\t\tif (-G[j] >= Gmax2)\n\t\t\t\t\tGmax2 = -G[j];\n\t\t\t\tif (grad_diff > 0)\n\t\t\t\t{\n\t\t\t\t\tdouble obj_diff; \n\t\t\t\t\tdouble quad_coef=Q_i[i]+QD[j]+2.0*y[i]*Q_i[j];\n\t\t\t\t\tif (quad_coef > 0)\n\t\t\t\t\t\tobj_diff = -(grad_diff*grad_diff)/quad_coef;\n\t\t\t\t\telse\n\t\t\t\t\t\tobj_diff = -(grad_diff*grad_diff)/TAU;\n\n\t\t\t\t\tif (obj_diff <= obj_diff_min)\n\t\t\t\t\t{\n\t\t\t\t\t\tGmin_idx=j;\n\t\t\t\t\t\tobj_diff_min = obj_diff;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif(Gmax+Gmax2 < eps)\n\t\treturn 1;\n\n\tout_i = Gmax_idx;\n\tout_j = Gmin_idx;\n\treturn 0;\n}\n\nbool Solver::be_shrunk(int i, double Gmax1, double Gmax2)\n{\n\tif(is_upper_bound(i))\n\t{\n\t\tif(y[i]==+1)\n\t\t\treturn(-G[i] > Gmax1);\n\t\telse\n\t\t\treturn(-G[i] > Gmax2);\n\t}\n\telse if(is_lower_bound(i))\n\t{\n\t\tif(y[i]==+1)\n\t\t\treturn(G[i] > Gmax2);\n\t\telse\t\n\t\t\treturn(G[i] > Gmax1);\n\t}\n\telse\n\t\treturn(false);\n}\n\nvoid Solver::do_shrinking()\n{\n\tint i;\n\tdouble Gmax1 = -INF;\t\t// max { -y_i * grad(f)_i | i in I_up(\\alpha) }\n\tdouble Gmax2 = -INF;\t\t// max { y_i * grad(f)_i | i in I_low(\\alpha) }\n\n\t// find maximal violating pair first\n\tfor(i=0;i<active_size;i++)\n\t{\n\t\tif(y[i]==+1)\t\n\t\t{\n\t\t\tif(!is_upper_bound(i))\t\n\t\t\t{\n\t\t\t\tif(-G[i] >= Gmax1)\n\t\t\t\t\tGmax1 = -G[i];\n\t\t\t}\n\t\t\tif(!is_lower_bound(i))\t\n\t\t\t{\n\t\t\t\tif(G[i] >= Gmax2)\n\t\t\t\t\tGmax2 = G[i];\n\t\t\t}\n\t\t}\n\t\telse\t\n\t\t{\n\t\t\tif(!is_upper_bound(i))\t\n\t\t\t{\n\t\t\t\tif(-G[i] >= Gmax2)\n\t\t\t\t\tGmax2 = -G[i];\n\t\t\t}\n\t\t\tif(!is_lower_bound(i))\t\n\t\t\t{\n\t\t\t\tif(G[i] >= Gmax1)\n\t\t\t\t\tGmax1 = G[i];\n\t\t\t}\n\t\t}\n\t}\n\n\tif(unshrink == false && Gmax1 + Gmax2 <= eps*10) \n\t{\n\t\tunshrink = true;\n\t\treconstruct_gradient();\n\t\tactive_size = l;\n\t}\n\n\tfor(i=0;i<active_size;i++)\n\t\tif (be_shrunk(i, Gmax1, Gmax2))\n\t\t{\n\t\t\tactive_size--;\n\t\t\twhile (active_size > i)\n\t\t\t{\n\t\t\t\tif (!be_shrunk(active_size, Gmax1, Gmax2))\n\t\t\t\t{\n\t\t\t\t\tswap_index(i,active_size);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tactive_size--;\n\t\t\t}\n\t\t}\n}\n\ndouble Solver::calculate_rho()\n{\n\tdouble r;\n\tint nr_free = 0;\n\tdouble ub = INF, lb = -INF, sum_free = 0;\n\tfor(int i=0;i<active_size;i++)\n\t{\n\t\tdouble yG = y[i]*G[i];\n\n\t\tif(is_upper_bound(i))\n\t\t{\n\t\t\tif(y[i]==-1)\n\t\t\t\tub = min(ub,yG);\n\t\t\telse\n\t\t\t\tlb = max(lb,yG);\n\t\t}\n\t\telse if(is_lower_bound(i))\n\t\t{\n\t\t\tif(y[i]==+1)\n\t\t\t\tub = min(ub,yG);\n\t\t\telse\n\t\t\t\tlb = max(lb,yG);\n\t\t}\n\t\telse\n\t\t{\n\t\t\t++nr_free;\n\t\t\tsum_free += yG;\n\t\t}\n\t}\n\n\tif(nr_free>0)\n\t\tr = sum_free/nr_free;\n\telse\n\t\tr = (ub+lb)/2;\n\n\treturn r;\n}\n\n//\n// Solver for nu-svm classification and regression\n//\n// additional constraint: e^T \\alpha = constant\n//\nclass Solver_NU : public Solver\n{\npublic:\n\tSolver_NU() {}\n\tvoid Solve(int l, const QMatrix& Q, const double *p, const schar *y,\n\t\t   double *alpha, double Cp, double Cn, double eps,\n\t\t   SolutionInfo* si, int shrinking)\n\t{\n\t\tthis->si = si;\n\t\tSolver::Solve(l,Q,p,y,alpha,Cp,Cn,eps,si,shrinking);\n\t}\nprivate:\n\tSolutionInfo *si;\n\tint select_working_set(int &i, int &j);\n\tdouble calculate_rho();\n\tbool be_shrunk(int i, double Gmax1, double Gmax2, double Gmax3, double Gmax4);\n\tvoid do_shrinking();\n};\n\n// return 1 if already optimal, return 0 otherwise\nint Solver_NU::select_working_set(int &out_i, int &out_j)\n{\n\t// return i,j such that y_i = y_j and\n\t// i: maximizes -y_i * grad(f)_i, i in I_up(\\alpha)\n\t// j: minimizes the decrease of obj value\n\t//    (if quadratic coefficeint <= 0, replace it with tau)\n\t//    -y_j*grad(f)_j < -y_i*grad(f)_i, j in I_low(\\alpha)\n\n\tdouble Gmaxp = -INF;\n\tdouble Gmaxp2 = -INF;\n\tint Gmaxp_idx = -1;\n\n\tdouble Gmaxn = -INF;\n\tdouble Gmaxn2 = -INF;\n\tint Gmaxn_idx = -1;\n\n\tint Gmin_idx = -1;\n\tdouble obj_diff_min = INF;\n\n\tfor(int t=0;t<active_size;t++)\n\t\tif(y[t]==+1)\n\t\t{\n\t\t\tif(!is_upper_bound(t))\n\t\t\t\tif(-G[t] >= Gmaxp)\n\t\t\t\t{\n\t\t\t\t\tGmaxp = -G[t];\n\t\t\t\t\tGmaxp_idx = t;\n\t\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(!is_lower_bound(t))\n\t\t\t\tif(G[t] >= Gmaxn)\n\t\t\t\t{\n\t\t\t\t\tGmaxn = G[t];\n\t\t\t\t\tGmaxn_idx = t;\n\t\t\t\t}\n\t\t}\n\n\tint ip = Gmaxp_idx;\n\tint in = Gmaxn_idx;\n\tconst Qfloat *Q_ip = NULL;\n\tconst Qfloat *Q_in = NULL;\n\tif(ip != -1) // NULL Q_ip not accessed: Gmaxp=-INF if ip=-1\n\t\tQ_ip = Q->get_Q(ip,active_size);\n\tif(in != -1)\n\t\tQ_in = Q->get_Q(in,active_size);\n\n\tfor(int j=0;j<active_size;j++)\n\t{\n\t\tif(y[j]==+1)\n\t\t{\n\t\t\tif (!is_lower_bound(j))\t\n\t\t\t{\n\t\t\t\tdouble grad_diff=Gmaxp+G[j];\n\t\t\t\tif (G[j] >= Gmaxp2)\n\t\t\t\t\tGmaxp2 = G[j];\n\t\t\t\tif (grad_diff > 0)\n\t\t\t\t{\n\t\t\t\t\tdouble obj_diff; \n\t\t\t\t\tdouble quad_coef = Q_ip[ip]+QD[j]-2*Q_ip[j];\n\t\t\t\t\tif (quad_coef > 0)\n\t\t\t\t\t\tobj_diff = -(grad_diff*grad_diff)/quad_coef;\n\t\t\t\t\telse\n\t\t\t\t\t\tobj_diff = -(grad_diff*grad_diff)/TAU;\n\n\t\t\t\t\tif (obj_diff <= obj_diff_min)\n\t\t\t\t\t{\n\t\t\t\t\t\tGmin_idx=j;\n\t\t\t\t\t\tobj_diff_min = obj_diff;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (!is_upper_bound(j))\n\t\t\t{\n\t\t\t\tdouble grad_diff=Gmaxn-G[j];\n\t\t\t\tif (-G[j] >= Gmaxn2)\n\t\t\t\t\tGmaxn2 = -G[j];\n\t\t\t\tif (grad_diff > 0)\n\t\t\t\t{\n\t\t\t\t\tdouble obj_diff; \n\t\t\t\t\tdouble quad_coef = Q_in[in]+QD[j]-2*Q_in[j];\n\t\t\t\t\tif (quad_coef > 0)\n\t\t\t\t\t\tobj_diff = -(grad_diff*grad_diff)/quad_coef;\n\t\t\t\t\telse\n\t\t\t\t\t\tobj_diff = -(grad_diff*grad_diff)/TAU;\n\n\t\t\t\t\tif (obj_diff <= obj_diff_min)\n\t\t\t\t\t{\n\t\t\t\t\t\tGmin_idx=j;\n\t\t\t\t\t\tobj_diff_min = obj_diff;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif(max(Gmaxp+Gmaxp2,Gmaxn+Gmaxn2) < eps)\n \t\treturn 1;\n\n\tif (y[Gmin_idx] == +1)\n\t\tout_i = Gmaxp_idx;\n\telse\n\t\tout_i = Gmaxn_idx;\n\tout_j = Gmin_idx;\n\n\treturn 0;\n}\n\nbool Solver_NU::be_shrunk(int i, double Gmax1, double Gmax2, double Gmax3, double Gmax4)\n{\n\tif(is_upper_bound(i))\n\t{\n\t\tif(y[i]==+1)\n\t\t\treturn(-G[i] > Gmax1);\n\t\telse\t\n\t\t\treturn(-G[i] > Gmax4);\n\t}\n\telse if(is_lower_bound(i))\n\t{\n\t\tif(y[i]==+1)\n\t\t\treturn(G[i] > Gmax2);\n\t\telse\t\n\t\t\treturn(G[i] > Gmax3);\n\t}\n\telse\n\t\treturn(false);\n}\n\nvoid Solver_NU::do_shrinking()\n{\n\tdouble Gmax1 = -INF;\t// max { -y_i * grad(f)_i | y_i = +1, i in I_up(\\alpha) }\n\tdouble Gmax2 = -INF;\t// max { y_i * grad(f)_i | y_i = +1, i in I_low(\\alpha) }\n\tdouble Gmax3 = -INF;\t// max { -y_i * grad(f)_i | y_i = -1, i in I_up(\\alpha) }\n\tdouble Gmax4 = -INF;\t// max { y_i * grad(f)_i | y_i = -1, i in I_low(\\alpha) }\n\n\t// find maximal violating pair first\n\tint i;\n\tfor(i=0;i<active_size;i++)\n\t{\n\t\tif(!is_upper_bound(i))\n\t\t{\n\t\t\tif(y[i]==+1)\n\t\t\t{\n\t\t\t\tif(-G[i] > Gmax1) Gmax1 = -G[i];\n\t\t\t}\n\t\t\telse\tif(-G[i] > Gmax4) Gmax4 = -G[i];\n\t\t}\n\t\tif(!is_lower_bound(i))\n\t\t{\n\t\t\tif(y[i]==+1)\n\t\t\t{\t\n\t\t\t\tif(G[i] > Gmax2) Gmax2 = G[i];\n\t\t\t}\n\t\t\telse\tif(G[i] > Gmax3) Gmax3 = G[i];\n\t\t}\n\t}\n\n\tif(unshrink == false && max(Gmax1+Gmax2,Gmax3+Gmax4) <= eps*10) \n\t{\n\t\tunshrink = true;\n\t\treconstruct_gradient();\n\t\tactive_size = l;\n\t}\n\n\tfor(i=0;i<active_size;i++)\n\t\tif (be_shrunk(i, Gmax1, Gmax2, Gmax3, Gmax4))\n\t\t{\n\t\t\tactive_size--;\n\t\t\twhile (active_size > i)\n\t\t\t{\n\t\t\t\tif (!be_shrunk(active_size, Gmax1, Gmax2, Gmax3, Gmax4))\n\t\t\t\t{\n\t\t\t\t\tswap_index(i,active_size);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tactive_size--;\n\t\t\t}\n\t\t}\n}\n\ndouble Solver_NU::calculate_rho()\n{\n\tint nr_free1 = 0,nr_free2 = 0;\n\tdouble ub1 = INF, ub2 = INF;\n\tdouble lb1 = -INF, lb2 = -INF;\n\tdouble sum_free1 = 0, sum_free2 = 0;\n\n\tfor(int i=0;i<active_size;i++)\n\t{\n\t\tif(y[i]==+1)\n\t\t{\n\t\t\tif(is_upper_bound(i))\n\t\t\t\tlb1 = max(lb1,G[i]);\n\t\t\telse if(is_lower_bound(i))\n\t\t\t\tub1 = min(ub1,G[i]);\n\t\t\telse\n\t\t\t{\n\t\t\t\t++nr_free1;\n\t\t\t\tsum_free1 += G[i];\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(is_upper_bound(i))\n\t\t\t\tlb2 = max(lb2,G[i]);\n\t\t\telse if(is_lower_bound(i))\n\t\t\t\tub2 = min(ub2,G[i]);\n\t\t\telse\n\t\t\t{\n\t\t\t\t++nr_free2;\n\t\t\t\tsum_free2 += G[i];\n\t\t\t}\n\t\t}\n\t}\n\n\tdouble r1,r2;\n\tif(nr_free1 > 0)\n\t\tr1 = sum_free1/nr_free1;\n\telse\n\t\tr1 = (ub1+lb1)/2;\n\t\n\tif(nr_free2 > 0)\n\t\tr2 = sum_free2/nr_free2;\n\telse\n\t\tr2 = (ub2+lb2)/2;\n\t\n\tsi->r = (r1+r2)/2;\n\treturn (r1-r2)/2;\n}\n\n//\n// Q matrices for various formulations\n//\nclass SVC_Q: public Kernel\n{ \npublic:\n\tSVC_Q(const svm_problem& prob, const svm_parameter& param, const schar *y_)\n\t:Kernel(prob.l, prob.x, param)\n\t{\n\t\tclone(y,y_,prob.l);\n\t\tcache = new Cache(prob.l,(long int)(param.cache_size*(1<<20)));\n\t\tQD = new Qfloat[prob.l];\n\t\tfor(int i=0;i<prob.l;i++)\n\t\t\tQD[i]= (Qfloat)(this->*kernel_function)(i,i);\n\t}\n\t\n\tQfloat *get_Q(int i, int len) const\n\t{\n\t\tQfloat *data;\n\t\tint start;\n\t\tif((start = cache->get_data(i,&data,len)) < len)\n\t\t{\n\t\t\tfor(int j=start;j<len;j++)\n\t\t\t\tdata[j] = (Qfloat)(y[i]*y[j]*(this->*kernel_function)(i,j));\n\t\t}\n\t\treturn data;\n\t}\n\n\tQfloat *get_QD() const\n\t{\n\t\treturn QD;\n\t}\n\n\tvoid swap_index(int i, int j) const\n\t{\n\t\tcache->swap_index(i,j);\n\t\tKernel::swap_index(i,j);\n\t\tswap(y[i],y[j]);\n\t\tswap(QD[i],QD[j]);\n\t}\n\n\t~SVC_Q()\n\t{\n\t\tdelete[] y;\n\t\tdelete cache;\n\t\tdelete[] QD;\n\t}\nprivate:\n\tschar *y;\n\tCache *cache;\n\tQfloat *QD;\n};\n\nclass ONE_CLASS_Q: public Kernel\n{\npublic:\n\tONE_CLASS_Q(const svm_problem& prob, const svm_parameter& param)\n\t:Kernel(prob.l, prob.x, param)\n\t{\n\t\tcache = new Cache(prob.l,(long int)(param.cache_size*(1<<20)));\n\t\tQD = new Qfloat[prob.l];\n\t\tfor(int i=0;i<prob.l;i++)\n\t\t\tQD[i]= (Qfloat)(this->*kernel_function)(i,i);\n\t}\n\t\n\tQfloat *get_Q(int i, int len) const\n\t{\n\t\tQfloat *data;\n\t\tint start;\n\t\tif((start = cache->get_data(i,&data,len)) < len)\n\t\t{\n\t\t\tfor(int j=start;j<len;j++)\n\t\t\t\tdata[j] = (Qfloat)(this->*kernel_function)(i,j);\n\t\t}\n\t\treturn data;\n\t}\n\n\tQfloat *get_QD() const\n\t{\n\t\treturn QD;\n\t}\n\n\tvoid swap_index(int i, int j) const\n\t{\n\t\tcache->swap_index(i,j);\n\t\tKernel::swap_index(i,j);\n\t\tswap(QD[i],QD[j]);\n\t}\n\n\t~ONE_CLASS_Q()\n\t{\n\t\tdelete cache;\n\t\tdelete[] QD;\n\t}\nprivate:\n\tCache *cache;\n\tQfloat *QD;\n};\n\nclass SVR_Q: public Kernel\n{ \npublic:\n\tSVR_Q(const svm_problem& prob, const svm_parameter& param)\n\t:Kernel(prob.l, prob.x, param)\n\t{\n\t\tl = prob.l;\n\t\tcache = new Cache(l,(long int)(param.cache_size*(1<<20)));\n\t\tQD = new Qfloat[2*l];\n\t\tsign = new schar[2*l];\n\t\tindex = new int[2*l];\n\t\tfor(int k=0;k<l;k++)\n\t\t{\n\t\t\tsign[k] = 1;\n\t\t\tsign[k+l] = -1;\n\t\t\tindex[k] = k;\n\t\t\tindex[k+l] = k;\n\t\t\tQD[k]= (Qfloat)(this->*kernel_function)(k,k);\n\t\t\tQD[k+l]=QD[k];\n\t\t}\n\t\tbuffer[0] = new Qfloat[2*l];\n\t\tbuffer[1] = new Qfloat[2*l];\n\t\tnext_buffer = 0;\n\t}\n\n\tvoid swap_index(int i, int j) const\n\t{\n\t\tswap(sign[i],sign[j]);\n\t\tswap(index[i],index[j]);\n\t\tswap(QD[i],QD[j]);\n\t}\n\t\n\tQfloat *get_Q(int i, int len) const\n\t{\n\t\tQfloat *data;\n\t\tint real_i = index[i];\n\t\tif(cache->get_data(real_i,&data,l) < l)\n\t\t{\n\t\t\tfor(int j=0;j<l;j++)\n\t\t\t\tdata[j] = (Qfloat)(this->*kernel_function)(real_i,j);\n\t\t}\n\n\t\t// reorder and copy\n\t\tQfloat *buf = buffer[next_buffer];\n\t\tnext_buffer = 1 - next_buffer;\n\t\tschar si = sign[i];\n\t\tfor(int j=0;j<len;j++)\n\t\t\tbuf[j] = (Qfloat) si * (Qfloat) sign[j] * data[index[j]];\n\t\treturn buf;\n\t}\n\n\tQfloat *get_QD() const\n\t{\n\t\treturn QD;\n\t}\n\n\t~SVR_Q()\n\t{\n\t\tdelete cache;\n\t\tdelete[] sign;\n\t\tdelete[] index;\n\t\tdelete[] buffer[0];\n\t\tdelete[] buffer[1];\n\t\tdelete[] QD;\n\t}\nprivate:\n\tint l;\n\tCache *cache;\n\tschar *sign;\n\tint *index;\n\tmutable int next_buffer;\n\tQfloat *buffer[2];\n\tQfloat *QD;\n};\n\n//\n// construct and solve various formulations\n//\nstatic void solve_c_svc(\n\tconst svm_problem *prob, const svm_parameter* param,\n\tdouble *alpha, Solver::SolutionInfo* si, double Cp, double Cn)\n{\n\tint l = prob->l;\n\tdouble *minus_ones = new double[l];\n\tschar *y = new schar[l];\n\n\tint i;\n\n\tfor(i=0;i<l;i++)\n\t{\n\t\talpha[i] = 0;\n\t\tminus_ones[i] = -1;\n\t\tif(prob->y[i] > 0) y[i] = +1; else y[i]=-1;\n\t}\n\n\tSolver s;\n\ts.Solve(l, SVC_Q(*prob,*param,y), minus_ones, y,\n\t\talpha, Cp, Cn, param->eps, si, param->shrinking);\n\n\tdouble sum_alpha=0;\n\tfor(i=0;i<l;i++)\n\t\tsum_alpha += alpha[i];\n\n\tif (Cp==Cn)\n\t\tinfo(\"nu = %f\\n\", sum_alpha/(Cp*prob->l));\n\n\tfor(i=0;i<l;i++)\n\t\talpha[i] *= y[i];\n\n\tdelete[] minus_ones;\n\tdelete[] y;\n}\n\nstatic void solve_nu_svc(\n\tconst svm_problem *prob, const svm_parameter *param,\n\tdouble *alpha, Solver::SolutionInfo* si)\n{\n\tint i;\n\tint l = prob->l;\n\tdouble nu = param->nu;\n\n\tschar *y = new schar[l];\n\n\tfor(i=0;i<l;i++)\n\t\tif(prob->y[i]>0)\n\t\t\ty[i] = +1;\n\t\telse\n\t\t\ty[i] = -1;\n\n\tdouble sum_pos = nu*l/2;\n\tdouble sum_neg = nu*l/2;\n\n\tfor(i=0;i<l;i++)\n\t\tif(y[i] == +1)\n\t\t{\n\t\t\talpha[i] = min(1.0,sum_pos);\n\t\t\tsum_pos -= alpha[i];\n\t\t}\n\t\telse\n\t\t{\n\t\t\talpha[i] = min(1.0,sum_neg);\n\t\t\tsum_neg -= alpha[i];\n\t\t}\n\n\tdouble *zeros = new double[l];\n\n\tfor(i=0;i<l;i++)\n\t\tzeros[i] = 0;\n\n\tSolver_NU s;\n\ts.Solve(l, SVC_Q(*prob,*param,y), zeros, y,\n\t\talpha, 1.0, 1.0, param->eps, si,  param->shrinking);\n\tdouble r = si->r;\n\n\tinfo(\"C = %f\\n\",1/r);\n\n\tfor(i=0;i<l;i++)\n\t\talpha[i] *= y[i]/r;\n\n\tsi->rho /= r;\n\tsi->obj /= (r*r);\n\tsi->upper_bound_p = 1/r;\n\tsi->upper_bound_n = 1/r;\n\n\tdelete[] y;\n\tdelete[] zeros;\n}\n\nstatic void solve_one_class(\n\tconst svm_problem *prob, const svm_parameter *param,\n\tdouble *alpha, Solver::SolutionInfo* si)\n{\n\tint l = prob->l;\n\tdouble *zeros = new double[l];\n\tschar *ones = new schar[l];\n\tint i;\n\n\tint n = (int)(param->nu*prob->l);\t// # of alpha's at upper bound\n\n\tfor(i=0;i<n;i++)\n\t\talpha[i] = 1;\n\tif(n<prob->l)\n\t\talpha[n] = param->nu * prob->l - n;\n\tfor(i=n+1;i<l;i++)\n\t\talpha[i] = 0;\n\n\tfor(i=0;i<l;i++)\n\t{\n\t\tzeros[i] = 0;\n\t\tones[i] = 1;\n\t}\n\n\tSolver s;\n\ts.Solve(l, ONE_CLASS_Q(*prob,*param), zeros, ones,\n\t\talpha, 1.0, 1.0, param->eps, si, param->shrinking);\n\n\tdelete[] zeros;\n\tdelete[] ones;\n}\n\nstatic void solve_epsilon_svr(\n\tconst svm_problem *prob, const svm_parameter *param,\n\tdouble *alpha, Solver::SolutionInfo* si)\n{\n\tint l = prob->l;\n\tdouble *alpha2 = new double[2*l];\n\tdouble *linear_term = new double[2*l];\n\tschar *y = new schar[2*l];\n\tint i;\n\n\tfor(i=0;i<l;i++)\n\t{\n\t\talpha2[i] = 0;\n\t\tlinear_term[i] = param->p - prob->y[i];\n\t\ty[i] = 1;\n\n\t\talpha2[i+l] = 0;\n\t\tlinear_term[i+l] = param->p + prob->y[i];\n\t\ty[i+l] = -1;\n\t}\n\n\tSolver s;\n\ts.Solve(2*l, SVR_Q(*prob,*param), linear_term, y,\n\t\talpha2, param->C, param->C, param->eps, si, param->shrinking);\n\n\tdouble sum_alpha = 0;\n\tfor(i=0;i<l;i++)\n\t{\n\t\talpha[i] = alpha2[i] - alpha2[i+l];\n\t\tsum_alpha += fabs(alpha[i]);\n\t}\n\tinfo(\"nu = %f\\n\",sum_alpha/(param->C*l));\n\n\tdelete[] alpha2;\n\tdelete[] linear_term;\n\tdelete[] y;\n}\n\nstatic void solve_nu_svr(\n\tconst svm_problem *prob, const svm_parameter *param,\n\tdouble *alpha, Solver::SolutionInfo* si)\n{\n\tint l = prob->l;\n\tdouble C = param->C;\n\tdouble *alpha2 = new double[2*l];\n\tdouble *linear_term = new double[2*l];\n\tschar *y = new schar[2*l];\n\tint i;\n\n\tdouble sum = C * param->nu * l / 2;\n\tfor(i=0;i<l;i++)\n\t{\n\t\talpha2[i] = alpha2[i+l] = min(sum,C);\n\t\tsum -= alpha2[i];\n\n\t\tlinear_term[i] = - prob->y[i];\n\t\ty[i] = 1;\n\n\t\tlinear_term[i+l] = prob->y[i];\n\t\ty[i+l] = -1;\n\t}\n\n\tSolver_NU s;\n\ts.Solve(2*l, SVR_Q(*prob,*param), linear_term, y,\n\t\talpha2, C, C, param->eps, si, param->shrinking);\n\n\tinfo(\"epsilon = %f\\n\",-si->r);\n\n\tfor(i=0;i<l;i++)\n\t\talpha[i] = alpha2[i] - alpha2[i+l];\n\n\tdelete[] alpha2;\n\tdelete[] linear_term;\n\tdelete[] y;\n}\n\n//\n// decision_function\n//\nstruct decision_function\n{\n\tdouble *alpha;\n\tdouble rho;\t\n};\n\ndecision_function svm_train_one(\n\tconst svm_problem *prob, const svm_parameter *param,\n\tdouble Cp, double Cn)\n{\n\tdouble *alpha = Malloc(double,prob->l);\n\tSolver::SolutionInfo si;\n\tswitch(param->svm_type)\n\t{\n\t\tcase C_SVC:\n\t\t\tsolve_c_svc(prob,param,alpha,&si,Cp,Cn);\n\t\t\tbreak;\n\t\tcase NU_SVC:\n\t\t\tsolve_nu_svc(prob,param,alpha,&si);\n\t\t\tbreak;\n\t\tcase ONE_CLASS:\n\t\t\tsolve_one_class(prob,param,alpha,&si);\n\t\t\tbreak;\n\t\tcase EPSILON_SVR:\n\t\t\tsolve_epsilon_svr(prob,param,alpha,&si);\n\t\t\tbreak;\n\t\tcase NU_SVR:\n\t\t\tsolve_nu_svr(prob,param,alpha,&si);\n\t\t\tbreak;\n\t}\n\n\tinfo(\"obj = %f, rho = %f\\n\",si.obj,si.rho);\n\n\t// output SVs\n\n\tint nSV = 0;\n\tint nBSV = 0;\n\tfor(int i=0;i<prob->l;i++)\n\t{\n\t\tif(fabs(alpha[i]) > 0)\n\t\t{\n\t\t\t++nSV;\n\t\t\tif(prob->y[i] > 0)\n\t\t\t{\n\t\t\t\tif(fabs(alpha[i]) >= si.upper_bound_p)\n\t\t\t\t\t++nBSV;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(fabs(alpha[i]) >= si.upper_bound_n)\n\t\t\t\t\t++nBSV;\n\t\t\t}\n\t\t}\n\t}\n\n\tinfo(\"nSV = %d, nBSV = %d\\n\",nSV,nBSV);\n\n\tdecision_function f;\n\tf.alpha = alpha;\n\tf.rho = si.rho;\n\treturn f;\n}\n\n//\n// svm_model\n//\nstruct svm_model\n{\n\tsvm_parameter param;\t// parameter\n\tint nr_class;\t\t// number of classes, = 2 in regression/one class svm\n\tint l;\t\t\t// total #SV\n\tsvm_node **SV;\t\t// SVs (SV[l])\n\tdouble **sv_coef;\t// coefficients for SVs in decision functions (sv_coef[k-1][l])\n\tdouble *rho;\t\t// constants in decision functions (rho[k*(k-1)/2])\n\tdouble *probA;          // pariwise probability information\n\tdouble *probB;\n\n\t// for classification only\n\n\tint *label;\t\t// label of each class (label[k])\n\tint *nSV;\t\t// number of SVs for each class (nSV[k])\n\t\t\t\t// nSV[0] + nSV[1] + ... + nSV[k-1] = l\n\t// XXX\n\tint free_sv;\t\t// 1 if svm_model is created by svm_load_model\n\t\t\t\t// 0 if svm_model is created by svm_train\n};\n\n// Platt's binary SVM Probablistic Output: an improvement from Lin et al.\nvoid sigmoid_train(\n\tint l, const double *dec_values, const double *labels, \n\tdouble& A, double& B)\n{\n\tdouble prior1=0, prior0 = 0;\n\tint i;\n\n\tfor (i=0;i<l;i++)\n\t\tif (labels[i] > 0) prior1+=1;\n\t\telse prior0+=1;\n\t\n\tint max_iter=100; \t// Maximal number of iterations\n\tdouble min_step=1e-10;\t// Minimal step taken in line search\n\tdouble sigma=1e-12;\t// For numerically strict PD of Hessian\n\tdouble eps=1e-5;\n\tdouble hiTarget=(prior1+1.0)/(prior1+2.0);\n\tdouble loTarget=1/(prior0+2.0);\n\tdouble *t=Malloc(double,l);\n\tdouble fApB,p,q,h11,h22,h21,g1,g2,det,dA,dB,gd,stepsize;\n\tdouble newA,newB,newf,d1,d2;\n\tint iter; \n\t\n\t// Initial Point and Initial Fun Value\n\tA=0.0; B=log((prior0+1.0)/(prior1+1.0));\n\tdouble fval = 0.0;\n\n\tfor (i=0;i<l;i++)\n\t{\n\t\tif (labels[i]>0) t[i]=hiTarget;\n\t\telse t[i]=loTarget;\n\t\tfApB = dec_values[i]*A+B;\n\t\tif (fApB>=0)\n\t\t\tfval += t[i]*fApB + log(1+exp(-fApB));\n\t\telse\n\t\t\tfval += (t[i] - 1)*fApB +log(1+exp(fApB));\n\t}\n\tfor (iter=0;iter<max_iter;iter++)\n\t{\n\t\t// Update Gradient and Hessian (use H' = H + sigma I)\n\t\th11=sigma; // numerically ensures strict PD\n\t\th22=sigma;\n\t\th21=0.0;g1=0.0;g2=0.0;\n\t\tfor (i=0;i<l;i++)\n\t\t{\n\t\t\tfApB = dec_values[i]*A+B;\n\t\t\tif (fApB >= 0)\n\t\t\t{\n\t\t\t\tp=exp(-fApB)/(1.0+exp(-fApB));\n\t\t\t\tq=1.0/(1.0+exp(-fApB));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tp=1.0/(1.0+exp(fApB));\n\t\t\t\tq=exp(fApB)/(1.0+exp(fApB));\n\t\t\t}\n\t\t\td2=p*q;\n\t\t\th11+=dec_values[i]*dec_values[i]*d2;\n\t\t\th22+=d2;\n\t\t\th21+=dec_values[i]*d2;\n\t\t\td1=t[i]-p;\n\t\t\tg1+=dec_values[i]*d1;\n\t\t\tg2+=d1;\n\t\t}\n\n\t\t// Stopping Criteria\n\t\tif (fabs(g1)<eps && fabs(g2)<eps)\n\t\t\tbreak;\n\n\t\t// Finding Newton direction: -inv(H') * g\n\t\tdet=h11*h22-h21*h21;\n\t\tdA=-(h22*g1 - h21 * g2) / det;\n\t\tdB=-(-h21*g1+ h11 * g2) / det;\n\t\tgd=g1*dA+g2*dB;\n\n\n\t\tstepsize = 1; \t\t// Line Search\n\t\twhile (stepsize >= min_step)\n\t\t{\n\t\t\tnewA = A + stepsize * dA;\n\t\t\tnewB = B + stepsize * dB;\n\n\t\t\t// New function value\n\t\t\tnewf = 0.0;\n\t\t\tfor (i=0;i<l;i++)\n\t\t\t{\n\t\t\t\tfApB = dec_values[i]*newA+newB;\n\t\t\t\tif (fApB >= 0)\n\t\t\t\t\tnewf += t[i]*fApB + log(1+exp(-fApB));\n\t\t\t\telse\n\t\t\t\t\tnewf += (t[i] - 1)*fApB +log(1+exp(fApB));\n\t\t\t}\n\t\t\t// Check sufficient decrease\n\t\t\tif (newf<fval+0.0001*stepsize*gd)\n\t\t\t{\n\t\t\t\tA=newA;B=newB;fval=newf;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse\n\t\t\t\tstepsize = stepsize / 2.0;\n\t\t}\n\n\t\tif (stepsize < min_step)\n\t\t{\n\t\t\tinfo(\"Line search fails in two-class probability estimates\\n\");\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (iter>=max_iter)\n\t\tinfo(\"Reaching maximal iterations in two-class probability estimates\\n\");\n\tfree(t);\n}\n\ndouble sigmoid_predict(double decision_value, double A, double B)\n{\n\tdouble fApB = decision_value*A+B;\n\tif (fApB >= 0)\n\t\treturn exp(-fApB)/(1.0+exp(-fApB));\n\telse\n\t\treturn 1.0/(1+exp(fApB)) ;\n}\n\n// Method 2 from the multiclass_prob paper by Wu, Lin, and Weng\nvoid multiclass_probability(int k, double **r, double *p)\n{\n\tint t,j;\n\tint iter = 0, max_iter=max(100,k);\n\tdouble **Q=Malloc(double *,k);\n\tdouble *Qp=Malloc(double,k);\n\tdouble pQp, eps=0.005/k;\n\t\n\tfor (t=0;t<k;t++)\n\t{\n\t\tp[t]=1.0/k;  // Valid if k = 1\n\t\tQ[t]=Malloc(double,k);\n\t\tQ[t][t]=0;\n\t\tfor (j=0;j<t;j++)\n\t\t{\n\t\t\tQ[t][t]+=r[j][t]*r[j][t];\n\t\t\tQ[t][j]=Q[j][t];\n\t\t}\n\t\tfor (j=t+1;j<k;j++)\n\t\t{\n\t\t\tQ[t][t]+=r[j][t]*r[j][t];\n\t\t\tQ[t][j]=-r[j][t]*r[t][j];\n\t\t}\n\t}\n\tfor (iter=0;iter<max_iter;iter++)\n\t{\n\t\t// stopping condition, recalculate QP,pQP for numerical accuracy\n\t\tpQp=0;\n\t\tfor (t=0;t<k;t++)\n\t\t{\n\t\t\tQp[t]=0;\n\t\t\tfor (j=0;j<k;j++)\n\t\t\t\tQp[t]+=Q[t][j]*p[j];\n\t\t\tpQp+=p[t]*Qp[t];\n\t\t}\n\t\tdouble max_error=0;\n\t\tfor (t=0;t<k;t++)\n\t\t{\n\t\t\tdouble error=fabs(Qp[t]-pQp);\n\t\t\tif (error>max_error)\n\t\t\t\tmax_error=error;\n\t\t}\n\t\tif (max_error<eps) break;\n\t\t\n\t\tfor (t=0;t<k;t++)\n\t\t{\n\t\t\tdouble diff=(-Qp[t]+pQp)/Q[t][t];\n\t\t\tp[t]+=diff;\n\t\t\tpQp=(pQp+diff*(diff*Q[t][t]+2*Qp[t]))/(1+diff)/(1+diff);\n\t\t\tfor (j=0;j<k;j++)\n\t\t\t{\n\t\t\t\tQp[j]=(Qp[j]+diff*Q[t][j])/(1+diff);\n\t\t\t\tp[j]/=(1+diff);\n\t\t\t}\n\t\t}\n\t}\n\tif (iter>=max_iter)\n\t\tinfo(\"Exceeds max_iter in multiclass_prob\\n\");\n\tfor(t=0;t<k;t++) free(Q[t]);\n\tfree(Q);\n\tfree(Qp);\n}\n\n// Cross-validation decision values for probability estimates\nvoid svm_binary_svc_probability(\n\tconst svm_problem *prob, const svm_parameter *param,\n\tdouble Cp, double Cn, double& probA, double& probB)\n{\n\tint i;\n\tint nr_fold = 5;\n\tint *perm = Malloc(int,prob->l);\n\tdouble *dec_values = Malloc(double,prob->l);\n\n\t// random shuffle\n\tfor(i=0;i<prob->l;i++) perm[i]=i;\n\tfor(i=0;i<prob->l;i++)\n\t{\n\t\tint j = i+rand()%(prob->l-i);\n\t\tswap(perm[i],perm[j]);\n\t}\n\tfor(i=0;i<nr_fold;i++)\n\t{\n\t\tint begin = i*prob->l/nr_fold;\n\t\tint end = (i+1)*prob->l/nr_fold;\n\t\tint j,k;\n\t\tstruct svm_problem subprob;\n\n\t\tsubprob.l = prob->l-(end-begin);\n\t\tsubprob.x = Malloc(struct svm_node*,subprob.l);\n\t\tsubprob.y = Malloc(double,subprob.l);\n\t\t\t\n\t\tk=0;\n\t\tfor(j=0;j<begin;j++)\n\t\t{\n\t\t\tsubprob.x[k] = prob->x[perm[j]];\n\t\t\tsubprob.y[k] = prob->y[perm[j]];\n\t\t\t++k;\n\t\t}\n\t\tfor(j=end;j<prob->l;j++)\n\t\t{\n\t\t\tsubprob.x[k] = prob->x[perm[j]];\n\t\t\tsubprob.y[k] = prob->y[perm[j]];\n\t\t\t++k;\n\t\t}\n\t\tint p_count=0,n_count=0;\n\t\tfor(j=0;j<k;j++)\n\t\t\tif(subprob.y[j]>0)\n\t\t\t\tp_count++;\n\t\t\telse\n\t\t\t\tn_count++;\n\n\t\tif(p_count==0 && n_count==0)\n\t\t\tfor(j=begin;j<end;j++)\n\t\t\t\tdec_values[perm[j]] = 0;\n\t\telse if(p_count > 0 && n_count == 0)\n\t\t\tfor(j=begin;j<end;j++)\n\t\t\t\tdec_values[perm[j]] = 1;\n\t\telse if(p_count == 0 && n_count > 0)\n\t\t\tfor(j=begin;j<end;j++)\n\t\t\t\tdec_values[perm[j]] = -1;\n\t\telse\n\t\t{\n\t\t\tsvm_parameter subparam = *param;\n\t\t\tsubparam.probability=0;\n\t\t\tsubparam.C=1.0;\n\t\t\tsubparam.nr_weight=2;\n\t\t\tsubparam.weight_label = Malloc(int,2);\n\t\t\tsubparam.weight = Malloc(double,2);\n\t\t\tsubparam.weight_label[0]=+1;\n\t\t\tsubparam.weight_label[1]=-1;\n\t\t\tsubparam.weight[0]=Cp;\n\t\t\tsubparam.weight[1]=Cn;\n\t\t\tstruct svm_model *submodel = svm_train(&subprob,&subparam);\n\t\t\tfor(j=begin;j<end;j++)\n\t\t\t{\n\t\t\t\tsvm_predict_values(submodel,prob->x[perm[j]],&(dec_values[perm[j]])); \n\t\t\t\t// ensure +1 -1 order; reason not using CV subroutine\n\t\t\t\tdec_values[perm[j]] *= submodel->label[0];\n\t\t\t}\t\t\n\t\t\tsvm_destroy_model(submodel);\n\t\t\tsvm_destroy_param(&subparam);\n\t\t}\n\t\tfree(subprob.x);\n\t\tfree(subprob.y);\n\t}\t\t\n\tsigmoid_train(prob->l,dec_values,prob->y,probA,probB);\n\tfree(dec_values);\n\tfree(perm);\n}\n\n// Return parameter of a Laplace distribution \ndouble svm_svr_probability(\n\tconst svm_problem *prob, const svm_parameter *param)\n{\n\tint i;\n\tint nr_fold = 5;\n\tdouble *ymv = Malloc(double,prob->l);\n\tdouble mae = 0;\n\n\tsvm_parameter newparam = *param;\n\tnewparam.probability = 0;\n\tsvm_cross_validation(prob,&newparam,nr_fold,ymv);\n\tfor(i=0;i<prob->l;i++)\n\t{\n\t\tymv[i]=prob->y[i]-ymv[i];\n\t\tmae += fabs(ymv[i]);\n\t}\t\t\n\tmae /= prob->l;\n\tdouble std=sqrt(2*mae*mae);\n\tint count=0;\n\tmae=0;\n\tfor(i=0;i<prob->l;i++)\n\t        if (fabs(ymv[i]) > 5*std) \n                        count=count+1;\n\t\telse \n\t\t        mae+=fabs(ymv[i]);\n\tmae /= (prob->l-count);\n\tinfo(\"Prob. model for test data: target value = predicted value + z,\\nz: Laplace distribution e^(-|z|/sigma)/(2sigma),sigma= %g\\n\",mae);\n\tfree(ymv);\n\treturn mae;\n}\n\n\n// label: label name, start: begin of each class, count: #data of classes, perm: indices to the original data\n// perm, length l, must be allocated before calling this subroutine\nvoid svm_group_classes(const svm_problem *prob, int *nr_class_ret, int **label_ret, int **start_ret, int **count_ret, int *perm)\n{\n\tint l = prob->l;\n\tint max_nr_class = 16;\n\tint nr_class = 0;\n\tint *label = Malloc(int,max_nr_class);\n\tint *count = Malloc(int,max_nr_class);\n\tint *data_label = Malloc(int,l);\t\n\tint i;\n\n\tfor(i=0;i<l;i++)\n\t{\n\t\tint this_label = (int)prob->y[i];\n\t\tint j;\n\t\tfor(j=0;j<nr_class;j++)\n\t\t{\n\t\t\tif(this_label == label[j])\n\t\t\t{\n\t\t\t\t++count[j];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tdata_label[i] = j;\n\t\tif(j == nr_class)\n\t\t{\n\t\t\tif(nr_class == max_nr_class)\n\t\t\t{\n\t\t\t\tmax_nr_class *= 2;\n\t\t\t\tlabel = (int *)realloc(label,max_nr_class*sizeof(int));\n\t\t\t\tcount = (int *)realloc(count,max_nr_class*sizeof(int));\n\t\t\t}\n\t\t\tlabel[nr_class] = this_label;\n\t\t\tcount[nr_class] = 1;\n\t\t\t++nr_class;\n\t\t}\n\t}\n\n\tint *start = Malloc(int,nr_class);\n\tstart[0] = 0;\n\tfor(i=1;i<nr_class;i++)\n\t\tstart[i] = start[i-1]+count[i-1];\n\tfor(i=0;i<l;i++)\n\t{\n\t\tperm[start[data_label[i]]] = i;\n\t\t++start[data_label[i]];\n\t}\n\tstart[0] = 0;\n\tfor(i=1;i<nr_class;i++)\n\t\tstart[i] = start[i-1]+count[i-1];\n\n\t*nr_class_ret = nr_class;\n\t*label_ret = label;\n\t*start_ret = start;\n\t*count_ret = count;\n\tfree(data_label);\n}\n\n//\n// Interface functions\n//\nsvm_model *svm_train(const svm_problem *prob, const svm_parameter *param)\n{\n\tsvm_model *model = Malloc(svm_model,1);\n\tmodel->param = *param;\n\tmodel->free_sv = 0;\t// XXX\n\n\tif(param->svm_type == ONE_CLASS ||\n\t   param->svm_type == EPSILON_SVR ||\n\t   param->svm_type == NU_SVR)\n\t{\n\t\t// regression or one-class-svm\n\t\tmodel->nr_class = 2;\n\t\tmodel->label = NULL;\n\t\tmodel->nSV = NULL;\n\t\tmodel->probA = NULL; model->probB = NULL;\n\t\tmodel->sv_coef = Malloc(double *,1);\n\n\t\tif(param->probability && \n\t\t   (param->svm_type == EPSILON_SVR ||\n\t\t    param->svm_type == NU_SVR))\n\t\t{\n\t\t\tmodel->probA = Malloc(double,1);\n\t\t\tmodel->probA[0] = svm_svr_probability(prob,param);\n\t\t}\n\n\t\tdecision_function f = svm_train_one(prob,param,0,0);\n\t\tmodel->rho = Malloc(double,1);\n\t\tmodel->rho[0] = f.rho;\n\n\t\tint nSV = 0;\n\t\tint i;\n\t\tfor(i=0;i<prob->l;i++)\n\t\t\tif(fabs(f.alpha[i]) > 0) ++nSV;\n\t\tmodel->l = nSV;\n\t\tmodel->SV = Malloc(svm_node *,nSV);\n\t\tmodel->sv_coef[0] = Malloc(double,nSV);\n\t\tint j = 0;\n\t\tfor(i=0;i<prob->l;i++)\n\t\t\tif(fabs(f.alpha[i]) > 0)\n\t\t\t{\n\t\t\t\tmodel->SV[j] = prob->x[i];\n\t\t\t\tmodel->sv_coef[0][j] = f.alpha[i];\n\t\t\t\t++j;\n\t\t\t}\t\t\n\n\t\tfree(f.alpha);\n\t}\n\telse\n\t{\n\t\t// classification\n\t\tint l = prob->l;\n\t\tint nr_class;\n\t\tint *label = NULL;\n\t\tint *start = NULL;\n\t\tint *count = NULL;\n\t\tint *perm = Malloc(int,l);\n\n\t\t// group training data of the same class\n\t\tsvm_group_classes(prob,&nr_class,&label,&start,&count,perm);\t\t\n\t\tsvm_node **x = Malloc(svm_node *,l);\n\t\tint i;\n\t\tfor(i=0;i<l;i++)\n\t\t\tx[i] = prob->x[perm[i]];\n\n\t\t// calculate weighted C\n\n\t\tdouble *weighted_C = Malloc(double, nr_class);\n\t\tfor(i=0;i<nr_class;i++)\n\t\t\tweighted_C[i] = param->C;\n\t\tfor(i=0;i<param->nr_weight;i++)\n\t\t{\t\n\t\t\tint j;\n\t\t\tfor(j=0;j<nr_class;j++)\n\t\t\t\tif(param->weight_label[i] == label[j])\n\t\t\t\t\tbreak;\n\t\t\tif(j == nr_class)\n\t\t\t\tfprintf(stderr,\"warning: class label %d specified in weight is not found\\n\", param->weight_label[i]);\n\t\t\telse\n\t\t\t\tweighted_C[j] *= param->weight[i];\n\t\t}\n\n\t\t// train k*(k-1)/2 models\n\t\t\n\t\tbool *nonzero = Malloc(bool,l);\n\t\tfor(i=0;i<l;i++)\n\t\t\tnonzero[i] = false;\n\t\tdecision_function *f = Malloc(decision_function,nr_class*(nr_class-1)/2);\n\n\t\tdouble *probA=NULL,*probB=NULL;\n\t\tif (param->probability)\n\t\t{\n\t\t\tprobA=Malloc(double,nr_class*(nr_class-1)/2);\n\t\t\tprobB=Malloc(double,nr_class*(nr_class-1)/2);\n\t\t}\n\n\t\tint p = 0;\n\t\tfor(i=0;i<nr_class;i++)\n\t\t\tfor(int j=i+1;j<nr_class;j++)\n\t\t\t{\n\t\t\t\tsvm_problem sub_prob;\n\t\t\t\tint si = start[i], sj = start[j];\n\t\t\t\tint ci = count[i], cj = count[j];\n\t\t\t\tsub_prob.l = ci+cj;\n\t\t\t\tsub_prob.x = Malloc(svm_node *,sub_prob.l);\n\t\t\t\tsub_prob.y = Malloc(double,sub_prob.l);\n\t\t\t\tint k;\n\t\t\t\tfor(k=0;k<ci;k++)\n\t\t\t\t{\n\t\t\t\t\tsub_prob.x[k] = x[si+k];\n\t\t\t\t\tsub_prob.y[k] = +1;\n\t\t\t\t}\n\t\t\t\tfor(k=0;k<cj;k++)\n\t\t\t\t{\n\t\t\t\t\tsub_prob.x[ci+k] = x[sj+k];\n\t\t\t\t\tsub_prob.y[ci+k] = -1;\n\t\t\t\t}\n\n\t\t\t\tif(param->probability)\n\t\t\t\t\tsvm_binary_svc_probability(&sub_prob,param,weighted_C[i],weighted_C[j],probA[p],probB[p]);\n\n\t\t\t\tf[p] = svm_train_one(&sub_prob,param,weighted_C[i],weighted_C[j]);\n\t\t\t\tfor(k=0;k<ci;k++)\n\t\t\t\t\tif(!nonzero[si+k] && fabs(f[p].alpha[k]) > 0)\n\t\t\t\t\t\tnonzero[si+k] = true;\n\t\t\t\tfor(k=0;k<cj;k++)\n\t\t\t\t\tif(!nonzero[sj+k] && fabs(f[p].alpha[ci+k]) > 0)\n\t\t\t\t\t\tnonzero[sj+k] = true;\n\t\t\t\tfree(sub_prob.x);\n\t\t\t\tfree(sub_prob.y);\n\t\t\t\t++p;\n\t\t\t}\n\n\t\t// build output\n\n\t\tmodel->nr_class = nr_class;\n\t\t\n\t\tmodel->label = Malloc(int,nr_class);\n\t\tfor(i=0;i<nr_class;i++)\n\t\t\tmodel->label[i] = label[i];\n\t\t\n\t\tmodel->rho = Malloc(double,nr_class*(nr_class-1)/2);\n\t\tfor(i=0;i<nr_class*(nr_class-1)/2;i++)\n\t\t\tmodel->rho[i] = f[i].rho;\n\n\t\tif(param->probability)\n\t\t{\n\t\t\tmodel->probA = Malloc(double,nr_class*(nr_class-1)/2);\n\t\t\tmodel->probB = Malloc(double,nr_class*(nr_class-1)/2);\n\t\t\tfor(i=0;i<nr_class*(nr_class-1)/2;i++)\n\t\t\t{\n\t\t\t\tmodel->probA[i] = probA[i];\n\t\t\t\tmodel->probB[i] = probB[i];\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tmodel->probA=NULL;\n\t\t\tmodel->probB=NULL;\n\t\t}\n\n\t\tint total_sv = 0;\n\t\tint *nz_count = Malloc(int,nr_class);\n\t\tmodel->nSV = Malloc(int,nr_class);\n\t\tfor(i=0;i<nr_class;i++)\n\t\t{\n\t\t\tint nSV = 0;\n\t\t\tfor(int j=0;j<count[i];j++)\n\t\t\t\tif(nonzero[start[i]+j])\n\t\t\t\t{\t\n\t\t\t\t\t++nSV;\n\t\t\t\t\t++total_sv;\n\t\t\t\t}\n\t\t\tmodel->nSV[i] = nSV;\n\t\t\tnz_count[i] = nSV;\n\t\t}\n\t\t\n\t\tinfo(\"Total nSV = %d\\n\",total_sv);\n\n\t\tmodel->l = total_sv;\n\t\tmodel->SV = Malloc(svm_node *,total_sv);\n\t\tp = 0;\n\t\tfor(i=0;i<l;i++)\n\t\t\tif(nonzero[i]) model->SV[p++] = x[i];\n\n\t\tint *nz_start = Malloc(int,nr_class);\n\t\tnz_start[0] = 0;\n\t\tfor(i=1;i<nr_class;i++)\n\t\t\tnz_start[i] = nz_start[i-1]+nz_count[i-1];\n\n\t\tmodel->sv_coef = Malloc(double *,nr_class-1);\n\t\tfor(i=0;i<nr_class-1;i++)\n\t\t\tmodel->sv_coef[i] = Malloc(double,total_sv);\n\n\t\tp = 0;\n\t\tfor(i=0;i<nr_class;i++)\n\t\t\tfor(int j=i+1;j<nr_class;j++)\n\t\t\t{\n\t\t\t\t// classifier (i,j): coefficients with\n\t\t\t\t// i are in sv_coef[j-1][nz_start[i]...],\n\t\t\t\t// j are in sv_coef[i][nz_start[j]...]\n\n\t\t\t\tint si = start[i];\n\t\t\t\tint sj = start[j];\n\t\t\t\tint ci = count[i];\n\t\t\t\tint cj = count[j];\n\t\t\t\t\n\t\t\t\tint q = nz_start[i];\n\t\t\t\tint k;\n\t\t\t\tfor(k=0;k<ci;k++)\n\t\t\t\t\tif(nonzero[si+k])\n\t\t\t\t\t\tmodel->sv_coef[j-1][q++] = f[p].alpha[k];\n\t\t\t\tq = nz_start[j];\n\t\t\t\tfor(k=0;k<cj;k++)\n\t\t\t\t\tif(nonzero[sj+k])\n\t\t\t\t\t\tmodel->sv_coef[i][q++] = f[p].alpha[ci+k];\n\t\t\t\t++p;\n\t\t\t}\n\t\t\n\t\tfree(label);\n\t\tfree(probA);\n\t\tfree(probB);\n\t\tfree(count);\n\t\tfree(perm);\n\t\tfree(start);\n\t\tfree(x);\n\t\tfree(weighted_C);\n\t\tfree(nonzero);\n\t\tfor(i=0;i<nr_class*(nr_class-1)/2;i++)\n\t\t\tfree(f[i].alpha);\n\t\tfree(f);\n\t\tfree(nz_count);\n\t\tfree(nz_start);\n\t}\n\treturn model;\n}\n\n// Stratified cross validation\nvoid svm_cross_validation(const svm_problem *prob, const svm_parameter *param, int nr_fold, double *target)\n{\n\tint i;\n\tint *fold_start = Malloc(int,nr_fold+1);\n\tint l = prob->l;\n\tint *perm = Malloc(int,l);\n\tint nr_class;\n\n\t// stratified cv may not give leave-one-out rate\n\t// Each class to l folds -> some folds may have zero elements\n\tif((param->svm_type == C_SVC ||\n\t    param->svm_type == NU_SVC) && nr_fold < l)\n\t{\n\t\tint *start = NULL;\n\t\tint *label = NULL;\n\t\tint *count = NULL;\n\t\tsvm_group_classes(prob,&nr_class,&label,&start,&count,perm);\n\n\t\t// random shuffle and then data grouped by fold using the array perm\n\t\tint *fold_count = Malloc(int,nr_fold);\n\t\tint c;\n\t\tint *index = Malloc(int,l);\n\t\tfor(i=0;i<l;i++)\n\t\t\tindex[i]=perm[i];\n\t\tfor (c=0; c<nr_class; c++) \n\t\t\tfor(i=0;i<count[c];i++)\n\t\t\t{\n\t\t\t\tint j = i+rand()%(count[c]-i);\n\t\t\t\tswap(index[start[c]+j],index[start[c]+i]);\n\t\t\t}\n\t\tfor(i=0;i<nr_fold;i++)\n\t\t{\n\t\t\tfold_count[i] = 0;\n\t\t\tfor (c=0; c<nr_class;c++)\n\t\t\t\tfold_count[i]+=(i+1)*count[c]/nr_fold-i*count[c]/nr_fold;\n\t\t}\n\t\tfold_start[0]=0;\n\t\tfor (i=1;i<=nr_fold;i++)\n\t\t\tfold_start[i] = fold_start[i-1]+fold_count[i-1];\n\t\tfor (c=0; c<nr_class;c++)\n\t\t\tfor(i=0;i<nr_fold;i++)\n\t\t\t{\n\t\t\t\tint begin = start[c]+i*count[c]/nr_fold;\n\t\t\t\tint end = start[c]+(i+1)*count[c]/nr_fold;\n\t\t\t\tfor(int j=begin;j<end;j++)\n\t\t\t\t{\n\t\t\t\t\tperm[fold_start[i]] = index[j];\n\t\t\t\t\tfold_start[i]++;\n\t\t\t\t}\n\t\t\t}\n\t\tfold_start[0]=0;\n\t\tfor (i=1;i<=nr_fold;i++)\n\t\t\tfold_start[i] = fold_start[i-1]+fold_count[i-1];\n\t\tfree(start);\t\n\t\tfree(label);\n\t\tfree(count);\t\n\t\tfree(index);\n\t\tfree(fold_count);\n\t}\n\telse\n\t{\n\t\tfor(i=0;i<l;i++) perm[i]=i;\n\t\tfor(i=0;i<l;i++)\n\t\t{\n\t\t\tint j = i+rand()%(l-i);\n\t\t\tswap(perm[i],perm[j]);\n\t\t}\n\t\tfor(i=0;i<=nr_fold;i++)\n\t\t\tfold_start[i]=i*l/nr_fold;\n\t}\n\n\tfor(i=0;i<nr_fold;i++)\n\t{\n\t\tint begin = fold_start[i];\n\t\tint end = fold_start[i+1];\n\t\tint j,k;\n\t\tstruct svm_problem subprob;\n\n\t\tsubprob.l = l-(end-begin);\n\t\tsubprob.x = Malloc(struct svm_node*,subprob.l);\n\t\tsubprob.y = Malloc(double,subprob.l);\n\t\t\t\n\t\tk=0;\n\t\tfor(j=0;j<begin;j++)\n\t\t{\n\t\t\tsubprob.x[k] = prob->x[perm[j]];\n\t\t\tsubprob.y[k] = prob->y[perm[j]];\n\t\t\t++k;\n\t\t}\n\t\tfor(j=end;j<l;j++)\n\t\t{\n\t\t\tsubprob.x[k] = prob->x[perm[j]];\n\t\t\tsubprob.y[k] = prob->y[perm[j]];\n\t\t\t++k;\n\t\t}\n\t\tstruct svm_model *submodel = svm_train(&subprob,param);\n\t\tif(param->probability && \n\t\t   (param->svm_type == C_SVC || param->svm_type == NU_SVC))\n\t\t{\n\t\t\tdouble *prob_estimates=Malloc(double,svm_get_nr_class(submodel));\n\t\t\tfor(j=begin;j<end;j++)\n\t\t\t\ttarget[perm[j]] = svm_predict_probability(submodel,prob->x[perm[j]],prob_estimates);\n\t\t\tfree(prob_estimates);\t\t\t\n\t\t}\n\t\telse\n\t\t\tfor(j=begin;j<end;j++)\n\t\t\t\ttarget[perm[j]] = svm_predict(submodel,prob->x[perm[j]]);\n\t\tsvm_destroy_model(submodel);\n\t\tfree(subprob.x);\n\t\tfree(subprob.y);\n\t}\t\t\n\tfree(fold_start);\n\tfree(perm);\t\n}\n\n\nint svm_get_svm_type(const svm_model *model)\n{\n\treturn model->param.svm_type;\n}\n\n/*** new function **/\nint svm_get_sv_size(const svm_model *model)\n{\n  long i=0;\n  if (model->l > 0) {\n    while (model->SV[0][i].index != -1) { i++; }\n    return model->SV[0][i - 1].index;\n  } else {\n    return 0;\n  }\n}\n/** end new function **/\n\nint svm_get_nr_class(const svm_model *model)\n{\n\treturn model->nr_class;\n}\n\nvoid svm_get_labels(const svm_model *model, int* label)\n{\n\tif (model->label != NULL)\n\t\tfor(int i=0;i<model->nr_class;i++)\n\t\t\tlabel[i] = model->label[i];\n}\n\ndouble svm_get_svr_probability(const svm_model *model)\n{\n\tif ((model->param.svm_type == EPSILON_SVR || model->param.svm_type == NU_SVR) &&\n\t    model->probA!=NULL)\n\t\treturn model->probA[0];\n\telse\n\t{\n\t\tinfo(\"Model doesn't contain information for SVR probability inference\\n\");\n\t\treturn 0;\n\t}\n}\n\nvoid svm_predict_values(const svm_model *model, const svm_node *x, double* dec_values)\n{\n\tif(model->param.svm_type == ONE_CLASS ||\n\t   model->param.svm_type == EPSILON_SVR ||\n\t   model->param.svm_type == NU_SVR)\n\t{\n\t\tdouble *sv_coef = model->sv_coef[0];\n\t\tdouble sum = 0;\n\t\tfor(int i=0;i<model->l;i++)\n\t\t\tsum += sv_coef[i] * Kernel::k_function(x,model->SV[i],model->param);\n\t\tsum -= model->rho[0];\n\t\t*dec_values = sum;\n\t}\n\telse\n\t{\n\t\tint i;\n\t\tint nr_class = model->nr_class;\n\t\tint l = model->l;\n\t\t\n\t\tdouble *kvalue = Malloc(double,l);\n\t\tfor(i=0;i<l;i++)\n\t\t\tkvalue[i] = Kernel::k_function(x,model->SV[i],model->param);\n\n\t\tint *start = Malloc(int,nr_class);\n\t\tstart[0] = 0;\n\t\tfor(i=1;i<nr_class;i++)\n\t\t\tstart[i] = start[i-1]+model->nSV[i-1];\n\n\t\tint p=0;\n\t\tfor(i=0;i<nr_class;i++)\n\t\t\tfor(int j=i+1;j<nr_class;j++)\n\t\t\t{\n\t\t\t\tdouble sum = 0;\n\t\t\t\tint si = start[i];\n\t\t\t\tint sj = start[j];\n\t\t\t\tint ci = model->nSV[i];\n\t\t\t\tint cj = model->nSV[j];\n\t\t\t\t\n\t\t\t\tint k;\n\t\t\t\tdouble *coef1 = model->sv_coef[j-1];\n\t\t\t\tdouble *coef2 = model->sv_coef[i];\n\t\t\t\tfor(k=0;k<ci;k++)\n\t\t\t\t\tsum += coef1[si+k] * kvalue[si+k];\n\t\t\t\tfor(k=0;k<cj;k++)\n\t\t\t\t\tsum += coef2[sj+k] * kvalue[sj+k];\n\t\t\t\tsum -= model->rho[p];\n\t\t\t\tdec_values[p] = sum;\n\t\t\t\tp++;\n\t\t\t}\n\n\t\tfree(kvalue);\n\t\tfree(start);\n\t}\n}\n\ndouble svm_predict(const svm_model *model, const svm_node *x)\n{\n\tif(model->param.svm_type == ONE_CLASS ||\n\t   model->param.svm_type == EPSILON_SVR ||\n\t   model->param.svm_type == NU_SVR)\n\t{\n\t\tdouble res;\n\t\tsvm_predict_values(model, x, &res);\n\t\t\n\t\tif(model->param.svm_type == ONE_CLASS)\n\t\t\treturn (res>0)?1:-1;\n\t\telse\n\t\t\treturn res;\n\t}\n\telse\n\t{\n\t\tint i;\n\t\tint nr_class = model->nr_class;\n\t\tdouble *dec_values = Malloc(double, nr_class*(nr_class-1)/2);\n\t\tsvm_predict_values(model, x, dec_values);\n\n\t\tint *vote = Malloc(int,nr_class);\n\t\tfor(i=0;i<nr_class;i++)\n\t\t\tvote[i] = 0;\n\t\tint pos=0;\n\t\tfor(i=0;i<nr_class;i++)\n\t\t\tfor(int j=i+1;j<nr_class;j++)\n\t\t\t{\n\t\t\t\tif(dec_values[pos++] > 0)\n\t\t\t\t\t++vote[i];\n\t\t\t\telse\n\t\t\t\t\t++vote[j];\n\t\t\t}\n\n\t\tint vote_max_idx = 0;\n\t\tfor(i=1;i<nr_class;i++)\n\t\t\tif(vote[i] > vote[vote_max_idx])\n\t\t\t\tvote_max_idx = i;\n\t\tfree(vote);\n\t\tfree(dec_values);\n\t\treturn model->label[vote_max_idx];\n\t}\n}\n\ndouble svm_predict_probability(\n\tconst svm_model *model, const svm_node *x, double *prob_estimates)\n{\n\tif ((model->param.svm_type == C_SVC || model->param.svm_type == NU_SVC) &&\n\t    model->probA!=NULL && model->probB!=NULL)\n\t{\n\t\tint i;\n\t\tint nr_class = model->nr_class;\n\t\tdouble *dec_values = Malloc(double, nr_class*(nr_class-1)/2);\n\t\tsvm_predict_values(model, x, dec_values);\n\n\t\tdouble min_prob=1e-7;\n\t\tdouble **pairwise_prob=Malloc(double *,nr_class);\n\t\tfor(i=0;i<nr_class;i++)\n\t\t\tpairwise_prob[i]=Malloc(double,nr_class);\n\t\tint k=0;\n\t\tfor(i=0;i<nr_class;i++)\n\t\t\tfor(int j=i+1;j<nr_class;j++)\n\t\t\t{\n\t\t\t\tpairwise_prob[i][j]=min(max(sigmoid_predict(dec_values[k],model->probA[k],model->probB[k]),min_prob),1-min_prob);\n\t\t\t\tpairwise_prob[j][i]=1-pairwise_prob[i][j];\n\t\t\t\tk++;\n\t\t\t}\n\t\tmulticlass_probability(nr_class,pairwise_prob,prob_estimates);\n\n\t\tint prob_max_idx = 0;\n\t\tfor(i=1;i<nr_class;i++)\n\t\t\tif(prob_estimates[i] > prob_estimates[prob_max_idx])\n\t\t\t\tprob_max_idx = i;\n\t\tfor(i=0;i<nr_class;i++)\n\t\t\tfree(pairwise_prob[i]);\n\t\tfree(dec_values);\n                free(pairwise_prob);\t     \n\t\treturn model->label[prob_max_idx];\n\t}\n\telse \n\t\treturn svm_predict(model, x);\n}\n\nconst char *svm_type_table[] =\n{\n\t\"c_svc\",\"nu_svc\",\"one_class\",\"epsilon_svr\",\"nu_svr\",NULL\n};\n\nconst char *kernel_type_table[]=\n{\n\t\"linear\",\"polynomial\",\"rbf\",\"sigmoid\",\"precomputed\",NULL\n};\n\n\n/****** begin functions for loading/saving binary models *******************/\n/*\nThese functions were added to LibSVM by Florian Eyben. \nCopyright 2009, Florian Eyben. All rights reserved.\n*/\n\n\n/*\nWe need a separate struct in order to convert the ints to integers of fixed width (32-bit)\nin order for the saved models to be platform independent!\nTODO: Lt-endian/Bg-endian compatibility..?\n*/\n\nstruct svm_node_bin\n{\n  int32_t index;\n  float   value;\n};\n\nstruct svm_parameter_bin\n{\n  int32_t svm_type;\n  int32_t kernel_type;\n  int32_t degree;     /* for poly */\n  int32_t dummy ;   // <-- we need to pad the struct to a multiple of 8 byte for proper alignment for 32 <-> 64 bit compatibility\n  double gamma;   /* for poly/rbf/sigmoid */\n  double coef0;   /* for poly/sigmoid */\n};\n\nstruct svm_model_bin\n{\n  char magic[8];  /* constant identifier: LibSVMbm  = LibSVM binary model */\n\n  svm_parameter_bin param;    // parameter\n  int32_t nr_class;           // number of classes, = 2 in regression/one class svm\n  int32_t l;                  // total #SV\n\n  int32_t rho;            //offset of double *   constants in decision functions (rho[k*(k-1)/2])\n  int32_t probA;          //offset of double *   pariwise probability information\n  int32_t probB;          //offset of double *\n\n  // for classification only\n\n  int32_t label;             //offset of int32_t *   label of each class (label[k])\n  int32_t nSV;               //offset of int32_t*    number of SVs for each class (nSV[k])\n\n  int32_t SVsize;\n  int32_t SV;          // SVs (SV[l])\n  int32_t sv_coef;       // coefficients for SVs in decision functions (sv_coef[k-1][l])\n  // nSV[0] + nSV[1] + ... + nSV[k-1] = l\n};\n\ninline int32_t binsave_intConv(int machine)\n{\n  return (int32_t)machine;\n}\n\ninline double binsave_doubleConv(double machine)\n{\n  return (double)machine;\n}\n\ninline float binsave_floatConv(double machine)\n{\n  return (float)machine;\n}\n\ninline int32_t binsave_ptrConv(int value)\n{\n  return (int32_t)value;\n}\n\ninline svm_node_bin binsave_nodeConv(svm_node &node)\n{\n  svm_node_bin ret;\n  ret.index = binsave_intConv(node.index);\n  ret.value = binsave_floatConv(node.value);\n  return ret;\n}\n\ninline int binload_intConv(int32_t data)\n{\n  return (int)data;\n}\n\ninline double binload_doubleConv(double data)\n{\n  return (double)data;\n}\n\ninline double binload_floatConv(float data)\n{\n  return (double)data;\n}\n\ninline void * binload_ptrConv(int32_t value, void * offset = NULL)\n{\n  return (void*)( (char*)offset + value );\n}\n\ninline int saveDoubleAsFloat(double *x, int n, FILE * fp)\n{\n  int i;\n  float * y = Malloc(float, n);\n  for (i=0; i<n; i++) y[i] = (float)(x[i]);\n  i = (int)fwrite(y, n, sizeof(float), fp);\n  free(y);\n  return i;\n}\n\ndouble * floatArrToDouble(void *pool, int32_t offset, int n)\n{\n\tint i;\n\tdouble * d = Malloc(double, n);\n\tfloat * f  = (float *)((char*)pool + offset);\n\tfor (i=0; i<n; i++) { d[i] = binload_floatConv(f[i]); }\n\treturn d;\n}\n\nint svm_save_binary_model(const char *model_file_name, const svm_model *model)\n{\n\tFILE *fp = fopen(model_file_name,\"wb\");\n\tif(fp==NULL) return -1;\n\n  int nr_class = model->nr_class;\n\tint n = nr_class*(nr_class-1)/2;\n\tint l = model->l;\n\n\tstruct svm_model_bin model_bin;\n\n\t// compute size of SV data to save\n\tlong size = 0;\n\t\n\tif (model->param.kernel_type == PRECOMPUTED) \n           size = l*sizeof(struct svm_node);\n\telse {\n\t\tfor(int i=0;i<l;i++)\n\t\t{\n\t\t\tconst svm_node *p = model->SV[i];\n\t\t\twhile(p->index != -1)\n\t\t\t{\n\t\t\t\tp++; size++;\n\t\t\t}\n\t\t\tsize++; // count the '-1' element!?\n\t\t}\n\t}\n\n  //printf(\"binsize: %i\\n\",sizeof(struct svm_model_bin));\t\n\t// convert model to model_bin, adjust pointers in model_bin to relative pointers\n\tmodel_bin.param.svm_type = binsave_intConv(model->param.svm_type);\n\tmodel_bin.param.kernel_type = binsave_intConv(model->param.kernel_type);\n\tmodel_bin.param.degree = binsave_intConv(model->param.degree);\n\tmodel_bin.param.gamma = binsave_doubleConv(model->param.gamma);\n\tmodel_bin.param.coef0 = binsave_doubleConv(model->param.coef0);\n\tmodel_bin.nr_class = binsave_intConv(model->nr_class);\n\tmodel_bin.l = binsave_intConv(model->l);\n\n\tint offset = 0; // sizeof(struct svm_model_bin);\n\t\n\tmodel_bin.rho = binsave_ptrConv(offset); offset += n * sizeof(float);\n\tif (model->probA) {\n\t  model_bin.probA = binsave_ptrConv(offset); offset += n * sizeof(float);\n\t} else {\n\t  model_bin.probA = binsave_ptrConv(-1);\n\t}\n\tif (model->probB) {\n  \t  model_bin.probB = binsave_ptrConv(offset); offset += n * sizeof(float);\n\t} else {\n\t  model_bin.probB = binsave_ptrConv(-1);\n\t}\n\n\n\tif (model->label) {\n\t  model_bin.label = binsave_ptrConv(offset); offset += nr_class * sizeof(int32_t);\n    } else {\n\t  model_bin.label = binsave_ptrConv(-1);\n\t}\n\n\tif (model->nSV) {\n      model_bin.nSV = binsave_ptrConv(offset); offset += nr_class * sizeof(int32_t);\n\t} else {\n\t  model_bin.nSV = binsave_ptrConv(-1);\n\t}\n\n\tmodel_bin.sv_coef = binsave_ptrConv(offset); offset += (nr_class-1) * l * sizeof(double);\n\tmodel_bin.SV = binsave_ptrConv(offset);\n\tmodel_bin.SVsize = binsave_intConv(size);\n\t\n\tmodel_bin.magic[0] = 'L';\n\tmodel_bin.magic[1] = 'i';\n\tmodel_bin.magic[2] = 'b';\n\tmodel_bin.magic[3] = 'S';\n\tmodel_bin.magic[4] = 'V';\n\tmodel_bin.magic[5] = 'M';\n\tmodel_bin.magic[6] = 'b';\n\tmodel_bin.magic[7] = 'm';\n\t\n\t// save model struct including pointers/offsets ...\n\tfwrite(&model_bin,sizeof(struct svm_model_bin), 1, fp);\n\t\n\t\n    // save rho\n\tsaveDoubleAsFloat(model->rho, n, fp);\n    //fwrite(model->rho, n, sizeof(double), fp);\n\t\n\t// save probA, probB\n\tif (model->probA) \n      saveDoubleAsFloat(model->probA, n, fp); //fwrite(model->probA, n, sizeof(double), fp);\n\tif (model->probB)\n      saveDoubleAsFloat(model->probB, n, fp);   //fwrite(model->probB, n, sizeof(double), fp);\n\t\n\t// save label\n\tif(model->label)\n\t{\n\t  for(int i=0;i<nr_class;i++) {\n\t    int32_t tmp = binsave_intConv(model->label[i]);\n   \t  fwrite(&tmp, 1, sizeof(int32_t), fp);\n\t  }\n  }\n\t\n\t// save nSV\n\tif(model->nSV)\n\t{\n\t  for(int i=0;i<nr_class;i++) {\n\t    int32_t tmp = binsave_intConv(model->nSV[i]);\n      fwrite(&tmp, 1, sizeof(int32_t), fp);\n\t  }\n  }\n\t\n\n\t// save sv_coeff  (nr_class - 1 for every SV)\n  for(int j=0;j<nr_class-1;j++)\n\t\tfwrite(model->sv_coef[j], l, sizeof(double), fp);\n\t//????????????????? uninitialized memory here after loading ascii model ??????????\n\t\n\t// finally save support vectors\n\tlong i;\n\tsvm_node_bin *space = Malloc(svm_node_bin, size);\n\tsvm_node *xspace = model->SV[0];\n\tfor (i=0; i<size; i++) {\n\t  space[i].index = binsave_intConv(xspace[i].index);\n\t  space[i].value = binsave_floatConv(xspace[i].value);\n\t}\n\tfwrite(space, size, sizeof(svm_node_bin), fp);\n\tfree(space);\n\n\tif (ferror(fp) != 0 || fclose(fp) != 0) return -1;\n\telse return 0;\n}\n\nsvm_model *svm_load_binary_model(const char *model_file_name)\n{\n\tFILE *fp = fopen(model_file_name,\"rb\");\n\tif(fp==NULL) return NULL;\n\t\n\tstruct svm_model_bin model_bin;\n\t//printf(\"binsize: %i\\n\",sizeof(struct svm_model_bin));\n\t// read parameters\n  fread(&model_bin, sizeof(struct svm_model_bin), 1, fp);\n\t\n\t// compute total size, alloc memory, and load the rest:\n\tlong size = binload_intConv(model_bin.SV) + binload_intConv(model_bin.SVsize) * sizeof(struct svm_node_bin) ; //- sizeof(struct svm_model_bin);\n\tvoid * pool = malloc(size);\n  if (pool == NULL) { printf(\"ERROR: out-of-memory (malloc for size %li returned NULL)\\n\",size); fflush(stdout); }\n\tlong rd = (long)fread(pool, 1, size, fp);\n  if (rd < size) {\n    printf(\"SVM: error, model file '%s' is corrupt, read only %li bytes instead of %li excpected!\\n\",model_file_name,rd,size);\n  }\n\t\n\t// then adjust the pointers and copy to newly allocated svm_model struct ...\n\tsvm_model *model = Malloc(svm_model,1);\n\tsvm_parameter& param = model->param;\n\t\n\t//copy parameters\n\n\t// convert model to model_bin, adjust pointers in model_bin to relative pointers\n\tparam.svm_type = binload_intConv(model_bin.param.svm_type);\n\tparam.kernel_type = binload_intConv(model_bin.param.kernel_type);\n\tparam.gamma = binload_doubleConv(model_bin.param.gamma);\n\tparam.degree = binload_intConv(model_bin.param.degree);\n\tparam.coef0 = binload_doubleConv(model_bin.param.coef0);\n\tmodel->nr_class = binload_intConv(model_bin.nr_class);\n\tmodel->l = binload_intConv(model_bin.l);\n\t\n\t// load data from pool\n\tint n = model->nr_class*(model->nr_class-1)/2;\n\t\n  //printf(\"offset rho: %i \\n\",model_bin.rho);\n\tmodel->rho = floatArrToDouble(pool, model_bin.rho, n);\n\t\n\tif (model_bin.probA != -1) \n\t  model->probA = floatArrToDouble(pool, model_bin.probA, n); //(double *)((char*)pool + model_bin.probA);\n\telse\n\t  model->probA = NULL;\n\n  if (model_bin.probB != -1) \n\t  model->probB = floatArrToDouble(pool, model_bin.probB, n); //(double *)((char*)pool + model_bin.probB);\n\telse\n\t  model->probB = NULL;\n\n\t// todo: convert int...\n  if (model_bin.label >= 0) model->label = Malloc(int, model->nr_class);\n  else model->label = NULL;\n\tif (model_bin.nSV >= 0) model->nSV = Malloc(int, model->nr_class);\n  else model->nSV = NULL;\n\n\tint32_t *label = (int32_t*)((char*)pool + model_bin.label);\n\tint32_t *nSV = (int32_t*)((char*)pool + model_bin.nSV);\n\tint i;\n\tfor (i=0; i<model->nr_class; i++) {\n\t  if (model_bin.label >= 0) model->label[i] = binload_intConv(label[i]);\n\t  if (model_bin.nSV >= 0) model->nSV[i] = binload_intConv(nSV[i]);\n\t}\n\t\n\t// read sv_coef and SV\n\tint m = model->nr_class - 1;\n\tint l = model->l;\n\tmodel->sv_coef = Malloc(double *,m);\n\t\n\tint j=0;\n\tfor(i=0;i<m;i++) {\n\t\tmodel->sv_coef[i] = Malloc(double, l); // (double*)(binload_ptrConv(model_bin.sv_coef + i*l*sizeof(double), pool));\n\t\tdouble * x = (double*)(binload_ptrConv(model_bin.sv_coef + i*l*sizeof(double), pool));\n\t\tfor (j=0; j<l; j++) { \n\t\t\tmodel->sv_coef[i][j] = x[j];\n\t\t}\n\t}\n\t\n\tmodel->SV = Malloc(svm_node*,l);\n\t\n\tconst svm_node_bin *space = (svm_node_bin*)(binload_ptrConv(model_bin.SV, pool));\n\tlong x_space_size = binload_intConv(model_bin.SVsize);\n  svm_node *x_space = Malloc(svm_node,x_space_size); //(svm_node *)(binload_ptrConv(model_bin.SV, pool));\n  if (x_space == NULL) { printf(\"ERROR: out-of-memory (libSvm Malloc for size %li returned NULL)\\n\",x_space_size); fflush(stdout); }\n  for(i=0;i<x_space_size;i++) {\n\t\tx_space[i].index = binload_intConv(space[i].index);\n\t\tx_space[i].value = binload_floatConv(space[i].value);\n\t}\t\n\n\tfree(pool);\n\n  j=0;\n  for(i=0;i<l;i++) {\n    model->SV[i] = &x_space[j];\n    if (j>=x_space_size-1) {\n      printf(\"SVM: model load error, x_space size too small (%li) for l=%i SVs (at SV i=%i)\\n\",x_space_size,l,i);\n      break;\n    }\n    while(x_space[j++].index != -1) {\n      if (j>=x_space_size) {\n        printf(\"SVM: model load error, x_space size too small (%li) for l=%i SVs (at SV i=%i)\\n\",x_space_size,l,i);\n        break;\n      }\n    }\t\n  }\t\n\t\n\tif (ferror(fp) != 0 || fclose(fp) != 0) return NULL;\n\n\tmodel->free_sv = 1; // XXX\n\treturn model;\n}\n\n/**** end new functions ****/\n\nint svm_save_model(const char *model_file_name, const svm_model *model)\n{\n\tFILE *fp = fopen(model_file_name,\"w\");\n\tif(fp==NULL) return -1;\n\n\tconst svm_parameter& param = model->param;\n\n\tfprintf(fp,\"svm_type %s\\n\", svm_type_table[param.svm_type]);\n\tfprintf(fp,\"kernel_type %s\\n\", kernel_type_table[param.kernel_type]);\n\n\tif(param.kernel_type == POLY)\n\t\tfprintf(fp,\"degree %d\\n\", param.degree);\n\n\tif(param.kernel_type == POLY || param.kernel_type == RBF || param.kernel_type == SIGMOID)\n\t\tfprintf(fp,\"gamma %g\\n\", param.gamma);\n\n\tif(param.kernel_type == POLY || param.kernel_type == SIGMOID)\n\t\tfprintf(fp,\"coef0 %g\\n\", param.coef0);\n\n\tint nr_class = model->nr_class;\n\tint l = model->l;\n\tfprintf(fp, \"nr_class %d\\n\", nr_class);\n\tfprintf(fp, \"total_sv %d\\n\",l);\n\t\n\t{\n\t\tfprintf(fp, \"rho\");\n\t\tfor(int i=0;i<nr_class*(nr_class-1)/2;i++)\n\t\t\tfprintf(fp,\" %g\",model->rho[i]);\n\t\tfprintf(fp, \"\\n\");\n\t}\n\t\n\tif(model->label)\n\t{\n\t\tfprintf(fp, \"label\");\n\t\tfor(int i=0;i<nr_class;i++)\n\t\t\tfprintf(fp,\" %d\",model->label[i]);\n\t\tfprintf(fp, \"\\n\");\n\t}\n\n\tif(model->probA) // regression has probA only\n\t{\n\t\tfprintf(fp, \"probA\");\n\t\tfor(int i=0;i<nr_class*(nr_class-1)/2;i++)\n\t\t\tfprintf(fp,\" %g\",model->probA[i]);\n\t\tfprintf(fp, \"\\n\");\n\t}\n\tif(model->probB)\n\t{\n\t\tfprintf(fp, \"probB\");\n\t\tfor(int i=0;i<nr_class*(nr_class-1)/2;i++)\n\t\t\tfprintf(fp,\" %g\",model->probB[i]);\n\t\tfprintf(fp, \"\\n\");\n\t}\n\n\tif(model->nSV)\n\t{\n\t\tfprintf(fp, \"nr_sv\");\n\t\tfor(int i=0;i<nr_class;i++)\n\t\t\tfprintf(fp,\" %d\",model->nSV[i]);\n\t\tfprintf(fp, \"\\n\");\n\t}\n\n\tfprintf(fp, \"SV\\n\");\n\tconst double * const *sv_coef = model->sv_coef;\n\tconst svm_node * const *SV = model->SV;\n\n\tfor(int i=0;i<l;i++)\n\t{\n\t\tfor(int j=0;j<nr_class-1;j++)\n\t\t\tfprintf(fp, \"%.16g \",sv_coef[j][i]);\n\n\t\tconst svm_node *p = SV[i];\n\n\t\tif(param.kernel_type == PRECOMPUTED)\n\t\t\tfprintf(fp,\"0:%d \",(int)(p->value));\n\t\telse\n\t\t\twhile(p->index != -1)\n\t\t\t{\n\t\t\t\tfprintf(fp,\"%d:%.8g \",p->index,p->value);\n\t\t\t\tp++;\n\t\t\t}\n\t\tfprintf(fp, \"\\n\");\n\t}\n\tif (ferror(fp) != 0 || fclose(fp) != 0) return -1;\n\telse return 0;\n}\n\n/** new function by Florian Eyben, automatically detects binary models **/\nsvm_model *svm_load_model(const char *model_file_name)\n{\n\tFILE *fp = fopen(model_file_name,\"rb\");\n\tif(fp==NULL) return NULL;\n\n\tchar magic[8];\n\t\n\tfread(magic, 8, 1, fp);\n\tfclose(fp);\t\n\t\n\tif (magic[0] == 'L' && \n\t\tmagic[1] == 'i' && \n\t\tmagic[2] == 'b' && \n\t\tmagic[3] == 'S' &&\n\t\tmagic[4] == 'V' &&\n\t\tmagic[5] == 'M' &&\n\t\tmagic[6] == 'b' &&\n\t\tmagic[7] == 'm' ) {\n\t\t\t\n\t\t\treturn svm_load_binary_model(model_file_name);\n\t\t\t\n\t} else {\n\t\t\treturn svm_load_ascii_model(model_file_name);\n\t}\n\n\treturn NULL;\n}\n/*********** end new function ********************/\n\nsvm_model *svm_load_ascii_model(const char *model_file_name)\n{\n\tFILE *fp = fopen(model_file_name,\"rb\");\n\tif(fp==NULL) return NULL;\n\t\n\t// read parameters\n\n\tsvm_model *model = Malloc(svm_model,1);\n\tsvm_parameter& param = model->param;\n\tmodel->rho = NULL;\n\tmodel->probA = NULL;\n\tmodel->probB = NULL;\n\tmodel->label = NULL;\n\tmodel->nSV = NULL;\n\n\tchar cmd[81];\n\twhile(1)\n\t{\n\t\tfscanf(fp,\"%80s\",cmd);\n\n\t\tif(strcmp(cmd,\"svm_type\")==0)\n\t\t{\n\t\t\tfscanf(fp,\"%80s\",cmd);\n\t\t\tint i;\n\t\t\tfor(i=0;svm_type_table[i];i++)\n\t\t\t{\n\t\t\t\tif(strcmp(svm_type_table[i],cmd)==0)\n\t\t\t\t{\n\t\t\t\t\tparam.svm_type=i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(svm_type_table[i] == NULL)\n\t\t\t{\n\t\t\t\tfprintf(stderr,\"unknown svm type.\\n\");\n\t\t\t\tfree(model->rho);\n\t\t\t\tfree(model->label);\n\t\t\t\tfree(model->nSV);\n\t\t\t\tfree(model);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t\telse if(strcmp(cmd,\"kernel_type\")==0)\n\t\t{\t\t\n\t\t\tfscanf(fp,\"%80s\",cmd);\n\t\t\tint i;\n\t\t\tfor(i=0;kernel_type_table[i];i++)\n\t\t\t{\n\t\t\t\tif(strcmp(kernel_type_table[i],cmd)==0)\n\t\t\t\t{\n\t\t\t\t\tparam.kernel_type=i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(kernel_type_table[i] == NULL)\n\t\t\t{\n\t\t\t\tfprintf(stderr,\"unknown kernel function.\\n\");\n\t\t\t\tfree(model->rho);\n\t\t\t\tfree(model->label);\n\t\t\t\tfree(model->nSV);\n\t\t\t\tfree(model);\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\t\telse if(strcmp(cmd,\"degree\")==0)\n\t\t\tfscanf(fp,\"%d\",&param.degree);\n\t\telse if(strcmp(cmd,\"gamma\")==0)\n\t\t\tfscanf(fp,\"%lf\",&param.gamma);\n\t\telse if(strcmp(cmd,\"coef0\")==0)\n\t\t\tfscanf(fp,\"%lf\",&param.coef0);\n\t\telse if(strcmp(cmd,\"nr_class\")==0)\n\t\t\tfscanf(fp,\"%d\",&model->nr_class);\n\t\telse if(strcmp(cmd,\"total_sv\")==0)\n\t\t\tfscanf(fp,\"%d\",&model->l);\n\t\telse if(strcmp(cmd,\"rho\")==0)\n\t\t{\n\t\t\tint n = model->nr_class * (model->nr_class-1)/2;\n\t\t\tmodel->rho = Malloc(double,n);\n\t\t\tfor(int i=0;i<n;i++)\n\t\t\t\tfscanf(fp,\"%lf\",&model->rho[i]);\n\t\t}\n\t\telse if(strcmp(cmd,\"label\")==0)\n\t\t{\n\t\t\tint n = model->nr_class;\n\t\t\tmodel->label = Malloc(int,n);\n\t\t\tfor(int i=0;i<n;i++)\n\t\t\t\tfscanf(fp,\"%d\",&model->label[i]);\n\t\t}\n\t\telse if(strcmp(cmd,\"probA\")==0)\n\t\t{\n\t\t\tint n = model->nr_class * (model->nr_class-1)/2;\n\t\t\tmodel->probA = Malloc(double,n);\n\t\t\tfor(int i=0;i<n;i++)\n\t\t\t\tfscanf(fp,\"%lf\",&model->probA[i]);\n\t\t}\n\t\telse if(strcmp(cmd,\"probB\")==0)\n\t\t{\n\t\t\tint n = model->nr_class * (model->nr_class-1)/2;\n\t\t\tmodel->probB = Malloc(double,n);\n\t\t\tfor(int i=0;i<n;i++)\n\t\t\t\tfscanf(fp,\"%lf\",&model->probB[i]);\n\t\t}\n\t\telse if(strcmp(cmd,\"nr_sv\")==0)\n\t\t{\n\t\t\tint n = model->nr_class;\n\t\t\tmodel->nSV = Malloc(int,n);\n\t\t\tfor(int i=0;i<n;i++)\n\t\t\t\tfscanf(fp,\"%d\",&model->nSV[i]);\n\t\t}\n\t\telse if(strcmp(cmd,\"SV\")==0)\n\t\t{\n\t\t\twhile(1)\n\t\t\t{\n\t\t\t\tint c = getc(fp);\n\t\t\t\tif(c==EOF || c=='\\n') break;\t\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfprintf(stderr,\"unknown text in model file: [%s]\\n\",cmd);\n\t\t\tfree(model->rho);\n\t\t\tfree(model->label);\n\t\t\tfree(model->nSV);\n\t\t\tfree(model);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n\t// read sv_coef and SV\n\n\tint elements = 0;\n\tlong pos = ftell(fp);\n\n\twhile(1)\n\t{\n\t\tint c = fgetc(fp);\n\t\tswitch(c)\n\t\t{\n\t\t\tcase '\\n':\n\t\t\t\t// count the '-1' element\n\t\t\tcase ':':\n\t\t\t\t++elements;\n\t\t\t\tbreak;\n\t\t\tcase EOF:\n\t\t\t\tgoto out;\n\t\t\tdefault:\n\t\t\t\t;\n\t\t}\n\t}\nout:\n\tfseek(fp,pos,SEEK_SET);\n\n\tint m = model->nr_class - 1;\n\tint l = model->l;\n\tmodel->sv_coef = Malloc(double *,m);\n\tint i;\n\tfor(i=0;i<m;i++)\n\t\tmodel->sv_coef[i] = Malloc(double,l);\n\tmodel->SV = Malloc(svm_node*,l);\n\tsvm_node *x_space=NULL;\n\tif(l>0) x_space = Malloc(svm_node,elements);\n\n\tint j=0;\n\tfor(i=0;i<l;i++)\n\t{\n\t\tmodel->SV[i] = &x_space[j];\n\t\tfor(int k=0;k<m;k++)\n\t\t\tfscanf(fp,\"%lf\",&model->sv_coef[k][i]);\n\t\twhile(1)\n\t\t{\n\t\t\tint c;\n\t\t\tdo {\n\t\t\t\tc = getc(fp);\n\t\t\t\tif(c=='\\n') goto out2;\n\t\t\t} while(isspace(c));\n\t\t\tungetc(c,fp);\n\t\t\tfscanf(fp,\"%d:%lf\",&(x_space[j].index),&(x_space[j].value));\n\t\t\t++j;\n\t\t}\t\nout2:\n\t\tx_space[j++].index = -1;\n\t}\n\tif (ferror(fp) != 0 || fclose(fp) != 0) return NULL;\n\n\tmodel->free_sv = 1;\t// XXX\n\treturn model;\n}\n\nvoid svm_destroy_model(svm_model* model)\n{\n\tif(model->free_sv && model->l > 0)\n\t\tfree((void *)(model->SV[0]));\n\tfor(int i=0;i<model->nr_class-1;i++)\n\t\tfree(model->sv_coef[i]);\n\tfree(model->SV);\n\tfree(model->sv_coef);\n\tfree(model->rho);\n\tfree(model->label);\n\tfree(model->probA);\n\tfree(model->probB);\n\tfree(model->nSV);\n\tfree(model);\n}\n\nvoid svm_destroy_param(svm_parameter* param)\n{\n\tfree(param->weight_label);\n\tfree(param->weight);\n}\n\nconst char *svm_check_parameter(const svm_problem *prob, const svm_parameter *param)\n{\n\t// svm_type\n\n\tint svm_type = param->svm_type;\n\tif(svm_type != C_SVC &&\n\t   svm_type != NU_SVC &&\n\t   svm_type != ONE_CLASS &&\n\t   svm_type != EPSILON_SVR &&\n\t   svm_type != NU_SVR)\n\t\treturn \"unknown svm type\";\n\t\n\t// kernel_type, degree\n\t\n\tint kernel_type = param->kernel_type;\n\tif(kernel_type != LINEAR &&\n\t   kernel_type != POLY &&\n\t   kernel_type != RBF &&\n\t   kernel_type != SIGMOID &&\n\t   kernel_type != PRECOMPUTED)\n\t\treturn \"unknown kernel type\";\n\n\tif(param->degree < 0)\n\t\treturn \"degree of polynomial kernel < 0\";\n\n\t// cache_size,eps,C,nu,p,shrinking\n\n\tif(param->cache_size <= 0)\n\t\treturn \"cache_size <= 0\";\n\n\tif(param->eps <= 0)\n\t\treturn \"eps <= 0\";\n\n\tif(svm_type == C_SVC ||\n\t   svm_type == EPSILON_SVR ||\n\t   svm_type == NU_SVR)\n\t\tif(param->C <= 0)\n\t\t\treturn \"C <= 0\";\n\n\tif(svm_type == NU_SVC ||\n\t   svm_type == ONE_CLASS ||\n\t   svm_type == NU_SVR)\n\t\tif(param->nu <= 0 || param->nu > 1)\n\t\t\treturn \"nu <= 0 or nu > 1\";\n\n\tif(svm_type == EPSILON_SVR)\n\t\tif(param->p < 0)\n\t\t\treturn \"p < 0\";\n\n\tif(param->shrinking != 0 &&\n\t   param->shrinking != 1)\n\t\treturn \"shrinking != 0 and shrinking != 1\";\n\n\tif(param->probability != 0 &&\n\t   param->probability != 1)\n\t\treturn \"probability != 0 and probability != 1\";\n\n\tif(param->probability == 1 &&\n\t   svm_type == ONE_CLASS)\n\t\treturn \"one-class SVM probability output not supported yet\";\n\n\n\t// check whether nu-svc is feasible\n\t\n\tif(svm_type == NU_SVC)\n\t{\n\t\tint l = prob->l;\n\t\tint max_nr_class = 16;\n\t\tint nr_class = 0;\n\t\tint *label = Malloc(int,max_nr_class);\n\t\tint *count = Malloc(int,max_nr_class);\n\n\t\tint i;\n\t\tfor(i=0;i<l;i++)\n\t\t{\n\t\t\tint this_label = (int)prob->y[i];\n\t\t\tint j;\n\t\t\tfor(j=0;j<nr_class;j++)\n\t\t\t\tif(this_label == label[j])\n\t\t\t\t{\n\t\t\t\t\t++count[j];\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\tif(j == nr_class)\n\t\t\t{\n\t\t\t\tif(nr_class == max_nr_class)\n\t\t\t\t{\n\t\t\t\t\tmax_nr_class *= 2;\n\t\t\t\t\tlabel = (int *)realloc(label,max_nr_class*sizeof(int));\n\t\t\t\t\tcount = (int *)realloc(count,max_nr_class*sizeof(int));\n\t\t\t\t}\n\t\t\t\tlabel[nr_class] = this_label;\n\t\t\t\tcount[nr_class] = 1;\n\t\t\t\t++nr_class;\n\t\t\t}\n\t\t}\n\t\n\t\tfor(i=0;i<nr_class;i++)\n\t\t{\n\t\t\tint n1 = count[i];\n\t\t\tfor(int j=i+1;j<nr_class;j++)\n\t\t\t{\n\t\t\t\tint n2 = count[j];\n\t\t\t\tif(param->nu*(n1+n2)/2 > min(n1,n2))\n\t\t\t\t{\n\t\t\t\t\tfree(label);\n\t\t\t\t\tfree(count);\n\t\t\t\t\treturn \"specified nu is infeasible\";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfree(label);\n\t\tfree(count);\n\t}\n\n\treturn NULL;\n}\n\nint svm_check_probability_model(const svm_model *model)\n{\n\treturn ((model->param.svm_type == C_SVC || model->param.svm_type == NU_SVC) &&\n\t\tmodel->probA!=NULL && model->probB!=NULL) ||\n\t\t((model->param.svm_type == EPSILON_SVR || model->param.svm_type == NU_SVR) &&\n\t\t model->probA!=NULL);\n}\n\n#endif // #ifdef BUILD_LIBSVM\n"
  },
  {
    "path": "src/classifiers/libsvmliveSink.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nLibSVM live classifier/regressor\n03/2016: added support for LibLINEAR models\n\n*/\n\n\n\n#include <classifiers/libsvmliveSink.hpp>\n\n#define MODULE \"cLibsvmLiveSink\"\n\n#ifdef BUILD_COMPONENT_LibsvmLiveSink\n\nSMILECOMPONENT_STATICS(cLibsvmLiveSink)\n\n//sComponentInfo * cLibsvmLiveSink::registerComponent(cConfigManager *_confman)\nSMILECOMPONENT_REGCOMP(cLibsvmLiveSink)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CLIBSVMLIVESINK;\n  sdescription = COMPONENT_DESCRIPTION_CLIBSVMLIVESINK;\n\n  // we inherit cDataSink configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSink\")\n\n  SMILECOMPONENT_IFNOTREGAGAIN_BEGIN\n  ct->makeMandatory(ct->setField(\"model\",\"LibSVM or LibLINEAR model file(s) to load (see isLibLinearModel option for libLinear).\", \"svm.model\", ARRAY_TYPE));\n#ifdef BUILD_LIBLINEAR\n  ct->setField(\"isLibLinearModel\", \"1 = load the model(s) as a liblinear model, not libsvm.\", 0);\n#endif\n  ct->setField(\"scale\",\"LibSVM scale file(s) to load\", (const char *) NULL, ARRAY_TYPE);\n  ct->setField(\"fselection\",\"Feature selection file(s) to apply (leave empty to use all features). The feature selection files must contain the exact names of the selected features, one feature per line.\",(const char*)NULL,ARRAY_TYPE);\n  ct->setField(\"nIgnoreEndSelection\",\"number of string lines to ignore at the *end* of the feature selection file (only works for string/name lists, not for index lists!)\",0);\n  ct->setField(\"classes\",\"Class name lookup file(s), which map the libsvm class indicies to actual class names (leave empty to display libsvm class numbers/indicies) [note: currently only ONE class name lookup file is supported!]\",(const char*)NULL,ARRAY_TYPE);\n  ct->setField(\"predictProbability\",\"1 = predict class probabilities (confidences) (0 = no)\",0);\n  ct->setField(\"printParseableResult\",\"1 = print easily parseable classification/regression result to stdout\", 0);\n  ct->setField(\"printResult\",\"1 = print classification/regression result to log\", 0);\n  ct->setField(\"saveResult\",\"filename of text file the result(s) will be saved to\",(const char*)NULL);\n  ct->setField(\"resultRecp\",\"List of component(s) to send 'classificationResult' messages to (use , to separate multiple recepients), leave blank (NULL) to not send any messages\",(const char *) NULL);\n  ct->setField(\"resultMessageName\",\"Freely defineable name that is sent with 'classificationResult' message\",\"svm_result\");\n  ct->setField(\"forceScale\",\"1 = for the input values, enforce the range specified in the scale file by clipping out-of-range values (after scaling).\",1);\n  ct->setField(\"lag\",\"read data <lag> frames behind (should always remain 0 for this component...?)\",0,0,0);\n  ct->setField(\"useThread\",\"1 = load the model and do the classification in a background thread, the data frames (inputs) will be stored in a queue and processed sequentially by the background thread (parallel processing is not implemented yet!).\",0);\n  ct->setField(\"loadModelBg\",\"1 = if useThread=1 (and only then...) load the libsvm model and scale files in the background thread. openSMILE will start to run the tick loop, but classify incoming frames only after the model has been loaded. Up to then all incoming frames are discarded.\",1);\n  ct->setField(\"threadQueSize\",\"max. number of frames to keep in queue (Set to 0 for an infinite number of frames).\",0);\n  ct->setField(\"multiModelMode\",\"1 = classify input data with all loaded models *in parallel* (you will have nModels output messages then). 0 = classify with first model by default. Switching of models is possible via a 'svmSinkSetModel' smile message.\",0);\n  ct->setField(\"batchMode\",\"1 = similar to multiModelMode=1, classify using all models, however only one result message (containing multiple individual results) will be generated.\",0);\n  ct->setField(\"noVerify\",\"1 = *DON'T* verify whether the support vector dimension matches the feature selection list dimension and the scale file dimension.\",0);\n  ct->setField(\"modelResultName\",\"Array of custom names sent as 'custData2' pointer with the classificationResult message for corresponding models. The dimensions of this array should match the dimensions of the 'model' array.\",(const char *)NULL,ARRAY_TYPE);\n  ct->setField(\"bgThreadPriority\",\"The thread priority of the background predictor thread (currently only supported on windows), values -15 (idle) to 15 (real-time), while 0 is normal. This should be lower as or equal to the priority of the openSMILE main thread!\",0);\n\n  SMILECOMPONENT_IFNOTREGAGAIN_END\n\n    SMILECOMPONENT_MAKEINFO(cLibsvmLiveSink);\n}\n\nSMILECOMPONENT_CREATE(cLibsvmLiveSink)\n\n//-----\n\ncLibsvmLiveSink::cLibsvmLiveSink(const char *_name) :\ncDataSink(_name),\nclassesarray(NULL),modelarray(NULL), scalearray(NULL), predictProbability(0),\nprintResult(1), printParseableResult(0),\nnModels(0),currentModel(0),\nnClassFiles(0), nScales(0), nFselections(0),\nsendResult(0),\nresultMessageName(NULL), resultRecp(NULL),\nthreadRunning(0), modelLoaded(0),\nmodels(NULL), singlePreprocessMultiModel(0),\nabortLater(0), nIgnoreEndSelection(0),\nclassifierThreadBusy(0), resultFile(NULL)\n{\n  smileMutexCreate(runningMtx);\n  smileMutexCreate(dataMtx);\n  smileCondCreate(dataCond);\n  dataFrameQue = new lsvmDataFrameQueue();\n}\n\nvoid cLibsvmLiveSink::fetchConfig()\n{\n  cDataSink::fetchConfig();\n  nModels = getArraySize(\"model\");\n  noVerify = getInt(\"noVerify\");\n  nIgnoreEndSelection = getInt(\"nIgnoreEndSelection\");\n  multiModelMode = getInt(\"multiModelMode\");\n  loadModelBg = getInt(\"loadModelBg\");\n  batchMode = getInt(\"batchMode\");\n  forceScale=getInt(\"forceScale\");\n  if (nModels > 0) {\n    nScales = getArraySize(\"scale\");\n    if ((nScales != nModels)&&(nScales > 1))\n      SMILE_IERR(1,\"size of 'scale' array is different from size of 'model' array!\");\n    nFselections = getArraySize(\"fselection\");\n    if ((nFselections != nModels)&&(nFselections > 1))\n      SMILE_IERR(2,\"size of 'fselection' array is different from size of 'model' array!\");\n    nClassFiles = getArraySize(\"classes\");\n    if ((nClassFiles != nModels)&&(nClassFiles > 1))\n      SMILE_IERR(2,\"size of 'classes' array is different from size of 'model' array!\");\n\n    models = new svmModelWrapper[nModels]();\n    if (nScales < 0) { nScales = 0; }\n    if (nFselections < 0) { nFselections = 0; }\n    if (nClassFiles < 0) { nClassFiles = 0; }\n    int nModelResultNames = getArraySize(\"modelResultName\");\n    for (int i=0; i<nModels; i++) {\n      models[i].isLibLinearModel = getInt_f(myvprint(\"isLibLinearModel[%i]\", i));\n      models[i].modelFile = getStr_f(myvprint(\"model[%i]\",i));\n      if (nModelResultNames > 0) {\n        if (i<nModelResultNames) models[i].modelResultName = getStr_f(myvprint(\"modelResultName[%i]\",i));\n        else {\n          SMILE_IERR(2,\"less model result names given than there are models!\");\n        }\n      }\n      models[i].noVerify = noVerify;\n    }\n    for (int i=0; i<nScales; i++) {\n      models[i].scaleFile = getStr_f(myvprint(\"scale[%i]\",i));\n    }\n    for (int i=0;i<nClassFiles;i++) {\n      models[i].classesFile = getStr_f(myvprint(\"classes[%i]\",i));\n    }\n    for (int i=0; i<nFselections; i++) {\n      models[i].fselectionFile = getStr_f(myvprint(\"fselection[%i]\",i));;\n      models[i].nIgnoreEndSelection = nIgnoreEndSelection;\n    }\n  } else {\n    SMILE_IERR(1,\"nModels < 1 ! You must specify at least one model to load (see the 'model=' option)!!\");\n    COMP_ERR(\"aborting...\");\n  }\n  predictProbability = getInt(\"predictProbability\");\n  for (int i=0;i<nModels;i++) {\n    models[i].predictProbability = predictProbability;\n    if (models[i].modelFile != NULL) {\n      SMILE_IDBG(2,\"Model #%i : filename of SVM model to load = '%s'\",i,models[i].modelFile);\n    }\n    if (nScales > 1 || i==0) {\n      SMILE_IDBG(2,\"Model #%i : filename of scale data to load = '%s'\",i,models[i].scaleFile);\n    } else { \n      if (nScales > 0) { \n        models[i].setTemplate(models);\n        SMILE_IDBG(2,\"Model #%i : using common feature scaling for all models = '%s'\",i,models[0].scaleFile); \n      }\n    }\n    if (nFselections > 1 || i==0) { SMILE_IDBG(2,\"Model #%i : filename of feature selection file to load = '%s'\",i,models[i].fselectionFile); }\n    else { \n      if (nFselections > 0) { \n        models[i].setTemplate(models);\n        SMILE_IDBG(2,\"Model #%i : using common feature selection list for all models = '%s'\",i,models[0].fselectionFile); \n      }\n    }\n    if (nClassFiles > 1 || i==0) { SMILE_IDBG(2,\"Model #%i : filename of class mapping to load = '%s'\",i,models[i].classesFile); }\n    else { \n      if (nClassFiles > 0) { \n        models[i].setTemplate(models);\n        SMILE_IDBG(2,\"Model #%i : using common class mapping for all models = '%s'\",i,models[0].classesFile); \n      }\n    }\n  }\n  if ((multiModelMode == 1) && (nScales <= 1) && (nFselections <= 1) && (nClassFiles <= 1))\n    singlePreprocessMultiModel = 1;\n  printParseableResult = getInt(\"printParseableResult\");\n  printResult = getInt(\"printResult\");\n  resultFile = getStr(\"saveResult\");\n  if (resultFile != NULL)\n    saveResult = 1;\n  else\n    saveResult = 0;\n  resultRecp = getStr(\"resultRecp\");\n  if (resultRecp != NULL)\n    sendResult = 1;\n  resultMessageName = getStr(\"resultMessageName\");\n  useThread = getInt(\"useThread\");\n  threadQueSize = getInt(\"threadQueSize\");\n  if (!singlePreprocessMultiModel && multiModelMode)\n    threadQueSize *= nModels;\n  bgThreadPriority = getInt(\"bgThreadPriority\");\n  if (bgThreadPriority < -15)\n    bgThreadPriority = -15;\n  if (bgThreadPriority > 15)\n    bgThreadPriority = 15;\n}\n\n\n#define MAX_LINE_LENGTH 2048\n\nint svmModelWrapper::loadClasses( const char *file, char *** names )\n{\n  if ((file != NULL)&&(names!=NULL)) {\n    if (strlen(file)<1) return 0;\n\n    FILE *f = NULL;\n    if (file != NULL) f = fopen(file,\"r\");\n    if (f== NULL) {\n      SMILE_ERR(2,\"error opening class map file '%s' for reading! NOT using a class map!\",file);\n      return 0;\n    }\n\n    char line[MAX_LINE_LENGTH+1];\n    int nCls=0;\n\n    while(fgets(line,MAX_LINE_LENGTH,f) != NULL) {\n      if (strlen( line ) > 1) { \n        line[strlen( line ) - 1] = 0;\n        const char *cn = strchr(line,':');\n        if (cn!=NULL) {\n          nCls++;\n          // TODO: use class number instead of cont. index\n        }\n      }\n    }\n    fclose(f);\n\n    *names = (char **) calloc(1,sizeof(char*)*nCls);\n    nClassNames = nCls;\n\n    f = fopen(file,\"r\");\n    if (f== NULL) {\n      SMILE_ERR(2,\"error opening class map file '%s' for reading (2nd pass)! NOT using a class map!\",file);\n      return 0;\n    }\n\n    int cIdx = 0;\n\n    while(fgets(line,MAX_LINE_LENGTH,f) != NULL) {\n      if (strlen( line ) > 1) { \n        line[strlen( line ) - 1] = 0;\n        const char *cn = strchr(line,':');\n        if (cn!=NULL) {\n          (*names)[cIdx++] = strdup(cn+1);\n          //SMILE_MSG(1,\"%s\",classNames[classnames_run-1]);\n          //if (cn+2 !=NULL) classNames[classnames_run++] = strdup(cn+2);\n          //if (cn+3 !=NULL) classNames[classnames_run++] = strdup(cn+3);\n\n          // TODO: use class number instead of cont. index\n        }\n      }\n    }\n    fclose(f);\n    //SMILE_IMSG(3,\"classNames[%i] = %s\",classnames_run-1,classNames[classnames_run-1]);\n\n    return nCls;\n  }\n  return 0;\n}\n\nint svmModelWrapper::loadSelection(const char *selFile, sFselectionData **fselections)\n{\n  if ((selFile != NULL)&&(fselections!=NULL)) {\n    if (strlen(selFile)<1) return 0;\n\n    FILE *f = fopen(selFile,\"r\");\n    if (f== NULL) {\n      SMILE_ERR(2,\"error opening feature selection file '%s' for reading! NOT using a feature selection!\",selFile);\n      return 0;\n    }\n\n    *fselections = (sFselectionData*)calloc(1,sizeof(sFselectionData)); \n\n    // read first line to determine filetype:\n    char line[MAX_LINE_LENGTH+1];\n    unsigned int nStr = 0;\n    unsigned int nStr0 = 0;\n    fgets( line, 5, f);\n    line[3] = 0;\n    if (!strncasecmp(line,\"str\",3)) { // string list\n      (*fselections)->fselType = 2;\n      SMILE_DBG(5,\"reading string list of features\");\n      fscanf( f, \"%u\\n\", &nStr0);\n      nStr = nStr0-nIgnoreEndSelection;\n      if (nStr < 1) { COMP_ERR(\"Error reading feature selection file, nFeatures < 1 (nIgnoreEndSelection = %i ; nStr0 = %i)!\",nIgnoreEndSelection,nStr0); }\n      (*fselections)->outputSelStr.n = nStr;\n      (*fselections)->Nsel=nStr;\n      (*fselections)->outputSelStr.names = (char **)calloc(1,sizeof(char *)*nStr);\n      unsigned int i=0; \n      line[0] = 0;\n      while(fgets(line,MAX_LINE_LENGTH,f) != NULL) {\n        size_t sl = strlen(line);\n        if (sl > 1) { \n          if (i<nStr) {\n            if (line[sl - 1] == '\\n') {\n              line[sl - 1] = 0; sl--;\n            }\n            if (line[sl - 1] == '\\r') {\n              line[sl - 1] = 0; sl--;\n            }\n            if (sl > 0) {\n              (*fselections)->outputSelStr.names[i++] = strdup(line);\n            } else {\n              SMILE_WRN(1,\"empty line in feature selection file '%s'\",selFile);\n            }\n          } else { \n            if (i>=nStr0) {\n              SMILE_ERR(1,\"excess line in feature selection file '%s' : '%s' (expected only %i lines with features)\",selFile,line,nStr);\n            }\n          }\n        }\n      }\n      if ((*fselections)->outputSelStr.n > i) {\n        SMILE_WRN(1,\"less feature names (only %i) in feature selection file '%s' than specified in the header (%i).\",i,selFile,(*fselections)->outputSelStr.n);\n        (*fselections)->outputSelStr.n = i;\n      }\n      SMILE_DBG(5,\"enabled %i features\",i);\n      fclose(f);\n      return 1;\n    } else if (!strncasecmp(line,\"idx\",3)) { // index list\n      (*fselections)->fselType = 1;\n      SMILE_DBG(5,\"reading index list of features\");\n      unsigned int idx = 0;\n      int i;\n      // pass1: parse for max index\n      while(fscanf(f,\"%u\\n\",&idx) == 1)\n        (*fselections)->outputSelIdx.nFull = MAX((*fselections)->outputSelIdx.nFull, idx);\n      SMILE_DBG(5,\"max index in selection file was found to be %i\",(*fselections)->outputSelIdx.nFull);\n      (*fselections)->outputSelIdx.nFull++;\n      (*fselections)->outputSelIdx.enabled = (long *)calloc(1,sizeof(long)*(*fselections)->outputSelIdx.nFull);\n      rewind( f );\n      fgets(line, 5, f); // skip header line;\n      // pass2: parse for max index\n      i=0;\n      while(fscanf(f,\"%u\\n\",&idx) == 1) {\n        (*fselections)->outputSelIdx.enabled[idx] = 1; // enable feature \"idx\"\n        i++;\n      }\n      (*fselections)->outputSelIdx.nSel = i;\n      (*fselections)->Nsel = i;\n      SMILE_DBG(5,\"enabled %i features\",i);\n      fclose(f);\n      return 1;\n    } else { // bogus file...\n      fclose( f );\n      COMP_ERR(\"error parsing fselection file '%s'. bogus header! expected 'str' or 'idx' at beginning. found '%s'.\",selFile,line);\n    }\n  }\n  return 0;\n}\n\n// load model, scale, etc. or copy from template, if template is set and filename is NULL\nint svmModelWrapper::load() \n{\n  if (modelFile == NULL)\n    return 0;\n  // model file\n  if (isLibLinearModel) {\n#ifdef BUILD_LIBLINEAR\n    modelLinear = liblinear_load_model(modelFile);\n    if (modelLinear == NULL) {\n      SMILE_ERR(1, \"svmModelWrapper: can't open LibLinear model file '%s'\", modelFile);\n      return 0;\n    }\n    nClasses = modelLinear->nr_class;\n    // TODO: labels/regression/type\n\n#else\n    SMILE_ERR(1, \"LibLinear is not supported by this openSMILE build!\");\n    COMP_ERR(\"aborting\");\n#endif\n  } else {\n    if ((model = svm_load_model(modelFile))==0) {\n      SMILE_ERR(1, \"svmModelWrapper: can't open LibSVM model file '%s'\",modelFile);\n      return 0;\n    }\n    nClasses = svm_get_nr_class(model);\n    svmType = svm_get_svm_type(model);\n    if (predictProbability) {\n      if ((svmType==NU_SVR) || (svmType==EPSILON_SVR)) {\n        nClasses = 0;\n        SMILE_MSG(3,\"LibSVM prob. model (regression) for test data: target value = predicted value + z,\\nz: Laplace distribution e^(-|z|/sigma)/(2sigma),sigma=%g\",svm_get_svr_probability(model));\n      } else {\n        labels=(int *) malloc(nClasses*sizeof(int));\n        svm_get_labels(model,labels);\n        SMILE_MSG(3,\"LibSVM %i labels in model '%s':\",nClasses,modelFile);\n        int j;\n        for(j=0;j<nClasses;j++) {\n          SMILE_MSG(3,\"  Label[%i] : '%d'\",j,labels[j]);\n        }\n      }\n    }\n  }\n\n  // scale file\n  if (scaleFile != NULL) {\n    if ((scale = svm_load_scale(scaleFile))==0) {\n      SMILE_ERR(1,\"can't open libSVM scale file '%s'\",scaleFile);\n      return 0;\n    }\n  } else {\n    if (templ != NULL) {\n      alienScale = 1;\n      scale = templ->scale;\n    } else {\n      scale = NULL;\n    }\n  }\n\n  // load feature selection(s)\n  if (fselectionFile != NULL) {\n    if (!loadSelection(fselectionFile,&fselection)) return 0;\n  } else {\n    if (templ != NULL) {\n      alienFselection = 1;\n      fselection = templ->fselection;\n    } else {\n      // dummy fsel with NULL values\n      fselection = (sFselectionData*)calloc(1,sizeof(sFselectionData)); \n    }\n  } \n\n  long svSize = 0;\n  if (isLibLinearModel) {\n#ifdef BUILD_LIBLINEAR\n    svSize = modelLinear->nr_feature;\n#endif\n  } else {\n    svSize = svm_get_sv_size(model);\n  }\n  // verify libsvm/liblinear model dimensions\n  int xret = 1;\n  if ((fselection != NULL) && (fselection->Nsel > 0 && fselection->Nsel != svSize)) {\n    SMILE_WRN(1,\"number of selected features (%i) does not match the data/vector size in the model (%i)!\", fselection->Nsel, svSize);\n    xret = 0;\n  }\n  if ((scale != NULL) && (scale->max_index != svSize)) {\n    SMILE_WRN(1,\"number of features to scale (%i) does not match the data/vector size in the model (%i)!\", scale->max_index, svSize);\n    xret = 0;\n  }\n  if ((xret == 0) && (!noVerify))\n    return 0;\n\n  //TODO: check consistency of model:\n  // nFsel == nScale == nFeaturesInModel !!\n  // class names\n  if (classesFile != NULL) {\n    if (nClasses>0) {\n      int nCls;\n      if (!(nCls = loadClasses(classesFile,&classNames))) return 0;\n      if (nCls != nClasses) {\n        SMILE_WRN(1,\"number of classes in classesFile (%i) doesn't match number of classes in model (%i) for model '%s' (classesfile = '%s')\",nCls,nClasses,modelFile,classesFile);\n      }\n    } else {\n      SMILE_WRN(2,\"not loading given class mapping file for regression SVR model (there are no classes...)!\");\n    }\n  } else {\n    if ((nClasses > 0)&&(templ!=NULL)) {\n      alienClassnames = 1;\n      classNames = templ->classNames;\n    }\n  }\n  return 1;\n}\n\n\n\nSMILE_THREAD_RETVAL libsvmliveThreadRunner(void *_data)\n{\n  if ((_data != NULL)) {\n    ((cLibsvmLiveSink *)_data)->classifierThread();\n  }\n  SMILE_THREAD_RET;\n}\n\nint cLibsvmLiveSink::myFinaliseInstance()\n{\n  int ret = cDataSink::myFinaliseInstance();\n  if (ret==0) return 0;\n\n  if (useThread) {\n    if (!loadModelBg) {\n      loadClassifier();\n      modelLoaded = 1;\n    }\n    // start the classifier background thread:\n    // this thread first loads the model and then processes data frames\n    smileMutexCreate(dataMtx);\n    smileMutexCreate(runningMtx);\n    smileCondCreate(dataCond);\n    threadRunning = 1;\n    if (!(int)smileThreadCreate(bgThread, libsvmliveThreadRunner, (void *)this)) {\n      SMILE_ERR(1,\"error creating libsvm background thread, multi-threading disabled!!\");\n      threadRunning = 0;\n    } else {\n      /* TODO: set thread priority ... */\n#ifdef __WINDOWS\n      SMILE_IMSG(3,\"current bgThread priority = %i\",GetThreadPriority(bgThread));\n      SetThreadPriority(bgThread, bgThreadPriority);\n      SMILE_IMSG(3,\"bgThread priority now set to %i\",GetThreadPriority(bgThread));\n#endif\n    }\n  } else {\n    loadClassifier();\n    modelLoaded = 1;\n  }\n  return ret;\n}\n\nvoid cLibsvmLiveSink::processResult(lsvmDataFrame *f, int modelIdx, int mmm /* multiModelMode */)\n{\n  //long long tick, long frameIdx, double time, float res, double *probEstim, char **classNames, int nClasses, double dur, int isFinal\n\n  int clIdx = -1;\n  if (printParseableResult || printResult || sendResult || saveResult) {\n    /*if (models[modelIdx].labels!=NULL) {\n      int r = (int)(f->res);\n      for (int i=0; i<models[modelIdx].nClasses; i++) {\n        if (models[modelIdx].labels[i] == r) { clIdx = i;  }\n      }\n      if (clIdx == -1) {\n        SMILE_IERR(1,\"svm error, result label (%f) not found in model->labels array!\",f->res);\n      }\n    } else {\n      clIdx = (int)(f->res);\n    }*/\n    // ??? ok ???\n    clIdx = (int)(f->res);\n  }\n\n  if (printParseableResult || printResult || saveResult) {\n    FILE * fl = NULL;\n    if (saveResult) {\n      fl = fopen(resultFile,\"a\");\n      if (fl==NULL) {\n        SMILE_IERR(1,\"cannot open result output file '%s' for writing (appending)! Disabling saving of classification result to file. No more errors will be shown.\");\n        saveResult = 0;\n      }\n    }\n\n    if ((models[modelIdx].nClasses > 0)&&(models[modelIdx].classNames != NULL)) {\n      if (clIdx >= models[modelIdx].nClasses) clIdx = models[modelIdx].nClasses;\n      else if (clIdx < 0) clIdx = 0;\n      if (printResult) {\n        SMILE_PRINT(\"\\n LibSVM  '%s' (#%i = %s) result [final=%i] (@ time: %f, vIdx: %ld) :  ~~> %s <~~\",getInstName(),modelIdx,models[modelIdx].modelResultName,f->isFinal,f->time, f->frameIdx, models[modelIdx].classNames[clIdx]);\n      }\n      if (printParseableResult) {\n        printf(\"SMILE-RESULT::ORIGIN=libsvm::TYPE=classification::COMPONENT=%s::VIDX=%ld::NAME=%s::CATEGORY_IDX=%i::CATEGORY=%s\", getInstName(), f->frameIdx, models[modelIdx].modelResultName, (int)(clIdx), models[modelIdx].classNames[clIdx]);\n      }\n      if (saveResult) {\n        fprintf(fl,\" LibSVM  '%s' (#%i = %s) result [final=%i] (@ time: %f, vIdx: %ld) :  ~~> %s <~~\\n\",getInstName(),modelIdx,models[modelIdx].modelResultName,f->isFinal,f->time, f->frameIdx, models[modelIdx].classNames[clIdx]);\n      }\n    } else {\n      if (printParseableResult) {\n        printf(\"SMILE-RESULT::ORIGIN=libsvm::TYPE=regression::COMPONENT=%s::VIDX=%ld::NAME=%s::VALUE=%e\", getInstName(), f->frameIdx, models[modelIdx].modelResultName, f->res);\n      }\n      if (printResult) {\n        SMILE_PRINT(\"\\n LibSVM  '%s' (#%i = %s) result [final=%i] (@ time: %f, vIdx: %ld) :  ~~> %.2f <~~\",getInstName(),modelIdx,models[modelIdx].modelResultName,f->isFinal,f->time, f->frameIdx, f->res);\n      }\n      if (saveResult) {\n        fprintf(fl,\" LibSVM  '%s' (#%i = %s) result [final=%i] (@ time: %f, vIdx: %ld) :  ~~> %.2f <~~\\n\",getInstName(),modelIdx,models[modelIdx].modelResultName,f->isFinal,f->time, f->frameIdx, f->res);\n      }\n    }\n    if (f->probEstim != NULL) {\n      int i;\n      if ((models[modelIdx].svmType==C_SVC || models[modelIdx].svmType==NU_SVC)) {\n        for (i=0; i<models[modelIdx].nClasses; i++) {\n          int idx = i;\n          if (models[modelIdx].labels!=NULL) idx = models[modelIdx].labels[i];\n          if ((models[modelIdx].nClasses > 0)&&(models[modelIdx].classNames != NULL)) {\n            if (idx >= models[modelIdx].nClasses) idx=models[modelIdx].nClasses-1;\n            if (idx < 0) idx = 0;\n            if (printParseableResult) {\n              printf(\"::PROB=%i;%s:%f\", idx, models[modelIdx].classNames[i], f->probEstim[idx]);\n            }\n            if (printResult) {\n              SMILE_PRINT(\"     prob. class '%s': \\t %f\",models[modelIdx].classNames[i],f->probEstim[idx]);\n            }\n            if (saveResult) {\n              fprintf(fl,\"     prob. class '%s': \\t %f\",models[modelIdx].classNames[i],f->probEstim[idx]);\n            }\n\n          } else {\n            if (printParseableResult) {\n              printf(\"::PROB=%i;:%f\", idx, f->probEstim[i]);\n            }\n            if (printResult) {\n              SMILE_PRINT(\"     prob. class %i : \\t %f\",idx,f->probEstim[i]);\n            }\n            if (saveResult) {\n              fprintf(fl,\"     prob. class %i : \\t %f\",idx,f->probEstim[i]);\n            }\n\n          }\n        }\n      } else {\n        if (printParseableResult) {\n          printf(\"::CONFIDENCE=%f\", f->svr_confidence);\n        }\n        if (printResult) {\n          SMILE_PRINT(\"     prob. of result : \\t %f\",f->svr_confidence);\n        }\n        if (saveResult) {\n          fprintf(fl,\"     prob. of result : \\t %f\",f->svr_confidence);\n        }\n      }\n    }\n    if (printParseableResult) {\n      printf(\"\\n\");\n    }\n    if (fl != NULL) fclose(fl);\n  }\n\n  // send result as componentMessage \n  if (sendResult && (!batchMode)) {\n    cComponentMessage msg(\"classificationResult\", resultMessageName);\n\t// msgtext contains classification result\n    if ((models[modelIdx].nClasses > 0)&&(models[modelIdx].classNames != NULL)) {\n      if (models[modelIdx].labels!=NULL) {\n        if ((int)(f->res) >= models[modelIdx].nClasses) f->res = (float)(models[modelIdx].nClasses-1);\n        if (f->res < 0.0) f->res = 0.0;\n        f->res = (float)models[modelIdx].labels[(int)(f->res)];\n      }\n      if ((int)(f->res) >= models[modelIdx].nClasses) f->res = (float)models[modelIdx].nClasses;\n      if (f->res < 0.0) f->res = 0.0;\n      strncpy(msg.msgtext, models[modelIdx].classNames[(int)clIdx], CMSG_textLen);\n    } else {\n\t  strncpy(msg.msgtext, \"_NUMERIC_\", 9);\n\t}\n    msg.floatData[0] = f->res;\n    // result confidence (float[1])\n    if (f->probEstim != NULL) {\n      if ((models[modelIdx].svmType==C_SVC || models[modelIdx].svmType==NU_SVC)) {\n        int idx=clIdx;\n        if (models[modelIdx].labels!=NULL) idx = models[modelIdx].labels[clIdx];\n        msg.floatData[1] = f->probEstim[idx];\n      } else {\n        msg.floatData[1] = f->probEstim[0];\n      }\n    } else {\n      msg.floatData[1] = 0.0;\n    }\n    msg.floatData[2] = msg.floatData[1];  // winning class probability\n    msg.intData[0]   = models[modelIdx].nClasses;\n    msg.intData[1]   = f->isFinal;\n    msg.intData[2]   = modelIdx;\n    msg.intData[3]   = mmm;\n    msg.intData[5]   = f->ID;\n    if (models[modelIdx].modelResultName != NULL) {\n      strncpy(msg.msgname, models[modelIdx].modelResultName, CMSG_typenameLen);\n    }\n    msg.custData     = f->probEstim;\n    msg.custData2    = (void *) ( models[modelIdx].modelResultName ); // dangerous conversion....! This is left only for backward compatibility. Use msgtext in new designs!!\n    msg.userTime1    = f->time;\n    msg.userTime2    = f->time + f->dur;\n\n    sendComponentMessage( resultRecp, &msg );\n    SMILE_IDBG(3,\"sending 'classificationResult' message to '%s'\",resultRecp);\n    // warning: the probEstim pointer is not valid anymore, after sendComponentMessage has exited..!\n  } else if (batchMode) {\n    int i;\n    // add result to cache..\n\n    resCache.res[resCache.nFilled] = f->res;\n    for (i=0; i<resCache.nTargets; i++) {\n      if ((i<f->nClasses)&&(f->probEstim != NULL)) resCache.prob[resCache.nFilled*resCache.nTargets+i] = f->probEstim[i];\n      else resCache.prob[resCache.nFilled*resCache.nTargets+i] = -1.0;\n    }\n    resCache.resnameA[resCache.nFilled] = models[modelIdx].modelResultName;\n    resCache.nFilled++;\n\n    if (f->isLast) { // send the message...\n      cComponentMessage msg(\"classificationResults\", resultMessageName);\n      msg.userTime1    = f->time;\n      msg.userTime2    = f->time + f->dur;\n      msg.intData[1]   = f->isFinal;\n      msg.custData     = (void *)&resCache;\n\n      sendComponentMessage( resultRecp, &msg );\n      for (i=0; i<resCache.nFilled; i++) {\n        //if (resCache.resnameA[i] != NULL) free(resCache.resnameA[i]);\n        resCache.resnameA[i] = NULL;\n      }\n      resCache.nFilled = 0;\n      SMILE_IDBG(3,\"sending 'classificationResults' message to '%s'\",resultRecp);\n    }\n\n  }\n}\n\n/*\nmulti classification result message:\n\nid[0] : nClasses (0=regression)\nid[1] : isFinal\nid[2] : nModels\nid[3] : 1 (to indicate multimodelmode)\nuserTime1 : segment start time\nuserTime2 : segment end time\n\ncustData : pointer to multi result struct:\n{\n  int nResults\n  double *res;\n  const char ** resnameA;\n  const char ** resnameB;\n}\n\n*/\n\n\nint cLibsvmLiveSink::buildEnabledSelFromNames(long N, const FrameMetaInfo *fmeta, sFselectionData *fselection)\n{\n  int n,i;\n  SMILE_IDBG(3,\"computing mapping from feature names to feature indicies\");\n  fselection->outputSelIdx.nFull = N;\n  fselection->outputSelIdx.nSel = fselection->outputSelStr.n;\n  fselection->outputSelIdx.enabled = (long *)calloc(1,sizeof(long)*fselection->outputSelIdx.nFull);\n  fselection->outputSelIdx.map = (long *)calloc(1,sizeof(long)*fselection->outputSelIdx.nSel);\n  int nEnab=0;\n  int *isFound = (int*)calloc(1,sizeof(int)*fselection->outputSelStr.n);\n  for (n=0; n<N; n++) {\n    //  int found=0;\n    //  SMILE_IDBG(4,\"selstr %i of %i\",i,outputSelStr.n);\n    const char * tmpname = reader_->getElementName(n);\n    \n    for (i=0; i<fselection->outputSelStr.n; i++) {\n      if (!isFound[i]) {\n        \n        if (!strcmp(tmpname,fselection->outputSelStr.names[i])) {\n          fselection->outputSelIdx.enabled[n] = 1;\n          fselection->outputSelIdx.map[i] = n;\n          nEnab++; isFound[i]=1;\n          break;\n        }\n      }\n    }\n    if (nEnab >= fselection->outputSelStr.n) break;\n    /*\n    if (found==0) {\n    SMILE_IERR(1,\"element '%s' requested in feature selection list, but it was not found in the input!\",outputSelStr.names[i]);\n    }*/\n  }\n\n  if (nEnab < fselection->outputSelStr.n) {\n    SMILE_IERR(1,\"%i features which were requested in feature selection file were not found in current input data! please check openSMILE config! These features are:\",fselection->outputSelStr.n-nEnab);\n    for (i=0; i<fselection->outputSelStr.n; i++) {\n      if (isFound[i]==0) {\n        SMILE_IERR(1,\"  element '%s' \",fselection->outputSelStr.names[i]);\n      }\n    }\n    abortLater=1;\n    //COMP_ERR(\"Your system will not run stable, since the models are incompatible with the currently extracted features. Thus, we are aborting here!\");\n  } else {\n    SMILE_IDBG(3,\"mapping computed successfully\");\n  }\n  free(isFound);\n  return 1;\n}\n\nint cLibsvmLiveSink::loadClassifier()\n{\n  // load model\n  SMILE_IMSG(2,\"loading LibSVM model(s) ...\"); \n  for (int i=0;i<nModels;i++) {\n    if (!models[i].load()) {\n      COMP_ERR(\"failed loading model %i (file: '%s')\",i,models[i].modelFile);\n    }\n  }\n\n  int ncMax = models[0].nClasses;\n  for (int i=1;i<nModels;i++) {\n    if (models[i].nClasses > ncMax) {\n      ncMax = models[i].nClasses;\n    }\n  }\n\n  // allocate result storage buffer\n  if (batchMode && nModels > 0) {\n    resCache.nResults = nModels;\n    resCache.nTargets = ncMax;\n    resCache.alloc();\n  }\n\n  // load feature selection(s)\n  long N = reader_->getLevelN();\n  const FrameMetaInfo *fmeta = reader_->getFrameMetaInfo();\n  \n  for(int i=0;i<nFselections;i++) {\n    SMILE_IDBG(2,\"building feature selection map for model %i\",i);\n    if (models[i].fselection->fselType) {\n      if ((models[i].fselection->outputSelIdx.enabled == NULL)&&(models[i].fselection->outputSelStr.names != NULL)) {\n        buildEnabledSelFromNames(N, fmeta, models[i].fselection);\n      } \n    }\n  }\n\n  SMILE_IMSG(2,\"Models loaded. Ready to classify!\"); \n  return 1;\n}\n\n// classify data frame with a single model\nvoid cLibsvmLiveSink::processDigestFrame(lsvmDataFrame * f, int modelIdx)\n{\n  if (models[modelIdx].isLibLinearModel) {\n#ifdef BUILD_LIBLINEAR\n    // TODO:\n    //double predict_values(const struct liblinear_model *model_, const struct svm_node *x, double* dec_values);\n    //double predict(const struct liblinear_model *model_, const struct svm_node *x);\n    //double predict_probability(const struct liblinear_model *model_, const struct svm_node *x, double* prob_estimates);\n    if ((models[modelIdx].predictProbability) && (models[modelIdx].svmType==C_SVC || models[modelIdx].svmType==NU_SVC)) {\n      f->res = liblinear_predict_probability(models[modelIdx].modelLinear, f->x, f->probEstim);\n      processResult(f, modelIdx, multiModelMode);\n    } else {\n      f->res = liblinear_predict(models[modelIdx].modelLinear, f->x);\n      //f->svr_confidence = svm_get_svr_probability(models[modelIdx].model);\n      processResult(f, modelIdx, multiModelMode);\n    }\n#else\n    SMILE_IERR(1, \"LibLINEAR not supported by this build version. Ignoring frame.\");\n#endif\n  } else {\n    if ( (models[modelIdx].predictProbability) && (models[modelIdx].svmType==C_SVC || models[modelIdx].svmType==NU_SVC) ) {\n      f->res = svm_predict_probability(models[modelIdx].model, f->x, f->probEstim);\n      processResult(f, modelIdx, multiModelMode);\n    } else {\n      f->res = svm_predict(models[modelIdx].model, f->x);\n      f->svr_confidence = svm_get_svr_probability(models[modelIdx].model);\n      processResult(f, modelIdx, multiModelMode);\n    }\n  }\n}\n\n// classify data frame with a single model or all models \nvoid cLibsvmLiveSink::digestFrame(lsvmDataFrame * f, int modelIdx)\n{\n  if (modelIdx == -1) { // all models\n    int i;\n    for (i=0; i<nModels; i++) {\n      if (i<nModels-1) { f->isFinal = 0; }\n      else { f->isFinal = 1; }\n      processDigestFrame(f,i);\n    }\n  } else { // single model\n    processDigestFrame(f,modelIdx);\n  }\n  delete f;\n}\n\nvoid cLibsvmLiveSink::classifierThread()\n{\n  //// this thread runs in a loop and waits for data to classify\n\n  // when a new message arrives a thread condition variable is signalled\n  smileMutexLock(runningMtx);\n  int _running = threadRunning;\n  smileMutexUnlock(runningMtx);\n\n  // load the model in the background...\n  if (!modelLoaded) loadClassifier(); // note: we don't need to lock the mutex right here, because the variable is set before the thread is called and only read from at the moment\n\n  smileMutexLock(dataMtx);\n  modelLoaded = 1;  \n\n  //smileMutexLock(dataMtx);\n  while (_running) {\n    if (!dataFrameQue->empty()) {\n      classifierThreadBusy = 1;\n\n      lsvmDataFrame *f = dataFrameQue->front();\n      dataFrameQue->pop();\n      smileMutexUnlock(dataMtx);\n\n      // classify frame...\n      if (f != NULL) {\n        if (f->modelchoice >= -1 && f->modelchoice < nModels) {\n          digestFrame(f, f->modelchoice);\n        } else {\n          SMILE_IERR(1,\"input frame dropped due to invalid model selection (out of range) [%i]  (valid: -1 - %i)\",f->modelchoice,nModels-1);\n        }\n      }\n\n    } else {\n      smileMutexUnlock(dataMtx);\n    }\n    \n    smileMutexLock(runningMtx);\n    _running = threadRunning;\n    smileMutexUnlock(runningMtx);\n\n    smileMutexLock(dataMtx);\n    if ((_running)&&(dataFrameQue->empty())) { \n      classifierThreadBusy = 0;\n      smileCondWaitWMtx(dataCond,dataMtx);\n    }\n  }\n  classifierThreadBusy = 0;\n  smileMutexUnlock(dataMtx);\n}\n\nint cLibsvmLiveSink::queFrameToClassify(lsvmDataFrame *fr)\n{\n  // add data in 'fr' to queue\n  smileMutexLock(dataMtx);\n  if ((threadQueSize > 0)&&(dataFrameQue->size() == threadQueSize)) {\n    lsvmDataFrame *f = dataFrameQue->front();\n    if (f != NULL) delete f; \n    dataFrameQue->pop();\n  }\n  classifierThreadBusy = 1;\n  dataFrameQue->push(fr);\n  smileMutexUnlock(dataMtx);\n\n  // signal thread condition\n  smileCondSignal(dataCond);\n\n  return 1;\n}\n\nstruct svm_node * cLibsvmLiveSink::preprocessFrame(int modelIdx, cVector *vec)\n{\n  struct svm_node *x = NULL;\n  long Nft = models[modelIdx].fselection->Nsel;\n  if (Nft <= 0) Nft = vec->N;\n\n  int i = 0;\n  int j = 0; \n  //double v;\n\n  // need one more for index = -1\n  x = (struct svm_node *) malloc( (Nft + 1) * sizeof(struct svm_node));\n\n  // select\n  if ((models[modelIdx].fselection->outputSelIdx.enabled == NULL)||(models[modelIdx].fselection->Nsel<=0)) {\n    // copy all features\n    for (i=0; i<vec->N; i++) {\n      x[i].index = i+1; // FIXME!!! +1 is ok??? (no!?)\n      x[i].value = (FLOAT_DMEM)(vec->dataF[i]);\n    }\n    x[i].index = -1;\n    x[i].value = 0.0;\n  } else {\n    // select features\n    for (i=0; i<models[modelIdx].fselection->Nsel; i++) {\n      x[i].index = i+1;\n      if ( (models[modelIdx].fselection->outputSelIdx.map[i] < vec->N)&&(models[modelIdx].fselection->outputSelIdx.map[i] >= 0) ) \n        x[i].value = (FLOAT_DMEM)(vec->dataF[models[modelIdx].fselection->outputSelIdx.map[i]]);\n      else \n        x[i].value = 0.0;\n    }\n    x[i].index = -1;\n    x[i].value = 0.0;\n  }\n\n  // scale  \n  if (models[modelIdx].scale != NULL) {\n    svm_apply_scale(models[modelIdx].scale, x);\n\n    if (forceScale) {\n      // clip values??\n      i=0;\n      while(1) {\n        if (x[i].index == -1) { break; }\n        else {\n          if (x[i].value > models[modelIdx].scale->upper) { x[i].value = models[modelIdx].scale->upper; }\n          else if (x[i].value < models[modelIdx].scale->lower) { x[i].value = models[modelIdx].scale->lower; }\n        }\n        i++;\n      }\n    }\n  }\n\n\n  return x;\n  /*\n  if (fselections[modelchoice].fselType) {\n    if ((fselections[modelchoice].outputSelIdx.enabled == NULL)&&(fselections[modelchoice].outputSelStr.names != NULL)) {\n      //buildEnabledSelFromNames(vec->N, vec->fmeta);\n      SMILE_IWRN(1,\"feature selection map was not yet built! this is a bug!\");\n    } else if (fselections[modelchoice].outputSelIdx.enabled == NULL) Nft = vec->N;\n  }\n  */\n  // TODO: fselection by names... \n  // TODO: compute Nsel in loadSelection\n}\n\n\nint cLibsvmLiveSink::myTick(long long t)\n{\n  if (abortLater) {\n    COMP_ERR(\"Your system will not run stable, since the models are incompatible with the currently extracted features. Thus, we are aborting here!\");\n  }\n  // check if model has been loaded\n  if (useThread && loadModelBg) {\n    smileMutexLock(dataMtx);\n    int _modelLoaded = modelLoaded;\n    smileMutexUnlock(dataMtx);\n    if (!_modelLoaded) {\n      cVector *vec= reader_->getNextFrame();\n      if (vec != NULL) { SMILE_IWRN(4,\"SVM model has not been loaded yet, discarding current input\"); }\n      return 0;\n    }\n  }\n\n  // check for valid models\n  if (multiModelMode) {\n    int i;\n    for (i=0; i<nModels; i++) {\n      if (models[i].model == NULL) {\n        SMILE_IERR(1,\"model %i == NULL, not classifying input...!\",i);\n        return 0;\n      }\n    }\n  } else {\n    if (models[currentModel].model == NULL) {\n      SMILE_IERR(1,\"model %i == NULL, not classifying input...!\",currentModel);\n      return 0;\n    }\n  }\n\n\n  cVector *vec= reader_->getNextFrame();\n  if (vec == NULL) {\n    /* here we must check if the que contains data and the background thread is processing \n       if the background thread is classifying we must return 1 here to prevent the main loop\n       from terminating, which will lead to invalid memory access from the classifier thread\n    */\n    smileMutexLock(dataMtx);\n    if (classifierThreadBusy) {\n      smileMutexUnlock(dataMtx);\n      return 1;\n    } else {\n      smileMutexUnlock(dataMtx);\n      return 0;\n    }\n  } \n  SMILE_DBG(4,\"tick # %i, classifiy value vector using LibSVM:\",t);\n  SMILE_IMSG(4,\"got a vector to process...\");\n\n  /* \n  A) multiModelMode:\n    a) all models independent\n    b) multi-models, common scaling, selection, names, etc.\n  B ) single model switching\n  */\n\n  long vi = vec->tmeta->vIdx;\n  double tm = vec->tmeta->smileTime;\n  double dur = vec->tmeta->lengthSec;\n  int isFinal = vec->tmeta->metadata.iData[0];\n  int customID = vec->tmeta->metadata.ID;\n\n  if (multiModelMode) {\n\n    struct svm_node * x = NULL;\n    lsvmDataFrame *f = NULL;\n    if (singlePreprocessMultiModel) {\n      long Nft = models[0].fselection->Nsel;\n      if (Nft <= 0) Nft = vec->N;\n\n      x = preprocessFrame(0, vec);\n      // the frame is created here, and freed by the thread when it is pop'ed from the queue\n      f = new lsvmDataFrame(x,(Nft + 1) * sizeof(struct svm_node), -1, t,vi,tm, 0.0, models[currentModel].predictProbability, models[currentModel].nClasses, dur, isFinal, customID);\n      f->setLast();\n      if ((useThread)&&(threadRunning)) {\n        queFrameToClassify(f);\n      } else { // run the old 'inline' code:\n        digestFrame(f, currentModel);\n      }\n\n    } else {\n\n      int i;\n      // NOTE: the threadQueSize must be larger in this case...(see fetchConfig())\n      for (i=0; i<nModels; i++) {\n        long Nft = models[i].fselection->Nsel;\n        if (Nft <= 0) Nft = vec->N;\n\n        x = preprocessFrame(i, vec);\n        // the frame is created here, and freed by the thread when it is pop'ed from the queue\n        f = new lsvmDataFrame(x,(Nft + 1) * sizeof(struct svm_node), i, t,vi,tm, 0.0, models[currentModel].predictProbability, models[currentModel].nClasses, dur, isFinal, customID);\n        if (i==nModels-1) { f->setLast(); }\n        if ((useThread)&&(threadRunning)) {\n          queFrameToClassify(f);\n        } else { // run the old 'inline' code:\n          digestFrame(f, i);\n        }\n      }\n\n    }\n\n    if (x != NULL)\n      free(x);\n\n  } else {\n    // verify currentModel\n    if (currentModel < 0) currentModel = 0;\n    if (currentModel >= nModels) currentModel = nModels-1;\n\n    long Nft = models[currentModel].fselection->Nsel;\n    if (Nft <= 0) Nft = vec->N;\n\n    struct svm_node * x = preprocessFrame(currentModel, vec);\n\n    // the frame is created here, and freed by the thread when it is pop'ed from the queue\n    lsvmDataFrame *f = new lsvmDataFrame(x,(Nft + 1) * sizeof(struct svm_node),currentModel ,t,vi,tm, 0.0, models[currentModel].predictProbability, models[currentModel].nClasses, dur, isFinal, customID);\n    f->setLast();\n\n    if ((useThread)&&(threadRunning)) {\n      queFrameToClassify(f);\n    } else { // run the old 'inline' code:\n      digestFrame(f, currentModel);\n    }\n\n    free(x);\n\n  }\n\n   // tick success\n  return 1;\n}\n\nint cLibsvmLiveSink::processComponentMessage( cComponentMessage *_msg )\n{\n  if (isMessageType(_msg,\"KeyClassforChord\"))  { // <- special message for ADMIRE\n    currentModel = (_msg->intData[0]);\n  } else if (isMessageType(_msg,\"svmSinkSetModel\"))  { // choose current SVM model by index // TODO: choose by name\n    currentModel = (_msg->intData[0]);\n  }\n\n  return 0;\n}\n\ncLibsvmLiveSink::~cLibsvmLiveSink()\n{\n  smileMutexLock(runningMtx);\n  threadRunning = 0;\n  smileMutexUnlock(runningMtx);\n\n  if (useThread) {\n    SMILE_IMSG(3,\"waiting for classifier thread to terminate ...\");\n  }\n  //    smileMutexUnlock(dataMtx);\n  // signal thread condition, to allow thread to wake and exit\n  smileCondSignal(dataCond);\n\n  if (useThread) {\n    smileThreadJoin(bgThread);\n    SMILE_IMSG(3,\"classifier thread terminated\");  \n  }\n\n  if (models != NULL)\n    delete[] models;\n\n  smileMutexDestroy(runningMtx);\n  smileMutexDestroy(dataMtx);\n  smileCondDestroy(dataCond);\n  if (dataFrameQue != NULL)\n    delete dataFrameQue;\n}\n\n\n/**************************************************************************/\n/*********              LibSVM   addon:   scale functions  ****************/\n/**************************************************************************/\n//\n// See src/classifiers/libsvm/COPYRIGHT for license and copying information !!\n// \n// Modified by Florian Eyben\n//\n\n#include <float.h>\n#include <string.h>\n#include <ctype.h>\n#include <stdlib.h>\n\n#ifndef __WINDOWS\n#define max(x,y) (((x)>(y))?(x):(y))\n#define min(x,y) (((x)<(y))?(x):(y))\n#endif\n\n/*\nstruct svm_scale {\nint max_index;\ndouble lower,upper;\ndouble y_lower,y_upper;\ndouble y_min,y_max;\ndouble *feature_max;\ndouble *feature_min;\n};\n*/\nchar *line = NULL;\nint max_line_len = 1024;\n\nchar* readline(FILE *input)\n{\n  int len;\n\n  if (line == NULL) line = (char *) calloc(1, max_line_len*sizeof(char));\n\n  if(fgets(line,max_line_len,input) == NULL)\n    return NULL;\n\n  while(strrchr(line,'\\n') == NULL)\n  {\n    max_line_len *= 2;\n    line = (char *) realloc(line, max_line_len);\n    len = (int) strlen(line);\n    if(fgets(line+len,max_line_len-len,input) == NULL)\n      break;\n  }\n  return line;\n}\n\nstruct svm_scale * svm_load_scale(const char* restore_filename)\n{\n\n  if (restore_filename==NULL) { return NULL; }\n\n  int idx, c;\n  FILE *fp_restore = NULL;\n  struct svm_scale *ret = NULL;\n  double fmin, fmax;\n  double y_max = -DBL_MAX;\n  double y_min = DBL_MAX;\n\n  fp_restore = fopen(restore_filename,\"r\");\n  if(fp_restore==NULL)\n  {\n    fprintf(stderr,\"can't open scale file %s\\n\", restore_filename);\n    return NULL;\n  }\n\n  c = fgetc(fp_restore);\n  if(c == 'y')\n  {\n    readline(fp_restore);\n    readline(fp_restore);\n    readline(fp_restore);\n  }\n  readline(fp_restore);\n  readline(fp_restore);\n\n  ret = (struct svm_scale *) calloc(1, sizeof(struct svm_scale) );\n  if (ret == NULL)\n  {\n    fprintf(stderr,\"Error allocating memory!\\n\");\n    return NULL;\n  }\n\n  while(fscanf(fp_restore,\"%d %*f %*f\\n\",&idx) == 1)\n    ret->max_index = max(idx,ret->max_index);\n\n  rewind(fp_restore);\n\n\n  ret->feature_max = (double *)calloc(1,(ret->max_index+1)* sizeof(double));\n  ret->feature_min = (double *)calloc(1,(ret->max_index+1)* sizeof(double));\n  ret->feature_min[0] = 0.0;\n  ret->feature_max[0] = 0.0;\n\n  if((c = fgetc(fp_restore)) == 'y')\n  {\n    fscanf(fp_restore, \"%lf %lf\\n\", &(ret->y_lower), &(ret->y_upper));\n    fscanf(fp_restore, \"%lf %lf\\n\", &(ret->y_min), &(ret->y_max));\n    ret->y_scaling = 1;\n  }\n  else {\n    ungetc(c, fp_restore);\n    ret->y_scaling = 0;\n  }\n\n  ret->lower = -1.0;\n  ret->upper = 1.0;\n\n  if (fgetc(fp_restore) == 'x') {\n    fscanf(fp_restore, \"%lf %lf\\n\", &(ret->lower), &(ret->upper));\n    while(fscanf(fp_restore,\"%d %lf %lf\\n\",&idx,&fmin,&fmax)==3)\n    {\n      if(idx<=ret->max_index)\n      {\n        ret->feature_min[idx] = fmin;\n        ret->feature_max[idx] = fmax;\n      }\n    }\n  }\n  fclose(fp_restore);\n\n  return ret;\n}\n\nvoid svm_destroy_scale(struct svm_scale *scale)\n{\n  if (scale) {\n    if (scale->feature_min) free(scale->feature_min);\n    if (scale->feature_max) free(scale->feature_max);\n    free(scale);\n  }\n}\n\nvoid svm_apply_scale(struct svm_scale *scale, struct svm_node * x)\n{\n  int i=0;\n  if (scale == NULL) return;\n  if (x == NULL) return;\n\n  while(1)\n  {\n    if (x[i].index == -1) break;\n\n    if (x[i].index <= scale->max_index)\n    {\n      int index = x[i].index;\n      double value = x[i].value;\n\n      /* skip single-valued attribute */\n      if(scale->feature_max[index] == scale->feature_min[index]) { \n        x[i].value = 0;  /* ??? */\n        i++; \n        continue; \n      }\n\n      if(value == scale->feature_min[index])\n        value = scale->lower;\n      else if(value == scale->feature_max[index])\n        value = scale->upper;\n      else\n        value = scale->lower + (scale->upper - scale->lower) *\n        (value- scale->feature_min[index])/\n        (scale->feature_max[index] - scale->feature_min[index]);\n\n      x[i].value = value;\n\n    }\n    i++;\n  }\n\n}\n\n#endif  // BUILD_COMPONENT_LibsvmLiveSink\n\n\n/**************************************************************************/\n\n"
  },
  {
    "path": "src/classifiers/svmSink.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nlinear svm classifier\n\n*/\n\n\n#include <classifiers/svmSink.hpp>\n\n#ifdef BUILD_COMPONENT_SvmSink\n#ifdef BUILD_MODELCRYPT\n#include <private/modelEncryption.hpp>\n#endif \n\n#define MODULE \"cSvmSink\"\n\nSMILECOMPONENT_STATICS(cSvmSink)\n\nSMILECOMPONENT_REGCOMP(cSvmSink)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CSVMSINK;\n  sdescription = COMPONENT_DESCRIPTION_CSVMSINK;\n\n  // we inherit cDataSink configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSink\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"model\",\"The name of the model file.\",(const char *)NULL);\n    ct->setField(\"printParseableResult\",\"1 = print easily parseable classification/regression result to stdout\", 0);\n    ct->setField(\"printResult\",\"1 = print classification/regression result to log\", 0);\n    ct->setField(\"saveResult\",\"filename of text file the result(s) will be saved to\", (const char*)NULL);\n    ct->setField(\"resultRecp\",\"List of component(s) to send 'classificationResult' messages to (use , to separate multiple recepients), leave blank (NULL) to not send any messages\",(const char *) NULL);\n    ct->setField(\"resultMessageName\",\"Freely defineable name that is sent with 'classificationResult' message\",\"svm_result\");\n    ct->setField(\"showStatsDebug\",\"1 = show internal values for debugging and sanity checks.\",0);\n    ct->setField(\"ignoreLogitModel\", \"1 = don't use a logistic model for probability estimates, if one is contained in the model.\", 0);\n\tct->setField(\"winningClassMethodName\", \"prob = use probabilties instead of votes to determine the winning class, if a logistic model is used. vote = use the standard majority voting based on the distance\",\"vote\");\n\n  )\n\n  SMILECOMPONENT_MAKEINFO(cSvmSink);\n}\n\nSMILECOMPONENT_CREATE(cSvmSink)\n\n//-----\n\ncSvmSink::cSvmSink(const char *_name) :\n  cDataSink(_name), modelObj(NULL),\n  saveResult(0), sendResult(0), printResult(0), printParseableResult(0),\n  ignoreLogitModel(0), winningClassMethodName(\"vote\")\n{\n\n}\n\nvoid cSvmSink::fetchConfig()\n{\n  cDataSink::fetchConfig();\n  \n  model = getStr(\"model\");\n  resultRecp = getStr(\"resultRecp\");\n  resultMessageName = getStr(\"resultMessageName\");\n  resultFile = getStr(\"saveResult\");\n  if (resultFile != NULL) { \n\t  saveResult = 1; \n  }\n  if (resultRecp != NULL) { \n\t  sendResult = 1; \n  }\n  printResult = getInt(\"printResult\");\n  printParseableResult = getInt(\"printParseableResult\");\n  ignoreLogitModel = getInt(\"ignoreLogitModel\");\n  winningClassMethodName = getStr(\"winningClassMethodName\");\n  if (!strncmp(winningClassMethodName, \"vote\", 2)) { \n\t  winningClassMethod = SVMSINK_WINNING_CLASS_VOTE;\n\t  usePairwiseCoupling = 0;\n\t  //\n  } else  if (!strncmp(winningClassMethodName, \"prob\", 2)) {\n\t  winningClassMethod = SVMSINK_WINNING_CLASS_PROB;\n\t  usePairwiseCoupling = 1;\n  } else {\n    SMILE_IERR(1, \"unknown value for winningClassMethod: '%s'. Using default 'vote'.\", winningClassMethodName);\n    winningClassMethod = SVMSINK_WINNING_CLASS_VOTE;\n }\n}\n\n\nint smileSvmModel::prepareModelStruct()\n{\n  int l = 1;\n\n  if (nPairs > 0) {\n    SMILE_IMSG(2,\"loading %i binary SVM model(s).\",nPairs);\n    binSvm = (struct smileBinarySvmModel *)calloc(1,sizeof(struct smileBinarySvmModel)*nPairs);\n  } else {\n    SMILE_IERR(1,\"Number of binary SVM models < 1 (%i). At least one model must be present. Your model file '%s' seems to be corrupt.\",nPairs,model);\n    l=0;\n  }\n\n  if (vectorDim < 1) {\n    SMILE_IERR(1,\"Number of attributes (elements of feature vectors) in model is < 1 (%i). Your model file '%s' seems to be corrupt.\",vectorDim,model);\n    l=0;\n  } else {\n    attributeNames = (char **)calloc(1,sizeof(char *)*vectorDim);\n  }\n\n  return 1;\n}\n\n\nint smileSvmModel::parseKernelType(char *line)\n{\n  if (!strncmp(line,\"Linear Kernel\",13)) {\n    return SMILESVM_KERNEL_LINEAR;\n  } \n  if (!strncmp(line,\"RBF Kernel\",10)) {\n    return SMILESVM_KERNEL_RBF;\n  }\n  if (!strncmp(line,\"Polynomial Kernel\",17)) {\n    return SMILESVM_KERNEL_POLYNOMIAL;\n  }\n  \n  return SMILESVM_KERNEL_UNKNOWN;\n}\n\n\n\n\nint smileSvmModel::parseNClasses(char * line)\n{\n  char * c = strchr(line, ',');\n  if (c!=NULL) *c = 0;\n  char * eptr = NULL;\n  long l = strtol(line,&eptr,10);\n  if (c!=NULL) *c = ',';\n  return l;\n}\n\nchar ** smileSvmModel::parseClassnames(char * line, int nClasses)\n{\n  char ** cln = NULL;\n  char * c = strchr(line, ',');\n  char * ln;\n  int i;\n\n  if (c!=NULL) {\n    smileUtil_stripline(&c);\n    ln = strdup(c+1);\n  }\n  \n  if (nClasses > 0) {\n    cln = (char **)calloc(1,sizeof(char *) * nClasses);\n    cln[0] = ln;\n    for (i=1; i<nClasses; i++) {\n      char * x = strchr(ln,',');\n      if (x!=NULL) {\n        *x = 0;\n        smileUtil_stripline(&ln); // strip end of previous token\n        x++;\n        smileUtil_stripline(&x); // strip beginning of current token\n        cln[i] = x;\n        ln = x;\n      } else {\n        SMILE_IERR(1,\"expected more class names (%i) than actually found! (Class names must be separated by ',')\",nClasses);\n      }\n    }\n    /*for (i=0; i<nClasses; i++) {\n      cln[i] = strdup(cln[i]);\n    }*/\n  }\n  return cln;\n}\n\nint smileSvmModel::parseInt(char * line)\n{\n  char * eptr = NULL;\n  long l = strtol(line,&eptr,10);\n  if (eptr != NULL && *eptr != 0) {\n    SMILE_IERR(1,\"excess characters ('%s') on a line where only a single integer number is expected (line nr. %i : '%s').\",eptr,lineNr,line);\n    return 0;\n  }\n  return l;\n}\n\nint smileSvmModel::getClassIndex(const char * c) \n{\n  int i;\n  if (c==NULL) { SMILE_IERR(1,\"Class name cannot be NULL in getClassIndex().\"); return 0; }\n  for (i=0; i<nClasses; i++) {\n    if (!strcmp(c,classnames[i])) {\n      return i;\n    }   \n  }\n  SMILE_IERR(1,\"Class index for class '%s' cannot be determined (nClasses=%i). This seems to be a bug!\",c,nClasses);\n  return 0;\n}\n\nint smileSvmModel::parseClassPair(struct smileBinarySvmModel *_s, char *inp)\n{\n  char * x = strchr(inp,',');\n  if (x != NULL) {\n    *x = 0;\n    _s->c1 = strdup(inp);\n    _s->c2 = strdup(x+1);\n    _s->ic1 = getClassIndex(_s->c1);\n    _s->ic2 = getClassIndex(_s->c2);\n  } else {\n    SMILE_IERR(1,\"Error parsing binary SVM class pair. There should be two names separated by a comma. Offending line: '%s'\",inp);\n    return 0;\n  }\n  return 1;\n}\n\nint smileSvmModel::parseLogisticModel(struct smileBinarySvmModel *_s, char *inp)\n{\n  char * x = strchr(inp,';');\n  if (x != NULL) {\n    char *eptr = NULL;\n    *x = 0;\n    double a = strtod(x+1,&eptr);\n    //if (eptr != NULL && eptr != x+1) { SMILE_IERR(1,\"Parse error while parsing logistic model of binary svm model (coeff1), token '%s'\",x+1); }\n    _s->logit_coeff1 = a;\n    eptr = NULL;\n    a = strtod(inp,&eptr);\n    //if (eptr != NULL && eptr != x+1) { SMILE_IERR(1,\"Parse error while parsing logistic model of binary svm model (coeff0), token '%s'\",inp); }\n    _s->logit_intercept = a;\n    _s->has_logit = 1;\n  } else {\n    SMILE_IERR(1,\"Error parsing binary SVM logistic model. There should be two coefficients separated by ';'. Offending line: '%s'\",inp);\n    return 0;\n  }\n  return 1;\n}\n\nint smileSvmModel::parseSVs(FLOAT_DMEM **_SV, int *_nSV, char * line, int idx)\n{\n  if (idx == 0 && *_SV == NULL) {\n    // read nSV\n    *_nSV = parseInt(line);\n    *_SV = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)* (*_nSV) * vectorDim);\n  } else {\n    int i=0;\n    char * x = strchr(line,',');\n    while(x != NULL) {\n      *x = 0;\n      (*_SV)[i*vectorDim+idx] = parseDouble(line);\n      line = x;\n      x = strchr(line,',');\n      i++;\n      if (i >= *_nSV-1) { break; }\n    }\n    (*_SV)[i*vectorDim+idx] = parseDouble(line);\n    idx++;\n  }\n  return idx;\n}\n\nFLOAT_DMEM smileSvmModel::parseDouble(char * line)\n{\n  char * eptr = NULL;\n  double d = strtod(line,&eptr);\n  if (eptr != NULL && *eptr != 0) {\n    SMILE_IERR(1,\"excess characters ('%s') on a line where only a single floating point value is expected (line nr. %i : '').\",eptr,lineNr,line);\n    return 0;\n  }\n  return (FLOAT_DMEM)d;\n}\n\nFLOAT_DMEM smileSvmModel::parseBias(char * line)\n{\n  if (!strncmp(line,\"BIAS: \",6)) { \n    line += 6;\n    smileUtil_stripline(&line);\n    return parseDouble(line);\n  } else {\n    SMILE_IERR(1,\"Expected BIAS: on line # %i in '%s' (found: '%s').\",lineNr,model,line);\n    return 0.0;\n  }\n}\n\nint smileSvmModel::parseEnd(char * line) \n{\n  if (!strncmp(line,\"++END++\",7)) {\n    return 1;\n  } else { \n    return 0; \n  }\n}\n\n\nint smileSvmModel::load()\n{\n  FILE *m = fopen(model,\"rb\");\n  if (m==NULL) {\n    SMILE_IERR(1,\"failed to open SVM model file '%s' for reading.\",model);\n    return 0;\n  }\n\n  int expectAttrNames = 0;\n  int expectHeader = 0;\n  int nAttrLoaded = 0;\n  int expectEnd = 0;\n  int properEnd = 0;\n  int encryptedFile = 0;\n  #ifdef BUILD_MODELCRYPT\n  cSmileModelcrypt crypt;\n  #endif\n  int magicNumber = fgetc(m);\n  if (magicNumber == 1) {\n    encryptedFile = 1;\n    SMILE_MSG(2, \"SVM file format: 2\");\n    // ignore magic number\n  } else {\n    SMILE_MSG(2, \"SVM file format: 1\");\n    fseek(m, 0, 0);\n    // first byte is part of text ...\n  }\n  \n  long read;\n  lineNr = 0;\n  \n  size_t lineLen=0;\n  char * line=NULL;\n\n  char * origline = NULL;\n  int l=1;\n  int binsvmIdx = -1;\n  int svIdx = 0;\n\n  int len=0;\n  int i=0, ncnt=0;\n  // get next non-empty line\n  do {\n    // read the next line from the text file\n    #ifdef BUILD_MODELCRYPT\n    read = crypt.getLine(&origline, &lineLen, m, encryptedFile);\n    #else \n    if (encryptedFile) {\n      SMILE_ERR(1, \"This model file (%s) type is not supported by this release of openSMILE.\");\n      fclose(m);\n      return 0;\n    } else {\n      read = smile_getline(&origline, &lineLen, m);\n    }\n    #endif\n    //origline = line;\n    line = origline;\n\n    if ((read > 0)&&(line!=NULL)) {\n      lineNr++;\n      len = smileUtil_stripline(&line);\n      if (len > 0) {\n        if (lineNr < 6) {\n\n          if ((lineNr == 1)&&((len<15)||(strncmp(line,\"SMILE SVM MODEL\",15)))) { // file magic\n            SMILE_IERR(1,\"The file '%s' does not seem to be a valid smile SVM model file. This first line of the file does not contain the identifier 'SMILE SVM MODEL'.\",model);\n            l = 0; \n          }\n          if (lineNr == 2) { // kernel type\n            kernelType = parseKernelType(line);\n          }\n          if (lineNr == 3) { // classes\n            nClasses = parseNClasses(line);\n            classnames = parseClassnames(line,nClasses);\n          }\n          if (lineNr == 4) { // number of pairwise binary SVMs\n            nPairs = parseInt(line);\n          }\n          if (lineNr == 5) { // number of attributes\n            vectorDim = parseInt(line);\n            //allocate memory\n            l = prepareModelStruct();\n            expectAttrNames = 1;\n          }\n\n        } else {\n          if (expectAttrNames) {\n            attributeNames[nAttrLoaded++] = strdup(line);\n            if (nAttrLoaded >= vectorDim) {\n              expectHeader = 2;\n              expectAttrNames = 0;\n            }\n          } else if (expectEnd) {\n            if (parseEnd(line)) {\n              properEnd = 1;\n              l=0;\n            } else if (!strncmp(line,\"##++LOGISTIC;\",13)) {\n              // parse logistic regression model for probability estimates\n              parseLogisticModel(&(binSvm[binsvmIdx]),line+13);\n            }\n            else if ((expectHeader == 2) && strncmp(line,\"##\",2)) { // ignore all lines beginning with ## to allow for extra model parameters\n              SMILE_IERR(1,\"Error reading model file '%s' on line %i. The next model was expected on this line, but the identifier '++BINARYSVM++: ' was not found!\",model,lineNr);\n              l=0;\n            }\n          } else if (expectHeader) {\n            if (!strncmp(line,\"++BINARYSVM++: \",15)) {\n              // class names for this pair ...\n              binsvmIdx++;\n              l = parseClassPair(&(binSvm[binsvmIdx]),line+15);\n              expectHeader = 0; svIdx = 0;\n            } \n            else if (!strncmp(line,\"##++LOGISTIC;\",13)) {\n              // parse logistic regression model for probability estimates\n              parseLogisticModel(&(binSvm[binsvmIdx]),line+13);\n            }\n            else if ((expectHeader == 2) && strncmp(line,\"##\",2)) { // ignore all lines beginning with ## to allow for extra model parameters\n              SMILE_IERR(1,\"Error reading model file '%s' on line %i. The next model was expected on this line, but the identifier '++BINARYSVM++: ' was not found!\",model,lineNr);\n              l=0;\n            }\n          } else if (svIdx < vectorDim) {\n            // read weights/SVs\n            svIdx = parseSVs(&(binSvm[binsvmIdx].SV),&(binSvm[binsvmIdx].nSV),line,svIdx);\n          } else {\n            // read SV weights & bias  // TODO: SV weights!\n            binSvm[binsvmIdx].bias = parseBias(line);\n            expectHeader = 2;\n\n            if (binsvmIdx == nPairs-1) { expectEnd = 1; }\n            else { expectEnd = 0; }\n          }\n        }\n      }\n    } else { \n      l=0; // EOF\n    }\n\n  } while (l);\n\n  if (!properEnd) {\n    SMILE_IERR(1,\"Premature End-of-file in model file '%s'. The file end marker line '++END++' was not found in %i lines read.\",model,lineNr);\n    l=0;\n  }\n\n  if (origline != NULL) free(origline);\n\n  fclose(m);\n\n  return properEnd;\n}\n\ndouble smileSvmModel::evalBinSvm(FLOAT_DMEM *v, int index) \n{\n  struct smileBinarySvmModel * m = &(binSvm[index]);\n  double d = 0.0;\n  int i;\n  if (kernelType == SMILESVM_KERNEL_LINEAR) {\n    if (ftSelMap == NULL) {\n      for (i=0; i<vectorDim; i++) {\n        d += v[i] * (m->SV[i]);\n      }\n    } else { // feature selection given in model (should be the default case...)\n      for (i=0; i<nFtSel; i++) {\n        d += v[ftSelMap[i]] * (m->SV[i]);\n      }\n    }\n    d += m->bias;\n  } else {\n    // TODO:\n\n  }\n  return d;\n}\n\n// compute logit prob for class 0\n// prob. for class 1 is (1-p(class0))\ndouble smileSvmModel::evalLogit(int index, double d) \n{\n  struct smileBinarySvmModel * m = &(binSvm[index]);\n  // sigmoid probability estimate:\n  if (m->has_logit) {\n    double z = m->logit_intercept + m->logit_coeff1 * d;\n    return 1.0 / (1.0 + exp(-z));\n  } else { \n    return -1.0;\n  }\n}\n\n// ps is array of probabilities for each pair\nFLOAT_DMEM * smileSvmModel::getPairwiseProbabilities(double **ps)\n{\n  FLOAT_DMEM * probs;\n  probs = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*nClasses);\n\n  int i,j;\n  //// compute sum of weights\n  double **wsum = new double *[nClasses];\n  for (i=0; i<nClasses; i++) {\n    wsum[i] = new double[nClasses];\n    for (j=0; j<nClasses; j++) {\n      wsum[i][j] = 0.0;\n    }\n  }\n  for (i=0; i<nPairs; i++) {\n    struct smileBinarySvmModel * m = &(binSvm[i]);\n    double w_sum = 0.0;\n    if (kernelType == SMILESVM_KERNEL_LINEAR) {\n      for (j=0; j<vectorDim; j++) {\n        w_sum += (double)fabs(m->SV[j]);\n      }\n    }\n\tif (m->ic1 > m->ic2) {\n\t\twsum[m->ic2][m->ic1] = w_sum;\n\t} else {\n\t\twsum[m->ic1][m->ic2] = w_sum;\n\t}\n  }\n\n  //// pairwise coupling algorithm\n  \n  // init p and u arrays\n  double * p = new double[nClasses];\n  for (i=0; i<nClasses; i++) {\n    p[i] = 1.0 / (double)nClasses;\n  }\n  double ** u;\n  u = new double *[nClasses];\n  for (i=0; i<nClasses; i++) {\n    u[i] = new double[nClasses];\n    for (j=i+1; j<nClasses; j++) {\n      u[i][j] = 0.5;\n    }\n  }\n  \n  // initial sum:\n  double * sum1 = new double[nClasses];\n  for (i=0; i<nClasses; i++) { \n    sum1[i] = 0.0; \n  }\n  for (i=0; i<nClasses; i++) {\n    for (j=i+1; j<nClasses; j++) {  \n      sum1[i] += wsum[i][j] * ps[i][j];\n      sum1[j] += wsum[i][j] * (1.0 - ps[i][j]);\n    }\n  }\n  \n  // iterative optimization\n  double * sum2 = new double[nClasses];\n  int changed = 0;\n  int nIterations = 0;\n  do {\n    changed = 0;\n    for (i=0; i<nClasses; i++) { \n      sum2[i] = 0.0; \n    }\n    for (i=0; i<nClasses; i++) {\n      for (j=i+1; j<nClasses; j++) {  \n        sum2[i] += wsum[i][j] * u[i][j]; \n        sum2[j] += wsum[i][j] * (1.0 - u[i][j]);\n      }\n    }\n\n    for (i=0; i<nClasses; i++) {\n      if ((sum1[i] == 0.0) || (sum2[i] == 0.0)) {\n        if (p[i] > 0.0) { \n          changed = 1; \n        }\n        p[i] = 0.0;\n      } else {\n        double f = sum1[i] / sum2[i];\n        double pOld = p[i];\n        p[i] *= f;\n        if (fabs(pOld-p[i]) > 0.001) { \n          changed = 1; \n        }\n      }\n    }\n\n    // normalise p\n    double psum = 0;\n    for (i=0; i<nClasses; i++) {\n      psum += p[i];\n    }\n    for (i=0; i<nClasses; i++) {\n      p[i] /= psum;\n      // we only add this to avoid hangs if probs. converge to 1\n      if (p[i] > 0.99999) { changed = 0; }\n    }\n    // update\n    for (i=0; i<nClasses; i++) {\n      for (j=i+1; j<nClasses; j++) {  \n        u[i][j] = p[i] / (p[i]+p[j]);\n      }\n    }\n    nIterations++;\n  } while (changed && nIterations < 500);\n\n  if (nIterations > 450) {\n    // This shouldn't be... if it is, we warn the user\n    SMILE_IWRN(3, \"High number of iterations in pairwise coupling! Check if your model is correct or if the data has problems..?\");\n  }\n  delete[] wsum;\n\n  for (i=0; i<nClasses; i++) {\n    delete[] u[i];\n    probs[i] = (FLOAT_DMEM)p[i];\n  }\n  delete[] p;\n  delete[] u;\n  delete[] sum1;\n  delete[] sum2;\n\n  return probs;\n}\n\n/*\n  probs will be a pointer to newly allocated space, which contains the probabilities for each class\n  if the model has a logisitic (sigmoid) model for probability estimation.\n  *conf will be set to a confidence value of the winning class (curently: average absolute distance to hyperplane)\n*/\nint smileSvmModel::evaluate(FLOAT_DMEM *v, long N, const char ** winningClass, FLOAT_DMEM ** probs, FLOAT_DMEM *conf, int winningClassMethod, int usePairwiseCoupling)\n{\n  int i,j;\n  int hasLogit=1;\n  double * dsum = new double[nClasses];\n  double * probsum = new double[nClasses];\n  int * result = new int[nClasses];\n  double ** ps;\n  ps = new double *[nClasses];\n  for (i=0; i<nClasses; i++) {\n    ps[i] = new double[nClasses];\n    for (j=i+1; j<nClasses; j++) {\n      ps[i][j] = 0.5;\n    }\n    dsum[i] = 0;\n    result[i] = 0;\n\t  probsum[i] = 0;\n  }\n\n  for (i=0; i<nPairs; i++) {\n    // get distance for each class pair\n    double d = evalBinSvm(v, i);\n    double p = evalLogit(i,d);\n    if (p == -1.0) hasLogit = 0;\n\n    // determine index of winning class\n    int winner;\n\n\t\n\tif (d < 0.0) winner = binSvm[i].ic1;\n\telse winner = binSvm[i].ic2;\n\n\tif (binSvm[i].ic1 > binSvm[i].ic2) {\n\t  ps[binSvm[i].ic2][binSvm[i].ic1] = 1 - p;\n\t} else {\n\t  ps[binSvm[i].ic1][binSvm[i].ic2] = p;\n\t}\n\n\t//printf(\"pair %i: d=%f , winner = %i (%s)\\n\",i,d,winner,classnames[winner]);\n\t// add up to majority vote...\n\tresult[winner]++;\n\tdsum[winner] += fabs(d);\n\n    if (!usePairwiseCoupling) {\n\t\tif (p < 0.5) {\n\t\t\twinner = binSvm[i].ic2;\n\t\t\tp = 1.0 - p;\n\t\t} else {\n\t\t\twinner = binSvm[i].ic1;\n\t\t}\n\t\tprobsum[winner] += p;\n\t} \n\n  }\n\n  // pairwise coupling of probabilites....\n  if (probs != NULL) {\n\t  if (hasLogit && ignoreLogitModel == 0) {\n\t\t  if (nPairs > 1 && usePairwiseCoupling) {\n\t\t\t  *probs = getPairwiseProbabilities(ps);\n\t\t  } else if (nPairs > 1) {\n\t\t\t  SMILE_IMSG(4,\"\\n  normalising probsum...\");\n\t\t\t  // normalise the probs in probsum to have sum 1\n\t\t\t  FLOAT_DMEM sumOfProbs = 0;\n\t\t\t  for (i=0; i<nClasses; i++) {\n\t\t\t\t  sumOfProbs += (FLOAT_DMEM)probsum[i];\n\t\t\t  }\n\t\t\t  *probs = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*nClasses);\n\t\t\t  for (i=0; i<nClasses; i++){\n\t\t\t\t  (*probs)[i] = (FLOAT_DMEM)probsum[i] / sumOfProbs;\n\t\t\t  }\n\t\t  } else {\n\t\t\t  *probs = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*nClasses);\n\t\t\t  (*probs)[0] = (FLOAT_DMEM)ps[binSvm[0].ic1][binSvm[0].ic2];\n\t\t\t  (*probs)[1] = (FLOAT_DMEM)( 1.0-ps[binSvm[0].ic1][binSvm[0].ic2] );\n\t\t  }\n\t  } else {\n\t\t  // use normalised # votes\n\t\t  *probs = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*nClasses); \n\t\t  for (i=0; i<nClasses; i++) {\n\t\t\t  (*probs)[i] = (FLOAT_DMEM)(result[i])/(FLOAT_DMEM)nPairs;\n\t\t  }\n\t  }\n  }\n  // find max\n\n  int max = 0; int maxC = 0; FLOAT_DMEM max_prob = 0;\n  if (winningClassMethod == SVMSINK_WINNING_CLASS_VOTE || probs == NULL || *probs == NULL) {\n\t  max = result[0];\n\t  for (i=1; i<nClasses; i++) {\n\t\t  \n\t\t  if (result[i] > max) { \n\t\t\t  maxC = i;\n\t\t\t  max = result[i];\n\t\t  } \n\t\t  // NOTE: weka does not do this part... WEKA choses only the first max. in case of evenness of votes\n\t\t  else if (result[i] == max) {\n\t\t\t  if (dsum[i] > dsum[maxC]) {\n\t\t\t\t  maxC = i;\n\t\t\t\t  max = result[i];\n\t\t\t  }\n\t\t  }\n\t  }\n  } else if (winningClassMethod == SVMSINK_WINNING_CLASS_PROB) {\n\t  max_prob = (*probs)[0];\n\t  for (i=1; i<nClasses; i++) {\n\t\t  if ((*probs)[i] > max_prob) {\n\t\t\t  maxC = i;\n\t\t\t  max_prob = (*probs)[i]; \n\t\t  } \n\t\t  SMILE_IMSG(4,\"\\n  Step %i: max=%f, probs=%f, maxC=%i\",i,max_prob,(*probs)[i],maxC);\n\t  }\n  }\n  if (showStatsDebug) {\n\t  // print result per class\n\t  for (i=0; i<nClasses; i++) {\n\t\t  if (probs != NULL && winningClassMethod == SVMSINK_WINNING_CLASS_PROB) { \n\t\t\t  fprintf(stderr,\"SVM result with probs, class %i/%i : probsum=%f , dsum=%f , prob=%f\\n\",i+1,nClasses,probsum[i],dsum[i],(*probs)[i]);\n\t\t  } else if (probs != NULL && winningClassMethod == SVMSINK_WINNING_CLASS_VOTE) {\n\t\t\t  fprintf(stderr,\"SVM result, class %i/%i : nVotes=%i , dsum=%f , prob=%f\\n\",i+1,nClasses,result[i],dsum[i],(*probs)[i]);\n\t\t  } else {\n\t\t\t  fprintf(stderr,\"SVM result, class %i/%i : nVotes=%i , dsum=%f\\n\",i+1,nClasses,result[i],dsum[i]);\n\t\t  }\n\t  }\n  }\n\n  SMILE_IMSG(4,\"\\n  Winning class: # %i (%s) (dsum=%f , #votes = %i).\",maxC,classnames[maxC],dsum[maxC],max);\n  if (conf != NULL) { *conf = (FLOAT_DMEM)fabs(dsum[maxC]); }\n\n  // return result\n  delete[] result;\n  delete[] dsum;\n  delete[] probsum;\n  for (i=0; i<nClasses; i++) {\n    if (ps[i] != NULL)\n      delete[] ps[i];\n  }\n  delete[] ps;\n  // delete pointers in ps!!??\n\n  if (winningClass != NULL) {\n    *winningClass = classnames[maxC];\n  }\n  return maxC;\n}\n\nint smileSvmModel::buildFtSelMap(int n, const char * name)\n{\n  if (name == NULL || n < 0) {\n    return -1;\n  }\n  if (ftSelMap == NULL) {\n    ftSelMap = (int *)malloc(sizeof(int) * vectorDim);\n    for (int i = 0; i < vectorDim; i++) {\n      ftSelMap[i] = -1;\n    }\n  }\n  int i = n;\n  int j = n - 1;\n  if (j >= vectorDim) {\n    j = vectorDim - 1;\n  }\n  do {\n    if (i < vectorDim) {\n      if (!strcmp(name, attributeNames[i])) {\n        ftSelMap[i] = n;\n        return i;\n      }\n      i++;\n    } else {\n      if (j < 0) { return -1; }\n    }\n    if (j >= 0) {\n      if (!strcmp(name, attributeNames[j])) {\n        ftSelMap[j] = n;\n        return j;\n      }\n      j--;\n    } else {\n      if (i >= vectorDim) { return -1; }\n    }\n  } while(1);\n  return -1;\n}\n\n// Checks the feature selection map for missing features,\n// after it has been fully built.\nint smileSvmModel::checkFtSelMap()\n{\n  for (int i = 0; i < vectorDim; i++) {\n    if (ftSelMap[i] == -1) {\n      SMILE_IERR(1, \"The attribute # %i (%s) in the model file (%s) does not exist in the input data level to this component!\", i, attributeNames[i], model);\n      return 0;\n    }\n  }\n  nFtSel = vectorDim;\n  return 1;\n}\n\nsmileSvmModel::~smileSvmModel()\n{\n  int i;\n  if (classnames != NULL) {\n    if (classnames[0] != NULL) free(classnames[0]);\n    free(classnames);\n  }\n  if (binSvm != NULL) {\n    for (i=0; i<nPairs; i++) {\n      if (binSvm[i].c1 != NULL) free(binSvm[i].c1);\n      if (binSvm[i].c2 != NULL) free(binSvm[i].c2);\n      if (binSvm[i].SV != NULL) free(binSvm[i].SV);\n    }\n    free(binSvm);\n  }\n  if (attributeNames != NULL) {\n    for (i=0; i<vectorDim; i++) {\n      if (attributeNames[i] != NULL) free(attributeNames[i]);\n    }\n    free(attributeNames);\n  }\n  if (ftSelMap != NULL)\n    free(ftSelMap);\n}\n\n\n\nint cSvmSink::myFinaliseInstance()\n{\n  int ret = cDataSink::myFinaliseInstance();\n\n  if ((ret)&&(model != NULL)) {\n    modelObj = new smileSvmModel((cSmileComponent*)this, model);\n    if (getInt(\"showStatsDebug\")) { \n      modelObj->setStatsDebug(); \n    }\n    if (ignoreLogitModel) {\n      modelObj->setIgnoreLogitModel();\n    }\n    ret = modelObj->load();\n    if (!ret) {\n      delete modelObj;\n      modelObj = NULL;\n    } else {\n      // build feature mapping table\n      SMILE_IMSG(3, \"Building feature index mapping table...\");\n      int N = reader_->getLevelN();\n      for (int i = 0; i < N; i++) {\n        char * name = reader_->getElementName(i);\n        if (name == NULL) {\n          SMILE_IERR(2, \"Cannot get name from input level for element # %i! Thus, cannot compute feature mapping. Unless the features in the model file are in exact the same order as in the input level (and none are missing in the model), the result of SVMSINK WILL PROBABLY BE WRONG!!\", i);\n        } else {\n          modelObj->buildFtSelMap(i, name);\n          free(name);\n        }\n      }\n      if (!modelObj->checkFtSelMap()) {\n        delete modelObj;\n        modelObj = NULL;\n        ret = 0;\n        SMILE_IERR(1, \"Aborting due to missing attributes in input level!\");\n      }\n      SMILE_IMSG(3, \"Done with building feature index mapping table.\");\n    }\n  }\n  return ret;\n}\n\n\nint cSvmSink::myTick(long long t)\n{\n  SMILE_DBG(4,\"tick # %i, reading value vector:\",t);\n  \n  cVector *vec= reader_->getNextFrame();\n  if (vec == NULL) return 0;\n  \n  int cls;\n  const char * name;\n  FLOAT_DMEM conf;\n  FLOAT_DMEM *probs=NULL;\n  cls = modelObj->evaluate(vec->dataF, vec->N, &name, &probs, &conf, winningClassMethod, usePairwiseCoupling);\n  // cls contains the index of the winning class, name the name, and conf the confidence measure\n\n  int isFinal = 0; // TODO: read this from meta-data\n  int ID = 0;      // TODO: read this from meta-data\n\n  if (printResult) {\n    SMILE_IMSG(1, \"\\n  ~~> SmileSVM classification result: class %i (%s) (conf=%f) <~~\",cls,name,conf); /*modelObj->className(cls)*/\n    // print probabilites...\n    if (probs != NULL) {\n      int i;\n      for (i = 0; i < modelObj->getNclasses(); i++) {\n        SMILE_IMSG(1, \"    prob class #%i (%s) = %f\", i, modelObj->className(i), probs[i]);\n      } \n    }\n  }\n  if (printParseableResult) { // standard parseable format\n    printf(\"SMILE-RESULT::ORIGIN=svmsmo::TYPE=classification::VIDX=%ld::NAME=%s::CATEGORY_IDX=%i::CATEGORY=%s::CONFIDENCE=%f\", vec->tmeta->vIdx, getInstName(), cls, name, conf);\n    if (probs != NULL) {\n      for (int i = 0; i < modelObj->getNclasses(); i++) {\n        printf(\"::PROB=%i;%s:%f\", i, modelObj->className(i), probs[i]);\n      }\n    }\n    printf(\"\\n\");\n  }\n\n  FILE * fl = NULL;\n  if (saveResult) {\n    fl = fopen(resultFile,\"a\");\n    if (fl==NULL) {\n      SMILE_IERR(1,\"cannot open result output file '%s' for writing (appending)! Disabling saving of classification result to file. No more errors will be shown.\");\n      saveResult = 0;\n    } else {\n      int i;\n      // time;length;classindex/value;classname;confidence;probs...\n      fprintf(fl,\"%f;%f;%f;%s;%f\",(float)vec->tmeta->time,(float)vec->tmeta->lengthSec,(float)cls,name,conf); /*modelObj->className(cls)*/\n      if (probs != NULL) {\n        for (i=0; i<modelObj->getNclasses(); i++) {\n          fprintf(fl,\";%f\",probs[i]);\n\t  //use the following instead if you want classnames in the resultsfile\n\t  //fprintf(fl,\";%s;%f\",modelObj->className(i),probs[i]);\n        } \n      }\n      fprintf(fl, \"\\n\");\n      fclose(fl);\n    }\n  }\n\n  if (sendResult) {\n    cComponentMessage msg(\"classificationResult\", resultMessageName);\n    msg.floatData[0] = (FLOAT_DMEM)cls;\n    msg.floatData[1] = conf;\n    msg.intData[0]   = modelObj->getNclasses(); // models[modelIdx].nClasses;\n    msg.intData[1]   = isFinal;\n    msg.intData[2]   = 0; // modelIdx\n    msg.intData[3]   = 0; // mmm; ??\n    msg.intData[5]   = ID; // f->ID;\n    if (name != NULL) {  // class name\n      strncpy(msg.msgtext, name, CMSG_textLen);\n    }\n    msg.custData     = (void *)probs; //f->probEstim;   // TODO: support probabilities\n    msg.custDataSize = modelObj->getNclasses() * sizeof(FLOAT_DMEM);\n    msg.custDataType = CUSTDATA_FLOAT_DMEM;\n    msg.custData2    = (void *) ( /*models[modelIdx].modelResultName*/ NULL ); // dangerous conversion....!\n    msg.userTime1    = vec->tmeta->time;\n    msg.userTime2    = vec->tmeta->time + vec->tmeta->lengthSec;\n    sendComponentMessage( resultRecp, &msg );\n    SMILE_IDBG(3,\"sending 'classificationResult' message to '%s'\",resultRecp);\n  }\n  if (probs != NULL) free(probs);\n\n  // tick success\n  return 1;\n}\n\n\ncSvmSink::~cSvmSink()\n{\n  if (modelObj != NULL) delete modelObj;\n}\n\n#endif // BUILD_SMOSVM\n"
  },
  {
    "path": "src/core/commandlineParser.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*\n openSMILE commandline parser\n\n\n*/\n\n\n#include <core/commandlineParser.hpp>\n\n#define MODULE \"commandlineParser\"\n\ncCommandlineParser::cCommandlineParser(int _argc, const char ** _argv) :\n  active(0),\n  N(0),\n  opt(NULL),\n  argc(0),\n  argv(NULL),\n  Nalloc(0)\n{\n  if (_argc > 0) {\n    argc = _argc;\n    argv = _argv;\n    active = 1;\n    Nalloc = N_ALLOC_BLOCK;\n    opt = (struct sCmdlineOpt *)calloc(1,sizeof(struct sCmdlineOpt)*Nalloc);\n  }\n}\n\ncCommandlineParser::~cCommandlineParser()\n{\n  int i;\n  if (opt != NULL) {\n    for (i=0; i<N; i++) {\n      if (opt[i].description != NULL) free(opt[i].description);\n      if (opt[i].dfltStr != NULL) free(opt[i].dfltStr);\n    }\n    free(opt);\n  }\n}\n\nint cCommandlineParser::getWrIdx()\n{\n  if (N>=Nalloc) {\n    struct sCmdlineOpt *tmp = (struct sCmdlineOpt *)calloc(1,sizeof(struct sCmdlineOpt)*(N+N_ALLOC_BLOCK));\n    if (tmp==NULL) OUT_OF_MEMORY;\n    memcpy( tmp, opt, sizeof(struct sCmdlineOpt)*Nalloc );\n    free(opt); opt = tmp;\n    Nalloc = N+N_ALLOC_BLOCK;\n  }\n  return N++;\n}\n\nint cCommandlineParser::addOpt( const char *name, char abbr, const char *description, int argMandatory, int isMandatory)\n{\n  if ((abbr == 'h')||((name != NULL)&&(name[0]=='h')&&(name[1]==0))) {\n    COMP_ERR(\"option -h is reserved for show usage internally! please chose another name in your code! sorry..\");\n  }\n  int n = getWrIdx();\n  if (name == NULL) COMP_ERR(\"addOpt: cannot add commandlineParser option with name==NULL!\");\n  size_t l = strlen(name)+1;\n  if (l > STRLEN_NAME) COMP_ERR(\"addOpt: name is longer then %i characters (legnth(name) = %i charachters)! increase STRLEN_NAME in commandlineParser.cpp!\",STRLEN_NAME,l);\n  memcpy(opt[n].name,name,l);\n  opt[n].abbr = abbr;\n  opt[n].description = strdup(description);\n  opt[n].argMandatory = argMandatory;\n  opt[n].isMandatory = isMandatory;\n  opt[n].isSet = 0;\n  return n;\n}\n\nint cCommandlineParser::addBoolean( const char *name, char abbr, const char *description , int dflt, int argMandatory, int isMandatory )\n{\n  int n = addOpt(name,abbr,description, argMandatory, isMandatory);\n  opt[n].dfltInt = dflt;\n  opt[n].type = CMDOPT_BOOLEAN;\n  return n;\n}\n\nint cCommandlineParser::addInt( const char *name, char abbr, const char *description , int dflt, int argMandatory, int isMandatory )\n{\n  int n = addOpt(name,abbr,description, argMandatory, isMandatory);\n  opt[n].dfltInt = dflt;\n  opt[n].dfltDouble = (double)dflt;\n  opt[n].type = CMDOPT_INT;\n  return n;\n}\n\nint cCommandlineParser::addDouble( const char *name, char abbr, const char *description, double dflt, int argMandatory, int isMandatory )\n{\n  int n = addOpt(name,abbr,description, argMandatory, isMandatory);\n  opt[n].dfltDouble = dflt;\n  opt[n].dfltInt = (int)dflt;\n  opt[n].type = CMDOPT_DOUBLE;\n  return n;\n}\n\nint cCommandlineParser::addStr( const char *name, char abbr, const char *description, const char *dflt, int argMandatory, int isMandatory )\n{\n  int n = addOpt(name,abbr,description, argMandatory, isMandatory);\n  if (dflt != NULL)\n    opt[n].dfltStr = strdup(dflt);\n  else\n    opt[n].dfltStr = NULL;\n  opt[n].type = CMDOPT_STR;\n  return n;\n}\n\n\n/* find index of option \"name\", return index upon success, else return -1 */\nint cCommandlineParser::findOpt( const char *name ) const\n{\n  int i;\n  if (name == NULL) return -1;\n  for (i=0; i<N; i++) {\n    if (!strcmp(opt[i].name, name)) return i;\n  }\n  // experimental: support for abbr...\n  if (strlen(name) == 1) {\n    char c = name[0];\n    for (i=0; i<N; i++) {\n      if (opt[i].abbr == c) return i;\n    }\n  }\n  return -1;\n}\n\nint cCommandlineParser::getBoolean( const char *name ) const\n{\n  int n = findOpt( name );\n  if (n >= 0) {\n    if ((opt[n].type != CMDOPT_BOOLEAN)&&(opt[n].type != CMDOPT_INT))\n      { COMP_ERR(\"requested commandline argument '%s' is not of type boolean or int!\"); }\n    return opt[n].dfltInt;\n  } else {\n    COMP_ERR(\"boolean commandline argument '%s' not found in commandline parser object!\",name);\n  }\n  return 0;\n}\n\nint cCommandlineParser::getInt( const char *name ) const\n{\n  int n = findOpt( name );\n  if (n >= 0) {\n    if (opt[n].type != CMDOPT_INT)\n      { COMP_ERR(\"requested commandline argument '%s' is not of type int!\"); }\n    return opt[n].dfltInt;\n  } else {\n    COMP_ERR(\"int commandline argument '%s' not found in commandline parser object!\",name);\n  }\n  return 0;\n}\n\ndouble cCommandlineParser::getDouble( const char *name ) const\n{\n  int n = findOpt( name );\n  if (n >= 0) {\n    if (opt[n].type != CMDOPT_DOUBLE)\n      { COMP_ERR(\"requested commandline argument '%s' is not of type double!\"); }\n    return opt[n].dfltDouble;\n  } else {\n    COMP_ERR(\"floating point commandline argument '%s' not found in commandline parser object!\",name);\n  }\n  return 0;\n}\n\nconst char * cCommandlineParser::getStr( const char *name ) const\n{\n  int n = findOpt( name );\n  if (n >= 0) {\n    if (opt[n].type != CMDOPT_STR)\n      { COMP_ERR(\"requested commandline argument '%s' is not of type string!\"); }\n    return opt[n].dfltStr;\n  } else {\n    COMP_ERR(\"string commandline argument '%s' not found in commandline parser object!\",name);\n  }\n  return 0;\n}\n\nint cCommandlineParser::isSet( const char *name ) const\n{\n  int n = findOpt( name );\n  if (n >= 0) {\n    return opt[n].isSet;\n  }\n  return 0;\n}\n\nint cCommandlineParser::doParse(int ignDupl, int ignUnknown)\n{\n  int expectOpt = 1;\n  int showusage = 0;\n\n  // foreach argv element with(--) or (-), find the thing in opt\n  int i,n;\n  SMILE_DBG(3,\"about to parse %i commandline options \",argc-1);\n  for (i=1; i<argc; i++) {\n    SMILE_DBG(5,\"parsing option %i : '%s'\",i,argv[i]);\n    if ((unsigned char)argv[i][0] > 127) {\n      SMILE_ERR(0, \"Please don't be lazy and copy & paste the commandlines from the SMILE book PDF. Your commandline contains invalid ASCII characters (probably incorrect '-'es) as a result of this and might not be parsed correctly! Type the commandline from scratch to avoid errors.\");\n      SMILE_ERR(0, \"The offending argument is: '%s'\", argv[i]);\n      COMP_ERR(\"Parse error.\");\n    }\n    if (argv[i][0] == '-') { // option...?\n      if ((argv[i][1] == 'h')&&(argv[i][2] == 0)) { // usage (-h)\n        showusage = 1;\n      } else {\n        const char *o = argv[i]+1;\n        if (o[0] == '-') o++;\n        n = findOpt(o);\n        if (n >= 0) { // found!\n          if (opt[n].isSet == 1) { // option specified twice...!\n            if (!ignDupl) {  // if ignDupl == 1, we supress this error message\n              SMILE_ERR(0,\"duplicate option '%s' on commandline (ignoring duplicate!) \",o);\n            }\n            if (opt[n].nArgSet > 0) {\n              i += opt[n].nArgSet;\n            }\n          } else {\n          // now look for value....\n          if (i+1 < argc) {\n            int optCand = 0;\n            if (argv[i+1][0] == '-') optCand = 1;  // argument might be an option... or a negative numeric\n            int v;\n            double vd;\n            const char *o2;\n            char *ep = NULL;\n            \n            // parse value according to type...\n            switch (opt[n].type) {\n              case CMDOPT_BOOLEAN:\n                if (!optCand) {  // explicit value given\n                  i++; // next parameter of commandline\n                  if ((argv[i][0] == '0')||(argv[i][0] == 'N')||(argv[i][0] == 'n')||(argv[i][0] == 'F')||(argv[i][0] == 'f')) opt[n].dfltInt = 0;\n                  else if ((argv[i][0] == '1')||(argv[i][0] == 'Y')||(argv[i][0] == 'y')||(argv[i][0] == 'T')||(argv[i][0] == 't')) opt[n].dfltInt = 1;\n                } else {\n                  if (opt[n].dfltInt == 0) opt[n].dfltInt = 1;  // invert boolean default, if option is given\n                  else {\n                    SMILE_WRN(4, \"setting boolean option '%s' inverts default (true) to false.\", argv[i]);\n                    opt[n].dfltInt = 0;\n                  }\n                }\n                opt[n].isSet = 1;\n                opt[n].nArgSet = 0;\n                break;\n              case CMDOPT_INT:\n                //  parse value:\n                errno=0;\n                v = strtol(argv[i+1],NULL,10); // values base 10... TODO: support hex\n                if ( (optCand) && ((v==0)&&(errno==EINVAL)) ) { // option... no value given\n                    if (opt[n].argMandatory) COMP_ERR(\"option '%s' requires an argument!\",o);\n                    else {\n                      opt[n].isSet = 1;\n                      opt[n].nArgSet = 0;\n                    }\n                } else {\n                  if ((v==0)&&(errno==EINVAL)) COMP_ERR(\"invalid value specified for commandline option '%s'\",o);\n                  if ((v==0)&&(errno==ERANGE)) COMP_ERR(\"value specified for commandline option '%s' is out of range\",o);\n                  opt[n].dfltInt = v;\n                  opt[n].dfltDouble = (double)v;\n                  opt[n].isSet = 1;\n                  opt[n].nArgSet = 1;\n                  i++; // next parameter of commandline\n                }\n                break;\n              case CMDOPT_DOUBLE:\n                //  parse value:\n                vd = strtod(argv[i+1],&ep);\n                if ( (optCand) && ((vd==0.0)&&(ep==argv[i+1])) ) { // option... no value given\n                    if (opt[n].argMandatory) COMP_ERR(\"option '%s' requires an argument!\",o);\n                    else {\n                      opt[n].isSet = 1;\n                      opt[n].nArgSet = 0;\n                    }\n                } else {\n                  if ((vd==0)&&(ep==argv[i+1])) COMP_ERR(\"invalid value specified for commandline option '%s'\",o);\n                  //if ((v==0)&&(errno==ERANGE)) COMP_ERR(\"value specified for commandline option '%s' is out of range\",o);\n                  opt[n].dfltDouble = vd;\n                  opt[n].dfltInt = (int)vd;\n                  opt[n].isSet = 1;\n                  opt[n].nArgSet = 1;\n                  i++; // next parameter of commandline\n                }\n                break;\n              case CMDOPT_STR:\n                if (optCand) {  // bad situation... look for option\n                  o2 = argv[i+1]+1;\n                  if (o2[0] == '-') o2++;\n                  int tmp = findOpt(o2);\n                  if (tmp >= 0) { // next option\n                    if (opt[n].argMandatory) COMP_ERR(\"option '%s' requires an argument!\",o);\n                    else {\n                      opt[n].isSet = 1;\n                      opt[n].nArgSet = 0;\n                    }\n                  } else { // string value\n                    i++; // next parameter of commandline\n                    if (opt[n].dfltStr != NULL) free(opt[n].dfltStr);\n                    opt[n].dfltStr = strdup(argv[i]);\n                    opt[n].isSet = 1;\n                    opt[n].nArgSet = 1;\n                  }\n                } else { // string value\n                  i++; // next parameter of commandline\n                  if (opt[n].dfltStr != NULL) free(opt[n].dfltStr);\n                  opt[n].dfltStr = strdup(argv[i]);\n                  opt[n].isSet = 1;\n                  opt[n].nArgSet = 1;\n                }\n                break;\n              default:\n                COMP_ERR(\"unknown option type (%i) encountered... this actually cannot be!\",opt[n].type);\n            }\n          } else {  // no value... check if one is required... \n            if (opt[n].argMandatory) COMP_ERR(\"option '%s' requires an argument!\",o);\n            else {\n              // process boolean option, if boolean, else ignore...\n              if (opt[n].type == CMDOPT_BOOLEAN) {\n                if (opt[n].dfltInt == 0) opt[n].dfltInt = 1;  // invert boolean default, if option is given\n                else {\n                  SMILE_WRN(4, \"setting boolean option '%s' inverts default (true) to false.\", argv[i]);\n                  opt[n].dfltInt = 0;\n                }\n              }\n              opt[n].isSet = 1;\n              opt[n].nArgSet = 0;\n            }\n          }\n          }\n        } else {\n          if (!ignUnknown) {\n            SMILE_ERR(0,\"doParse: unknown option '%s' on commandline!\",argv[i]);\n          }\n        }\n      } // end: if option == -h\n    }\n  }\n\n  // TODO: from argv[0] get correct 'binname' to pass to showUsage\n  if (showusage) {\n    showUsage();\n    return -1;\n  }\n  \n  // now check if all mandatory parameters have been specified...\n  int err = 0;\n  for (i=0; i<N; i++) {\n    if ( (opt[i].isSet == 0)&&(opt[i].isMandatory == 1) ) { SMILE_ERR(0,\"mandatory commandline option '%s' was not specified!\",opt[i].name); err = 1; }\n  }\n  if (err) {\n    showUsage();\n    SMILE_ERR(0,\"missing options on the commandline!\");\n    return -1;\n  }\n  \n  return 0;\n}\n\nvoid cCommandlineParser::showUsage(const char *binname)\n{\n  smilePrintHeader();\n  if (binname == NULL) {\n    SMILE_PRINT(\"Usage: SMILExtract [-option (value)] ...\");\n  } else {\n    SMILE_PRINT(\"Usage: %s [-option (value)] ...\",binname);\n  }\n  SMILE_PRINT(\" \");\n  SMILE_PRINT(\" -h    Show this usage information\");\n  SMILE_PRINT(\" \");\n  int i;\n  for (i=0; i<N; i++) {\n    const char *ty=\"\";\n    switch (opt[i].type) {\n      case CMDOPT_BOOLEAN:\n        if (opt[i].argMandatory) ty=\"<boolean 0/1>\";\n        else ty=\"[boolean 0/1]\";\n        break;\n      case CMDOPT_INT:\n        if (opt[i].argMandatory) ty=\"<integer value>\";\n       else ty=\"[integer value]\";\n        break;\n      case CMDOPT_DOUBLE:\n        if (opt[i].argMandatory) ty=\"<float value>\";\n        else ty=\"[float value]\";\n        break;\n      case CMDOPT_STR:\n        if (opt[i].argMandatory) ty=\"<string>\";\n        else ty=\"[string]\";\n        break;\n      default:\n        COMP_ERR(\"showUsage: unknown option type encountered! (ty=%i for opt # %i)\",opt[i].type,i);\n    }\n    if (opt[i].abbr != 0) {\n      SMILE_PRINT(\" -%c, -%s  \\t %s\",opt[i].abbr,opt[i].name,ty);\n    } else {\n      SMILE_PRINT(\" -%s      \\t %s\",opt[i].name,ty);\n    }\n    if (opt[i].description) {\n      SMILE_PRINT(\"     %s\",opt[i].description);\n    }\n    switch (opt[i].type) {\n      case CMDOPT_BOOLEAN:\n      case CMDOPT_INT:\n        SMILE_PRINT(\"     {{ default = %i }}\",opt[i].dfltInt);\n        break;\n      case CMDOPT_DOUBLE:\n        SMILE_PRINT(\"     {{ default = %f }}\",opt[i].dfltDouble);\n        break;\n      case CMDOPT_STR:\n        SMILE_PRINT(\"     {{ default = '%s' }}\",opt[i].dfltStr);\n        break;\n      default:\n        COMP_ERR(\"showUsage: unknown option type encountered! (ty=%i for opt # %i)\",opt[i].type,i);\n    }\n    SMILE_PRINT(\" \");\n  }\n}\n\n"
  },
  {
    "path": "src/core/componentManager.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*\n\ncentral object to manage all components\n\ncomponentManager registers a config type, which specifies the component list.\nExample:\n\n[componentInstances:cComponentManager]\ninstance[myWavReader].type = cWavReader\ninstance[myWavReader].configInstance = wavReader1Config\ninstance[myXYZcomp].type = cCompType\n...\n\n\n\n*********init procedure:\n\ncreate componentManager\nregister all components (from componentlist, or later from dyn. libs)\nload smile and componentManger config\ncreate component instances (datamemory, readers, writers, and the rest)\nconfigure all instances (once all instances are ready) [writers register dataMemory levels, etc.,]\nfinalise all instances (if all instances are configured, datamemory finalises here! (datamemory does sanity check on r/w level usage during finalise)\n\ntick() loop\n\n?? -> exit? external signal(ctrl+c, message, etc.) + component exception or state..? (e.g. EOF input file)\nOR: no progress for X ticks..?\n=> implement mechanism for signalling end-of-processing (EOP) to component manager (e.g. new exception type?)\nPROBLEM: if end-of-input is reached, then there might be more processing required till we are completely finished...\n(only components without a data reader can signal EOP?)\nTHUS: no progress for X ticks..AFTER at least one component has signalled EOP?\n\n???? support reconf via componentManager ????\n*/\n\n#include <core/componentManager.hpp>\n\n\n//TODO:\n/*\nhandle component creation, config, and finalisation better, give more suitable (success/fail) debug messages\nhalt on config and/or finalise errors\nallow manual configuration of components by calling create, config, and finalise seperately\n(however, also allow for single call setup (default!))\n*/\n\n\n// global component list: -----------------\n/* list all built-in components here... \nAlso be sure to include the necessary component header files\n*/\n#include <core/componentList.hpp>\n\n#define MODULE \"cComponentManager\"\n\n//-----------------------------------------\n\n\n\n/************************/\n\nvoid cComponentManager::registerType(cConfigManager *_confman) {\n  //confman = _confman;\n  if (_confman != NULL) {\n    ConfigType *comp = new ConfigType(\"cComponentManagerInst\");\n    if (comp == NULL) OUT_OF_MEMORY;\n    comp->setField( \"type\", \"name of component type to create an instance of\", (char*)NULL);\n    comp->setField( \"configInstance\", \"config instance to connect to component instance (UNTESTED?)\", (char*)NULL);\n    comp->setField( \"threadId\", \"thread nr. to run this component in (default = -1: either run in 1st thread or automatically run each component in one thread if nThread==0)\", -1);\n\n    ConfigType *complist = new ConfigType( \"cComponentManager\" );\n    if (complist == NULL) OUT_OF_MEMORY;\n    complist->setField( \"instance\", \"Associative array storing component list.\\n   Array indicies are the instance names.\",\n      comp, 1 );\n    complist->setField( \"printLevelStats\", \"1 = print detailed information about data memory level configuration, 2 = print even more details (?)\",1);\n    complist->setField( \"profiling\", \"1 = collect per component instance run-time stats and show summary at end of processing.\", 0);\n    complist->setField( \"nThreads\", \"number of threads to run (0=auto(=one thread per component), >0 = actual number of threads\",1);\n    complist->setField( \"threadPriority\", \"The default thread scheduling priority (multi-thread mode) or the priority of the single thread (single thread mode). 0 is normal priority (-15 is background/idle priority, +15 is time critical). This option is currently only supported on windows!\",0);\n    //#ifdef DEBUG\n    complist->setField( \"execDebug\", \"print summary of component run statistics to log for each tick\", 0);\n    complist->setField( \"oldSingleIterationTickLoop\", \"1 = run the old single iteration tick loop with a single EOI tick loop after the main tick loop. Use this for backwards compatibility for older configs with components such as fullinputMean.\", 0);\n    //#endif\n    ConfigInstance *Tdflt = new ConfigInstance( \"cComponentManagerInst\", complist, 1 );\n    _confman->registerType(Tdflt);\n    //confman->registerType( complist );\n  } else {\n    SMILE_ERR(1,\"cannot register component manager config type! _confman is NULL in registerType()!\");\n  }\n}\n\n/********************/\n\n// sComponentInfo *comps; // component types\n\nint cComponentManager::registerComponent(sComponentInfo *c, int noFree) // register a component type and free the sComponentInfo struct memory (if noFree=0)\n{\n  if (c!=NULL) {\n    // find existing:\n    int t = findComponentType(c->componentName);\n    if (t == -1) {\n      if (nCompTs >= nCompTsAlloc) { // realloc\n        sComponentInfo *_compTs = (sComponentInfo *)crealloc(compTs, (nCompTs+COMPONENTMANAGER_DEFAULT_NCOMPS)*sizeof(sComponentInfo), nCompTsAlloc*sizeof(sComponentInfo));\n        if (_compTs == NULL) OUT_OF_MEMORY;\n        compTs = _compTs;\n        nCompTsAlloc = (nCompTs+COMPONENTMANAGER_DEFAULT_NCOMPS);\n      }\n      t = nCompTs++;\n      memcpy(compTs+t, c, sizeof(sComponentInfo));\n      compTs[t].next = NULL;\n      SMILE_DBG(4,\"registered component type '%s' with id %i\", compTs[t].componentName, t);\n    } else {\n      memcpy(compTs+t, c, sizeof(sComponentInfo));\n      compTs[t].next = NULL;\n      SMILE_DBG(4,\"re-registered component type '%s' with id %i\", compTs[t].componentName, t);\n    }\n    if (!noFree) delete c; // <<-- NOTE: TODO! we are not allowed to call this delete when the component info struct has been allocated in a plugin!\n    return t;\n  }\n  return -1;\n}\n\nint cComponentManager::findComponentType(const char *_type)\n{\n  int i;\n  if (compTs == NULL) return -1;\n  for (i=0; i<nCompTs; i++) {\n    if (!strcmp(_type, compTs[i].componentName)) {\n      SMILE_DBG(5,\"findComponentType: found componentType '%s' at index %i\", _type, i);\n      return i;\n    }\n  }\n  return -1;\n}\n\nconst char * cComponentManager::getComponentType(int i, int filter, int *isAbstract, int *isNoDmem) // get name of component Type \"i\". abstract=1 = include abstract types (if abstract = 0 , then NULL will be returned if the type is abstract), or you may use the isAbstract flag, which is set by this function\n{\n  if ( (i>=0)&&(i<nCompTs) ) {\n    if (isAbstract != NULL) *isAbstract = compTs[i].abstract;\n    if (isNoDmem != NULL) *isNoDmem = compTs[i].noDmem;\n    if (filter == 0) { // filter = 0: return all components\n      return compTs[i].componentName;\n    } else {\n      if (filter == 1) {  // filter=1 : return non-abstract components\n        if (compTs[i].abstract) return NULL;\n        else return compTs[i].componentName;\n      } else if (filter==2) { // filter = 2: return only dmem interface componenets (non-abstract and non-noDmem)\n        if ((compTs[i].abstract)||(compTs[i].noDmem)) return NULL;\n        else return compTs[i].componentName;\n      }\n    }\n  } else {\n    return NULL;\n  }\n  return NULL;\n}\n\nconst char * cComponentManager::getComponentDescr(int i) // get name of component Type \"i\". abstract=1 = include abstract types (if abstract = 0 , then NULL will be returned if the type is abstract), or you may use the isAbstract flag, which is set by this function\n{\n  if ( (i>=0)&&(i<nCompTs) ) {\n    return compTs[i].description;\n  } else { return NULL; }\n}\n\n#ifdef SMILE_SUPPORT_PLUGINS\n\nint cComponentManager::checkPluginFilename(const char * str)\n{\n  const char * dot = strrchr(str,'.');\n#ifdef __WINDOWS\n  const char * ending = \"dll\";\n  int n = 3;\n#else\n  const char * ending = \"so\";\n  int n = 2;\n#endif\n  if (dot != NULL) {\n    dot++;\n    if (!strncasecmp(dot,ending,n)) return 1;\n  }\n  //TODO: find .so/.dll files even if a version number e.g. .so.0.0.1 is appended!\n\n  return 0;\n}\n\n\n#ifndef __WINDOWS\n\n//#include <windows.h>\n//#include <tchar.h>\n//#include <string.h>\n//#include <strsafe.h>\n\n//#else\n\n// unix/gnu\n#include <sys/types.h>\n#include <dirent.h>\n#include <dlfcn.h>\n\n#endif\n\n\nint cComponentManager::loadPlugin(const char * path, const char * fname)\n{\n#ifdef __STATIC_LINK\n  SMILE_ERR(1,\"This binary is statically linked, dynmaic loading of plugins is not supported!\");\n  return 0;\n#else\n  //sComponentInfo * registerComponent(cConfigManager *_confman, cComponentManager *_compman)\n  //sComponentInfo * (*regFn)(cConfigManager *_confman, cComponentManager *_compman);\n  registerFunction regFn;\n\n  char * fullname;\n  if (path != NULL) {\n#ifdef __WINDOWS\n    fullname = myvprint(\"%s\\\\%s\",path,fname);\n#else\n    fullname = myvprint(\"%s/%s\",path,fname);\n#endif\n  } else {\n    fullname = myvprint(\"%s\",fname);\n  }\n\n#ifdef __WINDOWS\n  HINSTANCE lib_handle;\n  lib_handle = LoadLibrary(TEXT(fullname));\n\n  // If the handle is valid, try to get the function address.\n  if (lib_handle != NULL) {\n    regFn = (registerFunction) GetProcAddress(lib_handle, \"registerPluginComponent\");\n    // If the function address is valid, call the function.\n    if (regFn == NULL) {\n      SMILE_ERR(1, \"error registering plugin '%s' (symbol 'registerPluginComponent' not found)\",fullname);\n      FreeLibrary(lib_handle);\n      return 0;\n    }\n  } else {\n    SMILE_ERR(1,\"cannot open library '%s' : LoadLibrary() failed!\",fullname);\n    return 0;\n  }\n\n#else\n  const char *error;\n  void *lib_handle;\n\n  lib_handle = dlopen(fullname, RTLD_LAZY);\n  if (!lib_handle) {\n    SMILE_ERR(1, \"cannot open plugin '%s' : '%s'\", fullname, dlerror());\n    return 0;\n  }\n\n  regFn = (registerFunction)dlsym(lib_handle, \"registerPluginComponent\");\n  if ( ((error = dlerror()) != NULL) || (regFn == NULL)) {\n    SMILE_ERR(1, \"error registering plugin '%s' (symbol 'registerPluginComponent' not found): '%s'\",fullname, error);\n    dlclose(lib_handle);\n    return 0;\n  }\n#endif\n\n  SMILE_MSG(4, \"found registerPluginComponent() in '%s'\",fullname);\n\n  free(fullname);\n  if (nPluginHandles >= nPluginHandlesAlloc) {\n#ifdef __WINDOWS\n    handlelist = (HINSTANCE*)crealloc(handlelist, (nPluginHandlesAlloc+COMPONENTMANAGER_DEFAULT_NCOMPS)*sizeof(HINSTANCE), (nPluginHandlesAlloc)*sizeof(HINSTANCE) );\n#else\n    handlelist = (void**)crealloc(handlelist, (nPluginHandlesAlloc+COMPONENTMANAGER_DEFAULT_NCOMPS)*sizeof(void*), (nPluginHandlesAlloc)*sizeof(void*) );\n#endif\n    regFnlist =  (registerFunction *)crealloc((void *)regFnlist, (nPluginHandlesAlloc+COMPONENTMANAGER_DEFAULT_NCOMPS)*sizeof(registerFunction), (nPluginHandlesAlloc)*sizeof(registerFunction) );\n    if (handlelist == NULL) OUT_OF_MEMORY;\n    if (regFnlist == NULL) OUT_OF_MEMORY;\n    nPluginHandlesAlloc += COMPONENTMANAGER_DEFAULT_NCOMPS;\n  }\n  handlelist[nPluginHandles] = lib_handle;\n  regFnlist[nPluginHandles++] = regFn;\n\n  return 1;\n#endif // __STATIC_LINK\n}\n\n\nint cComponentManager::registerPlugins()\n{\n  int nPlugins = 0;\n  nPluginHandles = 0;\n  nPluginHandlesAlloc = 0;\n\n  // scan plugins in plugin-path:\n#ifdef __WINDOWS\n  // TODO: config file option \"pluginpath\" and \"pluginlist\"\n  const char * pluginpath = \".\\\\plugins\";\n\n  // WIN: use FindFirstFile, FindNextFile, FindClose\n  WIN32_FIND_DATA ffd;\n  HANDLE hFind = INVALID_HANDLE_VALUE;\n  char szDir[MAX_PATH];\n  DWORD dwError=0;\n\n  if (strlen(pluginpath) > (MAX_PATH - 2)) {\n    SMILE_ERR(1,\"Plugin-directory path '%s' is too long for windows systems....\",pluginpath);\n    return 0;\n  }\n\n  // Prepare string for use with FindFile functions.  First, copy the\n  // string to a buffer, then append '\\*' to the directory name.\n\n#ifdef __MINGW32\n  strncpy(szDir, pluginpath, MAX_PATH);\n#else\n  strcpy_s(szDir, MAX_PATH, pluginpath);\n#endif\n  strncat(szDir, \"\\\\*\", MAX_PATH);\n\n  hFind = FindFirstFile(szDir, &ffd);\n  if (INVALID_HANDLE_VALUE == hFind) {\n    SMILE_WRN(3,\"Cannot find files in plugin directory '%s'! You can ignore this, if you are not using openSMILE plugins.\",pluginpath);\n    return 0;\n  }\n\n  // List all the files in the directory with some info about them.\n  do {\n    if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {\n      if (checkPluginFilename(ffd.cFileName)) {\n        SMILE_MSG(2,\"found plugin : '%s'\",ffd.cFileName);\n        // load the plugin:\n        //#ifdef __WINDOWS\n        if (loadPlugin(pluginpath, ffd.cFileName)) nPlugins++;\n        //#else\n        //if (loadPlugin(NULL, ffd.cFileName)) nPlugins++;\n        //#endif\n      }\n    }\n  }\n  while (FindNextFile(hFind, &ffd) != 0);\n\n  dwError = GetLastError();\n  if (dwError != ERROR_NO_MORE_FILES) {\n    SMILE_ERR(1,\"error reading contents of plugin-directory '%s' (nPlugins=%i plugins loaded)! \",pluginpath,nPlugins);\n    FindClose(hFind);\n    return nPlugins;\n  }\n  FindClose(hFind);\n\n#else  // UNIX:\n  // TODO: config file option \"pluginpath\" and \"pluginlist\"\n  const char * pluginpath = \"./plugins\";\n\n  DIR *dp;\n  struct dirent *dirp;\n  if((dp  = opendir(pluginpath)) == NULL) {\n    SMILE_WRN(3,\"cannot open plugin directory '%s' for reading! You can ignore this if you are not using openSMILE plugins.\",pluginpath);\n    return 0;\n  }\n\n  while ((dirp = readdir(dp)) != NULL) {\n    if (checkPluginFilename(dirp->d_name)) { // TODO: skip directories!\n      SMILE_MSG(2,\"found plugin : '%s'\",dirp->d_name);\n      // load the plugin:\n      if (loadPlugin(pluginpath, dirp->d_name)) nPlugins++;\n    }\n  }\n  closedir(dp);\n#endif\n\n  if (nPlugins == 0) return 0;\n\n  int i;\n  int nAgain=0, nReg=0;\n  int regIter = MAX_REG_ITER;\n\n  int *regDone = (int *) calloc(1,sizeof(int)*nPlugins);\n\n  if (printPlugins) {\n    SMILE_PRINT (\" == List of detected plugins: ==\");\n  }\n\n  do {\n\n    for (i=0; i<nPlugins; i++) {\n      if (!(regDone[i])) {\n        sComponentInfo *c = (regFnlist[i])(confman,this);\n\n        //        registerFunction *tmp = (registerFunction *) c; //--\n\n        do {\n          //          c = (*(tmp++))(confman,this); //--\n\n          if ((c!=NULL)&&(printPlugins)) {\n            SMILE_PRINT(\" plugin '%s' : '%s'\",c->componentName,c->description);\n          }\n\n          sComponentInfo *nextc;\n          if (c!=NULL) nextc = c->next;\n\n          int t = registerComponent( c, 1 );\n\n          if ( (t>=0) && (t < nCompTsAlloc)) {\n            if (compTs[t].registerAgain) { nAgain++; }\n            else { nReg++; regDone[i] = 1; }\n          }\n          c = nextc;\n        } while (c!=NULL);\n        //} while (*tmp!=NULL);\n      }\n    }\n\n#ifdef DEBUG\n    //printf(\"reg round %i - nAgain %i\\n\",regIter,nAgain);\n    if (nAgain > 0)\n      SMILE_DBG(3,\"%i of %i plugin-components requested re-register in round %i\",nAgain,nAgain+nReg,MAX_REG_ITER-regIter+1);\n#endif\n\n  } while ((nAgain > 0 )&&(regIter-- > 0));\n  if (printPlugins) {\n    SMILE_PRINT (\" ===============================\");\n  }\n\n  free(regDone);\n\n  return nReg;\n}\n#endif\n\n// register component types by scanning given struct\nint cComponentManager::registerComponentTypes(const registerFunction _clist[]) \n{\n  int i=0;\n  int nAgain, nReg=0;\n  int regIter = MAX_REG_ITER;\n\n  int nc=0;\n  while (_clist[i] != NULL) { nc++; i++; }\n  i=0;\n  int *regDone = (int *) calloc(1,sizeof(int)*nc);\n\n  if (_clist != NULL) {\n    do {\n      nAgain = 0; i=0;\n      //TODO: remember already registered componentes right here.... do not call registerComponent twice!\n      while (_clist[i] != NULL) {\n        if (!(regDone[i])) {\n          int t = registerComponent( (_clist[i])(confman,this) );\n          if ( (t>=0) && (t < nCompTsAlloc)) {\n            if (compTs[t].registerAgain) { nAgain++; }\n            else { nReg++; regDone[i] = 1; }\n          }\n        }\n        i++;\n      }\n#ifdef DEBUG\n      //printf(\"reg round %i - nAgain %i\\n\",regIter,nAgain);\n      if (nAgain > 0)\n        SMILE_DBG(3,\"%i of %i components requested re-register in round %i\",nAgain,nAgain+nReg,MAX_REG_ITER-regIter+1);\n#endif\n    } while ((nAgain > 0 )&&(regIter-- > 0));\n    if ((regIter == 0)&&(nAgain > 0)) {\n      free(regDone);\n      COMP_ERR(\"%i of %i components could not register successfully during %i registration iterations\",nAgain,nAgain+nReg,MAX_REG_ITER);\n    } else\n      SMILE_MSG(2,\"successfully registered %i component types.\",nReg);\n  }\n  free(regDone);\n\n#ifdef SMILE_SUPPORT_PLUGINS\n  // now register plug-in components...\n  nReg += registerPlugins();\n#endif\n\n  return nReg;\n}\n\nint cComponentManager::printComponentList(int filter, int details)\n{\n  int nTp = getNtypes();\n  int i,j=0;\n  //  if (details) {\n  SMILE_PRINT(\"==> The following %i components are currently registered in openSMILE:\\n\",nTp);\n  //  }\n  for (i=0; i<nTp; i++) {\n    const char * tp = getComponentType(i,filter);\n    if (tp!=NULL) {\n      if (details) {\n        SMILE_PRINT(\" +++ '%s' +++\",tp);\n        SMILE_PRINT(\"   %s\\n\",getComponentDescr(i));\n        // TODO: print if component is built in OR dll registered...\n      } else {\n        SMILE_PRINT(\"  '%s'\",tp);\n      }\n    }\n  }\n  return nTp;\n}\n\nextern void resetFunctionalsRaCounter();\ncComponentManager::cComponentManager(cConfigManager *_confman, const registerFunction _clist[]) :\nnComponents(0),\nlastComponent(0),\nnComponentsAlloc(0),\nready(0),\nconfman(_confman),\nnCompTs(0),\nhandlelist(NULL),\nregFnlist(NULL),\nnCompTsAlloc(0),\nnWaiting(0),\nnActive(0),\nprintPlugins(1),\n//  threadNRun(NULL),\nglobalRunState(0),\ncompTs(NULL),\nabortRequest(0),\ncomponentThreadId(NULL),\nEOI(0),\nEOIcondition(0),\ntickLoopPaused(0),\ntickLoopPauseTimeout(10),\npauseStartNr(-1),\nisConfigured(0), isFinalised(0), printLevelStats(0),\nmessageCounter(0), profiling(0),\noldSingleIterationTickLoop(0)\n{\n  resetFunctionalsRaCounter();\n  if (confman == NULL) COMP_ERR(\"cannot create component manager with _confman == NULL!\");\n  cComponentManager::confman = _confman;\n\n  smileMutexCreate(messageMtx);\n  smileMutexCreate(abortMtx);\n  smileMutexCreate(pauseMtx);\n  smileCondCreate(pauseCond);\n\n  // register components (component types)\n  registerComponentTypes(_clist);\n\n  // register our config type:\n  cComponentManager::registerType(confman);\n\n  component = (cSmileComponent **) calloc(1,sizeof(cSmileComponent *) * COMPONENTMANAGER_DEFAULT_NCOMPS);\n  componentInstTs = (char **) calloc(1,sizeof(char *) * COMPONENTMANAGER_DEFAULT_NCOMPS);\n  componentThreadId = (int*) calloc(1,sizeof(int *) * COMPONENTMANAGER_DEFAULT_NCOMPS);\n  if (component == NULL) OUT_OF_MEMORY;\n  if (componentInstTs == NULL) OUT_OF_MEMORY;\n  if (componentThreadId == NULL) OUT_OF_MEMORY;\n  nComponentsAlloc = COMPONENTMANAGER_DEFAULT_NCOMPS;\n\n  // get system start time\n  gettimeofday(&startTime,NULL);\n}\n\nint cComponentManager::compIsDm(const char *_compn)\n{\n  return (!strcmp(_compn,COMPONENT_NAME_CDATAMEMORY)); \n}\n\nint cComponentManager::ciRegisterComps(int _dm)\n{\n#ifdef DEBUG\n  if (_dm == 0) {\n    SMILE_DBG(2,\"==> createInstances: REGISTER PHASE (components) <==\");\n  } else {\n    SMILE_DBG(2,\"==> createInstances: REGISTER PHASE (dataMemories) <==\");\n  }\n  SMILE_DBG(2,\"    %i instances in total (max. %i iterations)\",  nComponents, MAX_REGI_ITER );\n#endif\n\n  int it,i;\n  int nDone = 0; \n  int nDef = 0;\n  int nIgn = 0;\n\n  for (it=0; it<MAX_REGI_ITER; it++) {\n    nDone = 0; \n    nDef = 0;\n    nIgn = 0;\n\n    // register all components \n    for (i=0; i<lastComponent; i++) {\n      if (component[i]!=NULL) {\n        if (compIsDm(component[i]->getTypeName()) == _dm) {\n\n          if (component[i]->registerInstance()) { // TODO: save runMe config in componentManager..\n            nDone++;\n            SMILE_DBG(3,\"registered component instance '%s' (type '%s'), index %i\",component[i]->getInstName(),component[i]->getTypeName(),i);\n          } else {\n            nDef++;\n            SMILE_DBG(3,\"component instance '%s' (type '%s'), index %i, could not be registered\",component[i]->getInstName(),component[i]->getTypeName(),i);\n          }\n\n        } else {\n          nIgn++;\n        }\n      }\n    }\n\n    if (nDef == 0) {\n      if (_dm == 0) \n      { SMILE_MSG(3,\"successfully registered %i of %i component instances (non dataMemory type)\", nDone, nComponents-nIgn ); }\n      else\n      { SMILE_MSG(3,\"successfully registered %i of %i dataMemory instances\", nDone, nComponents-nIgn ); }\n      break; // else: continue configuration process for MAX_REGI_ITER\n    } else {\n      SMILE_DBG(2,\"need to re-register %i components after iteration %i\",nDef,it);\n    }\n  }\n\n  return (nDef);\n}\n\nint cComponentManager::ciConfigureComps(int _dm)\n{\n#ifdef DEBUG\n  if (_dm == 0) {\n    SMILE_DBG(2,\"==> createInstances: CONFIGURE PHASE (components) <==\");\n  } else {\n    SMILE_DBG(2,\"==> createInstances: CONFIGURE PHASE (dataMemories) <==\");\n  }\n  SMILE_DBG(2,\"    %i instances in total (max. %i iterations)\",  nComponents, MAX_CONF_ITER );\n#endif\n\n  int it,i;\n  int nDone = 0; \n  int nDef = 0;\n  int nIgn = 0;\n\n  for (it=0; it<MAX_CONF_ITER; it++) {\n    nDone = 0; \n    nDef = 0;\n    nIgn = 0;\n\n    // register all components \n    for (i=0; i<lastComponent; i++) {\n      if (component[i]!=NULL) {\n        if (compIsDm(component[i]->getTypeName()) == _dm) {\n\n          if (component[i]->configureInstance()) {\n            nDone++;\n            SMILE_DBG(3,\"configured component instance '%s' (type '%s'), index %i\",component[i]->getInstName(),component[i]->getTypeName(),i);\n          } else {\n            nDef++;\n            SMILE_DBG(3,\"component instance '%s' (type '%s'), index %i, could not be configured (yet)\",component[i]->getInstName(),component[i]->getTypeName(),i);\n          }\n\n        } else {\n          nIgn++;\n        }\n      }\n    }\n\n    if (nDef == 0) {\n      if (_dm == 0) {\n        SMILE_MSG(3,\"successfully configured %i of %i component instances (non dataMemory type)\", nDone, nComponents-nIgn );\n      } else {\n        SMILE_MSG(3,\"successfully configured %i of %i dataMemory instances\", nDone, nComponents-nIgn );\n      }\n      break; // else: continue configuration process for MAX_CONF_ITER\n    } else {\n      SMILE_DBG(2,\"need to re-configure %i components after iteration %i\",nDef,it);\n    }\n  }\n\n  return (nDef);\n}\n\nint cComponentManager::ciFinaliseComps(int _dm, int *_n)\n{\n#ifdef DEBUG\n  if (_dm == 0) {\n    SMILE_DBG(2,\"==> createInstances: FINALISE PHASE (components) <==\");\n  } else {\n    SMILE_DBG(2,\"==> createInstances: FINALISE PHASE (dataMemories) <==\");\n  }\n  SMILE_DBG(2,\"    %i instances in total (max. %i iterations)\",  nComponents, MAX_FIN_ITER );\n#endif\n\n  int it,i;\n  int nDone = 0; \n  int nDef = 0;\n  int nIgn = 0;\n\n  //for (it=0; it<MAX_FIN_ITER; it++) {\n  for (it=0; it<(nComponents-1); it++) { // was: it < MAX_FIN_ITER , however we need to use nComponents - 1  !!\n    nDone = 0; \n    nDef = 0;\n    nIgn = 0;\n\n    // finalise components \n    for (i=0; i<lastComponent; i++) {\n      if (component[i]!=NULL) {\n        if (compIsDm(component[i]->getTypeName()) == _dm) {\n\n          if (component[i]->finaliseInstance()) {\n            nDone++;\n            SMILE_MSG(3,\"finalised component instance '%s' (type '%s'), index %i\",component[i]->getInstName(),component[i]->getTypeName(),i);\n          } else {\n            nDef++;\n            SMILE_DBG(3,\"component instance '%s' (type '%s'), index %i, could not be finalised\",component[i]->getInstName(),component[i]->getTypeName(),i);\n          }\n\n          if ( (_dm)&&(printLevelStats) ) {\n            ((cDataMemory *)component[i])->printDmLevelStats(printLevelStats);\n          }\n        } else {\n          nIgn++;\n        }\n      }\n    }\n\n    if (nDef == 0) {\n      if (_dm == 0) {\n        SMILE_MSG(3,\"successfully finalised %i of %i component instances (non dataMemory type)\", nDone, nComponents-nIgn );\n      } else {\n        SMILE_MSG(3,\"successfully finalised %i of %i dataMemory instances\", nDone, nComponents-nIgn );\n      }\n      break; // else: continue configuration process for MAX_FIN_ITER\n    } else {\n      SMILE_DBG(2,\"need to re-finalise %i components after iteration %i\",nDef,it);\n    }\n  }\n\n  if (_n != NULL) *_n = nDone;\n  return (nDef);\n}\n\n// configure and finalise in turns..\nint cComponentManager::ciConfFinComps(int _dm, int *_n)\n{\n#ifdef DEBUG\n  if (_dm == 0) {\n    SMILE_DBG(2,\"==> createInstances: CONFIGURE PHASE (components) <==\");\n  } else {\n    SMILE_DBG(2,\"==> createInstances: CONFIGURE PHASE (dataMemories) <==\");\n  }\n  SMILE_DBG(2,\"    %i instances in total (max. %i iterations)\",  nComponents, MAX_CONF_ITER );\n#endif\n\n  int it,i;\n  int nDone = 0; \n  int nDef = 0;\n  int nIgn = 0;\n\n  for (it=0; it<(nComponents-1); it++) { // was: it < MAX_CONF_ITER , however we need to use nComponents - 1  !!\n    nDone = 0; \n    nDef = 0;\n    nIgn = 0;\n\n    // register all components \n    for (i=0; i<lastComponent; i++) {\n      if (component[i]!=NULL) {\n        if (compIsDm(component[i]->getTypeName()) == _dm) {\n\n          if (component[i]->configureInstance()) {\n            //nDone++;\n            SMILE_DBG(3,\"configured component instance '%s' (type '%s'), index %i\",component[i]->getInstName(),component[i]->getTypeName(),i);\n            if (component[i]->finaliseInstance()) {\n              nDone++;\n              SMILE_DBG(3,\"configured component instance '%s' (type '%s'), index %i\",component[i]->getInstName(),component[i]->getTypeName(),i);\n            } else {\n              nDef++;\n              SMILE_DBG(3,\"component instance '%s' (type '%s'), index %i, could not be configured (yet)\",component[i]->getInstName(),component[i]->getTypeName(),i);\n            }\n\n          } else {\n            nDef++;\n            SMILE_DBG(3,\"component instance '%s' (type '%s'), index %i, could not be configured (yet)\",component[i]->getInstName(),component[i]->getTypeName(),i);\n          }\n\n        } else {\n          nIgn++;\n        }\n      }\n    }\n\n    if (nDef == 0) {\n      if (_dm == 0) {\n        SMILE_MSG(3,\"successfully configured %i of %i component instances (non dataMemory type)\", nDone, nComponents-nIgn );\n      } else {\n        SMILE_MSG(3,\"successfully configured %i of %i dataMemory instances\", nDone, nComponents-nIgn );\n      }\n      break; // else: continue configuration process for MAX_CONF_ITER\n    } else {\n      SMILE_DBG(2,\"need to re-configure %i components after iteration %i\",nDef,it);\n    }\n  }\n\n  if (_n != NULL) *_n = nDone;\n  return (nDef);\n}\n\nvoid cComponentManager::createInstances(int readConfig)\n{\n  /*\n  create component instances (datamemory, readers, writers, and the rest)\n  configure all instances (once all instances are ready) [writers register dataMemory levels, etc.,]\n  finalise all instances (if all instances are configured, datamemory finalises here! (datamemory does sanity check on r/w level usage during finalise)\n  */\n  // load smile and componentManger config\n  if (readConfig) confman->readConfig();\n\n  char *tmp = myvprint(\"%s.printLevelStats\",CM_CONF_INST);\n  printLevelStats = confman->getInt(tmp);\n  free(tmp);\n  tmp = myvprint(\"%s.profiling\",CM_CONF_INST);\n  profiling = confman->getInt(tmp);\n  free(tmp);\n  //#ifdef DEBUG\n  tmp = myvprint(\"%s.execDebug\",CM_CONF_INST);\n  execDebug = confman->getInt(tmp);\n  free(tmp);\n  tmp = myvprint(\"%s.oldSingleIterationTickLoop\", CM_CONF_INST);\n  oldSingleIterationTickLoop = confman->getInt(tmp);\n  free(tmp);\n  //#endif\n\n\n  // create component instances (datamemory, readers, writers, and the rest)\n  //     const char **getArrayKeys(const char *_name, int *N=NULL) const;\n  int N_=0;\n  tmp = myvprint(\"%s.instance\",CM_CONF_INST);\n  char **insts = confman->getArrayKeys(tmp,&N_);\n  if (tmp!=NULL) free(tmp);\n  if ((insts!=NULL)&&(N_>0)) {\n    SMILE_DBG(2,\"found %i component instances in config to create.\",N_);\n    int i;\n\n    // prepare threads:\n    nThreads = confman->getInt_f(myvprint(\"%s.nThreads\",CM_CONF_INST));\n    threadPriority = confman->getInt_f(myvprint(\"%s.threadPriority\",CM_CONF_INST));\n    if (threadPriority < -15) threadPriority = -15;\n    if (threadPriority > 20) threadPriority = 20;\n    if (threadPriority > 11) SMILE_WRN(2,\"componentManager: Running SMILE threads with real-time default priority (prio = %i > 11)! Be careful with this, you mouse may hang or disk caches not get flushed!\",threadPriority);\n\n    // create compnent objects and register them\n    for (i=0; i<N_; i++) {\n      const char *k = insts[i];\n      if (k!=NULL) {\n        const char *tp = confman->getStr_f(myvprint(\"%s.instance[%s].type\",CM_CONF_INST,k));\n        const char *ci = confman->getStr_f(myvprint(\"%s.instance[%s].configInstance\",CM_CONF_INST,k));\n        // check config:\n        if (tp == NULL) CONF_INVALID_ERR(\"%s.instance[%s].type is missing!\",CM_CONF_INST,k);\n        if (ci == NULL) ci = k;\n        SMILE_DBG(2,\" adding %i. component instance: name '%s', type '%s', configInstance '%s'\",i,k,tp,ci);\n        int tmpId = confman->getInt_f(myvprint(\"%s.instance[%s].threadId\",CM_CONF_INST,k));\n        if (tmpId < -2) tmpId = -1;  // NOTE: threadId = -2 => do not tick this component at all!!\n        if (tmpId >= nThreads) {\n          //CONF_INVALID_ERR(\"%s.instance[%s].threadId must be < %s.nThreads (first Id = 0)!\",CM_CONF_INST,k,CM_CONF_INST);\n          SMILE_MSG(1, \"[componentManager] threadId of instance %s must be < nThreads (%i). Setting to threadId 0.\", k, nThreads);\n          tmpId = 0;\n        }\n        /* TODO: add the reading of a *per component* threadPriority here, which will be passed to addComponent call */\n        /*\n        int threadPrio = threadPriority;\n        char * ctmp = myvprint(\"%s.instance[%s].threadPriority\",CM_CONF_INST,k);\n        if (confman->isSet(ctmp))\n        threadPrio = confman->getInt_f(ctmp);\n        }\n        */\n        int a = addComponent(k,tp,ci,tmpId /*, threadPrio */);\n        if (a>=0) {\n          SMILE_DBG(4,\" added %i. component instance at index %i (lc=%i)\",i,a,lastComponent);\n          // set configInstance name...\n          //          setConfigInstanceName..ok!\n        } else {\n          COMP_ERR(\"error during addComponent (returnVal=%i)!\",a);\n        }\n      }\n    }\n\n    // configure and finalise components in turn:\n    // 1a. register (components, NON dataMemory)\n    // 1b. register (dataMemories)\n    // 2a. configure (components, NON dataMemory)\n    // 2b. configure (dataMemories)\n    // 3a. finalise (components, NON dataMemory)\n    // 3b. finalise (dataMemories)\n\n    // we need to do this so the readers of e.g. dataProcessors can be configured after the writers for the corresponding levels have been finalised\n\n    if (ciRegisterComps(0)) COMP_ERR(\"createInstances: failed registering component instances\");\n    if (ciRegisterComps(1)) COMP_ERR(\"createInstances: failed registering dataMemory instances\");\n\n    int nFinC = 0, nFinD = 0;\n    if (ciConfFinComps(0,&nFinC)) COMP_ERR(\"createInstances: failed configuring&finalising component instances\");\n    //if (ciConfigureComps(0)) COMP_ERR(\"createInstances: failed configuring component instances\");\n    //if (ciFinaliseComps(0,&nFinC)) COMP_ERR(\"createInstances: failed finalising component instances\");\n    isConfigured=1;\n\n    if (ciConfigureComps(1)) COMP_ERR(\"createInstances: failed configuring dataMemory instances\");\n    if (ciFinaliseComps(1,&nFinD)) COMP_ERR(\"createInstances: failed finalising dataMemory instances\");\n    isFinalised=1;\n\n    SMILE_MSG(2,\"successfully finished createInstances\\n                                 (%i component instances were finalised, %i data memories were finalised)\", nFinC, nFinD);\n    ready = 1;\n  }\n}\n\nint cComponentManager::getNextComponentId()\n{\n  if (lastComponent >= nComponentsAlloc) {  // reallocate a larger component array\n    cSmileComponent **tmp;\n    tmp = (cSmileComponent **) crealloc(component,\n      sizeof(cSmileComponent *) * (lastComponent + COMPONENTMANAGER_DEFAULT_NCOMPS),\n      sizeof(cSmileComponent *) * nComponentsAlloc);\n    char **tmpn;\n    tmpn = (char **) crealloc(componentInstTs,\n      sizeof(char *) * (lastComponent + COMPONENTMANAGER_DEFAULT_NCOMPS),\n      sizeof(char *) * nComponentsAlloc);\n    int *tmpi;\n    tmpi = (int *) crealloc(componentThreadId,\n      sizeof(int) * (lastComponent + COMPONENTMANAGER_DEFAULT_NCOMPS),\n      sizeof(int) * nComponentsAlloc);\n\n    if (tmp == NULL) OUT_OF_MEMORY;\n    if (tmpn == NULL) OUT_OF_MEMORY;\n    if (tmpi == NULL) OUT_OF_MEMORY;\n    nComponentsAlloc = (lastComponent + COMPONENTMANAGER_DEFAULT_NCOMPS);\n    component = tmp;\n    componentInstTs = tmpn;\n    componentThreadId = tmpi;\n  }\n  nComponents++;\n  return lastComponent++;\n}\n\n// ci = config instance name (set to _instname by default in createInstances)\nint cComponentManager::addComponent(const char *_instname, const char *_type, const char *_ci, int _threadId /*, int threadPrio */)\n{\n  SMILE_DBG(3,\"addComponent: instname='%s' type='%s'\",_instname,_type);\n  int t = findComponentType(_type);\n  if (t >= 0) {\n    cSmileComponent *c = createComponent(_instname,t);\n    if (c==NULL) COMP_ERR(\"failed creating component '%s' (type: '%s')\",_instname,_type);\n    if (_ci != NULL) c->setConfigInstanceName(_ci);\n    if (profiling) c->setProfiling(1, 0);\n    return registerComponentInstance(c, _type, _threadId /*, threadPrio */);\n  } else {\n    SMILE_ERR(1,\"cannot add component (instname='%s' type='%s'): unknown component type!!\",_instname,_type);\n  }\n\n  return t;\n}\n\ncSmileComponent * cComponentManager::createComponent(const char *_instname, const char *_type)\n{\n  int t = findComponentType(_type);\n  if (t >= 0) {\n    return createComponent(_instname,t);\n  } else {\n    SMILE_ERR(1,\"cannot create component (instname='%s' type='%s'): unknown component type!!\",_instname,_type);\n    return NULL;\n  }\n}\n\n// n is index of component type in compTs\ncSmileComponent * cComponentManager::createComponent(const char *_instname, int n)\n{\n  if ((n>=0)&&(n<nCompTs)) {\n    cSmileComponent *c = (compTs[n].create)(_instname);\n    if (c==NULL) OUT_OF_MEMORY;\n    c->setComponentEnvironment(this, -1, NULL); // set component manager reference and the component ID, used by componentManager\n    return c;\n  } else {\n    SMILE_ERR(1,\"cannot create component of type (index=%i): index is out of range (0 - %i)!\",n,nCompTs);\n  }\n  return NULL;\n}\n\nint cComponentManager::registerComponentInstance(cSmileComponent * _component, const char *_typename, int _threadId /*, int threadPrio */)\n{\n  if (_component == NULL) {\n    SMILE_ERR(1,\"registerComponentInstance: cannot register NULL component instance!\");\n    return -1;\n  }\n  int id = getNextComponentId();\n  if (id >= 0) {\n    _component->setComponentEnvironment(this, id, NULL);\n    //_component->setId(id);\n    component[id] = _component;\n    if (_typename != NULL)\n      componentInstTs[id] = strdup(_typename);\n    else\n      componentInstTs[id] = NULL;\n    componentThreadId[id] = _threadId;\n    // componentThreadPrio[id] = threadPrio;\n  } else {\n    SMILE_ERR(1,\"registerComponentInstance: could not get next component id, return value == %i!\",id);\n  }\n  return id;\n}\n\nvoid cComponentManager::unregisterComponentInstance(int id, int noDM)  // unregister and destroy component object\n{\n  // TODO:::: the component would have to unregister it's reader/writer etc...\n  if ((id>=0)&&(id < lastComponent)&&(id < nComponentsAlloc)) {\n    if (component[id] != NULL) {\n      if ((noDM)&&(!strcmp(component[id]->getTypeName(),COMPONENT_NAME_CDATAMEMORY))) {\n        return;\n      } else {\n        delete component[id];\n        if (componentInstTs[id] != NULL) {\n          free(componentInstTs[id]);\n          componentInstTs[id] = NULL;\n          componentThreadId[id] = 0;  // TODO: stop thread ?????\n        }\n        component[id] = NULL;\n        nComponents--;\n        if (id == lastComponent) lastComponent--;\n      }\n    }\n  }\n}\n\nvoid cComponentManager::resetInstances()\n{\n  int i;\n  // TODO: abort processing , stop threads...etc.??\n  int mylastComponent = lastComponent;\n  for (i=0; i<mylastComponent; i++) {\n    unregisterComponentInstance(i,1);  // all BUT dataMemories...\n  }\n\n  mylastComponent = lastComponent;\n  for (i=0; i<mylastComponent; i++) {\n    unregisterComponentInstance(i); // now free the dataMemories\n  }\n  nComponents = 0;\n  lastComponent = 0; // ???\n  ready=0;    // flag that indicates if all components are set up and ready...\n  isConfigured=0;\n  isFinalised=0;\n  EOI=0;\n}\n\nint cComponentManager::findComponentInstance(const char *_compname) const\n{\n  int i;\n  if (_compname == NULL) return -1;\n  for (i=0; i<lastComponent; i++) {\n    if ((component[i] != NULL)&&(!strcmp(_compname,component[i]->getInstName()))) { return i; }\n  }\n  return -1;\n}\n\ncSmileComponent * cComponentManager::getComponentInstance(int n)\n{\n  if ((n>=0)&&(n<nComponents)) return component[n];\n  else return NULL;\n}\n\nconst char * cComponentManager::getComponentInstanceType(int n)\n{\n  if ((n>=0)&&(n<nComponents)) return componentInstTs[n];\n  else return NULL;\n}\n\ncSmileComponent * cComponentManager::getComponentInstance(const char *_compname)\n{\n  return getComponentInstance(findComponentInstance(_compname));\n}\n\nconst char * cComponentManager::getComponentInstanceType(const char *_compname)\n{\n  return getComponentInstanceType(findComponentInstance(_compname));\n}\n\n// send inter component messages directly to component (string version, takes recepient component name as first argument, sending to multiple components is possible, if they are separated via a comma ',' in the recepient name argument)\nint cComponentManager::sendComponentMessage(const char *_compname, cComponentMessage *_msg)\n{\n  if (_compname != NULL) {\n    char *inp = strdup(_compname);\n    char *tmp = strchr(inp,','); // is array of recepients ?\n    if (tmp != NULL) {\n      char *t = inp;\n      tmp = strchr(t,','); // is array of recepients ?\n      tmp[0] = 0;\n      int ret;\n      // first part:\n      ret = sendComponentMessage(findComponentInstance(t),_msg);\n      // second part:\n      tmp++;\n      ret += sendComponentMessage(tmp, _msg);\n      free(inp);\n      return ret;\n    } else {\n      free(inp);\n      return sendComponentMessage(findComponentInstance(_compname),_msg);\n    }\n  }\n  return 0;\n}\n\n// send inter component messages directly to component:\nint cComponentManager::sendComponentMessage(int compid, cComponentMessage *_msg)\n{\n  cSmileComponent *c = getComponentInstance(compid);\n  int ret = 0;\n  if (c!=NULL) {\n    if (_msg != NULL) {\n      // assign timestamp\n      _msg->smileTime = getSmileTime();\n      // assign unique message id from message counter:\n      smileMutexLock(messageMtx);\n      _msg->msgid = messageCounter++; // MUTEX!!\n      smileMutexUnlock(messageMtx);\n    }\n    ret = c->receiveComponentMessage(_msg);\n  }\n  return ret;\n}\n\ndouble cComponentManager::getSmileTime()\n{\n  struct timeval curTime;\n  gettimeofday( &curTime, NULL );\n  return ( (double)(curTime.tv_sec - startTime.tv_sec) + (double)(curTime.tv_usec - startTime.tv_usec)/1000000.0 );\n}\n\nlong cComponentManager::tick(int threadId, long long tickNr, long lastNrun)\n{\n  if (!ready) return 0;\n  int i;\n  long nRun = 0; int nRunnable = 0;\n  char *stat=NULL;\n  for (i=0; i<=lastComponent; i++) {\n    if (component[i] != NULL) {\n      if (((threadId == -1)||(threadId == componentThreadId[i]))&&(componentThreadId[i]!=-2)) {\n        nRunnable++;\n        //fprintf(stderr,\"~~~~> 'ticking' component '%s' (idx %i)\\n\",component[i]->getInstName(),i); fflush(stderr);\n        SMILE_DBG(4,\"~~~~> 'ticking' component '%s' (idx %i)\",component[i]->getInstName(),i);\n        if (component[i]->tick(tickNr, EOIcondition, lastNrun)) {\n          nRun++;\n          SMILE_DBG(4,\"%s.tick() executed successfully!\",component[i]->getInstName());\n          //#ifdef DEBUG\n          if (execDebug) { // show summary of components executed during this tick\n            if (stat != NULL) {\n              char *x = stat;\n              stat = myvprint(\"%s %s\",x,component[i]->getInstName());\n              free(x);\n            } else {\n              stat = strdup(component[i]->getInstName());\n            }\n          }\n          //#endif // DEBUG\n        }\n      }\n    }\n  }\n#ifdef DEBUG\n  if (nRun < nRunnable) { SMILE_DBG(4,\"not all components were run during tick %i (threadID: %i)! (%i<%i)\",tickNr,threadId, nRun,nRunnable); }\n  else { SMILE_DBG(4,\"ran all components in thread %i (tick: %i)\",threadId,(int)tickNr); }\n#endif\n  if (execDebug) { // show summary of components executed during this tick\n    SMILE_PRINT(\"SUMMARY tick #%i thread %i, (eoi=%i) ran (%i): %s\\n\", (int)tickNr, (int)threadId, EOI, nRun, stat);\n    if (stat != NULL) free(stat);\n  }\n  //#endif // DEBUG\n\n  return nRun;\n}\n\n\nint cComponentManager::pausedNotifyComponents(int threadId, int isPause)\n{\n  if (!ready) return 0;\n  int ret = 1;\n  int i;\n  for (i=0; i<=lastComponent; i++) {\n    if (component[i] != NULL) {\n      if (((threadId == -1)||(threadId == componentThreadId[i]))&&(componentThreadId[i]!=-2)) {\n        if (isPause) {\n          SMILE_DBG(4,\"~~~~> pausing component '%s' (idx %i)\",component[i]->getInstName(),i);\n          if (!component[i]->pause()) {\n            SMILE_ERR(2,\" component '%s' rejected pause.\", component[i]->getInstName());\n            ret = 0;\n          }\n        } else {\n          SMILE_DBG(4,\"~~~~> resuming component '%s' (idx %i)\",component[i]->getInstName(),i);\n          component[i]->resume();\n        }\n      }\n    }\n  }\n  if (ret == 0) {\n    SMILE_ERR(2,\"Failed to pause tick loop.\");\n  }\n  return ret;\n}\n\n/* pause tick loop:\nhow=1  :  notify components, halt loop in a sleep\nhow=2  :  notify components,  wait for nRun = 0 (force NOT EOI!), then put loop to sleep\ntimeout :  if how=2, then max number of ticks of nRun>0 , after which pause request is discarded and EOI is assumed again when nRun=0  (irrelevant when how=1)\n*/\nvoid cComponentManager::pause(int how, int timeout)\n{\n  // WARNING: pause/resume is currently only implemented for single thread processing!\n  smileMutexLock(pauseMtx);\n  if (tickLoopPaused && how > 0) {\n    smileMutexUnlock(pauseMtx);  \n    return; \n  }\n  int oldTickLoopPaused = tickLoopPaused;\n  tickLoopPaused = how;\n  tickLoopPauseTimeout = timeout;\n  pauseStartNr = -1;\n  if (how == 0 && oldTickLoopPaused) {\n    //smileCondBroadcast(pauseCond);  // for multi-threaded tick loops ?\n    smileCondSignal(pauseCond);\n  }\n  smileMutexUnlock(pauseMtx);\n}\n\nint cComponentManager::pauseThisTickLoop(int threadID, int nRun, long long tickNr)\n{\n  smileMutexLock(pauseMtx);\n  int ret = 0;\n  if (tickLoopPaused) {\n    if (tickLoopPaused == 1) {\n      // notify components about the pause/sleep. this is very useful if components have asynchronous background threads or callbacks the process data independently (e.g. portaudio)\n      ret = pausedNotifyComponents(threadID, 1 /*pause*/);\n      if (!ret) {\n        tickLoopPaused = 0;\n        pauseStartNr = -1;\n        pausedNotifyComponents(threadID, 0 /*resume*/);\n        return nRun;\n      }\n      // tick loop pause will lead to a sleep at this point\n      // thus, the pause my be initiated from the main thread (i.e. from any myTick() functions within components), but needs a *separate* thread to resume from it!!\n      // this thread needs to have a pointer to the component manager to call the unpause function!\n      smileCondWaitWMtx(pauseCond, pauseMtx);\n      // notify components of resume:\n      pausedNotifyComponents(threadID, 0 /*resume*/);\n    } else if (tickLoopPaused == 2) {\n      if (pauseStartNr == -1) { \n        pauseStartNr = tickNr; \n        // notify components about the pause/sleep. this is very useful if components have asynchronous background threads or callbacks the process data independently (e.g. portaudio)\n        ret = pausedNotifyComponents(threadID, 1 /*pause*/);\n        if (!ret) {\n          tickLoopPaused = 0;\n          pauseStartNr = -1;\n          pausedNotifyComponents(threadID, 0 /*resume*/);\n          return nRun;\n        }\n      } else if (tickNr - pauseStartNr > tickLoopPauseTimeout) { // resume due to timeout, loop still running\n        tickLoopPaused = 0;\n        pauseStartNr = -1;\n        // notify components of resume\n        pausedNotifyComponents(threadID, 0 /*resume*/);\n      } else if (nRun <= 0) {\n        // sleep until resumed  (TODO: or sleep fixed amount of time, if mode 3)\n        smileCondWaitWMtx(pauseCond, pauseMtx);\n        // notify components of resume  (TODO: do not resume, if in polling mode (3))\n        pausedNotifyComponents(threadID, 0 /*resume*/);\n        tickLoopPaused = 0;\n        pauseStartNr = -1;\n        nRun = 1; // continue tick loop\n      }\n    }\n  }\n  smileMutexUnlock(pauseMtx);\n\n  // TODO: how=3 : no sleep, but polling of tick loop until resumed. configurable poll intervals.\n  // TODO: in how=2 mode: check if resume is ok, or if next iteration after resume will return nRun=0 again because components are not ready yet\n\n  return nRun;\n}\n\nvoid cComponentManager::setEOIcounterInComponents()\n{\n  for (int i = 0; i <= lastComponent; i++) {\n    if (component[i] != NULL) {\n      component[i]->setEOIcounter(EOI);\n    }\n  }\n}\n\n// single thread tick loop\nlong long cComponentManager::runSingleThreaded(long long maxtick)\n{\n  long nRun=-1;\n  if (!ready) return 0;\n  SMILE_MSG(2,\"starting single thread processing loop\");\n#ifdef __WINDOWS\n  /* set priority of current thread here... */\n  SetThreadPriority(GetCurrentThread(), threadPriority);\n#endif\n  // TODO: external abort mechanism... (Message, etc.)\n  int running = 1;\n  long long tickNr = -1;\n  do {\n    int firstTick = 1;\n    do {\n      tickNr++;\n      SMILE_DBG(4,\"<------- TICK # %lld ---------->\", tickNr);\n      nRun = tick(-1, tickNr,nRun);\n      if (firstTick && nRun == 0) {\n        running = 0;\n        SMILE_MSG(3, \"Empty tick loop iteration # %i. tickNr = %lld. End of processing loop.\", EOI, tickNr)\n      }\n      firstTick = 0;\n      if ((maxtick != -1)&&(tickNr >= maxtick)) nRun = 0;\n      smileMutexLock(abortMtx);\n      if (abortRequest) nRun = 0;\n      smileMutexUnlock(abortMtx);\n      if (nRun > 0) userOnTick(tickNr,EOI);\n      // pause function:  // WARNING: pause/resume is currently only implemented for single thread processing!\n      nRun = pauseThisTickLoop(-1,nRun,tickNr);\n    } while(nRun > 0);\n    // TODO:\n    // new run scheme\n    //   run N tick loops, until first run of new tick loop after EOI has failed.\n    //  signale EOI counter and EOI condition to components. The condition is set on every other tick loop.\n    //\n    nRun=-1;\n    // TODO: if aborted (Ctrl+C etc.) do not run another EOI tick loop!\n    if (running && ((tickNr < maxtick)||(maxtick==-1))) {\n      setEOI();  // set EOIcondition and run another tick loop\n      setEOIcounterInComponents();\n      SMILE_MSG(3, \"Entering 'EOI condition == 1' tick loop. EOI counter = %i. tickNr = %ld\", EOI, tickNr);\n      do {\n        tickNr++;\n        SMILE_DBG(4,\"<------- TICK # %lld ---------->\", tickNr);\n        nRun = tick(-1, tickNr, nRun);\n        if ((maxtick != -1)&&(tickNr >= maxtick)) nRun = 0;\n        // ???\n        smileMutexLock(abortMtx);\n        if (abortRequest) {\n          nRun = 0;\n          running = 0;\n        }\n        smileMutexUnlock(abortMtx);\n        if (nRun > 0) userOnTick(tickNr,EOI);\n      } while(nRun > 0);\n    }\n    if (oldSingleIterationTickLoop) {\n      running = 0;\n    } else {\n      unsetEOI();\n    }\n    // running = 0 if no component ran in first tick loop part..\n    // EOI: EOI counter\n    // EOIcondition : new variable flag, indicating if in EOI tick loop.\n    if (running) {\n      SMILE_MSG(3, \"Starting the next tick loop iteration. EOI counter = %i. tickNr = %ld\", EOI, tickNr);\n    }\n  } while (running);\n  SMILE_MSG(2,\"Processing finished! System ran for %i ticks.\",tickNr);\n  // do profiling:\n  if (profiling) {\n    double psum = 0.0;\n    double *ps = (double*)calloc(1, sizeof(double) * (lastComponent + 1));\n    for (int i=0; i<=lastComponent; i++) {\n      if (component[i] != NULL) {\n        ps[i] = component[i]->getProfile(1);\n        psum += ps[i];\n      }\n    }\n    SMILE_PRINT(\" == Component run-time profiling ==\");\n    SMILE_PRINT(\"    Total time in component tick() in seconds: %f\", psum);\n    // normalise to percentages:\n    if (psum > 0.0) {\n      for (int i=0; i<=lastComponent; i++) {\n        if (component[i] != NULL) {\n          ps[i] /= psum;\n          SMILE_PRINT(\"  %s:   %.1f %s\", component[i]->getInstName(), ps[i] * 100.0, \"%\");\n        }\n      }\n    }\n    free(ps);\n  }\n  return tickNr;\n}\n\n\nSMILE_THREAD_RETVAL threadRunner(void *_data)\n{\n  sThreadData *data = (sThreadData*)_data;\n  if ((data != NULL)&&(data->obj!=NULL)) {\n    data->obj->waitForController(data->threadId,0);\n    data->obj->tickLoopA(data->maxtick, data->threadId, data);\n    // wait for all threads to be in this state....\n    data->obj->waitForController(data->threadId,2);\n    // post EOI processing\n    data->obj->tickLoopA(data->maxtick, data->threadId, data);\n  }\n  SMILE_THREAD_RET;\n}\n\nvoid cComponentManager::waitForAllThreads(int threadID)\n{\n  smileMutexLock(waitEndMtx);\n  SMILE_DBG(4,\"thread controller entered waiting state.. %i threads of %i are now waiting\\n\",threadID,waitEndCnt,nThreads);\n\n  if (waitEndCnt < nThreads) { \n    smileCondWaitWMtx(waitEndCond,waitEndMtx);\n  }\n  EOI = 1; \n  nActive = nThreads; //??\n  //smileCondBroadcast(waitEndCond);\n  endOfLoop=0;\n  waitEndCnt = 0;\n  controllerPresent = 0;\n  smileMutexUnlock(waitEndMtx);\n}\n\nvoid cComponentManager::waitForController(int threadID, int stage)\n{\n  smileMutexLock(waitEndMtx);\n  if (stage==2) {\n    waitEndCnt++; \n    SMILE_DBG(4,\"thread %i entered waiting state.. %i threads of %i are now waiting\\n\",threadID,waitEndCnt,nThreads);\n    if (waitEndCnt == nThreads) {\n      smileCondSignal(waitEndCond);\n    }\n    smileCondWaitWMtx(waitControllerCond,waitEndMtx);\n  } else {\n    if (!controllerPresent) { smileCondWaitWMtx(waitControllerCond,waitEndMtx); }\n  }\n  //EOI = _eoi; \n  //nActive = nThreads; //??\n  //  smileCondBroadcast(waitEndCond);\n  //endOfLoop=0;\n  smileMutexUnlock(waitEndMtx);\n}\n\nSMILE_THREAD_RETVAL threadRunnerControl(void *_data)\n{\n  sThreadData *data = (sThreadData*)_data;\n  if ((data != NULL)&&(data->obj!=NULL)) {\n    data->obj->controlLoopA();\n    // wait for all threads to be in this state....\n    data->obj->waitForAllThreads(-1); // thread ID is only used for display of messages\n    //    fprintf(stderr,\"CR eoi=1\\n\");\n    // post EOI processing\n    data->obj->controlLoopA();\n  }\n  SMILE_THREAD_RET;\n}\n\nvoid cComponentManager::controlLoopA()\n{\n  int run = 1;\n\n  smileMutexLock(syncCondMtx);\n  endOfLoop=0;\n\n  smileMutexLock(waitEndMtx);\n  waitEndCnt=0;\n  controllerPresent=1;\n  smileCondBroadcast(waitControllerCond);\n  smileMutexUnlock(waitEndMtx);\n\n  do {\n    if (!abortRequest) smileCondWaitWMtx(controlCond,syncCondMtx);\n    // if control cond was signald, all thread are waiting...!\n    // set a flag, an thus execute each thread loop excatly ONCE!\n    // then check the status, if still all are waiting, exit, else continue!\n    if (probeFlag) {\n      //      fprintf(stderr,\"probe end  cr=%i nP %i nA %i\\n\",compRunFlag,nProbe,nActive);fflush(stderr);\n      if (compRunFlag == 0) {\n        // final exit!\n        run = 0;\n      } else {\n        // continue\n        nProbe = 0;\n        nWaiting = 0;\n        probeFlag = 0;\n        //cnt = 0;\n      }\n    } else {\n      // probe components..\n      //      fprintf(stderr,\"probe start nW %i\\n\",nWaiting); fflush(stderr);\n      nWaiting = 0;\n      compRunFlag = 0;\n      probeFlag = 1;\n      nProbe = 0;\n    }\n\n    smileMutexLock(abortMtx);\n    if (abortRequest) { run = 0; }\n    else if (run==0) { endOfLoop = 1; }\n    smileMutexUnlock(abortMtx);\n    //    fprintf(stderr,\"cr stat nW %i nP %i ab %i run %i pf %i\\n\",nWaiting,nProbe,abortRequest,run,probeFlag); fflush(stderr);\n\n    smileCondBroadcast(syncCond); \n\n  } while(run);\n  smileMutexUnlock(syncCondMtx);\n\n  compRunFlag = 0; probeFlag = 0; nProbe = 0; nWaiting = 0;\n}\n\n\nlong long cComponentManager::tickLoopA(long long maxtick, int threadId, sThreadData *_data)\n{\n  int nRun; int _abort = 0; int doYield=0;\n  long long tickNr = -1;\n\n  SMILE_MSG(3,\"starting processing loop of thread %i\",threadId);\n\n  do {\n    smileMutexLock(syncCondMtx);\n    // if runFlag == 0 here...\n    runFlag[threadId] = 0;\n    tickNr++; //fprintf(stderr, \"tick %i eol %i eoi %i\\n\",tickNr,endOfLoop,EOI); fflush(stderr);\n    SMILE_DBG(3,\"<------- TICK # %i (thread %i) ---------->\",tickNr,threadId);\n    smileMutexUnlock(syncCondMtx);\n    nRun = tick(threadId,tickNr);\n    SMILE_DBG(3,\"nRun = %i (thread %i)\",nRun,threadId);\n\n    smileMutexLock(abortMtx);\n    if (abortRequest) {\n      _abort = 1;\n    }\n    smileMutexUnlock(abortMtx);\n\n    if (!_abort) {\n\n      smileMutexLock(syncCondMtx);\n      //    fprintf(stderr,\"mutlock...%i\\n\",threadId);\n      if (nRun==0) {\n        if (runFlag[threadId] == 1) {\n          runFlag[threadId] = 0;\n          nRun = 1;\n        } else {\n          if (!probeFlag) {\n            nWaiting++;\n            if (nWaiting < nActive) {\n              //SMILE_MSG(3, \"thread %i sleeping (tick %i) (nAct %i, nWait %i)\", threadId, tickNr, nActive, nWaiting);\n              smileCondWaitWMtx(syncCond,syncCondMtx); // sleep until another thread or the controller thread wakes us\n              //nRun = 1; // runStatus is set by the controller thread, it is 1 by default (=continue)\n            } else {\n              smileCondSignal(controlCond); // wake up controller thread...\n              //SMILE_MSG(3, \"thread %i sleeping and signalled controller (tick %i) (nAct %i, nWait %i)\", threadId, tickNr, nActive, nWaiting);\n              smileCondWaitWMtx(syncCond,syncCondMtx); // and sleep until the controller thread OR ANOTHER THREAD! wakes us\n              //nRun = 1; // runStatus is set by the controller thread, it is 1 by default (=continue)\n            }\n            if (!probeFlag && nWaiting > 0)\n              nWaiting--;\n          } else {\n            nProbe++;\n            //nWaiting++;\n            if (nProbe == nActive) {\n              smileCondSignal(controlCond); // wake up controller thread if we are the last in the probe...\n              //SMILE_MSG(3, \"PROBE: thread %i signalled controller (tick %i), nprobe = %i, nA %i, nW %i\", threadId, tickNr, nProbe, nActive, nWaiting);\n            }\n            //SMILE_MSG(3, \"PROBE: thread %i sleeping (tick %i), nprobe = %i\", threadId, tickNr, nProbe);\n            smileCondWaitWMtx(syncCond,syncCondMtx); // sleep until the controller thread OR ANOTHER THREAD! wakes us\n            //if (nWaiting > 0) nWaiting--;\n            //if (probeFlag) nProbe--;\n          }\n          nRun = 1;\n          doYield = 0;\n        }\n      } else {\n        userOnTick(tickNr,EOI,threadId);\n        for (int i = 0; i < nActive; i++) {\n          runFlag[i] = 1;\n        }\n        //for (int i=0; i<nActive; i++){\n        //  smileCondSignalRaw(syncCond);\n        //}\n        //if (!probeFlag) \n        //else {\n        compRunFlag = 1; \n        //SMILE_MSG(3, \"PROCESSED thread %i run>0 (tick %i), nprobe = %i\", threadId, tickNr, nProbe);\n        if (probeFlag) {\n          nProbe++;\n          // TODO: actually once one component has run, we can exit probe.. however, if we do the nWaiting counter is wrong and we enter a deadlock (all waiting afterwards)\n          if (nProbe == nActive) {\n            //SMILE_MSG(3, \"PROBE: thread %i run>0 and signalled controller (tick %i), nprobe = %i, nA %i, nW %i\", threadId, tickNr, nProbe, nActive, nWaiting);\n            smileCondSignal(controlCond);\n          }\n          //SMILE_MSG(3, \"PROBE: thread %i run>0 sleeping (tick %i), nprobe = %i\", threadId, tickNr, nProbe);\n          smileCondWaitWMtx(syncCond,syncCondMtx); // sleep until the controller thread OR ANOTHER THREAD! wakes us\n        }\n        /*else {\n          smileCondBroadcastRaw(syncCond);\n          if (nWaiting == nActive - 1) {\n            nWaiting++;\n            //SMILE_MSG(3, \"thread %i sleeping while waiting for others (tick %i) (nAct %i, nWait %i)\", threadId, tickNr, nActive, nWaiting);\n            smileCondWaitWMtx(syncCond,syncCondMtx); // sleep until the controller thread OR ANOTHER THREAD! wakes us\n          }\n        }*/\n        //nProbe++;\n        //if (nProbe == nActive) smileCondSignal(controlCond); // wake up controller thread...\n        //smileCondWaitWMtx(syncCond,syncCondMtx); // and sleep until the controller thread wakes us\n        //}\n        doYield=0;\n\n        // TODO: if all others waiting... make sure we sleep at the end\n\n      }\n      if ((_data->maxtick != -1)&&(tickNr >= _data->maxtick)) nRun = 0;\n      smileMutexUnlock(syncCondMtx);\n    }\n\n    smileMutexLock(abortMtx);\n    if ((endOfLoop)||(_abort)) { nRun = 0; }\n    smileMutexUnlock(abortMtx);\n\n    smileMutexLock(syncCondMtx);\n    if (nRun == 0) nActive--;\n    smileMutexUnlock(syncCondMtx);\n    if (doYield) { smileYield(); doYield = 0; }\n\n  } while (nRun>0) ;\n\n  SMILE_MSG(3,\"leaving processing loop of thread %i (ticks: %i)\",threadId,tickNr);\n  // first part... now enter EOI state, however wait for other threads...???\n\n  return tickNr;\n\n}\n\n\n#if 0\nlong long cComponentManager::tickLoopA(long long maxtick, int threadId, sThreadData *_data)\n{\n  int nRun; int _abort = 0; int doYield=0;\n  long long tickNr = -1;\n  int weDidRun = 0;\n  SMILE_MSG(3,\"starting processing loop of thread %i\",threadId);\n\n  do {\n    smileMutexLock(syncCondMtx);\n    // if runFlag == 0 here...\n    runFlag[threadId] = 0;\n    tickNr++; //fprintf(stderr, \"tick %i eol %i eoi %i\\n\",tickNr,endOfLoop,EOI); fflush(stderr);\n    SMILE_DBG(3,\"<------- TICK # %i (thread %i) ---------->\",tickNr,threadId);\n    smileMutexUnlock(syncCondMtx);\n    nRun = tick(threadId,tickNr);\n    SMILE_DBG(3,\"nRun = %i (thread %i)\",nRun,threadId);\n    smileMutexLock(abortMtx);\n    if (abortRequest) {\n      _abort = 1;\n    }\n    smileMutexUnlock(abortMtx);\n\n    if (!_abort) {\n      smileMutexLock(syncCondMtx);\n      if (nWaiting == nActive - 1) {  // all waiting except us.. looks like a probe round\n        nProbe++;\n      }\n      if (nRun > 0) {\n        smileCondBroadcastRaw(syncCond);\n        SMILE_MSG(3, \"thread %i processed data (%i)\", threadId, (int)tickNr);\n        //compRunFlag = 1;\n        for (int i = 0; i < nActive; i++) {\n            runFlag[i] = 1;\n        }\n        weDidRun = 1;\n        // we need some mechanism to ensure that if we just ran, but then will be waiting for all other threads,\n        // that all other threads have had a chance to run before we terminate!\n      } else {\n        if (runFlag[threadId] == 1) {\n          runFlag[threadId] = 0;\n          nRun = 1;\n        } else {\n          //smileCondBroadcastRaw(syncCond);\n          nWaiting++;\n          // actually: if nWaiting==nActive  terminate!\n          if (nWaiting == nActive) {\n            // we need some mechanism to ensure that if we just ran, but then will be waiting for all other threads,\n                    // that all other threads have had a chance to run before we terminate!\n            if (weDidRun == 1) {\n              // check a counter == nActive - 1?\n              if (nProbe == nActive - 1) {\n                nRun = 0;\n                SMILE_MSG(3, \"thread %i ending AFTER PROBE, tick %i -> ALL WAITING NOW (nW = %i)\", threadId, (int)tickNr, nWaiting);\n              } else {\n                nRun = 1;\n                SMILE_MSG(3, \"thread %i re-run (probe), tick %i -> ALL WAITING NOW (nW = %i)\", threadId, (int)tickNr, nWaiting);\n              }\n            } else {\n              SMILE_MSG(3, \"thread %i ending, tick %i -> ALL WAITING NOW (nW = %i)\", threadId, (int)tickNr, nWaiting);\n              nRun = 0;\n            }\n            nWaiting--;\n          } else {\n            SMILE_MSG(3, \"thread %i sleeping, tick %i (nW = %i)\", threadId, (int)tickNr, nWaiting);\n            smileCondWaitWMtx(syncCond,syncCondMtx); // sleep until another thread or the controller thread wakes us\n            nWaiting--;\n            SMILE_MSG(3, \"thread %i woken (%i)\", threadId, (int)tickNr);\n            nRun = 1;\n            weDidRun = 0;\n          }\n        }\n      }\n      if (nProbe >= nActive - 1) {\n        nProbe = 0;\n        weDidRun = 1;\n      }\n      smileMutexUnlock(syncCondMtx);\n      if ((_data->maxtick != -1)&&(tickNr >= _data->maxtick)) nRun = 0;\n    }\n    smileMutexLock(abortMtx);\n    if (_abort) { nRun = 0; }\n    smileMutexUnlock(abortMtx);\n  } while (nRun>0) ;\n\n  smileMutexLock(syncCondMtx);\n  nActive--;\n  smileMutexUnlock(syncCondMtx);\n\n  SMILE_MSG(3,\"leaving processing loop of thread %i (ticks: %i)\",threadId,tickNr);\n  // first part... now enter EOI state, however wait for other threads...???\n\n  return tickNr;\n\n}\n#endif\n#if 0\n// multi thread tick loop (tick loop for one of many threads)\nlong long cComponentManager::tickLoopA(long long maxtick, int threadId, sThreadData *_data)\n{\n  int nRun;\n  long long tickNr = -1;\n  int nRun0cnt = 0;\n\n  SMILE_MSG(2,\"starting processing loop of thread %i\",threadId);\n\n  /*\n  smileMutexLock(syncCondMtx);\n  // TODO: BUG, if nActive == 1, because other threads have not yet been started!!! (maybe initialise nActive with nThreads!?)\n  nActive++;\n  smileMutexUnlock(syncCondMtx);\n  */\n\n  do {\n    tickNr++;\n    SMILE_DBG(4,\"<------- TICK # %i (thread %i) ---------->\",tickNr,threadId);\n    nRun = tick(threadId,tickNr);\n    //    smileYield();\n    SMILE_DBG(4,\"nRun = %i (thread %i)\",nRun,threadId);\n    smileMutexLock(syncCondMtx);\n    //    fprintf(stderr,\"mutlock...%i\\n\",threadId);\n    if (nRun==0) {\n      // if not all waiting... wait!\n      //          fprintf(stderr,\"wc? %i nW %i nA %i\\n\",threadId,nWaiting,nActive); fflush(stderr);\n      //if (nWaiting+nWaiting2 < nActive) {\n\n      if (nWaiting+nWaiting2 < nActive-1) {\n        if (_data->status == THREAD_ACTIVE) {\n          nWaiting++;\n        }\n        if (_data->status == THREAD_WAIT_B) {\n          nWaiting2--;\n          nWaiting++;\n        }\n        _data->status = THREAD_WAIT_A;\n\n        nRun0cnt = 0;\n        //fprintf(stderr,\"entering wait cond %i  (T=%i) nW %i nA %i\\n\",threadId,tickNr,nWaiting,nActive); fflush(stderr);\n        //smileCondBroadcastRaw(syncCond);\n        //fprintf(stderr,\"w1 state %i  (T=%i) nW %i nA %i nW2 %i\\n\",threadId,tickNr,nWaiting,nActive,nWaiting2); fflush(stderr);\n        if (nWaiting + nWaiting2 >= nActive) { smileCondBroadcastRaw(syncCond); }\n        smileCondWaitWMtx(syncCond,syncCondMtx);\n        //fprintf(stderr,\"w1 state end %i  (T=%i) nW %i nA %i nW2 %i\\n\",threadId,tickNr,nWaiting,nActive,nWaiting2); fflush(stderr);\n        //fprintf(stderr,\"exiting wait cond %i\\n\",threadId); fflush(stderr);\n        //nWaiting--;\n        nRun=1;\n      } //else  //all threads seem to have failed.... nRun=0, this will exit the first loop\n      else {\n        if (_data->status == THREAD_WAIT_A) {\n          nWaiting--; \n        }\n        if (_data->status != THREAD_WAIT_B) {\n          nWaiting2++; _data->status = THREAD_WAIT_B;\n        }\n        int nWaiting_old = nWaiting;\n        fprintf(stderr,\"w2 state %i  (T=%i) nW %i nA %i nW2 %i\\n\",threadId,tickNr,nWaiting,nActive,nWaiting2); fflush(stderr);\n        //nWaiting2++;\n        //_data->status = THREAD_WAIT_B;\n        //if (nWaiting + nWaiting2 >= nActive) {smileCondBroadcastRaw(syncCond); }\n        smileCondBroadcastRaw(syncCond);\n        //fprintf(stderr,\"bc w2\\n\"); fflush(stderr);\n        if (nWaiting2 < nActive) {\n          nRun = 1;\n          smileCondWaitWMtx(syncCond,syncCondMtx);\n        } else {\n          // exit for sure (?)... inform other threads?\n          fprintf(stderr,\"exit of %i\\n\",threadId); fflush(stderr);\n        }\n        if (nWaiting_old > nWaiting) {\n          _data->status = THREAD_ACTIVE;\n          nWaiting2--;\n        }\n\n        //fprintf(stderr,\"w2 state end %i  (T=%i) nW %i nA %i nW2 %i\\n\",threadId,tickNr,nWaiting,nActive,nWaiting2); fflush(stderr);\n\n        //nRun0cnt++;\n\n        //if (nRun0cnt <= 1) { nRun = 1; \n        //fprintf(stderr,\"nRun0cnt %i = %i\\n\",threadId,nRun0cnt); fflush(stderr);\n        //nWaiting++;\n        //           nWaiting++;\n        //        smileCondBroadcastRaw(syncCond);\n        //smileCondWaitWMtx(syncCond,syncCondMtx);\n        //        smileMutexUnlock(syncCondMtx);\n        //        smileYield();\n        //        smileMutexLock(syncCondMtx);\n        //        nWaiting--;\n        //smileCondWaitWMtx(syncCond,syncCondMtx);\n        //nWaiting--;\n        //}\n      }\n      //}\n    } else {\n      //      smileMutexLock(syncCondMtx);\n      if (_data->status == THREAD_WAIT_A) {\n        _data->status = THREAD_ACTIVE;\n        nWaiting--;\n      } else\n        if (_data->status == THREAD_WAIT_B) {\n          _data->status = THREAD_ACTIVE;\n          //nWaiting--; \n          nWaiting2--;\n        }\n\n        smileCondBroadcastRaw(syncCond); \n        //fprintf(stderr,\"bc ok\\n\"); fflush(stderr);\n        userOnTick(tickNr,EOI,threadId);\n        nRun0cnt = 0;\n    }\n    if ((maxtick != -1)&&(tickNr >= maxtick)) nRun = 0;\n    smileMutexLock(abortMtx);\n    if (abortRequest) {\n      nRun = 0;\n    }\n    smileMutexUnlock(abortMtx);\n\n    if (nRun == 0) nActive--;\n\n    smileMutexUnlock(syncCondMtx);\n\n    smileYield(); // !!!!?\n  } while(nRun > 0);\n\n  //  smileMutexLock(syncCondMtx);\n  // we must signal, if we exit, in order to wake up other threads, to allow them to check , if they are finished too\n  //  smileCondBroadcastRaw(syncCond);\n  //  smileMutexUnlock(syncCondMtx);\n  if (_data->status == THREAD_WAIT_A) {\n    _data->status = THREAD_ACTIVE;\n    nWaiting--;\n  } else\n    if (_data->status == THREAD_WAIT_B) {\n      _data->status = THREAD_ACTIVE;\n      //nWaiting--; \n      nWaiting2--;\n    }\n\n    smileCondBroadcastRaw(syncCond); \n    SMILE_MSG(2,\"leaving processing loop of thread %i (ticks: %i)\",threadId,tickNr);\n    // first part... now enter EOI state, however wait for other threads...???\n\n    return tickNr;\n}\n#endif\n\n// multi thread tick loop (tick loop for one of many threads)\n//long long cComponentManager::tickLoopB(long long maxtick, int threadId)//\n//{\n//TODO... post EOI processing... (not needed... we will try to use tickLoopA again..)\n\n//  return 0;\n//}\n\n//\n// !!! THIS function should be always preferred, since it determines single/multi thread from config !!!\n//\n// multi threaded run: create threads for multiple tick loops and control/synchronize them...\nlong long cComponentManager::runMultiThreaded(long long maxtick)\n{\n  if (!ready) return 0;\n  int i;\n\n  if (nThreads == 1) {\n    return runSingleThreaded(maxtick);\n  } else {\n    if (nThreads == 0) {\n      int j=0;\n      // int * threadPrios = (int *) calloc(1,sizeof(int)*lastComponent);\n      for (i=0; i<lastComponent; i++) {\n        if (componentThreadId[i] != -2) {\n          /* TODO : store threadPrio in an array indexed by 1..j \n          threadPrios[j] = componentThreadPrio[i];\n          */\n          componentThreadId[i] = j++;\n        }\n      }\n      nThreads = j;\n    } else {\n      for (i=0; i<lastComponent; i++) {\n        if (componentThreadId[i] == -1) componentThreadId[i] = 0; // run in first thread\n      }\n    }\n    SMILE_MSG(2,\"starting mutli-thread processing with %i threads\",nThreads);\n    // create thread handles and data structures\n    runFlag = (int *)malloc(sizeof(int) * nThreads);\n    sThreadData *threadData = (sThreadData*)malloc(sizeof(sThreadData) * nThreads);\n    smileThread *threadHandles = (smileThread *)malloc(sizeof(smileThread) * nThreads);\n    smileMutexCreate(syncCondMtx);\n    smileCondCreate(syncCond);\n    smileCondCreate(waitEndCond);\n    smileCondCreate(waitControllerCond);\n\n    nActive = nThreads;\n    waitEndCnt = 0;\n    smileMutexCreate(waitEndMtx);\n\n    // create the controller thread...\n    smileCondCreate(controlCond);\n    sThreadData control;\n    control.obj = this;\n    control.threadId = -1;\n    smileThread controlThr;\n    runStatus = 1; compRunFlag = 0; probeFlag = 0; nProbe = 0; endOfLoop=0; controllerPresent=0;\n    if (!(int)smileThreadCreate(controlThr, threadRunnerControl, &control)) {\n      SMILE_ERR(1,\"error creating controller thread!!\",i);\n    }\n    // create all the threads....\n    for (i=0; i<nThreads; i++) {\n      threadData[i].obj = this;\n      threadData[i].maxtick = maxtick;\n      threadData[i].threadId = i;\n      threadData[i].status = THREAD_ACTIVE;\n      if (!(int)smileThreadCreate(threadHandles[i], threadRunner, &(threadData[i]))) {\n        //      if (!((long)(threadHandles[i] = (HANDLE)_beginthread(threadRunner,0,&(threadData[i]))) != -1)) {\n        SMILE_ERR(1,\"error creating thread with threadId %i!!\",i);\n        smileMutexLock(syncCondMtx);\n        nActive--;\n        smileMutexUnlock(syncCondMtx);\n      } else {\n        /* TODO: set priority of current thread here... */\n#ifdef __WINDOWS\n        //SetThreadPriority(threadHandles[i] , threadPrios[i] );\n#endif\n      }\n    }\n    //free(threadPrios);\n\n    // wait for all threads to finish\n    for (i=0; i<nThreads; i++) {\n      //      fprintf(stderr,\"joining thr %i (nA=%i)\\n\",i,nActive); fflush(stderr);\n      smileThreadJoin(threadHandles[i]);\n      threadData[i].status = THREAD_INACTIVE;\n    }\n\n    // and the controller thread\n    //    fprintf(stderr,\"joining controller (nA=%i)\\n\",nActive); fflush(stderr);\n    smileCondSignal(controlCond);\n    smileThreadJoin(controlThr);\n    //fprintf(stderr,\"joined controller\\n\");\n\n    smileMutexDestroy(waitEndMtx);\n    smileMutexDestroy(syncCondMtx);\n    smileCondDestroy(syncCond);\n    smileCondDestroy(controlCond);\n    smileCondDestroy(waitEndCond);\n    smileCondDestroy(waitControllerCond);\n\n    // destroy all threads and thread data:\n    if (runFlag != NULL) free(runFlag);\n    if (threadData != NULL) free(threadData);\n    if (threadHandles != NULL) free(threadHandles);\n\n    // do profiling (TODO: correct for multi-threading!?):\n    if (profiling) {\n      double psum = 0.0;\n      double *ps = (double*)calloc(1, sizeof(double) * (lastComponent + 1));\n      for (int i=0; i<=lastComponent; i++) {\n        if (component[i] != NULL) {\n          ps[i] = component[i]->getProfile(1);\n          psum += ps[i];\n        }\n      }\n      SMILE_PRINT(\" == Component run-time profiling ==\");\n      SMILE_PRINT(\"    Total time in component tick() in seconds: %f\", psum);\n      // normalise to percentages:\n      if (psum > 0.0) {\n        for (int i=0; i<=lastComponent; i++) {\n          if (component[i] != NULL) {\n            ps[i] /= psum;\n            SMILE_PRINT(\"  %s:   %.1f %s\", component[i]->getInstName(), ps[i] * 100.0, \"%\");\n          }\n        }\n      }\n      free(ps);\n    }\n  }\n  return 1; // TODO: tickNr??\n}\n\n\ncComponentManager::~cComponentManager()\n{\n  int i;\n\n  resetInstances();\n\n  for (i=0; i<lastComponent; i++) {\n    //    unregisterComponentInstance(i);\n    if ((componentInstTs!=NULL)&&(componentInstTs[i] != NULL)) free(componentInstTs[i]);\n  }\n  if (componentThreadId != NULL) free(componentThreadId);\n  if (component != NULL) free(component);\n  if (compTs != NULL) free(compTs);\n  if (componentInstTs != NULL) free(componentInstTs);\n\n  smileMutexDestroy(messageMtx);\n  smileMutexDestroy(abortMtx);\n  smileCondDestroy(pauseCond);\n  smileMutexDestroy(pauseMtx);\n\n#ifdef SMILE_SUPPORT_PLUGINS   // NOTE: the config Manager must be freed before this\n#ifndef __STATIC_LINK\n  //close dynlibs of plugins and free memory in plugin dlls/dynlibs:\n  if ((handlelist != NULL)&&(nPluginHandles>0)) {\n    for (i=0; i<nPluginHandles; i++) {\n#ifdef __WINDOWS\n      // unregister...\n      unRegisterFunction unRegFn = (unRegisterFunction) GetProcAddress(handlelist[i], \"unRegisterPluginComponent\");\n      if (unRegFn != NULL) { (*unRegFn)(); }\n      FreeLibrary(handlelist[i]);\n#else\n      // unregister...\n      const char *error;\n      unRegisterFunction unRegFn = (unRegisterFunction)dlsym(handlelist[i], \"unRegisterPluginComponent\");\n      if (!( ((error = dlerror()) != NULL) || (unRegFn == NULL))) {\n        (*unRegFn)(); \n      }\n      dlclose(handlelist[i]);\n#endif\n    }\n    free(handlelist);\n  }\n  if (regFnlist != NULL) free(regFnlist);\n#endif\n#endif\n\n}\n"
  },
  {
    "path": "src/core/configManager.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*\n\n  central configuration manager for all components\n  provides standard interface for various plugable config reader classes (e.g. config file, commandline, database, etc.)\n  \n  this configManager ONLY manages the configuration of specific parameters for components (or component instances),\n  it does NOT manage the components to be initialized and the component dependencies (i.e. initialisation of readers and writers of each component)\n\n  module names in this class refer to the names of the component instances.\n  i.e. if you create a component instance config be sure to use the same module (aka. component) names in the component parameter configuration file (this is the one read and managed by this module)\n\n  (however, there is one way to put the component initialisation config in this class:\n    you need to create a component \"compInitializer\"  (or use the componentManager)\n    and then configure this component\n  )\n */\n\n\n// TODO::::  implement setValue functions in analogy to getValue functions to override configuration values!\n// also, add a flag to setValue, to only overwrite UNset options\n\n#include <core/configManager.hpp>\n#include <ctype.h>\n\n\n\n\n#define MODULE \"configManager\"\n\n// split n at first . into b (left) and s (right)\n// return 1 if '.' was found in *n, 0 otherwise  , *b is allocated and must be freed by calling code!\nint instNameSplit(const char *n, char **b, const char **s)\n{\n  if (n!=NULL) {\n    const char *x = strchr(n,'.');\n    if (x== NULL) {\n      if (b != NULL) *b = strdup(n);\n      if (s != NULL) *s = NULL;\n      return 0;\n    } else {\n      size_t blen = (size_t)(x) - (size_t)(n);\n      if (b != NULL) {\n        *b = (char*)malloc(sizeof(char)*(blen+1));\n        memcpy(*b,n,blen);\n        (*b)[blen]=0;\n      }\n      if (s != NULL) *s = x+1;\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/** Config Instance ***************************/\n\n\n//#define CFTP_VAR   1000      // experimental...? variable type, determined at loading of config file..\n\n\nvoid ConfigValueNum::copyFrom(const ConfigValue *val)\n{\n  if (val==NULL) return;\n  if (val->getType() != getType()) CONF_MANAGER_ERR(\"ConfigValue::copyFrom, cannot copy from incompatible type (%i)!\",val->getType());\n  valueD = val->getDouble();\n  valueI = val->getInt();\n  set=val->isSet();\n}\n\nvoid ConfigValueStr::copyFrom(const ConfigValue *val)\n{\n  if (val==NULL) return;\n  if (val->getType() != getType()) CONF_MANAGER_ERR(\"ConfigValue::copyFrom, cannot copy from incompatible type (%i)!\",val->getType());\n  if (str != NULL) free(str);\n  if (val->getStr() != NULL) {\n    str = strdup(val->getStr());\n    set=val->isSet();\n  } else { set = 0; }\n}\n\nvoid ConfigValueChr::copyFrom(const ConfigValue *val)\n{\n  if (val==NULL) return;\n  if (val->getType() != getType()) CONF_MANAGER_ERR(\"ConfigValue::copyFrom, cannot copy from incompatible type (%i)!\",val->getType());\n  c = val->getChar();\n  set=val->isSet();\n}\n\n\nvoid ConfigValueObj::setValue(ConfigInstance * value, int n)\n{\n  if ((obj != NULL)&&(freeObj)) delete obj;\n  obj = value; if (value!=NULL) set=1; else set = 0;\n}\n\nvoid ConfigValueObj::copyFrom(const ConfigValue *val)\n{\n  if (val==NULL) return;\n  if (val->getType() != getType()) CONF_MANAGER_ERR(\"ConfigValue::copyFrom, cannot copy from incompatible type (%i)!\",val->getType());\n  if ((obj != NULL)&&(freeObj)) delete obj;\n  obj = val->getObj(); freeObj=0;\n  if (obj != NULL) set=val->isSet(); else set = 0;\n}\n\nint ConfigValueObj::missingFrom(const ConfigValue *val)\n{\n  if (val==NULL) return 0;\n  if (val->getType() != getType()) CONF_MANAGER_ERR(\"ConfigValue::copyFrom, cannot copy from incompatible type (%i)!\",val->getType());\n  if (obj != NULL) {\n    return obj->missingFrom(val->getObj());\n  } else {\n    //obj = val->getObj(); freeObj=0;  // TODO: nicer copy mechanism... e.g. copy constructor...?\n    CONF_MANAGER_ERR(\"ConfigValueObj::missingFrom: ConfigInstance copy not yet supported!\");\n  }\n}\n\nint ConfigValueObj::updateWith(const ConfigValue *val)\n{\n  if (val==NULL) return 0;\n  if (val->getType() != getType()) CONF_MANAGER_ERR(\"ConfigValue::copyFrom, cannot copy from incompatible type (%i)!\",val->getType());\n  if (obj != NULL) {\n    return obj->updateWith(val->getObj());\n  } else {\n    //obj = val->getObj(); freeObj=0;  // TODO: nicer copy mechanism... e.g. copy constructor...?\n    CONF_MANAGER_ERR(\"ConfigValueObj::updateWith: ConfigInstance copy not yet supported!\");\n  }\n}\n\n\nConfigValueObj::~ConfigValueObj()\n{\n  if ((obj != NULL)&&(freeObj))\n    delete obj;\n}\n\n\nConfigValueArr::ConfigValueArr(int initN) : N(0), el(NULL), maxN(-1)\n{\n  if (initN < NEL_ALLOC_BLOCK) initN = NEL_ALLOC_BLOCK;\n  el = (ConfigValue **)calloc(1,sizeof(ConfigValue*)*initN);\n  aName = (char **)calloc(1,sizeof(char*)*initN);\n  if (el==NULL) OUT_OF_MEMORY;\n  if (aName==NULL) OUT_OF_MEMORY;\n  N=initN;\n  type=CFTP_ARR;\n}\n\nConfigValueArr::~ConfigValueArr()\n{\n  if (el != NULL) {\n    int i;\n    for (i=0; i<N; i++) {\n      if (el[i] != NULL) delete el[i];\n    }\n    free(el);\n  }\n  if (aName != NULL) {\n    int i;\n    for (i=0; i<N; i++) {\n      if (aName[i] != NULL) free(aName[i]);\n    }\n    free(aName);\n  }\n}\n\nvoid ConfigValueArr::setValue(ConfigValue *v, int n)\n{\n  // TODO: checks... + realloc if n>=Nalloc\n  if (checkIdxWr(n)) {\n    if (el[n] != NULL) delete(el[n]);\n    el[n] = v;\n    set=1;\n  } else CONF_MANAGER_ERR(\"ConfigValueArr::setValue: invalid index %i (N=%i)\",n,N);\n}\n\nint ConfigValueArr::checkIdx(int n) const\n{\n  if (n >= 0) {\n    if (n<N) {\n      return 1;\n    } \n  }\n  return 0;\n}\n\nint ConfigValueArr::checkIdxWr(int n)\n{\n  if (n >= 0) {\n    if (n<N) {\n      if (n>maxN) maxN=n;\n      return 1;\n    } else { // realloc:\n      int newSize = n;\n      if (newSize-N < NEL_ALLOC_BLOCK) newSize = N+NEL_ALLOC_BLOCK;\n      ConfigValue **_el = (ConfigValue**)crealloc( el, sizeof(ConfigValue*)*newSize, sizeof(ConfigValue*)*N );\n      char **_aName = (char**)crealloc( aName, sizeof(char*)*newSize, sizeof(char*)*N );\n      if (_el==NULL) OUT_OF_MEMORY;\n      if (_aName==NULL) OUT_OF_MEMORY;\n      N = newSize;\n      el = _el;\n      aName=_aName;\n      if (n>maxN) maxN=n;\n      return 1;\n    }\n  }\n  return 0;\n}\n\nint ConfigValueArr::findField(const char *_name, int noerr) const\n{\n  int i;\n  if (_name == NULL) return -2;  // bogus name...\n  if (aName == NULL) return -2; // not an associative array??\n  SMILE_DBG(7,\"ConfigValueArr::findField: maxN = %i\",maxN);\n  for (i=0; i<=maxN; i++) {\n    SMILE_DBG(7,\"ConfigValueArr::findField: comp iter. %i\",i);\n    if ((el[i] != NULL)&&(aName[i] != NULL)) {\n      SMILE_DBG(7,\"ConfigValueArr::findField: compare '%s' <-> '%s'\",aName[i],_name);\n      if (!strcmp(aName[i],_name)) { return i; }\n    }\n  }\n  if (!noerr) SMILE_ERR(5,\"ConfigValueArr::findField: field '%s' not found in this associative array\",_name);\n  return -1; // not found\n}\n\nint ConfigValueArr::findFieldWr(const char *_name)\n{\n  int idx = findField(_name,1);\n  if (idx == -1) { // not found: assign it...\n    int i;\n    // search for first available index\n    for (i=0; i<N; i++) {\n      if ((el[i] == NULL)&&(aName[i] == NULL)) {\n        idx = i;\n        break;\n      }\n    }\n    if (idx == -1) { // no free elements... allocate next:\n      idx = N;\n      if (!checkIdxWr(N)) idx = -1;  // no space, or some other error...!\n    }\n    if (idx >= 0) {\n      aName[idx] = strdup(_name);\n    }\n  }\n  return idx;\n}\n\nConfigValue * ConfigValueArr::operator[](int n) const\n{\n  SMILE_DBG(7,\"operator [int] of ConfigValueArr called...\");\n  if (checkIdx(n)) return el[n];\n  else return NULL;\n}\n\nConfigValue * ConfigValueArr::operator[](const char *_name) const\n{\n  SMILE_DBG(7,\"operator [char *] of ConfigValueArr called...\");\n  int n = findField(_name);\n  if (checkIdx(n)) return el[n];\n  else return NULL;\n}\n\n// TODO: resize array.....!!!\nvoid ConfigValueArr::copyFrom(const ConfigValue *val)\n{\n  int i;\n  if (val==NULL) return;\n  ConfigValueArr *a;\n  if (val->getType() >= CFTP_ARR) a = (ConfigValueArr *)val;\n  else CONF_MANAGER_ERR(\"ConfigValueArr::copyFrom called with non-array element as argument!\");\n  int Nc;\n  Nc = a->getN();\n  if (Nc > N) Nc = N;\n  for (i=0; i<Nc; i++) {\n    if (el[i] != NULL)\n      el[i]->copyFrom(a->el[i]);\n    //TODO....  else : REAL copy of ConfigVal object... ??\n  }\n}\n\nint ConfigValueArr::missingFrom(const ConfigValue *val)\n{\n  int i;\n  if (val==NULL) return 0;\n  ConfigValueArr *a;\n  if (val->getType() >= CFTP_ARR) a = (ConfigValueArr *)val;\n  else return 0;\n  int Nc;\n  Nc = a->getN();\n  if (Nc > N) Nc = N;\n  for (i=0; i<Nc; i++) {\n    if (el[i] != NULL)\n      el[i]->missingFrom(a->el[i]);\n    //TODO....  else : REAL copy of ConfigVal object... ??\n  }\n  return 0; // TODO...\n}\n\nint ConfigValueArr::updateWith(const ConfigValue *val)\n{\n  int i;\n  if (val==NULL) return 0;\n  ConfigValueArr *a;\n  if (val->getType() >= CFTP_ARR) a = (ConfigValueArr *)val;\n  else return 0;\n  int Nc;\n  Nc = a->getN();\n  if (Nc > N) Nc = N;\n  for (i=0; i<Nc; i++) {\n    if (el[i] != NULL)\n      el[i]->updateWith(a->el[i]);\n    //TODO....  else : REAL copy of ConfigVal object... ??\n  }\n  return 0; // TODO...\n}\n\n\n\nvoid ConfigValueNumArr::setValue(double v, int n)\n{\n  if (checkIdxWr(n)) {\n    if (el[n] == NULL) {\n      // allocate value..\n      el[n] = new ConfigValueNum(v);   // WARNING: freeObj = 1  always!\n      if (el[n] == NULL) OUT_OF_MEMORY;\n    } else {\n      el[n]->setValue(v);\n    }\n  }\n}\n\nvoid ConfigValueNumArr::setValue(int v, int n)\n{\n  if (checkIdxWr(n)) {\n    if (el[n] == NULL) {\n      // allocate value..\n      el[n] = new ConfigValueNum(v);   // WARNING: freeObj = 1  always!\n      if (el[n] == NULL) OUT_OF_MEMORY;\n    } else {\n      el[n]->setValue(v);\n    }\n  }\n}\n\nvoid ConfigValueStrArr::setValue(const char *v, int n)\n{\n  if (checkIdxWr(n)) {\n    if (el[n] == NULL) {\n      // alocate value..\n      el[n] = new ConfigValueStr(v);   // WARNING: freeObj = 1  always!\n      if (el[n] == NULL) OUT_OF_MEMORY;\n    } else {\n      el[n]->setValue(v);\n    }\n  }\n}\n\nvoid ConfigValueChrArr::setValue(char v, int n) {\n  if (checkIdxWr(n)) {\n    if (el[n] == NULL) {\n      // alocate value..\n      el[n] = new ConfigValueChr(v);   // WARNING: freeObj = 1  always!\n      if (el[n] == NULL) OUT_OF_MEMORY;\n    } else {\n      el[n]->setValue(v);\n    }\n  }\n}\n\nvoid ConfigValueObjArr::setValue(ConfigInstance *v, int n) {\n  if (checkIdxWr(n)) {\n    if (el[n] == NULL) {\n      // alocate value..\n      el[n] = new ConfigValueObj(v);   // WARNING: freeObj = 1  always!\n      if (el[n] == NULL) OUT_OF_MEMORY;\n    } else {\n      el[n]->setValue(v);\n    }\n  }\n}\n\n\n/**************/\n\n\n/**** Config Type ***************************************************************/\n\n\nConfigType::ConfigType(const char *_name, int N_) :\n  element(NULL),\n  I(0)\n{\n  if (name != NULL) setName( _name );\n  parentName[0] = 0; // no parent name..\n  if (N_ > 0) {\n    N=N_;\n    element = (ConfigDescription *)calloc(1,sizeof(ConfigDescription)*N_);\n  } else {\n    CONF_MANAGER_ERR(\"Cannot create ConfigType object with number of elements _N < 0 (N_=%i)!\",N_);\n  }\n}\n\n// type copy constructor\nConfigType::ConfigType( ConfigType const& copy, const char *_newname) :\n  N(copy.N),\n  I(copy.I),\n  element(NULL)\n{\n  if (_newname != NULL) {\n    // save last name as parent name\n    memcpy( parentName, name, CONFIGTYPE_STRLEN+1 ); \n    // overwrite with new name\n    setName(_newname);\n  } else { setName(copy.name); }\n  // copy configDescription:\n  if (copy.element != NULL) {\n    element = (ConfigDescription *)calloc(1,sizeof(ConfigDescription)*N);\n    memcpy( element, copy.element, sizeof(ConfigDescription)*N );\n    int i;\n    for (i=0; i<N; i++) {\n      element[i].description = NULL;\n      element[i].dfltStr = NULL;\n      element[i].freeType=0;\n      if (copy.element[i].description != NULL) {\n        element[i].description = strdup(copy.element[i].description);\n      }\n      if (copy.element[i].dfltStr != NULL) {\n        element[i].dfltStr = strdup(copy.element[i].dfltStr);\n      }\n    }\n\n  }\n}\n\nvoid ConfigType::setName(const char *_name)\n{\n  if (_name == NULL) { SMILE_ERR(1,\"cannot set name == NULL (setName)\"); }\n  else {\n    size_t l = strlen(_name);\n    if (l>CONFIGTYPE_STRLEN) {\n      l=CONFIGTYPE_STRLEN;\n    }\n#ifdef _MSC_VER // Visual Studio specific macro\n    strncpy_s( name, CONFIGTYPE_STRLEN, _name, MIN((l+1),CONFIGTYPE_STRLEN) );\n#else\n    strncpy( name, _name, MIN((l+1),CONFIGTYPE_STRLEN) );\n#endif\n    name[CONFIGTYPE_STRLEN] = 0; // ensure last element is always the terminating NULL character\n  }\n}\n\nint ConfigType::findFieldH(const char *_name, int *n, const ConfigType **tp, int *aIdx, char **aStr) const\n{\n  try {\n  if (_name != NULL) {\n    int h, idx;\n    char *base=NULL;\n    const ConfigType *cur=this;\n    const char*origname = _name;\n    int arrIdx = -1;\n    char *arrStr = NULL;\n\n    do {\n      if (cur==NULL) {\n        CONF_MANAGER_ERR(\"ConfigType::findFieldH: cannot dereference NULL subobject pointer while finding filed '%s' (rem:'%s')\",origname,_name);\n      }\n      // split name\n      const char *rem=NULL;\n      h = instNameSplit(_name, &base, &rem);\n      if (base == NULL) { CONF_MANAGER_ERR(\"no base name returned by instNameSplit (name='%s')!\\n\",_name); }\n      arrIdx = -1;\n      if (arrStr != NULL) { free(arrStr); arrStr=NULL; }\n      idx = cur->findField(base,&arrIdx,&arrStr);\n      if (base!=NULL) { free(base); base=NULL; }\n      _name=rem;\n\n      if (h==1) {\n        if ((idx >= 0)&&(idx < N)) { // check for valid index\n          if ((cur->getType(idx) == CFTP_OBJ)||(cur->getType(idx) == CFTP_OBJ_ARR)) {\n            cur = cur->element[idx].subType;\n          }\n          else\n            CONF_MANAGER_ERR(\"ConfigType::findFieldH: subtype object referenced in '%s', however field %i is not of type OBJ or OBJ_ARR!\",_name,idx);\n        } else {\n          // error field \"base\" not found...\n          CONF_MANAGER_ERR(\"ConfigType::findFieldH: referenced base field with name '%s' not found!\",origname);\n        }\n      }\n    } while (h==1);\n\n    if (h==0) {\n      if ((idx >= 0)&&(idx < N)) { // check for valid index\n        if (n!=NULL) *n = idx;\n        if (tp!=NULL) *tp = cur;\n        if (aIdx!=NULL) *aIdx = arrIdx;\n        if (aStr!=NULL) *aStr = arrStr;\n        else if (arrStr != NULL) free(arrStr);\n        return 1;\n      } else\n        if (arrStr != NULL) { free(arrStr); }\n        // error field \"base\" not found...\n        CONF_MANAGER_ERR(\"ConfigType::findFieldH: referenced base field with name '%s' not found!\",origname);\n    }\n      if (arrStr != NULL) { free(arrStr); }\n  }\n  } catch (ConfigException *) {}\n  return 0;\n}\n\nvoid ConfigType::printTypeHelp(char *basestr, int _subtype) const\n{\n  int texOutput = 0;/////<---- enable this (=1), recompile, to get almost tex-ready documentation\n\n  if (basestr == NULL) {\n    if (texOutput) {\n      SMILE_PRINT(\"\\n %%Type: '%s'\\n\\\\label{sec:reference:componentlist:%s}\\n\\\\begin{description}\\n\",getName(),getName());\n    } else {\n      SMILE_PRINT(\"\\n === ConfigType '%s' : ===\",getName());\n    }\n  }\n  // TODO: print type description\n  if (element != NULL) {\n    int i;\n    const char *ArrS=\"\";\n    for (i=0; i<I; i++) {\n      if (element[i].enabled) {\n\n        if (texOutput) {\n          char *b=NULL;\n          if (basestr != NULL) b=myvprint(\"%s.\",basestr);\n          else b=myvprint(\"\");\n          if (element[i].type >= CFTP_ARR) { element[i].type -= CFTP_ARR+1; ArrS=\"[]\"; }\n          else { ArrS=\"\"; }\n          switch(element[i].type) {\n            case CFTP_OBJ: \n              if (element[i].subType != NULL)\n                SMILE_PRINT(\"\\\\item [%s%s%s = $<$object of type `%s'$>$] See the documentation of `%s' for more information (section~\\\\ref{sec:reference:componentlist:%s}).\",b,element[i].name,ArrS,element[i].subType->getName(),element[i].subType->getName(),element[i].subType->getName());\n              break;\n            case CFTP_NUM: \n              if (element[i].dfltDouble == floor(element[i].dfltDouble)) {\n                SMILE_PRINT(\"\\\\item [%s%s%s = $<$numeric$>$] \\\\hspace{1cm} [Default: %.0f] \\\\\\\\\",b,element[i].name,ArrS,element[i].dfltDouble);\n              } else {\n                SMILE_PRINT(\"\\\\item [%s%s%s = $<$numeric$>$] \\\\hspace{1cm} [Default: %g] \\\\\\\\\",b,element[i].name,ArrS,element[i].dfltDouble);\n              } \n              break;\n            case CFTP_STR:\n              SMILE_PRINT(\"\\\\item [%s%s%s = $<$string$>$]  \\\\hspace{1cm} [Default: `%s'] \\\\\\\\\",b,element[i].name,ArrS,element[i].dfltStr);\n              break;\n            case CFTP_CHR: \n              SMILE_PRINT(\"\\\\item [%s%s%s = $<$char$>$]   \\\\hspace{1cm} [Default: `%c'] \\\\\\\\\",b,element[i].name,ArrS,element[i].dfltChar);\n              break;\n\n          }\n          if (b!=NULL) free(b);\n\n          if (element[i].description != NULL) {\n            SMILE_PRINT(\"   %s\",element[i].description);\n          }\n          if ((element[i].type == CFTP_OBJ)&&(_subtype)) {\n            if (element[i].subType != NULL)\n              if (basestr!=NULL)\n                element[i].subType->printTypeHelp(myvprint(\"%s.%s%s\",basestr,element[i].name,ArrS));\n              else\n                element[i].subType->printTypeHelp(myvprint(\"%s%s\",element[i].name,ArrS));\n          }\n        \n        } else { ///////////////////// default console output:\n        \n          char *b=NULL;\n          if (basestr != NULL) b=myvprint(\"%s.\",basestr);\n          else b=myvprint(\"\");\n          if (element[i].type >= CFTP_ARR) { element[i].type -= CFTP_ARR+1; ArrS=\"[]\"; }\n          else { ArrS=\"\"; }\n          switch(element[i].type) {\n            case CFTP_OBJ: \n              if (element[i].subType != NULL)\n                SMILE_PRINT(\" %s%s%s = <object of type '%s'>\",b,element[i].name,ArrS,element[i].subType->getName());\n              break;\n            case CFTP_NUM: \n              if (element[i].dfltDouble == floor(element[i].dfltDouble)) {\n                SMILE_PRINT(\" %s%s%s = <numeric> [dflt: %.0f]\",b,element[i].name,ArrS,element[i].dfltDouble);\n              } else {\n                SMILE_PRINT(\" %s%s%s = <numeric> [dflt: %g]\",b,element[i].name,ArrS,element[i].dfltDouble);\n              }\n              //SMILE_PRINT(\" %s%s%s = <numeric> [dflt: %f]\",b,element[i].name,ArrS,element[i].dfltDouble);\n              break;\n            case CFTP_STR:\n              SMILE_PRINT(\" %s%s%s = <string>  [dflt: '%s']\",b,element[i].name,ArrS,element[i].dfltStr);\n              break;\n            case CFTP_CHR: \n              SMILE_PRINT(\" %s%s%s = <char>    [dflt: '%c']\",b,element[i].name,ArrS,element[i].dfltChar);\n              break;\n\n          }\n          if (b!=NULL) free(b);\n\n          if (element[i].description != NULL) {\n            SMILE_PRINT(\"   %s\",element[i].description);\n          }\n          if ((element[i].type == CFTP_OBJ)&&(_subtype)) {\n            if (element[i].subType != NULL)\n              if (basestr!=NULL)\n                element[i].subType->printTypeHelp(myvprint(\"%s.%s%s\",basestr,element[i].name,ArrS));\n              else\n                element[i].subType->printTypeHelp(myvprint(\"%s%s\",element[i].name,ArrS));\n          }\n\n        }\n      }\n    }\n  }\n  if (basestr != NULL) free(basestr);\n  else {\n    if (texOutput) {\n      SMILE_PRINT(\"\\n \\\\end{description}\\n\",getName());\n    } else {\n      SMILE_PRINT(\" \");\n    }\n  }\n}\n\nvoid ConfigType::printTypeDfltConfig(char *basestr, int _subtype, int withDescription, int ignInternal) const\n{\n  if (I <= 0) return;\n\n  if (ignInternal) { // check for various internal types such as dataReader/writer and do not print them...\n    const char * na = getName(); \n    if (na != NULL) {\n      if (!strcmp(na,\"cDataWriter\")) {\n        if (basestr != NULL) {\n          if (withDescription) {\n            SMILE_PRINT(\"   // Data memory level to write data to.\\n   // Only ONE level is possible here, and only this writer may write to that level.\");\n          }\n          SMILE_PRINT(\"writer.dmLevel = <<XXXX>>\");\n        }\n        return;\n      } else if (!strcmp(na,\"cDataReader\")) {\n        if (basestr != NULL) {\n          if (withDescription) {\n            SMILE_PRINT(\"   // Data memory level(s) to read data from. Concat multiple level names using ';'.\");\n          }\n          SMILE_PRINT(\"reader.dmLevel = <<XXXX>>\");\n        }\n        return;\n      } \n      //...\n\n    }\n  }\n\n  \n\n  // TODO: print only 'public' components, i..e  no dataReader, etc.\n\n  if (basestr == NULL) {\n    SMILE_PRINT(\"\\n  ;;;; default (template) configuration section for component '%s' ;;;;\",getName());\n\n    const char * na = getName(); \n    if (na != NULL) {\n      char * tmp = strdup(na);\n      char * tmpMod = tmp+1;\n      tmpMod[0] = tolower(tmpMod[0]);\n      SMILE_PRINT(\"[%s:%s]\",tmpMod,na);\n      free(tmp);\n    } else {\n      SMILE_PRINT(\"[null:cNULL]\");\n    }\n\n  }\n\n  // TODO: print type description\n  if (element != NULL) {\n    int i;\n    \n    for (i=0; i<I; i++) {\n      const char *ArrS=\"\";\n\n      int ok = 1;\n      if (ignInternal>=2) {\n        if (!strncmp(element[i].name,\"blocksize\",9) || !strncmp(element[i].name,\"buffersize\",10)) {\n          ok=0;\n        }\n      }\n\n      if ((element[i].enabled)&&(element[i].printDflt)/*&&(element[i].type < CFTP_ARR)*/&&(ok)) {\n\n\n        char *b=NULL;\n        if (basestr != NULL) b=myvprint(\"%s.\",basestr);\n        else b=myvprint(\"\");\n        \n        int etype = element[i].type;\n        if (element[i].type >= CFTP_ARR) {\n          etype = CFTP_ARR;\n          ArrS=\"[]\";\n        }\n\n        char *eDescription=NULL;\n\n        if (withDescription) { //element[i].type -= CFTP_ARR+1; ArrS=\"[]\"; }\n\n\n          if (element[i].description != NULL) {\n            char * desc = strdup(  element[i].description );\n            // parse for number of lines\n            long c,C; int nLines = 1;\n            long l = (long)strlen(desc);\n            for (c=0; c<l; c++) {\n              if (desc[c] == '\\n') nLines++;\n            }\n            eDescription = (char *)calloc(1,sizeof(char) * (l + nLines * 6 + 16));\n            C=0;\n            eDescription[C++] = ' ';\n            eDescription[C++] = ' ';\n            eDescription[C++] = ' ';\n            eDescription[C++] = '/';\n            eDescription[C++] = '/';\n            eDescription[C++] = ' ';\n            for (c=0; c<l; c++) {\n              eDescription[C++] = desc[c];\n              if (desc[c] == '\\n') {\n                eDescription[C++] = ' ';\n                eDescription[C++] = ' ';\n                eDescription[C++] = ' ';\n                eDescription[C++] = '/';\n                eDescription[C++] = '/';\n                eDescription[C++] = ' ';\n              } \n            }\n            free(desc);\n          }\n\n        }\n        switch(etype) {\n            case CFTP_OBJ: \n              //              if (element[i].subType != NULL)\n              //SMILE_PRINT(\" %s%s%s = <object of type '%s'>\",b,element[i].name,ArrS,element[i].subType->getName());\n              break;\n            case CFTP_NUM: \n              if (eDescription != NULL) SMILE_PRINT(\"%s\",eDescription);\n              if (element[i].dfltDouble == 0) {\n                SMILE_PRINT(\"%s%s%s = 0\",b,element[i].name,ArrS);\n              } else if (element[i].dfltDouble == 0) {\n                SMILE_PRINT(\"%s%s%s = 1\",b,element[i].name,ArrS);\n              } else {\n                // check for int...\n                double d = element[i].dfltDouble;\n                if (d - floor(d) == 0) { // integer...\n                  SMILE_PRINT(\"%s%s%s = %i\",b,element[i].name,ArrS,(long)d);\n                } else { // float...\n                  SMILE_PRINT(\"%s%s%s = %f\",b,element[i].name,ArrS,element[i].dfltDouble);\n                }\n              }\n              break;\n            case CFTP_STR:\n              if (element[i].dfltStr != NULL) {\n                if (eDescription != NULL) SMILE_PRINT(\"%s\",eDescription);\n                SMILE_PRINT(\"%s%s%s = %s\",b,element[i].name,ArrS,element[i].dfltStr);\n              } else {\n                if (eDescription != NULL) SMILE_PRINT(\"%s (default: '<NULL>')\",eDescription);\n                SMILE_PRINT(\"// %s%s%s = \",b,element[i].name,ArrS);\n              }\n              break;\n            case CFTP_ARR:\n              if (eDescription != NULL) SMILE_PRINT(\"%s (default: empty)\",eDescription);\n              SMILE_PRINT(\"// %s%s%s = \",b,element[i].name,ArrS);\n              break;\n            case CFTP_CHR: \n              if (eDescription != NULL) SMILE_PRINT(\"%s\",eDescription);\n              SMILE_PRINT(\"%s%s%s = %c\",b,element[i].name,ArrS,element[i].dfltChar);\n              break;\n\n        }\n        if (b!=NULL) free(b);\n        if (eDescription != NULL) free(eDescription);\n\n\n\n\n        if ((element[i].type == CFTP_OBJ)&&(_subtype)) {\n          if (element[i].subType != NULL)\n            if (basestr!=NULL)\n              element[i].subType->printTypeDfltConfig(myvprint(\"%s.%s%s\",basestr,element[i].name,ArrS),_subtype,withDescription);\n            else\n              element[i].subType->printTypeDfltConfig(myvprint(\"%s%s\",element[i].name,ArrS),_subtype,withDescription);\n        }\n      }\n    }\n  }\n  if (basestr != NULL) free(basestr);\n  else SMILE_PRINT(\" \");\n}\n\nConfigType::~ConfigType()\n{\n  if (element != NULL) {\n    int i;\n    for (i=0; i<N; i++) {\n      if (element[i].description != NULL) {\n        free(element[i].description);\n      }\n      if (element[i].dfltStr != NULL) {\n        free(element[i].dfltStr);\n      }\n      // TODO: delete subType!?\n      if ((element[i].freeType)&&(element[i].subType!=NULL)) delete element[i].subType;\n    }\n    free(element);\n  }\n}\n\n// disable field by setting \"enabled = 0\", the field is still available normally, however, it will not be shown by printTypeHelp anymore!\nint ConfigType::disableField(const char *_name)\n{\n  int FF = findField(_name);\n  if (FF > -1) {\n    element[FF].enabled = 0;\n    return 1;\n  }\n  return 0;\n}\n\nint ConfigType::setField(const char *_name, const char *description, int type, int subtype, const ConfigType *subType, int freeType, int N_, int printDflt)\n{\n  // check name for forbidden characters: . [ ] = : , ;\n  if (strchr(_name,'.') != NULL) CONF_MANAGER_ERR(\"ConfigType::setField: Forbidden charachter '.' in field name '%s'\",_name);\n  if (strchr(_name,',') != NULL) CONF_MANAGER_ERR(\"ConfigType::setField: Forbidden charachter ',' in field name '%s'\",_name);\n  if (strchr(_name,'[') != NULL) CONF_MANAGER_ERR(\"ConfigType::setField: Forbidden charachter '[' in field name '%s'\",_name);\n  if (strchr(_name,']') != NULL) CONF_MANAGER_ERR(\"ConfigType::setField: Forbidden charachter ']' in field name '%s'\",_name);\n  if (strchr(_name,':') != NULL) CONF_MANAGER_ERR(\"ConfigType::setField: Forbidden charachter ':' in field name '%s'\",_name);\n  if (strchr(_name,';') != NULL) CONF_MANAGER_ERR(\"ConfigType::setField: Forbidden charachter ';' in field name '%s'\",_name);\n  if (strchr(_name,'=') != NULL) CONF_MANAGER_ERR(\"ConfigType::setField: Forbidden charachter '=' in field name '%s'\",_name);\n\n  // check for uniqueness of name:\n  int FF = findField(_name);\n  if (FF == -1) {\n    // check for free space:\n    if (I>=N) {\n      // DONE: dynamically increase the number of fields\n      //CONF_MANAGER_ERR(\"ConfigType::setField: cannot add more then N=%i fields! Specify a larger N when creating the object!\",N);\n#define N_NEW_ALLOC 20\n      ConfigDescription * tmp = (ConfigDescription *)realloc(element, sizeof(ConfigDescription)*(I+N_NEW_ALLOC));\n      if (tmp != NULL) {\n        ConfigDescription * tmp2 = tmp+N;\n        // initialise tmp2 with zero\n        bzero( tmp2, sizeof(ConfigDescription)*N_NEW_ALLOC);\n        N=I+N_NEW_ALLOC;\n        element = tmp;\n      } else { OUT_OF_MEMORY; }\n    }\n\n    element[I].enabled = 1;\n    element[I].type = type;\n    element[I].printDflt = printDflt;\n    element[I].subtype = subtype;\n    element[I].subType = subType;\n    element[I].freeType = freeType;\n#ifdef _MSC_VER // Visual Studio specific macro\n    strncpy_s( element[I].name, CONFIGTYPE_STRLEN, _name, CONFIGTYPE_STRLEN );\n#else\n    strncpy( element[I].name, _name, CONFIGTYPE_STRLEN );\n#endif\n    //printf(\"name: %s.%s (d=%s)\\n\",this->getName(),_name,description); fflush(stdout);\n    if (description != NULL) {\n      element[I].description = strdup(description);\n    } else { element[I].description = NULL; }\n    //printf(\"name: %s.%s (Desc)\\n\",this->getName(),_name); fflush(stdout);\n    element[I].N = N_;\n    element[I].isMandatory = 0;\n    return I++;\n  } else {\n    element[FF].enabled = 1;\n    element[FF].type = type;\n    element[FF].printDflt = printDflt;\n    element[FF].subtype = subtype;\n    //element[FF].subType = subType;  // TODO: subtype overwrite!\n    //element[FF].freeType = freeType; // TODO: free on overwrite!?\n    //    strncpy( element[FF].name, _name, CONFIGTYPE_STRLEN ); // name may not be changed!\n    if (description != NULL) {\n      if (element[FF].description != NULL) free(element[FF].description);\n      element[FF].description = strdup(description);\n    }\n    element[FF].N = N_;\n    //element[FF].isMandatory = 0;\n    return FF;\n    //  CONF_MANAGER_ERR(\"ConfigType::setField: '%s' is not a unique name, already used in type!\");\n  }\n  return -1;\n}\n\nint ConfigType::setField(const char *_name, const char *description, int dflt, int arr, int printDflt)\n{\n  int ret=0;\n  if (!arr) {\n    ret = setField(_name,description,CFTP_NUM,0,(const ConfigType*)NULL,1,0,printDflt);\n  } else {\n    ret = setField(_name,description,CFTP_NUM_ARR,0,(const ConfigType*)NULL,1,0,printDflt);\n  }\n  if (ret >= 0) element[ret].dfltDouble = (double)dflt;\n  return ret;\n}\n\nint ConfigType::setField(const char *_name, const char *description, double dflt, int arr, int printDflt)\n{\n  int ret=0;\n  if (!arr) {\n    ret = setField(_name,description,CFTP_NUM,0,(const ConfigType*)NULL,1,0,printDflt);\n  } else {\n    ret = setField(_name,description,CFTP_NUM_ARR,0,(const ConfigType*)NULL,1,0,printDflt);\n  }\n  if (ret >= 0) element[ret].dfltDouble = dflt;\n  return ret;\n}\n\nint ConfigType::setField(const char *_name, const char *description, const char * dflt, int arr, int printDflt)\n{\n  int ret=0;\n  if (!arr) {\n    ret = setField(_name,description,CFTP_STR,0,NULL,1,0,printDflt);\n  } else {\n    ret = setField(_name,description,CFTP_STR_ARR,0,NULL,1,0,printDflt);\n  }\n  if (ret >= 0) {\n    if (dflt != NULL) {\n      if (element[ret].dfltStr != NULL) free(element[ret].dfltStr);\n      element[ret].dfltStr = strdup(dflt);\n    } else\n      element[ret].dfltStr = NULL;\n  }\n  return ret;\n}\n\nint ConfigType::setField(const char *_name, const char *description, char dflt, int arr, int printDflt)\n{\n  int ret=0;\n  if (!arr) {\n    ret = setField(_name,description,CFTP_CHR,0,NULL,1,0,printDflt);\n  } else {\n    ret = setField(_name,description,CFTP_CHR_ARR,0,NULL,1,0,printDflt);\n  }\n  if (ret >= 0) element[ret].dfltChar = dflt;\n  return ret;\n}\n\nint ConfigType::setField(const char *_name, const char *description, const ConfigType *dflt, int arr, int freeType)\n{\n  int ret=-1;\n  if (dflt==NULL) return ret;\n  if (arr==NO_ARRAY) {\n    ret = setField(_name,description,CFTP_OBJ,0,dflt,freeType);\n  } else {\n    ret = setField(_name,description,CFTP_OBJ_ARR,0,dflt,freeType);\n  }\n  return ret;\n}\n\n\nconst ConfigDescription * ConfigType::operator[] (int n)\n{\n  if ((n<N)&&(n>=0))\n    return &(element[n]);\n  else CONF_MANAGER_ERR(\"ConfigType [%i] index out of bounds (0-%i)\",n,N);\n}\n\nint ConfigType::findField(const char *fname, int *arrI, char **arrS) const\n{\n  // search for [] array indices:\n  if (element == NULL) return -1;\n  if (fname == NULL) {\n    SMILE_DBG(7,\"ConfigType::findField: called with fname == NULL!\");\n    return -1;\n  }\n  char *base = strdup(fname);\n  char * s = strchr(base,'[');\n  int isArr=0;\n  if (s!=NULL) { // [ was found\n    isArr=1;\n    char * e = strchr(base,']');\n    if (e==NULL) {\n      CONF_PARSER_ERR(\"ConfigType::findField: parse error: field name '%s', missing closing array index markers ] at end of name!\",fname);\n    }\n    if (strlen(e) > 1) {\n      CONF_PARSER_ERR(\"ConfigType::findField: parse error: field name '%s', has array index markers [] not at end of name!\",fname);\n    }\n    s[0] = 0;\n    if ((arrI != NULL)||(arrS != NULL)) {\n      e[0] = 0;\n      long Aidx;\n      char *idxStr = s+1;\n      // TODO: remove spaces from idxStr...\n      \n      if (strlen(idxStr) <= 0) CONF_PARSER_ERR(\"ConfigType::findField: parse error: field name '%s', has empty array index markers []!\",fname);\n      // scan array index...\n      char *eptr = NULL;\n      Aidx = strtol(idxStr,&eptr,0);\n      if ((eptr != NULL)&&(eptr[0]!=0)) { // not a pure number!\n        if (arrS != NULL) *arrS = strdup(idxStr);\n        if (arrI != NULL) *arrI = -1;\n      } else {\n        //sscanf( idxStr, \"%i\", &Aidx );\n        if (arrI != NULL) *arrI = Aidx;\n        if (arrS != NULL) *arrS = NULL;\n      }\n    }\n  } else if (arrI != NULL) { *arrI = -1; }\n\n  // now find \"base\":\n  int i;\n  for (i=0; i<N; i++) {\n    if (element[i].name != NULL) {\n      if (!strcmp(element[i].name,base)) {\n        free(base);\n/*\n        if ((element[i].type >= CFTP_ARR)&&(!isArr)) {\n          SMILE_ERR(1,\"missing array index [] for element '%s'\",element[i].name);\n          return -1;\n        }  TODO: move this somewhere else (in every function that uses findField(H)....!)*/\n        if ((element[i].type < CFTP_ARR)&&(isArr)) {\n          SMILE_ERR(1,\"array index [] specified for non-array element '%s'\",element[i].name);\n          return -1;\n        }\n        return i;\n      }\n    }\n  }\n  free(base);\n  return -1;  // field not found\n}\n\nint ConfigType::getType(int n) const  {\n  if ((n>=0)&&(n<N)&&(element!=NULL)) {\n    return element[n].type;\n  }\n  return -1;\n}\n\nconst ConfigType * ConfigType::getTypeObj(int n) const {\n  if ((n>=0)&&(n<N)&&(element!=NULL)) {\n    return element[n].subType;\n  }\n  return NULL;\n}\n\nconst char * ConfigType::getName(int n) const {\n  if ((n>=0)&&(n<N)&&(element!=NULL)) {\n    return element[n].name;\n  }\n  return NULL;\n}\n\n/**************************************************/\n\n\nConfigInstance::ConfigInstance(const char *_name, const ConfigType *_type, int _freeType) :\n  freeType(_freeType),\n  type(NULL)\n{\n  int n;\n  if (name != NULL) {\n#ifdef _MSC_VER // Visual Studio specific macro\n\tstrncpy_s(name,CONFIGTYPE_STRLEN,_name,CONFIGTYPE_STRLEN);\n#else\n    strncpy(name,_name,CONFIGTYPE_STRLEN);\n#endif\n    type=_type;\n    if (_type != NULL) {\n      n=_type->getN();\n      field=(ConfigValue **)calloc(1,sizeof(ConfigValue *)*n);\n      if (field == NULL) OUT_OF_MEMORY;\n      N=n;\n      int i;\n      for (i=0; i<n; i++) {\n        switch(_type->getType(i)) {\n          case CFTP_NUM : field[i] = new ConfigValueNum(_type->getDfltNum(i)); break;\n          case CFTP_STR : field[i] = new ConfigValueStr(_type->getDfltStr(i)); break;\n          case CFTP_CHR : field[i] = new ConfigValueChr(_type->getDfltChr(i)); break;\n          case CFTP_OBJ : field[i] = new ConfigValueObj(new ConfigInstance(_type->getName(i) ,_type->getDfltObj(i))); break;\n          case CFTP_ARR : field[i] = new ConfigValueArr(); break;\n          case CFTP_NUM_ARR : field[i] = new ConfigValueNumArr(); break;\n          case CFTP_STR_ARR : field[i] = new ConfigValueStrArr(); break;\n          case CFTP_CHR_ARR : field[i] = new ConfigValueChrArr(); break;\n          case CFTP_OBJ_ARR : field[i] = new ConfigValueObjArr(); break;\n          default: CONF_MANAGER_ERR(\"cannot create field of unknown type constant %i\",_type->getType(i));\n        }\n        if (field[i] != NULL) field[i]->unset();\n      }\n    } else {\n      CONF_MANAGER_ERR(\"Canot create a ConfigInstance with _type==NULL !\");\n    }\n  } else {\n    CONF_MANAGER_ERR(\"Canot create a ConfigInstance with _name==NULL !\");\n  }\n}\n\nConfigInstance::~ConfigInstance()\n{\n  if ((freeType)&&(type!=NULL)) delete type;\n  if (field != NULL) {\n    int i;\n    for(i=0; i<N; i++) {\n      if (field[i] != NULL) delete field[i];\n    }\n    free(field);\n  }\n}\n\n/* sanity check the given instance, if it is of the same type, dimensions etc. */\nint ConfigInstance::sanityCheck(ConfigInstance *_match) const\n{\n  // do some sanity checks:\n  if (_match == NULL) {\n    // argument cannot be NULL...\n    //CONF_MANAGER_ERR(\"argument of sanityCheck(ConfigInstance *_match) is NULL!\");\n    return 0;\n  }\n  if (_match->field == NULL) {\n    // no values in default\n    CONF_MANAGER_ERR(\"sanityCheck: field array in class passed as parameter is NULL!\");\n  }\n  if (_match->N != N) { // number of values must match\n    SMILE_ERR(2,\"cannot update missing values from an Instance with a different number of values\");\n    return 0;\n  }\n  if (_match->type->getName() != type->getName()) { // type name must match ??\n    SMILE_ERR(3,\"type mismatch during update missingFrom\");\n    return 0;\n  }\n  return 1;\n}\n\n/* returns the number of values that were  taken (updated) from _default */\n// TODO: handle array types...\nint ConfigInstance::missingFrom(ConfigInstance *_default)\n{\n  int i,nup=0;\n  if (!sanityCheck(_default)) return 0;\n  for (i=0; i<N; i++) {\n    nup += field[i]->missingFrom(_default->getValue(i));\n      //  (field[i]->getType() == CFTP_OBJ)||(field[i]->getType() >= CFTP_ARR)   then hierarchically update...\n    //if ((!(field[i]->isSet()))||(field[i]->getType() == CFTP_OBJ)||(field[i]->getType() >= CFTP_ARR)) { // value not set, use _default...\n    //  field[i]->copyFrom(_default->getValue(i));\n    //  nup++;\n    //}\n  }\n  return nup;\n}\n\n/* returns number of values overwritten (=number of set values in _new) */\nint ConfigInstance::updateWith(ConfigInstance *_new)\n{\n  int i,nov=0;\n  if (!sanityCheck(_new)) return 0;\n  for (i=0; i<N; i++) {\n    field[i]->updateWith(_new->getValue(i));\n   // if (!(_new->field[i]->isSet())) { // value not set, use _default...\n   //   field[i]->copyFrom(_new->getValue(i));\n   //   nov++;\n   // }\n  }\n  return nov;\n}\n\n\n/*\n   find field (value) in instance by field name (hierarchical)\n   return 1 on success, 0 on error\n   \n   optional: set *in to address of ConfigInstance containig the found value/field\n                 and *n to index of field in that instance.\n                 (only valid, if not NULL is returned)\n*/\nint ConfigInstance::findField(const char *_name, int *n, ConfigInstance **in, int *aIdx, char **aStr)\n{\n  try {\n  if (_name != NULL) {\n    int h, idx;\n    char *base=NULL;\n    ConfigInstance *cur=this;\n    const char*origname = _name;\n    int arrIdx = -1;\n    char *arrStr = NULL;\n    \n    do {\n      if (cur==NULL) {\n        CONF_MANAGER_ERR(\"ConfigInstance::findField: cannot dereference NULL subobject pointer while finding value for '%s' (rem:'%s')\",origname,_name);\n      }\n      // split name\n      const char *rem;\n      h = instNameSplit(_name, &base, &rem);\n      arrIdx = -1;\n      if (arrStr != NULL) { free(arrStr); arrStr = NULL; }\n      idx = cur->type->findField(base,&arrIdx,&arrStr);\n      if (base!=NULL) { free(base); base=NULL; }\n      _name=rem;\n\n      if (h==1) {\n        if ((idx >= 0)&&(idx < N)) { // check for valid index\n          if ((cur->field[idx]->getType() == CFTP_OBJ)||(cur->field[idx]->getType() == CFTP_OBJ_ARR)) {\n            // TODO... check if field is initialized ???!!!!!\n            if (field[idx] == NULL) CONF_MANAGER_ERR(\"ConfigInstance::findField: attempting to access object field '%s', which has not been initialized (full name: '%s')!\",base,origname);\n            cur = cur->field[idx]->getObj(arrIdx);\n          }\n          else\n            CONF_MANAGER_ERR(\"ConfigInstance::findField: subtype object referenced in '%s', however field %i is not of type OBJ or OBJ_ARR!\",_name,idx);\n        } else {\n          // error field \"base\" not found...\n          CONF_MANAGER_ERR(\"ConfigInstance::findField: referenced base field with name '%s' not found!\",origname);\n        }\n      }\n    } while (h==1);\n\n    if (h==0) {\n      if ((idx >= 0)&&(idx < N)) { // check for valid index\n        if (n!=NULL) *n = idx;\n        if (in!=NULL) *in = cur;\n        if (aIdx!=NULL) *aIdx = arrIdx;\n        if (aStr!=NULL) *aStr = arrStr;\n        return 1;\n      } else\n        if (arrStr != NULL) free(arrStr);\n        // error field \"base\" not found...\n        CONF_MANAGER_ERR(\"ConfigInstance::findField: referenced base field with name '%s' not found!\",origname);\n    }\n    if (arrStr != NULL) free(arrStr);\n  }\n  } catch (ConfigException *) {}\n  return 0;\n}\n\nint ConfigInstance::getType(const char *_name)\n{ /* recursively dereference, via findField */\n  int n,aIdx;\n  ConfigInstance *child=NULL;\n  int r = findField(_name, &n, &child, &aIdx, NULL);\n  if ((r)&&(child!=NULL)) {\n    return child->getType(n);\n  } else { return r; }\n}\n\n/* this function does not check n for valid range!!*/\n/* the memory pointed to by val is freed, if the content is copied over exisiting content,\n   otherwise the memory is not freed and the pointer is copied. the memory pointed to by\n   val may NEVER be freed by the calling code, however it must be allocated by the calling code */\nvoid ConfigInstance::setVal(int n, ConfigValue *val, int idx)\n{\n  if (val == NULL) return;\n  if (field[n] == NULL) {\n    int ty = type->getType(n);\n    if (ty != val->getType()) CONF_MANAGER_ERR(\"ConfigInstance::setVal: Type mistmatch *val : %i != getType(%i) : %i\",val->getType(),ty);\n    if ((ty >= CFTP_ARR)&&(idx>=0)) {\n      // a) array -> create array value for type\n      switch(ty) {\n        case CFTP_NUM_ARR: field[n] = new ConfigValueNumArr(idx+1); break;\n        case CFTP_STR_ARR: field[n] = new ConfigValueStrArr(idx+1); break;\n        case CFTP_CHR_ARR: field[n] = new ConfigValueChrArr(idx+1); break;\n        case CFTP_OBJ_ARR: field[n] = new ConfigValueObjArr(idx+1); break;\n        default: CONF_MANAGER_ERR(\"unknonwn array type %i for field idx=%i encountered in ConfigInstance::setVal!\",ty,n);\n      }\n      if (field[n] == NULL) OUT_OF_MEMORY;\n      field[n]->setValue(val,idx); // this is bogus , TODO: copyFrom for array element!\n    } else {\n      // b) non-array, or full array passed as *val parameter (when idx==-1): copy val\n      field[n] = val;\n    }\n  } else { // copy values\n    if ((idx >= 0)&&(field[n]->getType() >= CFTP_ARR)) {\n      // a) array -> use copyFrom with array index...\n      ConfigValue *tmp = (*(ConfigValueArr*)(field[n]))[idx];\n      if ( tmp != NULL) {\n        tmp->copyFrom(val);     delete val;\n      } else\n        field[n]->setValue(val,idx);\n    } else {\n      // b) non-array:\n      field[n]->copyFrom(val);  // check type??\n      delete val;\n    }\n  }\n}\n\nconst ConfigValue * ConfigInstance::getVal(int n, int idx) const {\n  if ((idx >= 0)&&(field[n]->getType() >= CFTP_ARR)) {\n    // a) array -> get element [idx]\n    return (*(ConfigValueArr*)(field[n]))[idx];\n  } else {\n    // b) non-array or full array element:\n    return field[n];  \n  }\n}\n\n/* recursively dereference subobj pointers */\n/* does not copy *val, it stores the pointer directly in the configInstance object */\nvoid ConfigInstance::setValue(ConfigValue *val, int n, const char *_name, int arrIdx)\n{\n  if (n >= 0) {  // prefer N\n    if (n<N) {\n      setVal(n,val,arrIdx);\n    }\n  } else if (_name != NULL) {\n    SMILE_DBG(7,\"called ConfigInstance::setValue (_name = '%s')\",_name);\n    // split name\n    const char *rem=NULL;\n    char *base=NULL;\n    int h = instNameSplit(_name, &base, &rem);\n    arrIdx=-1;\n    char *arrStr=NULL;\n    int idx = type->findField(base,&arrIdx,&arrStr);\n    SMILE_DBG(7,\"findField returned idx=%i and arrIdx=%i  arrStr='%s' (h=%i)\",idx,arrIdx,arrStr,h);\n    if (h==1) {\n      if ((idx >= 0)&&(idx < N)) { // check for valid index\n        if (field[idx] == NULL) CONF_MANAGER_ERR(\"ConfigInstance::getValue: attempting to access object field '%s', which has not been initialized!\",base);\n        if ((field[idx]->getType() == CFTP_OBJ)||(field[idx]->getType() == CFTP_OBJ_ARR)) {\n          // TODO: if field[idx] not allocated... create a new Instance...!\n          if (field[idx] == NULL) { // ... should never happen....\n             SMILE_DBG(7,\"ConfigInstance::setValue : creating new field (base = '%s') ... STRANGE!?\",base);\n             field[idx] = new ConfigValueObj(new ConfigInstance(base, type->getTypeObj(idx) ));\n          }\n          if (arrStr != NULL) {\n            arrIdx = field[idx]->findFieldWr(arrStr);\n            free(arrStr);\n          }\n          SMILE_DBG(7,\"ConfigInstance::setValue : arrIdx = %i, isset = %i\",arrIdx, field[idx]->isSet(arrIdx));\n          \n          if (!(field[idx]->isSet(arrIdx))) {\n            SMILE_DBG(7,\"ConfigInstance::setValue : creating new array element (base = '%s') ai:%i\",base,arrIdx);\n            field[idx]->setValue(new ConfigInstance(base, type->getTypeObj(idx) ),arrIdx);\n          }\n          ConfigInstance *cur = field[idx]->getObj(arrIdx);\n          if (cur!=NULL) cur->setValue(val,-1,rem);\n          else\n            CONF_MANAGER_ERR(\"setValue: cannot dereference NULL subobject pointer while setting value for '%s' (rem:'%s')\",_name,rem);\n        }\n        else\n          CONF_MANAGER_ERR(\"subtype object referenced in '%s', however field %i is not of type OBJ or OBJ_ARR!\",_name,idx);\n      } else CONF_MANAGER_ERR(\"setValue: hierarchical field referenced ('%s') does not exist! \",rem);\n    } else {\n      if (arrStr != NULL) {\n        arrIdx = field[idx]->findFieldWr(arrStr);\n        free(arrStr);\n      }\n      setValue(val,idx,NULL,arrIdx);\n    }\n    if (base!=NULL) { free(base); base=NULL; }\n  }\n}\n\nconst ConfigValue * ConfigInstance::getValue(int n, const char *_name, int arrIdx) const\n{\n  if (n >= 0) {  // prefer N\n    if (n<N) {\n      return getVal(n,arrIdx);\n    }\n  } else if (_name != NULL) {\n    // split name\n    SMILE_DBG(7,\"called ConfigInstance::getValue (_name = '%s')\",_name);\n    const char *rem;\n    char *base=NULL;\n    int h = instNameSplit(_name, &base, &rem);\n    arrIdx = -1;\n    char *arrStr = NULL;\n    int idx = type->findField(base,&arrIdx,&arrStr);\n    SMILE_DBG(7,\"findField returned idx=%i and arrIdx=%i arrStr='%s' (h=%i)\",idx,arrIdx,arrStr,h);\n    if (base!=NULL) { free(base); base=NULL; }\n    if (h==1) {\n      if ((idx >= 0)&&(idx < N)) { // check for valid index\n        if (field[idx] == NULL) CONF_MANAGER_ERR(\"ConfigInstance::getValue: attempting to access object field '%s', which has not been initialized!\",base);\n        if ((field[idx]->getType() == CFTP_OBJ)||(field[idx]->getType() == CFTP_OBJ_ARR)) {\n          // TODO:: check if field[idx] is initialized!!\n          if (arrStr != NULL) {\n            arrIdx = field[idx]->findField(arrStr);\n            free(arrStr);\n          }\n          ConfigInstance *cur = field[idx]->getObj(arrIdx);\n          if (cur!=NULL) return cur->getValue(-1,rem);\n          else\n            CONF_MANAGER_ERR(\"getValue: cannot dereference NULL subobject pointer while getting value for'%s' (rem:'%s')\",name,rem);\n        } else CONF_MANAGER_ERR(\"getValue: hierarchical field referenced is not of type object! ('%s')\",rem);\n      } else CONF_MANAGER_ERR(\"getValue: hierarchical field referenced ('%s') does not exist! \",rem);\n    } else {\n      if (idx < 0) SMILE_WRN(2,\"ConfigInstance::getValue : non-existant field '%s' (%i)\",_name,n);\n      if (arrStr != NULL) {\n        arrIdx = field[idx]->findField(arrStr);\n        free(arrStr);\n      }\n      return getValue(idx,NULL,arrIdx);\n    }\n  }\n  SMILE_WRN(2,\"ConfigInstance::getValue : index %i out of bounds (0-%i)\",n,N-1);\n  return NULL;\n}\n\n\n\n/*******************************************************************************/\n/* generic backend reader interface, virtual class only, descendant must implement:\n     findInstancesByName\n     getInstance\n     openInput\n            */\n\ncConfigReader::cConfigReader(const char *myInputPath, int myInputId, cCommandlineParser *myCmdparser) :\n  inputPath(NULL),\n  lastLevelFile(NULL),\n  inputId(myInputId),\n  cmdparser(myCmdparser)\n{\n  SMILE_DBG(4, \"creating a new cConfigReader component\");\n  if (myInputPath != NULL) \n    inputPath = strdup(myInputPath);\n  // derived class must call openInput()!?\n}\n\nvoid cConfigReader::destroyStrArray(char **arr, int n)\n{\n  int i;\n  if (arr != NULL) {\n    for (i=0; i<n; i++) {\n      if (arr[n] != NULL) free(arr[n]);\n    }\n    free(arr);\n  }\n}\n\nchar ** cConfigReader::findInstances(const ConfigType *_type, int *N)\n{\n  if (_type != NULL) {\n    return findInstancesByTypeName(_type->getName(),N);\n  }\n  return NULL;\n}\n\ncConfigReader::~cConfigReader()\n{\n  //closeInput();  must be called by derived class... ?\n  if (inputPath != NULL) \n    free(inputPath);\n  if (lastLevelFile != NULL) \n    free(lastLevelFile);\n}\n\n/*******************************************************************************/\n/* commandline config reader */\n#if 0\nclass cCommandlineConfigReader : public cConfigReader {\n  protected:\n    char **argv;\n    int argc;\n\n  public:\n    cCommandlineConfigReader(const char **_argv, int _argc);\n    virtual int openInput() {} // nothing to open here...\n    virtual int closeInput() {}\n\n    virtual char ** findInstancesByTypeName(const char *_typename, int *N);  /* returns names (and no.) of instances of type \"typename\" */\n    virtual ConfigInstance *getInstance(const char *_instname, const ConfigType *_type);    /* get an instance with name _instname */\n    virtual ~cConfigReader() {}\n};\n\ncCommandlineConfigReader::cCommandlineConfigReader(const char **_argv, int _argc)\n{\n\n}\n#endif\n\n/*******************************************************************************/\n/* ini-style file config reader */\n\n/* file format:\n\n[InstanceName:TypeName]\nInstanceName.Field1.subfield=value\nInstanceName.Field1.myarray[0]=value\nInstanceName.Field1.myarray[1]=value\nInstanceName.NextField = value\n[NextInstanceName:TypeName]\n\n*/\n\nint cFileConfigReader::addInst(const char*_instname, const char*_typename)\n{\n  // search for existing instances, warn but add to it...\n  int i;\n  for (i=0; i<nInst; i++) {\n    if ( (inst[i].name != NULL) && (_instname != NULL) && (!strcmp(inst[i].name,_instname)) ) {\n      // instance with same name found\n      if ((inst[i].type != NULL)&&(_typename != NULL)) {\n        if (!strcmp(inst[i].type,_typename)) { // type also matches\n          SMILE_WRN(4, \"cFileConfigReader::addInst:  duplicate instance '%s' in config file (type='%s'), these instances will be merged to one.\", _instname, _typename);\n          return i; // append to this type...\n        } else { // type mismatch: ERR!\n\t  CONF_MANAGER_ERR(\"duplicate instance '%s' in config file has conflicting types '%s'<->'%s' (duplicate instances must be of the same type, the content will be appended)\\n\",_instname,inst[i].type,_typename);\n        }\n      } else {\n        if (_typename != inst[i].type) { \n          CONF_MANAGER_ERR(\"duplicate instance '%s' in config file has conflicting types '%s'<->'%s' (duplicate instances must be of the same type, the content will be appended)\\n\",_instname,inst[i].type,_typename);\n        }\n      }\n    }\n  }\n\n  if (nInst >= nInstAlloc) { // realloc\n    fileInstance *f = (fileInstance *)realloc( inst, sizeof(fileInstance) * (nInst+10));\n    if (f == NULL) OUT_OF_MEMORY;\n    inst = f;\n    nInstAlloc = nInst+10;\n  }\n  inst[nInst].name = strdup(_instname);\n  inst[nInst].type = strdup(_typename);\n  SMILE_DBG(6,\"cFileConfigReader , added instance: '[%s:%s]'\",inst[nInst].name,inst[nInst].type);\n  inst[nInst].N=0;\n  inst[nInst].Nalloc=0;\n  inst[nInst].lines = NULL;\n  inst[nInst].lineNr = NULL;\n  return nInst++;\n}\n\nint cFileConfigReader::addLine(int n, const char *line, int lineNr)\n{\n  if ((n<0)||(n>=nInst)) return -1;\n  if (inst[n].N >= inst[n].Nalloc) { // realloc\n    char **l = (char **)realloc(inst[n].lines, sizeof(char*) * (inst[n].N+100) );\n    if (l==NULL) OUT_OF_MEMORY;\n    inst[n].lines = l;\n    inst[n].Nalloc = inst[n].N+100;\n    int *ln = (int *)realloc(inst[n].lineNr, sizeof(int) * (inst[n].N+100) );\n    if (ln==NULL) OUT_OF_MEMORY;\n    inst[n].lineNr = ln;\n  }\n  inst[n].lines[inst[n].N] = strdup(line);\n  inst[n].lineNr[inst[n].N] = lineNr;\n  return inst[n].N++;\n}\n\n// TODO: cache config files which have already been loaded once (including all includes?)\n/* each instance has a header: [instname:type] followed by the lines with values */\n/* including other config files can be done via the command:  \\{path/and/file_to.include} */\nint cFileConfigReader::openInput(const char*fname, int *idx0)\n{\n  FILE *in=NULL;\n  char *localThisLevelFile = NULL;\n  // open file \"_inputpath\"\n  if (fname == NULL) {\n    SMILE_MSG(3, \"reading config file '%s'\", inputPath);\n    in = fopen(inputPath, \"r\");\n    if (in == NULL) \n      CONF_MANAGER_ERR(\"cFileConfigReader::openInput : cannot open input file '%s'!\",inputPath);\n    if (lastLevelFile != NULL)\n      free(lastLevelFile);\n    lastLevelFile = NULL;\n  } else {\n    SMILE_MSG(3,\"reading config file '%s'\",fname);\n    if (!strcmp(fname,inputPath)) CONF_MANAGER_ERR(\"loop in config file includes detected (the base file '%s' was included in itself)!\",inputPath);\n    // try absolute path first...\n    in = fopen( fname, \"r\" );\n    if (in == NULL) {\n      // try relative to inputPath next\n      char * fname2 = strdup(inputPath);\n      char * pt = strrchr(fname2,'/');\n      if (pt == NULL) pt = strrchr(fname2,'\\\\');\n      if ((pt != NULL)&&(pt != fname)) {\n        *pt = 0;\n      } \n      char * fname3 = myvprint(\"%s/%s\",fname2,fname);\n      if (fname3 != NULL) {\n        SMILE_MSG(3,\"config file '%s' not found, trying to open '%s'.\",fname,fname3);\n        in = fopen(fname3, \"r\");\n        if (in == NULL) {\n          // try relative to path of previously included file (if not same as inputPath)\n          if (lastLevelFile != NULL && lastLevelFile != inputPath) {\n            char * fname2b = strdup(lastLevelFile);\n            char * ptb = strrchr(fname2b,'/');\n            if (ptb == NULL) ptb = strrchr(fname2b,'\\\\');\n            if ((ptb != NULL)&&(ptb != fname)) {\n              *ptb = 0;\n            } \n            char * fname3b = myvprint(\"%s/%s\", fname2b, fname);\n            if (fname3b != NULL) {\n              SMILE_MSG(3,\"config file '%s' not found, trying to open '%s'.\",fname3,fname3b);\n              in = fopen(fname3b, \"r\");\n              if (in == NULL) {\n                CONF_MANAGER_ERR(\"cFileConfigReader::openInput : cannot open input file '%s'. Fatal!\", fname3b);\n              } else {\n                if (lastLevelFile != NULL)\n                  free(lastLevelFile);\n                lastLevelFile = strdup(fname3b);\n              }\n              free(fname3b);\n            } else {\n              CONF_MANAGER_ERR(\"cFileConfigReader::openInput : cannot open input file '%s'. Fatal!\", fname3);\n            }\n            free(fname2b);\n          } else {\n            CONF_MANAGER_ERR(\"cFileConfigReader::openInput : cannot open input file '%s'. Fatal!\", fname3);\n          }\n        } else {\n          if (lastLevelFile != NULL)\n            free(lastLevelFile);\n          lastLevelFile = strdup(fname3);\n        }\n        free(fname3);\n      } else {\n        CONF_MANAGER_ERR(\"cFileConfigReader::openInput : cannot open input file '%s'. Fatal!\",fname);\n      }\n      free(fname2);\n    } else {\n      if (lastLevelFile != NULL)\n        free(lastLevelFile);\n      lastLevelFile = strdup(fname);\n    }\n  }\n  \n  if (lastLevelFile != NULL) {\n    localThisLevelFile = strdup(lastLevelFile);\n  }\n\n  // read file, 1st pass to find Types & Names\n  char *line=NULL;\n  int nline=-1;\n  int idx = -1;\n  if (idx0!=NULL) idx=*idx0;\n  int lineNr = 0;\n  size_t n,read;\n  int inComment = 0;\n\n  do {\n    read = smile_getline(&line, &n, in);\n    char *origline = line;\n    \n    if ((read != (size_t)-1)&&(origline!=NULL)) { ///XXXX\n      lineNr++;\n      // remove newline at end:\n      int len = (int)strlen(line)-1;\n      if (len>=0) { if (line[len] == '\\n') { line[len] = 0; len--; } }\n      if (len>=0) { if (line[len] == '\\r') { line[len] = 0; len--; } }\n      while (((line[0] == ' ')||(line[0] == '\\t'))&&(len>=0)) { line[0] = 0; line++; len--; }\n\n      if (len >= 0) {\n\n    // NEW: multi-line comments , c-style: /* */\n    if ( ((len>0)&&(line[0]=='/')&&(line[1]=='*')) )\n      {  inComment = 1; } \n\n    if (inComment) {\n      if ( ((len>0)&&( ((line[0]=='*')&&(line[1]=='/'))||((line[len]=='/')&&(line[len-1]=='*')) ) ) )\n        {  inComment = 0; } \n      if (origline != NULL) { free(origline); line = NULL; }\n      continue; // skip commented-out lines\n    }\n\n\n      SMILE_DBG(8,\"read line: '%s' read=%i, len=%i\",line,read,len);\n      if (line[0]=='[') { // check for instance header\n        char *ty = strchr(line,':');\n        if (ty==NULL) { CONF_PARSER_ERR(\"(line %i) error parsing '%s':\\n %s missing ':' separating instance name and type!\",lineNr,inputPath,line); }\n        ty[0] = 0; ty++;\n        char *tmp = strchr(ty,':');\n        if (tmp!=NULL) { CONF_PARSER_ERR(\"(line %i) error parsing '%s':\\n ':' cannot appear in config type name!\",lineNr,inputPath,line); }\n        tmp = strchr(ty,']');\n        if (tmp==NULL) { CONF_PARSER_ERR(\"(line %i) error parsing '%s':\\n %s missing ']' after instance type!\",lineNr,inputPath,line); }\n        tmp[0] = 0;\n        char *ins = line+1;\n        idx = addInst(ins,ty);\n        //free(line); line = NULL;\n      } else if ((len>4)&&(line[0] == '\\\\')&&(line[1] == '{')&&(line[len]=='}')) { // include config file\n        line[len]=0;\n        const char*fn = line+2;\n/*TODO: support \\cm here until a unified interface in openInput has been designed.*/\n        if (fn[0] == '\\\\' && fn[1] == 'c' && fn[2] == 'm' && fn[3] == '[' && len > 8) {  //....\n          char *value = strdup(fn);\n          if (cmdparser != NULL && value != NULL) {\n            char *_long = value+4;\n            char *_short = strchr(value,'(');\n            char *_dflt = strchr(value,'{');\n            char *_descr = strchr(value,':');\n            if (_short!=NULL) {\n              *_short = 0;\n              _short++;\n              char *_tmp = strchr(_short,')');\n              if (_tmp == NULL) { CONF_MANAGER_ERR(\"line %i : missing ) in commandline reference '%s'\",lineNr,value); }\n              else *_tmp = 0;\n              if (strlen(_short) > 1) { CONF_MANAGER_ERR(\"line %i : short option () in commandline reference '%s' is longer than one character!\",lineNr,value); }\n            }\n            if (_dflt!=NULL) {\n              *_dflt = 0;\n              _dflt++;\n              char *_tmp = strchr(_dflt,'}');\n              if (_tmp == NULL) { CONF_MANAGER_ERR(\"line %i : missing } in commandline reference '%s'\",lineNr,value); }\n              else *_tmp = 0;\n              if (strlen(_dflt) < 0) { CONF_MANAGER_ERR(\"line %i : dflt value {} in commandline reference '%s' is too short!\",lineNr,value); }\n            }\n            if (_descr!=NULL) {\n              *_descr = 0;\n              _descr++;\n              char *_tmp = strchr(_descr,']');\n              if (_tmp == NULL) { CONF_MANAGER_ERR(\"line %i : missing ] at end of commandline reference '%s'\",lineNr,value); }\n              else *_tmp = 0;\n              if (strlen(_descr) < 0) { CONF_MANAGER_ERR(\"line %i : description :..] in commandline reference '%s' is too short!\",lineNr,value); }\n            }\n            char *_tmp = strchr(_long,']');\n            if (_tmp != NULL) { *_tmp = 0; }\n            char __s=0;\n            if (_short!=NULL) __s = *_short;\n            \n            if ( (_dflt==NULL)&&(_descr==NULL) ) { // old option\n              // do nothing...\n            } else { // new option\n              if (!cmdparser->optionExists(_long)) {  // option does not yet exist\n                cmdparser->addStr(_long, __s, _descr, _dflt);\n                // Re-parsing must be enabled here, even if it's inefficient. Otherwise we are not able to read the newly created commandline options into the config.\n                cmdparser->doParse(1);  // ignore duplicates...\n              }\n            }\n            \n            const char *_tmps = cmdparser->getStr(_long);\n            char * tmpstr = NULL;\n            if (_tmps == NULL) {\n              SMILE_ERR(1,\"configManager: commandline option '%s' has NULL as default value, please check the \\\\cm options in the config file (at least one for each option has to have a default value or description given!)\",_long);\n              tmpstr = strdup(\"\");\n            } else {\n              tmpstr = strdup(_tmps);\n            }\n            free(value);\n            value = tmpstr;\n          } else {\n            CONF_MANAGER_ERR(\"commandline reference specified in line %i, however no commandline parser is present!\",lineNr);\n          }\n          if (value != NULL) {\n            openInput(value,&idx);\n            free(value);\n            // restore last level file:\n            if (lastLevelFile != NULL) {\n              free(lastLevelFile);\n              lastLevelFile = NULL;\n            }\n            if (localThisLevelFile != NULL) {\n              lastLevelFile = strdup(localThisLevelFile);\n            }\n          }\n        } else {\n          openInput(fn,&idx);\n          // restore last level file:\n          if (lastLevelFile != NULL) {\n            free(lastLevelFile);\n            lastLevelFile = NULL;\n          }\n          if (localThisLevelFile != NULL) {\n            lastLevelFile = strdup(localThisLevelFile);\n          }\n        }\n      } else {\n        addLine(idx,line,lineNr);\n      }\n      }\n    }\n    if (origline != NULL) { \n      free(origline); \n      line = NULL; \n    }\n  } while (read != (size_t)(-1));\n  fclose(in);\n  if (line != NULL) { \n    free(line); \n    line = NULL; \n  }\n  if (fname == NULL) {\n    SMILE_MSG(3,\"successfully read config file '%s'\", inputPath);\n  } else {\n    SMILE_MSG(3,\"successfully read config file '%s'\", localThisLevelFile);\n  }\n  if (localThisLevelFile != NULL)\n    free(localThisLevelFile);\n  if (idx0 != NULL)\n    *idx0 = idx;\n  return 1;\n}\n\n\ncFileConfigReader::~cFileConfigReader()\n{\n  int i;\n  if (inst != NULL) {\n    for (i=0; i<nInst; i++) {\n      if (inst[i].name != NULL) free(inst[i].name);\n      if (inst[i].type != NULL) free(inst[i].type);\n      if (inst[i].lineNr != NULL) free(inst[i].lineNr);\n      if (inst[i].lines != NULL) {\n        int j;\n        for (j=0; j<inst[i].N; j++) {\n          if (inst[i].lines[j] != NULL) free(inst[i].lines[j]);\n        }\n        free(inst[i].lines);\n      }\n    }\n    free(inst);\n  }\n}\n\nchar ** cFileConfigReader::findInstancesByTypeName(const char *_typename, int *N)  /* returns names (and no.) of instances of type \"typename\" */\n{\n  int i;\n  char **insts=NULL;\n  int n=0;\n  if (_typename == NULL) return NULL;\n  if (N == NULL) return NULL;\n\n  SMILE_DBG(7,\"cFileConfigReader::findInstancesByTypeName: typename=%s\",_typename);\n  for (i=0; i<nInst; i++) {\n    if (!strcmp(inst[i].type,_typename)) n++;\n  }\n  *N = n;\n  insts = (char **) calloc(1,sizeof(char*)*n);\n  n=0;\n  for (i=0; i<nInst; i++) {\n    if (!strcmp(inst[i].type,_typename)) {\n      insts[n++] = strdup(inst[i].name);\n      SMILE_DBG(7,\"found inst : '%s'\",inst[i].name);\n    }\n  }\n  return insts;\n}\n\n/*\nformat of a config line:\n name.name[nr].name.name{str}.name = val;val;val\n\n comments: line begins with ; or # or //\n name may not contain: [ ] . : = ; , \\\n\n val can be either numeric, string, or config instance reference:  0.00   blah   \\in[instname]\n   or commandline option reference: \\cm[long(short){dflt}:description]   (to add a new option)\n      or cmdline reference : \\cm[long]     (to reference an existing option)\n   or value of another field      : $fieldname\n val may not contain ; or $ or \\ as first character\n TODO later: add \\; and \\$ and \\\\ for quoting\n \n TODO??? array by  ;  ..!\n\n*/\n/* parse lines of an instance...*/\nConfigInstance *cFileConfigReader::getInstance(const char *_instname, const ConfigType *_type, cConfigManager *cman)    /* get an instance with name _instname */\n{\n  ConfigInstance *ret = new ConfigInstance( _instname, _type, 0 );\n  if (ret == NULL) OUT_OF_MEMORY;\n  \n  int i,idx;\n  // find instance index\n  SMILE_DBG(7,\"cFileConfigReader::getInstance: instname=%s\",_instname);\n  for (idx=0; idx<nInst; idx++) {\n    if (!strcmp(inst[idx].name,_instname)) break;\n  }\n  SMILE_DBG(7,\"cFileConfigReader::getInstance: instname=%s -> idx=%i\",_instname,idx);\n  if (idx >= nInst) CONF_PARSER_ERR(\"cFileConfigReader::getInstance: requested instance name '%s' not found in config file!\",_instname);\n  //now go through instance and parse lines\n  for (i=0; i<inst[idx].N; i++) {\n    char *line = strdup(inst[idx].lines[i]);\n    int lineNr = inst[idx].lineNr[i];\n    char *origline = line;  // we use this later in the call to free();\n    if (line==NULL) OUT_OF_MEMORY;\n    SMILE_DBG(7,\"cFileConfigReader::getInstance: parsing line no. %i\\n     %s\",lineNr,line);\n\n    // remove CR(+LF) at end\n    int l = (int)strlen(line)-1;\n    if (line[l] == '\\n') { line[l] = 0; l--; }\n    if (line[l] == '\\r') { line[l] = 0; l--; }\n    \n    //remove spaces and tabs at end and beginning\n    while (((line[l] == ' ')||(line[l] == '\\t'))&&(l>=0)) { line[l] = 0; l--; }\n    while (((line[0] == ' ')||(line[0] == '\\t'))&&(l>=0)) { line[0] = 0; line++; l--; }\n\n    if (l<0) { if (origline != NULL) free(origline); continue; } // skip empty lines\n    \n    // check for comments:\n    if ((line[0] == '%')||(line[0] == '#')||(line[0]==';')||((l>0)&&(line[0]=='/')&&(line[1]=='/')))\n      { if (origline != NULL) free(origline); continue; } // skip commented-out lines\n    \n    // NEW: EOL comments!!  ONLY with '//'\n    if (l>1) {\n      char *cc = strstr(line,\"//\");\n      if (cc != NULL) {\n        *cc = 0; // remove commented out rest of this line...\n      }\n    }\n\n      // TODO: search for \\in[]  -> link to instance\n      // return NULL and name of instance to link to\n\n    // split at FIRST =\n    char *field=line;\n    char *value;\n    value=strchr(line,'=');\n    if ( value == NULL ) CONF_PARSER_ERR(\"(line %i) cFileConfigReader::getInstance: missing '=' in line %i '%s' of instance '%s'\",lineNr,i,line,inst[idx].name);\n    value[0]=0;\n    value++;\n\n    int arrT=0,arrN=-1; char *arrS=NULL;\n\n    // remove basename (instance name)\n    field = strchr(line,'.');\n    if (field == NULL) field = line;//CONF_PARSER_ERR(\"cFileConfigReader::getInstance: missing field name in line '%s'\",line);\n    else {\n      field[0] = 0; \n      // check if first part of line really was _instname..\n      if (strcmp(line,_instname)) {\n        field[0] = '.';\n        field = line;\n      } else { field++; }\n    }\n\n    l=(int)strlen(field)-1;\n    // remove whitespaces at end of fieldname\n    while (((field[l] == ' ')||(field[l] == '\\t'))&&(l>0)) { field[l] = 0; l--; }\n\n    // get field basename:\n/*\n    char *fieldbn = NULL;\n    char *nex = strchr(field,'.');\n    if (nex != NULL) {\n      nex[0] = 0;\n      fieldbn = strdup(field);\n      nex[0] = '.';\n    } else {\n      fieldbn = strdup(field);\n    }\n*/\n\n    // check for array basename AND array type of field\n    if (l>=0) {\n      SMILE_DBG(8,\"       field=%s\",field);\n//printf(\"       field=%s\\n\",field); fflush(stdout);\n      if (field[l] == ']') { // numeric or associative array\n        field[l] = 0;\n        char * v = strrchr(field,'[');\n        if (v == NULL) CONF_PARSER_ERR(\"(line %i) cFileConfigReader::getInstance: execess ] found at end of field name!\",lineNr);\n        v++;\n        // associative array [] support : DONE\n        \n//        int val=0;\n        char *eptr=NULL;\n        long rn = strtol(v,&eptr,0);\n        if (strlen(v) <= 0) CONF_PARSER_ERR(\"(line %i) cFileConfigReader::getInstance: nothing specified in [] as array index!\",lineNr);\n        if ((eptr!=NULL)&&(eptr[0]!=0)) { // invalid characters -> no number!\n          arrT=2; arrS = strdup(v);\n        } else {\n//        int rn = sscanf(v,\"%i\",&val);\n//        if (rn!=1) CONF_PARSER_ERR(\"(line %i) cFileConfigReader::getInstance: no number specified in [] as array index!\");\n          arrT=1; //arrN = val;\n          arrN=rn;  // XXXX\n        }\n        field[l] = ']';\n      }\n/*\n      else if (field[l] == '}') { // associative string array\n        field[l] = 0;\n        char * v = strrchr(field,'{');\n        if (v == NULL) CONF_PARSER_ERR(\"(line %i) cFileConfigReader::getInstance: execess } found at end of field name!\");\n        v++;\n        int val;\n        int rn = strlen(v);\n        if (v<=0) CONF_PARSER_ERR(\"(line %i) cFileConfigReader::getInstance: no name specified in {} as array index!\");\n        arrT=2; arrS = strdup(v);\n        field[l] = '}';\n      }\n*/\n    } else {\n      CONF_PARSER_ERR(\"(line %i) cFileConfigReader::getInstance: invalid field name '%s'\",lineNr,field);\n    }\n\n    // check for presence of unquoted ;  => initialize array values of numeric index array, if array type matches )\n    char *a = strchr(value,';');\n    if ((a>value)&&(*(a-1)!='\\\\')&&(a != NULL)) { // this should enable quoting of ; via \\ ... ???\n      arrT=10;arrN=-1;\n//printf(\"arrT10\\n\"); fflush(stdout);\n    }\n\n    if (arrS != NULL) free(arrS);\n    \n//    if (arrT==10) {\n      // TODO: split values, convert each value, and save in array element\n//      SMILE_ERR(1,\"(line %i) arrT==10 not yet implemented! (array elements split by ';')\",lineNr);\n\n//    } else\n    {\n/*   optional: set *in to address of ConfigInstance containig the found value/field\n                 and *n to index of field in that instance.\n                 (only valid, if not NULL is returned)\n*/\n      int n,aIdx;\n      const ConfigType *tp=NULL;\n\n      int h = _type->findFieldH(field, &n, &tp, &aIdx, NULL);\n\n      int ty;\n      if (tp != NULL) {\n        ty = tp->getType(n);\n      } else {\n        // TODO: Error!!!\n        SMILE_ERR(4,\"type not found!\");\n        ty=-1;\n      }\n      SMILE_DBG(8,\"type = %i\",ty);\n      if (ty>=CFTP_ARR) {\n        if (arrT == 0) //CONF_PARSER_ERR(\"(line %i) expected array index for array type\",lineNr,line);\n          {\n            SMILE_WRN(5,\"(line %i) array type field with only one element and no array index in [], assuming arrT=10 and N=1\",lineNr);\n            arrT=10;\n          }\n        ty-=(CFTP_ARR+1);\n      }\n\n//--\n/*\nTODO: move this parsing to the openInput function allowing for more generic replacements..?\n*/\n\n    l = (int)strlen(value);\n    //remove spaces at end and beginning\n    while (((value[l] == ' ')||(value[l] == '\\t'))&&(l>0)) { value[l] = 0; l--; }\n    while (((value[0] == ' ')||(value[0] == '\\t'))&&(l>0)) { value[0] = 0; value++; l--; }\n    if (l==0) CONF_PARSER_ERR(\"(line %i) cFileConfigReader::getInstance: empty value in line %i '%s' of instance '%s'\",lineNr,i,line,inst[idx].name);\n    SMILE_DBG(8,\"       value=%s\",value);\n\n\n      // resolve commandline references RIGHT HERE:: :-)\n      char *tmpstr=NULL;\n        /* commandline option reference: \\cm[long(short){dflt}:description]  */\n      int vl=(int)strlen(value);\n      if (vl>=5) {\n        char *endOfOption = strchr(value, ']');\n        if ((value[0]=='\\\\')&&(value[1]=='c')&&(value[2]=='m')&&(value[3]=='[')&&(endOfOption > value + 5)) { // &&(value[vl-1]==']')) { // \\cm[*]\n          if (cmdparser != NULL) {\n            if (endOfOption == NULL) {\n              CONF_MANAGER_ERR(\"line %i: missing ']' in commandline option definition!\", lineNr);\n            }\n            char *_long = value+4;\n            char *_short = strchr(value,'(');\n            char *_dflt = strchr(value,'{');\n            char *_descr = strchr(value,':');\n            if (_short > endOfOption)\n              _short = NULL;\n            if (_dflt > endOfOption)\n              _dflt = NULL;\n            if (_descr > endOfOption)\n              _descr = NULL;\n            if (_short!=NULL) {\n              *_short = 0;\n              _short++;\n              char *_tmp = strchr(_short,')');\n              if (_tmp == NULL) { CONF_MANAGER_ERR(\"line %i : missing ) in commandline reference '%s'\",lineNr,value); }\n              else *_tmp = 0;\n              if (strlen(_short) > 1) { CONF_MANAGER_ERR(\"line %i : short option () in commandline reference '%s' is longer than one character!\",lineNr,value); }\n            }\n            if (_dflt!=NULL) {\n              *_dflt = 0;\n              _dflt++;\n              char *_tmp = strchr(_dflt,'}');\n              if (_tmp == NULL) { CONF_MANAGER_ERR(\"line %i : missing } in commandline reference '%s'\",lineNr,value); }\n              else *_tmp = 0;\n              if (strlen(_dflt) < 0) { CONF_MANAGER_ERR(\"line %i : dflt value {} in commandline reference '%s' is too short!\",lineNr,value); }\n            }\n            if (_descr!=NULL) {\n              *_descr = 0;\n              _descr++;\n              char *_tmp = strchr(_descr,']');\n              if (_tmp == NULL) { CONF_MANAGER_ERR(\"line %i : missing ] at end of commandline reference '%s'\",lineNr,value); }\n              else *_tmp = 0;\n              if (strlen(_descr) < 0) { CONF_MANAGER_ERR(\"line %i : description :..] in commandline reference '%s' is too short!\",lineNr,value); }\n            }\n            char *_tmp = strchr(_long,']');\n            if (_tmp != NULL) { *_tmp = 0; }\n            char __s=0;\n            if (_short!=NULL) __s = *_short;\n            char * trailing = endOfOption + 1;\n            if (endOfOption == NULL || *trailing == 0 || endOfOption > value + vl) {\n              trailing = NULL;\n            }\n            if ( (_dflt==NULL)&&(_descr==NULL) ) { // old option\n              // do nothing...\n            } else { // new option\n              if (!cmdparser->optionExists(_long)) {\n                if (ty==CFTP_NUM) {\n                  char *ep=NULL;\n                  if (_dflt == NULL) { CONF_MANAGER_ERR(\"line %i : to add a new commandline option you must specify a default value for it! To use an existing option, specify no default value AND no description text.\",lineNr); }\n                  else {\n                    double _dfltD = strtod(_dflt,&ep);\n                    if ((_dfltD==0.0)&&(ep==_dflt)) { CONF_MANAGER_ERR(\"line %i : invalid numerical default value for commandline reference '%s'\",lineNr,value); }\n                    cmdparser->addDouble( _long, __s, _descr, _dfltD );\n                  }\n                } else {\n                  cmdparser->addStr( _long, __s, _descr, _dflt );\n                }\n                // Re-parsing must be enabled here, even if it's inefficient. Otherwise we are not able to read the newly created commandline options into the config.\n                cmdparser->doParse(1);  // ignore duplicates...\n              } else {\n                SMILE_WRN(3, \"configManager: commandline option %s already defined (not adding new), consider removing default value and description from config file.\", _long);\n              }\n            }\n            \n            if (ty==CFTP_NUM) {\n              if (trailing != NULL) {\n                tmpstr = myvprint(\"%f%s\",cmdparser->getDouble(_long),trailing);\n              } else {\n                tmpstr = myvprint(\"%f\",cmdparser->getDouble(_long));\n              }\n            } else {\n              const char *_tmps = cmdparser->getStr(_long);\n              if (_tmps == NULL) {\n                SMILE_ERR(1,\"configManager: commandline option '%s' has NULL as default value, please check the \\\\cm options in the config file (at least one for each option has to have a default value or description given!)\",_long);\n                if (trailing != NULL) {\n                  tmpstr = strdup(trailing);\n                } else {\n                  tmpstr = strdup(\"\");\n                }\n              } else {\n                if (trailing != NULL) {\n                  tmpstr = myvprint(\"%s%s\", _tmps, trailing);\n                } else {\n                  tmpstr = strdup(_tmps);\n                }\n              }\n            }\n            value = tmpstr;\n          } else {\n            CONF_MANAGER_ERR(\"commandline reference specified in line %i, however no commandline parser is present!\",lineNr);\n          }\n        }\n      }\n//TOOD: look for memory leaks here....:!?  value / tmpstr... \n\n    // parse value (remove pre and post whitespaces)\n    l = (int)strlen(value);\n    //remove spaces at end and beginning\n    while (((value[l] == ' ')||(value[l] == '\\t'))&&(l>0)) { value[l] = 0; l--; }\n    while (((value[0] == ' ')||(value[0] == '\\t'))&&(l>0)) { value[0] = 0; value++; l--; }\n    if (l==0) CONF_PARSER_ERR(\"(line %i) cFileConfigReader::getInstance: empty value in line %i '%s' of instance '%s'\",lineNr,i,line,inst[idx].name);\n    SMILE_DBG(8,\"       value=%s\",value);\n\n\n\n      int nFields = 1;\n      char **valuefield = NULL;\n      if (arrT==10) {\n        // count number of unquoted ';' separators\n        int i;\n        //while (value[0] == ';') { value++; l--; }\n        //while (value[l] == ';') { value[l]=0; l--; }\n        for (i=1; i<=l; i++) { if ((value[i] == ';')&&(value[i-1] != '\\\\')&&(i!=l)) nFields++; if (value[i] == 0) break; }\n\n        // split into field array..\n        valuefield = (char**)calloc(1,sizeof(char*)*nFields);\n        i=0;\n        do {\n          if (i>=nFields) break;\n          a = strchr(value,';');\n          if (a!=NULL) *a=0;\n          valuefield[i]=value;\n          int lll = (int)strlen(valuefield[i]);\n          // remove spaces at beginning and end\n          while ( (lll>=0)&& ((valuefield[i][0]==' ')||(valuefield[i][0]=='\\t')) ) { valuefield[i]++; lll--; }\n          while ( (lll>=0)&& ((valuefield[i][lll-1]==' ')||(valuefield[i][lll-1]=='\\t')) ) { valuefield[i][lll-1]=0; lll--; }\n          if (lll<=0) valuefield[i]=NULL;\n          if (a!=NULL) {\n            value=a+1;\n          } \n          i++;\n        } while (a!=NULL);\n      }\n\n      int idx;\n      for( idx=0; idx < nFields; idx++)  {\n\n      if (arrT == 10) value = valuefield[idx] ; //...\n      \n\n      if (value == NULL) continue;\n\n//-----> was here.....\n\n      int mtmp=0;\n\n      vl = (int)strlen(value);\n      for (mtmp=1; mtmp<vl; mtmp++) {\n        if (value[mtmp-1]=='\\\\') {\n\n               if ( (value[mtmp]==';')||(value[mtmp]=='\\\\') ) {\n\n                  // remove value[a-1] and move all chars to left, vl--\n                  int aa;\n                  for (aa=mtmp-1; aa<vl; aa++) {\n                    value[aa] = value[aa+1];\n                  }\n                  value[vl--] = 0;\n\n               }\n\n          }\n      }\n      // ---\n\n      \n      ConfigValue *cv=NULL;\n      double f;\n      // convert value according to type...\n      switch (ty) {\n             //TODO: resolve variable references (i.e. $xxxx)\n             // introduce ConfigValueRef type... which will be replaced once all instances have been read\n        case CFTP_NUM:\n          //sscanf(value,\"%f\",&f);\n          char *eptr;\n//        cv = new ConfigValueRef(REF_NUM,name)\n\n          f = strtod(value,&eptr);\n          if ((f==0.0)&&(eptr == value)) { CONF_PARSER_ERR(\"(line %i) cFileConfigReader::getInstance: error parsing numeric value '%s'\",lineNr,value); }\n          SMILE_DBG(8,\"parsing numeric value: (field: '%s') val=%f (str: '%s')\",field,f,value);\n          cv = new ConfigValueNum(f);\n          break;\n        case CFTP_STR:\n//        cv = new ConfigValueRef(REF_STR,name)\n          cv = new ConfigValueStr(value);\n          SMILE_DBG(8,\"set string value : '%s'\",cv->getStr());\n          break;\n        case CFTP_CHR:\n//        cv = new ConfigValueRef(REF_CHR,name)\n          if (!(strncmp(value,\"<space>\",7))) {\n            cv = new ConfigValueChr(' ');\n          } else if (!(strncmp(value,\"<tab>\",5))) {\n            cv = new ConfigValueChr('\\t');\n          } else {\n            if ((strlen(value) > 1)) SMILE_WRN(2,\"(line %i) cFileConfigReader::getInstance: char field has length > 1 ('%s'='%s')\",lineNr,field,value);\n            cv = new ConfigValueChr(value[0]);\n          }\n          SMILE_DBG(8,\"set char value : '%c'\",cv->getChar());\n          break;\n        case CFTP_OBJ:\n                 // TODO!!  resolve object references '\\instancename'\n        // also use ConfigValueRef type here...\n//        cv = new ConfigValueRef(REF_INST,name)\n                 // if (cman!=NULL) in = cman->getInstance(iname);\n//                 cv = new ConfigValueObj( in , 0 );\n/*\n          if (strlen(value) > 1) SMILE_WRN(2,\"cFileConfigReader::getInstance: char field has length > 1 ('%s'='%s')\",field,value);\n          cv = new ConfigValueChr(value[0]);\n          SMILE_DBG(5,\"set char value : '%c'\",cv->getChr());\n          break;\n*/\n        default:\n          CONF_PARSER_ERR(\"(line %i) cFileConfigReader::getInstance: unknown field type (name '%s') (in ConfigType '%s') ty=%i\",lineNr,field,_type->getName(),ty);\n          //CONF_PARSER_ERR(\"unknown type OR  cannot convert value\");\n      }\n\n      //if (tmpstr!=NULL) free(tmpstr); // <-----\n\n      // TODO: variables, references, placeholders....\n      \n      // use setValue() to set the value\n      if (arrT == 10) {\n        char *c = myvprint(\"%s[%i]\",field,idx);\n//printf(\"setvalue10 %i '%s' = '%s'\\n\",idx,c,value); fflush(stdout);\n        ret->setValue(cv, -1, c);\n        free(c);\n      } else {\n//printf(\"setvalue %i %i '%s'\\n\",arrT,arrN,field);\n        ret->setValue(cv, -1, field);\n      }\n\n      } // END for nFields\n\n      if (tmpstr!=NULL) free(tmpstr);\n      // free valuefield:\n      if (valuefield != NULL) free(valuefield);\n      \n      //const ConfigValue *v = ret->getValue(-1,field);\n      //SMILE_DBG(5,\"str = '%s'\",v->getStr());\n    }\n    free(origline);\n  }\n  return ret;\n}\n\n\n\n/******************************************************************************/\n\n\n\ncConfigManager::cConfigManager(cCommandlineParser *parser) :\n  nReaders(0),\n  nInst(0),\n  nTypes(0),\n  cmdparser(parser)\n{\n  defaults = (ConfigInstance **)calloc(1,sizeof(ConfigInstance *)*NEL_ALLOC_BLOCK);\n  if (defaults != NULL) nTypesAlloc = NEL_ALLOC_BLOCK;\n  else nTypesAlloc = 0;\n\n  inst = (ConfigInstance **)calloc(1,sizeof(ConfigInstance *)*NEL_ALLOC_BLOCK);\n  if (inst != NULL) nInstAlloc = NEL_ALLOC_BLOCK;\n  else nInstAlloc = 0;\n\n  reader = (cConfigReader **)calloc(1,sizeof(cConfigReader *)*NEL_ALLOC_BLOCK);\n  //readerPriority = (int *)calloc(1,sizeof(int)*NEL_ALLOC_BLOCK);\n//  if ((reader != NULL)&&(readerPriority!=NULL)) {\n  if (reader != NULL) {\n    nReadersAlloc = NEL_ALLOC_BLOCK;\n  } else {\n    if (reader != NULL) free(reader);\n //   if (readerPriority != NULL) free(readerPriority);\n    nReadersAlloc = 0;\n  }\n  externalObjectMap_ = new std::map <std::string, void *>();\n}\n\n/* order in which readers are added determines their priority,\n   readers added last, will overwrite values from readers added prior to them */\nint cConfigManager::addReader(cConfigReader *_reader)\n{\n  if (_reader == NULL) return -1;\n  if (nReaders >= nReadersAlloc) { // realloc if true\n    cConfigReader **tmp = (cConfigReader **)realloc(reader, sizeof(cConfigReader*) * (nReadersAlloc+NEL_ALLOC_BLOCK));\n    if (tmp != NULL) {\n      reader = tmp;\n      nReadersAlloc += NEL_ALLOC_BLOCK;\n    } else { OUT_OF_MEMORY; }\n  }\n  _reader->setCmdparser(cmdparser);\n  reader[nReaders] = _reader;\n  return nReaders++;\n}\n\nint cConfigManager::addInstance(ConfigInstance *_inst)\n{\n  if (_inst == NULL) return -1;\n  if (nInst >= nInstAlloc) { // realloc if true\n    ConfigInstance **tmp = (ConfigInstance **)realloc(inst, sizeof(ConfigInstance*) * (nInstAlloc+NEL_ALLOC_BLOCK));\n    if (tmp != NULL) {\n      inst = tmp;\n      nInstAlloc += NEL_ALLOC_BLOCK;\n    } else { OUT_OF_MEMORY; }\n  }\n  inst[nInst] = _inst;\n  return nInst++;\n}\n\nint cConfigManager::deleteInstance(const char *_instname)   /* deletes instance \"_instname\" */\n{\n  int idx = findInstance(_instname);\n  if (idx >= 0) {\n\tdelete inst[idx];\n\tint i;\n\tfor (i=idx; i<nInst-1; i++) {\n      inst[i] = inst[i+1];\n\t}\n\tinst[i] = NULL;\n\tnInst--;\n\treturn 1;\n  } else {\n    SMILE_ERR(1,\"cannot delete instance '%s' -> not found!\",_instname);\n  }\n  return 0;\n}\n\n/* return value is index of instance or -1 if instance was not found */\nint cConfigManager::findInstance(const char *_instname) const\n{\n  int i;\n  if (_instname == NULL) {\n    SMILE_DBG(7,\"findInstance called with _instname = NULL!!\");\n    return -1;\n  }\n  for (i=0; i<nInst; i++) {\n    SMILE_DBG(7,\"findInstance: comparing instname ('%s') with '%s' for inst %i\",_instname,inst[i]->getName(),i);\n    if (!strcmp(inst[i]->getName(),_instname)) {\n      SMILE_DBG(7,\"findInstance: match (%i)!\",i);\n      return i;\n    }\n  }\n  return -1;\n}\n\n/* return value is index of instance or -1 if instance was not found */\nint cConfigManager::findType(const char *_typename) const\n{\n  int i;\n  if (_typename == NULL) return -1;\n  for (i=0; i<nTypes; i++) {\n    if (defaults[i]->getType() != NULL) {\n      if (!strcmp(defaults[i]->getTypeName(),_typename)) return i;\n    }\n  }\n  return -1;\n}\n\nconst ConfigType * cConfigManager::getTypeObj(int n) const\n{\n  if ((n>=0)&&(n<nTypes)) {\n    if (defaults[n] != NULL) return defaults[n]->getType();\n  }\n  return NULL;\n}\n\nconst ConfigType *cConfigManager::getTypeObj(const char *_typename) const // hierarchical type resolving...\n{\n  if (_typename != NULL) {\n    char *b=NULL;\n    const char *s=NULL;\n    const ConfigType *tp=NULL;\n    int h = instNameSplit(_typename, &b, &s);\n    if (b!=NULL) {\n      tp = getTypeObj(findType(b));\n      free(b); b=NULL;\n    }\n    \n    if (tp !=NULL) {\n      while (h==1) {\n        h = instNameSplit(s, &b, &s);\n        if (b!=NULL) {\n          int t = tp->findField(b);\n          free(b); b=NULL;\n          tp = tp->getTypeObj(t);\n          if (tp==NULL) {\n            SMILE_WRN(4,\"getType: cannot find configType for '%s' (at 's=%s')\",_typename,s);\n            return NULL;\n          }\n        } else {\n          CONF_MANAGER_ERR(\"getType: empty base returned by instNameSplit! (for config type '%s')\",_typename);\n        }\n      }\n      return tp;\n    } else {\n      SMILE_WRN(4,\"getType: cannot find configType base of '%s'\",_typename);\n      return NULL;\n    }\n  }\n  return NULL;\n}\n\n\nint cConfigManager::updateInstance(ConfigInstance *_inst)\n{\n  if (_inst == NULL) return -1;\n  int update = 0;\n  int idx = findInstance(_inst->getName());\n  if (idx == -1) {\n    // new instance, check for default instance in *defaults\n    SMILE_DBG(6,\"updateInstance: adding new instance '%s'\",_inst->getName());\n    const ConfigType *tmpType = _inst->getType();\n    int tidx = findType(tmpType->getName());\n    if (tidx == -1) {\n      // error: unknown type! (can not be...)\n      CONF_MANAGER_ERR(\"updateInstance: trying to add instance (%s) of unknown type (%s) to configManager\",_inst->getName(),tmpType->getName());\n    } else {\n      // copy and \"update\" default:\n      _inst->missingFrom(defaults[tidx]);\n      addInstance(_inst);\n    }\n  } else {\n    //update only\n    inst[idx]->updateWith(_inst);\n    update = 1;\n  }\n  return update;\n}\n\n/* register an instance specifying the type and the default values */\n/* the instance MUST contain a type, the instance must be created with freeType=0\n   the instance will be freed by the configManager */\nint cConfigManager::registerType(ConfigInstance *_type)\n{\n  if (_type == NULL) return -1;\n  // check for unique name... TODO:\n  int existing = findType(_type->getName());\n  if (existing >= 0) {\n    SMILE_WRN(3,\"ConfigType '%s' is already registered. Exiting cConfigManager::registerType\",_type->getName());\n    delete _type;\n    return existing;\n  }\n  if (nTypes >= nTypesAlloc) { // realloc if true\n    ConfigInstance **tmp = (ConfigInstance **)realloc(defaults, sizeof(ConfigInstance*) * (nTypesAlloc+NEL_ALLOC_BLOCK));\n    if (tmp != NULL) {\n      defaults = tmp;\n      nTypesAlloc += NEL_ALLOC_BLOCK;\n    } else { OUT_OF_MEMORY; }\n  }\n  defaults[nTypes] = _type;\n  return nTypes++;\n}\n\nvoid cConfigManager::readConfig()\n{                     /* read the config, after readers and types have been registered */\n  // find instance names for all types in all readers\n  int i,r,t;\n  for (t=0; t<nTypes; t++) {  // foreach config type\n    const ConfigType *typ = defaults[t]->getType();\n    for (r=0; r<nReaders; r++) { // foreach reader, in priority order\n      int _n;\n      char ** inames = reader[r]->findInstances(typ, &_n); // find instances\n      SMILE_DBG(7,\"found %i instance(s) for type %s\",_n,typ->getName());\n      if (inames != NULL) {\n        for (i=0; i<_n; i++) { // foreach instance of the current reader\n          SMILE_DBG(7,\"reading configInstance %i ('%s') from reader %i\",i,inames[i],r);\n          ConfigInstance *rd = reader[r]->getInstance(inames[i], typ);\n\n/*      #ifdef DEBUG\n      const ConfigValue *v=rd->getValue(-1,\"age\");\n      if (v!=NULL) {\n        SMILE_DBG(4,\"readConfig: inst->getValue('age') = %i\",v->getInt());\n      }\n      #endif*/\n              // TODO: if getInstance returned NULL , check for instance link... remember link\n\n\n          // now add the instance to the Manager\n          if (updateInstance(rd))\n            { delete rd; }\n          free(inames[i]);\n        }\n        free(inames);\n      } else {\n        SMILE_DBG(6,\"findInstances returned NULL pointer to instnames array!\");\n      }\n\n    }\n\n\n  }\n  // TODO: now, for each instance: resolve wildcards, %cmdline_xx%, etc. (except for %instname% )\n\n    // TODO: scan for instance links\n    // ... and for variable links (... difficult...)\n\n}\n\n/* no hierarchical names are supported... */\nConfigInstance * cConfigManager::getInstance(const char *_instname)\n{\n  const char * _subname;\n  char * _instbasename=NULL;\n  int h = instNameSplit(_instname, &_instbasename, &_subname);\n  int idx = findInstance(_instbasename);\n  if (_instbasename != NULL) free(_instbasename);\n  if (idx >= 0) {\n    if (h) { // search through the hierarchy\n      CONF_MANAGER_ERR(\"cConfigManager::getInstance: cannot get sub-instance, use getValue instead!\");\n    } else {\n      return inst[idx];\n    }\n  }\n  return NULL;\n}\n\nconst ConfigValue * cConfigManager::getValue(const char *_name) const\n{\n  const char * _subname=NULL;\n  char * _instbasename=NULL;\n\n  SMILE_DBG(7,\"cConfigManager::getValue: _name = '%s'\",_name);\n\n  int h = instNameSplit(_name, &_instbasename, &_subname);\n  SMILE_DBG(7,\"cConfigManager::getValue: instNameSplit returned %i\",h);\n  int idx = findInstance(_instbasename);\n  if (_instbasename != NULL) free(_instbasename);\n  if (idx >= 0) {\n    if (h) { // search through the hierarchy\n      return inst[idx]->getValue(-1,_subname);\n    } else {\n      CONF_MANAGER_ERR(\"field name not given in name '%s'\",_name);\n    }\n  } else CONF_MANAGER_ERR(\"base instance of field '%s' not found in configManager!\",_name);\n  return NULL;\n}\n\nint cConfigManager::getArraySize(const char *_name) const\n{\n  const ConfigValue *v = getValue(_name);\n  if (v!=NULL) {\n    if (v->getType() >= CFTP_ARR) {\n      return v->getSize();\n    } else {\n      CONF_MANAGER_ERR(\"cannot get size of array field '%s', this field is not an array (type=%i)\",_name,v->getType());\n    }\n  }\n  return -1;\n}\n\nchar ** cConfigManager::getArrayKeys(const char *_name, int *N) const\n{\n  const ConfigValue *v = getValue(_name);\n  if (v!=NULL) {\n    if (v->getType() >= CFTP_ARR) {\n      if (N!=NULL) *N = v->getSize();\n      return v->getAAkeys();\n    } else {\n      CONF_MANAGER_ERR(\"cannot get names (and size) of array field '%s', this field is not an array (type=%i)\",_name,v->getType());\n    }\n  }\n  if (N!=NULL) *N=0;\n  return NULL;\n}\n\nvoid cConfigManager::printTypeHelp(int _subtype, const char *selection, int dfltConf)\n{\n  int i;\n  const ConfigType * tp;\n\n  if (defaults == NULL) return;\n  for (i=0; i<nTypes; i++) {\n    tp = defaults[i]->getType();\n    if (tp != NULL) {\n      if (selection != NULL) {\n        //printf(\"N: %s Sel: %s Strl(sel): %i\\n\",tp->getName(), selection, strlen(selection));\n        if (!strncasecmp(tp->getName(), selection, strlen(selection)) ) {\n          tp->printTypeHelp(NULL,_subtype);\n          if (dfltConf) {\n//            SMILE_PRINT(\" // default (template) configuration file section for '%s' >>\",tp->getName());\n            tp->printTypeDfltConfig(NULL,_subtype);\n            //SMILE_PRINT(\"\");\n          }\n        }\n      } else {\n        tp->printTypeHelp(NULL,_subtype);\n        if (dfltConf) {\n          //SMILE_PRINT(\" // default (template) configuration file section for '%s' >>\",tp->getName());\n          tp->printTypeDfltConfig(NULL,_subtype);\n          //SMILE_PRINT(\"\");\n        }\n      }\n    }\n  }\n}\n\n/*\nfullMode == 1:   selection contains a list of multiple components,\n                 create a full config file with component list,\n                 though leaving reader/writer levels blank!\n*/\nvoid cConfigManager::printTypeDfltConfig(const char *selection, int _subtype, int fullMode, int withDescription)\n{\n  int i;\n  const ConfigType * tp;\n\n  if (defaults == NULL) return;\n  if (fullMode) {\n    if (selection == NULL) {\n      SMILE_ERR(1,\"cannot print a template config file (fullMode==1), when no comma separated list of components is given!\");\n      return;\n    }\n    // parse comma separated list of component types (names can appear twice..)\n    // and remove all spaces adjacent to a comma\n    int nSel = 1;\n    long l = (long)strlen(selection);\n    // TODO: check for empty string, or just consisting of spaces/tabs ..\n    for (i=0; i<l; i++) {\n      if (selection[i] == ',') nSel++;\n      if (selection[i] == 0) break;\n    }\n    \n    char * mySel = strdup(selection);\n    const char ** sels = (const char**) calloc(1,sizeof(const char*) * nSel);\n\n    int s = 0; i=0;\n    sels[s] = mySel; while (sels[s][0] == ' ') { sels[s]++; i++; }\n    for (; i<l; i++) {\n      if (selection[i] == ',') {\n        s++; mySel[i++] = 0;\n        if (s>=nSel) break; // this break should never be reached, just for double safety...\n        sels[s] = mySel+i; while (sels[s][0] == ' ') { sels[s]++; i++; }\n      }\n    }\n\n    // print the header and a few comments\n    SMILE_PRINT(\"\\n ///////////////////////////////////////////////////////////////////////////\");\n    SMILE_PRINT(\" // openSMILE configuration template file generated by SMILExtract binary //\");\n    SMILE_PRINT(\" // you must manually adapt this file and change at least the             //\");\n    SMILE_PRINT(\" // 'reader/writer.dmLevel =' lines.                                      //\");\n    SMILE_PRINT(\" ///////////////////////////////////////////////////////////////////////////\\n\");\n\n    SMILE_PRINT(\" ;===== component manager configuration (= list of enabled components!) =====\\n\");\n\n    SMILE_PRINT(\"[componentInstances:cComponentManager]\");\n    SMILE_PRINT(\" // this line configures the default data memory:\");\n    SMILE_PRINT(\"instance[dataMemory].type = cDataMemory\");\n    for (i=0; i<nSel; i++) {\n      tp = getTypeObj(findType(sels[i]));\n      if (tp == NULL) {\n        SMILE_ERR(1,\"Type '%s' not found! It seems, that this component does not exist!\",sels[i]);\n      } else {\n        char * modStr = strdup(sels[i]+1);\n        if (modStr != NULL) {\n          modStr[0] = tolower(modStr[0]);\n          SMILE_PRINT(\"instance[%s].type = %s\",modStr,sels[i]);\n          free(modStr);\n        }\n      }\n    }\n    SMILE_PRINT(\" // Here you can control the amount of detail displayed for the data memory\\n  // level configuration. 0 is no information at all, 5 is maximum detail.\");\n    SMILE_PRINT(\"printLevelStats = 1\");\n    SMILE_PRINT(\" // You can set the number of parallel threads (experimental):\");\n    SMILE_PRINT(\"nThreads = 1\");\n\n    SMILE_PRINT(\"\\n// ============= component configuration sections begin here ==============\\n\");\n\n    // for each element in the list print the config section\n    for (i=0; i<nSel; i++) {\n      tp = getTypeObj(findType(sels[i]));\n      if (tp != NULL) tp->printTypeDfltConfig(NULL,_subtype,withDescription);\n      else {\n        SMILE_ERR(1,\"Type '%s' not found! It seems, that this component does not exist!\",sels[i]);\n      }\n    }\n\n    free(sels);\n    free(mySel);\n\n    SMILE_PRINT(\"\\n// ################### END OF openSMILE CONFIG FILE ######################\\n\");\n    \n  } else {\n\n    for (i=0; i<nTypes; i++) {\n      tp = defaults[i]->getType();\n      if (tp != NULL) {\n          if ((selection != NULL)&&(!fullMode)) {\n            //printf(\"N: %s Sel: %s Strl(sel): %i\\n\",tp->getName(), selection, strlen(selection));\n            if (!strncasecmp(tp->getName(), selection, strlen(selection)) ) {\n              tp->printTypeDfltConfig(NULL,_subtype,withDescription);\n            }\n          } else {\n            tp->printTypeDfltConfig(NULL,_subtype,withDescription);\n          }\n      }\n    }\n\n  }\n}\n\ncConfigManager::~cConfigManager()\n{\n  int i;\n  //free instances\n  if (inst != NULL) {\n    for (i=0; i<nInst; i++) {\n      if (inst[i] != NULL) { delete inst[i]; }\n    }\n    free(inst);\n  }\n  nInstAlloc=0; nInst=0;\n\n  //free types\n  if (defaults != NULL) {\n    for (i=0; i<nTypes; i++) {\n      if (defaults[i] != NULL) { delete defaults[i]; }\n    }\n    free(defaults);\n  }\n  nTypesAlloc=0; nTypes=0;\n\n  //free readers\n  if (reader != NULL) {\n    for (i=0; i<nReaders; i++) {\n      if (reader[i] != NULL) { delete reader[i]; }\n    }\n    free(reader);\n  }\n  nReadersAlloc=0; nReaders=0;\n  if (externalObjectMap_ != NULL)\n    delete externalObjectMap_;\n}\n\n"
  },
  {
    "path": "src/core/dataMemory.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n#include <core/dataMemory.hpp>\n#include <core/componentManager.hpp>\n\n#define MODULE \"dataMemory\"\n\nSMILECOMPONENT_STATICS(cDataMemory)\n\nSMILECOMPONENT_REGCOMP(cDataMemory)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CDATAMEMORY;\n  sdescription = COMPONENT_DESCRIPTION_CDATAMEMORY;\n\n  // dataMemory level's config type:\n  ConfigType *dml = new ConfigType(\"cDataMemoryLevel\");\n  if (dml == NULL) OUT_OF_MEMORY;\n  dml->setField(\"name\", \"The name of this data memory level, must be unique within one data memory instance.\", (char*)NULL);\n  dml->setField(\"type\", \"The data type of the level [can be: 'float' or 'int'(eger) , currently only float is supported by the majority of processing components ]\", \"float\");\n  dml->setField(\"isRb\", \"Flag that indicates whether this level is a ring-buffer level (1) or not (0). I.e. this level stores the last 'nT' frames, and discards old data as new data comes in (if the old data has already been read by all registered readers; if this is not the case, the level will report that it is full to the writer attempting the write operation)\", 1);\n  dml->setField(\"nT\", \"The size of the level buffer in frames (this overwrites the 'lenSec' option)\", 100,0,0);\n  dml->setField(\"T\", \"The frame period of this level in seconds. Use a frame period of 0 for a-periodic levels (i.e. data that does not occur periodically)\", 0.0);\n  dml->setField(\"lenSec\", \"The size of the level buffer in seconds\", 0.0);\n  dml->setField(\"frameSizeSec\", \"The size of one frame in seconds. (This is generally NOT equal to 1/T, because frames may overlap)\", 0.0);\n  dml->setField(\"growDyn\", \"Supported currently only if 'ringbuffer=0'. If this option is set to 1, the level grows dynamically, if more memory is needed. You can use this to store live input of arbirary length in memory. However, be aware that if openSMILE runs for a long time, it will allocate more and more memory!\", 0);\n  dml->setField(\"noHang\", \"This option controls the 'hang' behaviour for ring-buffer levels, i.e. the behaviour exhibited, when the level is full because data from the ring-buffer has not been marked as read because not all readers registered to read from this level have read data. Valid options are, 0, 1, 2 :\\n   0 = always wait for readers, mark the level as full and make writes fail until all readers have read at least the next frame from this level\\n   1 = don't wait for readers, if no readers are registered, i.e. this level is a dead-end (this is the default) / 2 = never wait for readers, writes to this level will always succeed (reads to non existing data regions might then fail), use this option with a bit of caution.\", 1);\n\n  // dataMemory's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n\n  ct->setField(\"isRb\", \"The default for the isRb option for all levels.\", 1,0,0);\n  ct->setField(\"nT\", \"The default level buffer size in frames for all levels.\", 100,0,0);\n  if (ct->setField(\"level\", \"An associative array containing the level configuration (obsolete, you should use the cDataWriter configuration in the components that write to the dataMemory to properly configure the dataMemory!)\",\n                  dml, 1) == -1) {\n     rA=1; // if subtype not yet found, request , re-register in the next iteration\n  }\n\n  SMILECOMPONENT_IFNOTREGAGAIN( {} )\n  \n  SMILECOMPONENT_MAKEINFO(cDataMemory);\n}\n\nSMILECOMPONENT_CREATE(cDataMemory)\n\n\n\nvoid TimeMetaInfoMinimal::cloneFrom(const TimeMetaInfo *tm)\n{\n  if (tm != NULL) {\n    vIdx = tm->vIdx;\n    period = (float)tm->period;\n  }\n}\n\n/**** frame meta information *********\n   names, indicies (for each row)\n **************************************/\n\n// the returned name is the base name belonging to the expanded field n\n// arrIdx will be the index in the array (if an array)\n//   or -1 if no array!\n//-> n is element(!) index\nconst char * FrameMetaInfo::getName(int n, int *_arrIdx)\n{\n  smileMutexLock(myMtx);\n\n  long  lN=0;\n  lN = Ne; \n\n  static long nn=0; ////\n  static long ff=0; ////\n\n  if ((n>=0)&&(n<lN)) {\n    long f=0,tmp=0;\n\n    if (n>nn) {f=ff; tmp=nn; } //// fast, but unsafe? TODO: check!\n    //TODO: this code is NOT thread safe. solutions:\n    // a) use a mutex... this actually should do the job...\n    // b) use a lookup table for n->f which must be built earlier or here if it doesn exist (but then we must use mutexes again to ensure exclusive building and waiting of other threads for the built index)\n    \n    for(; f<N; f++) {\n      nn=tmp; ff=f; ////\n      tmp += field[f].N;\n      if (tmp>n) break;\n    }\n    if (_arrIdx != NULL) {\n      if (field[f].N > 1)\n        *_arrIdx = n-(tmp-field[f].N) + field[f].arrNameOffset;\n      else\n        *_arrIdx = -1;\n    }\n    smileMutexUnlock(myMtx);\n    return field[f].name;\n  }\n  smileMutexUnlock(myMtx);\n  return NULL;\n}\n\nlong FrameMetaInfo::fieldToElementIdx(long _field, long _arrIdx) const\n{\n  int i;\n  int lN=0;\n  if (_field >= N) _field = lN-1;\n  for(i=0; i<_field; i++) {\n    lN += field[i].N;\n  }\n  return lN + _arrIdx;\n}\n\nlong FrameMetaInfo::elementToFieldIdx(long _element, long *_arrIdx) const\n{\n  int i;\n  int  lN=0, _prevN = 0;\n  for(i=0; i<N; i++) {\n    lN += field[i].N;\n    if (lN > _element) {\n      if (_arrIdx != NULL) *_arrIdx = field[i].N - (lN - _element);\n      return i;\n    }\n  }\n  if (_arrIdx != NULL) *_arrIdx = 0;\n  return -1;\n}\n\n\n// returned *arrIdx will be the real index in the data structure, i.e. named index - arrNameOffset\nint FrameMetaInfo::findField(const char*_fieldName, int *arrIdx, int *more) const\n{\n  if (_fieldName == NULL) return -1;\n\n  // check for [] in _fieldName => array field\n  long ai = 0;\n  char *fn = strdup(_fieldName);\n  char *a  = strchr(fn,'[');\n  if (a != NULL) {  // yes, array\n    a[0] = 0;\n    a++;\n    char *b = strchr(fn,']');\n    if (b == NULL) { COMP_ERR(\"findField: invalid array field name '%s', expected ']' at the end!\",_fieldName); }\n    b[0] = 0;\n    char *eptr = NULL;\n    ai = strtol(a,&eptr,10);\n    if ((ai==0)&&(eptr == a)) { COMP_ERR(\"findField: error parsing array index in name '%s', index is not a number!\",_fieldName); }\n  } \n  if (arrIdx != NULL) *arrIdx = ai;\n\n  int i;\n  int idx = -1;\n  int _start = 0;\n  if ((more != NULL)&&(*more>0)) { _start = *more; *more = 0; }\n  int foundFlag = 0;\n  for (i=_start; i<N; i++) {\n    int myAi;\n    if (!foundFlag) {\n      if (a != NULL) // array name\n        myAi = ai - field[i].arrNameOffset;\n      else // non array name (first field of array, always index 0 in data structure)\n        myAi = 0;\n    }\n    if (!strcmp(fn,field[i].name)) {\n      if (!foundFlag) {\n        idx = i;\n        if (myAi < field[i].N) {\n          //idx = field[i].Nstart + myAi;\n          if (arrIdx != NULL) *arrIdx = myAi; // update *arrIdx with correct index (real index in data structure, not 'named' index)\n          if (more == NULL) break;\n          else foundFlag=1;\n        } else {\n          COMP_ERR(\"array index out of bounds (field '%s') %i > %i (must from %i - %i) (NOTE: first index is 0, not 1!)\",_fieldName,ai,field[i].N-1+field[N].arrNameOffset,field[N].arrNameOffset,field[i].N-1+field[N].arrNameOffset);\n        }\n      } else {\n        if (more != NULL) (*more)++;\n      }\n    }\n  }\n  free(fn);\n  return idx;\n}\n\n// returned *arrIdx will be the real index in the data structure, i.e. named index - arrNameOffset\nint FrameMetaInfo::findFieldByPartialName(const char*_fieldNamePart, int *arrIdx, int *more) const\n{\n  if (_fieldNamePart == NULL) return -1;\n\n  // check for [] in _fieldName => array field\n  long ai = 0;\n  char *fn = strdup(_fieldNamePart);\n  char *a  = strchr(fn,'[');\n  if (a != NULL) {  // yes, array\n    a[0] = 0;\n    a++;\n    char *b = strchr(fn,']');\n    if (b == NULL) { COMP_ERR(\"findField: invalid array field name part '%s', expected ']' at the end!\",_fieldNamePart); }\n    b[0] = 0;\n    char *eptr = NULL;\n    ai = strtol(a,&eptr,10);\n    if ((ai==0)&&(eptr == a)) { COMP_ERR(\"findField: error parsing array index in name part '%s', index is not a number!\",_fieldNamePart); }\n  }\n  if (arrIdx != NULL) *arrIdx = ai;\n\n  int i;\n  int idx = -1;\n  int _start = 0;\n  if ((more != NULL)&&(*more>0)) { _start = *more; *more = 0; }\n  int foundFlag = 0;\n  for (i=_start; i<N; i++) {\n    int myAi;\n    if (!foundFlag) {\n      if (a != NULL) // array name\n        myAi = ai - field[i].arrNameOffset;\n      else // non array name (first field of array, always index 0 in data structure)\n        myAi = 0;\n    }\n    //    printf(\"name(%i): '%s'\\n\",i,field[i].name);\n    if (strstr(field[i].name,fn)) {\n      if (!foundFlag) {\n        idx = i;\n        if (myAi < field[i].N) {\n          if (arrIdx != NULL) *arrIdx = myAi; // update *arrIdx with correct index (real index in data structure, not 'named' index)\n          if (more == NULL) break;\n          else foundFlag=1;\n        } else {\n          COMP_ERR(\"array index out of bounds (partial field name '%s') %i > %i (must from %i - %i) (NOTE: first index is 0, not 1!)\",_fieldNamePart,ai,field[i].N-1+field[N].arrNameOffset,field[N].arrNameOffset,field[i].N-1+field[N].arrNameOffset);\n        }\n      } else {\n        if (more != NULL) *more++;\n      }\n    }\n  }\n  free(fn);\n  return idx;\n}\n\n/******* datatypes ************/\n\ncVector::cVector(int lN, int _type) :\n  N(0), dataF(NULL), dataI(NULL), fmeta(NULL), tmeta(NULL), ntmp(NULL), tmetaAlien(0), tmetaArr(0)\n{\n  if (lN>0) {\n    switch (_type) {\n      case DMEM_FLOAT:\n        dataF = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*lN);\n        if (dataF==NULL) OUT_OF_MEMORY;\n        break;\n      case DMEM_INT:\n        dataI = (INT_DMEM*)calloc(1,sizeof(INT_DMEM)*lN);\n        if (dataI==NULL) OUT_OF_MEMORY;\n        break;\n      default:\n        COMP_ERR(\"cVector: unknown data type encountered in constructor! (%i)\",_type);\n    }\n    N = lN;\n    type = _type;\n    tmeta = new TimeMetaInfo(); //(TimeMetaInfo *)calloc(1,sizeof(TimeMetaInfo));\n    if (tmeta == NULL) OUT_OF_MEMORY;\n  }\n}\n\nconst char *cVector::name(int n, int *lN)\n{\n  if ((fmeta!=NULL)&&(fmeta->field!=NULL)) {\n    if (ntmp != NULL) free(ntmp);\n    int llN=-1;\n    const char *t = fmeta->getName(n,&llN);\n    if (lN!=NULL) *lN = llN;\n    if (llN>=0) {\n      ntmp=myvprint(\"%s[%i]\",t,llN);\n      return ntmp;\n    } else {\n      ntmp=NULL;\n      return t;\n    }\n  }\n  return NULL;\n}\n\ncVector::~cVector() {\n  if (dataF!=NULL) free(dataF);\n  if (dataI!=NULL) free(dataI);\n  if ((tmeta!=NULL)&&(!tmetaAlien)) {\n    if (tmetaArr) delete[] tmeta;\n    else delete tmeta;\n  }\n  if (ntmp!=NULL)  free(ntmp);\n}\n\ncMatrix::~cMatrix()\n{\n  if ((tmeta!=NULL)&&(!tmetaAlien)) {\n//    if (nT > 1)\n    if (tmetaArr) delete[] tmeta;\n    else delete tmeta;\n//    else\n//      delete tmeta;\n  }\n  tmeta = NULL;\n}\n\ncMatrix::cMatrix(int lN, int lnT, int ltype) :\n  cVector(0), nT(0)\n{\n  if ((lN>0)&&(lnT>0)) {\n    switch (ltype) {\n      case DMEM_FLOAT:\n        dataF = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*lN*lnT);\n        if (dataF==NULL) OUT_OF_MEMORY;\n        break;\n      case DMEM_INT:\n        dataI = (INT_DMEM*)calloc(1,sizeof(INT_DMEM)*lN*lnT);\n        if (dataI==NULL) OUT_OF_MEMORY;\n        break;\n      default:\n        COMP_ERR(\"cMatrix: unknown data type encountered in constructor! (%i)\",ltype);\n    }\n    N = lN;\n    nT = lnT;\n    type = ltype;\n    tmetaArr = 1;\n    tmeta = new TimeMetaInfo[lnT]; //(TimeMetaInfo *)calloc(1,sizeof(TimeMetaInfo)*_nT);\n    if (tmeta == NULL) OUT_OF_MEMORY;\n  }\n}\n\n/* helper function for transposing a matrix */\nstatic void quickTranspose(void *src, void *dst, long R, long C, int elSize)\n{\n  int r,c;\n  char *s=(char*)src, *d=(char*)dst;\n  for (r=0; r<R; r++) {  // read each row\n    for (c=0; c<C; c++) { // and copy it as column\n      memcpy( d+(r*C+c)*elSize, s+(c*R+r)*elSize, elSize );\n    }\n  }\n}\n\n// transpose matrix\nvoid cMatrix::transpose()\n{\n  FLOAT_DMEM *f = NULL;\n  INT_DMEM *i = NULL;\n  // transpose data:\n  switch (type) {\n    case DMEM_FLOAT:\n      f = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*N*nT);\n      if (f==NULL) OUT_OF_MEMORY;\n      // transpose:\n      quickTranspose(dataF,f,N,nT,sizeof(FLOAT_DMEM));\n      free(dataF);\n      dataF = f;\n      break;\n    case DMEM_INT:\n      i = (INT_DMEM*)calloc(1,sizeof(INT_DMEM)*N*nT);\n      if (i==NULL) OUT_OF_MEMORY;\n      // transpose:\n      quickTranspose(dataI,i,N,nT,sizeof(INT_DMEM));\n      free(dataI);\n      dataI = i;\n      break;\n    default:\n      COMP_ERR(\"cMatrix::transpose: unknown data type (%i) encountered, cannot transpose this matrix!\",type);\n  }\n  // swap dimensions:\n  long tmp = N;\n  N = nT;\n  nT = tmp;\n}\n\n// reshape to given dimensions, perform sanity check...\nvoid cMatrix::reshape(long R, long C)\n{\n  long len = N*nT;\n  if (R*C > len) SMILE_ERR(1,\"reshape: cannot reshape matrix, new size (%i*%i=%i) is greater than current size (%i*%i=%i)! this is not yet implemented! \\n   (maybe there should be a resize method in the future...)\",R,C,R*C,N,nT,len);\n  if (R*C < len) SMILE_WRN(1,\"reshape: new matrix will be smaller than current matrix, not all data will be accessible (maybe use resize() in future releases!\");\n  R=N;\n  C=nT;\n}\n\n// convert matrix to long vector with all columns concatenated ...\n// return a compatible cVector object\nconst cVector * cMatrix::expand()\n{\n  N = N*nT;\n  return (cVector*)this;\n}\n\n\n/******* dataMemory level class ************/\n\n\nvoid cDataMemoryLevel::frameWr(long rIdx, FLOAT_DMEM *_data)\n{\n  FLOAT_DMEM *f = data->dataF + rIdx*lcfg.N;\n  FLOAT_DMEM *end = f+lcfg.N;\n  for ( ; f < end; f++) {\n    *f = *_data;\n    _data++;\n  }\n}\n\nvoid cDataMemoryLevel::frameWr(long rIdx, INT_DMEM *_data)\n{\n  INT_DMEM *f = data->dataI + rIdx*lcfg.N;\n  INT_DMEM *end = f+lcfg.N;\n  for ( ; f < end; f++) {\n    *f = *_data;\n    _data++;\n  }\n}\n\nvoid cDataMemoryLevel::frameRd(long rIdx, FLOAT_DMEM *_data)\n{\n  FLOAT_DMEM *f = data->dataF + rIdx*lcfg.N;\n  FLOAT_DMEM *end = f+lcfg.N;\n  for ( ; f < end; f++) {\n    *_data = *f;\n    _data++;\n  }\n}\n\nvoid cDataMemoryLevel::frameRd(long rIdx, INT_DMEM *_data)\n{\n  INT_DMEM *f = data->dataI + rIdx*lcfg.N;\n  INT_DMEM *end = f+lcfg.N;\n  for ( ; f < end; f++) {\n    *_data = *f;\n    _data++;\n  }\n}\n\n/*\nconst sDmLevelConfig * cDataMemoryLevel::getConfig()\n{\n  if (lcfg == NULL) {\n    lcfg = new sDmLevelConfig();\n    if (lcfg==NULL) OUT_OF_MEMORY;\n  }\n  if (!finalised) {\n    lcfg->growDyn = growDyn;\n    lcfg->isRb = isRb;\n    lcfg->N = N;\n    lcfg->nT = nT;\n    lcfg->T = T;\n    lcfg->lenSec = T*(double)nT;\n    lcfg->frameSizeSec = frameSizeSec;\n    lcfg->type = type;\n    lcfg->fmeta = &fmeta;\n    lcfg->finalised = finalised;\n  } else {\n    lcfg->finalised = finalised;\n//    lcfg->N = N;\n//    lcfg->fmeta = &fmeta;\n  }\n  return lcfg;\n}\n*/\n\nvoid cDataMemoryLevel::printLevelStats(int detail)\n{\n  if (detail) {\n    SMILE_PRINT(\"==> LEVEL '%s'  +++  Buffersize(frames) = %i  +++  nReaders = %i\",getName(),lcfg.nT,nReaders);\n    if (detail >= 2) {\n    // TODO: more details  AND warn if nReaders == 0 or size == 0, etc.\n      SMILE_PRINT(\"     Period(in seconds) = %f \\t frameSize(in seconds) = %f (last: %f)\",lcfg.T,lcfg.frameSizeSec,lcfg.lastFrameSizeSec);\n      SMILE_PRINT(\"     BlocksizeRead(frames) = %i \\t BlocksizeWrite(frames) = %i\",lcfg.blocksizeReader,lcfg.blocksizeWriter);\n      if (detail >= 3) {\n        SMILE_PRINT(\"     Number of elements: %i \\t Number of fields: %i\",lcfg.N,lcfg.Nf);\n        if (detail >= 4) {\n          const char * typeStr = \"unknown\";\n          if (lcfg.type==DMEM_FLOAT) { typeStr=\"float\"; }\n          else if (lcfg.type==DMEM_INT) { typeStr=\"int\"; }\n          SMILE_PRINT(\"     type = %s   noHang = %i   isRingbuffer(isRb) = %i   growDyn = %i\",typeStr,lcfg.noHang,lcfg.isRb,lcfg.growDyn);\n          if (detail >= 5) {\n            // TODO: print data element names ??\n            int i; long idx = 0;\n            SMILE_PRINT(\"     Fields: index (range) : fieldname[array indicies]  (# elements)\");\n            for (i=0; i<fmeta.N; i++) {\n              if (fmeta.field[i].N > 1) {\n                SMILE_PRINT(\"      %2i. - %2i. : %s[%i-%i]  (%i)\",idx,idx+fmeta.field[i].N-1,fmeta.field[i].name,fmeta.field[i].arrNameOffset,fmeta.field[i].N+fmeta.field[i].arrNameOffset-1,fmeta.field[i].N);\n                idx += fmeta.field[i].N;\n              } else {\n                SMILE_PRINT(\"      %2i.       : %s\",idx,fmeta.field[i].name);\n                idx++;\n              }\n            }\n          }\n          if (detail >= 6) {\n            SMILE_PRINT(\"     Fields with info struct set: (index (range) : info struct size in bytes (dt = datatype))\");\n            long idx = 0;\n            for (int i = 0; i < fmeta.N; i++) {\n              if (fmeta.field[i].infoSet) {\n                if (fmeta.field[i].N > 1) {\n                  SMILE_PRINT(\"       %2i. - %2i. : infoSize = %i (dt = %i)\", idx, idx+fmeta.field[i].N-1, fmeta.field[i].infoSize, fmeta.field[i].dataType);\n                  idx += fmeta.field[i].N;\n                } else {\n                  SMILE_PRINT(\"       %2i.       : infoSize = %i (dt = %i)\", idx, fmeta.field[i].infoSize, fmeta.field[i].dataType);\n                  idx++;\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n  if (nReaders <= 0) SMILE_WRN(1,\"   Level '%s' might be a DEAD-END (nReaders <= 0!)\",getName());\n}\n\nconst char * cDataMemoryLevel::getFieldName(int n, int *lN, int *_arrNameOffset)\n{\n      //TODO::: use fmeta getName and implement expanding of array indcies... (see cVector::name)\n  if ( (n>=0)&&(n<lcfg.N) ) {\n    if (lN!=NULL) *lN = fmeta.field[n].N;\n\tif (_arrNameOffset!=NULL) *_arrNameOffset = fmeta.field[n].arrNameOffset;\n    return fmeta.field[n].name;\n  }\n  else return NULL;\n}\n\nchar * cDataMemoryLevel::getElementName(int n)\n{\n  if ( (n>=0)&&(n<lcfg.N) ) { // TODO:: is N correct? number of elements??\n    int llN=0;\n    const char *tmp = fmeta.getName(n,&llN);\n    char *ret;\n    if (llN >= 0) ret = myvprint(\"%s[%i]\",tmp,llN);\n    else ret = strdup(tmp); //myvprint(\"%s\",tmp,__N);\n    return ret;\n  }\n  else return NULL;\n}\n\nvoid cDataMemoryLevel::allocReaders() {\n  // allocate and initialize *curRr\n  if (nReaders > 0) { // if registered readers are present...\n    curRr = (long*)calloc(1,sizeof(long)*nReaders);\n  }\n}\n\n\n// set time meta information for frame at rIdx\nvoid cDataMemoryLevel::setTimeMeta(long rIdx, long vIdx, const TimeMetaInfo *tm)\n{\n  TimeMetaInfo *cur = tmeta+rIdx;\n  if (tm!=NULL) {\n    //memcpy( cur, tm, sizeof(TimeMetaInfo) );\n    cur->cloneFrom(tm); // <<-new!\n    cur->level = myId;\n    cur->vIdx =  vIdx;\n    cur->period = lcfg.T;\n    // keep an existing smiletime, else set the current smile time\n    if (tm->smileTime >= 0.0) cur->smileTime = tm->smileTime;\n    else {\n      if (!tm->noAutoSmileTime || cur->smileTime == -1.0 ) {\n        if (_parent != NULL) {\n          cComponentManager * cm = (cComponentManager *)_parent->getCompMan();\n          if (cm != NULL) {\n            cur->smileTime = cm->getSmileTime();\n          } else { cur->smileTime = -1.0; }\n        } else { cur->smileTime = -1.0; }\n      }\n    }\n    if (cur->time == 0.0)\n      if (lcfg.T!=0.0) cur->time = (double)vIdx * lcfg.T;\n      else {\n        cur->time = tmeta[(rIdx-1+lcfg.nT)%lcfg.nT].time + tmeta[(rIdx-1+lcfg.nT)%lcfg.nT].lengthSec;\n      }\n    if (!(cur->filled)) {\n      if (cur->lengthSec == 0.0) cur->lengthSec = tmeta[(rIdx-1+lcfg.nT)%lcfg.nT].lengthSec;\n      if (cur->lengthSec == 0.0) cur->lengthSec = (double)(cur->lengthSamples) * cur->samplePeriod;\n      if (cur->lengthSec == 0.0) cur->lengthSec = (double)(cur->lengthFrames) * cur->framePeriod;\n      if (cur->lengthSec == 0.0) cur->lengthSec = lcfg.T;\n      if (cur->vLengthSec == 0.0) cur->vLengthSec = cur->lengthSec;\n\n      if ((cur->lengthSamples == 0)&&(cur->samplePeriod != 0.0)) cur->lengthSamples = (int)(cur->lengthSec/cur->samplePeriod)+1;\n      if ((cur->vLengthSamples == 0)&&(cur->samplePeriod != 0.0)) cur->vLengthSamples = (int)(cur->vLengthSec/cur->samplePeriod)+1;\n\n      if ((cur->lengthFrames == 0)&&(cur->framePeriod != 0.0)) cur->lengthFrames = (int)(cur->lengthSec/cur->framePeriod)+1;\n      if ((cur->vLengthFrames == 0)&&(cur->framePeriod != 0.0)) cur->vLengthFrames = (int)(cur->vLengthSec/cur->framePeriod)+1;\n\n      if (cur->vLengthFrames == 0) cur->vLengthFrames = cur->lengthFrames;\n      if (cur->vLengthSamples == 0) cur->vLengthSamples = cur->lengthSamples;\n\n      if ((cur->samplePeriod == 0.0)&&(cur->lengthSamples!=0)) cur->samplePeriod = cur->lengthSec/(double)(cur->lengthSamples);\n      if ((cur->framePeriod == 0.0)&&(cur->lengthSamples!=0)) cur->framePeriod = cur->lengthSec/(double)(cur->lengthFrames);\n\n      cur->filled = 1;\n    }\n  } else {\n    // zero current time meta??\n  }\n}\n\n// get time meta information for frame at rIdx\nvoid cDataMemoryLevel::getTimeMeta(long rIdx, TimeMetaInfo *tm)\n{\n  TimeMetaInfo *cur = tmeta+rIdx;\n  if (tm!=NULL) {\n    tm->cloneFrom(cur);\n    //memcpy( tm, cur, sizeof(TimeMetaInfo) );\n  }\n}\n\n// Note: the memory pointed to by _info is freed upon destruction of the data memory level by the framemeta object!\nint cDataMemoryLevel::setFieldInfo(int i, int _dataType, void *_info, long _infoSize)\n{\n  if ((i>=0)&&(i < fmeta.N)) {\n    if (_dataType >= 0) fmeta.field[i].dataType = _dataType;\n    if (_infoSize >= 0) fmeta.field[i].infoSize = _infoSize;\n    if (_info != NULL) {\n      if (fmeta.field[i].info != NULL) free(fmeta.field[i].info);\n      fmeta.field[i].info = _info;\n    }\n    fmeta.field[i].infoSet = 1;\n    return 1;\n  }\n  return 0;\n}\n\nint cDataMemoryLevel::addField(const char *_name, int lN, int arrNameOffset)\n{\n  if (lcfg.finalised) {\n    SMILE_ERR(2,\"cannot add field '%s' to level '%s' , level is already finalised!\",_name,getName());\n    return 0;\n  }\n  //TODO: check for uniqueness of name!!\n\n  if (fmeta.N >= fmetaNalloc) { //realloc:\n    FieldMetaInfo *f;\n    f = (FieldMetaInfo *)realloc(fmeta.field,sizeof(FieldMetaInfo)*(fmeta.N+LOOKAHEAD_ALLOC));\n    if (f==NULL) OUT_OF_MEMORY;\n    // zero newly allocated data\n    int i;\n    for (i=fmeta.N; i<fmeta.N+LOOKAHEAD_ALLOC; i++) {\n      f[i].name = NULL;\n      f[i].N = 0;\n      f[i].dataType = 0;\n      f[i].info = NULL;\n      f[i].infoSize = 0;\n      f[i].infoSet = 0;\n    }\n    fmeta.field = f;\n    fmetaNalloc = fmeta.N + LOOKAHEAD_ALLOC;\n  }\n  if (lN <= 0) \n    lN = 1;\n  fmeta.field[fmeta.N].N = lN;\n  fmeta.field[fmeta.N].Nstart = lcfg.N;\n  fmeta.field[fmeta.N].name = strdup(_name);\n  fmeta.field[fmeta.N].arrNameOffset = arrNameOffset;\n  fmeta.N++; \n  lcfg.Nf++; \n  fmeta.Ne += lN;\n  lcfg.N += lN;\n    \n  SMILE_DBG(4,\"added field '%s' to level '%s' (size %i).\",_name,getName(),lN);\n  return 1;\n}\n\nvoid cDataMemoryLevel::setArrNameOffset(int arrNameOffset)\n{\n  if ((fmeta.N-1 < fmetaNalloc)&&(fmeta.N-1 >= 0)) {\n    fmeta.field[fmeta.N-1].arrNameOffset = arrNameOffset;\n  }\n}\n\nint cDataMemoryLevel::configureLevel()   // finalize config and allocate data memory\n{\n  /*\n  if (lcfg.blocksizeIsSet) return 1;\n\n  // TODO: what is the actual minimum buffersize, given blocksizeRead and blocksizeWrite??\n  long minBuf;  // = blocksizeRead + 2*blocksizeWrite;\n  if (lcfg.blocksizeReader <= lcfg.blocksizeWriter) {\n    minBuf = 2*lcfg.blocksizeWriter + 1;  // +1 just for safety...\n  } else {\n    minBuf = MAX( 2*lcfg.blocksizeWriter, (lcfg.blocksizeReader/lcfg.blocksizeWriter) * lcfg.blocksizeWriter ) + 1; // +1 just for safety...\n  }\n\n  // adjust level buffersize based on blocksize from write requests...\n  if (lcfg.nT<minBuf) {\n    lcfg.nT = minBuf;\n  }\n\n  lcfg.blocksizeIsSet = 1;\n  */\n    return 1;\n}\n\nint cDataMemoryLevel::finaliseLevel()   // finalize config and allocate data memory\n{\n    //if (lcfg.blocksizeIsSet) return 1;\n  if (lcfg.finalised) return 1;\n\n  // TODO: what is the actual minimum buffersize, given blocksizeRead and blocksizeWrite??\n  long minBuf;  // = blocksizeRead + 2*blocksizeWrite;\n  if (lcfg.blocksizeReader <= lcfg.blocksizeWriter) {\n    minBuf = 2*lcfg.blocksizeWriter + 1;  // +1 just for safety...\n  } else {\n    //minBuf = MAX( 2*lcfg.blocksizeWriter, (lcfg.blocksizeReader/lcfg.blocksizeWriter) * lcfg.blocksizeWriter ) + 1; // +1 just for safety...\n    minBuf = lcfg.blocksizeReader + 2 * lcfg.blocksizeWriter; // +1 just for safety...\n  }\n\n  // adjust level buffersize based on blocksize from write requests...\n  if (lcfg.nT<minBuf) {\n    lcfg.nT = minBuf;\n  }\n\n  lcfg.blocksizeIsSet = 1;\n  \n  //if (lcfg.finalised) return 1;\n\n  if ( (!lcfg.blocksizeIsSet) || (!lcfg.namesAreSet) ) {\n    COMP_ERR(\"cannot finalise level '%s' : blocksizeIsSet=%i, namesAreSet=%i (both should be 1...)\",getName(),lcfg.blocksizeIsSet,lcfg.namesAreSet);\n  }\n\n  // allocate data matrix\n  if ((lcfg.N<=0)||(lcfg.nT<=0)) COMP_ERR(\"cDataMemoryLevel::finaliseLevel: cannot allocate matrix with one (or more) dimensions == 0. did you add fields to this level ['%s']? (N=%i, nT=%i)\",getName(),lcfg.N,lcfg.nT);\n  data = new cMatrix(lcfg.N,lcfg.nT,lcfg.type);\n  if (data==NULL) COMP_ERR(\"cannot allocate level of unknown type %i or out of memory!\",lcfg.type);\n  \n  // allocate tmeta\n  //tmeta = (TimeMetaInfo *)calloc(1,sizeof(TimeMetaInfo) * lcfg.nT);\n  tmeta = new TimeMetaInfo[lcfg.nT]();\n  if (tmeta == NULL) OUT_OF_MEMORY;\n  \n  // initialise mutexes:\n  smileMutexCreate(RWptrMtx);\n  smileMutexCreate(RWmtx);\n  smileMutexCreate(RWstatMtx);\n  \n  lcfg.finalised = 1;\n  return 1;\n}\n\nvoid cDataMemoryLevel::catchupCurR(int rdId, int _curR) \n{\n  smileMutexLock(RWptrMtx);\n  if ((rdId < 0)||(rdId >= nReaders)) { \n    if ((_curR >= 0)&&(_curR <= curW)) curR = _curR;\n    else curR = curW-1;\n    checkCurRr(); // sync new global with readers' indicies\n  } else {\n    if ((_curR >= 0)&&(_curR <= curW)) curRr[rdId] = _curR;\n    else curRr[rdId] = curW-1;\n    checkCurRr(); // sync new readers' indicies with global\n  }\n  smileMutexUnlock(RWptrMtx);\n}\n\n\nint cDataMemoryLevel::setFrame(long vIdx, const cVector *vec, int special)  // id must already be resolved...!\n{\n  if (!lcfg.finalised) { COMP_ERR(\"cannot set frame in non-finalised level! call finalise() first!\"); }\n  if (vec == NULL) {\n    SMILE_ERR(3,\"cannot set frame in dataMemory from a NULL cVector object!\");\n    return 0;\n  }\n\n  if (lcfg.N != vec->N) { COMP_ERR(\"setFrame: cannot set frame in level '%s', framesize mismatch: %i != %i (expected)\",getName(),vec->N,lcfg.N); }\n  if (lcfg.type != vec->type) { COMP_ERR(\"setFrame: frame type mismtach between frame and level (frame=%i, level=%i)\",vec->type,lcfg.type); }\n\n//****** acquire write lock.... *******\n  smileMutexLock(RWstatMtx);\n  // set write request flag, incase the level is currently locked for reading\n  writeReqFlag = 1;\n  smileMutexUnlock(RWstatMtx);\n  smileMutexLock(RWmtx); // get exclusive lock for writing..\n  smileMutexLock(RWstatMtx);\n  writeReqFlag = 0;\n  smileMutexUnlock(RWstatMtx);\n//****************\n\n  smileMutexLock(RWptrMtx);\n#ifdef DM_DEBUG_LOGGER\n  long vIdx0=vIdx;\n#endif\n  long rIdx = validateIdxW(&vIdx,special);\n#ifdef DM_DEBUG_LOGGER\n  // logging in setFrame:\n  datamemoryLogger(this->lcfg.name, vIdx0, vIdx, rIdx, lcfg.nT, special, this->curR, this->curW, this->EOI, this->nReaders, this->curRr, vec);\n#endif\n  smileMutexUnlock(RWptrMtx);\n  \n  int ret = 0;\n  if (rIdx>=0) {\n    if (lcfg.type == DMEM_FLOAT) frameWr(rIdx, vec->dataF);\n    else if (lcfg.type == DMEM_INT)   frameWr(rIdx, vec->dataI);\n    setTimeMeta(rIdx,vIdx,vec->tmeta);\n    //setMetaData(rIdx,vIdx,vec->metadata);\n    ret= 1;\n  } else {\n    SMILE_ERR(4,\"setFrame: frame index (vIdx %i -> rIdx %i) out of range, frame was not set (level '%s')!\",vIdx,rIdx,getName());\n  }\n\n  smileMutexUnlock(RWmtx);\n  return ret;\n}\n\nint cDataMemoryLevel::setMatrix(long vIdx, const cMatrix *mat, int special)  // id must already be resolved...!\n{\n  if (!lcfg.finalised) { COMP_ERR(\"cannot set matrix in non-finalised level '%s'! call finalise() first!\",getName()); }\n  if (mat == NULL) {\n    SMILE_ERR(3,\"cannot set frame in dataMemory from a NULL cMatrix object!\");\n    return 0;\n  }\n\n  if (lcfg.N != mat->N) { COMP_ERR(\"setMatrix: cannot set frames in level '%s', framesize mismatch: %i != %i (expected)\",getName(),mat->N,lcfg.N); }\n  if (lcfg.type != mat->type) { COMP_ERR(\"setMatrix: frame type mismtach between frame and level (frame=%i, level=%i)\",mat->type,lcfg.type); }\n\n//****** acquire write lock.... *******\n  smileMutexLock(RWstatMtx);\n  // set write request flag, incase the level is currently locked for reading\n  writeReqFlag = 1;\n  smileMutexUnlock(RWstatMtx);\n  smileMutexLock(RWmtx); // get exclusive lock for writing..\n  smileMutexLock(RWstatMtx);\n  writeReqFlag = 0;\n  smileMutexUnlock(RWstatMtx);\n//****************\n\n  // validate start index\n  smileMutexLock(RWptrMtx);\n  long rIdx = validateIdxRangeW(&vIdx,vIdx+mat->nT,special);\n  smileMutexUnlock(RWptrMtx);\n\n  int ret = 0;\n  if (rIdx>=0) {\n    long i;\n   /* double smileTm = -1.0;\n    if (_parent != NULL) {\n      cComponentManager * cm = (cComponentManager *)_parent->getCompMan();\n      if (cm != NULL) {\n        smileTm = cm->getSmileTime();\n      }\n    }\n    */\n\n    if (lcfg.type == DMEM_FLOAT) for (i=0; i<mat->nT; i++) { \n      /*if (((mat->tmeta+i)->noAutoSmileTime)) {\n        //(mat->tmeta + i)->smileTime = -1.0;\n        printf(\"XXXXXXXXXXXXXXXx clear.... %i\\n\",(mat->tmeta+i)->noAutoSmileTime);\n      }*/\n      //if (!noAutoSmileTime || (mat->tmeta + i)->smileTime == -1.0 ) (mat->tmeta + i)->smileTime = smileTm;\n      frameWr((rIdx+i)%lcfg.nT, mat->dataF + i*lcfg.N); setTimeMeta((rIdx+i)%lcfg.nT,vIdx+i,mat->tmeta + i ); \n    }\n    else if (lcfg.type == DMEM_INT) for (i=0; i<mat->nT; i++) { \n      if (!((mat->tmeta+i)->noAutoSmileTime)) (mat->tmeta + i)->smileTime = -1.0;\n      //if (!noAutoSmileTime || (mat->tmeta + i)->smileTime == -1.0 ) (mat->tmeta + i)->smileTime = smileTm;\n      frameWr((rIdx+i)%lcfg.nT, mat->dataI + i*lcfg.N); setTimeMeta((rIdx+i)%lcfg.nT,vIdx+i,mat->tmeta + i);\n    }\n    ret = 1;\n  } else {\n    SMILE_DBG(4,\"ERROR, setMatrix: frame index range (vIdxStart %i - vIdxEnd %i  => rIdxStart %i) out of range, frame was not set (level '%s')!\",vIdx,vIdx+mat->nT,rIdx,getName());\n  }\n\n  smileMutexUnlock(RWmtx);\n  return ret;\n}\n\n\n//TODO: implement concealment strategies, when frames are not available (also report concealment method to caller)\n//    for vector: return 0'ed frame instead of NULL pointer\n//                return last available frame (beginning / end)\n//    for matrix: return NULL pointer if complete matrix is out of range\n//                fill partially (!) missing frames with 0es\n//                repeat first/last possible frames...\n\n// NOTE: caller must free the returned vector!!\ncVector * cDataMemoryLevel::getFrame(long vIdx, int special, int rdId, int *result)\n{\n  if (!lcfg.finalised) { COMP_ERR(\"cannot get frame from non-finalised level '%s'! call finalise() first!\",getName()); }\n\n//****** acquire read lock.... *******\n  smileMutexLock(RWstatMtx);\n  // check for urgent write request:\n  while (writeReqFlag) { // wait until write request has been served!\n    smileMutexUnlock(RWstatMtx);\n//    usleep(1000);\n    smileYield();\n    smileMutexLock(RWstatMtx);\n  }\n  if (nCurRdr == 0) {\n    nCurRdr++;\n    smileMutexUnlock(RWstatMtx);\n    smileMutexLock(RWmtx); // no other readers, so lock mutex to exclude writes...\n    smileMutexLock(RWstatMtx);\n  } else {\n    nCurRdr++;\n  }\n//      nCurRdr++;\n  smileMutexUnlock(RWstatMtx);\n//****************\n\n  smileMutexLock(RWptrMtx);\n  long rIdx = validateIdxR(&vIdx,special,rdId);\n  smileMutexUnlock(RWptrMtx);\n\n  cVector *vec=NULL;\n  if (rIdx>=0) {\n    vec = new cVector(lcfg.N,lcfg.type);\n    if (vec == NULL) OUT_OF_MEMORY;\n    if (lcfg.type == DMEM_FLOAT) frameRd(rIdx, vec->dataF);\n    else if (lcfg.type == DMEM_INT) frameRd(rIdx, vec->dataI);\n    getTimeMeta(rIdx,vec->tmeta);\n    vec->fmeta = &(fmeta);\n    if (result!=NULL) *result=DMRES_OK;\n  } else {\n    SMILE_DBG(4,\"getFrame: frame index (vIdx %i -> rIdx %i) out of range, frame cannot be read (level '%s')!\",vIdx,rIdx,getName());\n    if (result!=NULL) {\n      if (rIdx == -2) *result=DMRES_OORleft|DMRES_ERR;\n      else if (rIdx == -3) *result=DMRES_OORright|DMRES_ERR;\n      else if (rIdx == -4) *result=DMRES_OORbs|DMRES_ERR;\n      else *result=DMRES_ERR;\n    }\n  }\n\n  //**** now unlock ******\n  smileMutexLock(RWstatMtx);\n  nCurRdr--;\n  if (nCurRdr < 0) { // ERROR!!\n    SMILE_ERR(1,\"nCurRdr < 0  while unlocking dataMemory!! This is a BUG!!!\");\n    nCurRdr = 0;\n  }\n  if (nCurRdr==0) smileMutexUnlock(RWmtx);\n  smileMutexUnlock(RWstatMtx);\n  //********************\n\n  return vec;\n}\n\n//TODO: add an optimized 'simple' level for high performance and low overhead wave handling\n//  no tmeta, very simple access functions etc.\n//  tmeta if accessed will be emultated?\ncMatrix * cDataMemoryLevel::getMatrix(long vIdx, long vIdxEnd, int special, int rdId, int *result)\n{\n  if (!lcfg.finalised) { COMP_ERR(\"cannot get matrix from non-finalised level! call finalise() first!\"); }\n\n  long vIdxold=vIdx;\n//  long vIdxEndO = vIdxEnd;\n  if (vIdx < 0) vIdx = 0;\n  int padEnd = 0; // will be filled with the number of samples at the end of the matrix to be padded\n\n//****** acquire read lock.... *******\n  smileMutexLock(RWstatMtx);\n  // check for urgent write request:\n  while (writeReqFlag) { // wait until write request has been served!\n    smileMutexUnlock(RWstatMtx);\n    smileYield();\n    smileMutexLock(RWstatMtx);\n  }\n  if (nCurRdr == 0) {\n    nCurRdr++;\n    smileMutexUnlock(RWstatMtx);\n    smileMutexLock(RWmtx); // no other readers, so lock mutex to exclude writes...\n    smileMutexLock(RWstatMtx);\n  } else {\n    nCurRdr++;\n  }\n  smileMutexUnlock(RWstatMtx);\n//****************\n\n  smileMutexLock(RWptrMtx);\n  long rIdx = validateIdxRangeR(vIdxold, &vIdx, vIdxEnd, special, rdId, 0, &padEnd);  // TODO : if EOI state, then allow vIdxEnd out of range! pad frame...\n  smileMutexUnlock(RWptrMtx);\n\n  cMatrix *mat=NULL;\n  if (rIdx>=0) {\n    if (vIdxold < 0) mat = new cMatrix(lcfg.N,vIdxEnd-vIdxold,lcfg.type);\n    else mat = new cMatrix(lcfg.N,vIdxEnd-vIdx,lcfg.type);\n    SMILE_DBG(4,\"creating new data matrix (%s)  vIdxold=%i , vIdx=%i, vIdxEnd=%i, lcfg.N=%i\",this->getName(),vIdxold,vIdx,vIdxEnd,lcfg.N)\n    if (mat == NULL) OUT_OF_MEMORY;\n    long i,j;\n    if (vIdxold < 0) {\n      long i0 = 0-vIdxold;\n      if (lcfg.type == DMEM_FLOAT) {\n        for (i=0; i<i0; i++) {\n          if (special == DMEM_PAD_ZERO) for (j=0; j<mat->N; j++) mat->dataF[i*lcfg.N+j] = 0.0; // pad with value\n          else frameRd((rIdx)%lcfg.nT, mat->dataF + (i*lcfg.N)); // fill with first frame\n          getTimeMeta((rIdx)%lcfg.nT,mat->tmeta + i);\n        }\n        for (i=0; i<vIdxEnd; i++) { frameRd((rIdx+i)%lcfg.nT, mat->dataF + (i+i0)*lcfg.N); getTimeMeta((rIdx+i)%lcfg.nT,mat->tmeta + i +i0); }\n      } else if (lcfg.type == DMEM_INT) {\n        for (i=0; i<i0; i++) {\n          if (special == DMEM_PAD_ZERO) for (j=0; j<mat->N; j++) mat->dataI[i*lcfg.N+j] = 0; // pad with value\n          else frameRd((rIdx)%lcfg.nT, mat->dataI + (i*lcfg.N)); // fill with first frame\n          getTimeMeta((rIdx)%lcfg.nT,mat->tmeta + i);\n        }\n        for (i=0; i<vIdxEnd; i++) { frameRd((rIdx+i)%lcfg.nT, mat->dataI + (i+i0)*lcfg.N); getTimeMeta((rIdx+i)%lcfg.nT,mat->tmeta + i +i0); }\n      }\n    } else if (padEnd>0) {\n      if (lcfg.type == DMEM_FLOAT) {\n        for (i=0; i<(vIdxEnd-vIdx)-padEnd; i++) { frameRd((rIdx+i)%lcfg.nT, mat->dataF + (i*lcfg.N)); getTimeMeta((rIdx+i)%lcfg.nT,mat->tmeta + i); }\n        long i0 = i-1;\n        for (; i<(vIdxEnd-vIdx); i++) {\n          if (special == DMEM_PAD_ZERO) for (j=0; j<mat->N; j++) mat->dataF[i*lcfg.N+j] = 0.0; // pad with value\n          else frameRd((rIdx+i0)%lcfg.nT, mat->dataF + (i*lcfg.N)); // fill with last frame\n          getTimeMeta((rIdx+i0)%lcfg.nT,mat->tmeta + i);\n        }\n        // TODO: Test DMEM_PAD_NONE option to truncate the frame!!\n        if (special == DMEM_PAD_NONE) {\n          mat->nT = (vIdxEnd-vIdx)-padEnd;\n        }\n      } else if (lcfg.type == DMEM_INT) {\n        for (i=0; i<(vIdxEnd-vIdx)-padEnd; i++) { frameRd((rIdx+i)%lcfg.nT, mat->dataI + (i*lcfg.N)); getTimeMeta((rIdx+i)%lcfg.nT,mat->tmeta + i); }\n        long i0 = i-1;\n        for (; i<(vIdxEnd-vIdx); i++) {\n          if (special == DMEM_PAD_ZERO) for (j=0; j<mat->N; j++) mat->dataI[i*lcfg.N+j] = 0; // pad with value\n          else frameRd((rIdx+i0)%lcfg.nT, mat->dataI + (i*lcfg.N)); // fill with last frame\n          getTimeMeta((rIdx+i0)%lcfg.nT,mat->tmeta + i);\n        }\n        // TODO: Test DMEM_PAD_NONE option to truncate the frame!!\n        if (special == DMEM_PAD_NONE) {\n          mat->nT = (vIdxEnd-vIdx)-padEnd;\n        }\n      }\n\n    } else {\n      if (lcfg.type == DMEM_FLOAT) {\n        for (i=0; i<mat->nT; i++) {\n          frameRd((rIdx+i)%lcfg.nT, mat->dataF + i*lcfg.N);\n          getTimeMeta((rIdx+i)%lcfg.nT,mat->tmeta + i);\n        }\n      }\n      else if (lcfg.type == DMEM_INT) {\n        for (i=0; i<mat->nT; i++) {\n          frameRd((rIdx+i)%lcfg.nT, mat->dataI + i*lcfg.N);\n          getTimeMeta((rIdx+i)%lcfg.nT,mat->tmeta + i);\n        }\n      }\n    }\n    mat->fmeta = &(fmeta);\n  } else {\n    SMILE_DBG(4,\"ERROR, getMatrix: frame index range (vIdxStart %i - vIdxEnd %i  => rIdxStart %i) out of range, matrix cannot be read (level '%s')!\",vIdx,vIdxEnd,rIdx,getName());\n  }\n  \n  //**** now unlock ******\n  smileMutexLock(RWstatMtx);\n  nCurRdr--;\n  if (nCurRdr < 0) { // ERROR!!\n    SMILE_ERR(1,\"nCurRdr < 0  while unlocking dataMemory!! This is a BUG!!!\");\n    nCurRdr = 0;\n  }\n  if (nCurRdr==0) smileMutexUnlock(RWmtx);\n  smileMutexUnlock(RWstatMtx);\n  //********************\n  \n  return mat;\n}\n\n// methods to get info about current level fill status (e.g. number of frames written, curW, curR(global) and freeSpace, etc.)\nlong cDataMemoryLevel::getMaxR() \n{ \n  smileMutexLock(RWptrMtx);\n  long res = curW-1;\n  smileMutexUnlock(RWptrMtx);\n  return res;\n}\n\nlong cDataMemoryLevel::getMinR() {  // minimum readable index (relevant only for ringbuffers, otherwise it will always return 0)\n  long res=0;\n  if (lcfg.isRb) {\n    smileMutexLock(RWptrMtx);\n    if (curW > lcfg.nT)\n      res = curW-lcfg.nT;\n    smileMutexUnlock(RWptrMtx);\n  }\n  return res;\n}\n\n// functions to convert absolute times (in seconds) to level frame indicies!\nlong cDataMemoryLevel::secToVidx(double sec) { // returns a vIdx\n   //(for periodic levels this function is easy, however for aperiodic levels we must iterate through all frames... maybe also for periodic to compensate round-off errors?)\n  if (lcfg.T!=0.0) {\n    return (long)round(sec/lcfg.T);\n  } else {\n    SMILE_WRN(0,\"cDataMemoryLevel::secToVidx: NOT YET IMPLEMENTED for variable period levels!\");\n  }\n  return 0;\n}\n\ndouble cDataMemoryLevel::vIdxToSec(long vIdx) { // returns a vIdx\n   //(for periodic levels this function is easy, however for aperiodic levels we must iterate through all frames... maybe also for periodic to compensate round-off errors?)\n  if (lcfg.T!=0.0) {\n    return ((double)(vIdx))*lcfg.T;\n  } else {\n    SMILE_WRN(0,\"cDataMemoryLevel::vIdxToSec: NOT YET IMPLEMENTED for variable period levels!\");\n  }\n  return 0;\n}\n\n/***************************** dataMemory ***********************************************/\n\n\nvoid cDataMemory::_addLevel()\n{\n  nLevels++;\n  if (nLevels>=nLevelsAlloc) {\n    int lN = nLevels+LOOKAHEAD_ALLOC;\n    cDataMemoryLevel **l = (cDataMemoryLevel **)realloc(level,sizeof(cDataMemoryLevel *)*lN);\n    if (l==NULL) OUT_OF_MEMORY;\n    // initialize newly allocated memory with NULL\n    int i;\n    for (i=nLevels; i<lN; i++) l[i] = NULL;\n    level = l;\n    nLevelsAlloc=lN;\n  }\n}\n\n\nint cDataMemory::registerLevel(cDataMemoryLevel *l)\n{\n  if (l!=NULL) {\n    _addLevel();\n    level[nLevels] = l;\n    return nLevels;\n  } else { SMILE_WRN(1,\"attempt to register NULL level with dataMemory!\"); return -1; }\n}\n\n// get element id of level 'name', return -1 on failure (e.g. level not found)\nint cDataMemory::findLevel(const char *name)\n{\n  int i;\n  if (name==NULL) return -1;\n  \n  for (i=0; i<=nLevels; i++) {\n    if(!strcmp(name,level[i]->getName())) return i;\n  }\n  return -1;\n}\n\n\n// get element id of level 'name', return -1 on failure (e.g. level not found)\n// finalise the level, if found\nint cDataMemory::finaliseLevel(const char *name)\n{\n  int i = findLevel(name);\n  if (i>=0) {\n    level[i]->finaliseLevel();\n  }\n  return i;\n}\n\n// finalise level n\nint cDataMemory::finaliseLevel(int n)\n{\n  if ((n>=0)&&(n<=nLevels)) {\n    level[n]->finaliseLevel();\n    return 1;\n  }\n  return 0;\n}\n\n\nvoid cDataMemory::registerReadRequest(const char *lvl, const char *componentInstName)\n{\n  if (lvl == NULL) return;\n\n  // find existing request\n  int idx = rrq.findRequest(lvl, componentInstName);\n  // do nothing if this request was already registered!\n  if (idx) return;\n\n  // if lvl has not yet been registered, get pointer to next empty element in list:\n  sDmLevelRWRequest *rq = rrq.getElement();\n  if (rq!=NULL) {\n    rq->instanceName = componentInstName;\n    rq->levelName = lvl;\n  }\n\n  SMILE_DBG(2,\"registerReadRequest: registered read request for level '%s' by component instance '%s'\",lvl,componentInstName);\n}\n\nvoid cDataMemory::registerWriteRequest(const char *lvl, const char *componentInstName)\n{\n  if (lvl == NULL) return;\n\n  // find existing request\n  int idx = wrq.findRequest(lvl, NULL);\n  // check if the same component attempts to register twice (which is ok), or if two components want to write to the same level!!\n  if (idx) {\n    sDmLevelRWRequest *rq = wrq.getElement(idx-1);\n    if ((rq!=NULL)&&(!strcmp(rq->instanceName,componentInstName))) {\n      return;  // ignore duplicate request from the same component\n    } else {\n      // it's likely another component wanting to write to the same level...\n      COMP_ERR(\"two components cannot write to the same level: '%s', component1='%s', component2='%s'\",lvl,rq->instanceName,componentInstName);\n    }\n  }\n\n  // if lvl has not yet been registered, get pointer to next empty element in list:\n  sDmLevelRWRequest *rq = wrq.getElement();\n  if (rq!=NULL) {\n    rq->instanceName = componentInstName;\n    rq->levelName = lvl;\n  }\n\n  SMILE_DBG(2,\"registerWriteRequest: registered write request for level '%s' by component instance '%s'\",lvl,componentInstName);\n}\n\n/* add a new level with given _lcfg parameters */\nint cDataMemory::addLevel(sDmLevelConfig *_lcfg, const char *_name)\n{\n  if (_lcfg == NULL) return 0;\n\n  if (_name != NULL) {\n    _lcfg->setName(_name);\n  }\n\n  cDataMemoryLevel *l = new cDataMemoryLevel(-1, *_lcfg );\n  if (l==NULL) OUT_OF_MEMORY;\n  l->setParent( (cDataMemory*)this );\n  return registerLevel(l);\n}\n\n/*\nint cDataMemory::registerWriteRequest(const char *lvl, const char *componentInstName)\n{\n  int ret=-1;\n  if (lvl == NULL) return ret;\n  int i; int ex=-1;\n  // find existing:\n  for (i=0; i<nRRq; i++) {\n    if (!strcmp(lvl, writeReq[i].name)) {\n      ex = i;\n      SMILE_ERR(2,\"multiple write requests for level '%s' registered! only one writer should write to each level!\",lvl);\n      return ret;\n    }\n  }\n  if (nWRq >= nWRqAlloc) {\n    sDmLevelConfig *tmp = (sDmLevelConfig *)crealloc(writeReq, sizeof(sDmLevelConfig)*(nWRq+LOOKAHEAD_ALLOC), sizeof(sDmLevelConfig)*nWRqAlloc);\n    if (tmp==NULL) OUT_OF_MEMORY;\n    writeReq = tmp;\n    nWRqAlloc = (nWRq+LOOKAHEAD_ALLOC);\n  }\n\n    memcpy(writeReq+nWRq, &cfg, sizeof(sDmLevelConfig));\n    writeReq[nWRq].name = strdup(lvl);\n    SMILE_DBG(2,\"registerWriteRequest: registered write request for level '%s' (rq-idx %i)\",lvl,nWRq);\n    // create level:\n    cDataMemoryLevel *l = new cDataMemoryLevel(-1, writeReq[nWRq] );\n*/\n\n/*\n    if ((writeReq[nWRq].T != 0.0)&&(writeReq[nWRq].lenSec > 0.0)) {\n      l = new cDataMemoryLevel(-1, writeReq[nWRq].name, writeReq[nWRq].lenSec, writeReq[nWRq].T,\n                                   writeReq[nWRq].isRb, writeReq[nWRq].growDyn, writeReq[nWRq].type );\n    } else {\n\n\n      l = new cDataMemoryLevel(-1, writeReq[nWRq].name, writeReq[nWRq].nT,\n                                   writeReq[nWRq].isRb, writeReq[nWRq].growDyn, writeReq[nWRq].type );\n    }\n    */\n/*\n    if (l==NULL) OUT_OF_MEMORY;\n    l->setParent( (cDataMemory*)this );\n    ret = registerLevel(l);\n    SMILE_DBG(4,\"registerWriteRequest: created level '%s' and registered object with dataMemory object '%s'\",lvl,getInstName());\n    nWRq++;\n  //}\n  return ret;\n}\n*/\n\n\nint cDataMemory::myRegisterInstance(int *runMe)\n{\n  int i;\n\n  // check if a write request exists for each level where there exists a read request\n  int err=0;\n  for (i=0; i<rrq.getNEl(); i++) {\n    sDmLevelRWRequest * x = rrq.getElement(i);\n    if (x!=NULL) {\n      int idx = wrq.findRequest(x->levelName, NULL);\n      if (!idx) {\n        SMILE_ERR(1,\"level '%s' was not found! component '%s' requires it for reading.\\n     it seems that no dataWriter has registered this level! check your config!\",x->levelName,x->instanceName);\n        err=1;\n      }\n    }\n  }\n  if (err) { COMP_ERR(\"there were unresolved read-requests, please check your config file for missing components /  missing dataWriters or incorrect level names (typos, etc.) !\"); }\n\n  if (runMe != NULL) *runMe = 0;\n\n  return !err;\n}\n\nint cDataMemory::myConfigureInstance() \n{\n  // check blocksizeconfig and update buffersizes of levels accordingly\n  if (nLevels>=0) {\n    int i;\n    for (i=0; i<=nLevels; i++) {\n      // do this for each level...\n      SMILE_IDBG(3,\"configuring level %i ('%s') (checking buffersize and config)\",i,level[i]->getName());\n      int ret = level[i]->configureLevel();\n      if (!ret) {\n        SMILE_IERR(1,\"level '%s' could not be configured!\");\n        return 0;\n      }\n    }\n  } else {\n    SMILE_ERR(1,\"it makes no sense to configure a dataMemory without levels! cannot configure dataMemory '%s'!\",getInstName());\n    return 0;\n  }\n\n  return 1;\n}\n\nint cDataMemory::myFinaliseInstance()\n{\n  // now finalise the levels (allocate storage memory and finalise config):\n  if (nLevels>=0) {\n    int i;\n    for (i=0; i<=nLevels; i++) {\n      // actually finalise now\n      SMILE_DBG(3,\"finalising level %i (allocating buffer, etc.)\",i);\n      int ret = level[i]->finaliseLevel();\n      if (!ret) {\n        SMILE_IERR(1,\"level '%s' could not be finalised!\");\n        return 0;\n      }\n    }\n    // allocate reader config array\n    SMILE_DBG(4,\"allocating reader positions in %i level(s)\",nLevels+1);\n    for (i=0; i<=nLevels; i++) {\n      level[i]->allocReaders();\n    }\n  } else {\n    SMILE_ERR(1,\"it makes no sense to finalise a dataMemory without levels! cannot finalise dataMemory '%s'!\",getInstName());\n    return 0;\n  }\n  return 1;\n}\n\ncDataMemory::~cDataMemory() {\n  int i;\n  if (level != NULL) {\n    for (i=0; i<nLevelsAlloc; i++) {\n      if(level[i] != NULL) delete level[i];\n    }\n    free(level);\n  }\n}\n\n/****************** data memory logger functions ***************************/\n\n/*\nThese functions can be used for debugging the data flow. they log every read, write, and check operation, thus producing a lot of data.\n\nLog message fields:\n-level\n(-component?)\n-read/write/check\n-write/read/check counter\n-vIdx\n(-rIdx?)\n-length\n-curR\n-curW\n-nT\n-DATA\n*/\n\n\n\nvoid datamemoryLogger(const char *name, const char*dir, long cnt, long vIdx0, long vIdx, long rIdx, long nT, int special, long curR, long curW, long EOI, int nReaders, long *curRr, cVector *vec)\n{\n#ifdef DM_DEBUG_LOGGER\n  long i;\n  fprintf(stderr,\"xxDMemLOGxx:: level:%s dir:%s cnt:%i vIdx0:%i vIdx:%i rIdx:%i nT:%i special:%i EOI:%i curR:%i curW:%i :: nReaders:%i \",name,dir,cnt,vIdx0,vIdx,rIdx,nT,special,EOI,curR,curW,nReaders);\n  for (i=0; i<nReaders; i++) {\n    fprintf(stderr,\"curRr%i:%i \",i,curRr[i]);\n  }\n  fprintf(stderr,\"::: DATA(%i) ::: \",vec->N);\n  for (i=0; i<vec->N; i++) {\n    fprintf(stderr,\"f%i:%i \",i,vec->dataF[i]);\n  }\n  fprintf(stderr,\"::END\\n\");\n#endif\n}\n\nvoid datamemoryLogger(const char *name, long vIdx0, long vIdx, long rIdx, long nT, int special, long curR, long curW, long EOI, int nReaders, long *curRr, cMatrix *mat)\n{\n#ifdef DM_DEBUG_LOGGER\n  long i,j;\n  fprintf(stderr,\"xxDMemLOGxx:: level:%s dir:%s cnt:%i vIdx0:%i vIdx:%i rIdx:%i nT:%i special:%i EOI:%i curR:%i curW:%i :: nReaders:%i \",name,dir,cnt,vIdx0,vIdx,rIdx,nT,special,EOI,curR,curW,nReaders);\n  for (i=0; i<nReaders; i++) {\n    fprintf(stderr,\"curRr%i:%i \",i,curRr[i]);\n  }\n  fprintf(stderr,\"::: DATA[%ix%i] ::: \",vec->N,vec->nT); // row x column\n  for (j=0; j<vec->nT; j++) {\n    for (i=0; i<vec->N; i++) {\n      fprintf(stderr,\"f%i,%i:%i \",i,j,vec->dataF[i+j*vec->N]);  // row, column\n    }\n    if (j<vec->nT-1) fprintf(stderr,\":: \");\n  }\n  fprintf(stderr,\"::END\\n\");\n#endif\n}\n\n\n\n\n\n\n\n"
  },
  {
    "path": "src/core/dataProcessor.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\ndataProcessor\nwrite data to data memory...\n\n*/\n\n\n#include <core/dataProcessor.hpp>\n\n#define MODULE \"cDataProcessor\"\n\nSMILECOMPONENT_STATICS(cDataProcessor)\n\nSMILECOMPONENT_REGCOMP(cDataProcessor)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CDATAPROCESSOR;\n  sdescription = COMPONENT_DESCRIPTION_CDATAPROCESSOR;\n\n  // configure your component's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n  if (ct->setField(\"reader\", \"The configuration of the cDataReader subcomponent, which handles the dataMemory interface for data input\",\n                  sconfman->getTypeObj(\"cDataReader\"), NO_ARRAY, DONT_FREE) == -1) {\n     rA=1; // if subtype not yet found, request , re-register in the next iteration\n  }\n  if (ct->setField(\"writer\", \"The configuration of the cDataWriter subcomponent, which handles the dataMemory interface for data output\",\n                  sconfman->getTypeObj(\"cDataWriter\"), NO_ARRAY, DONT_FREE) == -1) {\n     rA=1; // if subtype not yet found, request , re-register in the next iteration\n  }\n\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"buffersize\", \"The buffer size for the output level in frames (default [0] = same as input level), this option overwrites 'buffersize_sec'\", 0,0,0);\n    ct->setField(\"buffersize_sec\", \"The buffer size for the output level in seconds (default [0] = same as input level)\", 0);\n    ct->setField(\"blocksize\", \"The size of data blocks to process in frames (this sets both blocksizeR and blocksizeW, and overwrites blocksize_sec)\", 0,0,0);\n    ct->setField(\"blocksizeR\", \"The size of data blocks to read in frames (overwrites blocksize)\", 0,0,0);\n    ct->setField(\"blocksizeW\", \"The size of data blocks to write in frames (overwrites blocksize)\", 0,0,0);\n    ct->setField(\"blocksize_sec\", \"size of data blocks to process in seconds (this sets both blocksizeR_sec and blocksizeW_sec)\", 0.0);\n    ct->setField(\"blocksizeR_sec\", \"size of data blocks to read in seconds (overwrites blocksize_sec!)\", 0.0,0,0);\n    ct->setField(\"blocksizeW_sec\", \"size of data blocks to write in seconds (overwrites blocksize_sec!)\", 0.0,0,0);\n\n    ct->setField(\"nameAppend\", \"A string suffix to append to the input field names (default: empty)\", (const char*)NULL);\n    ct->setField(\"copyInputName\", \"1 = copy the input name (and optionally append a suffix, see 'nameAppend' option), 0 = discard the input name and use only the 'nameAppend' string as new name.\", 1);\n    ct->setField(\"EOIlevel\", \"set the EOI counter threshold at which to act in EOI mode (for full input processing). Required e.g. for multi-level EOI chains to avoid running full input functionals/windows on incomplete first EOI iteration data.\", 0);\n  )\n  \n  SMILECOMPONENT_MAKEINFO_ABSTRACT(cDataProcessor);\n}\n\nSMILECOMPONENT_CREATE_ABSTRACT(cDataProcessor)\n\n//-----\n\ncDataProcessor::cDataProcessor(const char *_name) :\n  cSmileComponent(_name),\n  writer_(NULL),\n  reader_(NULL),\n  namesAreSet_(0),\n  buffersize_sec_(0.0),\n  blocksizeR_sec_(0.0), blocksizeW_sec_(0.0),\n  buffersize_(0),\n  blocksizeR_(0), blocksizeW_(0),\n  nameAppend_(NULL),\n  copyInputName_(0),\n  nInput_(0), inputStart_(0), inputName_(NULL)\n{\n  // create the child instances, reader and writer\n  char *tmp = myvprint(\"%s.reader\",getInstName());\n  reader_ = (cDataReader *)(cDataReader::create(tmp));\n  if (reader_ == NULL) {\n    COMP_ERR(\"Error creating dataReader '%s'\",tmp);\n  }\n  if (tmp!=NULL) free(tmp);\n\n  tmp = myvprint(\"%s.writer\",getInstName());\n  writer_ = (cDataWriter *)(cDataWriter::create(tmp));\n  if (writer_ == NULL) {\n    COMP_ERR(\"Error creating dataWriter '%s'\",tmp);\n  }\n  if (tmp!=NULL) free(tmp);\n\n  //( TODO: configure dateWriter level according to (descending priority)\n  //   1. dataReader level clone\n  //   2. application code (based on info from dataReader level)\n  //   3. config file )\n}\n\nvoid cDataProcessor::fetchConfig()\n{\n  buffersize_sec_ = getDouble(\"buffersize_sec\");\n  SMILE_IDBG(2,\"buffersize (sec.) = %f\",buffersize_sec_);\n  buffersize_ = getInt(\"buffersize\");\n  SMILE_IDBG(2,\"buffersize (frames.) = %i\",buffersize_);\n  double blocksize_sec = getDouble(\"blocksize_sec\");\n  blocksizeR_sec_ = blocksizeW_sec_ = blocksize_sec;\n  if ( (blocksizeR_sec_ <= 0.0) || (isSet(\"blocksizeR_sec\")) ) {\n    blocksizeR_sec_ = getDouble(\"blocksizeR_sec\");\n  }\n  if ( (blocksizeW_sec_ <= 0.0) || (isSet(\"blocksizeW_sec\")) ) {\n    blocksizeW_sec_ = getDouble(\"blocksizeW_sec\");\n  }\n  SMILE_IDBG(2,\"blocksizeR (sec.) = %f\",blocksizeR_sec_);\n  SMILE_IDBG(2,\"blocksizeW (sec.) = %f\",blocksizeW_sec_);\n  long blocksize = getInt(\"blocksize\");\n  blocksizeR_ = blocksizeW_ = blocksize;\n  if ( (blocksizeR_ <= 0) || (isSet(\"blocksizeR\")) ) {\n    blocksizeR_ = getInt(\"blocksizeR\");\n  }\n  if ( (blocksizeW_ <= 0) || (isSet(\"blocksizeW\")) ) {\n    blocksizeW_ = getInt(\"blocksizeW\");\n  }\n  SMILE_IDBG(2,\"blocksizeR (frames, from config only) = %i\",blocksizeR_);\n  SMILE_IDBG(2,\"blocksizeW (frames, from config only) = %i\",blocksizeW_);\n  nameAppend_ = getStr(\"nameAppend\");\n  if (nameAppend_ != NULL) { SMILE_IDBG(2,\"nameAppend = '%s'\",nameAppend_); }\n  copyInputName_ = getInt(\"copyInputName\");\n  SMILE_IDBG(2,\"copyInputName = %i\",copyInputName_);\n}\n\nvoid cDataProcessor::mySetEnvironment()\n{\n  writer_->setComponentEnvironment(getCompMan(), -1, this);\n  reader_->setComponentEnvironment(getCompMan(), -1, this);\n}\n\n/* register both read and write request, order is arbitrary */\n// TODO: *runMe config... ? from config file... or from a custom hook for base classes\nint cDataProcessor::myRegisterInstance(int *runMe)\n{\n  int ret = 1;\n  ret *= reader_->registerInstance();\n  ret *= writer_->registerInstance();\n  if ((ret)&&(runMe!=NULL)) {\n    // call runMe config hook\n    *runMe = runMeConfig();\n  }\n  return ret;\n}\n\nint cDataProcessor::configureReader(const sDmLevelConfig &c)\n{ \n  int EOIlevel = getInt(\"EOIlevel\");\n  setEOIlevel(EOIlevel);\n  reader_->setEOIlevel(EOIlevel);\n  writer_->setEOIlevel(EOIlevel);\n  reader_->setBlocksize(blocksizeR_);\n  return 1; \n}\n\n// Configures both reader and writer.\n// Here, the reader has to be configured first, in order to be able to auto configure the writer\n//  based on the input level parameters.\nint cDataProcessor::myConfigureInstance()\n{\n  if (!(reader_->configureInstance())) return 0;\n  // finalise the reader first. this makes sure that the names in the input level are set up correctly\n  if (!(reader_->finaliseInstance())) return 0;\n\n  // allow derived class to configure the writer AFTER the reader config is available\n  // if the derived class returns 1, we will continue\n  const sDmLevelConfig *c = reader_->getConfig();\n  if (c==NULL) COMP_ERR(\"myConfigureInstance: Error getting reader dmLevel config! returned sDmLevelConfig = NULL!\");\n\n  // now copy config so that we can safely modify it...\n  sDmLevelConfig c2(*c);\n\n  // convert blocksize options, so all options are accessible, if possible:\n  // 1. blocksize values in frames override those in seconds:\n  // 2. now do the inverse...\n  if (blocksizeW_ > 0) {\n    blocksizeW_sec_ = (double)blocksizeW_ * c2.T;\n  } else if ((blocksizeW_sec_ > 0.0)&&(c2.T != 0.0)) {\n    blocksizeW_ = (long) ceil (blocksizeW_sec_ / c2.T);\n  }\n\n  if (blocksizeR_ > 0) {\n    blocksizeR_sec_ = (double)blocksizeR_ * c2.T;\n  } else if ((blocksizeR_sec_ > 0.0)&&(c2.T != 0.0)) {\n    blocksizeR_ = (long) ceil (blocksizeR_sec_ / c2.T);\n  } else {\n    SMILE_IDBG(3,\"using fallback blocksizeR of 1, because blocksizeR or blocksize_sec was not set in config!\");\n    blocksizeR_ = 1;\n  }\n\n  // if only blocksizeR was set instead of blocksize, auto set blocksizeW to blocksizeR\n  // NOTE: if blocksizeW != 0 this auto setting will not be performed...\n  if (blocksizeW_ <= 0) {\n    blocksizeW_ = blocksizeR_;\n    blocksizeW_sec_ = blocksizeR_sec_;\n  }\n  \n  // set writer blocksize from \"blocksizeW\" config option\n  c2.blocksizeWriter = blocksizeW_;\n  long oldBsw = blocksizeW_;\n\n  // allow custom config of reader... \n  // main purpose: \"communicating\" blocksizeR to dataMemory !\n  if (!configureReader(c2)) {\n    // NOTE: reader config (setup matrix reading /blocksize / etc. may also be performed in configureWriter!! \n    SMILE_IERR(1,\"configureReader() returned 0 (failure)!\");\n    return 0;  \n  }\n\n  // provide a hook, to allow a derived component to modify the writer config we have obtained from the parent level:\n  int ret = configureWriter(c2);\n  // possible return values (others will be ignored): \n  // -1 : configureWriter has overwritten c->nT value for the buffersize, myConfigureInstance will not touch nT !\n  // 0 : failure, myConfigure must exit with code 0\n  // 1 : default / success\n  if (!ret) {\n    SMILE_IERR(1,\"configureWriter() returned 0 (failure)!\");\n    return 0;\n  }\n\n  // since configure writer may modify either c2.blocksizeWriter OR blocksizeW alone, we sync again if they differ:\n  if (c2.blocksizeWriter != oldBsw) {\n    blocksizeW_ = c2.blocksizeWriter;\n  } else if (blocksizeW_ != oldBsw) {\n    c2.blocksizeWriter = blocksizeW_;\n  }\n\n  if (ret!=-1) {\n    if (buffersize_ > 0) {\n      c2.nT = buffersize_;\n    } else if (buffersize_sec_ > 0.0) {\n      if (c2.T != 0.0) {\n        c2.nT = (long)ceil(buffersize_sec_/c2.T);\n      } else {\n        c2.nT = (long)ceil(buffersize_sec_);\n      } \n    } // else, don't modify c2.nT : buffersize will be the same as in input level or as set by configureWriter!\n  }\n\n  writer_->setConfig(c2,0);\n  return writer_->configureInstance();\n}\n\n// Adds a field with given parameters, concat base name and append string (if not NULL).\nvoid cDataProcessor::addNameAppendField(const char*base, const char*append, int N, int arrNameOffset)\n{\n  char *xx;\n\n  if  ((append != NULL)&&(strlen(append)>0)) {\n    if ((base != NULL)&&(strlen(base)>0)) {\n      xx = myvprint(\"%s_%s\",base,append);\n      writer_->addField( xx, N, arrNameOffset );\n      free(xx);\n    } else {\n      writer_->addField( append, N, arrNameOffset );\n    }\n  } else {\n    if ((base != NULL)&&(strlen(base)>0)) {\n      writer_->addField( base, N, arrNameOffset );\n    } else {\n      writer_->addField( \"noname\", N, arrNameOffset );\n    }\n  }\n}\n\n// automatically append \"nameAppend\", also allow for a fixed cutom part of the name\n// base is automatically appended or not depending on the value of copyInputName\nvoid cDataProcessor::addNameAppendFieldAuto(const char*base, const char *customFixed, int N, int arrNameOffset)\n{\n  char *xx;\n\n  if  ((nameAppend_ != NULL)&&(strlen(nameAppend_)>0)) {\n    if ((customFixed != NULL)&&(strlen(customFixed)>0)) {\n\n      if ((copyInputName_)&&(base != NULL)&&(strlen(base)>0)) {\n        xx = myvprint(\"%s_%s%s\",base,customFixed,nameAppend_);\n        writer_->addField( xx, N, arrNameOffset );\n        free(xx);\n      } else {\n        xx = myvprint(\"%s%s\",customFixed,nameAppend_);\n        writer_->addField( xx, N, arrNameOffset );\n        free(xx);\n      }\n\n    } else {\n\n      if ((copyInputName_)&&(base != NULL)&&(strlen(base)>0)) {\n        xx = myvprint(\"%s_%s\",base,nameAppend_);\n        writer_->addField( xx, N, arrNameOffset );\n        free(xx);\n      } else {\n        writer_->addField( nameAppend_, N, arrNameOffset );\n      }\n\n    }\n  } else {\n    if ((customFixed != NULL)&&(strlen(customFixed)>0)) {\n\n      if ((copyInputName_)&&(base != NULL)&&(strlen(base)>0)) {\n        xx = myvprint(\"%s_%s\",base,customFixed);\n        writer_->addField( xx, N, arrNameOffset );\n        free(xx);\n      } else {\n        writer_->addField( customFixed, N, arrNameOffset );\n      }\n\n\n    } else {\n\n      if ((copyInputName_)&&(base != NULL)&&(strlen(base)>0)) {\n        writer_->addField( base, N, arrNameOffset );\n      } else {\n        writer_->addField( \"noname\", N, arrNameOffset );\n      }\n\n    }\n\n  }\n}\n\n// get the size of input frames in seconds\ndouble cDataProcessor::getFrameSizeSec()\n{\n  const sDmLevelConfig *c = reader_->getLevelConfig();\n  return (double)(c->frameSizeSec);\n}\n\n// get the period of the base level (e.g. sampling rate for wave input)\ndouble cDataProcessor::getBasePeriod()\n{\n  const sDmLevelConfig *c = reader_->getLevelConfig();\n  return (double)(c->basePeriod);\n}\n\n//\n// find a field in the input level by a part of its name or its full name\n// set the internal variables nInput, inputStart, and inputName\n//\n// nEl specifies the maximum number of input elements (for checking valid range of field index)\n// (optional) fullName = 1: match full field name instead of part of name\nlong cDataProcessor::findInputField(const char *namePartial, int fullName, long nEl)\n{\n  int more = 0;\n  inputStart_ = findField(namePartial, fullName, &nInput_, &inputName_, nEl, &more, NULL);\n  return inputStart_;\n  // TODO: make this function use findField!\n  /*\n  const FrameMetaInfo * fmeta = reader_->getFrameMetaInfo();\n  int ri=0;\n  long idx;\n  if (fullName) {\n    idx = fmeta->findField( namePartial , &ri );\n  } else {\n    idx = fmeta->findFieldByPartialName( namePartial , &ri );\n  }\n  if (nEl <= 0) nEl = reader_->getLevelN();\n  if (idx < 0) {\n    nInput_ = nEl;\n    inputStart_ = 0;\n    inputName_ = NULL;\n    SMILE_IWRN(2,\"Requested input field '*%s*' not found, defaulting to use full input vector!\",namePartial);\n  } else {\n    inputStart_ = fmeta->fieldToElementIdx( idx ) + ri;;\n    nInput_ = fmeta->field[idx].N;\n    inputName_ = fmeta->field[idx].name;\n  }\n\n  if (nInput_+inputStart_ > nEl) nInput_ = nEl-inputStart_;\n  if (inputStart_ < 0) inputStart_ = 0;\n  return inputStart_;\n  */\n}\n\n//\n// find a field in the input level by a part of its name or its full name\n//\n// return value: index of first element of field\n//\n// *namePartial gives the name/partial to search for\n// nEl specifies the maximum number of input elements (for checking valid range of field index)\n//     -1 will enable autodetection from reader_->getLevelN();\n// *N , optional, a pointer to variable (long) that will be filled with the number of elements in the field\n// **_fieldName : will be set to a pointer to the name of the field\n// (optional) fullName = 1: match full field name instead of part of name\n// *more: will be set to > 0 if more than one field matches the search expression\n//        the index of the current field will be the value of *more\n// *fieldIdx: index of field (not element!)\nlong cDataProcessor::findField(const char *namePartial, int fullName, long *N, const char **fieldName, long nEl, int *more, int *fieldIdx)\n{\n  const FrameMetaInfo * fmeta = reader_->getFrameMetaInfo();\n  int ri=0;\n  long idx;\n  if (fullName) {\n    idx = fmeta->findField( namePartial , &ri, more );\n  } else {\n    idx = fmeta->findFieldByPartialName( namePartial , &ri, more );\n  }\n  long nInput, inputStart;\n  const char *inputName;\n  if (nEl <= 0)\n    nEl = reader_->getLevelN();\n  if (idx < 0) {\n    nInput = nEl;\n    inputStart = 0;\n    inputName = NULL;\n    if (fullName) {\n      SMILE_IWRN(2,\"Requested input field '%s' not found, check your config! Defaulting to use first field. Available fields:\", namePartial);\n    } else {\n      SMILE_IWRN(2,\"Requested input field matching pattern '*%s*' not found, check your config! Defaulting to use first field. Available fields:\", namePartial);\n    }\n    fmeta->printFieldNames();\n    //SMILE_IWRN(2,\"Requested input field '*%s*' not found, defaulting to use full input vector!\",namePartial);\n  } else {\n    inputStart = fmeta->fieldToElementIdx( idx ) + ri;\n    nInput = fmeta->field[idx].N;\n    inputName = fmeta->field[idx].name;\n  }\n  // FIXME: this function should return -1 if the field is not found and everyone using\n  //  this function should check for a valid index!\n\n  if ((nInput+inputStart > nEl)&&(nEl>0)) nInput = nEl-inputStart;\n  if (inputStart < 0) inputStart = 0;\n\n  if (fieldIdx != NULL) *fieldIdx = idx;\n  if (N != NULL) *N = nInput;\n  if (fieldName != NULL) *fieldName = inputName;\n  return inputStart;\n}\n\n//\n// search for an element by its partial name (if multiple matches are found, only the first is returned)\n// if fullName==1 , then do only look for exact name matches\n// the return value will be the element(!) index , i.e. the index of the element in the data vector\n//\nlong cDataProcessor::findElement(const char *namePartial, int fullName, long *N, const char **fieldName, int *more, int *fieldIdx)\n{\n  const FrameMetaInfo * fmeta = reader_->getFrameMetaInfo();\n  int ri=0;\n  long idx;\n  if (fullName) {\n    idx = fmeta->findField( namePartial , &ri, more );\n  } else {\n    idx = fmeta->findFieldByPartialName( namePartial , &ri, more );\n  }\n  long elIdx=-1;\n  const char *inputName;\n  long nInput;\n  if (idx < 0) {\n    inputName = NULL;\n    nInput = 0;\n    if (fullName) {\n      SMILE_IWRN(2,\"Requested input element '%s' not found, check your config! Available fields:\", namePartial);\n    } else {\n      SMILE_IWRN(2,\"Requested input element matching pattern '*%s*' not found, check your config! Available fields:\", namePartial);\n    }\n    fmeta->printFieldNames();\n  } else {\n    elIdx = fmeta->fieldToElementIdx( idx ) + ri;\n    nInput = fmeta->field[idx].N;\n    inputName = fmeta->field[idx].name;\n  }\n\n  if (fieldIdx != NULL) *fieldIdx = idx;\n  if (N != NULL) *N = nInput;\n  if (fieldName != NULL) *fieldName = inputName;\n  return elIdx;\n}\n\n\n// get data from input field (previously found by findInputField())\n// stores nInput elements in **_in, the memory is allocated if necessary (i.e. *_in == NULL)\nint cDataProcessor::getInputFieldData(const FLOAT_DMEM *src, long Nsrc, FLOAT_DMEM **in)\n{\n  if (nInput_ <= 0) return 0;\n  if (in != NULL) {\n    if (*in == NULL) *in = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*nInput_);\n    long i;\n    for (i=0; i<nInput_; i++) {\n      long j = inputStart_ + i;\n      if (j<Nsrc) (*in)[i] = src[j];\n      else {\n        SMILE_IERR(3,\"out of range index in getInputFieldData (j=%i , inputStart=%i, Nsrc=%s)\",j,inputStart_,Nsrc);\n        (*in)[i] = 0.0;\n      }\n    }\n    return 1;\n  }\n  return 0;\n}\n\n\nint cDataProcessor::setupNewNames(long nEl)\n{\n\t// if you overwrite this method, uncomment the following line in your own class'es code:\n\t// namesAreSet=1 \n   return 1;\n}\n\nint cDataProcessor::setupNamesForField(int i, const char*name, long nEl)\n{\n  if (copyInputName_) {\n    addNameAppendField( name, nameAppend_, nEl );\n  } else {\n    addNameAppendField( NULL, nameAppend_, nEl );\n  }\n  return nEl;\n}\n\nint cDataProcessor::cloneInputFieldInfo(int sourceFidx, int targetFidx, int force)\n{\n  const FrameMetaInfo * fmeta = reader_->getFrameMetaInfo();\n  if ((fmeta != NULL) && (sourceFidx < fmeta->N)) {\n    const FrameMetaInfo * fmetaW = writer_->getFrameMetaInfo();\n    int isset = 0;\n    if (fmetaW != NULL) {\n      if ((fmetaW->N > 0) && (fmetaW->field[fmetaW->N-1].infoSet)) isset = 1;\n      if (!isset || force) {\n        if (fmeta->field[sourceFidx].infoSize > 0) { // TODO: check why we had infoSize==0 here!! (valgrind leak check revealed this...)\n          void * _info = malloc(fmeta->field[sourceFidx].infoSize);\n          memcpy(_info, fmeta->field[sourceFidx].info, fmeta->field[sourceFidx].infoSize);\n          writer_->setFieldInfo(targetFidx, fmeta->field[sourceFidx].dataType, _info , fmeta->field[sourceFidx].infoSize );\n        }\n      }\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/* finalise reader an writer\n   first finalise the reader, so we can read field/element names from it\n   then set names for the writer\n   then finalise the writer...\n */\nint cDataProcessor::myFinaliseInstance()\n{\n  // an extra hook to allow custom configure of e.g. vectorProcessors, etc. without overwriting myFinaliseInstance!\n  if (!dataProcessorCustomFinalise()) {\n    SMILE_IERR(1,\"dataProcessorCustomFinalise returned 0 (failure) !\");\n    return 0;\n  }\n\n  /* available hooks for setting data element names in the output level:\n    1. setupNewNames() : you are free to set any names in the output level, independent of the names in the input level\n       (configureField will not be called! you must do everything in setupNewNames!)\n\n    2. setupNamesForField() : this will be called for every input field(!), use this if you only want to append a suffix or change the number of elements in each field!\n           setupNamesFor filed must return the number of elements that were set for the current field\n       + configureField() : custom configuration (e.g. allocation of buffers, etc.) that the component must perform shall be put into this method!\n\n    a hook that actually sets names MUST set the variable \"namesAreSet\" to 1\n\n    if no hook sets the names, the names will be copied from the input level, and the suffix \"nameAppend\" will be appended!\n  */\n\n  // hook 1.\n  if (!namesAreSet_) {\n    if (!setupNewNames(reader_->getLevelNf())) {\n      SMILE_IERR(1,\"setupNewNames() returned 0 (failure)!\");\n      return 0;\n    }\n  }\n\n  // hook 2.\n  if (!namesAreSet_) {\n    int lN = reader_->getLevelNf();\n    int i;\n    for (i=0; i<lN; i++) {\n      int llN=0;\n      int arrNameOffset=0;\n      const char *tmp = reader_->getFieldName(i,&llN,&arrNameOffset);\n      long nOut = setupNamesForField(i,tmp,llN);\n      if (nOut==llN) {\n  \t\t  writer_->setArrNameOffset(arrNameOffset);\n\t    }\n      configureField(i,llN,nOut);\n      cloneInputFieldInfo(i, -1, 0); //fallback... no overwrite\n    }\n    namesAreSet_ = 1;\n  }\n  \n  return writer_->finaliseInstance();\n}\n\ncDataProcessor::~cDataProcessor()\n{\n  if (writer_ != NULL) { delete writer_; }\n  if (reader_ != NULL) { delete reader_; }\n}\n\n\n"
  },
  {
    "path": "src/core/dataReader.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: dataReader */\n\n\n#include <core/dataReader.hpp>\n\n#define MODULE \"cDataReader\"\n\nSMILECOMPONENT_STATICS(cDataReader)\n\nSMILECOMPONENT_REGCOMP(cDataReader)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CDATAREADER;\n  sdescription = COMPONENT_DESCRIPTION_CDATAREADER;\n\n  // configure your component's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n    //(if set, this sets the dmInstance option in both 'reader' and 'writer' subcomponents. This option is provided for simplification only, it has no other function than setting both reader.dmInstance and writer.dmInstance.\n  ct->setField(\"dmInstance\", \"The name of the dataMemory instance this reader should connect to.\", \"dataMemory\",0,0);\n  ct->makeMandatory(ct->setField(\"dmLevel\", \"The level in the data memory instance specified by 'dmInstance' which to read from. If this array element contains more than one element, this reader will read data from multiple input levels, and concattenate the data to generate a single frame/vector. It is a good practice to have unique field names in all levels that you wish to concatenate. Note: If reading from multiple levels, the reader can only return a successfully read frame, if data is available for reading on all input levels. If data is missing on one level, the reader cannot output data, even if data is present on the other levels.\", (char *)NULL, ARRAY_TYPE));\n  ct->setField(\"forceAsyncMerge\", \"1/0 = yes/no : force framewise merging of levels with differing frame period, if multiple levels are specified in dmLevel\", 0);\n  ct->setField(\"errorOnFullInputIncomplete\", \"1/0 = yes/no : 1 = abort with an error if full input matrix reading is activated (frameSize=0 & frameStep=0 => frameMode=full) and beginning of matrix (curR) is not 0, (if this option is set to 0, only a warning is shown)\", 1);\n\n  SMILECOMPONENT_IFNOTREGAGAIN( {} )\n  \n  SMILECOMPONENT_MAKEINFO_NODMEM(cDataReader);\n}\n\nSMILECOMPONENT_CREATE(cDataReader)\n\n///------------------------------------ dynmaic part:\n\ncDataReader::cDataReader(const char *_name) : cSmileComponent(_name),\n  dm(NULL),\n  dmInstName(NULL),\n  dmLevel(NULL),\n  level(NULL),\n  V(NULL),\n  m(NULL),\n  curR(0),\n  stepM(1),\n  lengthM(1),\n  ignMisBegM(0),\n  stepM_sec(-1.0),\n  lengthM_sec(-1.0),\n  ignMisBegM_sec(0.0),\n  rdId(NULL),\n  eToL(NULL),\n  fToL(NULL),\n  Le(NULL),\n  Lf(NULL),\n  forceAsyncMerge(0),\n  errorOnFullInputIncomplete(1),\n  myfmeta(NULL),\n  myLcfg(NULL)\n{\n\n}\n\nvoid cDataReader::fetchConfig() {\n  // get name of dataMemory instance to connect to\n  dmInstName = getStr(\"dmInstance\");\n  if (dmInstName == NULL) COMP_ERR(\"fetchConfig: getStr(dmInstance) returned NULL! missing option in config file?\");\n  // now get read level information:\n  nLevels = getArraySize(\"dmLevel\");\n  SMILE_IDBG(2,\"'%s': reading from %i input levels\",getInstName(),nLevels);\n  \n  forceAsyncMerge = getInt(\"forceAsyncMerge\");\n  SMILE_IDBG(2,\"forceAsyncMerge = %i\",forceAsyncMerge);\n\n  errorOnFullInputIncomplete = getInt(\"errorOnFullInputIncomplete\");\n  SMILE_IDBG(2,\"errorOnFullInputIncomplete = %i\",errorOnFullInputIncomplete);\n\n  int i;\n  // XXX : read array of levels...\n  if (nLevels > 0) {\n    dmLevel = (const char **)calloc(1,sizeof(const char*)*nLevels);\n    level = (int *)calloc(1,sizeof(int)*nLevels);\n    rdId = (int *)calloc(1,sizeof(int)*nLevels);\n\n    if (dmLevel==NULL) OUT_OF_MEMORY;\n    for (i=0; i<nLevels; i++) {\n      dmLevel[i] = getStr_f(myvprint(\"dmLevel[%i]\",i));\n      if (dmLevel[i] == NULL) COMP_ERR(\"fetchConfig: getStr(dmLevel[%i]) returned NULL! missing option in config file?\",i);\n      SMILE_IDBG(2,\"'%s': input level %i = '%s'\",getInstName(),i,dmLevel[i]);\n      rdId[i] = -1;\n    }\n  }\n}\n\nint cDataReader::myRegisterInstance(int *runMe)\n{\n  const char * tn = getComponentInstanceType(dmInstName);\n  if (tn == NULL) {\n    SMILE_IWRN(4,\"cannot yet find dataMemory component '%s'!\",dmInstName);\n    return 0;\n  }\n  if (!strcmp(tn, COMPONENT_NAME_CDATAMEMORY)) {\n    dm = (cDataMemory *)getComponentInstance(dmInstName);\n    if (dm == NULL) {\n      SMILE_IERR(1,\"dataMemory instance dmInstance='%s' was not found in componentManager!\",dmInstName);\n//      COMP_ERR(\"failed to register!\");\n      return 0;\n    }\n  } else { // not datamemory type..\n    if (dm == NULL) {\n      SMILE_IERR(1,\"dmInstance='%s' -> not of type %s (dataMemory)!\",dmInstName,COMPONENT_NAME_CDATAMEMORY);\n//      COMP_ERR(\"failed to register!\");\n      return 0;\n    }\n  }\n\n  int i;\n  for (i=0; i<nLevels; i++) { \n    dm->registerReadRequest(dmLevel[i],getInstName());\n  }\n\n  return 1;\n}\n\nint cDataReader::myConfigureInstance()\n{\n  int i;\n\n  for (i=0; i<nLevels; i++) {\n    // find our read levels... the dataWriters should create them in their configure method\n    level[i] = dm->findLevel(dmLevel[i]);\n    if (level[i] < 0) {\n      SMILE_IDBG(3,\"level='%s' not yet available, waiting!\",dmLevel[i]);\n      return 0;\n    }\n  }\n\n  for (i=0; i<nLevels; i++) {\n    // setup the reader blocksize and get read level config\n    const sDmLevelConfig * c;\n    if (lengthM_sec >= 0.0) {\n      c = dm->queryReadConfig( level[i], lengthM_sec );\n    } else {\n      long tmp = (long)lengthM;\n      if (tmp < 1) tmp = 1;\n      c = dm->queryReadConfig( level[i], tmp );\n    }\n    // TODO: merge config from various levels....\n\n    //...\n    if ((myLcfg==NULL)&&(c!=NULL)) myLcfg = new sDmLevelConfig(*c);\n  }\n  \n  if (myLcfg == NULL) {\n    SMILE_IERR(1,\"reader level config could not be set in myConfigureInstance for an unknown reason!\");\n    return 0;\n  }\n\n  // now update stepM and lengthM from stepM_frames and lengthM_frames:\n  if (stepM < 0) {\n    if (myLcfg->T != 0.0) {\n      stepM = (long)round( stepM_sec / myLcfg->T );\n      ignMisBegM = (long)round( ignMisBegM_sec / myLcfg->T );\n    } else {\n      stepM = (long)round( stepM_sec );\n      ignMisBegM = (long)round( ignMisBegM_sec );\n    }\n    curR = ignMisBegM;\n  }\n\n  if (lengthM < 0) {\n    if (myLcfg->T != 0.0) {\n      lengthM = (long)round( lengthM_sec / myLcfg->T );\n    } else {\n      lengthM = (long)round( lengthM_sec );\n    }\n  }\n\n  return 1;\n}\n\nint cDataReader::myFinaliseInstance()\n{\n  int i,j;\n  double lT = -1.0;\n  long lN = 0;\n  long lNf = 0;\n  int ldtype = -1;\n\n  for (i = 0; i < nLevels; i++) {\n    // find multiple levels, register multiple readers...\n    if (!dm->namesAreSet(level[i])) {\n      SMILE_IDBG(3,\"finaliseInstance: names in input level '%s' are not yet set... waiting.\",\n          dmLevel[i]);\n      return 0;\n    }\n  }\n\n  if (Lf == NULL)\n    Lf = (int*)calloc(1,sizeof(int)*(nLevels+1));\n  if (Le == NULL)\n    Le = (int*)calloc(1,sizeof(int)*(nLevels+1));\n  int * bufSizes = (int *)calloc(1, sizeof(int) * (nLevels + 1));\n  int isRb = -1;\n  int growDyn = -1;\n  int bufSizeMax = 0;\n\n  for (i = 0; i < nLevels; i++) {\n    if (rdId[i] == -1) {\n      rdId[i] = dm->registerReader(level[i]);\n      SMILE_IDBG(2, \"registered reader level[i=%i]=%i ('%s'), rdId=%i\",\n          i, level[i], dm->getLevelName(level[i]), rdId[i]);\n    }\n    \n    const sDmLevelConfig *c = dm->getLevelConfig(level[i]);\n    if (c != NULL) {\n      // check bufsizes, growdyn and rb for consistency.\n      // if these are not consistent this might cause hidden problems, i.e. blocking the processing chain\n      bufSizes[i] = c->nT;\n      if (c->nT > bufSizeMax)\n        bufSizeMax = c->nT;\n      if (isRb == -1)\n        isRb = c->isRb;\n      if (growDyn == -1)\n        growDyn = c->growDyn;\n      if (growDyn != c->growDyn) {\n        SMILE_IWRN(2, \"Inconsistency in input level parameters. growDyn on first (#1) input = %i, growDyn on input # %i (%s) = %i. This might cause the processing to hang unpredictably or cause incomplete processing.\",\n            growDyn, i + 1, c->name, c->growDyn);\n      }\n      if (isRb != c->isRb) {\n        SMILE_IWRN(2, \"Inconsistency in input level parameters. isRb on first (#1) input = %i, isRb on input # %i (%s) = %i. This might cause the processing to hang unpredictably or cause incomplete processing.\",\n            isRb, i + 1, c->name, c->isRb);\n      }\n\n      // check if all levels have the same period!!\n      // (do not proceed unless forceAsyncMerge option is given in config!)\n      if (lT == -1.0)\n        lT = c->T;\n      else if ((c->T != lT) && (fabs(c->T - lT) > 10e-10) && (!forceAsyncMerge)) {\n        SMILE_IERR(1, \"frame period mismatch among input levels! '%s':%e <> '%s':%e\",\n            dm->getLevelName(level[i]), c->T, dm->getLevelName(level[0]), lT);\n        return 0;\n      }\n      if (ldtype==-1)\n        ldtype = c->type;\n      else if (ldtype != c->type) {\n        SMILE_IERR(1, \"dataType mismatch among input levels (conversion is not yet supported!) '%s':%i <> '%s':%i\",\n            dm->getLevelName(level[i]), c->type, dm->getLevelName(level[0]), ldtype);\n        return 0;\n      }\n\n    } else { \n      SMILE_IERR(1,\"can't get config for level '%s' (i=%i level[i]=%i)\",dmLevel[i],i,level[i]); \n      return 0; \n    }\n    \n    // BUILD a field -> level map for getFieldName...\n    if (c->fmeta != NULL) Lf[i] = lNf;\n    lNf += c->fmeta->N;\n    // BUILD a element -> level map for getElementName...\n    Le[i] = lN;\n    lN += c->N;\n\n    //SMILE_IDBG(4,\"finalised dmLevel[%i]='%s' level[%i]=%i in memory '%s'\",getInstName(),i,dmLevel[i],i,level[i],dmInstName);\n  }\n  Lf[nLevels] = lNf;\n  Le[nLevels] = lN;\n  \n  for (i = 0; i < nLevels; i++) {\n    if (bufSizes[i] < bufSizeMax)\n      SMILE_IWRN(1, \"Mismatch in input level buffer sizes (levelconf.nT). Level #%i has size %i which is smaller than the max. input size of all input levels (%i). This might cause the processing to hang unpredictably or cause incomplete processing.\",\n          i, bufSizes[i], bufSizeMax);\n  }\n  free(bufSizes);\n\n  // BUILD a field -> level map for getFieldName...\n  // BUILD a element -> level map for getElementName...\n  fToL = (int*)calloc(1,sizeof(int)*lNf);\n  eToL = (int*)calloc(1,sizeof(int)*lN);\n  for (i=0; i<nLevels; i++) {\n    for (j=Lf[i]; j<Lf[i+1]; j++) {\n      fToL[j] = i;\n    }\n    for (j=Le[i]; j<Le[i+1]; j++) {\n      eToL[j] = i;\n    }\n  }\n\n  myLcfg->N = lN;\n  myLcfg->Nf = lNf;\n  myLcfg->type = ldtype;\n\n  int updatefmeta = 0;\n  int f = 0;\n  if (myfmeta == NULL) {\n    myfmeta = new FrameMetaInfo();\n    if (myfmeta == NULL) OUT_OF_MEMORY;\n    myfmeta->N = myLcfg->Nf; // assign number of fields (total)\n    myfmeta->Ne = myLcfg->N; // assign total number of elements\n    myfmeta->field = (FieldMetaInfo *)calloc(1,sizeof(FieldMetaInfo)*(myLcfg->Nf));\n    myLcfg->fmeta = myfmeta;\n    updatefmeta = 1;\n  }\n  \n  for (i=0; i<nLevels; i++) {\n    const sDmLevelConfig *c = dm->getLevelConfig(level[i]);\n    if (c!=NULL) {\n      // update myfmeta (*c should contain names by now)\n      if (updatefmeta) {\n        const FrameMetaInfo * fm = c->fmeta;\n        if (fm != NULL) {\n          int j;\n          for (j=0; j<fm->N; j++) {\n            // now copy each field  from corresponding frame\n            myfmeta->field[f++].copyFrom(fm->field+j);\n          }\n        }\n      }\n    }\n  }\n\n  //----- DONE: ???\n  // todo .. MANUALLY update other values in myLcfg, e.g. blocksizeWriter, etc...\n\n  // TODO:: myLcfg->fmeta = myfmeta...  : DONE: this is handled when the first frame arrives and a concattenated fmeta is built\n  // HOWEVER, it would be better to concattenate the fmeta at this point.....\n  \n  return 1;\n}\n\nlong cDataReader::getMinR()\n{ \n  // NOTE: \"minimum index that is readable\", thus we must take the MAX among all input levels!!\n  long minR = dm->getMinR(level[0]);\n  int i;\n  for (i=1; i<nLevels; i++) {\n    long tmp = dm->getMinR(level[i]);\n    if (tmp > minR) minR = tmp;\n  }\n  return minR;\n}\n\nvoid cDataReader::catchupCurR(long _curR)\n{\n  int i;\n  for (i=0; i<nLevels; i++) {\n    //printf(\"catchup rdid %i in '%s' '%s'\\n\",rdId[i],getInstName(),dmLevel[i]);\n    dm->catchupCurR(level[i],rdId[i],_curR);\n  }\n}\n\n//-----\ncVector * cDataReader::getFrame(long vIdx, int special, int privateVec, int *result)\n{\n         // XXX : get multiple frames, concat them\n         // PROBLEM::: only return success, if all frames were read successfully\n         //             if not all frames were read successfully, UNDO changes to write/read counters!!\n         // THUS::=> use a checkRead() function to see if data is available!!\n  long i;\n  int r=1;\n  cVector *_V = NULL;\n  if (!privateVec) _V = V;\n  if (result != NULL) *result = 0;\n\n  if (nLevels > 1) {\n  \n    for (i=0; i<nLevels; i++) {\n      int myResult=0;\n      r &= dm->checkRead(level[i],vIdx,special,rdId[i], 1, &myResult);\n      if (result != NULL) *result |= myResult;\n    }\n    if (r) {\n      if (_V==NULL) _V = new cVector(myLcfg->N,myLcfg->type);\n      int fmetaUpdate = 0;\n      if (myfmeta == NULL) { \n        fmetaUpdate = 1;\n        myfmeta = new FrameMetaInfo();\n        if (myfmeta == NULL) OUT_OF_MEMORY;\n        myfmeta->N = myLcfg->Nf; // assign number of fields (total)\n        myfmeta->field = (FieldMetaInfo *)calloc(1,sizeof(FieldMetaInfo)*(myLcfg->Nf));\n        myLcfg->fmeta = myfmeta;\n      }\n      long e=0; \n      long f=0;\n      for (i=0; i<nLevels; i++) {\n        //        printf(\"rdid i = %i\\n\",rdId[i]);\n        int myResult=0;\n        cVector *f2 = dm->getFrame(level[i],vIdx, special, rdId[i], &myResult);\n        if (result != NULL) *result |= myResult;\n\n        if (f2 != NULL) {\n          // copy data from f2 into V at the correct position\n          if (f2->type == DMEM_FLOAT) {\n            memcpy( _V->dataF+e , f2->dataF, f2->N*sizeof(FLOAT_DMEM) );\n            \n            //            for (n=0; n<f2->N; n++)\n            //              V->dataF[e++] = f2->dataF[n];\n          } else if (f2->type == DMEM_INT) {\n            memcpy( _V->dataI+e , f2->dataI, f2->N*sizeof(INT_DMEM) );\n            \n            //            for (n=0; n<f2->N; n++)\n            //              V->dataI[e++] = f2->dataI[n];\n          }\n          e += f2->N;\n          // TODO: implement conversion from dataI <-> dataF\n\n\n          if (i==0) _V->tmetaClone(f2->tmeta); // TODO: change this for asynchronous levels...\n\n          //concat fmeta!!\n          if (fmetaUpdate) {\n            int j;\n            for (j=0; j<f2->fmeta->N; j++) {\n              // now copy each field  from corresponding frame\n              myfmeta->field[f++].copyFrom(f2->fmeta->field+j);\n            }\n            //f += f2->fmeta->N;\n          }\n          _V->fmeta = myfmeta;\n\n          delete f2;\n        } else {\n          SMILE_ERR(1,\"no data was read from one of multiple input levels, this is a BUG! checkRead <-> getFrame ! a bogus data vector will now be returned!\");\n        }\n      }\n\n      if (!privateVec) V=_V;\n      //if ((_V != NULL)&&(vIdx>curR)) curR=vIdx;\n      return _V;\n    } else {\n      return NULL;\n    }\n  \n  } else {\n    // TODO: speed-up by passing our V object to dm->getFrame, which fills it and does not have to reallocate an object!\n    cVector *f2 = dm->getFrame(level[0],vIdx, special, rdId[0], result);\n    if ((f2 != NULL)&&(!privateVec)) {\n      if (V != NULL) delete V;\n      V = f2;\n    }\n    //if ((f2 != NULL)&&(vIdx>curR)) curR=vIdx;\n    return f2;\n  }\n}\n\ncMatrix * cDataReader::getMatrix(long vIdx, long length, int special, int privateVec) // vIdx: start index of matrix (absolute)\n{\n         // XXX TODO: get multiple frames, concat them\n         // PROBLEM::: only return success, if all frames were read successfully\n         //             if not all frames were read successfully, UNDO changes to write/read counters!!\n         // THUS::=> use a checkRead() function to see if data is available!!\n\n  long i,n;\n  int r=1;\n  cMatrix *my_m = NULL;\n  if (!privateVec) my_m=m;\n  \n  if (nLevels > 1) {\n\n    for (i=0; i<nLevels; i++) {\n      r &= dm->checkRead(level[i],vIdx,special,rdId[i],length);\n    }\n    if (r) {\n      if (my_m!=NULL) {\n        if (length != my_m->nT) {\n          delete my_m;\n          my_m=NULL;\n        }\n      }\n      if (my_m == NULL) my_m = new cMatrix(myLcfg->N,length,myLcfg->type);\n      \n      int fmetaUpdate = 0;\n      if (myfmeta == NULL) { \n        fmetaUpdate = 1;\n        myfmeta = new FrameMetaInfo();\n        if (myfmeta == NULL) OUT_OF_MEMORY;\n        myfmeta->N = myLcfg->Nf; // assign number of fields (total)\n        myfmeta->field = (FieldMetaInfo *)calloc(1,sizeof(FieldMetaInfo)*(myLcfg->Nf));\n        myLcfg->fmeta = myfmeta;\n      }\n\n      FLOAT_DMEM*df = my_m->dataF;\n      INT_DMEM*di = my_m->dataI;\n      long N = myLcfg->N;\n      long f=0;\n      long minlen = length;\n      for (i=0; i<nLevels; i++) {\n\n        cMatrix *m2 = dm->getMatrix(level[i],vIdx,vIdx+length, special, rdId[i]);\n        if (m2 != NULL) {\n          if (m2->nT < minlen) { minlen = m2->nT; }\n          // copy data from f2 into V at the correct position\n          if (m2->type == DMEM_FLOAT) {\n            for (n=0; n<minlen /*length*/; n++)\n              memcpy( df+(N*n) , m2->dataF + n*(m2->N), m2->N*sizeof(FLOAT_DMEM) );\n            df += m2->N;\n          } else if (m2->type == DMEM_INT) {\n            for (n=0; n<minlen /*length*/; n++)\n              memcpy( di+(N*n) , m2->dataI + n*(m2->N), m2->N*sizeof(INT_DMEM) );\n            di += m2->N;\n          }\n          // TODO: implement conversion from dataI <-> dataF\n\n          if (i==0) my_m->tmetaClone(m2->tmeta); // TODO: change this for asynchronous levels...\n\n          //concat fmeta!!\n            if (fmetaUpdate) {\n              int j;\n              for (j=0; j<m2->fmeta->N; j++) {\n                // now copy each field  from corresponding frame\n                myfmeta->field[f++].copyFrom(m2->fmeta->field+j);\n              }\n              //f += f2->fmeta->N;\n            }\n            my_m->fmeta = myfmeta;\n\n          delete m2;\n        }\n      }\n      if (minlen < length) {\n        // TODO: if the matrix size increases again, we cannot increase! Introduce cMatrix->nAlloc variable?\n        my_m->nT = minlen;\n      }\n\n      if (!privateVec) m=my_m;\n      return m;\n    } else {\n      return NULL;\n    }\n\n  } else {\n    cMatrix *m2 = dm->getMatrix(level[0],vIdx,vIdx+length, special, rdId[0]);\n    if ((m2 != NULL)&&(!privateVec)) {\n      if (m != NULL) delete m;\n      m = m2;\n      // ???:\n      //if (vIdx+length > curR) curR = vIdx+length;\n    }\n    return m2;\n  }\n}\n\n// relative: (vIdxRelE is positive and indicates the number of frames to go back from the last read frame)\n// noInc: 1=do not increase current read counter (DEFAULT is to INCREASE READ COUNTER!)\ncVector * cDataReader::getFrameRel(long vIdxRelE, int privateVec, int noInc, int *result)\n{\n  cVector * ret = getFrame(curR-vIdxRelE,-1,privateVec,result);\n  if ((!noInc)&&((ret!=NULL)||(curR-vIdxRelE < 0))) { curR++; }\n  return ret;\n}\n\n// vIdxRelE: end of matrix relative to end of data\ncMatrix * cDataReader::getMatrixRel(long vIdxRelE, long length, int privateVec)\n{\n  return getMatrix(curR-vIdxRelE-length, curR-vIdxRelE, -1, privateVec);\n}  \n\n// sequential\ncVector * cDataReader::getNextFrame(int privateVec, int *result)\n{\n  cVector *ret = getFrame(curR,-1,privateVec,result);\n  if ((ret != NULL)||(curR < 0)) curR++;\n  return ret;\n}\n\ncMatrix * cDataReader::getNextMatrix(int privateVec, int readToEnd, int special)\n{\n  if (stepM == 0 || readToEnd == 1) { // read complete input...\n    if (isEOI() && EOIlevelIsMatch()) { \n     // EOIlevelIsMatch: need to query EOI level here to avoid components running before they should in multi-EOI iterations\n      int i;\n      long fl = -1;  // fl = length of input\n      for (i=0; i<nLevels; i++) {\n        long tmp = dm->getNAvail(level[i],rdId[i]);\n        if (fl==-1) fl = tmp;\n        else if (tmp < fl) fl = tmp;\n      }\n      if ((curR==0||readToEnd==1)&&(fl > 0)) {\n        /* TODO: curR will not be set correctly be getMatrix for arbitrary reads.. */\n        cMatrix *ret = getMatrix(curR,fl,-1,privateVec);\n        long tmpR = dm->getMinR(level[0]);\n        //\t\tprintf(\"avail: %i  free: %i\\n \",dm->getNAvail(level[0]), dm->getNFree(level[0]));\n        //\t\tprintf(\"curW: %i  curR(int): %i   curR: \\n \",dm->getCurW(level[0]),curR);\n        SMILE_IDBG(3,\"fullinput: read %i frames (idx %i -> %i).\",fl,tmpR,tmpR+fl);\n\n        if (((tmpR > 0)||((myLcfg->growDyn==0)&&(myLcfg->nT < fl)))&&(ret!=NULL)) {\n          if (errorOnFullInputIncomplete) SMILE_IERR(1,\"reading of full input is incomplete: read %i frames (idx %i -> %i). start index should be zero! you are having a problem with your buffersizes (%i)!\",fl,tmpR,tmpR+fl,myLcfg->nT)\n          else SMILE_IWRN(2,\"reading of full input is incomplete: read %i frames (idx %i -> %i). start index should be zero! you are having a problem with your buffersizes (%i)!\",fl,tmpR,tmpR+fl,myLcfg->nT)\n        }\n        if (ret != NULL) { curR += fl; }\n        return ret;\n      } else { return NULL; }\n    } else { return NULL; }\n  } else {\n    cMatrix *ret = getMatrix(curR, lengthM, special, privateVec);\n    if (ret != NULL) curR += stepM;\n    return ret;\n  }\n}\n\nlong cDataReader::getNAvail()\n{\n  long fl = -1; // fl = nAvailable\n  int i;\n  for (i=0; i<nLevels; i++) {\n    long tmp = dm->getNAvail(level[i],rdId[i]);\n    if (fl==-1) fl = tmp;\n    else if (tmp < fl) fl = tmp;\n  }\n  return fl;\n}\n\nlong cDataReader::getNFree()\n{\n  long fl = -1;  // fl = nFree\n  int i;\n  for (i=0; i<nLevels; i++) {\n    long tmp = dm->getNFree(level[i],rdId[i]);\n    if (fl==-1) fl = tmp;\n    else if (tmp < fl) fl = tmp;\n  }\n  return fl;\n}\n\n// in order to report blocksize to dataMemory correctly, this should be called before configure()\nint cDataReader::setupSequentialMatrixReading(long step, long length, long ignoreMissingBegin)\n{\n  if ((step < 0) || (length < 0)) {\n    SMILE_IERR(2,\"step (%i) OR length (%i) < 0 in setupSequentialMatrixReading (frames)\",step,length);\n    return 0;\n  }\n\n  stepM = step;\n  lengthM = length;\n  if ((length<=0)||(step<=0)) { stepM=0; lengthM=0; }\n  stepM_sec = -1.0;\n  lengthM_sec = -1.0;\n  curR = ignMisBegM = ignoreMissingBegin;\n\n  if (isConfigured()) {\n    // we must update the blocksize in DM!\n    updateBlocksize(lengthM+stepM);\n  }\n  return 1;\n}\n\n// since the period of the reader level is not available before configure(), we must provide both methods, \n// one for setting the parameters in frames, and one for setting them seconds, as this:\nint cDataReader::setupSequentialMatrixReading(double step, double length, double ignoreMissingBegin)\n{\n  if ((step < 0.0) || (length < 0.0)) {\n    SMILE_IERR(2,\"step (%f) OR length (%f) < 0.0 in setupSequentialMatrixReading (seconds)\",step,length);\n    return 0;\n  }\n  stepM_sec = step;\n  lengthM_sec = length;\n  ignMisBegM_sec = ignoreMissingBegin;\n  if ((length<=0.0)||(step<=0.0)) { stepM_sec=0.0; lengthM_sec=0.0; }\n  stepM = -1;\n  lengthM = -1;\n  // this is handled in myConfigureInstance now...\n  //curR = ignMisBegM = ignoreMissingBegin;\n\n  if (isConfigured()) {\n    // we must update the blocksize in DM and recompute stepM, lengthM and curR\n    updateBlocksizeSec(lengthM_sec+stepM_sec);  // WAS -> updateBlocksize() !! why??\n\n    if (myLcfg->T != 0.0) {\n      stepM = (long)round( stepM_sec / myLcfg->T );\n      ignMisBegM = (long)round( ignMisBegM_sec / myLcfg->T );\n      lengthM = (long)round( lengthM_sec / myLcfg->T );\n    } else {\n      stepM = (long)round( stepM_sec );\n      ignMisBegM = (long)round( ignMisBegM_sec );\n      lengthM = (long)round( lengthM_sec );\n    }\n    curR = ignMisBegM;\n  }\n\n  return 1;\n}\n\n\ncDataReader::~cDataReader() {\n  if (V!=NULL) delete V;\n  if (m!=NULL) delete m;\n  if (dmLevel!=NULL) free(dmLevel);\n  if (rdId != NULL) free(rdId);\n  if (level!=NULL)  free(level);\n  if (Lf!=NULL) free(Lf);\n  if (Le!=NULL) free(Le);\n  if (fToL!=NULL) free(fToL);\n  if (eToL!=NULL) free(eToL);\n  if (myfmeta!=NULL) delete myfmeta;\n  if (myLcfg != NULL) delete myLcfg;\n}\n"
  },
  {
    "path": "src/core/dataSelector.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nselects data elements by element name\n\n*/\n\n\n#include <core/dataSelector.hpp>\n\n#define MODULE \"cDataSelector\"\n\n#define MAX_LINE_LENGTH 2048\n\nSMILECOMPONENT_STATICS(cDataSelector)\n\nSMILECOMPONENT_REGCOMP(cDataSelector)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n    scname = COMPONENT_NAME_CDATASELECTOR;\n  sdescription = COMPONENT_DESCRIPTION_CDATASELECTOR;\n\n  // we inherit cDataProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataProcessor\")\n\n    SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"selFile\",\"The name of the data selection file to load. The file is a text file containing one element name per line of the elements which should be selected (case-sensitive!). (Note: the first two lines make up a header; the first line always contains 'str', the second line is number of features in list, next each line contains one feature name of the features to select)\",(const char*)NULL);\n  ct->setField(\"selected\",\"This is an alternative to loading 'selFile'. An array of exact (case-sensitive) names of features / data elements to select.\",(const char *)NULL, ARRAY_TYPE);\n  ct->setField(\"selectedRange\",\"This is an alternative to loading 'selFile'. It specifies the selected elements(!) by element index ranges. Each array element contains one range in the format of <start>-<end>, where <start> and <end> are the indicies of the startt and end features to *select* in this range. '$' specifies the last element, and '1' indicates the first element. If the '-' is missing, only a single element will be selected, not a range. NOTE: the 'newNames' option does not work in conjunction with this element selection method!\",(const char*)NULL,ARRAY_TYPE);\n  ct->setField(\"newNames\",\"An array of new names to assign to the selected features / data elements (optional). The order thereby corresponds to the order of data element names in the input.\",(const char *)NULL, ARRAY_TYPE);\n  ct->setField(\"elementMode\",\"1 = select elements exactly as given in 'selected' array or in 'selFile' (in this case, only full element names are allowed (i.e. mfcc[1], mfcc[2] instead of mfcc, mfcc[], or mfcc[1-2]\\n   0 = automatically copy arrays or partial arrays, e.g. if field[1-4] or only 'field' is given as name in the selction array/file, then the partial (1-4) or complete field will be copied to the output\",1);\n  ct->setField(\"dummyMode\",\"1 = don't set up output level names. Use this option temporarily, to get a working set-up where you can read the input level names, to set up your selection list.\",0);\n  ct->setField(\"outputSingleField\", \"If this is set to a string, the output will be a single field (with the name set by this string) for all the elements in the input.\", (const char *)NULL);\n  )\n\n    SMILECOMPONENT_MAKEINFO(cDataSelector);\n}\n\n\nSMILECOMPONENT_CREATE(cDataSelector)\n\n//-----\n\ncDataSelector::cDataSelector(const char *_name) :\ncDataProcessor(_name),\n  selFile(NULL),\n  names(NULL),\n  mapping(NULL),\n  elementMode(0),\n  selectionIsRange(0),\n  idxSelected(NULL),\n  vecO(NULL), outputSingleField(NULL)\n{\n}\n\nint cDataSelector::loadSelection()\n{\n  if (selFile != NULL) {\n    if (strlen(selFile)<1) return 0;\n\n    FILE *f = fopen(selFile,\"r\");\n    if (f== NULL) {\n      SMILE_IERR(2,\"error opening feature selection file '%s' for reading! NOT using a feature selection!\",selFile);\n      return 0;\n    }\n\n    // read first line to determine filetype:\n    char line[MAX_LINE_LENGTH+1];\n    long nStr=0;\n    fgets( line, 5, f);\n    line[3] = 0;\n    if (!strcmp(line,\"str\")) { // string list\n      fselType = 2;\n      SMILE_IDBG(5,\"reading string list of features\");\n      fscanf( f, \"%u\\n\", &nStr);\n      if (nStr < 1) { COMP_ERR(\"Error reading feature selection file, nFeatures < 1!\"); }\n\n      nSel = nStr;\n      names = (char**)calloc(1,sizeof(char*) * nSel);\n\n      int i=0; line[0] = 0;\n      while(fgets(line,MAX_LINE_LENGTH,f) != NULL) {\n        if (strlen( line ) > 1) { \n          if (i<nStr) {\n            line[strlen( line ) - 1] = 0;\n            names[i++] = strdup(line);\n          } else { \n            SMILE_IERR(1,\"excess line in feature selection file '%s' : '%s' (expected only %i lines with features)\",selFile,line,nStr);\n          }\n        }\n      }\n      if (nSel > i) {\n        SMILE_IWRN(1,\"less feature names (only %i) in feature selection file '%s' than specified in the header (%i).\",i,selFile,nSel);\n        nSel = i;\n      }\n      /*\n      while(fgets(line,MAX_LINE_LENGTH,f) != NULL) {\n      if (strlen( line ) > 1) { \n      line[strlen( line ) - 1] = 0;\n      names[i++] = strdup(line);\n      }\n      }*/\n      SMILE_IDBG(5,\"selected %i features\",i);\n      fclose(f);\n      return 1;\n    } else if (!strcmp(line,\"idx\")) { // index list\n      fclose(f);\n      SMILE_IERR(1,\"feature index list not yet supported in dataSelector.\");\n      COMP_ERR(\"Aborting.\");\n      /*      \n      fselType = 1;\n      SMILE_IDBG(5,\"reading index list of features\");\n      long idx=0; int i;\n      // pass1: parse for max index\n      while(fscanf(f,\"%u\\n\",&idx) == 1)\n      outputSelIdx.nFull = MAX(outputSelIdx.nFull, idx);\n      SMILE_IDBG(5,\"max index in selection file was found to be %i\",outputSelIdx.nFull);\n      outputSelIdx.nFull++;\n      outputSelIdx.enabled = (long *)calloc(1,sizeof(long)*outputSelIdx.nFull);\n      rewind( f );\n      fgets(line, 5, f); // skip header line;\n      // pass2: parse for max index\n      i=0;\n      while(fscanf(f,\"%u\\n\",&idx) == 1) {\n      outputSelIdx.enabled[idx] = 1; // enable feature \"idx\"\n      i++;\n      }\n      outputSelIdx.nSel = i;\n      Nsel = i;\n      SMILE_IDBG(5,\"enabled %i features\",i);\n      fclose(f);\n      return 1;\n      */\n    } else { // bogus file...\n      //TODO: read raw list of names??\n      fclose( f );\n      COMP_ERR(\"error parsing fselection file '%s'. bogus header! expected 'str' or 'idx' at beginning. found '%s'.\",selFile,line);\n    }\n  }\n  return 0;\n}\n\nvoid cDataSelector::fetchConfig()\n{\n  cDataProcessor::fetchConfig();\n\n  dummyMode = getInt(\"dummyMode\");\n\n  outputSingleField = getStr(\"outputSingleField\");\n\n  selFile = getStr(\"selFile\");\n  if (selFile == NULL) {\n\n    // load names of selected features:\n    nSel = getArraySize(\"selected\");\n    if (nSel>0) {\n\n      names = (char**)calloc(1,sizeof(char*) * nSel);\n      int i;\n      for (i=0; i<nSel; i++) {\n        names[i] = (char *)getStr_f(myvprint(\"selected[%i]\",i));\n        if (names[i] == NULL) {\n          SMILE_IERR(1, \"The %i-th element of the 'selected' names list in the config is empty or invalid. Please fix your config (check for double ; !).\", i + 1);\n          COMP_ERR(\"aborting\");\n        }\n        SMILE_IDBG(2,\"selected: '%s'\",names[i]);\n      }\n    } else {\n      // get feature selection by index ranges:\n      nSel = getArraySize(\"selectedRange\");\n      if (nSel > 0) {\n        names = (char**)calloc(1,sizeof(char*) * nSel);\n\n        int i;\n        for (i=0; i<nSel; i++) {\n          names[i] = (char *)getStr_f(myvprint(\"selectedRange[%i]\",i));\n          SMILE_IDBG(2,\"selectedRange: '%s'\",names[i]);\n        }\n        selectionIsRange = 1;\n      } else {\n        SMILE_IERR(1,\"no features selected, this does not make sense!\");\n        COMP_ERR(\"stopping here\");\n      }\n    }\n    if (selectionIsRange) { elementMode = 1; }\n    else {\n      elementMode = getInt(\"elementMode\");\n      if (elementMode) { SMILE_IDBG(2,\"exact element name matching enabled\"); }\n    } \n  } else {\n    SMILE_IDBG(2,\"exact element name matching enabled\");\n    SMILE_IDBG(2,\"loading feature selection from file '%s' (this forces elementMode=1 !).\",selFile);\n    elementMode = 1;\n    loadSelection();\n  }\n\n}\n\n/*\nint cDataSelector::myConfigureInstance()\n{\nint ret=1;\n// if you would like to change the write level parameters... do so HERE:\n\n//\n// .. or override configureWriter() to do so, after the reader config is available!\n//\nret *= cDataProcessor::myConfigureInstance();\nreturn ret;\n}\n*/\n\n/*\nint cDataSelector::configureWriter(const sDmLevelConfig *c)\n{\n\n// we must return 1, in order to indicate configure success (0 indicates failure)\nreturn 1;\n}\n*/\n\n// TODO!!!!!!!!!!   -> setupNewNames instead of finaliseInstance\n\n// field selection -> fields (arrays) will be added as arrays in output\n// element selection -> every output field will be one element\n// how to choose the mode?? \n// --> a) if array index is given -> element selection\n// --> b) if no array index for an array is given (field selection, select full field)\n// --> c) if array index contains \"-\", assume range -> field selection (partial)\n\nint cDataSelector::setupNewNames(long nEl)\n{\n  if (dummyMode) {\n    addNameAppendField(NULL,\"dummy\");\n    namesAreSet_=1;\n    return 1;\n  }\n  // match our list of selected names to the list of names obtained from the reader\n  long i,j,n;\n  if (elementMode) {\n    long _N = reader_->getLevelN();  \n    nElSel = 0;\n    if (selectionIsRange) {\n      idxSelected = (long *)calloc(1,sizeof(long)*_N);\n      for (i=0; i<nSel; i++) {\n        long start, end;\n        char * sep = strchr(names[i],'-');\n        char *eptr=NULL;\n        if (sep != NULL) { //range\n          *sep = 0; \n          start = strtol(names[i],&eptr,10); if (eptr == names[i]) { SMILE_IERR(1,\"parse error in config option 'selectedRange[%i]' : '%s' ! Expected a range <start>-<end>! Negative numbers are not allowed!\",i,names[i]); }\n          if (*(sep+1) == '$') {\n            end = _N-1;\n          } else {\n            end = strtol(sep+1,&eptr,10); if (eptr == sep+1) { SMILE_IERR(1,\"parse error in config option 'selectedRange[%i]' : '%s' ! Expected a range <start>-<end>! Negative numbers are not allowed!\",i,names[i]); }\n          }\n        } else { // single number\n          start = strtol(names[i],&eptr,10); if (eptr == names[i]) { SMILE_IERR(1,\"parse error in config option 'selectedRange[%i]' : '%s' ! Expected a single integer number (or a range with '-')! Negative numbers are not allowed!\",i,names[i]); }\n          end = start;\n        }\n        if (start > end) { \n          SMILE_IERR(1,\"start element index (%i) cannot be greater than end elemet index (%i) ! Setting start = %i\",start,end,end);\n          start = end;\n        }\n        if (end>=_N) {\n          SMILE_IERR(1,\"end element index (%i) out of range! Must be < %i. Setting end = %i\",end,_N,_N-1);\n          end = _N-1;\n        }\n        nElSel += end-start+1;\n        for (j=start; j<=end; j++) {\n          idxSelected[j] = 1;\n        }\n      }\n      for (i=0; i<_N; i++) {\n        if (idxSelected[i]) {\n          char * nnn = reader_->getElementName(i);\n          if (nnn!=NULL) {\n            SMILE_IMSG(3,\"selected element %i, name '%s'\\n\",i,nnn);\n            writer_->addField(nnn,1);\n            free(nnn);\n          }\n          // TODO: check for full array fields in range and add them as original array fields...??\n        }\n      }\n    } else {\n      mapping = (sDataSelectorSelData *)calloc(1,sizeof(sDataSelectorSelData) * nSel);\n      int *isFound = (int*)calloc(1,sizeof(int)*nSel);\n      for (n=0; n<_N; n++) {\n        //  int found=0;\n        //  SMILE_IDBG(4,\"selstr %i of %i\",i,outputSelStr.n);\n        char * tmpname = reader_->getElementName(n);\n        for (i=0; i<nSel; i++) {\n          if (!isFound[i]) {\n            if (!strcmp(tmpname,names[i])) {\n              mapping[i].eIdx = n;\n              nElSel++; isFound[i]=1;\n              break;\n            }\n          }\n        }\n        free(tmpname);\n        if (nElSel >= nSel) break;\n      }\n\n\n      if (nElSel < nSel) {\n        SMILE_IERR(1,\"%i elements which were requested in element selection file were not found in current input data! please check openSMILE config! These elements are:\",nSel-nElSel);\n        for (i=0; i<nSel; i++) {\n          if (isFound[i]==0) {\n            SMILE_IERR(1,\"  element '%s' \",names[i]);\n          }\n        }\n        const FrameMetaInfo * fmeta = reader_->getFrameMetaInfo();\n        SMILE_IMSG(1, \"Available field names are:\");\n        fmeta->printFieldNames();\n        COMP_ERR(\"Your system will not run stable, due to data incompatibilities. Thus, we are aborting here!\");\n      } else {\n        for (i=0; i<nSel; i++) {\n          if (selFile == NULL) {\n            const char *newname = getStr_f(myvprint(\"newNames[%i]\",i));\n            if (newname != NULL) {\n              writer_->addField(newname);\n            } else {\n              if (nameAppend_ != NULL) {\n                char * tmp = myvprint(\"%s_%s\", names[i], nameAppend_);\n                writer_->addField(tmp); free(tmp);\n              } else {\n                writer_->addField(names[i]);  // if no newName is given, add old name\n              }\n            }\n          } else {\n            if (nameAppend_ != NULL) {\n              char * tmp = myvprint(\"%s_%s\",names[i],nameAppend_);\n              writer_->addField(tmp); free(tmp);\n            } else {\n              writer_->addField(names[i]);  // if no newName is given, add old name\n            }\n          }\n        }\n        SMILE_IDBG(3,\"mapping computed successfully\");\n      }\n      free(isFound);\n    }\n    /*\n    for (j=0; j<nSel; j++) {\n    int found = 0;\n    for (i=0; i<_N; i++) {\n    char * tmp = reader->getElementName(i);\n    if (!strcmp(tmp,names[j])) {\n    // we found a match...\n    found = 1;\n    mapping[nElSel++].eIdx = i;\n    if (selFile == NULL) {\n    const char *newname = getStr_f(myvprint(\"newNames[%i]\",j));\n    if (newname != NULL) {\n    writer->addField(newname);\n    } else {\n    writer->addField(tmp);  // if no newName is given, add old name\n    }\n    } else {\n    writer->addField(tmp);\n    }\n    }\n    free(tmp);\n    }\n    if (found==0) {\n    SMILE_IERR(1,\"element '%s' requested in selection, but not found in input elements! please check input config!\",names[j]);\n    }\n    }\n    SMILE_IDBG(2,\"selected %i elements of %i requested elements\",nElSel,nSel);\n    */\n  } else {\n\n    // in non-element mode, create a list of expanded element names, then use the same code as in element mode\n    int _N = reader_->getLevelNf();  \n    nElSel = 0; nFSel = 0;\n    mapping = (sDataSelectorSelData *)calloc(1,sizeof(sDataSelectorSelData) * nSel);\n    /// !!!!!!!!!!!!!!!!!!! TODO !!!!!!!!!!!!!!!!!!!!!!!\n    //for (i=0; i<_N; i++) {\n    long dimensionSingleField = 0;\n    for (j=0; j<nSel; j++) {\n\n      // analyse type of field specified in selection, and extract fieldname (if array)\n      const char *fieldname=NULL;\n      int startIdx = 0, endIdx = 0, rangeGiven = 0;\n\n      char *tmp2 = NULL;\n      if (names[j] != NULL) {\n\n        tmp2 = strdup(names[j]);\n        char *ar = strchr(tmp2,'[');\n        if (ar == NULL) { // is non-array field (no [] in name) or full field\n          fieldname=names[j];\n        } else {    // is array field ( with [] in name )\n          *ar = 0;\n          fieldname=tmp2;\n          ar++;\n          int len = (int)strlen(ar);\n\n          if (len > 0) {\n            ar[len-1] = 0;  // remove closing ]\n\n            // look for element [x] OR range [x-y]\n            char *rng = strchr(ar,'-');\n            if (rng != NULL) { // is range\n              *rng = 0; rng++;\n              char *end=NULL;\n              startIdx = strtol(ar, &end, 10); // convert to int\n              if ((end != NULL)&&(end[0] != 0)) { // error, invalid chars\n                SMILE_IERR(1,\"invalid character in array start index in 'selected' field : '%s'\\n\",names[j]);\n                COMP_ERR(\"stopping\");\n              }\n              end=NULL;\n              endIdx = strtol(rng, &end, 10); // convert to int\n              if ((end != NULL)&&(end[0] != 0)) { // error, invalid chars\n                SMILE_IERR(1,\"invalid character in array end index in 'selected' field : '%s'\\n\",names[j]);\n                COMP_ERR(\"stopping\");\n              }\n              rangeGiven=1;\n            } else { // is element in array field\n              char *end=0;\n              startIdx = strtol(ar, &end, 10); // convert to int\n              if ((end != NULL)&&(end[0] != 0)) { // error, invalid chars\n                SMILE_IERR(1,\"invalid character in array index in 'selected' field : '%s'\\n\",names[j]);\n                COMP_ERR(\"stopping\");\n              }\n              endIdx = startIdx; rangeGiven=1;\n            }\n\n          }\n\n        }\n      }\n\n      // check if field exists\n      int __N=0;\n      int arrNameOffset=0;\n      int found = 0;\n      int elIdx = 0;\n      for (i=0; i<_N; i++) { // for each field\n        const char *tmp = reader_->getFieldName(i,&__N,&arrNameOffset);\n        if (!strcmp(fieldname,tmp)) {\n          // match found, ok\n          found = 1;\n          if (!rangeGiven)  { startIdx = 0; endIdx = __N-1; }\n          else {\n            startIdx -= arrNameOffset;\n            endIdx -= arrNameOffset;\n          }\n          mapping[nFSel].fIdx = i;\n          mapping[nFSel].eIdx = elIdx;\n          break;\n        }\n        elIdx += __N;\n      }\n\n\n\n      // add to writer, if found\n      if (!found) {\n        // warn\n        SMILE_IWRN(1,\"field '%s' requested for selection, but not found in input!\",names[j]);\n      } else {\n        // check range of start/end array index\n        if (startIdx < 0) {\n          SMILE_IWRN(1,\"start index (%i) for selected field '%s' is out of range (must be > 0)! Setting start index to 0.\",startIdx,names[j]);\n          startIdx = 0;\n        }\n        else if (startIdx >= __N) {\n          SMILE_IWRN(1,\"start index (%i) for selected field '%s' is out of range (must be < %i)! Setting start index to %i.\",startIdx,names[j],__N,__N-1);\n          startIdx = __N-1;\n        }\n\n        if (endIdx < 0) {\n          SMILE_IWRN(1,\"end index (%i) for selected field '%s' is out of range (must be > 0)! Setting end index to 0.\",endIdx,names[j]);\n          endIdx = 0;\n        }\n        else if (endIdx >= __N) {\n          SMILE_IWRN(1,\"end index (%i) for selected field '%s' is out of range (must be < %i)! Setting end index to %i.\",endIdx,names[j],__N,__N-1);\n          endIdx = __N-1;\n        }\n        //add\n        if (outputSingleField == NULL) {\n          writer_->addField(fieldname, endIdx - startIdx + 1, arrNameOffset + startIdx);\n        } else {\n          dimensionSingleField += endIdx - startIdx + 1;\n        }\n        // set names in mapping, and set nElSel correct\n        // TODO:::.\n        //mapping[nElSel++].fIdx = i; // note: i is still valid from the last for() loop\n        mapping[nFSel].aIdx = startIdx+mapping[nFSel].eIdx; // start index as element index\n        mapping[nFSel++].N = endIdx-startIdx+1; // start index as element index\n        nElSel += endIdx-startIdx+1;\n      }\n\n      if (tmp2 != NULL) free(tmp2);\n    }\n    if (outputSingleField != NULL) {\n      writer_->addField(outputSingleField, dimensionSingleField);\n    }\n  }\n  namesAreSet_ = 1;\n  return nElSel;\n}\n\n/*\nint cDataSelector::myFinaliseInstance()\n{\nreturn cDataProcessor::myFinaliseInstance();\n}\n*/\n\nint cDataSelector::myTick(long long t)\n{\n  if (dummyMode) return 0;\n\n  SMILE_DBG(4,\"tick # %i, processing value vector\",t);\n\n  // get next frame from dataMemory\n  cVector *vec = reader_->getNextFrame();\n  if (vec != NULL) {\n\n    if (vecO == NULL) vecO = new cVector(nElSel, vec->type);\n    long i;\n\n    if (vec->type == DMEM_FLOAT) {\n\n      if (elementMode) {\n        if (selectionIsRange) {\n          long j=0;\n          for (i=0; i<vec->N; i++) {\n            if (idxSelected[i]) { vecO->dataF[j++] = vec->dataF[i]; }\n          }\n        } else {\n          for (i=0; i<nElSel; i++) {\n            vecO->dataF[i] = vec->dataF[mapping[i].eIdx];\n          }\n        }\n      } else {\n        int j; long n=0;\n        for (i=0; i<nFSel; i++) {\n          for (j=0; j<mapping[i].N; j++) {\n            vecO->dataF[n++] = vec->dataF[mapping[i].aIdx+j];\n          }\n        }\n      }\n\n    } else if (vec->type == DMEM_INT) {\n\n      if (elementMode) {\n        if (selectionIsRange) {\n          long j=0;\n          for (i=0; i<vec->N; i++) {\n            if (idxSelected[i]) { vecO->dataI[j++] = vec->dataI[i]; }\n          }\n        } else {\n          for (i=0; i<nElSel; i++) {\n            vecO->dataI[i] = vec->dataI[mapping[i].eIdx];\n          }\n        }\n      } else {\n        int j; long n=0;\n        for (i=0; i<nFSel; i++) {\n          for (j=0; j<mapping[i].N; j++) {\n            vecO->dataI[n++] = vec->dataI[mapping[i].aIdx+j];\n          }\n        }\n      }\n\n    }\n\n\n    vecO->tmetaReplace(vec->tmeta);\n\n    // save to dataMemory\n    writer_->setNextFrame(vecO);\n\n    //   writer->setNextFrame(myVec);\n    return 1;\n\n  } \n\n  return 0;\n\n}\n\n\ncDataSelector::~cDataSelector()\n{\n  int i;\n  if (vecO != NULL) delete(vecO);\n  if (mapping!=NULL) free(mapping);\n  if (idxSelected!=NULL) free(idxSelected);\n  if (names!=NULL) {\n    if (selFile != NULL) {\n      for (i=0; i<nSel; i++) {\n        if (names[i] != NULL) free(names[i]);  // memory allocated via strdup()\n      }\n    } // else we don't free the names, since they are allocated in the config manager!\n    free(names); \n  }\n}\n\n"
  },
  {
    "path": "src/core/dataSink.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\ndataSink\nwrite data to data memory...\n\n*/\n// TODO: derived class dataSinkChunk (receives turn start/end messages), -> dataSinkChunkFile (writes data to files)\n\n\n#include <core/dataSink.hpp>\n\n#define MODULE \"cDataSink\"\n\nSMILECOMPONENT_STATICS(cDataSink)\n\nSMILECOMPONENT_REGCOMP(cDataSink)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CDATASINK;\n  sdescription = COMPONENT_DESCRIPTION_CDATASINK;\n\n  // configure your component's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n  if (ct->setField(\"reader\", \"The configuration of the cDataReader subcomponent, which handles the dataMemory interface for reading of input\",\n                  sconfman->getTypeObj(\"cDataReader\"), NO_ARRAY, DONT_FREE) == -1) {\n     rA=1; // if subtype not yet found, request , re-register in the next iteration\n  }\n  \n  ct->setField(\"blocksize\", \"The size of the data blocks to read at once, in frames (overwrites blocksize_sec, if set)\", 0,0,0);\n  ct->setField(\"blocksizeR\", \"The size of the data blocks to read at once, in frames (this overwrites blocksize and blocksize_sec!) (this option is provided for compatibility only... it is exactly the same as 'blocksize')\", 0,0,0);\n  ct->setField(\"blocksize_sec\", \"The size of the data blocks to read at once, in seconds\", 0);\n  ct->setField(\"blocksizeR_sec\", \"The size of the data blocks to read at once, in seconds (this overwrites blocksize_sec!) (this option is provided for compatibility only... it is exactly the same as 'blocksize')\", 0,0,0);\n  ct->setField(\"errorOnNoOutput\",\"1 = show an error message if no output was written by this sink during this run.\",0);\n  SMILECOMPONENT_IFNOTREGAGAIN( {} )\n  SMILECOMPONENT_MAKEINFO_ABSTRACT(cDataSink);\n}\n\nSMILECOMPONENT_CREATE_ABSTRACT(cDataSink)\n\n//-----\n\ncDataSink::cDataSink(const char *_name) :\n  cSmileComponent(_name),\n  reader_(NULL),\n  blocksizeR_(1),\n  blocksizeR_sec_(-1.0),\n  nWritten_(0)\n{\n  char *tmp = myvprint(\"%s.reader\",getInstName());\n  reader_ = (cDataReader *)(cDataReader::create(tmp));\n  if (reader_ == NULL) {\n    COMP_ERR(\"Error creating dataReader '%s'\",tmp);\n  }\n  if (tmp != NULL) free(tmp);\n}\n\nvoid cDataSink::mySetEnvironment()\n{\n  reader_->setComponentEnvironment(getCompMan(), -1, this);\n}\n\nvoid cDataSink::fetchConfig()\n{\n  blocksizeR_sec_ = getDouble(\"blocksize_sec\");\n  if ( (blocksizeR_sec_ <= 0.0) || (isSet(\"blocksizeR_sec\")) ) {\n    blocksizeR_sec_ = getDouble(\"blocksizeR_sec\");\n  }\n  SMILE_IDBG(2,\"blocksizeR (sec.) = %f\",blocksizeR_sec_);\n  blocksizeR_ = getInt(\"blocksize\");\n  if ( (blocksizeR_ <= 0) || (isSet(\"blocksizeR\")) ) {\n    blocksizeR_ = getInt(\"blocksizeR\");\n  }\n  errorOnNoOutput_ = getInt(\"errorOnNoOutput\");\n}\n\nint cDataSink::myRegisterInstance(int *runMe)\n{\n  int ret = reader_->registerInstance();\n  if ((ret) && (runMe!=NULL)) {\n    *runMe = runMeConfig();\n  }\n  return ret;\n}\n\nint cDataSink::configureReader() \n{ \n  reader_->setBlocksize(blocksizeR_);\n  return 1; \n}\n\nint cDataSink::myConfigureInstance()\n{\n  int ret = reader_->configureInstance();\n  if (ret) {\n    // convert blocksize options, so all options are accessible, if possible:\n    // 1. blocksize values in frames override those in seconds:\n    // 2. now do the inverse...\n    double TT = reader_->getLevelT();\n    if (blocksizeR_ > 0) {\n      blocksizeR_sec_ = (double)blocksizeR_ * TT;\n    } else if ((blocksizeR_sec_ > 0.0)&&(TT != 0.0)) {\n      blocksizeR_ = (long) ceil (blocksizeR_sec_ / TT);\n    } else {\n      SMILE_IDBG(3,\"using fallback blocksize of 1, because blocksize or blocksize_sec was not set in config!\");\n      blocksizeR_ = 1;\n    }\n    if (!configureReader()) {\n      SMILE_IERR(1,\"configureReader() returned 0 (failure)!\");\n      return 0;  \n    }\n  }\n  return ret;\n}\n\nint cDataSink::myFinaliseInstance()\n{\n  return reader_->finaliseInstance();\n}\n\ncDataSink::~cDataSink()\n{  \n  if (errorOnNoOutput_ && nWritten_ == 0) {\n    SMILE_IERR(1, \"No output was written! (Maybe the input was too short to extract features from, or the config is broken?)\");\n  }\n  if (reader_ != NULL) { delete reader_; }\n}\n\n"
  },
  {
    "path": "src/core/dataSource.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\ndataSource\nwrite data to data memory...\n\n*/\n\n\n#include <core/dataSource.hpp>\n\n#define MODULE \"cDataSource\"\n\n\nSMILECOMPONENT_STATICS(cDataSource)\n\nSMILECOMPONENT_REGCOMP(cDataSource)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CDATASOURCE;\n  sdescription = COMPONENT_DESCRIPTION_CDATASOURCE;\n\n  // configure your component's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n  if (ct->setField(\"writer\", \"The configuration of the cDataWriter subcomponent, which handles the dataMemory interface for data output\",\n                  sconfman->getTypeObj(\"cDataWriter\"), NO_ARRAY, DONT_FREE) == -1) {\n     rA=1; // if subtype not yet found, request , re-register in the next iteration\n  }\n\n  ct->setField(\"buffersize\", \"The buffer size for the output level in frames (this overwrites buffersize_sec)\", 0,0,0);\n  ct->setField(\"buffersize_sec\", \"The buffer size for the output level in seconds\", 0.0);\n  ct->setField(\"blocksize\", \"A size of data blocks to write at once, in frames (same as blocksizeW for source only components, this overwrites blocksize_sec, if set)\", 0,0,0);\n  ct->setField(\"blocksizeW\", \"The size of data blocks to write in frames (this overwrites blocksize and blocksize_sec, if it is set) (this option is provided for compatibility only... it is exactly the same as 'blocksize')\", 0,0,0);\n  ct->setField(\"blocksize_sec\", \"The size of data blocks to write at once, in seconds\", 0.0);\n  ct->setField(\"blocksizeW_sec\", \"The size of data blocks to write at once, in seconds (this option overwrites blocksize_sec!) (this option is provided for compatibility only... it is exactly the same as 'blocksize')\", 0.0,0,0);\n  ct->setField(\"period\", \"(optional) The period of the input frames (in seconds), if it cannot be determined from the input file format. (if set and != 0, this will overwrite any automatically set values, e.g. from samplerate and writer.levelconf etc. (NOTE: this behaviour also depends on the source component, whether it overwrites period in configureWriter() or whether it keeps the period if it is != 0.0))\", 0.0,0,0);\n  ct->setField(\"basePeriod\", \"(optional) The base period of the input data (in seconds). The default -1.0 will force the code to use the value of period (unless overwritten by configureWriter().)\", -1.0);\n  SMILECOMPONENT_IFNOTREGAGAIN( {} )\n  SMILECOMPONENT_MAKEINFO_ABSTRACT(cDataSource);\n}\n\nSMILECOMPONENT_CREATE_ABSTRACT(cDataSource)\n\n//-----\n\ncDataSource::cDataSource(const char *_name) :\n  cSmileComponent(_name),\n  writer_(NULL),\n  vec_(NULL),\n  mat_(NULL),\n  blocksizeW_(1),\n  blocksizeW_sec(0.0),\n  buffersize_(10),\n  buffersize_sec_(0.0),\n  period_(0.0),\n  basePeriod_(0.0),\n  namesAreSet_(0)\n{\n  char *tmp = myvprint(\"%s.writer\",getInstName());\n  writer_ = (cDataWriter *)(cDataWriter::create(tmp));\n  if (writer_ == NULL) {\n    COMP_ERR(\"Error creating dataWriter '%s'\",tmp);\n  }\n  if (tmp!=NULL) free(tmp);\n}\n\nvoid cDataSource::mySetEnvironment()\n{\n  writer_->setComponentEnvironment(getCompMan(), -1, this);\n}\n\nvoid cDataSource::allocVec(int n)\n{\n  if (vec_ != NULL) { delete vec_; }\n  vec_ = new cVector(n);\n}\n\nvoid cDataSource::allocMat(int n, int t)\n{\n  if (mat_ != NULL) { delete mat_; }\n  mat_ = new cMatrix(n,t);\n}\n\nvoid cDataSource::fetchConfig()\n{\n  buffersize_sec_ = getDouble(\"buffersize_sec\");\n  SMILE_IDBG(2, \"buffersize (sec.) = %f\", buffersize_sec_);\n  buffersize_ = getInt(\"buffersize\");\n  SMILE_IDBG(2, \"buffersize (frames.) = %i\", buffersize_);\n  blocksizeW_sec = getDouble(\"blocksize_sec\");\n  if ( (blocksizeW_sec <= 0.0) || (isSet(\"blocksizeW_sec\")) ) {\n    blocksizeW_sec = getDouble(\"blocksizeW_sec\");\n  }\n  SMILE_IDBG(2, \"blocksizeW (sec.) = %f\", blocksizeW_sec);\n  blocksizeW_ = getInt(\"blocksize\");\n  if ( (blocksizeW_ <= 0) || (isSet(\"blocksizeW\")) ) {\n    blocksizeW_ = getInt(\"blocksizeW\");\n  }\n  SMILE_IDBG(2, \"blocksizeW (frames, from config only) = %i\", blocksizeW_);\n  period_ = getDouble(\"period\");\n  basePeriod_ = getDouble(\"basePeriod\");  \n}\n\nint cDataSource::myRegisterInstance(int *runMe)\n{\n  int ret = writer_->registerInstance();\n  if ((ret)&&(runMe!=NULL)) {\n    // call runMe config hook\n    *runMe = runMeConfig();\n  }\n  return ret;\n}\n\nint cDataSource::myConfigureInstance()\n{\n// TODO: set writer config\n// if (!writer->isManualConfigSet()) {\n//     writer->setConfig(1,2*buffersize,T, 0.0, 0.0 , 0, DMEM_FLOAT);  // lenSec = (double)(2*buffersize)*T\n// }\n  sDmLevelConfig c2;\n\n  c2.T = period_;\n  c2.blocksizeWriter = -1;\n  c2.basePeriod = basePeriod_; //-1.0;\n  \n  // provide a hook, to allow a derived component to modify the writer config we have obtained from the parent level:\n  int ret = configureWriter(c2);\n  // possible return values (others will be ignored): \n  // -1 : configureWriter has overwritten c->nT value for the buffersize, myConfigureInstance will not touch nT !\n  // 0 : failure, myConfigure must exit with code 0\n  // 1 : default / success\n  if (!ret) {\n    SMILE_IERR(1,\"configureWriter() returned 0 (failure)!\");\n    return 0;  \n  }\n\n  // since this component is a source, it sets the base period\n  // if it was not set by configureWriter, we have to set it to T here! \n  if (c2.basePeriod == -1.0) \n    c2.basePeriod = c2.T;\n\n  // convert blocksize options, so all options are accessible, if possible:\n  // 1. blocksize values in frames override those in seconds:\n  // 2. now do the inverse...\n  if (blocksizeW_ > 0) {\n    blocksizeW_sec = (double)blocksizeW_ * c2.T;\n  } else if ((blocksizeW_sec > 0.0)&&(c2.T != 0.0)) {\n    blocksizeW_ = (long) ceil (blocksizeW_sec / c2.T);\n  } else {\n    SMILE_IDBG(3,\"using fallback blocksize of 1, because blocksize or blocksize_sec was not set in config!\");\n    blocksizeW_ = 1;\n  }\n\n  if (c2.blocksizeWriter == -1) { // if configureWriter has not modified the blocksize ...\n    // get writer blocksize from \"blocksizeW\" config options\n    c2.blocksizeWriter = blocksizeW_;\n  } else {\n    blocksizeW_ = c2.blocksizeWriter;\n  }\n\n  if (ret!=-1) {\n    if (buffersize_ > 0) {\n      c2.nT = buffersize_;\n    } else {\n      if (buffersize_sec_ > 0.0) {\n        if (c2.T != 0.0) {\n          c2.nT = (long)ceil(buffersize_sec_/c2.T);\n        } else {\n          c2.nT = (long)ceil(buffersize_sec_);\n        }\n      } else {\n        SMILE_IDBG(3,\"using default buffersize 100 because buffersize or buffersize_sec was not set in config!\");\n        c2.nT = 100;\n      }\n    }\n  }\n\n  writer_->setConfig(c2,0);\n\n  return writer_->configureInstance();\n}\n\nint cDataSource::myFinaliseInstance()\n{\n  // hook, to allow component to set data element names:\n  if (!setupNewNames(0)) {\n    SMILE_IERR(1,\"setupNewNames() returned 0 (failure)!\");\n    return 0;\n  }\n  return writer_->finaliseInstance();\n}\n\ncDataSource::~cDataSource()\n{\n  if (writer_ != NULL) { delete writer_; }\n  if (vec_ != NULL) { delete vec_; }\n  if (mat_ != NULL) { delete mat_; }\n}\n\n"
  },
  {
    "path": "src/core/dataWriter.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: dataWriter */\n\n\n#include <core/dataWriter.hpp>\n\n#define MODULE \"cDataWriter\"\n\n\nSMILECOMPONENT_STATICS(cDataWriter)\n\nSMILECOMPONENT_REGCOMP(cDataWriter)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CDATAWRITER;\n  sdescription = COMPONENT_DESCRIPTION_CDATAWRITER;\n\n  // configure your component's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n\n  ct->setField(\"dmInstance\", \"The cDataMemory instance this writer shall connect to. This allows for complex configurations with multiple, independent data memories. For most applications the default 'dataMemory' should be reasonable. This is also the assumed default when automatically generating a configuration file.\", \"dataMemory\",0,0);\n  ct->makeMandatory(ct->setField(\"dmLevel\", \"The data memory level this writer will write data to. You can specify any name here, this writer will register and create a level of this name in the dataMemory during initialisation of openSMILE. Please be aware of the fact that only one writer can write to a data memory level, therefore you are not allowed to use the same name again in a 'dmLevel' option of any other component in the same config.\", (char *)NULL));\n\n  if (ct->setField(\"levelconf\", \"This structure specifies an optional configuration of this data memory level.\\n   If this is given, it will overwrite any defaults or inherited values from input levels. For details see the help on the configuration type 'cDataMemoryLevel'.\",\n                  sconfman->getTypeObj(\"cDataMemory.level\"), NO_ARRAY, DONT_FREE) == -1) {\n     rA=1; // if subtype not yet found, request , re-register in the next iteration\n  }\n\n  SMILECOMPONENT_IFNOTREGAGAIN( {} )\n\n  SMILECOMPONENT_MAKEINFO_NODMEM(cDataWriter);\n}\n\nSMILECOMPONENT_CREATE(cDataWriter)\n\n///------------------------------------ dynamic part:\n\ncDataWriter::cDataWriter(const char *_name) : cSmileComponent(_name),\n  dm(NULL),\n  dmInstName(NULL),\n  dmLevel(NULL),\n  level(-1),\n  override_nT(0)\n//  blocksize(1)\n{\n // if (cm!=NULL) fetchConfig();\n}\n\nvoid cDataWriter::fetchConfig() {\n  // get name of dataMemory instance to connect to\n  dmInstName = getStr(\"dmInstance\");\n  if (dmInstName == NULL) COMP_ERR(\"fetchConfig: getStr(dmInstance) returned NULL! missing option in config file?\");\n\n  // now get read level information:\n  dmLevel = getStr(\"dmLevel\");\n  if (dmLevel == NULL) COMP_ERR(\"fetchConfig: getStr(dmLevel) returned NULL! missing option in config file?\");\n}\n\n//----- BEGIN obsolete methods --------\n// manual configuration:\n/*\nvoid cDataWriter::setConfig(int isRb, long nT, double period, double lenSec, int dyn, int _type, int _override)\n{\n  cfg.isRb = isRb;\n  if (!override_nT) cfg.nT = nT;\n  cfg.T = period;\n  if ((lenSec == 0.0)&&(nT>0)) lenSec = ((double)nT) * period;\n  cfg.lenSec = lenSec;\n  cfg.frameSizeSec = period;\n  cfg.growDyn = dyn;\n  cfg.type = _type;\n  //override = _override;\n  manualConfig = 1;\n}\n\n// manual configuration:\nvoid cDataWriter::setConfig(int isRb, long nT, double period, double lenSec, double frameSizeSec, int dyn, int _type, int _override)\n{\n  cfg.isRb = isRb;\n  if (!override_nT) cfg.nT = nT;\n  cfg.T = period;\n  if ((lenSec == 0.0)&&(nT>0)) lenSec = ((double)nT) * period;\n  cfg.lenSec = lenSec;\n  if (frameSizeSec == 0.0) frameSizeSec = period;\n  cfg.frameSizeSec = frameSizeSec;\n  cfg.growDyn = dyn;\n  cfg.type = _type;\n // override = _override;\n  manualConfig = 1;\n}\n*/\n//----- END obsolete methods ------------\n\n// manual configuration:\nvoid cDataWriter::setConfig(sDmLevelConfig &_cfg, int _override)\n{\n  /* just ensure that we don't have corrupt values */\n  _cfg.blocksizeReader = 0;\n  _cfg.N = 0;\n  _cfg.Nf = 0;\n  _cfg.fmeta = NULL;\n  _cfg.finalised = 0;\n  _cfg.blocksizeIsSet = 0;\n  _cfg.namesAreSet = 0;\n  /* some last sanity checks: */\n  if (_cfg.nT < 2) _cfg.nT = 2;\n  if (_cfg.T < 0.0) _cfg.T = 0.0;\n  if ((_cfg.frameSizeSec <= 0.0)&&(_cfg.T > 0.0)) _cfg.frameSizeSec = _cfg.T;\n  if (_cfg.blocksizeWriter < 1) _cfg.blocksizeWriter = 1;\n\n  cfg.updateFrom(_cfg);\n  override_ = _override;\n  manualConfig_ = 1;\n}\n\nvoid cDataWriter::setBuffersize(long nT)\n{\n  cfg.nT = nT;\n  override_nT = 1;\n}\n\nint cDataWriter::myRegisterInstance(int *runMe)\n{\n  const char * tn = getComponentInstanceType(dmInstName);\n  if (tn == NULL) {\n    SMILE_IWRN(4,\"cannot yet find dataMemory component '%s'!\",dmInstName);\n    return 0;\n  }\n  if (!strcmp(tn, COMPONENT_NAME_CDATAMEMORY)) {\n    dm = (cDataMemory *)getComponentInstance(dmInstName);\n    if (dm == NULL) {\n      SMILE_IERR(1,\"dataMemory instance dmInstance='%s' was not found in componentManager!\",dmInstName);\n//      COMP_ERR(\"failed to register!\");\n      return 0;\n    }\n  } else { // not datamemory type..\n    if (dm == NULL) {\n      SMILE_IERR(1,\"dmInstance='%s' -> not of type %s (dataMemory)!\",dmInstName,COMPONENT_NAME_CDATAMEMORY);\n//      COMP_ERR(\"failed to register!\");\n      return 0;\n    }\n  }\n\n  dm->registerWriteRequest(dmLevel,getInstName());\n\n  return 1;\n}\n\n/* create and configure writer level */\n// level config can be set:\n//   manually by setConfig, etc.  (usually used by dataProcessors to set output level config to input level config)\n//                                (this method is also used by dataSources to configure buffersize/blocksize)\n//   if not set manually from the levelconf struct in the config (default values)\n//   or, if explicitly specified in the config, from the levelconf values wich will overwrite the manual config values\nint cDataWriter::myConfigureInstance()\n{\n  cfg.noHang = getInt(\"levelconf.noHang\");\n\n  // TODO: better control of manual config overwriting levelconf and vice versa ...\n  //if (!override) {\n\n    if (isSet(\"levelconf.T\")||(!manualConfig_)) cfg.T = getDouble(\"levelconf.T\");\n    if (isSet(\"levelconf.lenSec\")||(!manualConfig_)) {\n      cfg.lenSec = getDouble(\"levelconf.lenSec\");\n      if (cfg.T != 0.0) \n        cfg.nT = (int)(cfg.lenSec / cfg.T)+1;\n    }\n    if (isSet(\"levelconf.frameSizeSec\")||(!manualConfig_)) cfg.frameSizeSec = getDouble(\"levelconf.frameSizeSec\");\n\n//    if (!override_nT) {\n      if (isSet(\"levelconf.nT\")||(!manualConfig_)) {\n        cfg.nT = getInt(\"levelconf.nT\");\n      }\n    //}\n\n    if (isSet(\"levelconf.growDyn\")||(!manualConfig_)) cfg.growDyn = getInt(\"levelconf.growDyn\");\n    if (isSet(\"levelconf.isRb\")||(!manualConfig_)) cfg.isRb = getInt(\"levelconf.isRb\");\n  \n    if (isSet(\"levelconf.type\")||(!manualConfig_)) {\n      const char *tp = getStr(\"levelconf.type\");\n      if (tp!=NULL) {\n        if (!strcmp(tp,\"float\")) { cfg.type = DMEM_FLOAT; }\n        else if (!strcmp(tp,\"int\")) { cfg.type = DMEM_INT; }\n          else if (!strcmp(tp,\"integer\")) { cfg.type = DMEM_INT; }\n      }\n    } \n\n//  }\n\n  // this will create the level specified, if it not already exists (then a warning will be issued by the dataMemory: multiple writers)\n  level = dm->addLevel((sDmLevelConfig *)&cfg, dmLevel);\n  if (level>=0) { return 1; }\n\n  SMILE_IERR(2,\"configureInstance: error adding level '%s' to data memory instance '%s'!\",dmLevel,dmInstName);\n  return 0;\n}\n\n\n\n// set the array name offset of last field that was added\nvoid cDataWriter::setArrNameOffset(int arrNameOffset) \n{\n  dm->setArrNameOffset(level, arrNameOffset);\n}\n\n// this function may be called only before finalise instance, i.e. after configure instance\nint cDataWriter::addField(const char*lname, int lN, int arrNameOffset)\n{\n  if (lname != NULL) {\n    int r = dm->addField(level, lname, lN, arrNameOffset);\n    if (r) cfg.namesAreSet++;\n    return r;\n  }\n  else return -1;\n}\n\nint cDataWriter::myFinaliseInstance()\n{\n  // check if level names have been set...?\n  if (cfg.namesAreSet <= 0) {\n    SMILE_IERR(2,\"finaliseInstance: no names (fields) were set for dmLevel='%s'\",dmLevel);\n    return 0;\n  }\n\n  // indicate to datamemory that the names have been completely set\n  dm->fixateLevel(level);\n\n  const sDmLevelConfig *c = dm->getLevelConfig(level);\n  if (c!=NULL) \n    cfg.updateFrom(*c);\n\n  SMILE_IDBG(4,\"successfully finalised dataWriter, dmLevel='%s' level=%i in memory '%s'\",dmLevel,level,dmInstName);\n  \n  return 1;\n}\n\n// ---\n// absolute position write functions:\nint cDataWriter::setFrame(long vIdx, const cVector *vec, int special)\n{\n  return dm->setFrame(level, vIdx, vec, special);\n}\n\nint cDataWriter::setMatrix(long vIdx, const cMatrix *mat, int special)\n{\n  return dm->setMatrix(level, vIdx, mat, special);\n}\n\n// sequential write functions: write next frame(s)\nint cDataWriter::setNextFrame(const cVector *vec)  // append at end in dataMemory level\n{ \n  return setFrame(0, vec, DMEM_IDX_CURW);\n}\n\nint cDataWriter::setNextMatrix(const cMatrix *mat)   // append at end in dataMemory (no overlap)\n{\n  return setMatrix(0, mat, DMEM_IDX_CURW);\n}\n\nint cDataWriter::checkWrite(long len)\n{\n  const sDmLevelConfig *c = dm->getLevelConfig(level);\n  if (c!=NULL) {\n    if ((c->growDyn)&&(!(c->isRb))) return 1; // if growDyn, a write should always succeed, except for that we run out of memory\n    // if nReaders in write level is 0 (dead end), then return 1 if noHang == 1 in write level\n    if (c->noHang == 2) return 1;\n    \n    //printf(\"'%s' checkwrite : %i %i\\n\",getInstName(),dm->getNreaders(level),c->noHang);\n    if ((dm->getNreaders(level) <= 0) && (c->noHang==1)) {\n      return 1;\n    }\n  }\n\n  return ( dm->getNFree(level) >= len );\n}\n\n/*\n\nint cDataWriter::getLevelN()   // number of elements\n{\n  const sDmLevelConfig *c = dm->getLevelConfig(level);\n  if (c!=NULL) return c->N;\n  else return 0;\n}\n\nint cDataWriter::getLevelNf()   // number of fields\n{\n  const sDmLevelConfig *c = dm->getLevelConfig(level);\n  if ((c!=NULL)&&(c->fmeta != NULL)) return c->fmeta->N;\n  else return 0;\n}\n\ndouble cDataWriter::getLevelT()   // frame period (or 0.0 for unperiodic)\n{\n  const sDmLevelConfig *c = dm->getLevelConfig(level);\n  if (c!=NULL) return c->T;\n  else return -1.0;\n}\n\nconst FrameMetaInfo * cDataWriter::getFrameMetaInfo()    // names of fields, etc.\n{\n  const sDmLevelConfig *c = dm->getLevelConfig(level);\n  if (c!=NULL) return c->fmeta;\n  else return NULL;\n}\n\n*/\n"
  },
  {
    "path": "src/core/exceptions.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*\n\n  SMILE exception classes\n  ===========================\n  \n  Exception base class:\n    cSMILException:\n      + int getCode()\n      + int getType()\n        valid type constants:\n          EX_GENERIC, EX_MEMORY, EX_COMPONENT, EX_IO, EX_CONFIG, EX_USER\n      + getText()  : get human readable error message\n\n  GenericException: (cSMILException) [Internal errors, usually not displayed or loggged, only informative purpose]\n    > GenericException(int code)\n    - int getCode()\n    \n  MemoryException: (cSMILException) [Memory allocation errors, etc.]\n    > MemoryException(int code)\n    - int getCode()\n\n  ----------------------------------------------------------------------------\n  ComponentException: (cSMILException) [Any error in a smile component]\n    > ComponentException([const char* module], const char* text)\n    > ComponentException([const char* module], FMT(const char* fmt, ...))\n    + getText()  : get full verbose text of error message\n    - int getCode()\n\n\n  ConfigException: (ComponentException) [Any configuration error]\n    > ConfigException(int origin, [const char *module], const char* text)\n    > ConfigException(int origin, [const char *module], FMT(const char* fmt, ...))\n    + int getOrigin()\n   origin: (exception raised when...)\n          a) errors occur during config file parsing (origin = CE_PARSER)\n          b) a module detects a bogus configuration, invalid value, etc.  (origin = CE_INVALID)\n          c) mandatory parameters are not specified, etc. (origin = CE_MANAGER)\n\n  IOException: (ComponentException) [Any I/O error, drive, network, sound, ...]\n    > IOException([const char *module], [int code], const char* text, )\n    > IOException([const char *module], [int code], FMT(const char* fmt, ...))\n\n  UserException: (ComponentException) [Any other error, user defined...]\n    > UserException([const char *module], int code, const char* text, )\n    > UserException([const char *module], int code, FMT(const char* fmt, ...))\n  \n */\n/*\n#include <stdlib.h>\n#include <stdarg.h>\n#include <stdio.h>\n\n#define MODULE \"exceptionHandler\"\n*/\n\n"
  },
  {
    "path": "src/core/nullSink.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: cNullSink\n----------------------------------\nNULL sink: reads data vectors from data memory and destroys them without writing them anywhere\n----------------------------------\n\n11/2009  Written by Florian Eyben\n*/\n\n\n#include <core/nullSink.hpp>\n\n#define MODULE \"cNullSink\"\n\n\nSMILECOMPONENT_STATICS(cNullSink)\n\nSMILECOMPONENT_REGCOMP(cNullSink)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CNULLSINK;\n  sdescription = COMPONENT_DESCRIPTION_CNULLSINK;\n\n  // we inherit cDataSink configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSink\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN( {} )\n\n  SMILECOMPONENT_MAKEINFO(cNullSink);\n}\n\nSMILECOMPONENT_CREATE(cNullSink)\n\n//-----\n\ncNullSink::cNullSink(const char *_name) :\n  cDataSink(_name)\n{\n}\n\nint cNullSink::myTick(long long t)\n{\n  SMILE_IDBG(4,\"tick # %i, reading value vector to NULL sink\",t);\n  cVector *vec= reader_->getNextFrame();\n  if (vec == NULL) return 0;\n  else \n    // tick success\n    return 1;\n}\n\n\ncNullSink::~cNullSink()\n{\n}\n\n"
  },
  {
    "path": "src/core/smileCommon.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n#include <core/smileCommon.hpp>\n\n\n\n\n#ifdef __DATE__\n#undef APPDATE\n#define APPDATE __DATE__\n#endif \n\nvoid smilePrintHeader()\n{\n  SMILE_PRINT(\" \");\n  SMILE_PRINT(\" =============================================================== \");\n  SMILE_PRINT(\"   %s version %s (Rev. %s)\",APPNAME, APPVERSION, OPENSMILE_SOURCE_REVISION);\n  SMILE_PRINT(\"   Build date: %s (%s)\", APPDATE, OPENSMILE_BUILD_DATE);\n  SMILE_PRINT(\"   Build branch: '%s'\", OPENSMILE_BUILD_BRANCH);\n  SMILE_PRINT(\"   (c) %s by %s\", APPCPYEAR, APPCPAUTHOR);\n  SMILE_PRINT(\"   All rights reserved. See the file COPYING for license terms.\");\n  SMILE_PRINT(\"   %s\", APPCPINST);\n  SMILE_PRINT(\" =============================================================== \");\n  SMILE_PRINT(\" \");\n}\n\n/* check if all elements in the vector are finite. If not, set the element to 0 */\nint checkVectorFinite(FLOAT_DMEM *x, long N) \n{\n  int i; int f = 1;\n  int ret = 1;\n  for (i=0; i<N; i++) {\n    if (isnan(x[i])) {\n      //printf(\"ERRR!\\n X:%f istart: %f iend %f gend %f gstart %f \\n iVI %i II %i end %f start %f step %f startV %f\\n\",X,istart,iend,gend,gstart,ivI,curRange[i].isInit,curRange[i].end,curRange[i].start,curRange[i].step,startV);\n      //SMILE_ERR(2,\"#NAN# value encountered in output (This value is now automatically set to 0, but somewhere there is a bug)! (index %i)\",i);\n      x[i] = 0.0; f=0;\n      ret = 0;\n    } \n    if (isinf(x[i])) {\n      //printf(\"ERRR!\\n X:%f istart: %f iend %f gend %f gstart %f \\n iVI %i II %i end %f start %f step %f startV %f\\n\",X,istart,iend,gend,gstart,ivI,curRange[i].isInit,curRange[i].end,curRange[i].start,curRange[i].step,startV);\n      //SMILE_ERR(2,\"#INF# value encountered in output (This value is now automatically set to 0, but somewhere there is a bug)! (index %i)\",i);\n      x[i] = 0.0; f=0;\n      ret = 0;\n    }\n  }\n  return ret;\n}\n\n// realloc and initialize additional memory with zero, like calloc\nvoid * crealloc(void *a, size_t size, size_t old_size)\n{\n  a = realloc(a,size);\n  if ((old_size < size)&&(a!=NULL)) {\n    char *b = (char *)a + old_size;\n    //fill with zeros:\n    bzero((void*)b, size-old_size);\n  }\n  return a;\n}\n\n/* allocate a string and expand vararg format string expression into it */\n// WARNING: memory allocated by myvprint must freed by the code calling myvprint!!\nchar *myvprint(const char *fmt, ...) {\n  char *s= (char *)malloc(sizeof(char)*(MIN_LOG_STRLEN+4));\n  int LL = MIN_LOG_STRLEN+1;\n  //TODO: use vasprintf(); -> only available on linux :(\n  if (s==NULL) return NULL;\n  va_list ap;\n  va_start(ap, fmt);\n  int len = vsnprintf(s,MIN_LOG_STRLEN+1, fmt, ap);\n  if (len > MIN_LOG_STRLEN) {\n    free(s);\n    s = (char *)malloc(sizeof(char)*(len+4));\n    va_start(ap, fmt);\n    len = vsnprintf(s,len+1, fmt, ap);\n    LL = len+1;\n  } else\n  if (len == -1) { // we are probably on windows...\n    #ifdef _MSC_VER\n    free(s);\n    len = _vscprintf(fmt, ap);\n    s = (char *)malloc(sizeof(char)*(len+4));\n    va_start(ap, fmt);\n    len = vsnprintf(s,len+1, fmt, ap);\n    LL = len+1;\n    #else\n    s[0] = 0; // return a null string\n    #endif\n  }\n  va_end(ap);\n  // ensure the last two characters are 0 !:\n  s[LL] = 0;\n  s[LL+1] = 0;\n  return s;\n}\n\nvoid * memdup(const void *in, size_t size)\n{\n  void *ret = malloc(size);\n  if (ret!=NULL) memcpy(ret,in,size);\n  return ret;\n}\n\n\n\n#ifdef __WINDOWS\nvoid gettimeofday(timeval* p, void* tz /* IGNORED */){\n  union {\n    long long ns100; /*time since 1 Jan 1601 in 100ns units */\n    FILETIME ft;\n  } _now;\n\n  GetSystemTimeAsFileTime( &(_now.ft) );\n  p->tv_usec=(long)((_now.ns100 / 10LL) % 1000000LL );\n  p->tv_sec= (long)((_now.ns100-(116444736000000000LL))/10000000LL);\n  return;\n}\n#endif /* __WINDOWS */\n\n\n#ifdef __MACOS\nint clock_gettime (int clock_id, struct timespec *tp)\n{\n\tstruct timeval tv;\n\tint retval = gettimeofday (&tv, NULL);\n\tif (retval == 0)\n\t\tTIMEVAL_TO_TIMESPEC (&tv, tp); // Convert into `timespec'.\n\treturn retval;\n}\n#endif\n\n#if defined(__HAVENT_GNULIBS) || defined(__ANDROID__)\n\n#define MIN_CHUNK 64\nlong getstr (char **lineptr, size_t *n, FILE *stream, char terminator, int offset)\n{\n  int nchars_avail;\t\t/* Allocated but unused chars in *LINEPTR.  */\n  char *read_pos;\t\t/* Where we're reading into *LINEPTR. */\n  long ret;\n\n  if (!lineptr || !n || !stream)\n    {\n      return -1;\n    }\n\n  if (!*lineptr)\n    {\n      *n = MIN_CHUNK;\n      *lineptr = (char *)malloc (*n);\n      if (!*lineptr)\n\t{\n\t  return -1;\n\t}\n    }\n\n  nchars_avail = (int)(*n) - offset;\n  read_pos = *lineptr + offset;\n\n  for (;;)\n    {\n      register int c = getc (stream);\n\n\n      /* We always want at least one char left in the buffer, since we\n\t always (unless we get an error while reading the first char)\n\t NUL-terminate the line buffer.  */\n\n\n      if (nchars_avail < 2)\n\t{\n\t  if (*n > MIN_CHUNK)\n\t    *n *= 2;\n\t  else\n\t    *n += MIN_CHUNK;\n\n\t  nchars_avail = (int)( (long long)(*n) + (long long)*lineptr - (long long)read_pos );\n\t  *lineptr = (char *)realloc (*lineptr, *n);\n\t  if (!*lineptr)\n\t    {\n\t      return -1;\n\t    }\n\t  read_pos = *n - nchars_avail + *lineptr;\n\t}\n\n      if (ferror (stream))\n\t{\n\t  return -1;\n\t}\n\n      if (c == EOF)\n\t{\n\t  /* Return partial line, if any.  */\n\t  if (read_pos == *lineptr)\n\t    return -1;\n\t  else\n\t    break;\n\t}\n\n      *read_pos++ = c;\n      nchars_avail--;\n\n      if (c == terminator)\n\t/* Return the line.  */\n\tbreak;\n   }\n\n  /* Done - NUL terminate and return the number of chars read.  */\n  *read_pos = '\\0';\n\n  ret = (long)( (long long)read_pos - ((long long)*lineptr + (long long)offset) );\n  return ret;\n}\n\nlong smile_getline (char **lineptr, size_t *n, FILE *stream)\n{\n  return getstr (lineptr, n, stream, '\\n', 0);\n}\n#endif\n\n"
  },
  {
    "path": "src/core/smileComponent.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*\nopenSMILE component hierarchy:\n\ncSmileComponent  (basic cmdline and config functionality)\n |\n v\ncProcessorComponent  - contains: Reader, Writer, ref to data mem, one or more compute components, plus interconnection logic\ncComputeComponent    - implements a specific algo, clearly defined io interface\n                       I: vector, O: vector\n                       I: matrix, O: vector\n                       (O: matrix ?? )\ncReaderComponent     - reads data from dataMemory and provides frame or matrix (also registers read request)\ncWriterComponent     - writes data to dataMemory (takes vector, (or matrix??)), also registers Level (data memory at the end will check, if all dependencies are fullfilled..?)\n*/\n\n\n/*\n   component base class,\n   \n   with register and config functionality\n   \n   \n //\n   \n */\n\n// enable this for debugging to enable profiling support for each component\n#define DO_PROFILING    0\n// enable this to output the profiling result after each tick via SMILE_IMSG(2,...)\n#define PRINT_PROFILING 0\n\n/* good practice for dynamic component library compatibility (will be added soon..):\n\n  define a global register method:\n\n  sComponentInfo * registerMe(cConfigManager *_confman) {\n    sMyComponent::registerComponent(_confman);\n  }\n\n  also: add a pointer to this method to global component list...\n*/\n\n#include <core/smileComponent.hpp>\n#include <core/componentManager.hpp>\n\n#define MODULE \"cSmileComponent\"\n\nSMILECOMPONENT_STATICS(cSmileComponent)\n\n// static, must be overriden by derived component class, these are only examples...!!!!\n\n// register component will return NULL, if the component could not be registered (fatal error..)\n// it will return a valid struct, with rA=1, if some information, e.g. sub-configTypes are still missing\nSMILECOMPONENT_REGCOMP(cSmileComponent)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_XXXX;\n  sdescription = COMPONENT_DESCRIPTION_XXXX;\n\n  // configure your component's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n  \n  //ConfigType *ct = new ConfigType(scname); if (ct == NULL) OUT_OF_MEMORY;\n\n  ct->setField(\"f1\", \"this is an example int\", 0);\n  if (ct->setField(\"subconf\", \"this is config of sub-component\",\n                  sconfman->getTypeObj(\"nameOfSubCompType\"), NO_ARRAY, DONT_FREE) == -1) {\n     rA=1; // if subtype not yet found, request , re-register in the next iteration\n  }\n\n  // ...\n  SMILECOMPONENT_IFNOTREGAGAIN( {} )\n\n    // change cSmileComponent to cMyComponent !\n  SMILECOMPONENT_MAKEINFO(cSmileComponent);\n  //return makeInfo(sconfman, scname, sdescription, cSmileComponent::create, rA);\n}\n\n\nSMILECOMPONENT_CREATE_ABSTRACT(cSmileComponent)\n\n// staic, internal....\nsComponentInfo * cSmileComponent::makeInfo(cConfigManager *_confman, const char *_name, const char *_description, cSmileComponent * (*create) (const char *_instname), int regAgain, int _abstract, int _nodmem)\n{\n  sComponentInfo *info = new sComponentInfo;\n  if (info == NULL) OUT_OF_MEMORY;\n  info->componentName = _name;\n  info->description = _description;\n  info->create = create;\n  info->registerAgain = regAgain;\n  info->abstract = _abstract;\n  info->noDmem = _nodmem;\n  info->next = NULL;\n  \n  return info;\n}\n\n\n//--------------------- dynamic:\n\ncSmileComponent * cSmileComponent::getComponentInstance(const char * name) {\n  if (compman_ != NULL)\n    return compman_->getComponentInstance(name);\n  else\n    return NULL;\n}\n\nconst char * cSmileComponent::getComponentInstanceType(const char * name) {\n  if (compman_ != NULL)\n    return compman_->getComponentInstanceType(name);\n  else\n    return NULL;\n}\n\ncSmileComponent * cSmileComponent::createComponent(const char *name, const char *component_type)\n{\n  if (compman_ != NULL) {\n    return compman_->createComponent(name, component_type);\n  } else {\n    return NULL;\n  }\n}\n\ncSmileComponent::cSmileComponent(const char *instname) :\n  iname_(NULL),\n  id_(-1),\n  compman_(NULL),\n  parent_(NULL),\n  cfname_(NULL),\n  isRegistered_(0),\n  isConfigured_(0),\n  isFinalised_(0),\n  isReady_(0),\n  confman_(NULL),\n  override_(0),\n  manualConfig_(0),\n  cname_(NULL),\n  EOIlevel_(0),\n  EOI_(0),\n  EOIcondition_(0),\n  paused_(0),\n  runMe_(1),\n  doProfile_(DO_PROFILING),\n  printProfile_(PRINT_PROFILING),\n  profileCur_(0.0), profileSum_(0.0)\n{\n  smileMutexCreate(messageMtx_);\n  if (instname == NULL) COMP_ERR(\"cannot create cSmileComponent with instanceName == NULL!\");\n  iname_ = strdup(instname);\n  cfname_ = iname_;\n}\n\nvoid cSmileComponent::setComponentEnvironment(cComponentManager *compman, int id, cSmileComponent *parent)\n{\n  if (compman != NULL) {\n    compman_ = compman;\n    id_ = id;\n  } else {\n    SMILE_IERR(3, \"setting NULL componentManager in cSmileComponent::setComponentEnvironment!\");\n  }\n  parent_ = parent;\n  mySetEnvironment();\n}\n\nint cSmileComponent::sendComponentMessage(const char *recepient, cComponentMessage *msg)\n{\n  int ret=0;\n  if (compman_ != NULL) {\n    if (msg != NULL) msg->sender = getInstName();\n    ret = compman_->sendComponentMessage(recepient, msg);\n  }\n  return ret;\n}\n\ndouble cSmileComponent::getSmileTime() \n{ \n  if (compman_ != NULL) {\n    return compman_->getSmileTime();\n  }\n  return 0.0;\n}\n\nint cSmileComponent::isAbort() \n{ \n  if (compman_ != NULL) return compman_->isAbort();\n  else return 0; \n}\n\nint cSmileComponent::finaliseInstance() \n{\n  if (!isConfigured_) {\n    SMILE_DBG(7,\"finaliseInstance called on a not yet successfully configured instance '%s'\",getInstName());\n    return 0;\n  }\n  if (isFinalised_) return 1;\n  isFinalised_ = myFinaliseInstance();\n  isReady_ = isFinalised_;\n  return isFinalised_;\n}\n\nvoid cSmileComponent::startProfile(long long t, int EOI)\n{\n  gettimeofday( &startTime_, NULL );\n}\n\nvoid cSmileComponent::endProfile(long long t, int EOI)\n{\n  gettimeofday( &endTime_, NULL );\n  profileCur_ = ( (double)(endTime_.tv_sec - startTime_.tv_sec) + (double)(endTime_.tv_usec - startTime_.tv_usec)/1000000.0 );\n  profileSum_ += profileCur_;\n  if (printProfile_) {\n    SMILE_IMSG(2, \"~~~~profile~~~~ cur=%f  sum=%f  tick=%i\\n\", getProfile(0), getProfile(1), t);\n  }\n\n}\n\ncSmileComponent::~cSmileComponent()\n{\n  if ((iname_ != cfname_)&&(cfname_!=NULL)) free (cfname_);\n  if (iname_ != NULL) free(iname_);\n  smileMutexDestroy(messageMtx_);\n}\n\n// signal EOI to componentManager (theoretically only useful for dataSource components, however we make it accessible to all smile components)\n// NOTE: you do not need to do this explicitely.. if all components fail, EOI is assumed, then a new tickLoop is started by the component manager\nvoid cSmileComponent::signalEOI()\n{\n  if (compman_ != NULL)\n    compman_->setEOI();\n}\n\nvoid cSmileComponent::abort_processing() {\n  compman_->requestAbort();\n}\n\n\n\n\n"
  },
  {
    "path": "src/core/smileLogger.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/******************************************************************************/\n\n /*\n\n openSMILE Message Logging\n\n */\n\n\n#include <time.h>\n\n//#include <exceptions.hpp>\n#include <core/smileLogger.hpp>\n\n// include android native logging functionality\n#ifdef __ANDROID__\n#include <android/log.h>\n#endif  //  __ANDROID__\n\n// Global logger variable (used by exception classes for automatically logging...)\nDLLEXPORT cSmileLogger SMILE_LOG_GLOBAL(1);\n\n#define MODULE \"smileLogger\"\n\n/********************* class implementation ***********************************/\n\ncSmileLogger::cSmileLogger(int _loglevel, const char * _logfile, int _append) :\n  logf(NULL),\n  msg(NULL),\n  silence(0),\n  _enableLogPrint(1)\n{\n  if (_logfile != NULL) {\n    logfile = strdup(_logfile);\n    stde = 0;\n    openLogfile(_append);\n  }\n  else { stde = 1; logfile = NULL; }\n\n  if (_loglevel >= 0) {\n    ll_msg = ll_wrn = ll_err = ll_dbg = _loglevel;\n  } else {\n    ll_msg = ll_wrn = ll_err = ll_dbg = 0;\n  }\n  smileMutexCreate(logmsgMtx);\n}\n\ncSmileLogger::cSmileLogger(int loglevel_msg, int loglevel_wrn, int loglevel_err, int loglevel_dbg, const char *_logfile, int _append):\n  logf(NULL),\n  msg(NULL),\n  silence(0),\n  _enableLogPrint(1)\n{\n  if (_logfile != NULL) {\n    logfile = strdup(_logfile);\n    stde = 0;\n    openLogfile(_append);\n  }\n  else { stde = 1; logfile = NULL; }\n\n  ll_msg = loglevel_msg;\n  ll_wrn = loglevel_wrn;\n  ll_err = loglevel_err;\n  ll_dbg = loglevel_dbg;\n  smileMutexCreate(logmsgMtx);\n}\n\ncSmileLogger::~cSmileLogger()\n{\n  smileMutexLock(logmsgMtx);\n  if (msg != NULL) free(msg);\n  closeLogfile();\n  if (logfile != NULL) free(logfile);\n  smileMutexUnlock(logmsgMtx);\n  smileMutexDestroy(logmsgMtx);\n}\n\n/* opens the logfile */\nvoid cSmileLogger::openLogfile(int append)\n{\n  if (logfile == NULL) return;\n  if (logf) { fclose(logf); logf=NULL; }\n  if (append) {\n    logf = fopen(logfile,\"a\");\n  } else {\n    logf = fopen(logfile,\"w\");\n  }\n  if (logf == NULL) {\n    throw(IOException(FMT(\"cannot open logfile for writing!\"),0,MODULE));\n  }\n}\n\nvoid cSmileLogger::closeLogfile()\n{\n  if (logf != NULL) { fclose(logf); logf = NULL; }\n}\n\nvoid cSmileLogger::setLogLevel(int _type, int level)\n{\n  switch(_type) {\n    case LOG_ALL:\n         ll_msg = ll_wrn = ll_err = ll_dbg = level;\n         break;\n    case LOG_MESSAGE: ll_msg = level; break;\n    case LOG_WARNING: ll_wrn = level; break;\n    case LOG_ERROR:   ll_err = level; break;\n    case LOG_DEBUG:   ll_dbg = level; break;\n    default:\n         throw(ComponentException(FMT(\"invalid log level type (%i) specified in call to setLogLevel\",level),MODULE));\n  }\n}\n\nvoid cSmileLogger::setLogLevel(int level)\n{\n  setLogLevel(LOG_ALL,level);\n}\n\nvoid cSmileLogger::setLogFile(char *file, int _append, int _stde)\n{\n  if (file != NULL) {\n    if (logfile) {\n      free(logfile); logfile = NULL;\n    }\n    logfile = strdup(file);\n    stde = _stde;\n    openLogfile(_append);\n  }\n}\n\nvoid cSmileLogger::setLogFile(const char *file, int _append, int _stde)\n{\n  if (file != NULL) {\n    if (logfile) {\n      free(logfile); logfile = NULL;\n    }\n    logfile = strdup(file);\n    stde = _stde;\n    openLogfile(_append);\n  }\n}\n\n// formating of log message, save result in msg\nvoid cSmileLogger::fmtLogMsg(const char *type, char *t, int level, const char *m)\n{\n  if (t == NULL) return;\n  if (msg != NULL) {\n    free(msg); msg = NULL;\n  }\n  if ((type != NULL)&&(m!=NULL)) {\n    msg = myvprint(\"(%s) [%i] in %s : %s\",type,level,m,t);\n  } else if (type != NULL) {\n    msg = myvprint(\"(%s) [%i] : %s\",type,level,t);\n  } else if (m != NULL) {\n    msg = myvprint(\"(MSG) [%i] in %s : %s\",level,m,t);\n  } else {\n    msg = myvprint(\"(MSG) [%i] : %s\",level,t);\n  }\n}\n\n// main log message dispatcher\nvoid cSmileLogger::logMsg(int itype, char *s, int level, const char *m)\n{\n  if (!silence) {\n    // check loglevel and type\n    const char *type=NULL;\n    switch (itype) {\n       case LOG_PRINT :\n            if (level > ll_msg) { free(s); return; }\n            type=NULL;\n            break;\n       case LOG_MESSAGE :\n            if (level > ll_msg) { free(s); return; }\n            type=NULL;\n            break;\n       case LOG_ERROR :\n            if (level > ll_err) { free(s); return; }\n            type=\"ERROR\";\n            break;\n       case LOG_WARNING :\n            if (level > ll_wrn) { free(s); return; }\n            type=\"WARN\";\n            break;\n       case LOG_DEBUG :\n            if (level > ll_dbg) { free(s); return; }\n            type=\"DBG\";\n            break;\n       default: return;\n    }\n\n    smileMutexLock(logmsgMtx);\n    // format log message\n    if (itype == LOG_PRINT) {\n      if (msg != NULL) {\n        free(msg); msg = NULL;\n      }\n      msg = myvprint(\"%s\",s);\n      if (_enableLogPrint) {\n        // write to file\n        writeMsgToFile(1);\n      }\n\n    } else {\n      fmtLogMsg(type,s,level,m);\n      // write to file\n      writeMsgToFile();\n    }\n    free(s);\n    \n\n    // print to console\n    if ((stde)||(logf == NULL)||(itype==LOG_PRINT))\n      printMsgToConsole();\n\n    smileMutexUnlock(logmsgMtx);\n  }\n}\n\n// print message to console , without a timestamp\nvoid cSmileLogger::printMsgToConsole()\n{\n  if (msg != NULL) {\n    #ifdef __ANDROID__\n      #ifndef __STATIC_LINK\n         __android_log_print(ANDROID_LOG_INFO, \"opensmile\", \"%s\",msg);\n      #else\n        fprintf(stderr,\"%s\\n\",msg);\n        fflush(stderr);\n      #endif\n    #else\n    fprintf(stderr,\"%s\\n\",msg);\n    fflush(stderr);\n    #endif\n    //#ifdef __MINGW32\n    //fflush(stderr);\n    //#endif\n  }\n}\n\n// write a log message in *msg to current logfile (if open)\n// add a date- and timestamp to message\nvoid cSmileLogger::writeMsgToFile(int pr)\n{\n  if ((logf != NULL)&&(msg != NULL)) {\n    if (pr==0) {\n      // date string\n      time_t t;\n      time(&t);\n      struct tm *ti;\n      ti = localtime(&t);\n      fprintf(logf,\"[ %.2i.%.2i.%.4i - %.2i:%.2i:%.2i ]\\n    \",\n        ti->tm_mday, ti->tm_mon+1, ti->tm_year+1900,\n        ti->tm_hour, ti->tm_min, ti->tm_sec\n      );\n    }\n    // log message\n    fprintf(logf,\"%s\\n\",msg);\n    fflush(logf);\n  }\n}\n\n"
  },
  {
    "path": "src/core/vecToWinProcessor.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nreads in windows and outputs vectors (frames)\n\n*/\n\n\n#include <core/vecToWinProcessor.hpp>\n\n#define MODULE \"cVecToWinProcessor\"\n\n\nSMILECOMPONENT_STATICS(cVecToWinProcessor)\n\nSMILECOMPONENT_REGCOMP(cVecToWinProcessor)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  \n  scname = COMPONENT_NAME_CVECTOWINPROCESSOR;\n  sdescription = COMPONENT_DESCRIPTION_CVECTOWINPROCESSOR;\n\n  // we inherit cDataProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataProcessor\");\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->disableField(\"blocksize\");\n    ct->disableField(\"blocksizeR\");\n    ct->disableField(\"blocksizeW\");\n    ct->disableField(\"blocksize_sec\");\n    ct->disableField(\"blocksizeR_sec\");\n    ct->disableField(\"blocksizeW_sec\");\n\n    ct->setField(\"forceSampleRate\",\"Set a given sample rate for the output level. Typically the base period of the input level will be used for this purpose, but when reading frame-based data from feature files, for example, this information is not available. This option overwrites the input level base period, if it is set.\",16000.0);\n\n    ct->setField(\"normaliseAdd\",\"1/0 (on/off) : normalise frames before adding to eliminate envelope fluctuation artefacts and scaling artefacts. When this is enabled the output should always be correctly scaled to the range -1 and +1. If this is deactivated perfect reconstruction can only be guaranteed with root-raised cosine windows and 50 percent overlap.\",0);\n    ct->setField(\"useWinAasWinB\",\"1 = use window A as window B (e.g. if win A is a root of window x function, e.g. root raised cosine). The 'windowB' must be left blank, and NO windower must be present between the ifft (or other processing) and this component. This component will internally apply window function A before doing the overlap add. (NOT YET IMPLEMENTED)\",0);\n    ct->setField(\"gain\",\"A gain to apply to the output samples.\",1.0);\n\n    ct->setField(\"windowA\",\"Name of cWindower component applied before transforming into the spectral domain. Leave empty to use constant window (=1).\",(const char*)NULL);\n    ct->setField(\"windowB\",\"Name of cWindower component applied after transforming back into the time domain. Leave empty to use constant window (=1).\",(const char*)NULL);\n\n    ct->setField(\"processArrayFields\",\"If turned on (1), process array fields individually. If turned off (0), treat the input vector as a single field/frame.\",1);\n    ct->setField(\"noPostEOIprocessing\",\"1 = do not process incomplete windows at end of input\",1);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cVecToWinProcessor);\n}\n\nSMILECOMPONENT_CREATE(cVecToWinProcessor)\n\n//-----\n\ncVecToWinProcessor::cVecToWinProcessor(const char *_name) :\n  cDataProcessor(_name),\n  ptrWinA(NULL), ptrWinB(NULL),\n  mat(NULL), ola(NULL),\n  hasOverlap(0)\n{\n}\n\nvoid cVecToWinProcessor::fetchConfig()\n{\n  cDataProcessor::fetchConfig();\n\n  normaliseAdd = getInt(\"normaliseAdd\");\n  gain = (FLOAT_DMEM)getDouble(\"gain\");\n\n\n  useWinAasWinB = getInt(\"useWinAasWinB\");\n\n  processArrayFields = getInt(\"processArrayFields\");\n}\n\n\nint cVecToWinProcessor::configureWriter(sDmLevelConfig &c)\n{\n  //SMILE_DBG(2,\"reader period = %f\",c.T);\n\n  if (isSet(\"forceSampleRate\")) {\n    double sr = getDouble(\"forceSampleRate\");\n    if (sr > 0.0) {\n      c.basePeriod = 1.0/sr;\n    } else {\n      c.basePeriod = 1.0;\n      SMILE_IERR(1,\"sample rate (forceSampleRate) must be > 0! (it is: %f)\",sr);\n    }\n  }\n\n  c.frameSizeSec = c.basePeriod;\n  c.N = Nfi; // TODO: is N fi available already??\n  c.blocksizeWriter = (long)round(c.T/c.basePeriod);\n  c.T = c.basePeriod;\n  \n\n  // this is now handled by cDataProcessor myConfigureInstance\n  //writer->setConfig( 1, len, frameStep, 0.0, frameSize, 0, DMEM_FLOAT);\n\n  // we must return 1, in order to indicate configure success (0 indicates failure)\n  return 1;\n}\n\n\n\n\ndouble * cVecToWinProcessor::getWindowfunction(cWindower *_ptrWin, long n, int *didAlloc)\n{\n  double *w;\n  if (_ptrWin != NULL) {\n    sWindowerConfigParsed *c = _ptrWin->getWindowerConfigParsed();\n    w = c->win;\n    if (c->frameSizeFrames != n) {\n      if (n > c->frameSizeFrames) {\n        // TODO: alloc new frame, and zero pad \n        w = (double*)malloc(sizeof(double)*n);\n        long i;\n        for (i=0; i<c->frameSizeFrames; i++) w[i] = c->win[i];\n        for (i=c->frameSizeFrames; i<n; i++) w[i] = 0.0;  // zero-pad window function\n        if (didAlloc != NULL) *didAlloc = 1;\n      } else {\n        SMILE_IERR(1,\"frameSizeFrames (%i) of cWindower component mismatches input frameSize in VecToWinProcessor (%i)!\",c->frameSizeFrames,n);\n      }\n    }\n    free(c);\n  } else {\n    w = (double*)malloc(sizeof(double)*n);\n    if (didAlloc != NULL) *didAlloc = 1;\n    long i;\n    for (i=0; i<n; i++) w[i] = 1.0;\n  }\n  return w;\n}\n\nvoid cVecToWinProcessor::computeOlaNorm(long n, int idx)\n{\n  // get window functions\n  cWindower * _ptrWinA = ptrWinA;\n  cWindower * _ptrWinB = ptrWinB;\n\n  long olaS = inputPeriodS; //(long) round( n * (1.0-ola[idx].overlap) );  // frame overlap in samples\n  long I = (long)( floor((double)n / ((double)olaS))+4.0 );\n  long i,j,a;\n  int didAllocA=0, didAllocB=0;\n\n  double *wA, *wB;\n  wA = getWindowfunction(_ptrWinA,n,&didAllocA);\n  if (useWinAasWinB) {\n    wB = wA;\n  } else {\n    wB = getWindowfunction(_ptrWinB,n,&didAllocB);\n    // problem: when zero-padding is used, the window function is shorter than n and should be zero outside its range\n    // TODO: get the actual n from getWindowfunction\n  }\n  \n  if (!normaliseAdd) {  // if we only want to scale with window B (=A, when useWinAasWinB is active)\n\n    for (j=0; j<n; j++) {\n      ola[idx].norm[j] = wB[j] * gain;\n    }\n\n  } else {\n\n    double * tmp = (double*)calloc(1,sizeof(double)*(I*olaS+n));\n\n    for (i=0; i<I; i++) {\n      a=0;\n      for (j=i*olaS; j<i*olaS+n; j++) {\n        tmp[j] += wA[a]*wB[a];\n        a++;\n      }\n    }\n\n    a=0;\n    for (j=(I/2+1)*olaS; j<(I/2+1)*olaS+n; j++) {\n      if (tmp[j] > 0.0) {\n        ola[idx].norm[a] = gain * 0.99 * ( 1.0/tmp[j] ); // if we should use winA as winB (winB NULL, and option set), then we must multiply winB into norm here...\n        if (useWinAasWinB) ola[idx].norm[a] *= wB[a];\n        //printf(\"xx: %f\\n\", ola[idx].norm[a]);\n      } else {\n        ola[idx].norm[a] = 1.0; // this should never happen... if it does audio will be broken/choppy, forcing the value of 1.0 will only reduce the damage and prevent applications from crashing\n      }\n      a++;\n    }\n    \n    free(tmp);\n\n  }\n\n  // free wA and wB if they have been allocated. we only keep norm  (and wB in the future to save one extra windower component)\n  if (didAllocA) free(wA);\n  if (didAllocB) free(wB);\n}\n\n\n\nvoid cVecToWinProcessor::initOla(long n, double _samplePeriod, double _inputPeriod, int idx)\n{\n  ola[idx].framelen = n;\n  // compute overlap \n  if (_inputPeriod <= 0 || _samplePeriod <= 0 || n <= 0) {\n    ola[idx].overlap = 0.0;\n  } else {\n    ola[idx].overlap = 1.0 - _inputPeriod / ( (double)n * _samplePeriod );\n  }\n\n\n  if (ola[idx].overlap > 0.0) { \n    // init OLA buffer\n    ola[idx].buffersize = 2*n;\n    ola[idx].buffer = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*ola[idx].buffersize);\n    \n\n    // OLA normalisation curve\n    if (normaliseAdd || useWinAasWinB) {\n      ola[idx].norm = (double*)calloc(1,sizeof(double)*n);\n      computeOlaNorm(n,idx);\n    }\n    hasOverlap = 1;\n  } else {\n    hasOverlap = 0;\n  }\n}\n\n\nint cVecToWinProcessor::dataProcessorCustomFinalise() \n{\n  //No = Nfi;\n  // window functions\n  const char * windowA = getStr(\"windowA\");\n  const char * windowB = getStr(\"windowB\");\n  \n  if (windowA != NULL) {\n    const char * tpA = getComponentInstanceType(windowA);\n    cSmileComponent * winA = getComponentInstance(windowA);\n\n    if (winA != NULL && tpA != NULL) {\n      if (strcmp(tpA,\"cWindower\")) {  // !!strcmp ...\n        SMILE_IERR(1,\"The component '%s' (specified via the 'windowA' option) is not of type cWindower (it is of type '%s')! Please check your config!\",windowA,tpA);\n      } else {\n        ptrWinA = (cWindower *)winA;\n      }\n    } else {\n      SMILE_IERR(1,\"The component '%s' was not found in the current config!\",windowA);\n    }\n  }\n\n  if (windowB != NULL) {\n    const char * tpB = getComponentInstanceType(windowB);\n    cSmileComponent * winB = getComponentInstance(windowB);\n\n    if (winB != NULL && tpB != NULL) {\n      if (strcmp(tpB,\"cWindower\")) {  // !!strcmp ...\n        SMILE_IERR(1,\"The component '%s' (specified via the 'windowB' option) is not of type cWindower (it is of type '%s')! Please check your config!\",windowB,tpB);\n      } else {\n        ptrWinB = (cWindower *)winB;\n      }\n    } else {\n      SMILE_IERR(1,\"The component '%s' was not found in the current config!\",windowB);\n    }\n  }\n\n  // before we do any actions, we must check if the windower configs have been finalised and the window function is available (if normaliseAdd is activated), otherwise we must delay our finalise\n  if (normaliseAdd && (ptrWinA != NULL || ptrWinB != NULL)) {\n    if ( (ptrWinA == NULL || ptrWinA->isFinalised()) && (ptrWinB == NULL || ptrWinB->isFinalised()) ) {\n\n   } else {\n      // at least one windower is not yet ready...\n      return 0;\n    }\n  } else {\n    normaliseAdd = 0;\n  } \n\n  Nfi = reader_->getLevelNf();\n  if (!processArrayFields) { Nfi = 1; }\n\n  ola = (struct sVecToWinProcessorOla*)calloc(1,sizeof(struct sVecToWinProcessorOla)*Nfi);\n\n  const FrameMetaInfo * fm = reader_->getFrameMetaInfo();\n  const sDmLevelConfig *cfg = reader_->getLevelConfig();\n  samplePeriod = cfg->basePeriod; // ???\n  inputPeriod = cfg->T;\n  inputPeriodS = (long)round(inputPeriod/samplePeriod);\n\n  // foreach input field: compute output and overlap parameters and create buffers\n  long i;\n  long e=0;\n\n  if (!processArrayFields) {\n    // the whole input is treated as a single vector/frame\n    long n = reader_->getLevelN();\n    No = setupNamesForField(0,nameAppend_,1);\n\n    // TODO.. overlap, ola buffer, etc...\n    initOla(n,samplePeriod,inputPeriod,0);\n\n  } else {\n\n    No = 0;\n    for (i=0; i<Nfi; i++) {\n      int __N=0;\n      const char *tmp = reader_->getFieldName(i,&__N);\n      if (tmp == NULL) { SMILE_ERR(1,\"reader->getFieldName(%i) failed (return value = NULL)!\",i); return 0; }\n\n\n      long n = fm->field[i].N;\n      \n      initOla(n,samplePeriod,inputPeriod,i);\n\n      // set output field name\n      if (__N > 1) { // we only consider input vectors... not single elements!\n        No += setupNamesForField(e++, tmp, 1);\n      } else {\n        SMILE_IWRN(2,\"ignoring field '%s' with single element\",tmp);\n      }\n    }\n\n  }\n\n  namesAreSet_ = 1;\n\n  if (useWinAasWinB) normaliseAdd = 1;\n\n  //Mult = getMultiplier();\n  //if (Mult*Ni != No) COMP_ERR(\"Mult not constant (as returned by setupNamesForField! This is not allowed! Mult*Ni=%i <> No=%i\",Mult*Ni,No);\n  //???\n  //if (tmpFrameF==NULL) tmpFrameF=(FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*Mult);\n  //if (tmpFrameI==NULL) tmpFrameI=(INT_DMEM*)calloc(1,sizeof(INT_DMEM)*Mult);\n  return 1;\n}\n\n/*\nint cVecToWinProcessor::myFinaliseInstance()\n{\n\n  // get reader names, append _win(_winf) to it (winf is optional)\n  int ret=1;\n  ret *= reader->finaliseInstance();\n  if (!ret) return ret;\n\n  Ni = reader->getLevelN();\n  Nfi = reader->getLevelNf();\n  No = 0;\n//  Nfo = Ni;\n  inputPeriod = reader->getLevelT();\n\n  int i,n;\n\n  long e=0;\n  for (i=0; i<Nfi; i++) {\n    int __N=0;\n    const char *tmp = reader->getFieldName(i,&__N);\n    if (tmp == NULL) { SMILE_ERR(1,\"reader->getFieldName(%i) failed (return value = NULL)!\",i); return 0; }\n    if (__N > 1) {\n\n      for (n=0; n<__N; n++) {\n\t\t    char *na = reader->getElementName(e);\n        No += setupNamesForField(e++, na, 1);\n        free(na);\n      }\n\n    } else {\n      No += setupNamesForField(e++, tmp, 1);\n    }\n  }\n\n  namesAreSet = 1;\n  Mult = getMultiplier();\n  if (Mult*Ni != No) COMP_ERR(\"Mult not constant (as returned by setupNamesForField! This is not allowed! Mult*Ni=%i <> No=%i\",Mult*Ni,No);\n  if (tmpFrameF==NULL) tmpFrameF=(FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*Mult);\n  if (tmpFrameI==NULL) tmpFrameI=(INT_DMEM*)calloc(1,sizeof(INT_DMEM)*Mult);\n\n  if (frameMode != FRAMEMODE_VAR) \n    reader->setupSequentialMatrixReading(frameStepFrames, frameSizeFrames, pre);\n\n  return cDataProcessor::myFinaliseInstance();\n  \n}\n*/\n\n// idxi is index of input element\n// row is the input row\n// y is the output vector (part) for the input row\nint cVecToWinProcessor::doProcess(int idxi, cMatrix *row, FLOAT_DMEM*y)\n{\n   /* int i;\n    for (i=0;i<row->nT; i++) {\n      printf(\"[%i] %f\\n\",i,row->dataF[i]);\n    }*/\n  SMILE_IERR(1,\"dataType FLOAT_DMEM not yet supported!\");\n  //return getMultiplier();\n  return 0;\n  // return the number of actually set components in y!!\n  // return 0 on failue\n  // return -1 if you don't want to set a new output frame...\n}\n\nint cVecToWinProcessor::doProcess(int idxi, cMatrix *row, INT_DMEM*y)\n{\n  SMILE_IERR(1,\"dataType INT_DMEM not yet supported!\");\n  //return getMultiplier();\n  return 0;\n  // return the number of actually set components in y!!\n  // return 0 on failue\n  // return -1 if you don't want to set a new output frame...\n}\n\nint cVecToWinProcessor::doFlush(int idxi, FLOAT_DMEM*y)\n{\n  //SMILE_IERR(1,\"dataType FLOAT_DMEM not yet supported!\");\n  //return getMultiplier();\n  return 0;\n  // return the number of actually set components in y!!\n  // return 0 on failue\n  // return -1 if you don't want to set a new output frame...\n}\n\nint cVecToWinProcessor::doFlush(int idxi, INT_DMEM*y)\n{\n  //SMILE_IERR(1,\"dataType INT_DMEM not yet supported!\");\n  //return getMultiplier();\n  return 0;\n  // return the number of actually set components in y!!\n  // return 0 on failue\n  // return -1 if you don't want to set a new output frame...\n}\n\n/*\nCONCEPT:\n\n* inverse window function is handled seperately by the windower component on the vectors\n\n* metadata read from vectors:\n - period of vectors, \n - vector size\n - samplePeriod\n* automatically compute overlap\nSPECIAL CASE: if T=0 we have asynchronous data, in this case assume no overlap, then just concattenate data in the output level and don't do OLA\n\n* configurable window functions a and b\n* used for pre computing the normalisation function\n\n- myTick reads single vectors and adds them in an internal buffer (auto sized)\n- the fully overlapped parts of the buffer are flushed to the output level\n\n--\nnaming of output elements:\n- ideally input element without array name suffix (single element)\n- but: manually overwriteable (i.e. processArrayFields = 0, and define 1 output name!)\n\n*/\n\nint cVecToWinProcessor::flushOlaBuffer(cMatrix *mat) \n{\n  long i,j;\n  for (i=0; i<Nfi; i++) {\n    long ptr = ola[i].bufferReadPtr;\n    long bs = ola[i].buffersize;\n    FLOAT_DMEM * buf = ola[i].buffer;\n    FLOAT_DMEM * df = mat->dataF+i;\n    for (j=0; j<inputPeriodS; j++) {\n      df[j*Nfi] = buf[ptr]; //(float)rand()/(float)RAND_MAX; \n      buf[ptr++] = 0.0;\n      ptr %= bs;\n    }\n    ola[i].bufferReadPtr = ptr;\n  }\n  return 1;\n}\n\n/*\nvoid cVecToWinProcessor::setOlaBufferRel(long idx, long j, FLOAT_DMEM val) \n{\n  long x = (j+ola[idx].bufferPtr[idx])%ola[idx].buffersize;\n  ola[idx].buffer[x] += val;\n}\n*/\n\nvoid cVecToWinProcessor::setOlaBufferNext(long idx, FLOAT_DMEM val) \n{\n  ola[idx].buffer[ola[idx].bufferPtr] += val;\n  ola[idx].bufferPtr++;\n  if (ola[idx].bufferPtr >= ola[idx].buffersize) {\n    ola[idx].bufferPtr = 0;\n  }\n}\n\nint cVecToWinProcessor::myTick(long long t)\n{\n  /*\n   get a vector, for each field call a processFrame method to modify data\n   then overlap add data to buffer and flush buffer pieces (of size n-olaS) to output level\n\n   NOTE: the input period is always the same, this is the amount of data which will be written to the output in every tick. \n         only the frameSize and thus the percentage of overlap can change\n\n  */\n\n  SMILE_IDBG(4,\"tick # %i, running vecToWinProcessor ....\",t);\n  \n  // check for space in output level\n  if (!(writer_->checkWrite(inputPeriodS))) return 0;\n\n  // get next frame from dataMemory\n  cVector *vec;\n  vec = reader_->getNextFrame();\n  if (vec==NULL) { return 0; } // currently no data available\n\n  if (mat == NULL) mat = new cMatrix(Nfi, inputPeriodS, DMEM_FLOAT);\n  \n\n  long i,j;\n  if (hasOverlap) {\n\n    for (i=0; i<Nfi; i++) {\n      long el = vec->fmeta->fieldToElementIdx(i);\n      long ptr1 = ola[i].bufferPtr;\n      long ptr = ola[i].bufferPtr;\n      FLOAT_DMEM * buf = ola[i].buffer;\n      FLOAT_DMEM * df = vec->dataF+el;\n      long bs = ola[i].buffersize;\n      double * norm = ola[i].norm;\n\n      if (normaliseAdd)  {\n        // multiply input with norm function & add to buffer\n        for (j=0; j<ola[i].framelen; j++) {\n          //setOlaBufferNext(i, (FLOAT_DMEM)( vec->dataF[el+j] * ola[i].norm[j] ));\n          buf[ptr1++] += df[j] * (FLOAT_DMEM)norm[j];\n          if (ptr1 >= bs) ptr1 = 0;\n        }\n      } else {\n        if (gain != 1.0) {\n          // add to buffer, multiply with gain\n          for (j=0; j<ola[i].framelen; j++) {\n            //setOlaBufferNext(i, vec->dataF[el+j] * gain); \n            buf[ptr1++] += df[j] * gain;\n            if (ptr1 >= bs) ptr1 = 0;\n          }\n        } else {\n          // add to buffer\n          for (j=0; j<ola[i].framelen; j++) {\n            //setOlaBufferNext(i, vec->dataF[el+j]); \n            buf[ptr1++] += df[j];\n            if (ptr1 >= bs) ptr1 = 0;\n          }\n        }\n      }\n\n      ola[i].bufferPtr = ptr + inputPeriodS;\n      ola[i].bufferPtr %= ola[i].buffersize;\n    }\n\n    // flush buffer (always size of inputPeriod)\n    if (flushOlaBuffer(mat)) {\n      writer_->setNextMatrix(mat);\n    } else {\n      return 0;\n    }\n\n  } else {\n\n    // flush directly to matrix object and write output\n    for (i=0; i<Nfi; i++) {\n      long el = vec->fmeta->fieldToElementIdx(i);\n      if (gain != 1.0) {\n        for (j=0; j<ola[i].framelen; j++) {\n          mat->dataF[j*Nfi+i] = vec->dataF[el+j] * gain;\n        }\n      } else {\n        for (j=0; j<ola[i].framelen; j++) {\n          mat->dataF[j*Nfi+i] = vec->dataF[el+j];\n        }\n      }\n    }\n    writer_->setNextMatrix(mat);\n\n  }\n\n  return 1;\n}\n\n\ncVecToWinProcessor::~cVecToWinProcessor()\n{\n  // free overlap add buffers\n  if (ola != NULL) {\n    long i;\n    for (i=0; i<Nfi; i++) {\n      if (ola[i].norm != NULL) {\n        free(ola[i].norm);\n      }\n      if (ola[i].buffer != NULL) {\n        free(ola[i].buffer);\n      }\n    }\n    free(ola);\n  }\n\n  // free output buffer matrix object\n  if (mat != NULL) delete(mat);\n}\n\n"
  },
  {
    "path": "src/core/vectorProcessor.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nvector Processor :  (abstract class only)\n       specialised dataProcessor, which takes one frame as input an produces one frame as output\n       however, each array field is processed individually as a vector\n       for each field the output dimension can be set in derived components\n\n*/\n\n\n#include <core/vectorProcessor.hpp>\n\n#define MODULE \"cVectorProcessor\"\n\n\nSMILECOMPONENT_STATICS(cVectorProcessor)\n\nSMILECOMPONENT_REGCOMP(cVectorProcessor)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CVECTORPROCESSOR;\n  sdescription = COMPONENT_DESCRIPTION_CVECTORPROCESSOR;\n\n  // we inherit cDataProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataProcessor\")\n\n  SMILECOMPONENT_IFNOTREGAGAIN( {}\n    ct->setField(\"processArrayFields\",\"1 = process each array field as one vector individually (and produce one output for each input array field). Only array fields (i.e. fields with more than one element) are processed if this is set. / 0 = process complete input frame as one vector, ignoring field/element structure\",1);\n    ct->setField(\"includeSingleElementFields\", \"1 = if in processArrayFields (1) mode, then also include single element fields.\", 0);\n    ct->setField(\"preserveFieldNames\", \"1 = when processArrrayFields is disabled (0), then still preserve the input field partitioning and names in the output, but just process the whole vector instead of fields. This was the default in old versions, but now it can be controlled. This is what you would usually want, except if you want/need to combine inputs to a single large array field.\", 1);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cVectorProcessor);\n}\n\nSMILECOMPONENT_CREATE_ABSTRACT(cVectorProcessor)\n\n//-----\n\ncVectorProcessor::cVectorProcessor(const char *_name) :\n  cDataProcessor(_name),\n  Nfo(0), No(0),\n  Nfi(0), Ni(0),\n  fNi(NULL),\n  fNo(NULL),\n  vecO(NULL),\n  confBs(NULL),\n  fconf(NULL),\n  fconfInv(NULL),\n  Nfconf(0),\n  processArrayFields(1),\n  preserveFieldNames(1),\n  includeSingleElementFields(0)\n{\n\n}\n\nvoid cVectorProcessor::fetchConfig()\n{\n  cDataProcessor::fetchConfig();\n\n  processArrayFields = getInt(\"processArrayFields\");\n  SMILE_IDBG(2,\"processArrayFields = %i\",processArrayFields);\n  preserveFieldNames = getInt(\"preserveFieldNames\");\n  includeSingleElementFields = getInt(\"includeSingleElementFields\");\n}\n\n/*\nint cVectorProcessor::myConfigureInstance()\n{\n  int ret=1;\n  ret *= cDataProcessor::myConfigureInstance();\n  return ret;\n}\n*/\n\n/*\nint cVectorProcessor::configureWriter(const sDmLevelConfig *c)\n{\n\n  // you must return 1, in order to indicate configure success (0 indicated failure)\n  return 1;\n}\n\n*/\n\nint cVectorProcessor::addFconf(long bs, int field) // return value is index of assigned configuration\n{\n  int i;\n  if (bs<=0) return -1;\n  for (i=0; i<Nfi; i++) {\n    if ((confBs[i] == bs)||(confBs[i]==0)) {\n      confBs[i] = bs;\n      fconfInv[i] = field;\n      fconf[field] = i;\n      if (i>=Nfconf) Nfconf = i+1;\n      return i;\n    }\n  }\n  return -1;\n}\n\n\n// this method should be overridden by a derived class in order to configure the output fields\n/*\nint cVectorProcessor::setupNamesForField(int i, const char*name, long nEl)\n{\n  return cDataProcessor::setupNamesForField(i,name,nEl);\n//  return nEl;\n}\n*/\n\nint cVectorProcessor::dataProcessorCustomFinalise()\n{\n  if (namesAreSet_) return 1;\n\n  int i;\n\n  Nfi = reader_->getLevelNf();\n  if (!processArrayFields) {\n    if (!preserveFieldNames) {\n      Nfi=1; // this has to be one... setupNamesForField must be called only once with nEl=number of elements!\n             // if we need to call setupNames... for each field to preserve the input names, but then call processVector only once (where??)\n             // then we need a separate option for preserveFieldNames.. etc.\n    }\n    Ni = reader_->getLevelN(); // number of elements\n  }\n\n  fNi = (long*)calloc(1,sizeof(long)*Nfi); // input\n  fNo = (long*)calloc(1,sizeof(long)*Nfi); // output  (Nfo <= Nfi, always!)\n\n  fconf = (int *)malloc(sizeof(int)*Nfi);\n  fconfInv = (int *)malloc(sizeof(int)*Nfi);\n  confBs = (long *)calloc(1,sizeof(long)*Nfi);\n\n  if (!processArrayFields) {\n\n    int __N=0;\n    //const char *tmp = reader->getFieldName(0,&__N);\n    fconf[0] = -1;\n    addFconf(Ni,0);\n\n    if (!namesAreSet_) fNo[0] = setupNewNames(Ni);\n\n    if (!namesAreSet_) {\n      fNo[0] = 0; \n      //SMILE_IMSG(1,\"XXXX array Nfi=%i Ni=%i\\n\",Nfi,Ni);\n      i=0;\n      //TODO: still a problem here: output names are only 1st field + appended name, instead we want the names to be input name + appended bit... (example: cVectorOperation with processArrayFields=0)\n      // NOTE: for vectorTransform an co. we need to preserve the individual names (other components might not... or want to have setupNamesForField only called once? Check!!\n      int myN = 1;\n      if (preserveFieldNames) {\n        myN = Nfi;\n      }\n      //for (i=0; i<Nfi; i++) {  // OK, changed Nfi to 1 on this line.. hope this breaks nothing else.. ( TODO::: this is NOT OK... why do we run this for each input field?? (names...?) )\n      for (i=0; i<myN; i++) {  // OK, changed Nfi to 1 on this line.. hope this breaks nothing else.. ( TODO::: this is NOT OK... why do we run this for each input field?? (names...?) )\n        int arrNameOffset=0;\n        const char *tmp = reader_->getFieldName(i,&__N,&arrNameOffset);\n        int myN2 = Ni;\n        if (preserveFieldNames) {\n          myN2 = __N;\n        }\n        long nOut = setupNamesForField(i,tmp,myN2);\n        if (nOut==__N) {\n          // set arrNameOffset\n          writer_->setArrNameOffset(arrNameOffset);\n        }\n        fNo[0] += nOut; //fNo[0] += __N;\n      }\n    }\n    else { if (fNo[0]==0) fNo[0] = Ni; }\n    No = fNo[0];\n//old:    Nfo=Nfi;  // ?????\n//new:\n    Nfo=1;\n\n    fNi[0] = Ni;\n    Nfi=1; // ????\n\n    configureField(0,Ni,No);\n\n  } else {\n    for (i=0; i<Nfi; i++) { fconf[i] = -1; }\n    //\n    for (i=0; i<Nfi; i++) {\n      int __N=0;\n      int arrNameOffset=0;\n      const char *tmp = reader_->getFieldName(i,&__N,&arrNameOffset);\n      if (tmp == NULL) { SMILE_ERR(1,\"reader->getFieldName(%i) failed (return value = NULL)!\",i); return 0; }\n      fNi[i] = __N; Ni += __N;\n      if ((__N > 1) || (includeSingleElementFields)) {  // Changed to >= 1 (was > 1) ,single fields should be ok..!\n        addFconf(__N,i);\n        if (!namesAreSet_) {\n          fNo[Nfo] = setupNamesForField(i,tmp,__N);\n          if (fNo[Nfo]==__N) {\n            // set arrNameOffset\n            writer_->setArrNameOffset(arrNameOffset);\n          }\n        }\n        else fNo[Nfo] = __N; // fNo[i] = __N;\n        No += fNo[Nfo];\n        configureField(i,__N,fNo[Nfo]);\n        Nfo++;\n      } else {\n        SMILE_IWRN(1,\"ignoring single (non-array) field '%s'!\",tmp);\n      }\n    }\n  }\n\n  namesAreSet_ = 1;\n  return 1;\n}\n\n/*\nint cVectorProcessor::myFinaliseInstance()\n{\n  int ret=1;\n  ret *= reader->finaliseInstance();\n  if (!ret) return ret;\n\n \n\n  for (i=0; i<Nfconf; i++) {\n    //      configureField(fconfInv[i],fNi[fconfInv[i]]);\n    configureField(fconfInv[i],confBs[i]);\n  }\n\n  \n  return cDataProcessor::myFinaliseInstance();\n}\n\n*/\n\n// a derived class should override this method, in order to implement the actual processing\nint cVectorProcessor::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  //memcpy(dst,src, MIN(Nsrc,Ndst));\n  SMILE_ERR(1,\"component '%s' (type '%s') does not support data type DMEM_FLOAT (yet) !\",getInstName(),getTypeName());\n  return 1;\n}\n\n// a derived class should override this method, in order to implement the actual processing\nint cVectorProcessor::processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  //memcpy(dst,src, MIN(Nsrc,Ndst));\n  SMILE_ERR(1,\"component '%s' (type '%s') does not support data type DMEM_INT (yet) !\",getInstName(),getTypeName());\n  return 1;\n}\n\n// a derived class should override this method, in order to implement the actual processing\nint cVectorProcessor::flushVectorFloat(FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  //memcpy(dst,src, MIN(Nsrc,Ndst));\n  //SMILE_ERR(1,\"component '%s' (type '%s') does not support data type DMEM_FLOAT (yet) !\",getInstName(),getTypeName());\n  return 0;\n}\n\n// a derived class should override this method, in order to implement the actual processing\nint cVectorProcessor::flushVectorInt(INT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  //memcpy(dst,src, MIN(Nsrc,Ndst));\n  //SMILE_ERR(1,\"component '%s' (type '%s') does not support data type DMEM_INT (yet) !\",getInstName(),getTypeName());\n  return 0;\n}\n\nint cVectorProcessor::myTick(long long t)\n{\n  SMILE_IDBG(4,\"tick # %i, running vector processor\",t);\n\n  if (!(writer_->checkWrite(1))) return 0;\n  // printf(\"'%s' checkwrite ok\\n\",getInstName());\n\n  // get next frame from dataMemory\n  cVector *vec = reader_->getNextFrame();\n  int i;\n  int iO = 0;\n  int toSet = 1;\n  int ret = 1;\n  int res;\n\n  int type;\n  if (vec==NULL) {\n    const sDmLevelConfig * c = writer_->getLevelConfig();\n    if (c != NULL) {\n      type = c->type;\n    } else {\n      return 0;\n    }\n  } else { \n    type = vec->type;\n  }\n  if (vecO == NULL)\n    vecO = new cVector(No, type);\n  if (customVecProcess(vec, vecO)) {\n    if (vec != NULL) vecO->tmetaReplace(vec->tmeta);\n    // save the output to dataMemory\n    writer_->setNextFrame(vecO);\n    return 1;\n  }\n\n  if (type == DMEM_FLOAT) {\n    FLOAT_DMEM *dFi = NULL;\n    if (vec != NULL) {\n      dFi = vec->dataF;\n    }\n    FLOAT_DMEM *dFo = vecO->dataF;\n    for (i=0; i<Nfi; i++) {\n      if ((fNi[i] == 1 && includeSingleElementFields == 0 && processArrayFields == 1) || (fNi[i] < 1)) {\n        continue;\n      }\n      if (vec != NULL) {\n        if ((dFo == NULL)||(fNo[iO]<=0)) {\n          SMILE_IERR(1,\"output field size for field %i is 0 in call to processVectorFloat!\\n  Please check if setupNewNames or setupNamesForField returns a number > 0 !!\",iO);\n          COMP_ERR(\"aborting here, since this is a serious bug in this component ...\");\n        }\n        res = processVectorFloat(dFi, dFo, fNi[i], fNo[iO], i);\n      } else {\n        if ((dFo == NULL)||(fNo[iO]<=0)) {\n          SMILE_IERR(1,\"output field size for field %i is 0 in call to processVectorFloat!\\n  Please check if setupNewNames or setupNamesForField returns a number > 0 !!\",iO);\n          COMP_ERR(\"aborting here, since this is a serious bug in this component ...\");\n        }\n        res = flushVectorFloat(dFo, fNi[i], fNo[iO], i);\n      }\n      if (res == 0) ret=0;\n      else if (res < 0) toSet=0;\n      dFi += fNi[i];\n      dFo += fNo[iO];\n      iO++;\n    }\n  } else if (type == DMEM_INT) {\n    INT_DMEM *iFi = NULL;\n    if (vec != NULL) {\n      iFi = vec->dataI;\n    }\n    INT_DMEM *iFo = vecO->dataI;\n    for (i=0; i<Nfi; i++) {\n      if ((fNi[i] == 1 && includeSingleElementFields == 0 && processArrayFields == 1) || (fNi[i] < 1)) {\n        continue;\n      }\n      if (vec != NULL) {\n        if ((iFo == NULL)||(fNo[iO]<=0)) {\n          SMILE_IERR(1,\"output field size for field %i is 0 in call to processVectorFloat!\\n  Please check if setupNewNames or setupNamesForField returns a number > 0 !!\",iO);\n          COMP_ERR(\"aborting here, since this is a serious bug in this component ...\");\n        }\n        res = processVectorInt(iFi, iFo, fNi[i], fNo[iO], i);\n      } else {\n        if ((iFo == NULL)||(fNo[iO]<=0)) {\n          SMILE_IERR(1,\"output field size for field %i is 0 in call to processVectorFloat!\\n  Please check if setupNewNames or setupNamesForField returns a number > 0 !!\",iO);\n          COMP_ERR(\"aborting here, since this is a serious bug in this component ...\");\n        }\n        res = flushVectorInt(iFo, fNi[i], fNo[iO], i);\n      }\n      if (res == 0) ret=0;\n      else if (res < 0) toSet=0;\n\n      iFi += fNi[i];\n      iFo += fNo[iO];\n      iO++;\n    }\n  } else {\n    SMILE_ERR(1,\"unknown data type: vec->type = %i! (instance: '%s')\",vec->type,getInstName());\n  }\n\n  if (!ret) {\n    toSet=0;\n  }\n  if (toSet) {    \n    if (vec != NULL) vecO->tmetaReplace(vec->tmeta);\n    // save to dataMemory\n    writer_->setNextFrame(vecO);\n  }\n  return ret;\n}\n\n\nvoid cVectorProcessor::multiConfFree( void *x )\n{\n  int i;\n  void **y = (void **)x;\n  if (y!=NULL) {\n    for (i=0; i<getNf(); i++) {\n      if (y[i] != NULL) free(y[i]);\n    }\n    free(y);\n  }\n}\n\ncVectorProcessor::~cVectorProcessor()\n{\n  if (fNi!=NULL)  free(fNi);\n  if (fNo!=NULL)  free(fNo);\n  if (fconf != NULL) free(fconf);\n  if (fconfInv != NULL) free(fconfInv);\n  if (confBs != NULL)  free(confBs);\n  if (vecO!=NULL) delete vecO;\n}\n\n"
  },
  {
    "path": "src/core/vectorTransform.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: cVectorTransform\n\nthis is a base class for vector transforms which require history data or precomputed data\nthe class provides support for \n a) saving computed data at the end of processing (level or custom)\n a) saving computed data continuously (level or custom)\n b) applying pre-computed transformation data loaded from file, w/o adaptation\n c) applying pre-computed transformation data loaded from file, with on-line adaptation\n d) applying purely on-line adaptive transformation\n\ndifferent modes of operation are distinguished:\n\n a) pure analysis: transform data is computed, no output is generated (except for transformation data, if it is output to a level)\n       (full input, or each turn)\n b) pure transform: apply pre-computed transform data\n       (apply always, only during turn, switch models for turn/non-turn, switch models by external message)\n c) transform w. online adaptation: combines a) and b). transform output to a level is NOT possible\n         (more analysis methods: fixed buffer)\n*/\n\n\n/*\nFile Format for storing transformations (will be auto-detected):\n\nA) HTK CMN Format   (text)\n  <MEAN> N\n  Val1 Val2 Val3 ...\n\nB) simple MVN matrix data format (deprecated!): Binary (2*N x double):  \n   (N x double = means), \n   (N x double = stddevs)\n\nC) advanced smile transformation format: Binary\n   (note: this format is used interally)\n  Header: \n    Magic     (int32)  0xEE 0x11 0x11 0x00\n    N vectors (int32)\n    N groups  (int32)\n    N timeunits(int32)\n    Vecsize   (int32)\n    N userData(int32)\n    TypeID    (int32)  [defined in the header file of the component implementing the transform]\n    Reserved  (16 byte)\n  User data : N userData (double)\n  Matrix data: N vec x Vecsize (double, 8 byte)\n\nWhen a file is loaded, the first 4 bytes are checked for:\n  a) magic       0xEE 0x11 0x11 0x00   => FORMAT C\n  b) HTK Header: <    M    E    A    (or leading spaces, which will be removed..?!)  => FORMAT A\n  c) else => FORMAT B\n\n*/\n\n\n/* Current component status:\n\n* AVG method working\n* Exp method working\n* BUF/FIX method working\n\nTODO:  AVGI method possibly broken !\n\n*/\n\n\n#include <core/vectorTransform.hpp>\n\n#define MODULE \"cVectorTransform\"\n\n\nSMILECOMPONENT_STATICS(cVectorTransform)\n\nSMILECOMPONENT_REGCOMP(cVectorTransform)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CVECTORTRANSFORM;\n  sdescription = COMPONENT_DESCRIPTION_CVECTORTRANSFORM;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"nameAppend\",(const char *)NULL,(const char *)NULL);\n    ct->setField(\"mode\",\"The mode of operation:\\n   an(alysis) : analyse all incoming data and compute transform for later use\\n   tr(ansformation) : use pre-computed transform loaded from initFile, no on-line adaptation\\n   in(cremental) : use initFile as inital transform, if given, update transform on-line using 'updateMethod'\",\"analysis\");\n\n    ct->setField(\"initFile\",\"The file to load the (initial) transformation data from (see vectorTransform.cpp for documentation of the file format)\",(const char*)NULL);\n    ct->setField(\"saveFile\",\"The file to save transformation data to (see vectorTransform.cpp for documentation of the file format)\",(const char*)NULL);\n\n    ct->setField(\"updateMethod\",\"Method to use for incrementally updating the transform. Can be one of the following:\\n   'exp'  exponential: m1 = alpha * m0  + (1-alpha) * x\\n   'fix'/'buf'  compute tranform over history buffer of fixed length\\n   'ifix'/'ibuf'  compute tranform over history buffer of fixed length and use init data from last turn (see weight option)\\n   'usr'  other update method (usually defined by a descendant component of cVectorTransform, look for customUpdateMethod option)\\n   'avg'  cummulative average method with weighted fixed inital values\\n   'iavg'  cummulative average method with weighted variable (from the last turn) inital values\\n   NOTE: if 'resetOnTurn'==0 then 'avg' and 'iavg' are identical\",\"iavg\");\n\n    ct->setField(\"alpha\",\"The weighting factor alpha for exponential transform update\",0.995);\n    ct->setField(\"weight\",\"The weighting factor for 'avg'/'avgI'/'bufI' update, i.e. the factor the initial transform parameters are weighted by when building the cummulative average\",100);\n    ct->setField(\"fixedBuffer\",\"The size of the fixed length buffer [in seconds] (for fixed buffer update method)\",5.0);\n\n    ct->setField(\"turnOnlyUpdate\",\"1 = perform transform update only during turns (between turnStart and turnEnd messages) (works for all methods)\",0);\n    ct->setField(\"invertTurn\",\"1 = invert the turn state (i.e. changes a 'turnOnly...' option into 'notTurn' option)\",0);\n    ct->setField(\"resetOnTurn\",\" 1 = reset transform values at the beginning of each new turn (only in mode 'analysis' and 'incremental')\",0);\n//    ct->setField(\"nextTrOnTurn\",\"save/load next set of transform values at the end/beginning of each new turn (only in mode 'analysis' and 'transform')\",0);\n\n    ct->setField(\"turnOnlyNormalise\",\"1 = apply the transform only to turns (in between data will pass through unmodified) ('invertTurn' will also invert this option)\",0); // check this!!\n    ct->setField(\"turnOnlyOutput\",\"1 = output data to writer level only during a turn (this will implicitely set turnOnlyNormalise = 1) ('invertTurn' will also invert this option)\",0); // check this!!\n\n    ct->setField(\"htkcompatible\",\"A flag that indicates (if set to 1) wheter last coefficient in 'initFile' is loaded into means[0] (use this only when reading htk-compatible cmn init files, and NOT using htk-compatible mfccs)\",0);\n    ct->setField(\"invertMVNdata\", \"1 = invert the loaded MVN data to 'unstandardise' to these parameters. Currently only works with MVn text and old MVN binary data. mu' = -mu/sigma and sigma' = 1/sigma ; \", 0);\n    ct->setField(\"turnStartMessage\",\"You can use this option to define a custom message name for the turn start message, i.e. if you want to use voice activity start/end messages instead\",\"turnStart\");\n    ct->setField(\"turnEndMessage\",\"You can use this option to define a custom message name for the turn end message, i.e. if you want to use voice activity start/end messages instead\",\"turnEnd\");\n\n    // OBSOLETE\n    //ct->setField(\"skipNfirst\",\"The number of frames(!) at the beginning of the input to skip (i.e. not to use for computation/update of transform parameters)\",10);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cVectorTransform);\n}\n\n\n\nSMILECOMPONENT_CREATE_ABSTRACT(cVectorTransform)\n\n//-----\n\ncVectorTransform::cVectorTransform(const char *_name) :\n  cVectorProcessor(_name),\n  initFile(NULL), saveFile(NULL),\n  mode(0), err(0), flushed(0),\n  alpha(0.0), weight(0.0),\n  buffer(NULL), bufferNframes(NULL),\n  nAvgBuffer(0), wPtr(0), rPtr(0),\n  updateMethod(0),\n  turnOnlyNormalise(0),\n  invertTurn(0),\n  resetOnTurn(0),\n  turnOnlyUpdate(0),\n  turnOnlyOutput(0),\n  zeroThIsLast(0),\n  skipNfirst(10),\n  fixedBuffer(0.0),\n  fixedBufferFrames(0),\n  isTurn(0), resetMeans(0), nFrames(0),\n  turnStartMessage(NULL), turnEndMessage(NULL)\n{\n  transform.userData = NULL;\n  transform.vectors = NULL;\n  /* use the free method to initialize all important values to 0 */\n  freeTransformData(&transform);\n\n  transform0.userData = NULL;\n  transform0.vectors = NULL;\n  /* use the free method to initialize all important values to 0 */\n  freeTransformData(&transform0);\n}\n\nvoid cVectorTransform::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n  \n  initFile = getStr(\"initFile\");\n  if (initFile != NULL) {\n    SMILE_IDBG(2,\"initFile = '%s'\",initFile);\n  }\n\n  saveFile = getStr(\"saveFile\");\n  if (saveFile != NULL) {\n    SMILE_IDBG(2,\"saveFile = '%s'\",saveFile);\n  }\n\n  const char * _mode = getStr(\"mode\");\n  SMILE_IDBG(2,\"mode = '%s'\",_mode);\n  if (!strncmp(_mode,\"an\",2)) {\n    mode = MODE_ANALYSIS;\n  } else if (!strncmp(_mode,\"tr\",2)) {\n    mode = MODE_TRANSFORMATION;\n  } else if (!strncmp(_mode,\"in\",2)) {\n    mode = MODE_INCREMENTAL;\n  } else {\n    SMILE_IERR(1,\"unknown mode '%s' (setting to 'in(cremental)' !)\",_mode);\n    mode = MODE_INCREMENTAL;\n  }\n\n  alpha = (FLOAT_DMEM)getDouble(\"alpha\");\n  SMILE_IDBG(2,\"alpha = %f\",alpha);\n\n  weight = (FLOAT_DMEM)getDouble(\"weight\");\n  SMILE_IDBG(2,\"weight = %f\",weight);\n\n  const char * updateMethodStr = getStr(\"updateMethod\");\n  SMILE_IDBG(2,\"updateMethod = '%s'\",updateMethodStr);\n  if (!strncmp(updateMethodStr,\"exp\",3)) {\n    updateMethod = UPDMETHOD_EXP;\n  } else if (!strncmp(updateMethodStr,\"fix\",3)) {\n    updateMethod = UPDMETHOD_FIX;\n  } else if (!strncmp(updateMethodStr,\"buf\",3)) {\n    updateMethod = UPDMETHOD_FIX;\n  } else if (!strncmp(updateMethodStr,\"usr\",3)) {\n    updateMethod = UPDMETHOD_USR;\n  } else if (!strncmp(updateMethodStr,\"avg\",3)) {\n    updateMethod = UPDMETHOD_AVG;\n  } else if (!strncmp(updateMethodStr,\"iavg\",4)) {\n    updateMethod = UPDMETHOD_AVGI;\n  } else if (!strncmp(updateMethodStr,\"ifix\",4)) {\n    updateMethod = UPDMETHOD_FIXI;\n  } else if (!strncmp(updateMethodStr,\"ibuf\",4)) {\n    updateMethod = UPDMETHOD_FIXI;\n  } else {\n    SMILE_IERR(1,\"unknown update method '%s' (setting to 'usr' !)\",updateMethodStr);\n    updateMethod = UPDMETHOD_USR;\n  }\n\n  zeroThIsLast = getInt(\"htkcompatible\");\n  SMILE_IDBG(2,\"zeroThIsLast (htkcompatible) = %i\",zeroThIsLast);\n\n//  skipNfirst = getInt(\"skipNfirst\");\n//  SMILE_IDBG(2,\"skipNfirst = %i\",skipNfirst);\n  \n  turnOnlyUpdate = getInt(\"turnOnlyUpdate\");\n  SMILE_IDBG(2,\"turnOnlyUpdate = %i\",turnOnlyUpdate);\n\n  turnOnlyNormalise = getInt(\"turnOnlyNormalise\");\n  turnOnlyOutput = getInt(\"turnOnlyOutput\");\n  SMILE_IDBG(2,\"turnOnlyOutput = %i\",turnOnlyOutput);\n  if (turnOnlyOutput) turnOnlyNormalise = 1;\n\n  SMILE_IDBG(2,\"turnOnlyNormalise = %i\",turnOnlyNormalise);\n\n  resetOnTurn = getInt(\"resetOnTurn\");\n  SMILE_IDBG(2,\"resetOnTurn = %i\",resetOnTurn);\n\n  invertTurn = getInt(\"invertTurn\");\n  SMILE_IDBG(2,\"invertTurn = %i\",invertTurn);\n\n  fixedBuffer = getDouble(\"fixedBuffer\");\n  SMILE_IDBG(2,\"fixedBuffer = %f\",fixedBuffer);\n\n  turnStartMessage = getStr(\"turnStartMessage\");\n  SMILE_IDBG(2,\"turnStartMessage = '%s'\",turnStartMessage);\n\n  turnEndMessage = getStr(\"turnEndMessage\");\n  SMILE_IDBG(2,\"turnEndMessage = '%s'\",turnEndMessage);\n\n  invertMVNdata = getInt(\"invertMVNdata\");\n}\n\nint cVectorTransform::loadHTKCMNdata(const char *filename, struct sTfData * tf)\n{\n  int ret;\n  FILE *f = NULL;\n  if (filename != NULL) {\n    f = fopen(filename,\"r\");\n  }\n  freeTransformData(tf);\n\n  if (f!=NULL) {\n    int i = 0;\n    int n = -1;\n    float v;\n    fscanf(f,\"<MEAN> %i\\n\",&n);\n    if (n < 1) {\n      SMILE_IERR(1, \"Number of means in HTK CMN file is < 1 (%i).\", n);\n      fclose(f);\n      return 0;\n    }\n    tf->head.nVec = 1;\n    tf->head.nGroups = 1;\n    tf->head.vecSize = n;\n    tf->head.typeID = TRFTYPE_MNN;\n    tf->vectors = (double *)malloc(sizeof(double)*n);\n    //printf(\"nMeans to load: %i\\n\",n);\n    if (zeroThIsLast) { i=1; }\n    for (; i<n; i++) {\n      if (fscanf(f,\" %f\",&v) > 0) {\n        tf->vectors[i] = v;\n        //printf(\"v(%i): %f\\n\",i,v);\n      } else {\n        tf->vectors[i] = 0.0;\n        SMILE_IERR(1,\"parse error during loading of HTK cepstral mean file: '%s'\",filename);\n      }\n    }\n    if (zeroThIsLast) {\n      if (fscanf(f,\" %f\",&v) > 0) {\n        tf->vectors[0] = v;\n        //printf(\"v(%i): %f\\n\",i,v);\n      } else {\n        tf->vectors[0] = 0.0;\n        SMILE_IERR(1,\"parse error during load of HTK cepstral mean file: '%s'\\n\",filename);\n      }\n    }\n    fclose(f);\n    ret = 1;\n  } else {\n    if (filename != NULL) {\n      SMILE_ERR(1,\"cannot open transform data initialisation file '%s' for reading it as HTK Ascii format\",filename);\n      ret = 0;\n    } else {\n      ret = 1;\n    }\n  }\n  return ret;\n}\n\nvoid cVectorTransform::prepareUnstandardise(struct sTfData * tf)\n{\n  if (tf->head.nVec == 2 && tf->head.nGroups == 2 && tf->head.typeID == TRFTYPE_MVN) {\n    double *m = tf->vectors;\n    double *v = tf->vectors + tf->head.vecSize;\n    // means\n\n    for (int i = 0; i < tf->head.vecSize; i++) {\n      if (*v != 0.0) {\n        *m = - (*m) / (*v);\n      } else {\n        *m = - (*m);\n      }\n      m++;\n      v++;\n    }\n    v = tf->vectors + tf->head.vecSize;\n    for (int i = 0; i < tf->head.vecSize; i++) {\n      if (*v != 0.0) {\n        *v = 1.0 / *v;\n      }\n      v++;\n    }\n    SMILE_IMSG(3, \"'Unstandardised' (=inverted) this MVN transformation!\");\n  } else {\n    SMILE_IERR(2, \"This transform does not seem to be MVN type, not applying unstandardise!\");\n  }\n}\n\nint cVectorTransform::loadMVNtextdata(const char *filename, struct sTfData * tf)\n{\n  int ret;\n  FILE *f = NULL;\n  if (filename != NULL) {\n    f = fopen(filename,\"r\");\n  }\n  freeTransformData(tf);\n\n  if (f!=NULL) {\n    int i=0,n; float v;\n    fscanf(f,\"<MVN> %i\\n\",&n);\n    tf->head.nVec = 2;\n    tf->head.nGroups = 2;\n    tf->head.vecSize = n;\n    tf->head.typeID = TRFTYPE_MVN;\n    tf->vectors = (double *)malloc(sizeof(double)*n*2);\n    for (int line = 0; line < 2; line++) {\n      double * vectors = tf->vectors + line * n;\n      i = 0;\n      if (zeroThIsLast) {\n        i = 1;\n      }\n      for (; i < n - 1; i++) {\n        if (fscanf(f,\"%f \",&v) > 0) {\n          vectors[i] = (double)v;\n          //printf(\"v(%i): %f\\n\",i,v);\n        } else {\n          vectors[i] = 0.0;\n          SMILE_IERR(1,\"parse error during loading of text MVN file (line %i, element: %i, zeroThIsLast: %i): '%s'\", line, i, zeroThIsLast, filename);\n        }\n      }\n      if (zeroThIsLast) {\n        i = 0;\n      }\n      const char *match = \"%f\\n\";\n      if (line == 1) {\n        match = \"%f\";\n      }\n      if (fscanf(f, match, &v) > 0) {\n        vectors[i] = (double)v;\n      } else {\n        vectors[i] = 0.0;\n        SMILE_IERR(1,\"parse error during loading of text MVN file (line: %i, element: %i, zeroThIsLast: %i): '%s'\", line, i, zeroThIsLast, filename);\n      }\n    }\n    fclose(f);\n    if (invertMVNdata) {\n      prepareUnstandardise(tf);\n    }\n    ret = 1;\n  } else {\n    if (filename != NULL) {\n      SMILE_IERR(1,\"cannot open transform data initialisation file '%s' for reading (mvn text format).\", filename);\n      ret = 0;\n    } else {\n      ret = 1;\n    }\n  }\n  return ret;\n}\n\n\nint cVectorTransform::loadMVNdata(const char *filename, struct sTfData * tf)\n{\n  int ret;\n  FILE *f = NULL;\n  if (filename != NULL) {\n    f = fopen(filename,\"rb\");\n  }\n  freeTransformData(tf);\n\n  if (f!=NULL) {\n    // get file size:\n    fseek(f, 0L, SEEK_END);\n    long len = ftell(f);\n    fseek(f, 0L, SEEK_SET);\n    tf->head.nVec = 2;\n    tf->head.nGroups = 2;\n    tf->head.typeID = TRFTYPE_MVN;\n    tf->head.vecSize = len / ( sizeof(double) * 2 );\n    tf->vectors = (double*)malloc( sizeof(double) * tf->head.vecSize * tf->head.nVec);\n    double * const means = tf->vectors;\n    double * const stddev = tf->vectors + tf->head.vecSize; \n\n    if (!fread(means, sizeof(double)*tf->head.vecSize, 1, f))\n      SMILE_IERR(1,\"error reading data from file '%s', encountered EOF before it was expected\\n\",filename);\n    if (!fread(stddev, sizeof(double)*tf->head.vecSize, 1, f))\n      SMILE_IERR(1,\"error reading data from file '%s', encountered EOF before it was expected\\n\",filename);\n\n    double floor = 0.0000001;\n    //for (i=0; i<tf->head.vecSize; i++) {\n      //if (stddev[i] <= 0.0) {\n      //  stddev[i] = floor;\n      //  SMILE_IWRN(2,\"some values of stddev in MVN file '%s' are <= 0.0 ! Flooring them to %f\",f,floor);\n      //}\n    //}\n    fclose(f);\n    if (invertMVNdata) {\n      prepareUnstandardise(tf);\n    }\n    ret = 1;\n  } else {\n    if (filename != NULL) {\n      SMILE_IERR(1,\"cannot open transform data initialisation file '%s' for reading it as MVN binary format\",filename);\n      ret = 0;\n    } else {\n      ret = 1;\n    }\n  }\n  return ret;\n}\n\nint cVectorTransform::loadSMILEtfData(const char *filename, struct sTfData * tf)\n{\n  int ret;\n  FILE *f = NULL;\n  if (filename != NULL) {\n    f = fopen(filename,\"rb\");\n  }\n  freeTransformData(tf);\n\n  if (f!=NULL) {\n    if (!fread(&(tf->head), sizeof(struct sTfHeader), 1, f)) \n      SMILE_IERR(1,\"error reading header from file '%s', encountered EOF before it was expected\\n\",filename);\n    if (tf->head.nUserdata > 0.0) {\n      tf->userData = (double *)malloc(sizeof(double)*tf->head.nUserdata);\n      if (!fread(tf->userData, sizeof(double)*tf->head.nUserdata, 1, f)) \n        SMILE_IERR(1,\"error reading userData from file '%s', encountered EOF before it was expected\\n\",filename);\n    }\n    if ( (tf->head.nVec > 0.0)&&(tf->head.vecSize > 0.0) ) {\n      tf->vectors = (double *)malloc(sizeof(double)*tf->head.nVec*tf->head.vecSize);\n      if (!fread(tf->vectors, sizeof(double)*tf->head.nVec*tf->head.vecSize, 1, f)) \n        SMILE_IERR(1,\"error reading vectors from file '%s', encountered EOF before it was expected\\n\",filename);\n    }\n    fclose(f);\n    if (invertMVNdata) {\n      prepareUnstandardise(tf);\n    }\n    ret = 1;\n  } else {\n    if (filename != NULL) {\n      SMILE_IERR(1,\"cannot open transform data initialisation file '%s' for reading it as SMILEtf binary format\",filename);\n      ret = 0;\n    } else {\n      ret = 1;\n    }\n  }\n  return ret;\n}\n\n\n/* loads data, the format (HTK, old MVN, smile native) is determined automatically */\nint cVectorTransform::loadTransformData(const char *filename, struct sTfData * tf)\n{\n  if (tf == NULL) return 0;\n  if (filename == NULL) return 0;\n  FILE *f = fopen(filename,\"rb\");\n  if (f != NULL) {\n    int ret = 1;\n    /* determine file format, and maybe reopen file as ascii, if ascii format... */\n    unsigned char magic[4];\n    fread(magic, 4, 1, f);\n    /* check for SMILEtf format magic */\n    if ( (magic[0] == smileMagic[0]) &&\n         (magic[1] == smileMagic[1]) &&\n         (magic[2] == smileMagic[2]) &&\n         (magic[3] == smileMagic[3]) ) {\n       /* load new format */\n       fclose(f);\n       SMILE_IMSG(4,\"loading init file in SMILEtf binary format\");\n       ret = loadSMILEtfData(filename, tf);\n    } else {\n      /* check for HTK CMN ascii file (<MEAN> N)*/\n      int i = 0;\n        /* skip whitespace/newline characters at the beginning */\n      while ((magic[i] == ' ')||(magic[i] == '\\t')||(magic[i] == '\\r')||(magic[i] == '\\n')) {\n        i++;\n        if (i==4) {\n          i=0;\n          if (!fread(magic, 4, 1, f)) break; /* EOF */\n        }\n      }\n      if (i) {\n        int j;\n        for (j=i; j<4; j++) magic[j-i] = magic[j];\n        fread(&(magic[4-i]),i,1,f);\n      }\n\n      if ( (magic[0] == '<') &&\n         ( (magic[1] == 'M') ) &&\n         ( (magic[2] == 'E') ) &&\n         ( (magic[3] == 'A') ) ) {\n          /* load HTK CMN Ascii format file, close binary file handle first */\n          fclose(f);\n          SMILE_IMSG(2, \"Loading tranform init file in HTK CMN Ascii format\");\n          ret = loadHTKCMNdata(filename, tf);\n      } else if ( (magic[0] == '<') &&\n         ( (magic[1] == 'M') ) &&\n         ( (magic[2] == 'V') ) &&\n         ( (magic[3] == 'N') ) ) {\n         fclose(f);\n         SMILE_IMSG(2, \"Loading init file in MVN text format\");\n         ret = loadMVNtextdata(filename, tf);\n      } else {\n         /* load old format MVN binary file */\n         fclose(f);\n         SMILE_IMSG(2, \"Loading init file in old MVN binary format\");\n         ret = loadMVNdata(filename, tf);\n      }\n    }\n    return ret;\n  }\n  SMILE_IERR(1, \"could not open initial transform file (initFile) '%s' for reading, probably 'file not found'!\", filename);\n  return 0;\n}\n    \n/* saves transform data in smile native format,\n   other formats are not supported and will not be supported */\nint cVectorTransform::saveTransformData(const char *filename, struct sTfData * tf)\n{\n  if (filename == NULL) return 0;\n  if (tf == NULL) return 0;\n  tf->head.nTimeunits = (int64_t)nFrames;\n  FILE *f = fopen(filename,\"wb\");\n  if (f != NULL) {\n    tf->head.magic[0] = smileMagic[0]; \n    tf->head.magic[1] = smileMagic[1];\n    tf->head.magic[2] = smileMagic[2];\n    tf->head.magic[3] = smileMagic[3];\n    if (!fwrite(&(tf->head), sizeof(struct sTfHeader), 1, f)) \n      SMILE_IERR(1,\"error writing data to file '%s', fwrite returned 0\",filename);\n    if (tf->head.nUserdata > 0) {\n      if (tf->userData == NULL) {\n        double c = 0.0; int i;\n        for (i=0; i<tf->head.nUserdata; i++) {\n          if (!fwrite(&c, sizeof(double), 1, f)) \n            SMILE_IERR(1,\"error writing data to file '%s', fwrite returned 0\",filename);\n        }\n      } else {\n        if (!fwrite(tf->userData, sizeof(double), tf->head.nUserdata, f)) \n          SMILE_IERR(1,\"error writing data to file '%s', fwrite returned 0\",filename);\n      }\n    }\n    if ((tf->head.nVec > 0)&&(tf->head.vecSize > 0)) {\n      if (tf->vectors == NULL) {\n        double c = 0.0; int i;\n        for (i=0; i<tf->head.vecSize*tf->head.nVec; i++) {\n          if (!fwrite(&c, sizeof(double), 1, f)) \n            SMILE_IERR(1,\"error writing data to file '%s', fwrite returned 0\",filename);\n        }\n      } else {\n        if (!fwrite(tf->vectors, tf->head.vecSize*sizeof(double)*tf->head.nVec, 1, f)) \n          SMILE_IERR(1,\"error writing data to file '%s', fwrite returned 0\",filename);\n      }\n    }\n    fclose(f);\n    return 1;\n  }\n  return 0;\n}\n\n/* free the vectors and user data */\nvoid cVectorTransform::freeTransformData(struct sTfData * tf)\n{\n  if (tf != NULL) {\n    if (tf->userData != NULL) { free(tf->userData); tf->userData = NULL; }\n    if (tf->vectors != NULL)  { free(tf->vectors); tf->vectors = NULL; }\n    tf->head.nVec = 0;\n    tf->head.nGroups = 0;\n    tf->head.vecSize = 0;\n    tf->head.nUserdata = 0;\n    tf->head.nTimeunits = 0;\n    tf->head.typeID = 0;\n  }\n}\n    \n\nint cVectorTransform::configureWriter(sDmLevelConfig &c)\n{\n  if (c.T != 0.0) {\n    if (fixedBuffer > 0.0) {\n      fixedBufferFrames = (long)ceil(fixedBuffer / c.T);\n      SMILE_IDBG(2,\"fixedBufferFrames = %i\\n\",fixedBufferFrames);\n      /*\n      //reader->setBlocksize(fixedBufferFrames+1);\n      auxReader->setComponentEnvironment(getCompMan(), -1, this);\n      auxReader->registerInstance();\n      auxReader->configureInstance();\n      auxReader->finaliseInstance();\n      auxReader->setBlocksize(fixedBufferFrames+1);\n      */\n    }\n  }\n\n  return 1;\n}\n\n\nint cVectorTransform::myFinaliseInstance()\n{\n  int ret = cVectorProcessor::myFinaliseInstance();\n  if (!ret) return 0;\n\n  // load initialisation transform file:\n  if (!loadTransformData(initFile, &transform0)) {\n    // set initial transform weight to 0 if no data has been loaded\n    weight = 0.0;\n    if (initFile != NULL) {\n      return 0;\n    }\n  }\n  modifyInitTransform(&transform0);\n\n  if ( (updateMethod == UPDMETHOD_FIX) || (updateMethod == UPDMETHOD_AVGI) ) {\n    // memory for ring-buffer is allocated during the first call to processVectorFloat\n    if (fixedBufferFrames < 3) {\n      SMILE_IWRN(1,\"fixedBuffer (in frames) is < 3, setting to minimum value of 3!!\");\n      fixedBufferFrames = 3;\n    } \n  }\n  return ret;\n}\n\nint cVectorTransform::processComponentMessage( cComponentMessage *_msg )\n{\n  const char * endM = NULL;\n  if (turnEndMessage == NULL) endM = \"turnEnd\";\n  else endM = turnEndMessage;\n\n  if (isMessageType(_msg,endM)) {\n    if (invertTurn) {\n      isTurn = 1; resetMeans = 1;\n    } else {\n      isTurn = 0;\n    }\n    SMILE_IDBG(3,\"received turnEnd (%s)\",endM);\n    return 1;\n  }\n\n  const char * startM = NULL;\n  if (turnStartMessage == NULL) startM = \"turnStart\";\n  else startM = turnStartMessage;\n\n  if (isMessageType(_msg,startM)) {\n    if (invertTurn) {\n      isTurn = 0;\n    } else {\n      isTurn = 1;\n      resetMeans = 1;\n    }\n    SMILE_IDBG(3,\"received turnStart (%s)\",startM);\n    return 1;\n  }\n  return 0;\n}\n\n/* this function will handle saving of transform data, if enabled */\nint cVectorTransform::flushVectorFloat(FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi)\n{\n  if (!flushed) {\n    /* call refactoring method: */\n    if (mode != MODE_TRANSFORMATION) \n      computeFinalTransformData(&transform,idxi);\n    /* save transform data to SMILEtf format binary file */\n    saveTransformData(saveFile, &transform);\n\n    flushed = 1;\n  }\n  return 0; /* no output data */\n}\n\n// copy transform data from tf0 to tf OR init tf with 0'ed data\nvoid cVectorTransform::initTransform(struct sTfData *tf, struct sTfData *tf0)\n{\n  if ((tf0 == NULL)) { weight = 0.0; return; } /*||(tf0->head.nVec==0)*/\n  if (tf != NULL) {\n    if (tf0->head.typeID == 0) tf0->head.typeID = tf->head.typeID;\n    if (tf->head.typeID != tf0->head.typeID) {\n      SMILE_IERR(2,\"initTransform: transform data typeID mismatch (tgt: %i != src: %i), I will not copy data.\",tf->head.typeID, tf0->head.typeID);\n      return;\n    }\n\n    // only copy data if valid data is present in tf0\n    if ((tf0->userData!=NULL)&&(tf->userData != NULL)) {\n      if (tf->head.nUserdata < tf0->head.nUserdata) {\n        SMILE_IERR(2,\"nUserdata (%i) in transform < nUserdata (%i) in transform0, this is a bug, or you have loaded an incompatible transform file!\",tf->head.nUserdata,tf0->head.nUserdata);\n      } else tf->head.nUserdata = tf0->head.nUserdata;\n      // copy user data:\n      memcpy(tf->userData, tf0->userData, sizeof(double) * tf->head.nUserdata);\n    } else {\n      // zero-init\n      if ((tf->userData != NULL)&&(tf->head.nUserdata > 0)) {\n        memset(tf->userData, 0, tf->head.nUserdata * sizeof(double));\n      }\n    }\n\n    if ((tf0->vectors!=NULL)&&(tf->vectors!=NULL)&&(tf0->head.nVec > 0)&&(tf0->head.vecSize > 0)) {\n      if (tf->head.nGroups != tf0->head.nGroups) {\n        if (tf->head.nGroups == 0) tf->head.nGroups = tf0->head.nGroups;\n        else {\n          SMILE_IWRN(3,\"nGroups (%i) in transform != nGroups (%i) in transform0, this might be a bug, or you might have loaded an incompatible transform file, or everything is ok ;-)\",tf->head.nGroups,tf0->head.nGroups);\n        }\n      }\n\n      \n      if (tf->head.nVec != tf0->head.nVec) {\n        SMILE_IWRN(3,\"nVec (%i) in transform != nVec (%i) in transform0, this might be a bug, or you might have loaded an incompatible transform file, or everything is ok ;-)\",tf->head.nVec,tf0->head.nVec);\n        \n      }\n\n      if (tf->head.vecSize != tf0->head.vecSize) {\n        SMILE_IERR(2,\"vecSize (%i) in transform != vecSize (%i) in transform0, this is a bug, or you have loaded an incompatible transform file!\",tf->head.vecSize,tf0->head.vecSize);\n        return;\n      }\n\n      // copy vec data:\n      tf->head.nTimeunits = tf0->head.nTimeunits;\n      memcpy(tf->vectors, tf0->vectors, sizeof(double) * tf0->head.nVec * tf0->head.vecSize);\n      \n      // zero remaining:\n      if (tf0->head.nVec < tf->head.nVec) {\n        memset(tf->vectors+tf0->head.nVec * tf0->head.vecSize, 0, ((tf->head.nVec - tf0->head.nVec) * tf0->head.vecSize) * sizeof(double));\n      }\n    } else {\n      weight = 0.0;\n      // zero-init:\n      if ((tf->vectors != NULL)&&(tf->head.nVec > 0)&&(tf->head.vecSize > 0)) {\n        memset(tf->vectors, 0, tf->head.nVec * tf->head.vecSize * sizeof(double));\n      }\n    }\n    nFrames = (long)tf->head.nTimeunits;\n    transformInitDone(tf,tf0);\n  }\n  \n}\n\nint cVectorTransform::updateTransformFloat(struct sTfData * tf, const FLOAT_DMEM *src, FLOAT_DMEM *buf, long * _bufferNframes, long Nbuf, long wrPtr, int idxi)\n{\n  if (tf == NULL) return 0;\n  if (src == NULL) return 0;\n  switch (updateMethod) {\n    case UPDMETHOD_EXP: \n      return updateTransformFloatExp(tf,src,idxi);\n    case UPDMETHOD_FIX: \n    case UPDMETHOD_FIXI:\n      return updateTransformFloatBuf(tf,src,buf,Nbuf,wrPtr,idxi);\n    case UPDMETHOD_AVG: \n      return updateTransformFloatAvg(tf,src,idxi);\n    case UPDMETHOD_AVGI: \n      return updateTransformFloatAvgI(tf,src,buf,_bufferNframes,Nbuf,wrPtr,idxi);\n    case UPDMETHOD_NUL:\n      return 0;\n    default:\n      SMILE_IWRN(2,\"unknown update method in updateTransformFloat() : %i\\n\",updateMethod);\n      return 0;\n  }\n}\n\nvoid cVectorTransform::updateRingBuffer(const FLOAT_DMEM *src, long Nsrc) \n{\n  long i;\n  if (nAvgBuffer == fixedBufferFrames) {\n    for (i=0; i<Nsrc; i++) {\n      // store current input in ringbuffer at position of last input:\n      buffer[i + Nsrc*wPtr] = src[i];\n    }\n  } else {\n    for (i=0; i<Nsrc; i++) {\n      // store current input in ringbuffer:\n      buffer[i + Nsrc*wPtr] = src[i];\n    }\n    nAvgBuffer++;\n  }\n  wPtr++;\n  if (wPtr >= fixedBufferFrames) wPtr = 0;\n}\n\n\n// a derived class should override this method, in order to implement the actual processing\nint cVectorTransform::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  int ret=0;\n  long i;\n\n  if (src == NULL) return 0;\n  if (Nsrc <= 0) return 0;\n  \n  if (mode != MODE_TRANSFORMATION) {\n    if ( (updateMethod == UPDMETHOD_FIX) || (updateMethod == UPDMETHOD_AVGI) ) {\n      if (buffer == NULL) {\n        nAvgBuffer=0;\n        buffer = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*fixedBufferFrames*Nsrc);\n      }\n/*      if (updateMethod == UPDMETHOD_AVGI) {\n        if (bufferNframes == NULL) bufferNframes = (long*)malloc(sizeof(long)*fixedBufferFrames);\n      }*/\n    }\n  }\n\n  // setup transform struct\n    int init = 0;\n    if ((transform.userData == NULL)&&(transform.vectors==NULL)) {\n      transform.head.vecSize = Nsrc;\n      /* hook for allocating vectors and userData in transform data,\n         this hook should also set the typeID, etc. */\n      allocTransformData(&transform,Ndst,idxi);\n      /* copy initial transform (transform0) to current transform (transform) */\n      initTransform(&transform, &transform0);\n     //printf(\"nFrames %i\\n\",nFrames);\n      init = 1;\n    }\n  \n  if ((mode == MODE_ANALYSIS)||(mode == MODE_INCREMENTAL)) {\n\n    int _resetMeans = 0;\n    lockMessageMemory();\n    int _isTurn = isTurn;\n    if (resetOnTurn) _resetMeans = resetMeans;\n    unlockMessageMemory();\n\n    if ((_resetMeans)&&(!init)) {\n      /* copy initial transform (transform0) to current transform (transform) TODO: check this code!!!*/\n      if (!transformResetNotify(&transform, &transform0)) {\n        if (updateMethod != UPDMETHOD_AVGI) {\n          initTransform(&transform, &transform0);\n        }\n      }\n      // reset history buffers:\n      if (updateMethod != UPDMETHOD_AVGI) nFrames=0;\n      else nFrames = (long)transform.head.nTimeunits;\n      wPtr=0; nAvgBuffer = 0;\n      lockMessageMemory();\n      resetMeans = 0;\n      unlockMessageMemory();\n    }\n\n    if ((!turnOnlyUpdate)||(_isTurn)) {\n\n      // nFrames is the number of frames which were so-far analysed\n      nFrames++; // NOTE: nFrames includes the current frame, when updateTransform is being called!\n\n      /* hook for updating the transform parameters */\n      updateTransformFloat(&transform, src, buffer, bufferNframes, nAvgBuffer, wPtr, idxi);\n      \n\n      if ((updateMethod == UPDMETHOD_FIX)||(updateMethod == UPDMETHOD_FIXI)) { // manage ring buffer history if fixedBuffer update method\n        // add a sample to the ring-buffer\n        updateRingBuffer(src,Nsrc);\n      } else if (updateMethod == UPDMETHOD_AVGI) {\n        if (nFrames > 0) {\n          /* update buffer of sums... */\n          for (i=0; i<Nsrc; i++) {\n            buffer[i + Nsrc*wPtr] = src[i];\n          }\n          bufferNframes[wPtr] = nFrames;\n          wPtr++;\n          if (wPtr == fixedBufferFrames) wPtr = 0;\n          if (nAvgBuffer < fixedBufferFrames) nAvgBuffer++;\n        }\n      }\n\t    /* save transform data to SMILEtf format binary file */\n      saveTransformData(saveFile, &transform);\n    }\n\n    if (mode == MODE_INCREMENTAL) {\n      if ((Ndst <= 0) || (dst == NULL)) return 0;\n\n      if ((!turnOnlyNormalise)||(_isTurn)) {\n        // apply transform\n        //TODO: check !! transform might be uninitialized !!\n        int ret = transformDataFloat(&(transform), src, dst, Nsrc, Ndst, idxi);\n        //fprintf(stderr,\"XXX: instname: %s\\n\",getInstName());\n        checkDstFinite(dst,ret);\n        return ret;\n      } else {\n        // copy without processing, if enabled\n        if (turnOnlyOutput) return 0;\n        else {\n          for (i=0; i<MIN(Ndst,Nsrc); i++) {\n            dst[i] = src[i];\n          }\n          return MIN(Ndst,Nsrc);\n        }\n      }\n\n    } else { \n      // TODO: output transform parameters to *dst ??\n      // this also requires changes in myConfigure and myFinalise ...\n      return 0;\n    }\n\n  } else {\n\n    if (mode == MODE_TRANSFORMATION) {\n      if ((Ndst <= 0) || (dst == NULL)) return 0;\n\n      lockMessageMemory();\n      int _isTurn = isTurn;\n      unlockMessageMemory();\n\n      if (transform.head.vecSize != Nsrc) {\n        if (!err) {\n          SMILE_IERR(1,\"vecSize of loaded transform data (from '%s') [vecSize=%i] does not match vecSize of source level [=%i]. I will not apply any transformation, the output will be corrput.\",initFile,transform.head.vecSize,Nsrc);\n          err=1; \n        }\n        return 0;\n      }\n      if ((!turnOnlyNormalise)||(_isTurn)) {\n        // apply transform\n        int ret = transformDataFloat(&(transform), src, dst, Nsrc, Ndst, idxi);\n        checkDstFinite(dst,ret);\n        return ret;\n      } else {\n        // copy without processing, if enabled\n        if (turnOnlyOutput) return 0;\n        else {\n          for (i=0; i<MIN(Ndst,Nsrc); i++) {\n            dst[i] = src[i];\n          }\n          return MIN(Ndst,Nsrc);\n        }\n      }\n    }\n\n  }\n\n  // unknown mode....\n  return 0;\n\n//  return Ndst;\n}\n\ncVectorTransform::~cVectorTransform()\n{\n  if (buffer!=NULL) free(buffer);\n  if (bufferNframes!=NULL) free(bufferNframes);\n  freeTransformData(&transform);\n  freeTransformData(&transform0);\n}\n\n"
  },
  {
    "path": "src/core/winToVecProcessor.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nreads in windows and outputs vectors (frames)\n\n*/\n\n\n/*\n *TODO: Segment analyser component (which creates input segments according to peaks, segment boundaries, etc. as done by FunctionalsSegemnts/Peaks (maybe reuse code there...?)\n *TODO: Segment analyser component will send messages to wintovec component for frame boundaries\n *\n */\n\n\n#include <core/winToVecProcessor.hpp>\n\n\n\n\n#define MODULE \"cWinToVecProcessor\"\n\n\nSMILECOMPONENT_STATICS(cWinToVecProcessor)\n\nSMILECOMPONENT_REGCOMP(cWinToVecProcessor)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  \n  scname = COMPONENT_NAME_CWINTOVECPROCESSOR;\n  sdescription = COMPONENT_DESCRIPTION_CWINTOVECPROCESSOR;\n\n  // we inherit cDataProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataProcessor\");\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->disableField(\"blocksize\");\n    ct->disableField(\"blocksizeR\");\n    ct->disableField(\"blocksizeW\");\n    ct->disableField(\"blocksize_sec\");\n    ct->disableField(\"blocksizeR_sec\");\n    ct->disableField(\"blocksizeW_sec\");\n\n    ct->setField(\"allowLastFrameIncomplete\", \"If this option is set to 1 (true) then in frameMode 'fixed', the last frame will be processed, even if it is not frameSize frames long.\", 0);\n    ct->setField(\"frameMode\",\"Specifies how to create frames: 'fixed' (fixed frame size, given via 'frameSize' option), 'full' (create one frame at the end of the input only), 'variable' (via message), 'list' (in config file or external text file, see frameList and frameListFile options, UNIMPLEMENTED)\",\"fixed\");\n    ct->setField(\"frameListFile\",\"Filename of a file with a list of frame intervals to load (text file with a comma separted list of intervals: 1-10,11-20 , etc., if no interval is specified, i.e. no - is found then consecutive frames with the given number being the frame length are assumed; first index is 0; use the suffix \\\"s\\\" after the numbers to specify intervals in seconds (e.g. 0s-2.5s); use an 'E' instead of a number for 'end of sequence')\",(const char*) NULL);\n    ct->setField(\"frameList\",\"The list of frame intervals specified directly in the configuration file (comma separted list of intervals: 1-10,11-20 , etc., if no interval is specified, i.e. no - is found then consecutive frames with the given number being the frame length are assumed; first index is 0; use the suffix \\\"s\\\" after the numbers to specify intervals in seconds (e.g. 0s-2.5s); use an 'E' instead of a number for 'end of sequence')\",(const char*) NULL);\n\n    ct->setField(\"frameSize\",\"The frame size in seconds (0.0 = full input, same as frameMode=full)\",0.025);\n    ct->setField(\"frameStep\",\"The frame step (frame sampling period) in seconds (0.0 = set to the same value as 'frameSize')\",0.0);\n    ct->setField(\"frameSizeFrames\",\"The frame size in input level frames (=samples for a pcm/wave input level) (overrides frameSize, if set and > 0)\",0,0,0);\n    ct->setField(\"frameStepFrames\",\"The frame step in input level frames (=samples for a pcm/wave input level) (overrides frameStep, if set and > 0)\",0,0,0);\n    ct->setField(\"frameCenter\",\"The frame center in seconds, i.e. where frames are sampled (0=left)\",0,0,0);\n    ct->setField(\"frameCenterFrames\",\"The frame sampling center in input level frames (overrides frameCenter, if set), (0=left)\",0,0,0);\n    ct->setField(\"frameCenterSpecial\",\"The frame sampling center (overrides the other frameCenter options, if set). The available special frame sampling points as strings are: 'mid' = middle (first frame from -frameSize/2 to frameSize/2), 'left' = sample at the beginning of the frame (first frame from 0 to frameSize), 'right' = sample at the end of the frame (first frame from -frameSize to 0)\",\"left\");\n    ct->setField(\"noPostEOIprocessing\",\"1 = do not process incomplete windows at the end of the input\",1);\n//    ct->setField(\"frameBorderList\",\"array list of frame borders (in seconds), if frameMode==list\",(const char*)NULL, ARRAY_TYPE);\n//    ct->setField(\"frameList\",\"array list of frame start/end times (in seconds) (specifiy as: '0.3-1.7 ; 0.9-2.1', for example), if frameMode==list (use either this OR frameBorderList)\",(const char*)NULL, ARRAY_TYPE);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cWinToVecProcessor);\n}\n\nSMILECOMPONENT_CREATE(cWinToVecProcessor)\n\n//-----\n\ncWinToVecProcessor::cWinToVecProcessor(const char *_name) :\n  cDataProcessor(_name),\n  allow_last_frame_incomplete_(0),\n  wholeMatrixMode(0), processFieldsInMatrixMode(0),\n  //outputPeriod(0.0),\n  fsfGiven(0),\n  fstfGiven(0),\n  frameSizeFrames(0),\n  frameStepFrames(0),\n  frameCenterFrames(0),\n  frameSize(0.0),\n  frameStep(0.0),\n  frameCenter(0.0),\n  pre(0),\n  dtype(0),\n  matBuf(NULL), matBufN(0), matBufNalloc(0),\n  tmpRow(NULL),\n  tmpVec(NULL),\n  lastText(NULL), lastCustom(NULL),\n  tmpFrameF(NULL),\n  tmpFrameI(NULL),\n  noPostEOIprocessing(0),\n  nQ(0),\n  frameMode(FRAMEMODE_FIXED),\n  ivSec(NULL), ivFrames(NULL),\n  frameIdx(0)\n{\n}\n\n\ndouble cWinToVecProcessor::stringToTimeval(char *x, int *isSec)\n{\n  long xl = (long)strlen(x);\n  while ( x[xl-1] == ' ' && xl>0 ) { x[xl-1] = 0; xl--; }\n  while ( x[0] == ' ' && xl>0 ) { x++; xl--; }\n  if (*x == 'E') { return -2.0; }\n  if (x[xl-1] == 's' || x[xl-1] == 'S') {\n    x[xl-1] = 0;\n    if (isSec!=NULL) {\n      if (*isSec == -1) *isSec = 1;\n      else if (*isSec == 0) {\n        SMILE_IERR(2,\"mixing time specifiers in seconds and frames is not supported! Please ensure that all time values are not suffixed by an 's' ! (openSMILE in this case will treat all values as being given in input level frames ...): '%s'\", x);\n      }\n    }\n  } else {\n    if (isSec!=NULL) {\n      if (*isSec == -1) *isSec = 0;\n      else if (*isSec == 1) {\n        SMILE_IERR(2,\"mixing time specifiers in seconds and frames is not supported! Please ensure that all time values are suffixed by an 's' ! (openSMILE in this case will treat all values as being given in seconds...)\");\n      }\n    }\n  }\n  return strtod(x,NULL);\n}\n\nvoid cWinToVecProcessor::fetchConfig()\n{\n  cDataProcessor::fetchConfig();\n\n  allow_last_frame_incomplete_ = getInt(\"allowLastFrameIncomplete\");\n\n  if (isSet(\"frameSizeFrames\")) {\n    frameSizeFrames = getInt(\"frameSizeFrames\");\n    if (frameSizeFrames != 0)  fsfGiven = 1;\n    SMILE_DBG(2,\"frameSizeFrames = %i\",frameSizeFrames);\n  } else {\n    frameSize = getDouble(\"frameSize\");\n    SMILE_DBG(2,\"frameSize = %f s\",frameSize);\n  }\n  if (isSet(\"frameStepFrames\")) {\n    frameStepFrames = getInt(\"frameStepFrames\");\n    if (frameStepFrames != 0) fstfGiven = 1;\n    SMILE_DBG(2,\"frameStepFrames = %i\",frameStepFrames);\n  } else {\n    frameStep = getDouble(\"frameStep\");\n    SMILE_DBG(2,\"frameStep = %f s\",frameStep);\n  }\n\n  noPostEOIprocessing = getInt(\"noPostEOIprocessing\");\n  if (noPostEOIprocessing) { SMILE_IDBG(2,\"not processing incomplete frames at end of input\"); }\n  \n  const char *tmp = getStr(\"frameMode\");\n  if (tmp != NULL) {\n    if (!strncmp(tmp,\"fix\",3)) { frameMode = FRAMEMODE_FIXED; }\n    else if (!strncmp(tmp,\"var\",3)) { frameMode = FRAMEMODE_VAR; }\n    else if (!strncmp(tmp,\"ful\",3)) { frameMode = FRAMEMODE_FULL; }\n    else if (!strncmp(tmp,\"msg\",3)) { frameMode = FRAMEMODE_VAR; }\n    else if (!strncmp(tmp,\"meta\",4)) { frameMode = FRAMEMODE_META; }\n    else if (!strncmp(tmp,\"list\",4)) { frameMode = FRAMEMODE_LIST; }\n    else if (!strncmp(tmp,\"message\",7)) { frameMode = FRAMEMODE_VAR; }\n  }\n  SMILE_IDBG(2,\"frameMode = %i\\n\",frameMode);\n\n  if (frameMode == FRAMEMODE_LIST) {\n    const char *flf=NULL;\n    char * fl = NULL;\n    if (isSet(\"frameListFile\")) { // prefer file over config file list\n      flf = getStr(\"frameListFile\");\n      SMILE_IMSG(3,\"using frameList from external file: '%s'\");\n      if (isSet(\"frameList\")) {\n        SMILE_IWRN(1,\"frameListFile overrides option frameList! option frameList will be ignored!\");\n      }\n      if (flf != NULL) { // open file and read frame list (only 1st line!)\n        FILE *f = fopen(flf,\"r\");\n        size_t n;\n        smile_getline(&fl,&n,f);\n        fclose(f);\n      } else { // display error message, shouldn't happen\n        SMILE_IERR(1,\"cannot open frameListFile 'NULL'\");\n        COMP_ERR(\"aborting\");\n      }\n    } else {\n      if (isSet(\"frameList\")) {\n        // get frame list\n        const char * _fl = getStr(\"frameList\");\n        if (_fl != NULL) {\n          fl = strdup(_fl);\n        } else {\n          SMILE_IERR(1,\"frameList string is 'NULL'\");\n          COMP_ERR(\"aborting\");\n        }\n      } else {\n        SMILE_IERR(1,\"you have selected frameMode=list, but you have specified neither frameList nor frameListFile options! One of these is required!\");\n        COMP_ERR(\"aborting\");\n      }\n    }\n    if (fl != NULL) { // if frameList has been loaded\n      //printf(\"Loaded: %s \\n\",fl);\n      // parse frame list string\n      // 1(s)-20(s),...,999-E <- intervals\n      // 1,2,1,1,   <- lengths\n\n      // do a quick count of commas to determine number of intervals\n      char * c = NULL;\n      char * s = fl;\n      int nIvs = 1;\n      do {\n        c = strchr(s,',');\n        if (c != NULL) {\n          nIvs++;\n          s = c+1;\n        }\n      } while (c!=NULL);\n\n      // allocate arrays\n      nIntervals = nIvs;\n      ivSec = (double*)calloc(1,sizeof(double)*nIvs*2);\n      ivFrames = (long*)calloc(1,sizeof(long)*nIvs*2);\n      long idx=0;\n      double last=0.0;\n\n      //printf(\"nIntervals: %i \\n\",nIntervals);\n\n      // arrays are filled with -1 to indicate missing data\n      // -2 indicates end of input\n      // 0 indicates beginning of input , logically...\n      // when input level period is available, convert all to frames data\n\n      // find commas, ignore spaces\n      s = fl;\n      int l;\n      int isIv = -1; \n      int isSec = -1;\n      do {\n        c = strchr(s,',');\n        if (c != NULL) {\n          *c = 0;\n        }\n        l = (int)strlen(s);\n        // process string s, which contains one token only by now\n        // check for \"-\" in string -> interval\n        char *x = strchr(s,'-');\n        if (x!=NULL) { // interval\n          if (isIv == -1) isIv = 1;\n          else {\n            if (isIv != 1) {\n              SMILE_IWRN(2,\"mixing intervals and continuous frames (lengths) may lead to unpredictable results if not used deliberately and with care! (see frameList or frameListFile option : substring string  = '%s')\",s);\n            }\n          }\n          *x = 0; x++;\n          // start: s, end: x\n          double start=stringToTimeval(s,&isSec);\n          double end=stringToTimeval(x,&isSec);\n\n          if (isSec) {\n            ivSec[idx*2] = start;\n            ivSec[idx*2+1] = end;\n          } else {\n            ivFrames[idx*2] = (long)start;\n            ivFrames[idx*2+1] = (long)end;\n          }\n\n          idx++;\n\n        } else { // no interval, length of segment given, segments are continuous\n\n          if (isIv == -1) isIv = 0;\n          else {\n            if (isIv != 0) {\n              SMILE_IWRN(2,\"mixing intervals and continuous frames (lengths) may lead to unpredictable results if not used deliberately and with care! (see frameList or frameListFile option : substring string  = '%s')\",s);\n            }\n          }\n          double len=stringToTimeval(s,&isSec);\n          if (isSec) {\n            ivSec[idx*2] = last;\n            if (len != -2.0)\n              ivSec[idx*2+1] = last+len;\n            else\n              ivSec[idx*2+1] = len;\n          } else {\n            ivFrames[idx*2] = (long)(last);\n            if (len != -2.0)\n              ivFrames[idx*2+1] = (long)(last+len-1);\n            else\n              ivFrames[idx*2+1] = -2;\n          }\n          last += len;\n\n          idx++;\n        }\n        s = c+1;\n\n      } while (c != NULL);\n\n      if (isSec==1) { ivFrames[0] = -1; }\n\n      // free string\n      free(fl);\n    }\n\n    // TODO: get frame array list\n    //SMILE_IERR(1,\"FRAMEMODE_LIST not yet implemented!! See winToVecProcessor.cpp!\");\n  }\n/*\n  outputPeriod = getDouble(\"outputPeriod\");\n  if (outputPeriod <= 0.0) outputPeriod = 0.1;\n  SMILE_DBG(2,\"outputPeriod = %f s\",outputPeriod);\n*/\n\n/*\n  if (isSet(\"outputBuffersize\")) {\n    outputBuffersize = getInt(\"outputBuffersize\");\n    SMILE_DBG(2,\"outputBuffersize = %i frames\",outputBuffersize);\n  }*/\n  \n}\n\nint cWinToVecProcessor::addFconf(long bs, int field) // return value is index of assigned configuration\n{\n  int i;\n  if (bs<=0) return -1;\n  for (i=0; i<Nfi; i++) {\n    if ((confBs[i] == bs)||(confBs[i]==0)) {\n      confBs[i] = bs;\n      fconfInv[i] = field;\n      fconf[field] = i;\n      if (i>=Nfconf) Nfconf = i+1;\n      return i;\n    }\n  }\n  return -1;\n}\n\nvoid cWinToVecProcessor::multiConfFree( void *x )\n{\n  int i;\n  void **y = (void **)x;\n  if (y!=NULL) {\n    for (i=0; i<getNf(); i++) {\n      if (y[i] != NULL) free(y[i]);\n    }\n    free(y);\n  }\n}\n\nint cWinToVecProcessor::configureWriter(sDmLevelConfig &c)\n{\n  SMILE_DBG(2,\"reader period = %f\",c.T);\n\n  if ((!fsfGiven)&&(c.T!=0.0)) frameSizeFrames = (long)round(frameSize / c.T);\n  else frameSize = ((double)frameSizeFrames) * c.T;\n  if (frameStep == 0.0) frameStep = frameSize;\n  if (!fstfGiven) {\n    if (c.T != 0.0)\n      frameStepFrames = (long)round(frameStep / c.T);\n    else\n      frameStepFrames = frameSizeFrames;\n  } else frameStep = ((double)frameStepFrames) * c.T;\n  if (frameStepFrames == 0) frameStepFrames = frameSizeFrames;\n\n  \n  SMILE_DBG(2,\"computed frameSizeFrames = %i\",frameSizeFrames);\n  SMILE_DBG(2,\"computed frameStepFrames = %i\",frameStepFrames);\n\n  if (isSet(\"frameCenterSpecial\")) {\n    const char * fc = getStr(\"frameCenterSpecial\");\n    if (fc!=NULL) {\n      frameCenterFrames = 0;\n      if (!strncasecmp(fc,\"mi\",2)) frameCenter=frameSize/2.0;\n      else if (!strncasecmp(fc,\"ce\",2)) frameCenter=frameSize/2.0;\n      else if (!strncasecmp(fc,\"le\",2)) frameCenter=0.0;\n      else if (!strncasecmp(fc,\"ri\",2)) frameCenterFrames=frameSizeFrames-1;\n      else frameCenterFrames=0; // frameSizeFrames-1;\n    }\n    if (frameCenterFrames == 0) {\n      if (c.T != 0.0) frameCenterFrames = (long)round(frameCenter / c.T);\n      else frameCenterFrames = (long)round(frameCenter);\n    }\n  } else {\n    if (isSet(\"frameCenterFrames\")) {\n      frameCenterFrames = getInt(\"frameCenterFrames\");\n      frameCenter = (frameCenterFrames * c.T); // + frameSize/2.0;\n      //frameCenterFrames += frameSizeFrames/2;\n    } else {\n      frameCenter = getDouble(\"frameCenter\");\n      //frameCenter += frameSize/2.0;\n      if (c.T != 0.0) frameCenterFrames = (long)round(frameCenter / c.T);\n      else frameCenterFrames = (long)round(frameCenter);\n    }\n  }\n\n  SMILE_DBG(2,\"frameCenter = %f\",frameCenter);\n  SMILE_DBG(2,\"frameCenterFrames = %i\",frameCenterFrames);\n  if (frameMode == FRAMEMODE_FULL) {\n    pre = 0;\n  } else {\n    pre = -frameCenterFrames;\n  }\n  \n  if (frameStep == 0.0 && frameStepFrames == 0 && frameMode == FRAMEMODE_FIXED) {\n    frameMode = FRAMEMODE_FULL;\n  }\n\n  if ((frameMode == FRAMEMODE_FULL)||(frameMode==FRAMEMODE_VAR)||(frameMode==FRAMEMODE_META)||(frameMode==FRAMEMODE_LIST)) {\n    frameStep = 0.0;\n    frameSize = 0.0;\n    frameStepFrames = 0;\n    frameSizeFrames = 0;\n  }\n\n\n  if (frameMode == FRAMEMODE_FULL) { // full input mode\n    if (isSet(\"noPostEOIprocessing\") && (noPostEOIprocessing == 1)) { \n      SMILE_IWRN(1,\"default user defined option noPostEOIprocessing=1 forced to 0 due to frameStep==0.0 (full input mode)\");\n    }\n    noPostEOIprocessing = 0; // change default...\n  }\n\n  long fsMax=0;\n  if (frameMode == FRAMEMODE_LIST) {\n    long i;\n    if (ivFrames[0] == -1) {\n      // convert intervals given in seconds to frames..\n      double _T = c.T;\n      if (_T == 0.0) _T = 1.0;\n      for (i=0; i<nIntervals; i++) {\n        ivFrames[i*2] = (long)floor(ivSec[i*2] / _T);\n        if (ivSec[i*2+1] >= 0.0) {\n          ivFrames[i*2+1] = (long)ceil(ivSec[i*2+1] / _T);\n        } else {\n          ivFrames[i*2+1] = (long)ivSec[i*2+1];\n        }\n\n      }\n    }\n    // find maximum interval size, and set frameSizeFrame to that...\n    for (i=0; i<nIntervals; i++) {\n      if (ivFrames[i*2+1] - ivFrames[i*2] > fsMax) {\n        fsMax = ivFrames[i*2+1] - ivFrames[i*2];\n      }\n    }\n  }\n\n  /*for (int i=0; i<nIntervals; i++) {\n    printf(\"iv %i: %i - %i\\n\",i,ivFrames[i*2],ivFrames[i*2+1]);\n    printf(\"iv %i: %f - %f\\n\",i,ivSec[i*2],ivSec[i*2+1]);\n  }*/\n\n  // we adjust the buffersize proportionally \n  if ((frameStepFrames==0)||(frameSizeFrames==0)) {\n    c.nT = 2;\n  } else {\n    c.nT /= frameStepFrames;\n  }\n  SMILE_DBG(2,\"using buffersize = %i frames\",c.nT);\n\n  // we overwrite the reader period with the recently computed writer period...\n  c.T = frameStep;\n  c.frameSizeSec = frameSize;\n  dtype = c.type; // INPUT type ??\n  c.type = DMEM_FLOAT;\n\n  if ((frameMode != FRAMEMODE_VAR)&&(frameMode != FRAMEMODE_META)&&(frameMode != FRAMEMODE_LIST)) { // ||(frameMode==FRAMEMODE_LIST)\n    reader_->setupSequentialMatrixReading(frameStepFrames, frameSizeFrames, pre);\n  } else if ((frameMode == FRAMEMODE_LIST)) {\n    reader_->setupSequentialMatrixReading(fsMax, fsMax, 0);\n  }\n\n  // this is now handled by cDataProcessor myConfigureInstance\n  //writer->setConfig( 1, len, frameStep, 0.0, frameSize, 0, DMEM_FLOAT);\n\n  // we must return 1, in order to indicate configure success (0 indicates failure)\n  return 1;\n}\n\n\n// overwrite in descendant class, return number of elements that are output for each input element\n // NOTE: this is rather a setupNamesForElement!!\nint cWinToVecProcessor::setupNamesForElement(int idxi, const char*name, long nEl)\n{\n  if (wholeMatrixMode) {\n    return setupNamesForField(idxi,name,getNoutputs(nEl));\n  } else {\n    return setupNamesForField(idxi,name,getMultiplier());\n  }\n}\n\n// this must return the multiplier, i.e. the vector size returned for each input element (e.g. number of functionals, etc.)\nint cWinToVecProcessor::getMultiplier()\n{\n  return 1;\n}\n\n// get the number of outputs given a number of inputs, \n// this is used for wholeMatrixMode, where the quantitative relation between inputs and outputs may be non-linear\n// this replaces getMultiplier, which is used in the standard row-wise processing mode\nlong cWinToVecProcessor::getNoutputs(long nIn) \n{\n  // some default behaviour... override this in your derived class\n  return nIn;\n}\n\n// OBSOLETE\n/*\nint cWinToVecProcessor::myConfigureInstance()\n{\n  int ret = cDataProcessor::myConfigureInstance();\n\n  return ret;\n}\n*/\n\nint cWinToVecProcessor::dataProcessorCustomFinalise() \n{\n  Ni = reader_->getLevelN();\n  Nfi = reader_->getLevelNf();\n  No = 0;\n  //  Nfo = Ni;\n  inputPeriod = reader_->getLevelT();\n\n  int i,n;\n\n  long e=0;\n\n  if (wholeMatrixMode) {\n\n    if (processFieldsInMatrixMode) {\n      for (i = 0; i < Nfi; i++) {\n        int __N=0;\n        const char *tmp = reader_->getFieldName(i, &__N);\n        No += setupNamesForElement(i, tmp, __N);\n      }\n    } else {\n      int __N=0;\n      const char *tmp = reader_->getFieldName(0,&__N);\n      No += setupNamesForElement(0, tmp, Ni);\n    }\n\n  } else {\n\n\n  for (i=0; i<Nfi; i++) {\n    int __N=0;\n    const char *tmp = reader_->getFieldName(i,&__N);\n    if (tmp == NULL) { SMILE_ERR(1,\"reader->getFieldName(%i) failed (return value = NULL)!\",i); return 0; }\n\n    {\n      if (__N > 1) {\n\n        for (n=0; n<__N; n++) {\n          char *na = reader_->getElementName(e);\n          No += setupNamesForElement(e++, na, 1);\n          free(na);\n        }\n\n      } else {\n        No += setupNamesForElement(e++, tmp, 1);\n      }\n    }\n  }\n\n  }\n\n  namesAreSet_ = 1;\n\n  if (!wholeMatrixMode) {\n    Mult = getMultiplier();\n    if (Mult*Ni != No) COMP_ERR(\"Mult not constant (as returned by setupNamesForField! This is not allowed! Mult*Ni=%i <> No=%i\",Mult*Ni,No);\n    if (tmpFrameF==NULL) tmpFrameF=(FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*Mult);\n    if (tmpFrameI==NULL) tmpFrameI=(INT_DMEM*)calloc(1,sizeof(INT_DMEM)*Mult);\n  }\n  return 1;\n}\n\n/*\nint cWinToVecProcessor::myFinaliseInstance()\n{\n\n  // get reader names, append _win(_winf) to it (winf is optional)\n  int ret=1;\n  ret *= reader->finaliseInstance();\n  if (!ret) return ret;\n\n  Ni = reader->getLevelN();\n  Nfi = reader->getLevelNf();\n  No = 0;\n//  Nfo = Ni;\n  inputPeriod = reader->getLevelT();\n\n  int i,n;\n\n  long e=0;\n  for (i=0; i<Nfi; i++) {\n    int __N=0;\n    const char *tmp = reader->getFieldName(i,&__N);\n    if (tmp == NULL) { SMILE_ERR(1,\"reader->getFieldName(%i) failed (return value = NULL)!\",i); return 0; }\n    if (__N > 1) {\n\n      for (n=0; n<__N; n++) {\n\t\t    char *na = reader->getElementName(e);\n        No += setupNamesForField(e++, na, 1);\n        free(na);\n      }\n\n    } else {\n      No += setupNamesForField(e++, tmp, 1);\n    }\n  }\n\n  namesAreSet = 1;\n  Mult = getMultiplier();\n  if (Mult*Ni != No) COMP_ERR(\"Mult not constant (as returned by setupNamesForField! This is not allowed! Mult*Ni=%i <> No=%i\",Mult*Ni,No);\n  if (tmpFrameF==NULL) tmpFrameF=(FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*Mult);\n  if (tmpFrameI==NULL) tmpFrameI=(INT_DMEM*)calloc(1,sizeof(INT_DMEM)*Mult);\n\n  if (frameMode != FRAMEMODE_VAR) \n    reader->setupSequentialMatrixReading(frameStepFrames, frameSizeFrames, pre);\n\n  return cDataProcessor::myFinaliseInstance();\n  \n}\n*/\n\nint cWinToVecProcessor::doProcessMatrix(int idxi, cMatrix *in, FLOAT_DMEM *out, long nOut)\n{\n  SMILE_IERR(1,\"doProcessMatrix (type FLOAT_DMEM) is not implemented in this component, however for some reason the 'wholeMatrixMode' variable was set to 1...!\");\n  return 0;\n}\n\nint cWinToVecProcessor::doProcessMatrix(int idxi, cMatrix *in, INT_DMEM *out, long nOut)\n{\n  SMILE_IERR(1,\"doProcessMatrix (type INT_DMEM) is not implemented in this component, however for some reason the 'wholeMatrixMode' variable was set to 1...!\");\n  return 0;\n}\n\n// idxi is index of input element\n// row is the input row\n// y is the output vector (part) for the input row\nint cWinToVecProcessor::doProcess(int idxi, cMatrix *row, FLOAT_DMEM*y)\n{\n   /* int i;\n    for (i=0;i<row->nT; i++) {\n      printf(\"[%i] %f\\n\",i,row->dataF[i]);\n    }*/\n  SMILE_IERR(1,\"dataType FLOAT_DMEM not yet supported!\");\n  //return getMultiplier();\n  return 0;\n  // return the number of actually set components in y!!\n  // return 0 on failue\n  // return -1 if you don't want to set a new output frame...\n}\n\nint cWinToVecProcessor::doProcess(int idxi, cMatrix *row, INT_DMEM*y)\n{\n  SMILE_IERR(1,\"dataType INT_DMEM not yet supported!\");\n  //return getMultiplier();\n  return 0;\n  // return the number of actually set components in y!!\n  // return 0 on failue\n  // return -1 if you don't want to set a new output frame...\n}\n\nint cWinToVecProcessor::doFlush(int idxi, FLOAT_DMEM*y)\n{\n  //SMILE_IERR(1,\"dataType FLOAT_DMEM not yet supported!\");\n  //return getMultiplier();\n  return 0;\n  // return the number of actually set components in y!!\n  // return 0 on failue\n  // return -1 if you don't want to set a new output frame...\n}\n\nint cWinToVecProcessor::doFlush(int idxi, INT_DMEM*y)\n{\n  //SMILE_IERR(1,\"dataType INT_DMEM not yet supported!\");\n  //return getMultiplier();\n  return 0;\n  // return the number of actually set components in y!!\n  // return 0 on failue\n  // return -1 if you don't want to set a new output frame...\n}\n\n// get data for next segment begin/end from frame message memory (if FRAMEMODE_VAR)\nint cWinToVecProcessor::getNextFrameData(double *start, double *end, int *flag, int *ID)\n{\n  if ((start!=NULL)&&(end!=NULL)) {\n    lockMessageMemory();\n    if (nQ > 0) {\n      *start = Qstart[0];\n      *end = Qend[0];\n      if (flag != NULL) *flag = Qflag[0];\n      if (ID != NULL) *ID = QID[0];\n      int i;\n      for (i=0; i<nQ-1; i++) {\n        Qstart[i] = Qstart[i+1];\n        Qend[i] = Qend[i+1];\n        Qflag[i] = Qflag[i+1];\n        QID[i] = QID[i+1];\n      }\n      nQ--;\n      unlockMessageMemory();\n      return 1;\n    } else {\n      *start = -1.0;\n      *end = -1.0;\n      if (flag != NULL) *flag = -1;\n      unlockMessageMemory();\n      return 0;\n    }\n  }\n  return 0;\n}\n\nint cWinToVecProcessor::peakNextFrameData(double *start, double *end, int *flag, int *ID)\n{\n  if ((start!=NULL)&&(end!=NULL)) {\n    lockMessageMemory();\n    if (nQ > 0) {\n      *start = Qstart[0];\n      *end = Qend[0];\n      if (flag != NULL) *flag = Qflag[0];\n      if (ID != NULL) *ID = QID[0];\n      unlockMessageMemory();\n      return 1;\n    } else {\n      *start = -1.0;\n      *end = -1.0;\n      if (flag != NULL) *flag = -1;\n      unlockMessageMemory();\n      return 0;\n    }\n  }\n  return 0;\n}\n\nint cWinToVecProcessor::clearNextFrameData()\n{\n  lockMessageMemory();\n  if (nQ > 0) {\n    int i;\n    for (i=0; i<nQ-1; i++) {\n      Qstart[i] = Qstart[i+1];\n      Qend[i] = Qend[i+1];\n      Qflag[i] = Qflag[i+1];\n      QID[i] = QID[i+1];\n    }\n    nQ--;\n    unlockMessageMemory();\n    return 1;\n  }\n  unlockMessageMemory();\n  return 0;\n}\n\nint cWinToVecProcessor::queNextFrameData(double start, double end, int flag, int ID)\n{\n  if (nQ < FRAME_MSG_QUE_SIZE) {\n    Qstart[nQ] = start;\n    Qend[nQ] = end;\n    Qflag[nQ] = flag;\n    QID[nQ++] = ID;\n    return 1;\n  }\n  return 0;\n}\n\nint cWinToVecProcessor::processComponentMessage( cComponentMessage *_msg )\n{\n  if (isMessageType(_msg,\"turnFrameTime\")) {\n    SMILE_IMSG(4,\"received a 'turnFrameTime' message\");\n    if (frameMode != FRAMEMODE_VAR) {\n      SMILE_IWRN(2,\"frameMode is not set to 'var(iable)', but a 'turnFrameTime' message was received (the message will be ignored). Check your config!\");\n    }\n    return queNextFrameData(_msg->floatData[0], _msg->floatData[1], _msg->intData[0], _msg->intData[5]);\n  }\n  return 0;\n}\n\nvoid cWinToVecProcessor::addVecToBuf(cVector *ve) \n{\n  // add the current vector to the buffer...\n  if (matBuf == NULL) {\n    matBuf = new cMatrix(ve->N, MATBUF_ALLOC_STEP);\n  }\n  if (matBuf->nT <= matBufN) {\n    matBuf->resize(matBufN + MATBUF_ALLOC_STEP);\n  }\n  long i;\n  for (i=0; i<ve->N; i++) {\n    matBuf->dataF[i+matBufN*matBuf->N] = ve->dataF[i];\n  }\n  matBufN++;\n}\n\nint cWinToVecProcessor::myTick(long long t)\n{\n  SMILE_IDBG(4, \"tick # %i, running winToVecProcessor ....\",t);\n  \n  if ((isEOI())&&(noPostEOIprocessing)) {\n    if ((noPostEOIprocessing)&&((frameMode == FRAMEMODE_FULL)||(frameMode == FRAMEMODE_LIST && ivFrames[nIntervals*2-1]==-2))) {\n      SMILE_IWRN(1,\"frameMode=full|list, or frameStep==0: this means processing of full input at End-Of-Input is enabled. However, noPostEOIProcessing is set to 'yes' (1) . This means that no output will be produced!! To solve this, set noPostEOIProcessing=0 in section [%s:%s]\",getInstName(),getTypeName());\n    }\n    return 0;\n  }\n\n  if (!(writer_->checkWrite(1))) return 0;\n\n  int customID = 0;\n  cMatrix *mat=NULL;\n  cVector * vec=NULL;\n  int isFinal = 0;\n  // get next frame from dataMemory\n  if (frameMode == FRAMEMODE_META) { \n    vec = reader_->getNextFrame();\n    if (vec == NULL) return 0;\n    // check for arff instance id in vector meta data!\n    if ((vec->tmeta->metadata.iData[1] != 1234)||(vec->tmeta->metadata.text == NULL)) {\n      SMILE_IERR(1,\"using frameMode=meta requires instance ID as string in vector meta data (see the saveInstanceIdInMetadata option in cArffSource!)\");\n    } else {\n      //SMILE_IMSG(1,\"metadata.custom = '%s'\",vec->tmeta->metadata.custom);\n      // check meta info, add frames to buffer... flush if meta info text changes\n      if ((lastText!=NULL)&&(strcmp(lastText,vec->tmeta->metadata.text))) {\n        // if the strings differ... we generate a new segment\n        if (matBuf != NULL) {\n          mat = matBuf;\n          matBufNalloc = matBuf->nT;\n          matBuf->nT = matBufN;\n        }\n      } else {\n        if (lastText == NULL) {\n          // save old metadata.text / custom\n          lastText = strdup(vec->tmeta->metadata.text);\n          if (lastCustom != NULL) free(lastCustom);\n          lastCustom = strdup((char*)(vec->tmeta->metadata.custom));\n        }\n        // add new frame to buffer\n        addVecToBuf(vec);\n        // no new segment...\n        return 0;\n      }\n\n    }\n  \n  } else if (frameMode == FRAMEMODE_VAR) {\n\n    double start = 0.0;\n    double end = 0.0;\n    if (peakNextFrameData(&start, &end, &isFinal, &customID)) { // TODO: add turn end flag here (isFinal)\n      // comment: why start -1  and end +1 ?? \n      /*\n      SMILE_IDBG(3,\"getting frame based on received message: vIdx %i - %i\",(long)start - 1, (long)end + 1);\n      mat = reader->getMatrix((long)start - 1,(long)(end-start) + 2);\n      */\n      // EDIT: by Flo: removed this silly behaviour. This breaks compatibility with old code, but should be fine anyways..?\n      SMILE_IDBG(3,\"getting frame based on received message: vIdx %i - %i\",(long)start, (long)end);\n      mat = reader_->getMatrix((long)start,(long)(end-start)+1);\n      if (mat != NULL) {\n        /* SMILE_IDBG(2,\"successfully got frame based on received message: vIdx %i - %i (nT:%i)\",(long)start-1, (long)end+1, mat->nT); */\n        SMILE_IDBG(2,\"successfully got frame based on received message: vIdx %i - %i (nT:%i)\",(long)start, (long)end, mat->nT);\n        clearNextFrameData();\n      }\n    } else {\n      return 0;\n    }\n\n  } else if (frameMode == FRAMEMODE_LIST) {\n\n    if (frameIdx < nIntervals) {\n\n       long start = ivFrames[frameIdx*2];\n       long end = ivFrames[frameIdx*2+1];\n\n     //  if (peakNextFrameData(&start, &end, &isFinal)) { // TODO: add turn end flag here (isFinal)\n\n         SMILE_IDBG(3,\"attempting to get next frame from list: vIdx %i - %i\",(long)start, (long)end);\n         if (end > 0) {\n           mat = reader_->getMatrix((long)start,(long)(end-start) + 1);\n         } else if (end == -2) {\n           //mat = reader->getMatrix((long)start,/*TODO*/);\n           SMILE_IWRN(1,\"a segment boundary from current position to end of input is not yet supported!\");\n         }\n         if (mat != NULL) {\n           SMILE_IDBG(2,\"successfully got next frame from list: vIdx %i - %i (nT:%i)\",(long)start, (long)end, mat->nT);\n     //      clearNextFrameData(); // increase frame list pointer:\n           frameIdx++;\n         }\n//       } else {\n//         return 0;\n//       }\n    } else { return 0; }\n\n  } else {\n    if (allow_last_frame_incomplete_ == 1) {\n      mat = reader_->getNextMatrix(0, 0, DMEM_PAD_NONE);\n#ifdef DEBUG\n      long ss = 0;\n      if (mat != NULL) ss = mat->nT;\n      SMILE_IDBG(4, \"winToVecProcessor: get mat with DMEM_PAD_NONE, eoi = %i, mat = %ld (size %ld)\\n\", getInstName(), isEOI(), mat, ss);\n#endif\n    } else if (allow_last_frame_incomplete_ == 2) {\n      mat = reader_->getNextMatrix(0, 0, DMEM_PAD_ZERO);\n#ifdef DEBUG\n      long ss = 0;\n      if (mat != NULL) ss = mat->nT;\n      SMILE_IDBG(4, \"winToVecProcessor: get mat with DMEM_PAD_ZERO, eoi = %i, mat = %ld (size %ld)\\n\", getInstName(), isEOI(), mat, ss);\n#endif\n    } else {\n      mat = reader_->getNextMatrix();\n#ifdef DEBUG\n      long ss = 0;\n      if (mat != NULL) ss = mat->nT;\n      SMILE_IDBG(4, \"winToVecProcessor: get mat without pad, eoi = %i, mat = %ld (size %ld)\\n\", getInstName(), isEOI(), mat, ss);\n#endif\n    }\n  }\n  //SMILE_IMSG(1,\"mat %lld eoi %i match %i\\n\", (long long)mat,isEOI(), EOIlevelIsMatch());\n\n  if ((mat == NULL) && (!(isEOI()&&EOIlevelIsMatch()))) { \n    // currently no data available\n    return 0; \n  } \n\n  int type;\n  if (mat==NULL) {\n    const sDmLevelConfig * c = writer_->getLevelConfig();\n    if (c!=NULL) type = c->type;\n    else return 0;\n  } else { type=mat->type; }\n\n  if (tmpVec==NULL) tmpVec = new cVector(No,type);\n  \n  if (frameMode == FRAMEMODE_META) { \n    // set tmeta correctly in tmpVec...      \n    if (tmpVec->tmeta->metadata.text != NULL) free(tmpVec->tmeta->metadata.text);\n    tmpVec->tmeta->metadata.text = strdup(lastText);\n    if (tmpVec->tmeta->metadata.custom != NULL) free(tmpVec->tmeta->metadata.custom);\n    tmpVec->tmeta->metadata.custom = strdup(lastCustom);\n    tmpVec->tmeta->metadata.customLength = (long)(strlen(lastCustom)+1);\n    tmpVec->tmeta->metadata.iData[1] = 1234;\n    //TODO: proper tmeta squashing and cloning for correct time-stamps!\n    // (problem: after squashing, we must restore to original state for new data in buffer...?)\n\n    // next...\n    if (lastText != NULL) free(lastText);\n    lastText = strdup(vec->tmeta->metadata.text);\n    if (lastCustom != NULL) free(lastCustom);\n    lastCustom = strdup((char*)(vec->tmeta->metadata.custom));\n  }\n\n  //if ((tmpRow==NULL)&&(mat!=NULL)) tmpRow = mat->getRow(0);\n\n//  printf(\"vs=%i Nf=%i nn=%i\\n\",tmpVec->N,Nf,nNotes);\n  int i,toSet=1,ret=1;\n  if (type == DMEM_FLOAT) {\n    if (wholeMatrixMode) { // call the function to process the whole data matrix, producing a single output vector\n\n      if (mat != NULL) {\n      if (processFieldsInMatrixMode) {\n        FLOAT_DMEM * opVec = tmpVec->dataF;\n        for(i=0; i<Nfi; i++) {\n          long nout = getNoutputs(mat->fmeta->field[i].N);\n          doProcessMatrix(i,mat,opVec,nout);\n          opVec += nout;\n        }\n      } else { \n        doProcessMatrix(0,mat,tmpVec->dataF,tmpVec->N);\n      }\n\n      } else { ret = 0; toSet = 0; }\n\n    } else { // process each row independently and concatenate output vectors\n\n      for (i=0; i<Ni; i++) {\n        long Mu;\n        //cMatrix *r=NULL;\n        if (mat!=NULL) {\n          tmpRow = mat->getRow(i,tmpRow);\n          Mu = doProcess(i,tmpRow,tmpFrameF);\n        } else {\n          Mu = doFlush(i,tmpFrameF);\n        }\n        if ((Mu > 0)&&(toSet==1)) {\n          // copy data into main vector\n          Mu = MIN(Mu,Mult);\n          memcpy( tmpVec->dataF+i*Mult, tmpFrameF, sizeof(FLOAT_DMEM)*Mu ); // was: *Mult\n          if (Mu<Mult)\n            memset( tmpVec->dataF+i*Mult+Mu, 0, sizeof(FLOAT_DMEM)*(Mult-Mu) );\n        } else { \n          toSet=0;\n          if (Mu==0) {\n            ret=0;\n          }\n        }\n        //if (r!=NULL) delete r;\n      }\n    }\n  } else if (mat->type == DMEM_INT) {\n    if (wholeMatrixMode) { // call the function to process the whole data matrix, producing a single output vector\n      if (processFieldsInMatrixMode) {\n        for(i=0; i<Nfi; i++) {\n          //doProcessMatrix(i,mat,tmpVec); // TODO!\n        }\n      } else { \n        doProcessMatrix(0,mat,tmpVec->dataI, tmpVec->N);\n      }\n\n    } else { // process each row independently and concattenate output vectors\n\n\n      for (i=0; i<Ni; i++) {\n        // TODO: return value... toSet, etc...\n        //!!!!!!!!!!!!\n        //cMatrix *r = mat->getRow(i);\n        doProcess(i,tmpRow,tmpFrameI);\n        // copy data into main vector\n        memcpy( tmpVec->dataI+i*Mult, tmpFrameI, sizeof(INT_DMEM)*Mult );\n      }\n    }\n  } else { SMILE_ERR(1,\"unknown dataType %i (inst: '%s')!!\",mat->type,getInstName()); return 0; }\n  \n  if (toSet == 1) {\n    if (frameMode == FRAMEMODE_META) { \n      mat->nT = matBufNalloc;\n      matBufN = 0; // (the vector we just added)\n      addVecToBuf(vec);\n    } else {\n    // generate new tmeta from first and last tmeta\n    if (mat != NULL) {\n      mat->tmetaSquash();\n      if (frameCenterFrames>0) {\n        mat->tmeta[0].time += frameCenter;\n      }\n      tmpVec->tmetaReplace(mat->tmeta);  // tmetaClone ??\n    } else {\n      // ugly TODO: compute correct tmeta...\n    }\n    }\n    tmpVec->tmeta->metadata.ID = customID;\n    tmpVec->tmeta->metadata.iData[0] = isFinal;\n \n    // save to dataMemory\n    writer_->setNextFrame(tmpVec);\n  }\n\n  return ret;\n}\n\n\ncWinToVecProcessor::~cWinToVecProcessor()\n{\n  if (tmpFrameF!=NULL) free(tmpFrameF);\n  if (tmpFrameI!=NULL) free(tmpFrameI);\n  if (ivSec != NULL) free(ivSec);\n  if (ivFrames != NULL) free(ivFrames);\n  if (tmpVec!=NULL) delete tmpVec;\n  if (tmpRow != NULL) delete tmpRow;\n  if (matBuf != NULL) delete matBuf;\n  if (lastText != NULL) free(lastText);\n  if (lastCustom != NULL) free(lastCustom);\n}\n\n"
  },
  {
    "path": "src/core/windowProcessor.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n// TODO:!! check what happens at EOI when blocksize is large (it seems the matrix gets zero padded at the end, but it would be better to have it truncated)\n\n\n/*  openSMILE component:\n\nfilter :  (abstract class only)\n       linear N-th order filter for single value data streams\n       this class processed every element of a frame independently\n       derived classes only need to implement the filter algorithm\n\n*/\n\n\n#include <core/windowProcessor.hpp>\n\n#define MODULE \"cWindowProcessor\"\n\nSMILECOMPONENT_STATICS(cWindowProcessor)\n\nSMILECOMPONENT_REGCOMP(cWindowProcessor)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CWINDOWPROCESSOR;\n  sdescription = COMPONENT_DESCRIPTION_CWINDOWPROCESSOR;\n\n  // we inherit cDataProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataProcessor\");\n\n  SMILECOMPONENT_IFNOTREGAGAIN(\n//    ct->setField(\"pre\",\"number of past frames required\",1);\n//    ct->setField(\"post\",\"number of post frames required\",1);\n    ct->setField(\"noPostEOIprocessing\",\"1 = do not process incomplete windows at the end of the input\",0);\n    //ct->setField(\"blocksize\",\"# of samples to process at once (for computational speed-up)\",256);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cWindowProcessor);\n}\n\nSMILECOMPONENT_CREATE_ABSTRACT(cWindowProcessor)\n\n//-----\n\ncWindowProcessor::cWindowProcessor(const char *_name, int _pre, int _post) :\n  cDataProcessor(_name),\n  matnew(NULL),\n  isFirstFrame(1),\n  row(NULL),\n  rowout(NULL), rowsout(NULL),\n  pre(_pre),\n  post(_post),\n  winsize(0),\n  //blocksize(256),\n  noPostEOIprocessing(0),\n  multiplier(1)\n{\n  winsize = _pre + _post;\n}\n\nvoid cWindowProcessor::fetchConfig()\n{\n  cDataProcessor::fetchConfig();\n/*\n  blocksize = getInt(\"blocksize\");\n  SMILE_DBG(2,\"blocksize = %i\",blocksize);\n  */\n\n  noPostEOIprocessing = getInt(\"noPostEOIprocessing\");\n  if (noPostEOIprocessing) { SMILE_IDBG(2,\"not processing incomplete frames at end of input\"); }\n}\n\nvoid cWindowProcessor::setWindow(int _pre, int _post)\n{\n  pre = _pre;\n  post = _post;\n  winsize = pre+post;\n}\n\nint cWindowProcessor::configureWriter(sDmLevelConfig &c)\n{\n  // blocksize should not be larger than c->nT / 2\n/*\nif (blocksize >= c->nT/2) {\n    blocksize = c->nT / 2 - 1;\n    SMILE_MSG(3,\"auto-adjusting blocksize to %i\",blocksize);\n  }\n  if (blocksize < 1) blocksize = 1;\n*/  \n\n  /*\n  if (!writer->isManualConfigSet()) {\n    long bs;\n    if (buffersize > 0) bs = buffersize;\n    else bs=c->nT;\n    if (bs < 2*blocksize+1) bs=2*blocksize+1;\n    writer->setConfig(c->isRb, bs, c->T, c->lenSec, c->frameSizeSec, c->growDyn, c->type, 0);\n  } else {\n    if (writer->getBuffersize() < 2*blocksize+1) writer->setBuffersize(2*blocksize+1);\n  }\n*/\n\n  if (blocksizeW_ != blocksizeR_) {\n    //blocksizeW = blocksizeR;\n    blocksizeW_sec_ = blocksizeR_sec_;\n    c.blocksizeWriter = blocksizeR_;\n  }\n\n  if (winsize < pre+post) winsize = pre+post;\n  // TODO: seconds/frames??\n  reader_->setupSequentialMatrixReading(blocksizeR_,blocksizeR_+winsize,-pre); // winsize = pre + post\n\n  return 1;\n}\n\n\n// order is the amount of memory (overlap) that will be present in _buf\n// buf will have nT timesteps, however also order negative indicies (i.e. you may access a negative array index up to -order!)\nint cWindowProcessor::processBuffer(cMatrix *_in, cMatrix *_out, int _pre, int _post )\n{\n\n  // return value: \n  //   0: error, myTick will return 0, and no frame will be set\n  //   1: ok, next frame will be set\n  //   -1: ok, myTick will return 1, but no new frame will be set \n  //          (use this for analysers, for example)\n  return 0;\n}\n\n// overwrite this method in your derived class if you need to know for which input element (matrix row) \n// processBuffer was called (-> rowGlobal)\nint cWindowProcessor::processBuffer(cMatrix *_in, cMatrix *_out, int _pre, int _post, int rowGlobal )\n{\n\n  // return value: \n  //   0: error, myTick will return 0, and no frame will be set\n  //   1: ok, next frame will be set\n  //   -1: ok, myTick will return 1, but no new frame wcMatrix * rowout;ill be set\n  //          (use this for analysers, for example)\n  return 0;\n}\n\nint cWindowProcessor::dataProcessorCustomFinalise()\n{\n  Ni = reader_->getLevelN();\n  return 1;\n}\n\n/*\nint cWindowProcessor::myFinaliseInstance()\n{\n  int ret=1;\n  ret *= reader->finaliseInstance();\n  if (!ret) return ret;\n\n  \n  //ok? TODO: blocksize < order????  more or less neg start offset... zero pad, => i.e. ignMissingBegin option in reader!!\n  return cDataProcessor::myFinaliseInstance();\n}\n*/\n\nint cWindowProcessor::myTick(long long t)\n{\n  SMILE_IDBG(4,\"tick # %i, running window processor\",t);\n  if ((isEOI())&&(noPostEOIprocessing)) return 0;\n\n  int ret = 1;\n  \n  if (!(writer_->checkWrite(blocksizeW_))) return 0;\n\n  // get next block from dataMemory\n  cMatrix *mat = reader_->getNextMatrix();\n  // TODO: if blocksize< order!! also check if we need to increase the read counter!\n  if (mat != NULL) {\n\n    int i,j,toSet=0;\n    if (matnew == NULL) {\n      matnew = new cMatrix(mat->N*multiplier, mat->nT-winsize,mat->type);\n//      printf(\"XXXaa matnew N = %i, mult = %i, matN = %i, matNt %i, ws %i\\n\",matnew->N,multiplier,mat->N,mat->nT,winsize);\n    }\n\n    // TODO: support multiplier for N output rows for each input row!\n    if (rowsout == NULL) rowsout = new cMatrix(multiplier, mat->nT-winsize, mat->type);\n    if (multiplier > 1 && rowout == NULL) rowout = new cMatrix(1, mat->nT-winsize, mat->type);\n    if (row == NULL) row = new cMatrix(1,mat->nT, mat->type);\n    for (i=0; i<mat->N; i++)  {\n      // get matrix row...\n      cMatrix *rowr = mat->getRow(i,row);\n      if (rowr==NULL) COMP_ERR(\"cWindowProcessor::myTick : Error getting row %i from matrix! (return obj = NULL!)\",i);\n      if (row->dataF != NULL) row->dataF += pre;\n      if (row->dataI != NULL) row->dataI += pre;\n      row->nT -= winsize;\n      toSet = processBuffer(row, rowsout, pre, post);\n      if (toSet == 0) toSet = processBuffer(row, rowsout, pre, post, i);\n      if (!toSet) ret=0;\n      // copy row back into new matrix... ( NO overlap!)\n      if (toSet==1) {\n        if (multiplier > 1) {\n          for (j=0; j<multiplier; j++) {\n            rowsout->getRow(j,rowout);\n            matnew->setRow(i*multiplier+j,rowout);\n          }\n        } else {\n          matnew->setRow(i,rowsout);\n        }\n      }\n      if (row->dataF != NULL) row->dataF -= pre;\n      if (row->dataI != NULL) row->dataI -= pre;\n      row->nT += winsize;\n    }\n    // set next matrix...\n    if (toSet==1)  {\n      mat->tmeta += pre; // TODO::: skip \"order\" elements of tmeta array ..ok?\n      matnew->tmetaReplace(mat->tmeta); \n      mat->tmeta -= pre;\n      writer_->setNextMatrix(matnew);\n    }\n  } else {\n//         printf(\"WINPROC '%s' mat==NULL tickNr=%i EOI=%i\\n\",getInstName(),t,isEOI());\n    return 0;\n  }\n\n  isFirstFrame = 0;\n  \n  return ret;\n\n}\n\n\n\ncWindowProcessor::~cWindowProcessor()\n{\n  if (row != NULL) delete row;\n  if (rowout != NULL) delete rowout;\n  if (rowsout != NULL) delete rowsout;\n  if (matnew != NULL) delete matnew;\n}\n\n"
  },
  {
    "path": "src/dsp/dbA.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: dbA\n\napplies dbX weighting to fft magnitudes\n\n*/\n\n\n#include <dsp/dbA.hpp>\n\n#define MODULE \"cDbA\"\n\n/*Library:\nsComponentInfo * registerMe(cConfigManager *_confman) {\n  cDataProcessor::registerComponent(_confman);\n}\n*/\n\nSMILECOMPONENT_STATICS(cDbA)\n\nSMILECOMPONENT_REGCOMP(cDbA)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CDBA;\n  sdescription = COMPONENT_DESCRIPTION_CDBA;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n  SMILECOMPONENT_IFNOTREGAGAIN(\n//    ct->setField(\"nameAppend\", NULL, (const);\n    ct->setField(\"curve\",\"1 character, which specifies the type of the curve to use (supported: A ; soon supported: B,C) [NOT YET FULLY IMPLEMENTED, ONLY A is supported]\",'A');\n    ct->setField(\"usePower\",\"1 = square the input magnitudes before multiplying with the dX weighting function (the output will then be a dBX weighted power spectrum)\",1);\n  )\n  SMILECOMPONENT_MAKEINFO(cDbA);\n}\n\nSMILECOMPONENT_CREATE(cDbA)\n\n//-----\n\ncDbA::cDbA(const char *_name) :\n  cVectorProcessor(_name),\n  curve(0),\n  filterCoeffs(NULL)\n{\n\n}\n\nvoid cDbA::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n  \n  char c = getChar(\"curve\");\n  SMILE_DBG(2,\"curve = %c\",c);\n  if ((c=='A')||(c=='a')) curve = CURVE_DBA;\n  if ((c=='B')||(c=='b')) curve = CURVE_DBB;\n  if ((c=='C')||(c=='c')) curve = CURVE_DBC;\n\n  usePower = getInt(\"usePower\");\n  if (usePower) { SMILE_DBG(2,\"using power spectrum\"); }\n}\n\n/*\nint cDbA::myConfigureInstance()\n{\n  int ret=1;\n  ret *= cVectorProcessor::myConfigureInstance();\n  if (ret == 0) return 0;\n\n  return ret;\n}\n*/\n\n/*\nint cDbA::configureWriter(const sDmLevelConfig *c)\n{\n  if (c==NULL) return 0;\n  \n  // you must return 1, in order to indicate configure success (0 indicated failure)\n  return 1;\n}\n*/\n\nint cDbA::dataProcessorCustomFinalise()\n{\n  // allocate for multiple configurations..\n  if (filterCoeffs == NULL) filterCoeffs = (FLOAT_DMEM**)multiConfAlloc();\n  \n  return cVectorProcessor::dataProcessorCustomFinalise();\n}\n\nint cDbA::setupNamesForField(int i, const char*name, long nEl)\n{\n  if ((strstr(name,\"phase\") == NULL)&&(strstr(name,\"Phase\") == NULL)) {\n    const sDmLevelConfig *c = reader_->getLevelConfig();\n    computeFilters(nEl, c->frameSizeSec, getFconf(i));\n\n    return cVectorProcessor::setupNamesForField(i,name,nEl);\n  } else { return 0; }\n}\n\n\nvoid computeDBA(FLOAT_DMEM *x, long blocksize, FLOAT_DMEM F0)\n{\n  FLOAT_DMEM curF = 0.0;\n  FLOAT_DMEM tmp,cf2;\n  int i;\n  \n  for (i=0; i < blocksize; i++)\n  {\n    cf2 = (FLOAT_DMEM)pow(curF,(FLOAT_DMEM)2.0);\n    tmp = (FLOAT_DMEM)( pow(12200.0,2.0) * pow(cf2,(FLOAT_DMEM)2.0) ) /  ( (cf2+(FLOAT_DMEM)pow(20.6,2.0)) * (cf2+(FLOAT_DMEM)pow(12200.0,2.0))  );\n    tmp /=  (FLOAT_DMEM)( sqrt(cf2+pow(107.7,2.0)) * sqrt(cf2+pow(737.9,2.0)) );\n      //obj->db[i] = 10.0*log(ddummy) + 2.0;\n    *(x++) = (FLOAT_DMEM) pow (10.0,( (10.0*log(tmp) + 2.0) / 10.0));\n      //obj->db[i] = fdummy;\n    curF += F0;\n  }\n}\n\n// blocksize is size of fft block, _T is period of fft frames\n// sampling period is reconstructed by: _T/((blocksize-1)*2)\nint cDbA::computeFilters( long blocksize, double frameSizeSec, int idxc )\n{\n  FLOAT_DMEM *_filterCoeffs = filterCoeffs[idxc];\n  FLOAT_DMEM F0 = (FLOAT_DMEM)(1.0/frameSizeSec);\n\n  if (_filterCoeffs != NULL) { free(_filterCoeffs);   }\n  _filterCoeffs = (FLOAT_DMEM *)malloc(sizeof(FLOAT_DMEM) * blocksize);\n\n  // dbA::\n  computeDBA(_filterCoeffs, blocksize, F0);\n  // TODO::: support dbB, dbC, etc.\n\n  filterCoeffs[idxc] = _filterCoeffs;\n  return 1;\n}\n\n\n/*\nint cDbA::myFinaliseInstance()\n{\n  int ret;\n  ret = cVectorProcessor::myFinaliseInstance();\n  return ret;\n}\n*/\n\n// a derived class should override this method, in order to implement the actual processing\n/*\nint cDbA::processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  // do domething to data in *src, save result to *dst\n  // NOTE: *src and *dst may be the same...\n  \n  return 1;\n}\n*/\n\n// a derived class should override this method, in order to implement the actual processing\nint cDbA::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  int n;\n  FLOAT_DMEM *db = filterCoeffs[getFconf(idxi)];\n\n  // do the dbX filtering by multiplying with the filters and summing up\n  bzero(dst, Ndst*sizeof(FLOAT_DMEM));\n\n  // copy & square the fft magnitude\n  FLOAT_DMEM *_src;\n  if (usePower) {\n    _src = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*Nsrc);\n    if (src==NULL) OUT_OF_MEMORY;\n    for (n=0; n<Nsrc; n++) {\n      _src[n] = src[n]*src[n];\n    }\n    src = _src;\n  }\n\n  for (n=0; n<Ndst; n++) {\n    *(dst++) = *(src++) * *(db++);\n  }\n\n  if ((usePower)&&(_src!=NULL)) free((void *)_src);\n\n  return 1;\n}\n\ncDbA::~cDbA()\n{\n  multiConfFree(filterCoeffs);\n}\n\n"
  },
  {
    "path": "src/dsp/signalGenerator.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nSignal source. Generates various noise types and pre-defined signals.\n\n*/\n\n\n#include <dsp/signalGenerator.hpp>\n#define MODULE \"cSignalGenerator\"\n\nSMILECOMPONENT_STATICS(cSignalGenerator)\n\nSMILECOMPONENT_REGCOMP(cSignalGenerator)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CSIGNALGENERATOR;\n  sdescription = COMPONENT_DESCRIPTION_CSIGNALGENERATOR;\n\n  // we inherit cDataSource configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSource\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"nFields\",\"The number of fields in the output vector, set to -1 to use the size of the 'nElements' array or the 'fieldNames' array, if no nElements array is given.\",1);\n    ct->setField(\"nElements\",\"An array of number of values/elements for each field in the output vector (default is 1)\",1,ARRAY_TYPE);\n    ct->setField(\"fieldNames\",\"An array of names of fields in the output vector (default for all: noiseN, where N is the field number).\",(const char*)NULL,ARRAY_TYPE);\n    ct->setField(\"signalType\",\"The type of signal/noise to generate for ALL(!) output fields. If you want different types of signals for the individual fields, use multiple noise sources and combine the output vectors in a data reader.\\n Currently implemented noise and signal types are:\\n   'white' \\t white gaussian noise, use parameters 'stddev' and 'mean' to tune.\\n   'const' \\t constant value output, use 'constant' parameter to set this value.\\n   'sine' \\t single sine wave (range -1 to +1), see 'signalPeriod' or 'frequency' option and 'phase'.\\n   'rect' \\t rectangular periodic signal (range -1 to +1), see 'signalPeriod' or 'frequency' option and 'phase'.\",\"white\");\n    ct->setField(\"randSeed\",\"Random seed, for pseudo random gaussian white noise\",1.0);\n    //ct->setField(\"stddev\",\"Standard deviation for gaussian white noise [CURRENTLY NOT IMPLEMENTED]\",1.0);\n    //ct->setField(\"mean\",\"Mean value of the gaussian white noise [CURRENTLY NOT IMPLEMENTED]\",0.0);\n    ct->setField(\"scale\",\"A scaling factor by which the generated signal is multiplied by\",1.0);\n    ct->setField(\"const\",\"The constant value for the 'constant' signal type\",0.0);\n    ct->setField(\"signalPeriod\",\"The period T in seconds for periodic signals (1.0/frequency). Don't forget to set the sample period via writer.levelconf.T or the 'period' option. Don't confuse this option with the 'period' option!\",1.0,0,0);\n    ct->setField(\"frequency\",\"The frequency in Hz of periodic signals (1.0/signalPeriod). This overrides the 'signalPeriod' option, if both are set.\",1.0);\n    ct->setField(\"phase\",\"The initial phase of periodic signals in seconds.\",0.0);\n    ct->setField(\"length\",\"The length of the signal to generate (in seconds), -1.0 for infinite\",3.0);\n    ct->setField(\"lengthFrames\",\"The length of signal to generate (in frames), -1 for infinite (overwrites 'length', if set)\",-1,0,0);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cSignalGenerator);\n}\n\nSMILECOMPONENT_CREATE(cSignalGenerator)\n\n//-----\n\ncSignalGenerator::cSignalGenerator(const char *_name) :\n  cDataSource(_name),\n  nValues(0), nFields(0), noiseType(0), lengthFrames(-1),\n  fieldNames(NULL), nElements(NULL), samplePeriod(1.0), lastP(0.0), val(0.0), scale(1.0), myt(0), curT(0)\n{\n  // ...\n}\n\nvoid cSignalGenerator::fetchConfig()\n{\n  cDataSource::fetchConfig();\n  \n  nFields = getInt(\"nFields\");\n  SMILE_IDBG(2,\"nFields = %i\",nFields);\n\n  int nEl, nfN, minF=-1;\n  nEl = getArraySize(\"nElements\");\n  nfN = getArraySize(\"fieldNames\");\n\n  if (nFields > 0) { minF = nFields; }\n  \n  if (nEl > 0) {\n    if (minF < 0) { minF = nEl; }\n    if (nEl != minF) {\n      minF = MIN(nEl,minF);\n      SMILE_IWRN(2,\"nFields (%i) specified does not match size of nElements array (%i) ! Using minimum: nFields = %i.\",nFields,nEl,minF);\n    } \n  }\n  if (nfN > 0) {\n    if (minF < 0) { minF = nfN; }\n    if (nfN != nFields) {\n      minF = MIN(nfN,minF);\n      SMILE_IWRN(2,\"nFields (%i) specified does not match size of fieldNames array (%i) ! Using minimum: nFields = %i.\",nFields,nfN,minF);\n    }\n  }\n\n  if (minF <= 0) {\n    SMILE_IERR(1,\"The automatically determined number of fields is invalid: %i . [ nFields = %i ; # nElements = %i ; # fieldNames = %i ]\",minF,nFields,nEl,nfN);\n  } else {\n    // allocate arrays\n    nElements = (int*)malloc(sizeof(int)*minF);\n    fieldNames = (char**)calloc(1,sizeof(char*)*minF);\n\n    int i;\n    for (i=0; i<minF; i++) {\n      if (nEl > 0) {\n        nElements[i] = getInt_f(myvprint(\"nElements[%i]\",i));\n      } else {\n        nElements[i] = 1;\n      }\n      if (nfN > 0) {\n        fieldNames[i] = strdup(getStr_f(myvprint(\"fieldNames[%i]\",i)));\n      } else {\n        fieldNames[i] = myvprint(\"noise%i\",i);\n      }\n    }\n  }\n\n  nFields = minF;\n\n  // noise type:\n  const char * nt = getStr(\"signalType\");\n  if (nt != NULL) {\n    if ( (!strncasecmp(nt,\"white\",5)) || (!strncasecmp(nt,\"gauss\",5)) || (!strncasecmp(nt,\"static\",5)) ) {\n      noiseType = NOISE_WHITE;\n    } else\n    if ( (!strncasecmp(nt,\"sin\",3)) ) {\n      noiseType = SIGNAL_SINE;\n    } else\n    if ( (!strncasecmp(nt,\"rect\",4)) ) {\n      noiseType = SIGNAL_RECT;\n    } else\n    if ( (!strncasecmp(nt,\"const\",5)) ) {\n      noiseType = SIGNAL_CONST;\n    }\n  }\n\n  randSeed = getInt(\"randSeed\");\n  SMILE_IDBG(2,\"randSeed = %i\",randSeed);\n\n  stddev = (FLOAT_DMEM)getDouble(\"stddev\");\n  SMILE_IDBG(2,\"stddev = %f\",stddev);\n\n  mean = (FLOAT_DMEM)getDouble(\"mean\");\n  SMILE_IDBG(2,\"mean = %f\",mean);\n\n  scale = getDouble(\"scale\");\n  SMILE_IDBG(2,\"scale = %f\",scale);\n\n  constant = (FLOAT_DMEM)getDouble(\"const\");\n  SMILE_IDBG(2,\"const = %f\",constant);\n\n  signalPeriod = getDouble(\"signalPeriod\");\n  SMILE_IDBG(2,\"signalPeriod = %f\",signalPeriod);\n  \n  if (isSet(\"frequency\")) {\n    double frequency = getDouble(\"frequency\");\n    SMILE_IDBG(2,\"frequency = %f\",frequency);\n    if (frequency > 0.0) {\n      signalPeriod = 1.0/frequency;\n    } else {\n      SMILE_ERR(1,\"invalid value for the 'frequency' option (%f). Must be > 0. Setting signalPeriod = 0.\",frequency);\n      signalPeriod = 0.0;\n    }\n    SMILE_IDBG(2,\"signalPeriod = %f\",signalPeriod);\n  }\n\n  phase = getDouble(\"phase\");\n  SMILE_IDBG(2,\"phase = %f\",phase);\n  myt = phase;\n\n\n  if (isSet(\"lengthFrames\")) {\n    lengthFrames = getInt(\"lengthFrames\");\n  } else {\n    double _length = getDouble(\"length\");\n    if (_length < 0.0) lengthFrames = -1;\n    else {\n\n      if (period_ > 0.0) {\n        lengthFrames = (long)ceil( _length / period_ );\n      } else {\n        lengthFrames = (long)_length;\n      }\n    }\n  }\n}\n\n\nint cSignalGenerator::configureWriter(sDmLevelConfig &c)\n{\n  // configure your writer by setting values in &c\n  samplePeriod = c.T;\n\n  return 1;\n}\n\n// NOTE: nEl is always 0 for dataSources....\nint cSignalGenerator::setupNewNames(long nEl)\n{\n  int i;\n  nValues=0;\n//  samplePeriod = writer->getLevelT();\n\n  for (i=0; i<nFields; i++) {\n    writer_->addField(fieldNames[i],nElements[i]);\n    nValues += nElements[i];\n  }\n\n  // initialise random generator:\n  srand(randSeed); \n\n  allocVec(nValues);\n  return 1;\n}\n\n/*\nint cSignalGenerator::myFinaliseInstance()\n{\n  return cDataSource::myFinaliseInstance();\n}\n*/\n\n\n/* WHITE NOISE SHIFT REGISTER:\nfloat g_fScale = 2.0f / 0xffffffff;\nint g_x1 = 0x67452301;\nint g_x2 = 0xefcdab89;\n\nvoid whitenoise(\n  float* _fpDstBuffer, // Pointer to buffer\n  unsigned int _uiBufferSize, // Size of buffer\n  float _fLevel ) // Noiselevel (0.0 ... 1.0)\n{\n  _fLevel *= g_fScale;\n\n  while( _uiBufferSize-- )\n  {\n    g_x1 ^= g_x2;\n    *_fpDstBuffer++ = g_x2 * _fLevel;\n    g_x2 += g_x1;\n  }\n}\n\n\nGAUSSIAN:\n#define PI 3.1415926536f\n\nfloat R1 = (float) rand() / (float) RAND_MAX;\nfloat R2 = (float) rand() / (float) RAND_MAX;\n\nfloat X = (float) sqrt( -2.0f * log( R1 )) * cos( 2.0f * PI * R2 );\n\n\n\n*/\n\n\n#if 0 \nGAUSSIAN:\n/* Generate a new random seed from system time - do this once in your constructor */\nsrand(time(0));\n\n/* Setup constants */\nconst static int q = 15;\nconst static float c1 = (1 << q) - 1;\nconst static float c2 = ((int)(c1 / 3)) + 1;\nconst static float c3 = 1.f / c1;\n\n/* random number in range 0 - 1 not including 1 */\nfloat random = 0.f;\n\n/* the white noise */\nfloat noise = 0.f;\n\nfor (int i = 0; i < numSamples; i++)\n{\n    random = ((float)rand() / (float)(RAND_MAX + 1));\n    noise = (2.f * ((random * c2) + (random * c2) + (random * c2)) - 3.f * (c2 - 1.f)) * c3;\n}\n#endif\n\nint cSignalGenerator::myTick(long long t)\n{\n  SMILE_DBG(4,\"tick # %i, writing value vector\",t);\n\n  if ( (nValues > 0) && ( (curT < lengthFrames) || (lengthFrames == -1) ) && (writer_->checkWrite(1)) ) {\n    long i=0;\n    const static int q = 15;\n    const static float c1 = (1 << q) - 1;\n    const static float c2 = ((int)(c1 / 3)) + 1; // ignore compiler warning here?? or do typecast?\n    const static float c3 = 1.f / c1;\n    \n    FLOAT_DMEM v=0.0;\n    switch(noiseType) {\n      case NOISE_WHITE:\n        float random;\n        random = ((float)rand() / ((float)(RAND_MAX) + 1.0f));\n        v = (FLOAT_DMEM)scale * (FLOAT_DMEM)( (2.f * ((random * c2) + (random * c2) + (random * c2)) - 3.f * (c2 - 1.f)) * c3 );\n        for (i=0; i<nValues; i++) {\n          vec_->dataF[i] = v;\n        }\n        break;\n      case SIGNAL_CONST:\n        for (i=0; i<nValues; i++) {\n          vec_->dataF[i] = constant;\n        }\n        break;\n      case SIGNAL_RECT:\n        v = (FLOAT_DMEM)(val*scale);\n        for (i=0; i<nValues; i++) {\n          vec_->dataF[i] = v;\n        }\n        myt += samplePeriod;\n        if ((signalPeriod > 0.0) && (floor(myt/(signalPeriod*0.5)) > lastP)) {\n          if (val==1.0) val = -1.0;\n          else val = 1.0;\n        }\n        lastP = floor(myt/(signalPeriod*0.5));\n        break;\n      case SIGNAL_SINE:\n        val = sin(2.0*M_PI*(1.0/signalPeriod)*myt) ;\n        v = (FLOAT_DMEM)( val * scale ); \n        for (i=0; i<nValues; i++) {\n          vec_->dataF[i] = v;\n        }\n        myt += samplePeriod;\n        break;\n\n    // TODO: option for multiple additive sines (phase/frequency..)\n\n      default:\n        break;\n    }\n\n    writer_->setNextFrame(vec_);\n    curT++;\n\n    return 1;\n  } else {\n    return 0;\n  }\n}\n\n\ncSignalGenerator::~cSignalGenerator()\n{\n  if (nFields > 0) {\n    int i;\n    if (fieldNames != NULL) {\n      for (i=0; i<nFields; i++) {\n        if (fieldNames[i] != NULL) free(fieldNames[i]);\n      }\n      free(fieldNames);\n    }\n  }\n  if (nElements != NULL) {\n    free(nElements);      \n  }\n}\n"
  },
  {
    "path": "src/dsp/smileResample.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: resmapler\n\nresampling using fft and ideal sin/cos interpolation\n\n*/\n\n\n#include <dsp/smileResample.hpp>\n#include <dspcore/fftXg.h>\n\n#define MODULE \"cSmileResample\"\n\n\nSMILECOMPONENT_STATICS(cSmileResample)\n\nSMILECOMPONENT_REGCOMP(cSmileResample)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CSMILERESAMPLE;\n  sdescription = COMPONENT_DESCRIPTION_CSMILERESAMPLE;\n\n  // we inherit cWindowProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataProcessor\")\n\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"targetRate\",\"The target sampling frequency in Hz\",16000);  \n    ct->setField(\"resampleRatio\",\"A fixed resample ratio a (a=fsNew/fsCurrent). If set, this overrides targetFs\",1.0,0,0);\n    ct->setField(\"pitchRatio\",\"Low-quality pitch scaling factor, if != 1.0 \",1.0);\n    ct->setField(\"useQuickAlgo\",\"Use a quick algo for low-quality integer-ratio DOWN(!)sampling.\",0);\n    ct->setField(\"winSize\",\"Internal window size in seconds (will be rounded to nearest power of 2 framesize internally). This affects the quality of the resampling and the accuracy of the target sampling rate. Larger window sizes allow for a more accurate target sampling frequency, i.e. less pitch distortion.\",0.030);  \n    // NOTE: blocksize will be determined by winSize\n    //ct->setField(\"blocksize\", \"size of data blocks to process in frames\", 0);\n    ct->disableField(\"blocksize\");\n    ct->disableField(\"blocksizeR\");\n    ct->disableField(\"blocksizeW\");\n  )\n\n  SMILECOMPONENT_MAKEINFO(cSmileResample);\n}\n\nSMILECOMPONENT_CREATE(cSmileResample)\n\n//-----\n\ncSmileResample::cSmileResample(const char *_name) :\n  cDataProcessor(_name),   \n  inputBuf(NULL), outputBuf(NULL), lastOutputBuf(NULL),\n  resampleWork(NULL), rowout(NULL), matnew(NULL), row(NULL),\n  flushed(0)\n{\n}\n\n\nvoid cSmileResample::fetchConfig()\n{\n  cDataProcessor::fetchConfig();\n  \n   if (isSet(\"resampleRatio\")) {\n    resampleRatio = getDouble(\"resampleRatio\");\n    if (resampleRatio <= 0.0) {\n      SMILE_IERR(1,\"invalid resampling ratio (%f) ! must be > 0.0\",resampleRatio);\n      resampleRatio = 1.0;\n    }\n    SMILE_IDBG(2,\"resampleRatio = '%s'\",resampleRatio);\n  } else {\n    targetFs = getDouble(\"targetRate\");\n    if (targetFs <= 0.0) {\n      SMILE_IERR(1,\"invalid target sampling frequency (targetFs=%f) ! must be > 0.0\",targetFs);\n      targetFs = 1.0;\n    }\n    SMILE_IDBG(2,\"targetRate = '%s'\",targetFs);\n    resampleRatio = -1.0;\n  }\n\n pitchRatio = getDouble(\"pitchRatio\");\n SMILE_IDBG(2,\"pitchRatio = '%s'\",pitchRatio);\n\n winSize = getDouble(\"winSize\");\n SMILE_IDBG(2,\"winSize = '%s'\",winSize);\n\n useQuickAlgo = getInt(\"useQuickAlgo\");\n SMILE_IDBG(2,\"useQuickAlgo = %i\",useQuickAlgo);\n\n}\n\nint cSmileResample::configureWriter(sDmLevelConfig &c)\n{\n  double bT = c.T;\n  double sr;\n\n  if (bT > 0.0) sr = 1.0/bT;\n  else {\n    SMILE_IERR(1,\"unable to determine sample rate of input! basePeriod <= 0.0 (=%f)!\",bT);\n    sr = 1.0;\n  }\n\n  /* compute resampling parameters: */\n  if (resampleRatio == -1.0) { // convert targetFs\n    resampleRatio = targetFs/sr;\n    SMILE_IDBG(2,\"resampleRatio (computed) = %f\",resampleRatio);\n  } else {\n    // compute targetFs from resampling ratio\n    targetFs = resampleRatio * sr;\n  }\n\n  if (useQuickAlgo) {\n    if (resampleRatio > 1.0) {\n      COMP_ERR(\"cannot use quick resampling algo for upsampling!\");\n    }\n    double rr = 1.0/resampleRatio;\n    rr = round(rr); // round to nearest int...\n    resampleRatio = 1.0/rr;\n    SMILE_IDBG(2,\"resampleRatio (rounded) = %f\",resampleRatio);\n\n    //TODO: winSizeFrames must be a multiple of the integer resampleRatio !\n    winSizeFramesTarget = (long)ceil( (double)winSizeFrames * resampleRatio );\n    winSizeTarget = (double)winSizeFramesTarget * bT;\n\n  } else {\n\n\n    // convert winSize (sec) to winSizeFrames:\n    winSizeFrames = smileMath_ceilToNextPowOf2( (long)round(winSize/bT) );\n    winSizeFramesTarget = (long)ceil( (double)winSizeFrames * resampleRatio );\n    ND = (double)winSizeFrames * resampleRatio / pitchRatio;\n    if (winSizeFramesTarget&1) winSizeFramesTarget = (long)floor( (double)winSizeFrames * resampleRatio ); // odd->even!\n    if (winSizeFramesTarget&1) winSizeFramesTarget++;\n    winSize = (double)winSizeFrames * bT;\n    winSizeTarget = (double)winSizeFramesTarget * bT;\n    SMILE_IMSG(3,\"using actual frame size (pow 2): %i samples (%f seconds)\",winSizeFrames,winSize);\n    SMILE_IDBG(2,\"target frame size: %i samples (%f seconds)\",winSizeFramesTarget,winSizeTarget);\n    double newRatio = (double)winSizeFramesTarget / (double)winSizeFrames;\n    if (newRatio != resampleRatio) {\n      SMILE_IMSG(2,\"NOTE: actual output rate is targetRate* = %f (increase winSize for more accuracy!)\",sr*newRatio);\n    }\n\n  }\n\n  blocksizeR_ = winSizeFrames;\n  blocksizeR_sec_ = winSize;\n  if (useQuickAlgo) {\n    blocksizeW_ = winSizeFramesTarget;\n    blocksizeW_sec_ = winSizeTarget;\n  } else {\n    blocksizeW_ = winSizeFramesTarget/2;\n    blocksizeW_sec_ = winSizeTarget/2.0;\n  }\n\n  c.blocksizeWriter = blocksizeW_;\n  c.T = 1.0/targetFs;\n  if (useQuickAlgo) {\n    reader_->setupSequentialMatrixReading(winSizeFrames, winSizeFrames /* * pitchRatio */);\n  } else {\n    reader_->setupSequentialMatrixReading(winSizeFrames/2, winSizeFrames /* * pitchRatio */);\n  }\n\n  return 1;\n}\n\nint cSmileResample::dataProcessorCustomFinalise()\n{\n  double bT = reader_->getLevelT();\n  double sr;\n\n  if (bT > 0.0) sr = 1.0/bT;\n  else {\n    SMILE_IERR(1,\"unable to determine sample rate of input! basePeriod <= 0.0 (=%f)!\",bT);\n    sr = 1.0;\n  }\n\n  // allocate buffers:\n  Ni = reader_->getLevelN();\n  outputBuf = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*Ni*winSizeFramesTarget);\n  lastOutputBuf = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*Ni*(winSizeFramesTarget/2+1));\n  inputBuf = (FLOAT_TYPE_FFT*)calloc(1,sizeof(FLOAT_TYPE_FFT)*Ni*winSizeFrames);\n\n  return 1;\n}\n\n\n\nint cSmileResample::getOutput(FLOAT_DMEM *cur, FLOAT_DMEM *last, long N, FLOAT_DMEM *out, long Nout)\n{\n  long i;\n  for (i=0; i<Nout; i++) {\n    // the overlap add:\n    out[i] = ( cur[i]+last[i] );\n  }\n\n  // cur N/2..N -> last\n  for (i=N-Nout; i<N; i++) {\n    last[i-(N-Nout)] = cur[i];\n  }\n\n  return 1;\n}\n\nint cSmileResample::myTick(long long t)\n{\n  long i,j;\n\n  SMILE_IDBG(4,\"tick # %i, running resampler\",t);\n  //if ((isEOI())&&(noPostEOIprocessing)) return 0;\n  if ((isEOI())) {\n    if (!flushed) {\n    for (i=0; i<matnew->N; i++)  {\n      FLOAT_DMEM *outBuf = outputBuf+i*winSizeFramesTarget;\n      FLOAT_DMEM *lastOutBuf = lastOutputBuf + i*(winSizeFramesTarget/2+1);\n      FLOAT_TYPE_FFT *inBuf = inputBuf+i*winSizeFrames;\n      for (j=0; j<winSizeFramesTarget; j++) { outBuf[j]=0.0; }\n      getOutput(outBuf, lastOutBuf, winSizeFramesTarget, rowout->dataF, rowout->nT);\n      //rowout->dataF[0]= outBuf[0];\n      matnew->setRow(i,rowout);\n    }\n    writer_->setNextMatrix(matnew);\n    flushed = 1;\n    return 1;\n    } else { return 0; }\n  }\n\n  int ret = 1;\n  \n  if (!(writer_->checkWrite(blocksizeW_))) return 0;\n\n  // get next block from dataMemory\n  cMatrix *mat = reader_->getNextMatrix();\n  \n  // TODO: if blocksize< order!! also check if we need to increase the read counter!\n  if (mat != NULL) {\n    if (mat->type!=DMEM_FLOAT) COMP_ERR(\"dataType (%i) != DMEM_FLOAT not yet supported!\",mat->type);\n\n    // TODO: test quick resample algo here...!\n    if (useQuickAlgo) {\n\n      if (matnew == NULL) matnew = new cMatrix(mat->N, winSizeFramesTarget,DMEM_FLOAT);\n      //if (rowout == NULL) rowout = new cMatrix(1,winSizeFramesTarget/2, DMEM_FLOAT);\n      //if (row == NULL) row = new cMatrix(1,winSizeFrames, DMEM_FLOAT);\n      long i,j,n,r=0;\n      int rr = (int)(1.0/resampleRatio);\n      if (rr<1) rr=1;\n      for (i=0; i<mat->nT; i+=rr) {\n        for (j=0; j<mat->N; j++) {\n          FLOAT_DMEM *out = matnew->dataF + (r*matnew->N+j);\n          *out = 0;\n          for (n=0; n<rr; n++) {\n            *out += mat->dataF[(i+n)*mat->N+j];\n          }\n          *out /= rr;\n        }\n        r++;\n      }\n\n    } else {\n    \n    /*\n    if (row == NULL) row = new cMatrix(1,mat->nT, mat->type);\n*/\n    if (matnew == NULL) matnew = new cMatrix(mat->N, winSizeFramesTarget/2,DMEM_FLOAT);\n    if (rowout == NULL) rowout = new cMatrix(1,winSizeFramesTarget/2, DMEM_FLOAT);\n    if (row == NULL) row = new cMatrix(1,winSizeFrames, DMEM_FLOAT);\n\n    for (i=0; i<mat->N; i++)  {\n      FLOAT_DMEM *outBuf = outputBuf+i*winSizeFramesTarget;\n      FLOAT_DMEM *lastOutBuf = lastOutputBuf + i*(winSizeFramesTarget/2+1);\n      FLOAT_TYPE_FFT *inBuf = inputBuf+i*winSizeFrames/* *pitchRatio */;\n\n      // get matrix row...\n      cMatrix *rowr = mat->getRow(i,row);\n      if (rowr==NULL) COMP_ERR(\"cWindowProcessor::myTick : Error getting row %i from matrix! (return obj = NULL!)\",i);\n\n      for (j=0; j<rowr->nT; j++) {\n        inBuf[j] = (FLOAT_TYPE_FFT) rowr->dataF[j];\n      }\n      \n      smileDsp_doResample(inBuf, row->nT, outBuf, winSizeFramesTarget, ND, &resampleWork);\n      getOutput(outBuf, lastOutBuf, winSizeFramesTarget, rowout->dataF, rowout->nT);\n      //rowout->dataF[0]= outBuf[0];\n      matnew->setRow(i,rowout);\n    }\n    \n    // set next matrix...\n    //if (toSet==1)  {\n      \n    }\n      //matnew->tmetaReplace(mat->tmeta); \n    // TODO: tmeta adjust...\n      //mat->tmeta -= pre;\n    writer_->setNextMatrix(matnew);\n    //}\n  } else {\n//         printf(\"WINPROC '%s' mat==NULL tickNr=%i EOI=%i\\n\",getInstName(),t,isEOI());\n    return 0;\n  }\n\n//  isFirstFrame = 0;\n  \n  return ret;\n\n}\n\n\n\ncSmileResample::~cSmileResample()\n{\n  if (inputBuf != NULL) free(inputBuf);\n  if (outputBuf != NULL) free(outputBuf);\n  if (lastOutputBuf != NULL) free(lastOutputBuf);\n  if (row != NULL) delete row;\n  if (rowout != NULL) delete rowout;\n  if (matnew != NULL) delete matnew;\n  smileDsp_resampleWorkFree(resampleWork);\n}\n\n"
  },
  {
    "path": "src/dsp/specResample.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: resmapler\n\n\n*/\n\n// TODO: when upsampling we need a post lp filter (time domain) to remove hf artefacts\n\n\n#include <dsp/specResample.hpp>\n\n#define MODULE \"cSpecResample\"\n\n\nSMILECOMPONENT_STATICS(cSpecResample)\n\nSMILECOMPONENT_REGCOMP(cSpecResample)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CSPECRESAMPLE;\n  sdescription = COMPONENT_DESCRIPTION_CSPECRESAMPLE;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n\n  // if the inherited config type was found, we register our configuration variables\n  SMILECOMPONENT_IFNOTREGAGAIN( {} // <- this is only to avoid compiler warnings...\n    // name append has a special role: it is defined in cDataProcessor, and can be overwritten here:\n\t  // if you set description to NULL, the existing description will be used, thus the following call can\n  \t// be used to update the default value:\n    //ct->setField(\"nameAppend\",NULL,\"processed\");\n\n    ct->setField(\"targetFs\",\"The target sampling frequency in Hz\",16000);  \n    ct->setField(\"resampleRatio\",\"Specifies a fixed resample ratio a (a=fsNew/fsCurrent). If set, this overrides targetFs\",1.0,0,0);\n\n    ct->setField(\"inputFieldPartial\",\"The name of the input field to search for. (NULL (default): use full input vector)\",(const char*)NULL);\n    ct->setField(\"processArrayFields\",NULL,0); // TODO? support array field processing...\n  )\n\n  // The configType gets automatically registered with the config manger by the SMILECOMPONENT_IFNOTREGAGAIN macro\n  \n  // we now create out sComponentInfo, including name, description, success status, etc. and return that\n  SMILECOMPONENT_MAKEINFO(cSpecResample);\n}\n\nSMILECOMPONENT_CREATE(cSpecResample)\n\n//-----\n\ncSpecResample::cSpecResample(const char *_name) :\n  cVectorProcessor(_name),\n  inData(NULL),\n  resampleRatio(1.0),\n  inputFieldPartial(NULL),\n  antiAlias(1),\n  dftWork(NULL)\n  //costable(NULL),sintable(NULL)\n{\n\n}\n\nvoid cSpecResample::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n\n  if (isSet(\"resampleRatio\")) {\n    resampleRatio = getDouble(\"resampleRatio\");\n    if (resampleRatio <= 0.0) {\n      SMILE_IERR(1,\"invalid resampling ratio (%f) ! must be > 0.0\",resampleRatio);\n      resampleRatio = 1.0;\n    }\n    SMILE_IDBG(2,\"resampleRatio = '%s'\",resampleRatio);\n  } else {\n    targetFs = getDouble(\"targetFs\");\n    if (targetFs <= 0.0) {\n      SMILE_IERR(1,\"invalid target sampling frequency (targetFs=%f) ! must be > 0.0\",targetFs);\n      targetFs = 1.0;\n    }\n    SMILE_IDBG(2,\"targetFs = '%s'\",targetFs);\n    resampleRatio = -1.0;\n  }\n\n  inputFieldPartial = getStr(\"inputFieldPartial\");\n}\n\nint cSpecResample::configureWriter(sDmLevelConfig &c)\n{\n  if ((c.lastFrameSizeSec != c.basePeriod)&&(c.lastFrameSizeSec > 0.0))\n    c.frameSizeSec = c.lastFrameSizeSec;\n\n  double bT = (double)(c.basePeriod);\n  if (bT > 0.0) sr = 1.0/bT;\n  else {\n    SMILE_IERR(1,\"unable to determine sample rate of input! basePeriod <= 0.0 (=%f)!\",bT);\n    sr = 1.0;\n  }\n\n  /* compute resampling parameters: */\n  if (resampleRatio == -1.0) { // convert targetFs\n    resampleRatio = targetFs/sr;\n    SMILE_IDBG(2,\"resampleRatio (computed) = %f\",resampleRatio);\n  } else {\n    // compute targetFs from resampling ratio\n    targetFs = resampleRatio * sr;\n  }\n\n  c.basePeriod = 1.0/targetFs;\n  return 1;\n}\n\nint cSpecResample::setupNewNames(long nEl)\n{\n  const sDmLevelConfig *c = reader_->getLevelConfig();\n  fsSec = (double)(c->frameSizeSec);\n  double lastFsSec = (double)(c->lastFrameSizeSec);\n  double bT = (double)(c->basePeriod);\n  if (bT > 0.0) sr = 1.0/bT;\n  else {\n    SMILE_IERR(1,\"unable to determine sample rate of input! basePeriod <= 0.0 (=%f)!\",bT);\n    sr = 1.0;\n  }\n\n  if (inputFieldPartial != NULL) {\n    findInputField(inputFieldPartial, 0, nEl);\n  } else {\n    nInput_=nEl;\n    inputStart_ = 0;\n  }\n  _Nin = nInput_;\n\n  \n  // we must round the resampling ratio to the closest integer frame size for the target frames to avoid discontinuities\n  \n  // detect zero-padded fft input and adjust actual output\n  double nd;\n  if ((fsSec != lastFsSec)&&(lastFsSec != 0.0)&&(lastFsSec!=bT)) {\n    double _Nout0 = round((double)_Nin * resampleRatio * lastFsSec/fsSec);\n    double newRatio = _Nout0 / ((double)_Nin * (lastFsSec/fsSec));\n    _Nout = (long)_Nout0;\n    if (newRatio != resampleRatio) {\n      targetFs = sr*newRatio;\n      SMILE_IMSG(2,\"adjusting resampleRatio from %f to %f to match next integer frame size! (targetFs* = %f)\",resampleRatio,newRatio,targetFs);\n      resampleRatio = newRatio;\n    }\n    nd = (double)_Nin * resampleRatio;\n  } else {\n    double _Nout0 = round((double)_Nin * resampleRatio);\n    double newRatio = _Nout0 / (double)_Nin;\n    _Nout = (long)_Nout0;\n    if (newRatio != resampleRatio) {\n      targetFs = sr*newRatio;\n      SMILE_IMSG(2,\"adjusting resampleRatio from %f to %f to match next integer frame size! (targetFs* = %f)\",resampleRatio,newRatio,targetFs);\n      resampleRatio = newRatio;\n    }\n    nd = _Nout0;\n  }\n\n  dftWork = smileDsp_initIrdft(_Nin, _Nout, nd, antiAlias);\n  \n  //int n=0;\n  writer_->addField(\"resampled\",_Nout);\n  namesAreSet_ = 1;\n  return _Nout;\n}\n\n\n// a derived class should override this method, in order to implement the actual processing\nint cSpecResample::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  //long i,k;\n  // we assume we have complex fft as input...\n\n//  if (!getInputFieldData(src,Nsrc,&inData)) return 0;\n\n  smileDsp_irdft(src, dst, dftWork);\n  \n  return Ndst;\n}\n\ncSpecResample::~cSpecResample()\n{\n  if (inData != NULL) free(inData);\n  smileDsp_freeDftwork(dftWork);\n}\n\n"
  },
  {
    "path": "src/dsp/specScale.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nscaling of an FFT magnitude spectrum to non-linear axis:\n * log (OK)\n * bark (TODO)\n * semi-tone (=log2) (OK)\n * mel (TODO)\n * ... (TODO)\n\n*/\n\n\n\n#include <dsp/specScale.hpp>\n#include <smileutil/smileUtilSpline.h>\n\n#define MODULE \"cSpecScale\"\n\nSMILECOMPONENT_STATICS(cSpecScale)\n\nSMILECOMPONENT_REGCOMP(cSpecScale)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CSPECSCALE;\n  sdescription = COMPONENT_DESCRIPTION_CSPECSCALE;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n\n  // if the inherited config type was found, we register our configuration variables\n  SMILECOMPONENT_IFNOTREGAGAIN( {} // <- this is only to avoid compiler warnings...\n    // name append has a special role: it is defined in cDataProcessor, and can be overwritten here:\n\t  // if you set description to NULL, the existing description will be used, thus the following call can\n  \t// be used to update the default value:\n    //ct->setField(\"nameAppend\",NULL,\"processed\");\n    ct->setField(\"scale\",\"The target scale, one of the following:\\n   'log(arithmic)' (logarithmic, see 'logScaleBase')\\n   'oct(ave)' (octave scale = logarithmic with base 2)\\n   'sem(itone)' (musical semi-tone scale)\\n   'lin(ear)' (linear scale)\\n   'bar(k)' (bark scale)\\n   'bao' (old - pre 2.0 - approximation of bark scale)\\n   'mel' (mel frequency scale)\", \"log\");\n    ct->setField(\"sourceScale\",\"The source scale (currently only 'lin(ear)' is supported, all other options (as found for target scale) are experimental)\", \"lin\");\n\n    ct->setField(\"logScaleBase\",\"The base for log scales (a log base of 2.0 - the default - corresponds to an octave target scale)\", 2.0);  \n    ct->setField(\"logSourceScaleBase\",\"The base for log source scales (a log base of 2.0 - the default - corresponds to an octave target scale)\", 2.0);  \n    ct->setField(\"firstNote\",\"The first note (in Hz) for a semi-tone scale\", 55.0);  \n\n    ct->setField(\"interpMethod\",\"The interpolation method for rescaled spectra: 'none', 'spline'\", \"spline\");  \n\n    ct->setField(\"minF\",\"The minimum frequency of the target scale\", 25.0);  \n    ct->setField(\"maxF\",\"The maximum frequency of the target scale (-1.0 : set to maximum frequency of the source spectrum)\", -1.0);\n    ct->setField(\"nPointsTarget\",\"The number of frequency points in target spectrum (<= 0 : same as input spectrum)\", 0);\n\n    ct->setField(\"specSmooth\",\"1 = perform spectral smoothing before applying the scale transformation\",0);\n    ct->setField(\"specEnhance\",\"1 = do spectral peak enhancement before applying smoothing (if enabled) and scale transformation\",0);\n\n    //ct->setField(\"psymodel\",\">0 : if target scale == bark, perform masking analysis and global loudness compensation and subtract combined masking threshold from spectrum (if set to 1, output spectrum floored to masking levels, where signal is below masking thresholds, if set to 2, outputs spectrum with masking levels subtracted, i.e. the perceptual spectrum)\",0);\n\n    ct->setField(\"auditoryWeighting\",\"1 = enable post-scale auditory weighting (this is currently only supported for octave (log2) scales)\",0);\n/*\n * TODO: support auditory weighting for arbitrary scales, but esp. for the bark scale (copy from plp component...?)\n *\n * aud. weighting: Terhardt 1997\n * Tq(flin) = 3.64*pow( (f/1000.0), -0.8 ) - 6.5 exp(-0.6*pow( (f/1000.0) - 3.3 ,2)) + 0.001*pow(f/1000.0 , 4);  // dB SPL\n *\n * TODO: support for masking analysis in the linear (input) domain or bark output domain\n *\n */\n\n  \tct->setField(\"processArrayFields\",NULL,0);\n  )\n\n  // The configType gets automatically registered with the config manger by the SMILECOMPONENT_IFNOTREGAGAIN macro\n  \n  // we now create out sComponentInfo, including name, description, success status, etc. and return that\n  SMILECOMPONENT_MAKEINFO(cSpecScale);\n}\n\nSMILECOMPONENT_CREATE(cSpecScale)\n\n//-----\n\ncSpecScale::cSpecScale(const char *_name) :\n  cVectorProcessor(_name),\n    fsSec(-1.0), magStart(0), nMag(0), \n    f_t(NULL), spline_work(NULL), \n    y(NULL), y2(NULL), audw(NULL)\n{\n\n}\n\nvoid cSpecScale::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n  \n  \n  const char *scaleStr = getStr(\"scale\");\n  SMILE_IDBG(2,\"scale = '%s'\",scaleStr);\n  if (!strncasecmp(scaleStr,\"log\",3)) {\n    scale = SPECTSCALE_LOG;\n    logScaleBase = getDouble(\"logScaleBase\");\n    if ((logScaleBase <= 0.0)||(logScaleBase==1.0)) {\n      SMILE_IERR(1,\"logScaleBase must be > 0.0 and != 1.0 ! You have set it to: %f (I will set it to 2.0 now, but you are advised to correct your configuration!)\",logScaleBase);\n      logScaleBase = 2.0;\n    }\n  } else if (!strncasecmp(scaleStr,\"oct\",3)) {\n    scale = SPECTSCALE_LOG;\n    logScaleBase = 2.0;\n  } else if (!strncasecmp(scaleStr,\"sem\",3)) {\n    scale = SPECTSCALE_SEMITONE;\n    firstNote = getDouble(\"firstNote\");\n  } else if (!strncasecmp(scaleStr,\"lin\",3)) {\n    scale = SPECTSCALE_LINEAR;\n  } else if (!strncasecmp(scaleStr,\"bar\",3)) {\n      scale = SPECTSCALE_BARK;\n  } else if (!strncasecmp(scaleStr,\"bao\",3)) {\n      scale = SPECTSCALE_BARK_OLD;\n  } else if (!strncasecmp(scaleStr,\"mel\",3)) {\n     scale = SPECTSCALE_MEL;\n  } else {\n    SMILE_IERR(1,\"unknown target scale type scale='%s' , please check your config!\",scaleStr);\n    COMP_ERR(\"aborting\");\n  }\n\n  scaleStr = getStr(\"sourceScale\");\n  SMILE_IDBG(2,\"sourceScale = '%s'\",scaleStr);\n  if (!strncasecmp(scaleStr,\"log\",3)) {\n    sourceScale = SPECTSCALE_LOG;\n    logSourceScaleBase = getDouble(\"logSourceScaleBase\");\n    if ((logSourceScaleBase <= 0.0)||(logSourceScaleBase==1.0)) {\n      SMILE_IERR(1,\"logSourceScaleBase must be > 0.0 and != 1.0 ! You have set it to: %f (I will set it to 2.0 now, but you are advised to correct your configuration!)\",logSourceScaleBase);\n      logScaleBase = 2.0;\n    }\n  } else if (!strncasecmp(scaleStr,\"oct\",3)) {\n    sourceScale = SPECTSCALE_LOG;\n    logSourceScaleBase = 2.0;\n  } else if (!strncasecmp(scaleStr,\"lin\",3)) {\n    sourceScale = SPECTSCALE_LINEAR;\n  } else if (!strncasecmp(scaleStr,\"bar\",3)) {\n      sourceScale = SPECTSCALE_BARK;\n  } else if (!strncasecmp(scaleStr,\"mel\",3)) {\n      sourceScale = SPECTSCALE_MEL;\n  } else {\n    SMILE_IERR(1,\"unknown source scale type scale='%s' , please check your config!\",scaleStr);\n    COMP_ERR(\"aborting\");\n  }\n\n  if (scale == SPECTSCALE_LOG) {\n    SMILE_IDBG(2,\"logScaleBase = %i\",logScaleBase);\n  }\n  if (sourceScale == SPECTSCALE_LOG) {\n    SMILE_IDBG(2,\"logSourceScaleBase = %i\",logSourceScaleBase);\n  }\n\n  specEnhance = getInt(\"specEnhance\");\n  SMILE_IDBG(2,\"specEnhance = %i\",specEnhance);\n\n  specSmooth = getInt(\"specSmooth\");\n  SMILE_IDBG(2,\"specSmooth = %i\",specSmooth);\n\n  auditoryWeighting = getInt(\"auditoryWeighting\");\n  if (auditoryWeighting) {\n    if (!((scale==SPECTSCALE_LOG)&&(logScaleBase==2.0))) {\n      auditoryWeighting = 0;\n      SMILE_IWRN(1,\"auditory weighting is currently only supported for octave target scales (log 2)! Disabling auditory weighting.\");\n    }\n  }\n  SMILE_IDBG(2,\"auditoryWeighting = %i\",auditoryWeighting);\n\n  minF = getDouble(\"minF\");\n  if (minF < 1.0) {\n    minF = 1.0;\n    SMILE_IERR(1,\"minF (%f) must be >= 1.0\",minF);\n  }\n  SMILE_IDBG(2,\"minF = %i\",minF);\n  maxF = getDouble(\"maxF\");\n  SMILE_IDBG(2,\"maxF = %i\",maxF);\n  nPointsTarget = getInt(\"nPointsTarget\");\n  SMILE_IDBG(2,\"nPointsTarget = %i\",nPointsTarget);\n\n  if (scale == SPECTSCALE_LOG) param = logScaleBase;\n  else if (scale == SPECTSCALE_SEMITONE) param = firstNote;\n  else param = 0.0;\n}\n\nint cSpecScale::setupNewNames(long nEl)\n{\n  if (fsSec == -1.0) {\n    const sDmLevelConfig *c = reader_->getLevelConfig();\n    fsSec = (float)(c->frameSizeSec);\n  }\n\n  const FrameMetaInfo * fmeta = reader_->getFrameMetaInfo();\n  int ri=0;\n  const char *base;\n  long idx = fmeta->findFieldByPartialName( \"Mag\" , &ri );\n  if (idx < 0) {\n    nMag = nEl;\n    magStart = 0;\n    base=NULL;\n    SMILE_IWRN(2,\"FFT magnitude field '*Mag*' not found, defaulting to use full input vector!\");\n  } else {\n    magStart = ri;\n    nMag = fmeta->field[idx].N;\n    base = fmeta->field[idx].name;\n  }\n\n  if (nMag+magStart > nEl) nMag = nEl-magStart;\n  if (magStart < 0) magStart = 0;\n\n  deltaF = 1.0/fsSec;\n  if (nPointsTarget <= 0) {\n    nPointsTarget = nMag;\n  }\n\n  int n=0;\n  const char *scaleStr = getStr(\"scale\");\n  char *name;\n  if (scaleStr!=NULL) {\n    name = myvprint(\"%s_%c%c%cScale\",base,scaleStr[0],scaleStr[1],scaleStr[2]);\n  } else {\n    name = myvprint(\"%s_scaledSpectrum\",base);\n  }\n  writer_->addField( name, nPointsTarget ); n+=nPointsTarget;\n  free(name);\n\n  /* source scale frequency labels -> target scale frequency labels*/\n  // todo: check info type!!\n  if (fmeta->field[idx].dataType >= DATATYPE_SPECTRUM_BINS_FIRST && fmeta->field[idx].dataType <= DATATYPE_SPECTRUM_BINS_LAST) {\n    double * _buf = (double *)malloc(fmeta->field[idx].infoSize);\n    double * in = (double *)( fmeta->field[idx].info );\n    long i;\n    for (i=0; i<fmeta->field[idx].infoSize/(long)sizeof(double); i++) {\n      _buf[i] = smileDsp_specScaleTransfFwd(in[i],scale,param);\n    }\n    writer_->setFieldInfo(-1 /* last field added */,fmeta->field[idx].dataType,_buf,fmeta->field[idx].infoSize);\n  } else {\n    SMILE_IWRN(2,\"The data type of the input field is not of type DATATYPE_SPECTRUM_BINS_* , spectral power/magnitude bins are required as input to this component! Please check your config!\");\n  }\n\n  namesAreSet_ = 1;\n  return n;\n}\n\nint cSpecScale::dataProcessorCustomFinalise()\n{\n  int i;\n  int ret = cVectorProcessor::dataProcessorCustomFinalise();\n  if (!ret) return ret;\n\n  // check maxF < sampleFreq.\n  double samplF = deltaF * (double)nMag; // sampling frequency\n  if ((maxF <= minF)||(maxF > samplF)) {\n    maxF = samplF; \n  }\n  \n  // transform from source to target scale:\n\n  fmin_t = smileDsp_specScaleTransfFwd(minF,scale,param); \n  fmax_t = smileDsp_specScaleTransfFwd(maxF,scale,param);\n\n  // target delta f\n  deltaF_t = (fmax_t - fmin_t) / (nPointsTarget - 1);\n\n  // calculate the target frequencies of the linear scale fft input points\n  if (f_t == NULL) f_t = (double*)malloc(sizeof(double)*nMag);\n\n  if (scale == SPECTSCALE_LOG) {\n    for (i=1; i < nMag; i++) {\n      f_t[i] = smileDsp_specScaleTransfFwd( (double)i * (double)deltaF , scale, param );\n    }\n    f_t[0] = 2.0 * f_t[1] - f_t[2]; // heuristic for the 0th frequency (only valid for log2 ??)\n  } else { // generic transform:\n    for (i=0; i < nMag; i++) {\n      f_t[i] = smileDsp_specScaleTransfFwd( (double)i * (double)deltaF , scale, param );\n    }\n  }\n\n  \n  double nOctaves = log(maxF / minF)/log(2.0);\n  double nPointsPerOctave = nPointsTarget / nOctaves; // this is valid for log(2.0) scale only...\n  if (auditoryWeighting) {\n    /* auditory weighting function (octave scale only...)*/\n    double atan_s = nPointsPerOctave * smileMath_log2(65.0 / 50.0) - 1.0;\n    audw = (double*)malloc(sizeof(double)*nPointsTarget);\n    for (i=0; i < nPointsTarget; i++) {\n      audw[i] = 0.5 + atan (3.0 * (i + 1 - atan_s) / nPointsPerOctave) / M_PI;\n    }\n  }\n\n  cVectorMeta *mdata = writer_->getLevelMetaDataPtr();\n  if (mdata != NULL) {\n    //TODO: mdata ID!\n    mdata->ID = 1001; /* SCALED_SPEC */;\n    mdata->fData[0] = (FLOAT_DMEM)minF; /* min frequency (source) */\n    mdata->fData[1] = (FLOAT_DMEM)maxF; /* max frequency (source) */\n    mdata->fData[2] = (FLOAT_DMEM)nOctaves; /* number of octaves (log/octave scales only) */\n    mdata->fData[3] = (FLOAT_DMEM)nPointsPerOctave; /* points per octave, valid only for log(2) scale! */\n    mdata->fData[4] = (FLOAT_DMEM)fmin_t; /* min frequency (target) */\n    mdata->fData[5] = (FLOAT_DMEM)fmax_t; /* max frequency (target) */\n    mdata->fData[6] = (FLOAT_DMEM)scale; /* constant indicating the type of target scale */\n    mdata->fData[7] = (FLOAT_DMEM)param; /* target scale param (if applicable) */\n  }\n  return ret;\n}\n\n\n\n// a derived class should override this method, in order to implement the actual processing\nint cSpecScale::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  // we assume we have fft magnitude as input...\n  double _N = (double)(Nsrc);  \n  int i;\n  if (nMag < 0) return 0;\n  \n  // allocate workspace arrays\n  if (y == NULL) y = (double *)malloc(sizeof(double)*nMag);\n  if (y2 == NULL) y2 = (double *)malloc(sizeof(double)*nMag);\n\n  // copy and (possibly) convert input data\n  for (i=magStart; i<magStart+nMag; i++) {\n    y[i-magStart] = (double)src[i];\n  }\n\n  // do spectral peak enhancement, if enabled\n  if (specEnhance) smileDsp_specEnhanceSHS(y,nMag);\n  \n  // do spectral smoothing, if enabled\n  if (specSmooth) smileDsp_specSmoothSHS(y,nMag);\n\n  // scale to the target scale and interpolate missing values via spline interpolation\n  if ( smileMath_spline( f_t, y, nMag, 1e30, 1e30, y2, &spline_work ) ) {\n    // after successful spline computation, do the actual interpolation point by point\n    for (i=0; i < nPointsTarget; i++) {\n      double f = fmin_t + (double)i * deltaF_t;\n      double out;\n      smileMath_splint( f_t, y, y2, nMag, f, &out);\n      dst[i] = (FLOAT_DMEM)out; // save in output vector\n    }\n  } else {\n    SMILE_IERR(3,\"spline computation failed on current frame, zeroing the output (?!)\");\n    // zero output\n    for (i=0; i < nPointsTarget; i++) {\n      dst[i] = 0.0;\n    }\n  }\n\n\n  // multiply by frequency selectivity of the auditory system (octave-scale only)\n  if (auditoryWeighting) {\n    for (i=0; i < nPointsTarget; i++) {\n      if (dst[i] > 0.0) {\n        dst[i] = (FLOAT_DMEM)( (double)dst[i] * audw[i] );\n      } else {\n        dst[i] = 0.0;\n      }\n    }\n  }\n\n  return nPointsTarget;\n}\n\ncSpecScale::~cSpecScale()\n{\n  if (y != NULL) free(y);\n  if (y2 != NULL) free(y2);\n\n  if (audw != NULL) free(audw);\n  if (spline_work != NULL) free(spline_work);\n  if (f_t != NULL) free(f_t);\n}\n\n"
  },
  {
    "path": "src/dsp/vadV1.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nrule based voice activity detector\n\n*/\n\n\n#include <dsp/vadV1.hpp>\n\n#define MODULE \"cVadV1\"\n\n// default values (can be changed via config file...)\n#define N_PRE  10\n#define N_POST 20\n\nSMILECOMPONENT_STATICS(cVadV1)\n\nSMILECOMPONENT_REGCOMP(cVadV1)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CVADV1;\n  sdescription = COMPONENT_DESCRIPTION_CVADV1;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataProcessor\")\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"threshold\",\"The minimum rms/log energy threshold to use (or the actual rms energy threshold, if disableDynamicVAD==1)\",-13.0); // 0.0005\n    ct->setField(\"disableDynamicVAD\",\"1/0 = yes/no, whether dynamic VAD is disabled (default is enabled)\",0);\n    ct->setField(\"debug\",\"1/0 enable/disable vad debug output\",0);\n  )\n  SMILECOMPONENT_MAKEINFO(cVadV1);\n}\n\nSMILECOMPONENT_CREATE(cVadV1)\n\n//-----\n\ncVadV1::cVadV1(const char *_name) :\n  cDataProcessor(_name),\n  turnState(0), actState(0),\n  useRMS(1),\n  threshold(0.0),\n  nPost(N_POST),\n  nPre(N_PRE),\n  cnt1(0), cnt2(0),\n  startP(0),\n  recFramer(NULL),\n  recComp(NULL),\n  statusRecp(NULL),\n  disableDynamicVAD(0),\n  spec(NULL), div0(0.0),\n  t0histIdx(0),\n  f0v_0(0.0), ent_0(0.0), E_0(0.0),\n  nInit(0),\n  uF0v(0.0), uEnt(0.0), uE(0.0),\n  vF0v(0.0), vEnt(0.0), vE(0.0),\n  tuF0v(0.0), tuEnt(0.0), tuE(0.0),\n  tvF0v(0.0), tvEnt(0.0), tvE(0.0),\n  vadFuzHidx(0), vadBin(0),\n  F0vHidx(0), entHidx(0), EHidx(0),\n  tF0vHidx(0), tentHidx(0), tEHidx(0),\n  nInitT(0), nInitN(0)\n{\n  t0hist[0] = 0.0;\n  t0hist[1] = 0.0;\n  t0hist[2] = 0.0;\n  t0hist[3] = 0.0;\n  \n  ar1 = (FLOAT_DMEM)( 1.0 - exp(-10.0/20.0) ); // THIS DEPENDS ON THE INPUT FRAME RATE.. ASSUMING 10ms HERE!\n  ar0 = (FLOAT_DMEM)( 1.0 - exp(-10.0/200.0) ); // THIS DEPENDS ON THE INPUT FRAME RATE.. ASSUMING 10ms HERE!\n\n  arU = (FLOAT_DMEM)0.005; //(FLOAT_DMEM)( 1.0 - exp(-10.0/100.0) ); // THIS DEPENDS ON THE INPUT FRAME RATE.. ASSUMING 10ms HERE!\n  arV = (FLOAT_DMEM)0.005; //(FLOAT_DMEM)( 1.0 - exp(-10.0/500.0) ); // THIS DEPENDS ON THE INPUT FRAME RATE.. ASSUMING 10ms HERE!\n  \n  int i;\n  for (i=0; i<FUZBUF; i++) {\n    vadFuzH[i] = 0.0;\n  }\n  for(i=0; i<FTBUF; i++) {\n    F0vH[i] = 0;\n    entH[i] = 0;\n    EH[i] = 0;\n  }\n}\n\nvoid cVadV1::fetchConfig()\n{\n  cDataProcessor::fetchConfig();\n  \n/*  nPre = getInt(\"nPre\");\n  SMILE_IDBG(2,\"nPre = %i\",nPre);\n\n  nPost = getInt(\"nPost\");\n  SMILE_IDBG(2,\"nPost = %i\",nPost);\n*/\n  debug = getInt(\"debug\");\n  disableDynamicVAD = getInt(\"disableDynamicVAD\");\n\n  minE = (FLOAT_DMEM)getDouble(\"threshold\");\n}\n\nint cVadV1::setupNewNames(long nEl)\n{\n  findInputMapping();\n\n  writer_->addField( \"vadBin\" );\n  writer_->addField( \"vadFuz\" );\n  writer_->addField( \"vadSmo\" );\n  namesAreSet_ = 1;\n\n  return 1;\n}\n\nvoid cVadV1::findInputMapping()\n{\n  const FrameMetaInfo * fmeta = reader_->getFrameMetaInfo();\n\n  long specField = fmeta->findFieldByPartialName( \"lspFreq\" );\n\n  if (specField < 0) { specField = 0; } // default : fallbak to 0th field\n\n  if (specField >= 0) {\n    specIdx = fmeta->fieldToElementIdx( specField );\n    if (specIdx >= 0) {\n      specN = fmeta->field[specField].N;\n    } else { specN = 0; }\n  } else {\n    specIdx = -1; specN = 0;\n  }\n  lsfN = fmeta->field[0].N;\n  \n  F0rawIdx = fmeta->fieldToElementIdx( fmeta->findFieldByPartialName( \"F0raw\" ) );\n  voiceProbIdx = fmeta->fieldToElementIdx( fmeta->findFieldByPartialName( \"voiceProb\" ) );\n  eIdx = fmeta->fieldToElementIdx( fmeta->findFieldByPartialName( \"LOG\" ) );\n\n  spec = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*(specN));\n  int i;\n  for(i=0; i<specN; i++) {\n    spec[i] = ( (FLOAT_DMEM)i * ((FLOAT_DMEM)3.0/(FLOAT_DMEM)specN) + (FLOAT_DMEM)0.2 ); \n  }\n}\n\n\nFLOAT_DMEM cVadV1::pitchVariance(FLOAT_DMEM curF0raw)\n{\n  // convert to period in seconds:\n  FLOAT_DMEM Tp=curF0raw;\n  //if (curF0raw != 0.0) Tp = 1.0/curF0raw;\n\n  // add new value to history:\n  t0hist[t0histIdx++] = Tp;\n  if (t0histIdx >= 8) t0histIdx = 0;\n\n  // mean over 8 frames:\n  FLOAT_DMEM m = (FLOAT_DMEM)0.125 * (t0hist[0]+t0hist[1]+t0hist[2]+t0hist[3]+t0hist[4]+t0hist[5]+t0hist[6]+t0hist[7]);\n  //FLOAT_DMEM m = 0.125 * (t0hist[0]+t0hist[1]+t0hist[2]+t0hist[3]);\n\n  int i;\n  FLOAT_DMEM v = (FLOAT_DMEM)0.0;\n  for (i=0; i<8; i++) {\n    v += (t0hist[i] - m) * (t0hist[i] - m);\n  }\n\n  return (FLOAT_DMEM)sqrt((double)v/8.0);\n}\n\n// a derived class should override this method, in order to implement the actual processing\nint cVadV1::myTick(long long t)\n{\n  // get next frame from dataMemory\n  //printf(\"tick\");\n  cVector *vec = reader_->getNextFrame();\n  if (vec == NULL) return 0;\n  //printf(\" OK \\n\");\n\n  cVector *vec0 = new cVector(3);  // TODO: move vec0 to class...\n  \n  FLOAT_DMEM *src = vec->dataF;\n  FLOAT_DMEM *dst = vec0->dataF;\n\n\n/*\n// get LSF difference vector:\n  if (lsfIdx>=0) {\n    int j=0, i;\n    for(i=lsfIdx; i<lsfIdx+lsfN-1; i++) {\n      //lsf[j] = src[i+1]-src[i];\n      lsf[j] = src[i];\n      printf(\"lsf[%i] %f \\n\",j,lsf[j]);\n      j++;\n    }\n    //lsf[j] = 3.15 - src[i];\n    lsf[j] = src[i];\n    printf(\"lsf[%i] %f \\n\",j,lsf[j]);\n  } else { printf(\"no lsf!\\n\"); }\n*/\n  //printf(\"sepcidx %i specN %i\\n\",specIdx,specN);\n  int j=0; int i;\n\n  // get energy\n  FLOAT_DMEM E = 0.0;\n  if (eIdx >= 0) {\n    E = src[eIdx];\n  }\n  // check if disableDynamicVAD is set\n  if (disableDynamicVAD) {\n    if (E > threshold) {\n      dst[0] = 1.0;\n      dst[1] = 1.0;\n      dst[2] = 1.0;\n    } else {\n      dst[0] = 0.0;\n      dst[1] = 0.0;\n      dst[2] = 0.0;\n    }\n\n    // save to dataMemory\n    writer_->setNextFrame(vec0);\n    delete vec0;\n\n    return 1;\n  }\n\n  // compute LSP diversion\n  FLOAT_DMEM div = 0.0;\n  for(i=0; i<specN; i++) {\n    //FLOAT_DMEM x = ( (FLOAT_DMEM)i * (3.0/(FLOAT_DMEM)specN) + 0.14 ) - spec[i]; \n    FLOAT_DMEM x = spec[i] - src[i+specIdx]; \n    div += x*x;\n  }\n  //printf (\"LSF div: %f\\n\",div);\n  //div /= specN;\n  //div = sqrt(div);\n  //printf (\"LSF div: %f\\n\",div);\n\n  // compute spectral entropy:\n  FLOAT_DMEM ent = smileStat_entropy(src,lsfN);\n\n  // compute pitch variance\n  FLOAT_DMEM f0v=0.0;\n // if (F0rawIdx >= 0) {\n    //printf(\"f0raw %f [%i]\\n\",src[F0rawIdx],F0rawIdx);\n //   f0v = pitchVariance(src[F0rawIdx]);\n // }\n  f0v=div;\n\n  FLOAT_DMEM f0prob=0.0;\n  if (voiceProbIdx >= 0) {\n    //printf(\"f0raw %f [%i]\\n\",src[F0rawIdx],F0rawIdx);\n    f0prob = src[voiceProbIdx];\n  }\n\n\n\n  // now smooth the 3 contours\n  if (ent > ent_0) {\n    ent = ar0 * (ent - ent_0) + ent_0;\n  } else {\n    ent = ar1 * (ent - ent_0) + ent_0;\n  }\n\n  if (f0v > f0v_0) {\n    f0v = ar0 * (f0v - f0v_0) + f0v_0;  //f0v = ar * f0v + (1.0-ar) f0v_0;\n  } else {\n    f0v = ar1 * (f0v - f0v_0) + f0v_0;  //f0v = ar * f0v + (1.0-ar) f0v_0;\n  }\n\n  if (E < E_0) {\n    E = ar0 * (E - E_0) + E_0;\n  } else {\n    E = ar1 * (E - E_0) + E_0;\n  }\n\n  ent_0 = ent;\n  f0v_0 = f0v;\n  E_0 = E;\n\n  //int vadBin = 0;\n  FLOAT_DMEM vadFuz=0.0;\n  FLOAT_DMEM vadSmo=0.0;\n\n  if ((nInit < NINIT)) { // prepare initial thresholds\n    if (nInit > 10) {\n    uF0v += f0v;\n    uEnt += ent;\n    uE   += E;\n    \n    F0vH[F0vHidx++] = f0v;\n    entH[entHidx++] = ent;\n    EH[EHidx++] = E;\n    }\n    nInit ++; \n    vadBin=0;\n  } else {\n    if (nInit == NINIT) { // compute inital thresholds\n      FLOAT_DMEM nn = ((FLOAT_DMEM)nInit) - (FLOAT_DMEM)10.0;\n\n      // means\n      uF0v /= nn;\n      uEnt /= nn;\n      uE   /= nn;\n\n      // standard deviations:\n      int i;\n      for (i=0; i<nInit-10; i++) {\n        vF0v += (F0vH[i] - uF0v) * (F0vH[i] - uF0v);\n        vEnt += (entH[i] - uEnt) * (entH[i] - uEnt);\n        vE   += (EH[i] - uE)     * (EH[i] - uE);\n      }\n      vF0v /= nn;\n      vF0v = sqrt(vF0v);\n\n      vEnt /= nn;\n      vEnt = sqrt(vEnt);\n\n      vE /= nn;\n      vE = sqrt(vE);\n      nInitN = nInit;\n    }\n    \n    // compute thresholds\n    FLOAT_DMEM th1ent = uEnt;\n    FLOAT_DMEM th1e = uE;\n    //FLOAT_DMEM th1f0v = 1.0/72.0 * vF0v;\n    FLOAT_DMEM th1f0v = uF0v;\n\n    FLOAT_DMEM th2ent = uEnt - vEnt;\n    FLOAT_DMEM th2e = uE + vE;\n    //FLOAT_DMEM th2f0v = 1.0/36.0 * vF0v;\n    FLOAT_DMEM th2f0v = uF0v + vF0v;\n\n    FLOAT_DMEM th3ent = uEnt - (FLOAT_DMEM)2.0*vEnt;\n    FLOAT_DMEM th3e = uE + (FLOAT_DMEM)1.0*vE;\n    //FLOAT_DMEM th3f0v = 1.0/27.0 * vF0v;\n    FLOAT_DMEM th3f0v = uF0v + (FLOAT_DMEM)2.0* vF0v;\n\n    FLOAT_DMEM th4ent = uEnt - (FLOAT_DMEM)3.0*vEnt;\n    FLOAT_DMEM th4e = uE + (FLOAT_DMEM)2.0*vE;\n    //FLOAT_DMEM th4f0v = 1.0/18.0 * vF0v;\n    FLOAT_DMEM th4f0v = uF0v + (FLOAT_DMEM)3.0* vF0v;\n    \n    FLOAT_DMEM th5ent = uEnt - (FLOAT_DMEM)5.0*vEnt;\n    FLOAT_DMEM th5e = uE + (FLOAT_DMEM)4.0*vE;\n    //FLOAT_DMEM th5f0v = 1.0/9.0 * vF0v;\n    FLOAT_DMEM th5f0v = uF0v + (FLOAT_DMEM)5.0* vF0v;\n\n    \n    FLOAT_DMEM tth0ent = tuEnt + (FLOAT_DMEM)0.5*tvEnt;\n    FLOAT_DMEM tth0e = tuE - (FLOAT_DMEM)0.1*tvE;\n    //FLOAT_DMEM th1f0v = 1.0/72.0 * vF0v;\n    FLOAT_DMEM tth0f0v = tuF0v - (FLOAT_DMEM)0.5*tvF0v;\n\n    FLOAT_DMEM tth1ent = tuEnt - (FLOAT_DMEM)0.5*tvEnt;\n    FLOAT_DMEM tth1e = tuE + (FLOAT_DMEM)0.1*tvE;\n    //FLOAT_DMEM th1f0v = 1.0/72.0 * vF0v;\n    FLOAT_DMEM tth1f0v = tuF0v + (FLOAT_DMEM)0.5*tvF0v;\n\n    FLOAT_DMEM tth2ent = tuEnt + (FLOAT_DMEM)1.0*tvEnt;\n    FLOAT_DMEM tth2e = tuE - (FLOAT_DMEM)0.5*tvE;\n    //FLOAT_DMEM th1f0v = 1.0/72.0 * vF0v;\n    FLOAT_DMEM tth2f0v = tuF0v - (FLOAT_DMEM)2.0*tvF0v;\n\n    FLOAT_DMEM tth3ent = tuEnt + (FLOAT_DMEM)3.0*tvEnt;\n    FLOAT_DMEM tth3e = tuE - (FLOAT_DMEM)2.0*tvE;\n    //FLOAT_DMEM th1f0v = 1.0/72.0 * vF0v;\n    FLOAT_DMEM tth3f0v = tuF0v - (FLOAT_DMEM)3.0*tvF0v;\n\n  \n    // perform VAD\n    FLOAT_DMEM vadEnt, vadE, vadF0v;\n\n    if (ent < th5ent) { // inverse\n      vadEnt = (FLOAT_DMEM)1.0;\n    } else if (ent < th4ent) {\n      vadEnt = (FLOAT_DMEM)0.8;\n    } else if (ent < th3ent) {\n      vadEnt = (FLOAT_DMEM)0.6;\n    } else if (ent < th2ent) {\n      vadEnt = (FLOAT_DMEM)0.4;\n    } else if (ent < th1ent) {\n      vadEnt = (FLOAT_DMEM)0.2;\n    } else { \n      vadEnt = (FLOAT_DMEM)0.0;\n    }\n\n    if ((tuEnt > (FLOAT_DMEM)0.0)&&(tth2ent<th4ent)) {\n      if (ent > tth3ent) {\n        vadEnt -= (FLOAT_DMEM)0.3;\n      } else if (ent > tth2ent) {\n        vadEnt -= (FLOAT_DMEM)0.2;\n      } else if (ent < tth1ent) {\n        vadEnt = (FLOAT_DMEM)1.0;\n      }  \n    } else if ((tth2ent>th4ent)) {\n      //vadEnt -= 0.2; // penalty, if turns are very equal to noise\n    }\n\n\n    if (vadEnt < (FLOAT_DMEM)0.0) vadEnt = 0;\n \n    if (E < th1e) {\n      vadE = (FLOAT_DMEM)0;\n    } else if (E < th2e) {\n      vadE = (FLOAT_DMEM)0.2;\n    } else if (E < th3e) {\n      vadE = (FLOAT_DMEM)0.4;\n    } else if (E < th4e) {\n      vadE = (FLOAT_DMEM)0.6;\n    } else if (E < th5e) {\n      vadE = (FLOAT_DMEM)0.8;\n    } else { \n      vadE = (FLOAT_DMEM)1.0;\n    }\n\n    if ((tuE > (FLOAT_DMEM)0.0)&&(tth2e<th4e)) {\n      if (E < tth3e) {\n        vadE -= (FLOAT_DMEM)0.2;\n      } else if (E < tth2e) {\n        vadE -= (FLOAT_DMEM)0.2;\n      } else if (E > tth1e) {\n        vadE = (FLOAT_DMEM)1.0;\n      }  \n    } else if ((tth2e<th4e)&&(tuE>(FLOAT_DMEM)0.0)) {\n      //vadE -= 0.2; // penalty, if turns are very equal to noise\n    }\n    if (vadE < (FLOAT_DMEM)0.0) vadE = 0;\n\n\n    if (f0v < th1f0v) {  \n      vadF0v = (FLOAT_DMEM)0.0;\n    } else if (f0v < th2f0v) {\n      vadF0v = (FLOAT_DMEM)0.2;\n    } else if (f0v < th3f0v) {\n      vadF0v = (FLOAT_DMEM)0.4;\n    } else if (f0v < th4f0v) {\n      vadF0v = (FLOAT_DMEM)0.6;\n    } else if (f0v < th5f0v) {\n      vadF0v = (FLOAT_DMEM)0.8;\n    } else { \n      vadF0v = (FLOAT_DMEM)1.0;\n    }\n\n    if ((tuF0v > (FLOAT_DMEM)0.0)&&(tth2f0v<th4f0v)) {\n      if (f0v < tth3f0v) {\n        vadF0v -= (FLOAT_DMEM)0.2;\n      } else if (f0v < tth2f0v) {\n        vadF0v -= (FLOAT_DMEM)0.2;\n      } else if (f0v > tth1f0v) {\n        vadF0v = (FLOAT_DMEM)1.0;\n      }  \n    } else if ((tth2f0v<th4f0v)&&(tuF0v>(FLOAT_DMEM)0.0)) {\n      //vadF0v -= 0.2; // penalty, if turns are very equal to noise\n    }\n    if (vadF0v < (FLOAT_DMEM)0.0) vadF0v = 0;\n\n    if (debug) {\n      printf(\"VADent %f  %f  %f   %f | %f %f\\n\",vadEnt, ent, uEnt, vEnt, tuEnt, tvEnt);\n      printf(\"VADdiv %f  %f  %f   %f | %f %f\\n\",vadF0v, f0v, uF0v, vF0v, tuF0v, tvF0v);\n      printf(\"VADE   %f  %f  %f   %f | %f %f\\n\",vadE, E, uE, vE, tuE, tvE);\n    }\n\n    vadFuz = (FLOAT_DMEM)0.45 * vadEnt + (FLOAT_DMEM)0.25 * vadE +  (FLOAT_DMEM)0.30 * vadF0v;\n    //vadFuz = (FLOAT_DMEM)0.55 * vadEnt + (FLOAT_DMEM)0.45 * vadE  * vadF0v;\n\n    //vadFuz = vadEnt * vadE  * vadF0v;\n\n    // maintain history:\n    vadFuzH[vadFuzHidx++] = vadFuz;\n    if (vadFuzHidx >= FUZBUF) vadFuzHidx = 0;\n\n    //printf(\"VADfuz %f\\n\",vadFuz);\n\n    // determine vad bin:\n    int i;\n    FLOAT_DMEM sum = 0.0;\n    for (i=0; i<FUZBUF; i++) {\n      sum += vadFuzH[i];\n    }\n    sum /= (FLOAT_DMEM)FUZBUF;\n\n    vadSmo = sum;\n\n    // ... the big magic ;-)\n    if ((sum > (FLOAT_DMEM)0.50)&&(E > minE)) {\n      if (vadBin==0) { turnSum = 0.0; turnN=0.0; /*printf(\"turnstart\\n\");*/ }\n      vadBin = 1;\n      turnSum += sum; turnN += 1.0;\n    } else {\n      if (vadBin == 1) {\n        //printf(\"turnConf = %f\\n\",turnSum/turnN);\n      }\n      vadBin = 0;\n    }\n\n\n    if ((vadBin == 0)&&(vadFuz < 0.5)) {    \n      // dynamic threshold update:\n\n      F0vH[F0vHidx++] = f0v;\n      if (F0vHidx >= FTBUF) F0vHidx = 0;\n      entH[entHidx++] = ent;\n      if (entHidx >= FTBUF) entHidx = 0;\n      EH[EHidx++] = E;\n      if (EHidx >= FTBUF) EHidx = 0;\n  \n      if (nInit < FTBUF) nInit++;\n      else {\n        int i;\n        FLOAT_DMEM sumEnt=0.0;\n        FLOAT_DMEM sumF0v=0.0;\n        FLOAT_DMEM sumE=0.0;\n        for (i=0; i< FTBUF; i++) {\n          sumEnt += entH[i];\n          sumE += EH[i];\n          sumF0v += F0vH[i];\n        }\n        sumEnt /= (FLOAT_DMEM)FTBUF;\n        sumE /= (FLOAT_DMEM)FTBUF;\n        sumF0v /= (FLOAT_DMEM)FTBUF;\n\n        uEnt = ((FLOAT_DMEM)1.0-arU) * uEnt + (arU)*sumEnt;\n        uF0v = ((FLOAT_DMEM)1.0-arU) * uF0v + (arU)*sumF0v;\n        uE = ((FLOAT_DMEM)1.0-arU) * uE + (arU)*sumE;\n\n        // standard deviations:\n        FLOAT_DMEM stEnt=(FLOAT_DMEM)0.0;\n        FLOAT_DMEM stF0v=(FLOAT_DMEM)0.0;\n        FLOAT_DMEM stE=(FLOAT_DMEM)0.0;\n        for (i=0; i< FTBUF; i++) {\n          stEnt += ( entH[i] - sumEnt ) * ( entH[i] - sumEnt );\n          stE += ( EH[i] - sumE ) * ( EH[i] - sumE );\n          stF0v += ( F0vH[i] - sumF0v ) * ( F0vH[i] - sumF0v );\n        }\n        stEnt /= (FLOAT_DMEM)FTBUF;\n        stE /= (FLOAT_DMEM)FTBUF;\n        stF0v /= (FLOAT_DMEM)FTBUF;\n\n        vEnt = ((FLOAT_DMEM)1.0-arV) * vEnt + (arV)*sqrt(stEnt);\n        vF0v = ((FLOAT_DMEM)1.0-arV) * vF0v + (arV)*sqrt(stF0v);\n        vE = ((FLOAT_DMEM)1.0-arV) * vE + (arV)*sqrt(stE);\n        //nInitN=0;\n      }\n\n      int j=0;\n      for(i=specIdx; i<specIdx+specN; i++) {\n        spec[j] = (FLOAT_DMEM)0.995*spec[j] + (FLOAT_DMEM)0.005*src[i]; \n        j++;\n      }\n\n\n    } else if ((vadFuz > 0.6)&&(vadBin==1)&&(turnN>20.0)) {\n\n      tF0vH[tF0vHidx++] = f0v;\n      if (tF0vHidx >= FTBUF) tF0vHidx = 0;\n      tentH[tentHidx++] = ent;\n      if (tentHidx >= FTBUF) tentHidx = 0;\n      tEH[tEHidx++] = E;\n      if (tEHidx >= FTBUF) tEHidx = 0;\n\n      if (nInitT < FTBUF) nInitT++;\n      else {\n        FLOAT_DMEM sumEnt=0.0;\n        FLOAT_DMEM sumF0v=0.0;\n        FLOAT_DMEM sumE=0.0;\n        for (i=0; i< FTBUF; i++) {\n          sumEnt += tentH[i];\n          sumE += tEH[i];\n          sumF0v += tF0vH[i];\n        }\n        sumEnt /= (FLOAT_DMEM)FTBUF;\n        sumE /= (FLOAT_DMEM)FTBUF;\n        sumF0v /= (FLOAT_DMEM)FTBUF;\n\n        tuEnt = ((FLOAT_DMEM)1.0-arU) * tuEnt + (arU)*sumEnt;\n        tuF0v = ((FLOAT_DMEM)1.0-arU) * tuF0v + (arU)*sumF0v;\n        tuE = ((FLOAT_DMEM)1.0-arU) * tuE + (arU)*sumE;\n\n        // standard deviations:\n        FLOAT_DMEM stEnt=0.0;\n        FLOAT_DMEM stF0v=0.0;\n        FLOAT_DMEM stE=0.0;\n        for (i=0; i< FTBUF; i++) {\n          stEnt += ( tentH[i] - sumEnt ) * ( tentH[i] - sumEnt );\n          stE += ( tEH[i] - sumE ) * ( tEH[i] - sumE );\n          stF0v += ( tF0vH[i] - sumF0v ) * ( tF0vH[i] - sumF0v );\n        }\n        stEnt /= (FLOAT_DMEM)FTBUF;\n        stE /= (FLOAT_DMEM)FTBUF;\n        stF0v /= (FLOAT_DMEM)FTBUF;\n\n        tvEnt = ((FLOAT_DMEM)1.0-arV) * tvEnt + (arV)*sqrt(stEnt);\n        tvF0v = ((FLOAT_DMEM)1.0-arV) * tvF0v + (arV)*sqrt(stF0v);\n        tvE = ((FLOAT_DMEM)1.0-arV) * tvE + (arV)*sqrt(stE);\n        //nInitT=0;\n      }\n\n    }\n\n  }\n\n//  printf(\"VADbin %i\\n\",vadBin);\n\n  dst[0] = (FLOAT_DMEM)vadBin;\n  dst[1] = (FLOAT_DMEM)vadFuz;\n  dst[2] = (FLOAT_DMEM)vadSmo;\n\n  // save to dataMemory\n  writer_->setNextFrame(vec0);\n  delete vec0;\n\n  return 1;\n}\n\ncVadV1::~cVadV1()\n{\n  if (spec != NULL) free(spec);\n}\n\n"
  },
  {
    "path": "src/dspcore/acf.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nFIXME:\nThe current implementation does not properly consider the border conditions.\nI.e. we assume a signal periodic with the frame length!!\nWe should perform the ACF properly on two different versions of the same sample,\nzero-padded to the same length!\n\nWe need to add symmetric zero padding (on top of the pow2 padding) to the\nfft component!\nPad with N/2 left and right, i.e. double the frame size.\nHow to treat metadata?\n\nTODO:\nAutocorrelation Function (ACF)\n\nsimple windowed ACF\n\n(further TODO: continuous ACF (overlap add OR time domain?)\n\n*/\n\n#include <dspcore/acf.hpp>\n\n#define MODULE \"cAcf\"\n\nSMILECOMPONENT_STATICS(cAcf)\n\nSMILECOMPONENT_REGCOMP(cAcf)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CACF;\n  sdescription = COMPONENT_DESCRIPTION_CACF;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n    SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"nameAppend\", NULL, \"acf\");\n    ct->setField(\"usePower\",\"= square input values; you must leave this at default 1, when using fft magnitude as input for ACF. For cepstrum this will be set to 0 by default, unless you explicitly give the value 1.\",1);\n    ct->setField(\"cepstrum\",\"1 = compute the real valued cepstrum instead of the standard ACF. This applies a log() to the magnitudes bevore transforming from the spectral domain back to the time domain. You might want to set 'nameAppend=cepstrum' when using this option. See the cCepstrum component for complex valued cepstrum and more options (only in commercial version).\", 0);\n    ct->setField(\"inverse\", \"1 = do the inverse transform of cepstrum or ACF. The output is an FFT magnitude spectrum.\", 0);\n    ct->setField(\"cosLifterCepstrum\", \"1 = apply cosine lifter function to the cepstrum, effectively applying a Hanning window function to the cepstrum.\", 0);\n    ct->setField(\"expBeforeAbs\", \"1 = perform exp operation before computing magnitude spectrum (for inverse cepstrum only).\", 1);\n    ct->setField(\"symmetricData\", \"1 = treat data in acf/cepstral domain as symmetric data, i.e. output only half of the buffer or symmetrically duplicate the input before applying fft.\", 1);\n    ct->setField(\"acfCepsNormOutput\", \"1 = Divide the output values by the framesize (this is the default since version 2.0, however for older versions, such as 0.1 (openEAR) setting this option to 0 is required for comaptibility.\", 1);\n    ct->setField(\"oldCompatCepstrum\", \"1= compatibility with old openEAR (0.1) cepstrum computation (absCepstrum = 1, acfCepsNormOutput = 0, and usePower should be 1 (not forced though)).\", 0);\n    ct->setField(\"absCepstrum\", \"Enable output of root of power cepstrum (absolute value)\", 0);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cAcf);\n}\n\nSMILECOMPONENT_CREATE(cAcf)\n\n//-----\n\ncAcf::cAcf(const char *_name) :\ncVectorProcessor(_name),\nsymmetricData(0),\nexpBeforeAbs(0),\ncosLifterCepstrum(0),\nusePower(0), cepstrum(0), inverse(0),\ndata(NULL),\nw(NULL),\nip(NULL),\nwinFunc(NULL)\n{\n}\n\nvoid cAcf::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n  symmetricData = getInt(\"symmetricData\");\n  expBeforeAbs = getInt(\"expBeforeAbs\");\n  acfCepsNormOutput_ = getInt(\"acfCepsNormOutput\");\n  cepstrum = getInt(\"cepstrum\");\n  oldCompatCepstrum_ = getInt(\"oldCompatCepstrum\");\n  absCepstrum_ = getInt(\"absCepstrum\");\n  if (cepstrum) {\n    SMILE_IDBG(2,\"computing cesptrum instead of ACF\");\n  }\n  inverse = getInt(\"inverse\");\n  if (inverse) {\n    SMILE_IDBG(2,\"computing inverse transform.\");\n  }\n  if (cepstrum) {\n    if (isSet(\"usePower\")) {\n      usePower = getInt(\"usePower\");\n    } else {\n      usePower = 0;\n    }\n  } else {\n    usePower = getInt(\"usePower\");\n  }\n  if (oldCompatCepstrum_) {\n    acfCepsNormOutput_ = 0;\n    absCepstrum_ = 1;\n    if (usePower == 0) {\n      SMILE_IWRN(2, \"usePower (0) should be 1 for oldCompatCepstrum, please ensure that the input to this component is a power spectrum!\");\n    }\n  }\n  if (usePower) { SMILE_IDBG(2,\"Squaring magnitude spectrum input to become power spectrum.\"); }\n  cosLifterCepstrum = getInt(\"cosLifterCepstrum\");\n}\n\nint cAcf::setupNamesForField(int i, const char*name, long nEl)\n{\n  long nOutEl;\n  // TODO: truncate to half length output option for compatibility with old Acf/Cepstral pitch\n  if (symmetricData) {\n    if (inverse) {\n      nOutEl = nEl + 1;\n    } else {\n      nOutEl = nEl - 1;  // FIXME: removed -1 from nEl, this might break ACF pitch in old configs! Check!\n    }\n  } else {\n    if (inverse) {\n      nOutEl = nEl / 2 + 1;\n    } else {\n      nOutEl = (nEl-1) * 2;\n    }\n  }\n  int ret = cVectorProcessor::setupNamesForField(i, name, nOutEl);\n  if (cepstrum && cosLifterCepstrum) {\n    // compute liftering function\n    winFunc[i] = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM) * nOutEl);\n    if (symmetricData) {\n      double * wh = smileDsp_winHan(nOutEl * 2);\n      if (wh != NULL) {\n        for (int j = 0; j < nOutEl; j++) {\n          winFunc[i][j] = (FLOAT_DMEM)wh[nOutEl - j];\n        }\n        free(wh);\n      }\n    } else {\n      double * wh = smileDsp_winHan(nOutEl);\n      if (wh != NULL) {\n        for (int j = 0; j < nOutEl / 2; j++) {\n          winFunc[i][j] = (FLOAT_DMEM)wh[nOutEl / 2 - j];\n        }\n        for (int j = nOutEl/2; j < nOutEl; j++) {\n          winFunc[i][j] = (FLOAT_DMEM)wh[nOutEl / 2 - j + nOutEl - 1];\n        }\n        free(wh);\n      }\n    }\n  }\n  return ret;\n}\n\nint cAcf::dataProcessorCustomFinalise()\n{\n  if (ip == NULL) ip = (int**)multiConfAlloc();\n  if (w == NULL) w = (FLOAT_TYPE_FFT**)multiConfAlloc();\n  if (data == NULL) data = (FLOAT_TYPE_FFT**)multiConfAlloc();\n  if (winFunc == NULL) winFunc = (FLOAT_DMEM**)multiConfAlloc();\n\n  return cVectorProcessor::dataProcessorCustomFinalise();\n}\n\n// a derived class should override this method, in order to implement the actual processing\nint cAcf::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  long i,n;\n  idxi=getFconf(idxi);\n  FLOAT_TYPE_FFT *_data = data[idxi];\n  int *_ip = ip[idxi];\n  FLOAT_TYPE_FFT *_w = w[idxi];\n\n  if (inverse) {\n    long N = Nsrc;\n    if (symmetricData) {\n      N = Nsrc * 2;\n    }\n    if (_data == NULL) {\n      _data = (FLOAT_TYPE_FFT*)malloc(sizeof(FLOAT_TYPE_FFT)*N);\n    }\n    if (_ip==NULL) _ip = (int *)calloc(1,sizeof(int)*(N+2));\n    if (_w==NULL) _w = (FLOAT_TYPE_FFT *)calloc(1,sizeof(FLOAT_TYPE_FFT)*(N*5)/4+2);\n\n    // normal fft  (time -> spec)  // TODO: check dim of data etc.\n    if (cepstrum && cosLifterCepstrum) {\n      for (i = 0; i < Nsrc; i++) {\n        _data[i] = (FLOAT_TYPE_FFT)src[i] * winFunc[idxi][i];\n      }\n    } else {\n      for (i = 0; i < Nsrc; i++) {\n        _data[i] = (FLOAT_TYPE_FFT)src[i];\n      }\n    }\n\n    if (symmetricData) {\n      for (i = Nsrc; i < N; i++) {\n        _data[i] = _data[N - 1 - i];\n      }\n    }\n\n    rdft(N, 1, _data, _ip, _w);\n\n    // do exp for inverse cepstrum\n    if (cepstrum && expBeforeAbs) {\n      _data[0] = exp(_data[0]);\n      _data[1] = exp(_data[1]);\n      for (i = 2; i < N - 1; i += 2) {\n        // exp on real part, imag to zero\n        _data[i] = exp(_data[i]);\n        _data[i+1] = 0.0;\n      }\n    }\n\n    // compute magnitude (should be the real data... but just in case..)\n    dst[0] = fabs(_data[0]);\n    for (i = 2; i < N - 1; i += 2) {\n      if (i>>1 < Ndst) {\n        dst[i>>1] = sqrt((_data[i] * _data[i]) + (_data[i + 1] * _data[i + 1]));\n      }\n    }\n    dst[Ndst - 1] = fabs(_data[1]);\n\n    // subtract 1 for inverse cepstrum\n    if (cepstrum) {\n      if (!expBeforeAbs) {\n        for (i = 0; i < Ndst; i ++) {\n          dst[i] = exp(dst[i]) - (FLOAT_DMEM)1.0;\n          if (dst[i] < 0.0) dst[i] = 0.0;\n        }\n      } else {\n        for (i = 0; i < Ndst; i ++) {\n          dst[i] -= 1.0;\n          if (dst[i] < 0.0) dst[i] = 0.0;\n        }\n      }\n    }\n\n    // if usePower==1 take the square root when in ACF mode... (inverse behaviour as the other way round)\n    if (usePower) {\n      for (i = 0; i < Ndst; i ++) {\n        dst[i] = sqrt(dst[i]);\n      }\n    }\n  } else {\n    // copy & square the fft magnitude\n    FLOAT_DMEM *_src = NULL;\n    if (usePower) {\n      _src = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*Nsrc);\n      if (src==NULL) OUT_OF_MEMORY;\n      for (n=0; n<Nsrc; n++) {\n        _src[n] = src[n]*src[n];\n      }\n      src = _src;\n    }\n\n    long N = (Nsrc-1)*2;  // FIXME: Remove -1 from NSrc??\n    // check for power of 2!!\n    if (!smileMath_isPowerOf2(N)) {\n      SMILE_IERR(1,\"(Nsrc-1)*2 = %i is not a power of 2, this is required for acf!! make sure the input data really is fft magnitude data!\",N);\n      return 0;\n    }\n\n    // data preparation for inverse fft:\n    if (_data == NULL) {\n      _data = (FLOAT_TYPE_FFT*)malloc(sizeof(FLOAT_TYPE_FFT)*N);\n    }\n    if (_ip==NULL) _ip = (int *)calloc(1,sizeof(int)*(N+2));\n    if (_w==NULL) _w = (FLOAT_TYPE_FFT *)calloc(1,sizeof(FLOAT_TYPE_FFT)*(N*5)/4+2);\n\n    if (cepstrum) {\n      if (oldCompatCepstrum_) {\n        _data[0] = (FLOAT_TYPE_FFT)(src[0]);\n        _data[1] = (FLOAT_TYPE_FFT)(src[Nsrc-1]);\n        for (i=2; i<N-1; i += 2) {\n          if (src[i>>1] > 0.0) {\n            _data[i] = (FLOAT_TYPE_FFT)log(src[i>>1]);\n          } else {\n            _data[i] = 0.0;\n          }\n          _data[i+1] = 0.0;\n        }\n      } else {\n        if (src[0] > 0.0) {\n          _data[0] = (FLOAT_TYPE_FFT)(log(src[0] + 1.0));\n        } else {\n          _data[0] = 0.0;\n        }\n        if (src[Nsrc - 1] > 0.0) {\n          _data[1] = (FLOAT_TYPE_FFT)(log(src[Nsrc - 1] + 1.0));\n        } else {\n          _data[1] = 0.0;\n        }\n        for (i=2; i<N-1; i += 2) {\n          if (src[i>>1] > 0.0) {\n            _data[i] = (FLOAT_TYPE_FFT)log(src[i>>1] + 1.0);\n          } else {\n            _data[i] = 0.0;\n          }\n          _data[i+1] = 0.0;\n        }\n      }\n    } else {\n      _data[0] = (FLOAT_TYPE_FFT)(src[0]);\n      _data[1] = (FLOAT_TYPE_FFT)(src[Nsrc-1]);\n      for (i=2; i<N-1; i += 2) {\n        _data[i] = (FLOAT_TYPE_FFT)(src[i>>1]);\n        _data[i+1] = 0.0;\n      }\n    }\n\n    // inverse fft\n    rdft(N, -1, _data, _ip, _w);\n\n    // NOTE: The symmetricData option is implicitly handled by (i<N)&&(i<Ndst) and Ndst limiting the output size.\n    // TODO : debug the symmetricData option when doing cepstrum and inv cepstrum\n    if (acfCepsNormOutput_) {\n      for (i=0; (i<N)&&(i<Ndst); i++) {\n        _data[i] = (FLOAT_DMEM)_data[i] / (FLOAT_DMEM)Nsrc;\n      }\n    }\n    if (cepstrum) {\n      if (absCepstrum_) {\n        for (i=0; (i<N)&&(i<Ndst); i++) {\n          _data[i] = (FLOAT_DMEM)fabs(_data[i]);\n        }\n      }\n      if (cosLifterCepstrum) {\n        for (i=0; (i<N)&&(i<Ndst); i++) {\n          dst[i] = (FLOAT_DMEM)_data[i] * winFunc[idxi][i];\n        }\n      } else {\n        for (i=0; (i<N)&&(i<Ndst); i++) {\n          dst[i] = (FLOAT_DMEM)_data[i];\n        }\n      }\n    } else {\n      for (i=0; (i<N)&&(i<Ndst); i++) {\n        dst[i] = (FLOAT_DMEM)fabs(_data[i]);\n      }\n    }\n\n    // cleanup\n    if ((usePower)&&(_src!=NULL)) free((void *)_src);\n  }\n  data[idxi] = _data;\n  ip[idxi] = _ip;\n  w[idxi] = _w;\n  return 1;\n}\n\ncAcf::~cAcf()\n{\n  multiConfFree(ip);\n  multiConfFree(w);\n  multiConfFree(data);\n  multiConfFree(winFunc);\n}\n\n"
  },
  {
    "path": "src/dspcore/amdf.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nTODO:\nAverage Magnitude Difference Function (AMDF)\n\nthis implements a simple windowed AMDF\n\n\n(further TODO: continuous AMDF of fixed delay and decay -> WindowProcessor)\n*/\n\n\n#include <dspcore/amdf.hpp>\n\n#define MODULE \"cAmdf\"\n\n/*Library:\nsComponentInfo * registerMe(cConfigManager *_confman) {\ncDataProcessor::registerComponent(_confman);\n}\n*/\n\nSMILECOMPONENT_STATICS(cAmdf)\n\nSMILECOMPONENT_REGCOMP(cAmdf)\n//sComponentInfo * cAmdf::registerComponent(cConfigManager *_confman)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n    scname = COMPONENT_NAME_CAMDF;\n  sdescription = COMPONENT_DESCRIPTION_CAMDF;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n\n    SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"nameAppend\",NULL,\"amdf\");\n    ct->setField(\"nLag\",\"If nLag > 0, compute AMDF up to maximum lag 'nLag' (or maximum possible lag limited by framesize). If nLag=0, then always the maximum framesize will be used (this is the default). If nLag < 0, then nLag=framesize/((-1)*nLag) will be used.\",0);\n    ct->setField(\"method\",\"The AMDF computation method (i.e. the handling of border conditions):\\n    'limit' :  compute AMDF only in regions where the shifted windows overlap\\n    'warp' : compute cyclical AMDF by warping of input\\n    'zeropad' : zero pad missing samples\",\"limit\");\n    ct->setField(\"invert\",\"1 = invert the AMDF output values (literally '1-amdf'), i.e. so that the behaviour of the AMDF output corresponds more to that of an autocorrelation function.\",0);\n\n  )\n    SMILECOMPONENT_MAKEINFO(cAmdf);\n}\n\nSMILECOMPONENT_CREATE(cAmdf)\n\n//-----\n\ncAmdf::cAmdf(const char *_name) :\ncVectorProcessor(_name),\nnLag(1),\nmethod(AMDF_LIMIT),\ninvert(0)\n{\n\n}\n\nvoid cAmdf::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n\n  const char *_method = getStr(\"method\");\n  if (_method != NULL) {\n    if (!strcmp(_method,\"limit\")) {\n      method = AMDF_LIMIT;\n    } else\n      if (!strcmp(_method,\"warp\")) {\n        method = AMDF_WARP;\n      } else\n        if (!strcmp(_method,\"zeropad\")) {\n          method = AMDF_ZEROPAD;\n        }\n  }\n  nLag = getInt(\"nLag\");\n  invert = getInt(\"invert\");\n}\n\n/*\nint cAmdf::myConfigureInstance()\n{\nint ret=1;\nret *= cVectorProcessor::myConfigureInstance();\nif (ret == 0) return 0;\n\n//...\n\n\nreturn ret;\n}\n*/\n\n/*\nint cAmdf::configureWriter(const sDmLevelConfig *c)\n{\n\n// you must return 1, in order to indicate configure success (0 indicated failure)\nreturn 1;\n}\n\n*/\n\n\nint cAmdf::setupNamesForField(int i, const char*name, long nEl)\n{\n  if (nLag == 0) nLag = nEl-1;\n  if (nLag < 0) nLag = (nEl)/((-1)*nLag) - 1;\n  if (nLag < 1) nLag = 1;\n  if (nLag > nEl-1) nLag = nEl-1;\n  SMILE_DBG(2,\"nLag = %i\",nLag);\n  return cVectorProcessor::setupNamesForField(i,name,nLag);\n}\n\n\n/*\nint cAmdf::myFinaliseInstance()\n{\nint ret=1;\nret *= cVectorProcessor::myFinaliseInstance();\n//.....\nreturn ret;\n}\n*/\n\n/*\n// a derived class should override this method, in order to implement the actual processing\nint cAmdf::processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n// do domething to data in *src, save result to *dst\n// NOTE: *src and *dst may be the same...\n\nreturn 0;\n}\n*/\n\n// SMILElib function:\n// compute AMDF\nint computeAMDF(const FLOAT_DMEM *in, FLOAT_DMEM *out, long nIn, long nOut)\n{ // assumption: nOut = nLag!\n  long j; // lag j\n  FLOAT_DMEM tmp;\n  const FLOAT_DMEM *in1, *in2, *end;\n  *(out++) = 0.0;\n  for (j=1; j<nOut; j++) {\n    tmp=0.0;\n    in1 = in;\n    end = in+nIn-j;\n    in2 = in+j;\n    while (in1<end) {\n      tmp += fabs( *(in1++) - *(in2++) );\n    }\n    *(out++) = (tmp)/(FLOAT_DMEM)(nIn-j);\n  }\n  return 1;\n}\n\n// SMILElib function:\n// compute warped AMDF from a vector\nint computeAMDFwarped(const FLOAT_DMEM *in, FLOAT_DMEM *out, long nIn, long nOut, int invert=0)\n{ // assumption: nOut = nLag!\n  long j; // lag j\n  FLOAT_DMEM tmp;\n  const FLOAT_DMEM *in1, *in2, *end;\n  *(out) = 0.0;\n\n  for (j=1; j<nOut; j++) {\n    //printf(\"j=%i\\n\",j);\n    tmp=0.0;\n    in1 = in;\n    end = in+nIn;\n    in2 = in+j;\n    //long tt = 0;\n    while (in2<end) {\n      //while (tt<nIn-j) {\n      tmp += fabs( *(in1++) - *(in2++) );\n      //\ttt++;\n    }\n    in2 = in;\n\n    while (in1<end) {\n      //while (tt<nIn) {\n      tmp += fabs( *(in1++) - *(in2++) );\n      //tt++;\n    }\n    out[j] = (tmp)/(FLOAT_DMEM)(nIn);\n  }\n  return 1;\n}\n\n// SMILElib function:\n// compute zeropadded AMDF from a vector\nint computeAMDFzeropad(const FLOAT_DMEM *in, FLOAT_DMEM *out, long nIn, long nOut)\n{ // assumption: nOut = nLag!\n  long j; // lag j\n  FLOAT_DMEM tmp;\n  const FLOAT_DMEM *in1, *in2, *end1, *end2;\n  *(out++) = 0.0;\n  for (j=1; j<nOut; j++) {\n    tmp=0.0;\n    in1 = in;\n    end1 = in+nIn-j;\n    end2 = in+nIn;\n    in2 = in+j;\n    while (in1<end1) {\n      tmp += fabs( *(in1++) - *(in2++) );\n    }\n    while (in1<end2) { // TODO: avoid double computation effort here.... sum up only once and then look up cummulative value\n      tmp += fabs( *(in1++) );\n    }\n    *(out++) = (tmp)/(FLOAT_DMEM)(nIn);\n  }\n  return 1;\n}\n\n// a derived class should override this method, in order to implement the actual processing\nint cAmdf::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  // do domething to data in *src, save result to *dst\n  // NOTE: *src and *dst may be the same...\n  if (Nsrc == 0) return 0;\n\n  switch (method) {\n    case AMDF_LIMIT:  computeAMDF(src,dst,Nsrc,Ndst); break;\n    case AMDF_WARP:  computeAMDFwarped(src,dst,Nsrc,Ndst, invert); break;\n    case AMDF_ZEROPAD:  computeAMDFzeropad(src,dst,Nsrc,Ndst); break;\n    default : {\n      SMILE_ERR(1,\"unknown AMDF computation method: %i\",method);\n      return 0;\n              }\n  }\n\n  if (invert) {\n    FLOAT_DMEM max = 0.0;\n    long j;\n    for (j=0; j<Ndst; j++)\n      if (dst[j] > max ) max = dst[j];\n    for (j=0; j<Ndst; j++)\n      dst[j] = max - dst[j];\n  }\n\n  return 1;\n}\n\ncAmdf::~cAmdf()\n{\n}\n\n"
  },
  {
    "path": "src/dspcore/contourSmoother.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: contour smoother\n\nsmooth data contours by moving average filter\n\n*/\n\n\n#include <dspcore/contourSmoother.hpp>\n#include <math.h>\n\n#define MODULE \"cContourSmoother\"\n\n\nSMILECOMPONENT_STATICS(cContourSmoother)\n\nSMILECOMPONENT_REGCOMP(cContourSmoother)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CCONTOURSMOOTHER;\n  sdescription = COMPONENT_DESCRIPTION_CCONTOURSMOOTHER;\n\n  // we inherit cWindowProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cWindowProcessor\")\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"nameAppend\", NULL, \"sma\");\n    ct->setField(\"smaWin\",\"The size of the moving average window. A larger window means more smoothing.\",3);\n    ct->setField(\"noZeroSma\",\" 1 = exclude frames where the element value is 0 from smoothing (i.e. 0 input will be 0 output, and zeros around non-zero values will not be included in the computation of the running average).\",0);\n    ct->setField(\"blocksize\", NULL ,1);\n  )\n  SMILECOMPONENT_MAKEINFO(cContourSmoother);\n}\n\nSMILECOMPONENT_CREATE(cContourSmoother)\n\n//-----\n\ncContourSmoother::cContourSmoother(const char *_name) :\n  cWindowProcessor(_name),\n  smaWin(0)\n{\n}\n\n\nvoid cContourSmoother::fetchConfig()\n{\n  cWindowProcessor::fetchConfig();\n  \n  noZeroSma = getInt(\"noZeroSma\");\n  SMILE_IDBG(2,\"noZeroSma = %i\",noZeroSma);\n\n  smaWin = getInt(\"smaWin\");\n  \n  if (smaWin < 1) {\n    SMILE_IWRN(1,\"smaWin must be >= 1 ! (setting to 1)\");\n    smaWin = 1;\n  }\n  if (smaWin % 2 == 0) {\n    smaWin++;\n    SMILE_IWRN(1,\"smaWin must be an uneven number >= 1 ! (increasing smaWin by 1 -> smaWin=%i)\",smaWin);\n  }\n  SMILE_IDBG(2,\"smaWin = %i\",smaWin);\n\n  setWindow(smaWin/2,smaWin/2);\n}\n\n/*\nint cContourSmoother::setupNamesForField(int i, const char*name, long nEl)\n{\n  char *tmp = myvprint(\"%s_de\",name);\n  writer->addField( name, nEl );\n  return nEl;\n}\n*/\n\n// order is the amount of memory (overlap) that will be present in _in\n// buf will have nT timesteps, however also order negative indicies (i.e. you may access a negative array index up to -order!)\nint cContourSmoother::processBuffer(cMatrix *_in, cMatrix *_out, int _pre, int _post )\n{\n  long n,w;\n  if (_in->type!=DMEM_FLOAT) COMP_ERR(\"dataType (%i) != DMEM_FLOAT not yet supported!\",_in->type);\n  FLOAT_DMEM *x=_in->dataF;\n  FLOAT_DMEM *y=_out->dataF;\n\n  if (noZeroSma) {\n    for (n=0; n<_out->nT; n++) {\n      if (x[n] != 0.0) {\n        long _N=1;\n        y[n] = x[n];\n        for (w=1; w<=smaWin/2; w++) {\n          if (x[n-w] != 0.0) { y[n] += x[n-w]; _N++; }\n          if (x[n+w] != 0.0) { y[n] += x[n+w]; _N++; }\n        }\n        y[n] /= (FLOAT_DMEM)_N;\n      } else {\n        y[n] = 0.0;\n      }\n    }\n  } else {\n    for (n=0; n<_out->nT; n++) {\n      y[n] = x[n];\n      for (w=1; w<=smaWin/2; w++) {\n        y[n] += x[n-w];\n        y[n] += x[n+w];\n      }\n      y[n] /= (FLOAT_DMEM)smaWin;\n    }\n  }\n\n  return 1;\n}\n\n\ncContourSmoother::~cContourSmoother()\n{\n}\n\n"
  },
  {
    "path": "src/dspcore/deltaRegression.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: delta coefficients\n\ncompute delta regression using regression formula\n\n*/\n\n\n\n#include <dspcore/deltaRegression.hpp>\n//#include <math.h>\n\n#define MODULE \"cDeltaRegression\"\n\n\nSMILECOMPONENT_STATICS(cDeltaRegression)\n\nSMILECOMPONENT_REGCOMP(cDeltaRegression)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n    scname = COMPONENT_NAME_CDELTAREGRESSION;\n  sdescription = COMPONENT_DESCRIPTION_CDELTAREGRESSION;\n\n  // we inherit cWindowProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cWindowProcessor\")\n    SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"nameAppend\", NULL, \"de\");\n  ct->setField(\"deltawin\",\"Specifies the size of half of the delta regression window (If set to 0, a simple difference x[n]-x[n-1] will be computed)\",2);\n  ct->setField(\"absOutput\",\"1/0 = on/off : Output absolute value of delta regression or difference function (i.e. do full wave rectification on output signal).\",0);\n  ct->setField(\"halfWaveRect\",\"1/0 = on/off : Do half-wave rectification on output values (i.e. keep only positive values and set negative values to 0). Please note that 'halfWaveRect' overrides the 'absOutput' option.\",0);\n  ct->setField(\"onlyInSegments\",\"1/0 = on/off : Don't compute deltas at segment boundaries. Segments are bounded by one or more NaN values, or zeros, if zeroSegBound=1 (default)\",0);\n  ct->setField(\"zeroSegBound\",\"1/0 = on/off : Consider zeros as segment boundaries (in conjunction with onlyInSegments option).\",1);\n  ct->setField(\"blocksize\", NULL , 1);\n  )\n    SMILECOMPONENT_MAKEINFO(cDeltaRegression);\n}\n\nSMILECOMPONENT_CREATE(cDeltaRegression)\n\n//-----\n\ncDeltaRegression::cDeltaRegression(const char *_name) :\ncWindowProcessor(_name),\ndeltawin(0), halfWaveRect(0), absOutput(0),\nnorm(1.0)\n{\n}\n\n\nvoid cDeltaRegression::fetchConfig()\n{\n  cWindowProcessor::fetchConfig();\n\n  halfWaveRect = getInt(\"halfWaveRect\");\n  SMILE_IDBG(2,\"halfWaveRect = %i\",halfWaveRect);\n  if (!halfWaveRect) {\n    absOutput = getInt(\"absOutput\");\n    SMILE_IDBG(2,\"absOutput = %i\",absOutput);\n  }\n\n  deltawin = getInt(\"deltawin\");\n  SMILE_IDBG(2,\"deltawin = %i\",deltawin);\n  if (deltawin < 0) {\n    SMILE_IERR(1,\"deltawin must be >= 0 ! (setting to 0)\");\n    deltawin = 0;\n  }\n\n  int i;\n  norm = 0.0;\n  for (i=1; i<=deltawin; i++) norm += (FLOAT_DMEM)i*(FLOAT_DMEM)i;\n  norm *= 2.0;\n\n  if (deltawin > 0) {\n    setWindow(deltawin,deltawin);\n  } else {\n    setWindow(1,0);\n  }\n\n  onlyInSegments=getInt(\"onlyInSegments\");\n  zeroSegBound=getInt(\"zeroSegBound\");\n}\n\n/*\nint cDeltaRegression::setupNamesForField(int i, const char*name, long nEl)\n{\nchar *tmp = myvprint(\"%s_de\",name);\nwriter->addField( name, nEl );\nreturn nEl;\n}\n*/\n\n// order is the amount of memory (overlap) that will be present in _in\n// buf will have nT timesteps, however also order negative indicies (i.e. you may access a negative array index up to -order!)\nint cDeltaRegression::processBuffer(cMatrix *_in, cMatrix *_out, int _pre, int _post )\n{\n  long n;\n  int i;\n  FLOAT_DMEM num;\n  if (_in->type!=DMEM_FLOAT) COMP_ERR(\"dataType (%i) != DMEM_FLOAT not yet supported!\",_in->type);\n  FLOAT_DMEM *x=_in->dataF;\n  FLOAT_DMEM *y=_out->dataF;\n\n  if (deltawin > 0) {\n    if (onlyInSegments) {\n      for (n=0; n<_out->nT; n++) {\n        num = 0.0;\n        FLOAT_DMEM _norm = 0.0;\n        for (i=1; i<=deltawin; i++) {\n          if (!(isNoValue(x[n+i]) || isNoValue(x[n-i]))) {\n            num += (FLOAT_DMEM)i * (x[n+i] - x[n-i]);\n            norm += (FLOAT_DMEM)i*(FLOAT_DMEM)i;\n          }\n        }\n        if (norm != 0.0) {\n          y[n] = num / norm;\n        } else {\n          y[n] = 0.0;\n        }\n      }\n    } else {\n      for (n=0; n<_out->nT; n++) {\n        num = 0.0;\n        for (i=1; i<=deltawin; i++) num += (FLOAT_DMEM)i * (x[n+i] - x[n-i]);\n        y[n] = num / norm;\n      }\n    }\n  } else { // simple difference\n    if (onlyInSegments) {\n      for (n=0; n<_out->nT; n++) {\n        if (isNoValue(x[n]) || isNoValue(x[n-1])) {\n          y[n] = 0.0; \n        } else {\n          y[n] = x[n]-x[n-1];\n        }\n      }\n    } else {\n      for (n=0; n<_out->nT; n++) {\n        y[n] = x[n]-x[n-1];\n      }\n    }\n  }\n\n  if (halfWaveRect) {\n    for (n=0; n<_out->nT; n++) {\n      if (y[n] < 0.0) y[n] = 0.0;\n    }\n  } else if (absOutput) {\n    for (n=0; n<_out->nT; n++) {\n      if (y[n] < 0.0) y[n] = -y[n];\n    }\n  }\n\n  return 1;\n}\n\n\ncDeltaRegression::~cDeltaRegression()\n{\n}\n\n"
  },
  {
    "path": "src/dspcore/fft4g.c",
    "content": "/*\n * http://www.kurims.kyoto-u.ac.jp/~ooura/fft.html\n * Copyright Takuya OOURA, 1996-2001\n *\n * You may use, copy, modify and distribute this code for any purpose (include\n * commercial use) and without fee. Please refer to this package when you modify\n * this code.\n *\n * Changes:\n * Trivial type modifications by the openSMILE authors.\n */\n\n/*\nFast Fourier/Cosine/Sine Transform\n    dimension   :one\n    data length :power of 2\n    decimation  :frequency\n    radix       :4, 2\n    data        :inplace\n    table       :use\nfunctions\n    cdft: Complex Discrete Fourier Transform\n    rdft: Real Discrete Fourier Transform\n    ddct: Discrete Cosine Transform\n    ddst: Discrete Sine Transform\n    dfct: Cosine Transform of RDFT (Real Symmetric DFT)\n    dfst: Sine Transform of RDFT (Real Anti-symmetric DFT)\nfunction prototypes\n    void cdft(int, int, FLOAT_TYPE_FFT *, int *, FLOAT_TYPE_FFT *);\n    void rdft(int, int, FLOAT_TYPE_FFT *, int *, FLOAT_TYPE_FFT *);\n    void ddct(int, int, FLOAT_TYPE_FFT *, int *, FLOAT_TYPE_FFT *);\n    void ddst(int, int, FLOAT_TYPE_FFT *, int *, FLOAT_TYPE_FFT *);\n    void dfct(int, FLOAT_TYPE_FFT *, FLOAT_TYPE_FFT *, int *, FLOAT_TYPE_FFT *);\n    void dfst(int, FLOAT_TYPE_FFT *, FLOAT_TYPE_FFT *, int *, FLOAT_TYPE_FFT *);\n\n\n-------- Complex DFT (Discrete Fourier Transform) --------\n    [definition]\n        <case1>\n            X[k] = sum_j=0^n-1 x[j]*exp(2*pi*i*j*k/n), 0<=k<n\n        <case2>\n            X[k] = sum_j=0^n-1 x[j]*exp(-2*pi*i*j*k/n), 0<=k<n\n        (notes: sum_j=0^n-1 is a summation from j=0 to n-1)\n    [usage]\n        <case1>\n            ip[0] = 0; // first time only\n            cdft(2*n, 1, a, ip, w);\n        <case2>\n            ip[0] = 0; // first time only\n            cdft(2*n, -1, a, ip, w);\n    [parameters]\n        2*n            :data length (int)\n                        n >= 1, n = power of 2\n        a[0...2*n-1]   :input/output data (FLOAT_TYPE_FFT *)\n                        input data\n                            a[2*j] = Re(x[j]), \n                            a[2*j+1] = Im(x[j]), 0<=j<n\n                        output data\n                            a[2*k] = Re(X[k]), \n                            a[2*k+1] = Im(X[k]), 0<=k<n\n        ip[0...*]      :work area for bit reversal (int *)\n                        length of ip >= 2+sqrt(n)\n                        strictly, \n                        length of ip >= \n                            2+(1<<(int)(log(n+0.5)/log(2))/2).\n                        ip[0],ip[1] are pointers of the cos/sin table.\n        w[0...n/2-1]   :cos/sin table (FLOAT_TYPE_FFT *)\n                        w[],ip[] are initialized if ip[0] == 0.\n    [remark]\n        Inverse of \n            cdft(2*n, -1, a, ip, w);\n        is \n            cdft(2*n, 1, a, ip, w);\n            for (j = 0; j <= 2 * n - 1; j++) {\n                a[j] *= 1.0 / n;\n            }\n        .\n\n\n-------- Real DFT / Inverse of Real DFT --------\n    [definition]\n        <case1> RDFT\n            R[k] = sum_j=0^n-1 a[j]*cos(2*pi*j*k/n), 0<=k<=n/2\n            I[k] = sum_j=0^n-1 a[j]*sin(2*pi*j*k/n), 0<k<n/2\n        <case2> IRDFT (excluding scale)\n            a[k] = (R[0] + R[n/2]*cos(pi*k))/2 + \n                   sum_j=1^n/2-1 R[j]*cos(2*pi*j*k/n) + \n                   sum_j=1^n/2-1 I[j]*sin(2*pi*j*k/n), 0<=k<n\n    [usage]\n        <case1>\n            ip[0] = 0; // first time only\n            rdft(n, 1, a, ip, w);\n        <case2>\n            ip[0] = 0; // first time only\n            rdft(n, -1, a, ip, w);\n    [parameters]\n        n              :data length (int)\n                        n >= 2, n = power of 2\n        a[0...n-1]     :input/output data (FLOAT_TYPE_FFT *)\n                        <case1>\n                            output data\n                                a[2*k] = R[k], 0<=k<n/2\n                                a[2*k+1] = I[k], 0<k<n/2\n                                a[1] = R[n/2]\n                        <case2>\n                            input data\n                                a[2*j] = R[j], 0<=j<n/2\n                                a[2*j+1] = I[j], 0<j<n/2\n                                a[1] = R[n/2]\n        ip[0...*]      :work area for bit reversal (int *)\n                        length of ip >= 2+sqrt(n/2)\n                        strictly, \n                        length of ip >= \n                            2+(1<<(int)(log(n/2+0.5)/log(2))/2).\n                        ip[0],ip[1] are pointers of the cos/sin table.\n        w[0...n/2-1]   :cos/sin table (FLOAT_TYPE_FFT *)\n                        w[],ip[] are initialized if ip[0] == 0.\n    [remark]\n        Inverse of \n            rdft(n, 1, a, ip, w);\n        is \n            rdft(n, -1, a, ip, w);\n            for (j = 0; j <= n - 1; j++) {\n                a[j] *= 2.0 / n;\n            }\n        .\n\n\n-------- DCT (Discrete Cosine Transform) / Inverse of DCT --------\n    [definition]\n        <case1> IDCT (excluding scale)\n            C[k] = sum_j=0^n-1 a[j]*cos(pi*j*(k+1/2)/n), 0<=k<n\n        <case2> DCT\n            C[k] = sum_j=0^n-1 a[j]*cos(pi*(j+1/2)*k/n), 0<=k<n\n    [usage]\n        <case1>\n            ip[0] = 0; // first time only\n            ddct(n, 1, a, ip, w);\n        <case2>\n            ip[0] = 0; // first time only\n            ddct(n, -1, a, ip, w);\n    [parameters]\n        n              :data length (int)\n                        n >= 2, n = power of 2\n        a[0...n-1]     :input/output data (FLOAT_TYPE_FFT *)\n                        output data\n                            a[k] = C[k], 0<=k<n\n        ip[0...*]      :work area for bit reversal (int *)\n                        length of ip >= 2+sqrt(n/2)\n                        strictly, \n                        length of ip >= \n                            2+(1<<(int)(log(n/2+0.5)/log(2))/2).\n                        ip[0],ip[1] are pointers of the cos/sin table.\n        w[0...n*5/4-1] :cos/sin table (FLOAT_TYPE_FFT *)\n                        w[],ip[] are initialized if ip[0] == 0.\n    [remark]\n        Inverse of \n            ddct(n, -1, a, ip, w);\n        is \n            a[0] *= 0.5;\n            ddct(n, 1, a, ip, w);\n            for (j = 0; j <= n - 1; j++) {\n                a[j] *= 2.0 / n;\n            }\n        .\n\n\n-------- DST (Discrete Sine Transform) / Inverse of DST --------\n    [definition]\n        <case1> IDST (excluding scale)\n            S[k] = sum_j=1^n A[j]*sin(pi*j*(k+1/2)/n), 0<=k<n\n        <case2> DST\n            S[k] = sum_j=0^n-1 a[j]*sin(pi*(j+1/2)*k/n), 0<k<=n\n    [usage]\n        <case1>\n            ip[0] = 0; // first time only\n            ddst(n, 1, a, ip, w);\n        <case2>\n            ip[0] = 0; // first time only\n            ddst(n, -1, a, ip, w);\n    [parameters]\n        n              :data length (int)\n                        n >= 2, n = power of 2\n        a[0...n-1]     :input/output data (FLOAT_TYPE_FFT *)\n                        <case1>\n                            input data\n                                a[j] = A[j], 0<j<n\n                                a[0] = A[n]\n                            output data\n                                a[k] = S[k], 0<=k<n\n                        <case2>\n                            output data\n                                a[k] = S[k], 0<k<n\n                                a[0] = S[n]\n        ip[0...*]      :work area for bit reversal (int *)\n                        length of ip >= 2+sqrt(n/2)\n                        strictly, \n                        length of ip >= \n                            2+(1<<(int)(log(n/2+0.5)/log(2))/2).\n                        ip[0],ip[1] are pointers of the cos/sin table.\n        w[0...n*5/4-1] :cos/sin table (FLOAT_TYPE_FFT *)\n                        w[],ip[] are initialized if ip[0] == 0.\n    [remark]\n        Inverse of \n            ddst(n, -1, a, ip, w);\n        is \n            a[0] *= 0.5;\n            ddst(n, 1, a, ip, w);\n            for (j = 0; j <= n - 1; j++) {\n                a[j] *= 2.0 / n;\n            }\n        .\n\n\n-------- Cosine Transform of RDFT (Real Symmetric DFT) --------\n    [definition]\n        C[k] = sum_j=0^n a[j]*cos(pi*j*k/n), 0<=k<=n\n    [usage]\n        ip[0] = 0; // first time only\n        dfct(n, a, t, ip, w);\n    [parameters]\n        n              :data length - 1 (int)\n                        n >= 2, n = power of 2\n        a[0...n]       :input/output data (FLOAT_TYPE_FFT *)\n                        output data\n                            a[k] = C[k], 0<=k<=n\n        t[0...n/2]     :work area (FLOAT_TYPE_FFT *)\n        ip[0...*]      :work area for bit reversal (int *)\n                        length of ip >= 2+sqrt(n/4)\n                        strictly, \n                        length of ip >= \n                            2+(1<<(int)(log(n/4+0.5)/log(2))/2).\n                        ip[0],ip[1] are pointers of the cos/sin table.\n        w[0...n*5/8-1] :cos/sin table (FLOAT_TYPE_FFT *)\n                        w[],ip[] are initialized if ip[0] == 0.\n    [remark]\n        Inverse of \n            a[0] *= 0.5;\n            a[n] *= 0.5;\n            dfct(n, a, t, ip, w);\n        is \n            a[0] *= 0.5;\n            a[n] *= 0.5;\n            dfct(n, a, t, ip, w);\n            for (j = 0; j <= n; j++) {\n                a[j] *= 2.0 / n;\n            }\n        .\n\n\n-------- Sine Transform of RDFT (Real Anti-symmetric DFT) --------\n    [definition]\n        S[k] = sum_j=1^n-1 a[j]*sin(pi*j*k/n), 0<k<n\n    [usage]\n        ip[0] = 0; // first time only\n        dfst(n, a, t, ip, w);\n    [parameters]\n        n              :data length + 1 (int)\n                        n >= 2, n = power of 2\n        a[0...n-1]     :input/output data (FLOAT_TYPE_FFT *)\n                        output data\n                            a[k] = S[k], 0<k<n\n                        (a[0] is used for work area)\n        t[0...n/2-1]   :work area (FLOAT_TYPE_FFT *)\n        ip[0...*]      :work area for bit reversal (int *)\n                        length of ip >= 2+sqrt(n/4)\n                        strictly, \n                        length of ip >= \n                            2+(1<<(int)(log(n/4+0.5)/log(2))/2).\n                        ip[0],ip[1] are pointers of the cos/sin table.\n        w[0...n*5/8-1] :cos/sin table (FLOAT_TYPE_FFT *)\n                        w[],ip[] are initialized if ip[0] == 0.\n    [remark]\n        Inverse of \n            dfst(n, a, t, ip, w);\n        is \n            dfst(n, a, t, ip, w);\n            for (j = 1; j <= n - 1; j++) {\n                a[j] *= 2.0 / n;\n            }\n        .\n\n\nAppendix :\n    The cos/sin table is recalculated when the larger table required.\n    w[] and ip[] are compatible with all routines.\n*/\n\n#include <dspcore/fftXg.h>\n\nvoid cdft(int n, int isgn, FLOAT_TYPE_FFT *a, int *ip, FLOAT_TYPE_FFT *w)\n{\n    void makewt(int nw, int *ip, FLOAT_TYPE_FFT *w);\n    void bitrv2(int n, int *ip, FLOAT_TYPE_FFT *a);\n    void bitrv2conj(int n, int *ip, FLOAT_TYPE_FFT *a);\n    void cftfsub(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void cftbsub(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    \n    if (n > (ip[0] << 2)) {\n        makewt(n >> 2, ip, w);\n    }\n    if (n > 4) {\n        if (isgn >= 0) {\n            bitrv2(n, ip + 2, a);\n            cftfsub(n, a, w);\n        } else {\n            bitrv2conj(n, ip + 2, a);\n            cftbsub(n, a, w);\n        }\n    } else if (n == 4) {\n        cftfsub(n, a, w);\n    }\n}\n\n\nvoid rdft(int n, int isgn, FLOAT_TYPE_FFT *a, int *ip, FLOAT_TYPE_FFT *w)\n{\n    void makewt(int nw, int *ip, FLOAT_TYPE_FFT *w);\n    void makect(int nc, int *ip, FLOAT_TYPE_FFT *c);\n    void bitrv2(int n, int *ip, FLOAT_TYPE_FFT *a);\n    void cftfsub(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void cftbsub(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void rftfsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c);\n    void rftbsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c);\n    int nw, nc;\n    FLOAT_TYPE_FFT xi;\n    \n    nw = ip[0];\n    if (n > (nw << 2)) {\n        nw = n >> 2;\n        makewt(nw, ip, w);\n    }\n    nc = ip[1];\n    if (n > (nc << 2)) {\n        nc = n >> 2;\n        makect(nc, ip, w + nw);\n    }\n    if (isgn >= 0) {\n        if (n > 4) {\n            bitrv2(n, ip + 2, a);\n            cftfsub(n, a, w);\n            rftfsub(n, a, nc, w + nw);\n        } else if (n == 4) {\n            cftfsub(n, a, w);\n        }\n        xi = a[0] - a[1];\n        a[0] += a[1];\n        a[1] = xi;\n    } else {\n        a[1] = 0.5 * (a[0] - a[1]);\n        a[0] -= a[1];\n        if (n > 4) {\n            rftbsub(n, a, nc, w + nw);\n            bitrv2(n, ip + 2, a);\n            cftbsub(n, a, w);\n        } else if (n == 4) {\n            cftfsub(n, a, w);\n        }\n    }\n}\n\n\nvoid ddct(int n, int isgn, FLOAT_TYPE_FFT *a, int *ip, FLOAT_TYPE_FFT *w)\n{\n    void makewt(int nw, int *ip, FLOAT_TYPE_FFT *w);\n    void makect(int nc, int *ip, FLOAT_TYPE_FFT *c);\n    void bitrv2(int n, int *ip, FLOAT_TYPE_FFT *a);\n    void cftfsub(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void cftbsub(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void rftfsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c);\n    void rftbsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c);\n    void dctsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c);\n    int j, nw, nc;\n    FLOAT_TYPE_FFT xr;\n    \n    nw = ip[0];\n    if (n > (nw << 2)) {\n        nw = n >> 2;\n        makewt(nw, ip, w);\n    }\n    nc = ip[1];\n    if (n > nc) {\n        nc = n;\n        makect(nc, ip, w + nw);\n    }\n    if (isgn < 0) {\n        xr = a[n - 1];\n        for (j = n - 2; j >= 2; j -= 2) {\n            a[j + 1] = a[j] - a[j - 1];\n            a[j] += a[j - 1];\n        }\n        a[1] = a[0] - xr;\n        a[0] += xr;\n        if (n > 4) {\n            rftbsub(n, a, nc, w + nw);\n            bitrv2(n, ip + 2, a);\n            cftbsub(n, a, w);\n        } else if (n == 4) {\n            cftfsub(n, a, w);\n        }\n    }\n    dctsub(n, a, nc, w + nw);\n    if (isgn >= 0) {\n        if (n > 4) {\n            bitrv2(n, ip + 2, a);\n            cftfsub(n, a, w);\n            rftfsub(n, a, nc, w + nw);\n        } else if (n == 4) {\n            cftfsub(n, a, w);\n        }\n        xr = a[0] - a[1];\n        a[0] += a[1];\n        for (j = 2; j < n; j += 2) {\n            a[j - 1] = a[j] - a[j + 1];\n            a[j] += a[j + 1];\n        }\n        a[n - 1] = xr;\n    }\n}\n\n\nvoid ddst(int n, int isgn, FLOAT_TYPE_FFT *a, int *ip, FLOAT_TYPE_FFT *w)\n{\n    void makewt(int nw, int *ip, FLOAT_TYPE_FFT *w);\n    void makect(int nc, int *ip, FLOAT_TYPE_FFT *c);\n    void bitrv2(int n, int *ip, FLOAT_TYPE_FFT *a);\n    void cftfsub(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void cftbsub(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void rftfsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c);\n    void rftbsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c);\n    void dstsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c);\n    int j, nw, nc;\n    FLOAT_TYPE_FFT xr;\n    \n    nw = ip[0];\n    if (n > (nw << 2)) {\n        nw = n >> 2;\n        makewt(nw, ip, w);\n    }\n    nc = ip[1];\n    if (n > nc) {\n        nc = n;\n        makect(nc, ip, w + nw);\n    }\n    if (isgn < 0) {\n        xr = a[n - 1];\n        for (j = n - 2; j >= 2; j -= 2) {\n            a[j + 1] = -a[j] - a[j - 1];\n            a[j] -= a[j - 1];\n        }\n        a[1] = a[0] + xr;\n        a[0] -= xr;\n        if (n > 4) {\n            rftbsub(n, a, nc, w + nw);\n            bitrv2(n, ip + 2, a);\n            cftbsub(n, a, w);\n        } else if (n == 4) {\n            cftfsub(n, a, w);\n        }\n    }\n    dstsub(n, a, nc, w + nw);\n    if (isgn >= 0) {\n        if (n > 4) {\n            bitrv2(n, ip + 2, a);\n            cftfsub(n, a, w);\n            rftfsub(n, a, nc, w + nw);\n        } else if (n == 4) {\n            cftfsub(n, a, w);\n        }\n        xr = a[0] - a[1];\n        a[0] += a[1];\n        for (j = 2; j < n; j += 2) {\n            a[j - 1] = -a[j] - a[j + 1];\n            a[j] -= a[j + 1];\n        }\n        a[n - 1] = -xr;\n    }\n}\n\n\nvoid dfct(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *t, int *ip, FLOAT_TYPE_FFT *w)\n{\n    void makewt(int nw, int *ip, FLOAT_TYPE_FFT *w);\n    void makect(int nc, int *ip, FLOAT_TYPE_FFT *c);\n    void bitrv2(int n, int *ip, FLOAT_TYPE_FFT *a);\n    void cftfsub(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void rftfsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c);\n    void dctsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c);\n    int j, k, l, m, mh, nw, nc;\n    FLOAT_TYPE_FFT xr, xi, yr, yi;\n    \n    nw = ip[0];\n    if (n > (nw << 3)) {\n        nw = n >> 3;\n        makewt(nw, ip, w);\n    }\n    nc = ip[1];\n    if (n > (nc << 1)) {\n        nc = n >> 1;\n        makect(nc, ip, w + nw);\n    }\n    m = n >> 1;\n    yi = a[m];\n    xi = a[0] + a[n];\n    a[0] -= a[n];\n    t[0] = xi - yi;\n    t[m] = xi + yi;\n    if (n > 2) {\n        mh = m >> 1;\n        for (j = 1; j < mh; j++) {\n            k = m - j;\n            xr = a[j] - a[n - j];\n            xi = a[j] + a[n - j];\n            yr = a[k] - a[n - k];\n            yi = a[k] + a[n - k];\n            a[j] = xr;\n            a[k] = yr;\n            t[j] = xi - yi;\n            t[k] = xi + yi;\n        }\n        t[mh] = a[mh] + a[n - mh];\n        a[mh] -= a[n - mh];\n        dctsub(m, a, nc, w + nw);\n        if (m > 4) {\n            bitrv2(m, ip + 2, a);\n            cftfsub(m, a, w);\n            rftfsub(m, a, nc, w + nw);\n        } else if (m == 4) {\n            cftfsub(m, a, w);\n        }\n        a[n - 1] = a[0] - a[1];\n        a[1] = a[0] + a[1];\n        for (j = m - 2; j >= 2; j -= 2) {\n            a[2 * j + 1] = a[j] + a[j + 1];\n            a[2 * j - 1] = a[j] - a[j + 1];\n        }\n        l = 2;\n        m = mh;\n        while (m >= 2) {\n            dctsub(m, t, nc, w + nw);\n            if (m > 4) {\n                bitrv2(m, ip + 2, t);\n                cftfsub(m, t, w);\n                rftfsub(m, t, nc, w + nw);\n            } else if (m == 4) {\n                cftfsub(m, t, w);\n            }\n            a[n - l] = t[0] - t[1];\n            a[l] = t[0] + t[1];\n            k = 0;\n            for (j = 2; j < m; j += 2) {\n                k += l << 2;\n                a[k - l] = t[j] - t[j + 1];\n                a[k + l] = t[j] + t[j + 1];\n            }\n            l <<= 1;\n            mh = m >> 1;\n            for (j = 0; j < mh; j++) {\n                k = m - j;\n                t[j] = t[m + k] - t[m + j];\n                t[k] = t[m + k] + t[m + j];\n            }\n            t[mh] = t[m + mh];\n            m = mh;\n        }\n        a[l] = t[0];\n        a[n] = t[2] - t[1];\n        a[0] = t[2] + t[1];\n    } else {\n        a[1] = a[0];\n        a[2] = t[0];\n        a[0] = t[1];\n    }\n}\n\n\nvoid dfst(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *t, int *ip, FLOAT_TYPE_FFT *w)\n{\n    void makewt(int nw, int *ip, FLOAT_TYPE_FFT *w);\n    void makect(int nc, int *ip, FLOAT_TYPE_FFT *c);\n    void bitrv2(int n, int *ip, FLOAT_TYPE_FFT *a);\n    void cftfsub(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void rftfsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c);\n    void dstsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c);\n    int j, k, l, m, mh, nw, nc;\n    FLOAT_TYPE_FFT xr, xi, yr, yi;\n    \n    nw = ip[0];\n    if (n > (nw << 3)) {\n        nw = n >> 3;\n        makewt(nw, ip, w);\n    }\n    nc = ip[1];\n    if (n > (nc << 1)) {\n        nc = n >> 1;\n        makect(nc, ip, w + nw);\n    }\n    if (n > 2) {\n        m = n >> 1;\n        mh = m >> 1;\n        for (j = 1; j < mh; j++) {\n            k = m - j;\n            xr = a[j] + a[n - j];\n            xi = a[j] - a[n - j];\n            yr = a[k] + a[n - k];\n            yi = a[k] - a[n - k];\n            a[j] = xr;\n            a[k] = yr;\n            t[j] = xi + yi;\n            t[k] = xi - yi;\n        }\n        t[0] = a[mh] - a[n - mh];\n        a[mh] += a[n - mh];\n        a[0] = a[m];\n        dstsub(m, a, nc, w + nw);\n        if (m > 4) {\n            bitrv2(m, ip + 2, a);\n            cftfsub(m, a, w);\n            rftfsub(m, a, nc, w + nw);\n        } else if (m == 4) {\n            cftfsub(m, a, w);\n        }\n        a[n - 1] = a[1] - a[0];\n        a[1] = a[0] + a[1];\n        for (j = m - 2; j >= 2; j -= 2) {\n            a[2 * j + 1] = a[j] - a[j + 1];\n            a[2 * j - 1] = -a[j] - a[j + 1];\n        }\n        l = 2;\n        m = mh;\n        while (m >= 2) {\n            dstsub(m, t, nc, w + nw);\n            if (m > 4) {\n                bitrv2(m, ip + 2, t);\n                cftfsub(m, t, w);\n                rftfsub(m, t, nc, w + nw);\n            } else if (m == 4) {\n                cftfsub(m, t, w);\n            }\n            a[n - l] = t[1] - t[0];\n            a[l] = t[0] + t[1];\n            k = 0;\n            for (j = 2; j < m; j += 2) {\n                k += l << 2;\n                a[k - l] = -t[j] - t[j + 1];\n                a[k + l] = t[j] - t[j + 1];\n            }\n            l <<= 1;\n            mh = m >> 1;\n            for (j = 1; j < mh; j++) {\n                k = m - j;\n                t[j] = t[m + k] + t[m + j];\n                t[k] = t[m + k] - t[m + j];\n            }\n            t[0] = t[m + mh];\n            m = mh;\n        }\n        a[l] = t[0];\n    }\n    a[0] = 0;\n}\n\n\n/* -------- initializing routines -------- */\n\n\n#include <math.h>\n\nvoid makewt(int nw, int *ip, FLOAT_TYPE_FFT *w)\n{\n    void bitrv2(int n, int *ip, FLOAT_TYPE_FFT *a);\n    int j, nwh;\n    FLOAT_TYPE_FFT delta, x, y;\n    \n    ip[0] = nw;\n    ip[1] = 1;\n    if (nw > 2) {\n        nwh = nw >> 1;\n        delta = atan(1.0) / nwh;\n        w[0] = 1;\n        w[1] = 0;\n        w[nwh] = cos(delta * nwh);\n        w[nwh + 1] = w[nwh];\n        if (nwh > 2) {\n            for (j = 2; j < nwh; j += 2) {\n                x = cos(delta * j);\n                y = sin(delta * j);\n                w[j] = x;\n                w[j + 1] = y;\n                w[nw - j] = y;\n                w[nw - j + 1] = x;\n            }\n            bitrv2(nw, ip + 2, w);\n        }\n    }\n}\n\n\nvoid makect(int nc, int *ip, FLOAT_TYPE_FFT *c)\n{\n    int j, nch;\n    FLOAT_TYPE_FFT delta;\n    \n    ip[1] = nc;\n    if (nc > 1) {\n        nch = nc >> 1;\n        delta = atan(1.0) / nch;\n        c[0] = cos(delta * nch);\n        c[nch] = 0.5 * c[0];\n        for (j = 1; j < nch; j++) {\n            c[j] = 0.5 * cos(delta * j);\n            c[nc - j] = 0.5 * sin(delta * j);\n        }\n    }\n}\n\n\n/* -------- child routines -------- */\n\n\nvoid bitrv2(int n, int *ip, FLOAT_TYPE_FFT *a)\n{\n    int j, j1, k, k1, l, m, m2;\n    FLOAT_TYPE_FFT xr, xi, yr, yi;\n    \n    ip[0] = 0;\n    l = n;\n    m = 1;\n    while ((m << 3) < l) {\n        l >>= 1;\n        for (j = 0; j < m; j++) {\n            ip[m + j] = ip[j] + l;\n        }\n        m <<= 1;\n    }\n    m2 = 2 * m;\n    if ((m << 3) == l) {\n        for (k = 0; k < m; k++) {\n            for (j = 0; j < k; j++) {\n                j1 = 2 * j + ip[k];\n                k1 = 2 * k + ip[j];\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += m2;\n                k1 += 2 * m2;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += m2;\n                k1 -= m2;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += m2;\n                k1 += 2 * m2;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n            }\n            j1 = 2 * k + m2 + ip[k];\n            k1 = j1 + m2;\n            xr = a[j1];\n            xi = a[j1 + 1];\n            yr = a[k1];\n            yi = a[k1 + 1];\n            a[j1] = yr;\n            a[j1 + 1] = yi;\n            a[k1] = xr;\n            a[k1 + 1] = xi;\n        }\n    } else {\n        for (k = 1; k < m; k++) {\n            for (j = 0; j < k; j++) {\n                j1 = 2 * j + ip[k];\n                k1 = 2 * k + ip[j];\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += m2;\n                k1 += m2;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n            }\n        }\n    }\n}\n\n\nvoid bitrv2conj(int n, int *ip, FLOAT_TYPE_FFT *a)\n{\n    int j, j1, k, k1, l, m, m2;\n    FLOAT_TYPE_FFT xr, xi, yr, yi;\n    \n    ip[0] = 0;\n    l = n;\n    m = 1;\n    while ((m << 3) < l) {\n        l >>= 1;\n        for (j = 0; j < m; j++) {\n            ip[m + j] = ip[j] + l;\n        }\n        m <<= 1;\n    }\n    m2 = 2 * m;\n    if ((m << 3) == l) {\n        for (k = 0; k < m; k++) {\n            for (j = 0; j < k; j++) {\n                j1 = 2 * j + ip[k];\n                k1 = 2 * k + ip[j];\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += m2;\n                k1 += 2 * m2;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += m2;\n                k1 -= m2;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += m2;\n                k1 += 2 * m2;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n            }\n            k1 = 2 * k + ip[k];\n            a[k1 + 1] = -a[k1 + 1];\n            j1 = k1 + m2;\n            k1 = j1 + m2;\n            xr = a[j1];\n            xi = -a[j1 + 1];\n            yr = a[k1];\n            yi = -a[k1 + 1];\n            a[j1] = yr;\n            a[j1 + 1] = yi;\n            a[k1] = xr;\n            a[k1 + 1] = xi;\n            k1 += m2;\n            a[k1 + 1] = -a[k1 + 1];\n        }\n    } else {\n        a[1] = -a[1];\n        a[m2 + 1] = -a[m2 + 1];\n        for (k = 1; k < m; k++) {\n            for (j = 0; j < k; j++) {\n                j1 = 2 * j + ip[k];\n                k1 = 2 * k + ip[j];\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += m2;\n                k1 += m2;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n            }\n            k1 = 2 * k + ip[k];\n            a[k1 + 1] = -a[k1 + 1];\n            a[k1 + m2 + 1] = -a[k1 + m2 + 1];\n        }\n    }\n}\n\n\nvoid cftfsub(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w)\n{\n    void cft1st(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void cftmdl(int n, int l, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    int j, j1, j2, j3, l;\n    FLOAT_TYPE_FFT x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;\n    \n    l = 2;\n    if (n > 8) {\n        cft1st(n, a, w);\n        l = 8;\n        while ((l << 2) < n) {\n            cftmdl(n, l, a, w);\n            l <<= 2;\n        }\n    }\n    if ((l << 2) == n) {\n        for (j = 0; j < l; j += 2) {\n            j1 = j + l;\n            j2 = j1 + l;\n            j3 = j2 + l;\n            x0r = a[j] + a[j1];\n            x0i = a[j + 1] + a[j1 + 1];\n            x1r = a[j] - a[j1];\n            x1i = a[j + 1] - a[j1 + 1];\n            x2r = a[j2] + a[j3];\n            x2i = a[j2 + 1] + a[j3 + 1];\n            x3r = a[j2] - a[j3];\n            x3i = a[j2 + 1] - a[j3 + 1];\n            a[j] = x0r + x2r;\n            a[j + 1] = x0i + x2i;\n            a[j2] = x0r - x2r;\n            a[j2 + 1] = x0i - x2i;\n            a[j1] = x1r - x3i;\n            a[j1 + 1] = x1i + x3r;\n            a[j3] = x1r + x3i;\n            a[j3 + 1] = x1i - x3r;\n        }\n    } else {\n        for (j = 0; j < l; j += 2) {\n            j1 = j + l;\n            x0r = a[j] - a[j1];\n            x0i = a[j + 1] - a[j1 + 1];\n            a[j] += a[j1];\n            a[j + 1] += a[j1 + 1];\n            a[j1] = x0r;\n            a[j1 + 1] = x0i;\n        }\n    }\n}\n\n\nvoid cftbsub(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w)\n{\n    void cft1st(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void cftmdl(int n, int l, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    int j, j1, j2, j3, l;\n    FLOAT_TYPE_FFT x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;\n    \n    l = 2;\n    if (n > 8) {\n        cft1st(n, a, w);\n        l = 8;\n        while ((l << 2) < n) {\n            cftmdl(n, l, a, w);\n            l <<= 2;\n        }\n    }\n    if ((l << 2) == n) {\n        for (j = 0; j < l; j += 2) {\n            j1 = j + l;\n            j2 = j1 + l;\n            j3 = j2 + l;\n            x0r = a[j] + a[j1];\n            x0i = -a[j + 1] - a[j1 + 1];\n            x1r = a[j] - a[j1];\n            x1i = -a[j + 1] + a[j1 + 1];\n            x2r = a[j2] + a[j3];\n            x2i = a[j2 + 1] + a[j3 + 1];\n            x3r = a[j2] - a[j3];\n            x3i = a[j2 + 1] - a[j3 + 1];\n            a[j] = x0r + x2r;\n            a[j + 1] = x0i - x2i;\n            a[j2] = x0r - x2r;\n            a[j2 + 1] = x0i + x2i;\n            a[j1] = x1r - x3i;\n            a[j1 + 1] = x1i - x3r;\n            a[j3] = x1r + x3i;\n            a[j3 + 1] = x1i + x3r;\n        }\n    } else {\n        for (j = 0; j < l; j += 2) {\n            j1 = j + l;\n            x0r = a[j] - a[j1];\n            x0i = -a[j + 1] + a[j1 + 1];\n            a[j] += a[j1];\n            a[j + 1] = -a[j + 1] - a[j1 + 1];\n            a[j1] = x0r;\n            a[j1 + 1] = x0i;\n        }\n    }\n}\n\n\nvoid cft1st(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w)\n{\n    int j, k1, k2;\n    FLOAT_TYPE_FFT wk1r, wk1i, wk2r, wk2i, wk3r, wk3i;\n    FLOAT_TYPE_FFT x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;\n    \n    x0r = a[0] + a[2];\n    x0i = a[1] + a[3];\n    x1r = a[0] - a[2];\n    x1i = a[1] - a[3];\n    x2r = a[4] + a[6];\n    x2i = a[5] + a[7];\n    x3r = a[4] - a[6];\n    x3i = a[5] - a[7];\n    a[0] = x0r + x2r;\n    a[1] = x0i + x2i;\n    a[4] = x0r - x2r;\n    a[5] = x0i - x2i;\n    a[2] = x1r - x3i;\n    a[3] = x1i + x3r;\n    a[6] = x1r + x3i;\n    a[7] = x1i - x3r;\n    wk1r = w[2];\n    x0r = a[8] + a[10];\n    x0i = a[9] + a[11];\n    x1r = a[8] - a[10];\n    x1i = a[9] - a[11];\n    x2r = a[12] + a[14];\n    x2i = a[13] + a[15];\n    x3r = a[12] - a[14];\n    x3i = a[13] - a[15];\n    a[8] = x0r + x2r;\n    a[9] = x0i + x2i;\n    a[12] = x2i - x0i;\n    a[13] = x0r - x2r;\n    x0r = x1r - x3i;\n    x0i = x1i + x3r;\n    a[10] = wk1r * (x0r - x0i);\n    a[11] = wk1r * (x0r + x0i);\n    x0r = x3i + x1r;\n    x0i = x3r - x1i;\n    a[14] = wk1r * (x0i - x0r);\n    a[15] = wk1r * (x0i + x0r);\n    k1 = 0;\n    for (j = 16; j < n; j += 16) {\n        k1 += 2;\n        k2 = 2 * k1;\n        wk2r = w[k1];\n        wk2i = w[k1 + 1];\n        wk1r = w[k2];\n        wk1i = w[k2 + 1];\n        wk3r = wk1r - 2 * wk2i * wk1i;\n        wk3i = 2 * wk2i * wk1r - wk1i;\n        x0r = a[j] + a[j + 2];\n        x0i = a[j + 1] + a[j + 3];\n        x1r = a[j] - a[j + 2];\n        x1i = a[j + 1] - a[j + 3];\n        x2r = a[j + 4] + a[j + 6];\n        x2i = a[j + 5] + a[j + 7];\n        x3r = a[j + 4] - a[j + 6];\n        x3i = a[j + 5] - a[j + 7];\n        a[j] = x0r + x2r;\n        a[j + 1] = x0i + x2i;\n        x0r -= x2r;\n        x0i -= x2i;\n        a[j + 4] = wk2r * x0r - wk2i * x0i;\n        a[j + 5] = wk2r * x0i + wk2i * x0r;\n        x0r = x1r - x3i;\n        x0i = x1i + x3r;\n        a[j + 2] = wk1r * x0r - wk1i * x0i;\n        a[j + 3] = wk1r * x0i + wk1i * x0r;\n        x0r = x1r + x3i;\n        x0i = x1i - x3r;\n        a[j + 6] = wk3r * x0r - wk3i * x0i;\n        a[j + 7] = wk3r * x0i + wk3i * x0r;\n        wk1r = w[k2 + 2];\n        wk1i = w[k2 + 3];\n        wk3r = wk1r - 2 * wk2r * wk1i;\n        wk3i = 2 * wk2r * wk1r - wk1i;\n        x0r = a[j + 8] + a[j + 10];\n        x0i = a[j + 9] + a[j + 11];\n        x1r = a[j + 8] - a[j + 10];\n        x1i = a[j + 9] - a[j + 11];\n        x2r = a[j + 12] + a[j + 14];\n        x2i = a[j + 13] + a[j + 15];\n        x3r = a[j + 12] - a[j + 14];\n        x3i = a[j + 13] - a[j + 15];\n        a[j + 8] = x0r + x2r;\n        a[j + 9] = x0i + x2i;\n        x0r -= x2r;\n        x0i -= x2i;\n        a[j + 12] = -wk2i * x0r - wk2r * x0i;\n        a[j + 13] = -wk2i * x0i + wk2r * x0r;\n        x0r = x1r - x3i;\n        x0i = x1i + x3r;\n        a[j + 10] = wk1r * x0r - wk1i * x0i;\n        a[j + 11] = wk1r * x0i + wk1i * x0r;\n        x0r = x1r + x3i;\n        x0i = x1i - x3r;\n        a[j + 14] = wk3r * x0r - wk3i * x0i;\n        a[j + 15] = wk3r * x0i + wk3i * x0r;\n    }\n}\n\n\nvoid cftmdl(int n, int l, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w)\n{\n    int j, j1, j2, j3, k, k1, k2, m, m2;\n    FLOAT_TYPE_FFT wk1r, wk1i, wk2r, wk2i, wk3r, wk3i;\n    FLOAT_TYPE_FFT x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;\n    \n    m = l << 2;\n    for (j = 0; j < l; j += 2) {\n        j1 = j + l;\n        j2 = j1 + l;\n        j3 = j2 + l;\n        x0r = a[j] + a[j1];\n        x0i = a[j + 1] + a[j1 + 1];\n        x1r = a[j] - a[j1];\n        x1i = a[j + 1] - a[j1 + 1];\n        x2r = a[j2] + a[j3];\n        x2i = a[j2 + 1] + a[j3 + 1];\n        x3r = a[j2] - a[j3];\n        x3i = a[j2 + 1] - a[j3 + 1];\n        a[j] = x0r + x2r;\n        a[j + 1] = x0i + x2i;\n        a[j2] = x0r - x2r;\n        a[j2 + 1] = x0i - x2i;\n        a[j1] = x1r - x3i;\n        a[j1 + 1] = x1i + x3r;\n        a[j3] = x1r + x3i;\n        a[j3 + 1] = x1i - x3r;\n    }\n    wk1r = w[2];\n    for (j = m; j < l + m; j += 2) {\n        j1 = j + l;\n        j2 = j1 + l;\n        j3 = j2 + l;\n        x0r = a[j] + a[j1];\n        x0i = a[j + 1] + a[j1 + 1];\n        x1r = a[j] - a[j1];\n        x1i = a[j + 1] - a[j1 + 1];\n        x2r = a[j2] + a[j3];\n        x2i = a[j2 + 1] + a[j3 + 1];\n        x3r = a[j2] - a[j3];\n        x3i = a[j2 + 1] - a[j3 + 1];\n        a[j] = x0r + x2r;\n        a[j + 1] = x0i + x2i;\n        a[j2] = x2i - x0i;\n        a[j2 + 1] = x0r - x2r;\n        x0r = x1r - x3i;\n        x0i = x1i + x3r;\n        a[j1] = wk1r * (x0r - x0i);\n        a[j1 + 1] = wk1r * (x0r + x0i);\n        x0r = x3i + x1r;\n        x0i = x3r - x1i;\n        a[j3] = wk1r * (x0i - x0r);\n        a[j3 + 1] = wk1r * (x0i + x0r);\n    }\n    k1 = 0;\n    m2 = 2 * m;\n    for (k = m2; k < n; k += m2) {\n        k1 += 2;\n        k2 = 2 * k1;\n        wk2r = w[k1];\n        wk2i = w[k1 + 1];\n        wk1r = w[k2];\n        wk1i = w[k2 + 1];\n        wk3r = wk1r - 2 * wk2i * wk1i;\n        wk3i = 2 * wk2i * wk1r - wk1i;\n        for (j = k; j < l + k; j += 2) {\n            j1 = j + l;\n            j2 = j1 + l;\n            j3 = j2 + l;\n            x0r = a[j] + a[j1];\n            x0i = a[j + 1] + a[j1 + 1];\n            x1r = a[j] - a[j1];\n            x1i = a[j + 1] - a[j1 + 1];\n            x2r = a[j2] + a[j3];\n            x2i = a[j2 + 1] + a[j3 + 1];\n            x3r = a[j2] - a[j3];\n            x3i = a[j2 + 1] - a[j3 + 1];\n            a[j] = x0r + x2r;\n            a[j + 1] = x0i + x2i;\n            x0r -= x2r;\n            x0i -= x2i;\n            a[j2] = wk2r * x0r - wk2i * x0i;\n            a[j2 + 1] = wk2r * x0i + wk2i * x0r;\n            x0r = x1r - x3i;\n            x0i = x1i + x3r;\n            a[j1] = wk1r * x0r - wk1i * x0i;\n            a[j1 + 1] = wk1r * x0i + wk1i * x0r;\n            x0r = x1r + x3i;\n            x0i = x1i - x3r;\n            a[j3] = wk3r * x0r - wk3i * x0i;\n            a[j3 + 1] = wk3r * x0i + wk3i * x0r;\n        }\n        wk1r = w[k2 + 2];\n        wk1i = w[k2 + 3];\n        wk3r = wk1r - 2 * wk2r * wk1i;\n        wk3i = 2 * wk2r * wk1r - wk1i;\n        for (j = k + m; j < l + (k + m); j += 2) {\n            j1 = j + l;\n            j2 = j1 + l;\n            j3 = j2 + l;\n            x0r = a[j] + a[j1];\n            x0i = a[j + 1] + a[j1 + 1];\n            x1r = a[j] - a[j1];\n            x1i = a[j + 1] - a[j1 + 1];\n            x2r = a[j2] + a[j3];\n            x2i = a[j2 + 1] + a[j3 + 1];\n            x3r = a[j2] - a[j3];\n            x3i = a[j2 + 1] - a[j3 + 1];\n            a[j] = x0r + x2r;\n            a[j + 1] = x0i + x2i;\n            x0r -= x2r;\n            x0i -= x2i;\n            a[j2] = -wk2i * x0r - wk2r * x0i;\n            a[j2 + 1] = -wk2i * x0i + wk2r * x0r;\n            x0r = x1r - x3i;\n            x0i = x1i + x3r;\n            a[j1] = wk1r * x0r - wk1i * x0i;\n            a[j1 + 1] = wk1r * x0i + wk1i * x0r;\n            x0r = x1r + x3i;\n            x0i = x1i - x3r;\n            a[j3] = wk3r * x0r - wk3i * x0i;\n            a[j3 + 1] = wk3r * x0i + wk3i * x0r;\n        }\n    }\n}\n\n\nvoid rftfsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c)\n{\n    int j, k, kk, ks, m;\n    FLOAT_TYPE_FFT wkr, wki, xr, xi, yr, yi;\n    \n    m = n >> 1;\n    ks = 2 * nc / m;\n    kk = 0;\n    for (j = 2; j < m; j += 2) {\n        k = n - j;\n        kk += ks;\n        wkr = 0.5 - c[nc - kk];\n        wki = c[kk];\n        xr = a[j] - a[k];\n        xi = a[j + 1] + a[k + 1];\n        yr = wkr * xr - wki * xi;\n        yi = wkr * xi + wki * xr;\n        a[j] -= yr;\n        a[j + 1] -= yi;\n        a[k] += yr;\n        a[k + 1] -= yi;\n    }\n}\n\n\nvoid rftbsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c)\n{\n    int j, k, kk, ks, m;\n    FLOAT_TYPE_FFT wkr, wki, xr, xi, yr, yi;\n    \n    a[1] = -a[1];\n    m = n >> 1;\n    ks = 2 * nc / m;\n    kk = 0;\n    for (j = 2; j < m; j += 2) {\n        k = n - j;\n        kk += ks;\n        wkr = 0.5 - c[nc - kk];\n        wki = c[kk];\n        xr = a[j] - a[k];\n        xi = a[j + 1] + a[k + 1];\n        yr = wkr * xr + wki * xi;\n        yi = wkr * xi - wki * xr;\n        a[j] -= yr;\n        a[j + 1] = yi - a[j + 1];\n        a[k] += yr;\n        a[k + 1] = yi - a[k + 1];\n    }\n    a[m + 1] = -a[m + 1];\n}\n\n\nvoid dctsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c)\n{\n    int j, k, kk, ks, m;\n    FLOAT_TYPE_FFT wkr, wki, xr;\n    \n    m = n >> 1;\n    ks = nc / n;\n    kk = 0;\n    for (j = 1; j < m; j++) {\n        k = n - j;\n        kk += ks;\n        wkr = c[kk] - c[nc - kk];\n        wki = c[kk] + c[nc - kk];\n        xr = wki * a[j] - wkr * a[k];\n        a[j] = wkr * a[j] + wki * a[k];\n        a[k] = xr;\n    }\n    a[m] *= c[0];\n}\n\n\nvoid dstsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c)\n{\n    int j, k, kk, ks, m;\n    FLOAT_TYPE_FFT wkr, wki, xr;\n    \n    m = n >> 1;\n    ks = nc / n;\n    kk = 0;\n    for (j = 1; j < m; j++) {\n        k = n - j;\n        kk += ks;\n        wkr = c[kk] - c[nc - kk];\n        wki = c[kk] + c[nc - kk];\n        xr = wki * a[k] - wkr * a[j];\n        a[k] = wkr * a[k] + wki * a[j];\n        a[j] = xr;\n    }\n    a[m] *= c[0];\n}\n\n"
  },
  {
    "path": "src/dspcore/fftmagphase.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\ncompute magnitude and phase from complex valued fft output\nTODO: support inverse??\n \n*/\n\n\n#include <dspcore/fftmagphase.hpp>\n#include <math.h>\n\n#define MODULE \"cFFTmagphase\"\n\n/*Library:\nsComponentInfo * registerMe(cConfigManager *_confman) {\n  cDataProcessor::registerComponent(_confman);\n}\n*/\n\nSMILECOMPONENT_STATICS(cFFTmagphase)\n\nSMILECOMPONENT_REGCOMP(cFFTmagphase)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CFFTMAGPHASE;\n  sdescription = COMPONENT_DESCRIPTION_CFFTMAGPHASE;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"inverse\",\"If set to 1, converts magnitude and phase input data to complex frequency domain data\",0);\n    ct->setField(\"magnitude\",\"1/0 = compute magnitude yes/no (or use magnitude as input to inverse transformation, must be enabled for inverse)\",1);\n    ct->setField(\"phase\",\"1/0 = compute phase yes/no (or use phase as input to inverse transformation, must be enabled for inverse)\",0);\n    ct->setField(\"joinMagphase\",\"Output magnitude and phase information to a single array field (instead of creating two array fields, one for magnitude and one for phase information). The first half contains magnitude values, the second half phase values.\",0);\n\n    ct->setField(\"normalise\",\"1/0 = yes/no: normalise FFT magnitudes to input window length, to obtain spectral densities.\",0);\n    ct->setField(\"power\",\"1/0 = yes/no: square FFT magnitudes to obtain power spectrum.\",0);\n\n    ct->setField(\"dBpsd\",\"1/0 = yes/no: output logarithmic (dB SPL) power spectral density instead of linear magnitude spectrum (you should use a Hann window for analysis in this case). Setting this option also sets/implies 'normalise=1' and 'power=1'\",0);\n    ct->setField(\"dBpnorm\",\"Value for dB power normalisation when 'dBpsd=1' (in dB SPL). Default is according to MPEG-1, psy I model.\",90.302);\n    ct->setField(\"mindBp\", \"Minimum dB power value for flooring when using dBpsd. (mindBp - dBpnorm < -120.0) will be enforced, so mindBp might be higher than set here, depending on dBpnorm parameter.\", -102.0);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cFFTmagphase);\n}\n\nSMILECOMPONENT_CREATE(cFFTmagphase)\n\n//-----\n\n\ncFFTmagphase::cFFTmagphase(const char *_name) :\n  cVectorProcessor(_name),\n  magnitude(1),\n  phase(0)\n{\n\n}\n\nvoid cFFTmagphase::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n  \n  inverse = getInt(\"inverse\");\n  magnitude = getInt(\"magnitude\");\n  phase = getInt(\"phase\");\n  joinMagphase = getInt(\"joinMagphase\");\n\n  if ((!magnitude)&&(!phase)&&(!power)&&(!dBpsd)) { magnitude = 1; }\n  if (magnitude) { SMILE_IDBG(2,\"magnitude computation enabled\"); }\n  if (phase) { SMILE_IDBG(2,\"phase computation enabled\"); }\n  if (inverse) { \n    SMILE_IDBG(2,\"inverse mode selected\"); \n    if (!(magnitude&&phase)) {\n      SMILE_IERR(1,\"we need magnitude AND phase as inputs for inverse fftmagphase. Thus you need to provide the phase with the input AND enable the option 'phase' in the config file!\");\n      COMP_ERR(\"aborting\");\n    }\n  }\n\n  power = getInt(\"power\");\n  if (power) { magnitude = 1; }\n  normalise = getInt(\"normalise\");\n  dBpsd = getInt(\"dBpsd\");\n  if (dBpsd) { normalise = 1; magnitude = 1; }\n  dBpnorm = (FLOAT_DMEM)getDouble(\"dBpnorm\");\n  mindBp = (FLOAT_DMEM)getDouble(\"mindBp\");\n  if (mindBp - dBpnorm < -120.0) {\n    mindBp = -120 + dBpnorm;\n    SMILE_IMSG(3, \"mindBp = %f\", mindBp);\n  }\n}\n\n\nint cFFTmagphase::setupNamesForField(int i, const char*name, long nEl)\n{\n  long newNEl = 0; \n  \n  // copy frequency axis information for this field...\n  const FrameMetaInfo *c = reader_->getFrameMetaInfo();\n\n  if (inverse) {\n    // TODO: find Mag and Phase fields by name, build lookup table and create only a single output for the Mag field, ignore the phase field...\n    // TODO2: cache in processVectorFloat, or method to access the phase field when the magnitude field is processed...\n    // OR: do not derive from cVectorProcessor...?\n    // ASSUMPTION: The first field is the magnitudes, and the second the phases, both same size, we use only the first here!\n    if (i == 0) {\n      addNameAppendFieldAuto(name, \"fftcInv\", (nEl*2)-2);\n      newNEl += (nEl*2)-2;\n    }\n  } else {\n    if (magnitude) {\n      int dtype = DATATYPE_SPECTRUM_BINS_MAG;\n      if (phase && joinMagphase) {\n        dtype = DATATYPE_SPECTRUM_BINS_MAGPHASE;\n        // TODO: new datatypes for mag_phase version of power spectra, etc.\n        if (dBpsd) {\n          addNameAppendFieldAuto(name, \"fftMag_dBsplPSD_Phase\", nEl + 2);\n          dtype = DATATYPE_SPECTRUM_BINS_DBPSD;\n        } else if (power && !normalise) {\n          addNameAppendFieldAuto(name, \"fftMag_PowSpec_Phase\", nEl + 2);\n          dtype = DATATYPE_SPECTRUM_BINS_POWSPEC;\n        } else if (power && normalise) {\n          addNameAppendFieldAuto(name, \"fftMag_PowSpecDens_Phase\", nEl + 2);\n          dtype = DATATYPE_SPECTRUM_BINS_POWSPECDENS;\n        } else if (normalise && !power) {\n          addNameAppendFieldAuto(name, \"fftMag_SpecDens_Phase\", nEl + 2);\n          dtype = DATATYPE_SPECTRUM_BINS_SPECDENS;\n        } else {\n          addNameAppendFieldAuto(name, \"fftMagphase\", nEl + 2);\n        }\n        newNEl += nEl + 2; \n      } else {\n        if (dBpsd) {\n          addNameAppendFieldAuto(name, \"fftMag_dBsplPSD\", nEl/2 + 1);\n          dtype = DATATYPE_SPECTRUM_BINS_DBPSD;\n        } else if (power && !normalise) {\n          addNameAppendFieldAuto(name, \"fftMag_PowSpec\", nEl/2 + 1);\n          dtype = DATATYPE_SPECTRUM_BINS_POWSPEC;\n        } else if (power && normalise) {\n          addNameAppendFieldAuto(name, \"fftMag_PowSpecDens\", nEl/2 + 1);\n          dtype = DATATYPE_SPECTRUM_BINS_POWSPECDENS;\n        } else if (normalise && !power) {\n          addNameAppendFieldAuto(name, \"fftMag_SpecDens\", nEl/2 + 1);\n          dtype = DATATYPE_SPECTRUM_BINS_SPECDENS;\n        } else {\n          addNameAppendFieldAuto(name, \"fftMag\", nEl/2 + 1);\n        }\n        newNEl += nEl/2 +1; \n      }\n      void * _buf = malloc(c->field[i].infoSize);\n      memcpy(_buf, c->field[i].info, c->field[i].infoSize);\n      writer_->setFieldInfo(-1,dtype,_buf,c->field[i].infoSize);\n    } \n    if (phase && (!magnitude || !joinMagphase)) {\n      addNameAppendFieldAuto(name, \"fftPhase\", nEl/2 + 1);\n      newNEl += nEl/2 +1; \n      void * _buf = malloc(c->field[i].infoSize);\n      memcpy(_buf, c->field[i].info, c->field[i].infoSize);\n      writer_->setFieldInfo(-1,DATATYPE_SPECTRUM_BINS_PHASE,_buf,c->field[i].infoSize);  \n    }\n  }\n  \n  \n\n  return newNEl;\n}\n\n\n\n// a derived class should override this method, in order to implement the actual processing\nint cFFTmagphase::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  long n;\n  if (Nsrc <= 0) return 0;\n  // TODO : seperate magnitude and phase is still broken, as processVectorFloat does not allow for a single input field and more than one output fields...\n\n  // TODO: nyquist phase\n  if (inverse) { // inverse is only possible from joint Mag & phase array fields... TODO: check this!\n\n    // we assume the first Nsrc/2+1 inputs to be magnitude and the second Nsrc/2 inputs to be phase\n    if ( (Nsrc & 1) == 1 ) { \n      SMILE_IERR(1,\"number of inputs (Nsrc=%i) must be even, please check if you have enabled magnitude and phase input!\",Nsrc); \n      COMP_ERR(\"aborting\");\n    }\n    const FLOAT_DMEM *mag = src;\n    const FLOAT_DMEM *phase = src + Nsrc/2;\n    long myN = Nsrc/2;\n\n    dst[0] = src[0]*src[Nsrc/2];\n    dst[1] = 0;\n    for (n=1; n<myN-1; n++) {\n      dst[n*2] = cos(phase[n])*mag[n];  // real\n      dst[n*2+1] = sin(phase[n])*mag[n];  // imaginary\n    }\n    \n  } else {\n    int doMag = 0;\n\n    if (magnitude && phase && !joinMagphase) {\n      // check if this is an even field number... if not skip\n      if ((idxi & 1) == 0) doMag = 1;\n    } else {\n      doMag = 1;\n    }\n\n    if (doMag) {\n      if (magnitude && !dBpsd && !normalise && !power) {\n        dst[0] = fabs(src[0]);\n        for(n=2; n<Nsrc; n += 2) {\n          dst[n/2] = sqrt(src[n]*src[n] + src[n+1]*src[n+1]);\n        }\n        dst[Nsrc/2] = fabs(src[1]);\n        //dst += Nsrc/2+1;\n        //    dst += Nsrc/2;\n      } else if (magnitude && !dBpsd && normalise && !power) {\n        dst[0] = ((FLOAT_DMEM)1.0/(FLOAT_DMEM)Nsrc)*fabs(src[0]);\n        for(n=2; n<Nsrc; n += 2) {\n          dst[n/2] = ((FLOAT_DMEM)1.0/(FLOAT_DMEM)Nsrc)*sqrt(src[n]*src[n] + src[n+1]*src[n+1]);\n        }\n        dst[Nsrc/2] = ((FLOAT_DMEM)1.0/(FLOAT_DMEM)Nsrc)*fabs(src[1]);\n        //dst += Nsrc/2+1;\n      } else if (magnitude && !dBpsd && normalise && power) {\n        dst[0] = ((FLOAT_DMEM)1.0/(FLOAT_DMEM)Nsrc)*src[0]; \n        dst[0] *= dst[0];\n        for(n=2; n<Nsrc; n += 2) {\n          dst[n/2] = ((FLOAT_DMEM)1.0/((FLOAT_DMEM)Nsrc*(FLOAT_DMEM)Nsrc))*(src[n]*src[n] + src[n+1]*src[n+1]);\n        }\n        dst[Nsrc/2] = ((FLOAT_DMEM)1.0/(FLOAT_DMEM)Nsrc)*fabs(src[1]);\n        dst[Nsrc/2] *= dst[Nsrc/2];\n        //dst += Nsrc/2+1;\n      } else if (magnitude && !dBpsd && !normalise && power) {\n        dst[0] = fabs(src[0]); \n        dst[0] *= dst[0];\n        for(n=2; n<Nsrc; n += 2) {\n          dst[n/2] = (src[n]*src[n] + src[n+1]*src[n+1]);\n        }\n        dst[Nsrc/2] = fabs(src[1]);\n        dst[Nsrc/2] *= dst[Nsrc/2];\n        //dst += Nsrc/2+1;\n      } else if (magnitude && dBpsd) {\n        dst[0] = MAX(mindBp, (dBpnorm + (FLOAT_DMEM)20.0 * log10( ((FLOAT_DMEM)1.0/(FLOAT_DMEM)Nsrc)*fabs(src[0]) )));\n        for(n=2; n<Nsrc; n += 2) {\n          dst[n/2] = MAX(mindBp, (dBpnorm + (FLOAT_DMEM)10.0 * log10( ((FLOAT_DMEM)1.0/((FLOAT_DMEM)Nsrc*(FLOAT_DMEM)Nsrc))*(src[n]*src[n] + src[n+1]*src[n+1]) )) );\n        }\n        dst[Nsrc/2] = MAX(mindBp, (dBpnorm + (FLOAT_DMEM)20.0 * log10( ((FLOAT_DMEM)1.0/(FLOAT_DMEM)Nsrc)*fabs(src[1]) )));\n        //dst += Nsrc/2+1;\n      }\n    }\n    if (phase) {\n      if (joinMagphase && magnitude) {\n        // add Nsrc/2 to index...\n        dst[Nsrc/2+1] = (src[0]>=0) ? (FLOAT_DMEM)0 : (FLOAT_DMEM)M_PI;\n        for(n=2; n<Nsrc; n+=2) {\n          dst[Nsrc/2+1+n/2] = atan2(src[n+1],src[n]);\n        }\n        // TODO: valgrind checks on this line!!\n        dst[Nsrc/2+1+Nsrc/2] = (src[1]>=0) ? (FLOAT_DMEM)0 : (FLOAT_DMEM)M_PI;\n      } else {\n        if (magnitude) {\n          // check if this field is the phase field, otherwise skip...\n          if ((idxi & 1) == 1) {  // TODO: this check is wrong, it will never output phase for a single input field!\n            dst[0] = (src[0]>=0) ? (FLOAT_DMEM)0 : (FLOAT_DMEM)M_PI;\n            for(n=2; n<Nsrc; n+=2) {\n              dst[n/2] = atan2(src[n+1],src[n]);\n            }\n          }\n          dst[Nsrc/2] = (src[1]>=0) ? (FLOAT_DMEM)0 : (FLOAT_DMEM)M_PI;\n        } else {\n          // only phase output, so this field has to be the phase field...\n          dst[0] = (src[0]>=0) ? (FLOAT_DMEM)0 : (FLOAT_DMEM)M_PI;\n          for(n=2; n<Nsrc; n+=2) {\n            dst[n/2] = atan2(src[n+1],src[n]);\n          }\n          dst[Nsrc/2] = (src[1]>=0) ? (FLOAT_DMEM)0 : (FLOAT_DMEM)M_PI;\n        }\n      }\n      //    dst[Nsrc/2] = 0.0;\n      //dst += Nsrc/2+1;\n    }\n\n  }\n\n  return 1;\n}\n\ncFFTmagphase::~cFFTmagphase()\n{\n}\n\n"
  },
  {
    "path": "src/dspcore/fftsg.c",
    "content": "/*\n * http://www.kurims.kyoto-u.ac.jp/~ooura/fft.html\n * Copyright Takuya OOURA, 1996-2001\n *\n * You may use, copy, modify and distribute this code for any purpose (include\n * commercial use) and without fee. Please refer to this package when you modify\n * this code.\n *\n * Changes:\n * Trivial type modifications by the openSMILE authors.\n */\n\n/*\nFast Fourier/Cosine/Sine Transform\n\n@@@@  FLOAT_TYPE_FFT floating porint PRECISION VERSION modified by Florian @@@@@@@\n \n    dimension   :one\n    data length :power of 2\n    decimation  :frequency\n    radix       :split-radix\n    data        :inplace\n    table       :use\nfunctions\n    cdft: Complex Discrete Fourier Transform\n    rdft: Real Discrete Fourier Transform\n    ddct: Discrete Cosine Transform\n    ddst: Discrete Sine Transform\n    dfct: Cosine Transform of RDFT (Real Symmetric DFT)\n    dfst: Sine Transform of RDFT (Real Anti-symmetric DFT)\nfunction prototypes\n    void cdft(int, int, FLOAT_TYPE_FFT *, int *, FLOAT_TYPE_FFT *);\n    void rdft(int, int, FLOAT_TYPE_FFT *, int *, FLOAT_TYPE_FFT *);\n    void ddct(int, int, FLOAT_TYPE_FFT *, int *, FLOAT_TYPE_FFT *);\n    void ddst(int, int, FLOAT_TYPE_FFT *, int *, FLOAT_TYPE_FFT *);\n    void dfct(int, FLOAT_TYPE_FFT *, FLOAT_TYPE_FFT *, int *, FLOAT_TYPE_FFT *);\n    void dfst(int, FLOAT_TYPE_FFT *, FLOAT_TYPE_FFT *, int *, FLOAT_TYPE_FFT *);\nmacro definitions\n    USE_CDFT_PTHREADS : default=not defined\n        CDFT_THREADS_BEGIN_N  : must be >= 512, default=8192\n        CDFT_4THREADS_BEGIN_N : must be >= 512, default=65536\n    USE_CDFT_WINTHREADS : default=not defined\n        CDFT_THREADS_BEGIN_N  : must be >= 512, default=32768\n        CDFT_4THREADS_BEGIN_N : must be >= 512, default=524288\n\n\n-------- Complex DFT (Discrete Fourier Transform) --------\n    [definition]\n        <case1>\n            X[k] = sum_j=0^n-1 x[j]*exp(2*pi*i*j*k/n), 0<=k<n\n        <case2>\n            X[k] = sum_j=0^n-1 x[j]*exp(-2*pi*i*j*k/n), 0<=k<n\n        (notes: sum_j=0^n-1 is a summation from j=0 to n-1)\n    [usage]\n        <case1>\n            ip[0] = 0; // first time only\n            cdft(2*n, 1, a, ip, w);\n        <case2>\n            ip[0] = 0; // first time only\n            cdft(2*n, -1, a, ip, w);\n    [parameters]\n        2*n            :data length (int)\n                        n >= 1, n = power of 2\n        a[0...2*n-1]   :input/output data (FLOAT_TYPE_FFT *)\n                        input data\n                            a[2*j] = Re(x[j]), \n                            a[2*j+1] = Im(x[j]), 0<=j<n\n                        output data\n                            a[2*k] = Re(X[k]), \n                            a[2*k+1] = Im(X[k]), 0<=k<n\n        ip[0...*]      :work area for bit reversal (int *)\n                        length of ip >= 2+sqrt(n)\n                        strictly, \n                        length of ip >= \n                            2+(1<<(int)(log(n+0.5)/log(2))/2).\n                        ip[0],ip[1] are pointers of the cos/sin table.\n        w[0...n/2-1]   :cos/sin table (FLOAT_TYPE_FFT *)\n                        w[],ip[] are initialized if ip[0] == 0.\n    [remark]\n        Inverse of \n            cdft(2*n, -1, a, ip, w);\n        is \n            cdft(2*n, 1, a, ip, w);\n            for (j = 0; j <= 2 * n - 1; j++) {\n                a[j] *= 1.0 / n;\n            }\n        .\n\n\n-------- Real DFT / Inverse of Real DFT --------\n    [definition]\n        <case1> RDFT\n            R[k] = sum_j=0^n-1 a[j]*cos(2*pi*j*k/n), 0<=k<=n/2\n            I[k] = sum_j=0^n-1 a[j]*sin(2*pi*j*k/n), 0<k<n/2\n        <case2> IRDFT (excluding scale)\n            a[k] = (R[0] + R[n/2]*cos(pi*k))/2 + \n                   sum_j=1^n/2-1 R[j]*cos(2*pi*j*k/n) + \n                   sum_j=1^n/2-1 I[j]*sin(2*pi*j*k/n), 0<=k<n\n    [usage]\n        <case1>\n            ip[0] = 0; // first time only\n            rdft(n, 1, a, ip, w);\n        <case2>\n            ip[0] = 0; // first time only\n            rdft(n, -1, a, ip, w);\n    [parameters]\n        n              :data length (int)\n                        n >= 2, n = power of 2\n        a[0...n-1]     :input/output data (FLOAT_TYPE_FFT *)\n                        <case1>\n                            output data\n                                a[2*k] = R[k], 0<=k<n/2\n                                a[2*k+1] = I[k], 0<k<n/2\n                                a[1] = R[n/2]\n                        <case2>\n                            input data\n                                a[2*j] = R[j], 0<=j<n/2\n                                a[2*j+1] = I[j], 0<j<n/2\n                                a[1] = R[n/2]\n        ip[0...*]      :work area for bit reversal (int *)\n                        length of ip >= 2+sqrt(n/2)\n                        strictly, \n                        length of ip >= \n                            2+(1<<(int)(log(n/2+0.5)/log(2))/2).\n                        ip[0],ip[1] are pointers of the cos/sin table.\n        w[0...n/2-1]   :cos/sin table (FLOAT_TYPE_FFT *)\n                        w[],ip[] are initialized if ip[0] == 0.\n    [remark]\n        Inverse of \n            rdft(n, 1, a, ip, w);\n        is \n            rdft(n, -1, a, ip, w);\n            for (j = 0; j <= n - 1; j++) {\n                a[j] *= 2.0 / n;\n            }\n        .\n\n\n-------- DCT (Discrete Cosine Transform) / Inverse of DCT --------\n    [definition]\n        <case1> IDCT (excluding scale)\n            C[k] = sum_j=0^n-1 a[j]*cos(pi*j*(k+1/2)/n), 0<=k<n\n        <case2> DCT\n            C[k] = sum_j=0^n-1 a[j]*cos(pi*(j+1/2)*k/n), 0<=k<n\n    [usage]\n        <case1>\n            ip[0] = 0; // first time only\n            ddct(n, 1, a, ip, w);\n        <case2>\n            ip[0] = 0; // first time only\n            ddct(n, -1, a, ip, w);\n    [parameters]\n        n              :data length (int)\n                        n >= 2, n = power of 2\n        a[0...n-1]     :input/output data (FLOAT_TYPE_FFT *)\n                        output data\n                            a[k] = C[k], 0<=k<n\n        ip[0...*]      :work area for bit reversal (int *)\n                        length of ip >= 2+sqrt(n/2)\n                        strictly, \n                        length of ip >= \n                            2+(1<<(int)(log(n/2+0.5)/log(2))/2).\n                        ip[0],ip[1] are pointers of the cos/sin table.\n        w[0...n*5/4-1] :cos/sin table (FLOAT_TYPE_FFT *)\n                        w[],ip[] are initialized if ip[0] == 0.\n    [remark]\n        Inverse of \n            ddct(n, -1, a, ip, w);\n        is \n            a[0] *= 0.5;\n            ddct(n, 1, a, ip, w);\n            for (j = 0; j <= n - 1; j++) {\n                a[j] *= 2.0 / n;\n            }\n        .\n\n\n-------- DST (Discrete Sine Transform) / Inverse of DST --------\n    [definition]\n        <case1> IDST (excluding scale)\n            S[k] = sum_j=1^n A[j]*sin(pi*j*(k+1/2)/n), 0<=k<n\n        <case2> DST\n            S[k] = sum_j=0^n-1 a[j]*sin(pi*(j+1/2)*k/n), 0<k<=n\n    [usage]\n        <case1>\n            ip[0] = 0; // first time only\n            ddst(n, 1, a, ip, w);\n        <case2>\n            ip[0] = 0; // first time only\n            ddst(n, -1, a, ip, w);\n    [parameters]\n        n              :data length (int)\n                        n >= 2, n = power of 2\n        a[0...n-1]     :input/output data (FLOAT_TYPE_FFT *)\n                        <case1>\n                            input data\n                                a[j] = A[j], 0<j<n\n                                a[0] = A[n]\n                            output data\n                                a[k] = S[k], 0<=k<n\n                        <case2>\n                            output data\n                                a[k] = S[k], 0<k<n\n                                a[0] = S[n]\n        ip[0...*]      :work area for bit reversal (int *)\n                        length of ip >= 2+sqrt(n/2)\n                        strictly, \n                        length of ip >= \n                            2+(1<<(int)(log(n/2+0.5)/log(2))/2).\n                        ip[0],ip[1] are pointers of the cos/sin table.\n        w[0...n*5/4-1] :cos/sin table (FLOAT_TYPE_FFT *)\n                        w[],ip[] are initialized if ip[0] == 0.\n    [remark]\n        Inverse of \n            ddst(n, -1, a, ip, w);\n        is \n            a[0] *= 0.5;\n            ddst(n, 1, a, ip, w);\n            for (j = 0; j <= n - 1; j++) {\n                a[j] *= 2.0 / n;\n            }\n        .\n\n\n-------- Cosine Transform of RDFT (Real Symmetric DFT) --------\n    [definition]\n        C[k] = sum_j=0^n a[j]*cos(pi*j*k/n), 0<=k<=n\n    [usage]\n        ip[0] = 0; // first time only\n        dfct(n, a, t, ip, w);\n    [parameters]\n        n              :data length - 1 (int)\n                        n >= 2, n = power of 2\n        a[0...n]       :input/output data (FLOAT_TYPE_FFT *)\n                        output data\n                            a[k] = C[k], 0<=k<=n\n        t[0...n/2]     :work area (FLOAT_TYPE_FFT *)\n        ip[0...*]      :work area for bit reversal (int *)\n                        length of ip >= 2+sqrt(n/4)\n                        strictly, \n                        length of ip >= \n                            2+(1<<(int)(log(n/4+0.5)/log(2))/2).\n                        ip[0],ip[1] are pointers of the cos/sin table.\n        w[0...n*5/8-1] :cos/sin table (FLOAT_TYPE_FFT *)\n                        w[],ip[] are initialized if ip[0] == 0.\n    [remark]\n        Inverse of \n            a[0] *= 0.5;\n            a[n] *= 0.5;\n            dfct(n, a, t, ip, w);\n        is \n            a[0] *= 0.5;\n            a[n] *= 0.5;\n            dfct(n, a, t, ip, w);\n            for (j = 0; j <= n; j++) {\n                a[j] *= 2.0 / n;\n            }\n        .\n\n\n-------- Sine Transform of RDFT (Real Anti-symmetric DFT) --------\n    [definition]\n        S[k] = sum_j=1^n-1 a[j]*sin(pi*j*k/n), 0<k<n\n    [usage]\n        ip[0] = 0; // first time only\n        dfst(n, a, t, ip, w);\n    [parameters]\n        n              :data length + 1 (int)\n                        n >= 2, n = power of 2\n        a[0...n-1]     :input/output data (FLOAT_TYPE_FFT *)\n                        output data\n                            a[k] = S[k], 0<k<n\n                        (a[0] is used for work area)\n        t[0...n/2-1]   :work area (FLOAT_TYPE_FFT *)\n        ip[0...*]      :work area for bit reversal (int *)\n                        length of ip >= 2+sqrt(n/4)\n                        strictly, \n                        length of ip >= \n                            2+(1<<(int)(log(n/4+0.5)/log(2))/2).\n                        ip[0],ip[1] are pointers of the cos/sin table.\n        w[0...n*5/8-1] :cos/sin table (FLOAT_TYPE_FFT *)\n                        w[],ip[] are initialized if ip[0] == 0.\n    [remark]\n        Inverse of \n            dfst(n, a, t, ip, w);\n        is \n            dfst(n, a, t, ip, w);\n            for (j = 1; j <= n - 1; j++) {\n                a[j] *= 2.0 / n;\n            }\n        .\n\n\nAppendix :\n    The cos/sin table is recalculated when the larger table required.\n    w[] and ip[] are compatible with all routines.\n*/\n\n#include <dspcore/fftXg.h>\n\nvoid cdft(int n, int isgn, FLOAT_TYPE_FFT *a, int *ip, FLOAT_TYPE_FFT *w)\n{\n    void makewt(int nw, int *ip, FLOAT_TYPE_FFT *w);\n    void cftfsub(int n, FLOAT_TYPE_FFT *a, int *ip, int nw, FLOAT_TYPE_FFT *w);\n    void cftbsub(int n, FLOAT_TYPE_FFT *a, int *ip, int nw, FLOAT_TYPE_FFT *w);\n    int nw;\n    \n    nw = ip[0];\n    if (n > (nw << 2)) {\n        nw = n >> 2;\n        makewt(nw, ip, w);\n    }\n    if (isgn >= 0) {\n        cftfsub(n, a, ip, nw, w);\n    } else {\n        cftbsub(n, a, ip, nw, w);\n    }\n}\n\n//#include <stdio.h>\n\nvoid rdft(int n, int isgn, FLOAT_TYPE_FFT *a, int *ip, FLOAT_TYPE_FFT *w)\n{\n    void makewt(int nw, int *ip, FLOAT_TYPE_FFT *w);\n    void makect(int nc, int *ip, FLOAT_TYPE_FFT *c);\n    void cftfsub(int n, FLOAT_TYPE_FFT *a, int *ip, int nw, FLOAT_TYPE_FFT *w);\n    void cftbsub(int n, FLOAT_TYPE_FFT *a, int *ip, int nw, FLOAT_TYPE_FFT *w);\n    void rftfsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c);\n    void rftbsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c);\n    int nw, nc;\n    FLOAT_TYPE_FFT xi;\n    \n    nw = ip[0];\n    if (n > (nw << 2)) {\n        nw = n >> 2;\n        makewt(nw, ip, w);\n    }\n    nc = ip[1];\n    if (n > (nc << 2)) {\n        nc = n >> 2;\n        makect(nc, ip, w + nw);\n    }\n    if (isgn >= 0) {\n        if (n > 4) {\n            cftfsub(n, a, ip, nw, w);\n            rftfsub(n, a, nc, w + nw);\n        } else if (n == 4) {\n            cftfsub(n, a, ip, nw, w);\n        }\n        xi = a[0] - a[1];\n        a[0] += a[1];\n        a[1] = xi;\n    } else {\n        a[1] = (FLOAT_TYPE_FFT)0.5 * (a[0] - a[1]);\n        a[0] -= a[1];\n        if (n > 4) {\n            rftbsub(n, a, nc, w + nw);\n            cftbsub(n, a, ip, nw, w);\n        } else if (n == 4) {\n            cftbsub(n, a, ip, nw, w);\n        }\n    }\n}\n\n\nvoid ddct(int n, int isgn, FLOAT_TYPE_FFT *a, int *ip, FLOAT_TYPE_FFT *w)\n{\n    void makewt(int nw, int *ip, FLOAT_TYPE_FFT *w);\n    void makect(int nc, int *ip, FLOAT_TYPE_FFT *c);\n    void cftfsub(int n, FLOAT_TYPE_FFT *a, int *ip, int nw, FLOAT_TYPE_FFT *w);\n    void cftbsub(int n, FLOAT_TYPE_FFT *a, int *ip, int nw, FLOAT_TYPE_FFT *w);\n    void rftfsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c);\n    void rftbsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c);\n    void dctsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c);\n    int j, nw, nc;\n    FLOAT_TYPE_FFT xr;\n    \n    nw = ip[0];\n    if (n > (nw << 2)) {\n        nw = n >> 2;\n        makewt(nw, ip, w);\n    }\n    nc = ip[1];\n    if (n > nc) {\n        nc = n;\n        makect(nc, ip, w + nw);\n    }\n    if (isgn < 0) {\n        xr = a[n - 1];\n        for (j = n - 2; j >= 2; j -= 2) {\n            a[j + 1] = a[j] - a[j - 1];\n            a[j] += a[j - 1];\n        }\n        a[1] = a[0] - xr;\n        a[0] += xr;\n        if (n > 4) {\n            rftbsub(n, a, nc, w + nw);\n            cftbsub(n, a, ip, nw, w);\n        } else if (n == 4) {\n            cftbsub(n, a, ip, nw, w);\n        }\n    }\n    dctsub(n, a, nc, w + nw);\n    if (isgn >= 0) {\n        if (n > 4) {\n            cftfsub(n, a, ip, nw, w);\n            rftfsub(n, a, nc, w + nw);\n        } else if (n == 4) {\n            cftfsub(n, a, ip, nw, w);\n        }\n        xr = a[0] - a[1];\n        a[0] += a[1];\n        for (j = 2; j < n; j += 2) {\n            a[j - 1] = a[j] - a[j + 1];\n            a[j] += a[j + 1];\n        }\n        a[n - 1] = xr;\n    }\n}\n\n\nvoid ddst(int n, int isgn, FLOAT_TYPE_FFT *a, int *ip, FLOAT_TYPE_FFT *w)\n{\n    void makewt(int nw, int *ip, FLOAT_TYPE_FFT *w);\n    void makect(int nc, int *ip, FLOAT_TYPE_FFT *c);\n    void cftfsub(int n, FLOAT_TYPE_FFT *a, int *ip, int nw, FLOAT_TYPE_FFT *w);\n    void cftbsub(int n, FLOAT_TYPE_FFT *a, int *ip, int nw, FLOAT_TYPE_FFT *w);\n    void rftfsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c);\n    void rftbsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c);\n    void dstsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c);\n    int j, nw, nc;\n    FLOAT_TYPE_FFT xr;\n    \n    nw = ip[0];\n    if (n > (nw << 2)) {\n        nw = n >> 2;\n        makewt(nw, ip, w);\n    }\n    nc = ip[1];\n    if (n > nc) {\n        nc = n;\n        makect(nc, ip, w + nw);\n    }\n    if (isgn < 0) {\n        xr = a[n - 1];\n        for (j = n - 2; j >= 2; j -= 2) {\n            a[j + 1] = -a[j] - a[j - 1];\n            a[j] -= a[j - 1];\n        }\n        a[1] = a[0] + xr;\n        a[0] -= xr;\n        if (n > 4) {\n            rftbsub(n, a, nc, w + nw);\n            cftbsub(n, a, ip, nw, w);\n        } else if (n == 4) {\n            cftbsub(n, a, ip, nw, w);\n        }\n    }\n    dstsub(n, a, nc, w + nw);\n    if (isgn >= 0) {\n        if (n > 4) {\n            cftfsub(n, a, ip, nw, w);\n            rftfsub(n, a, nc, w + nw);\n        } else if (n == 4) {\n            cftfsub(n, a, ip, nw, w);\n        }\n        xr = a[0] - a[1];\n        a[0] += a[1];\n        for (j = 2; j < n; j += 2) {\n            a[j - 1] = -a[j] - a[j + 1];\n            a[j] -= a[j + 1];\n        }\n        a[n - 1] = -xr;\n    }\n}\n\n\nvoid dfct(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *t, int *ip, FLOAT_TYPE_FFT *w)\n{\n    void makewt(int nw, int *ip, FLOAT_TYPE_FFT *w);\n    void makect(int nc, int *ip, FLOAT_TYPE_FFT *c);\n    void cftfsub(int n, FLOAT_TYPE_FFT *a, int *ip, int nw, FLOAT_TYPE_FFT *w);\n    void rftfsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c);\n    void dctsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c);\n    int j, k, l, m, mh, nw, nc;\n    FLOAT_TYPE_FFT xr, xi, yr, yi;\n    \n    nw = ip[0];\n    if (n > (nw << 3)) {\n        nw = n >> 3;\n        makewt(nw, ip, w);\n    }\n    nc = ip[1];\n    if (n > (nc << 1)) {\n        nc = n >> 1;\n        makect(nc, ip, w + nw);\n    }\n    m = n >> 1;\n    yi = a[m];\n    xi = a[0] + a[n];\n    a[0] -= a[n];\n    t[0] = xi - yi;\n    t[m] = xi + yi;\n    if (n > 2) {\n        mh = m >> 1;\n        for (j = 1; j < mh; j++) {\n            k = m - j;\n            xr = a[j] - a[n - j];\n            xi = a[j] + a[n - j];\n            yr = a[k] - a[n - k];\n            yi = a[k] + a[n - k];\n            a[j] = xr;\n            a[k] = yr;\n            t[j] = xi - yi;\n            t[k] = xi + yi;\n        }\n        t[mh] = a[mh] + a[n - mh];\n        a[mh] -= a[n - mh];\n        dctsub(m, a, nc, w + nw);\n        if (m > 4) {\n            cftfsub(m, a, ip, nw, w);\n            rftfsub(m, a, nc, w + nw);\n        } else if (m == 4) {\n            cftfsub(m, a, ip, nw, w);\n        }\n        a[n - 1] = a[0] - a[1];\n        a[1] = a[0] + a[1];\n        for (j = m - 2; j >= 2; j -= 2) {\n            a[2 * j + 1] = a[j] + a[j + 1];\n            a[2 * j - 1] = a[j] - a[j + 1];\n        }\n        l = 2;\n        m = mh;\n        while (m >= 2) {\n            dctsub(m, t, nc, w + nw);\n            if (m > 4) {\n                cftfsub(m, t, ip, nw, w);\n                rftfsub(m, t, nc, w + nw);\n            } else if (m == 4) {\n                cftfsub(m, t, ip, nw, w);\n            }\n            a[n - l] = t[0] - t[1];\n            a[l] = t[0] + t[1];\n            k = 0;\n            for (j = 2; j < m; j += 2) {\n                k += l << 2;\n                a[k - l] = t[j] - t[j + 1];\n                a[k + l] = t[j] + t[j + 1];\n            }\n            l <<= 1;\n            mh = m >> 1;\n            for (j = 0; j < mh; j++) {\n                k = m - j;\n                t[j] = t[m + k] - t[m + j];\n                t[k] = t[m + k] + t[m + j];\n            }\n            t[mh] = t[m + mh];\n            m = mh;\n        }\n        a[l] = t[0];\n        a[n] = t[2] - t[1];\n        a[0] = t[2] + t[1];\n    } else {\n        a[1] = a[0];\n        a[2] = t[0];\n        a[0] = t[1];\n    }\n}\n\n\nvoid dfst(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *t, int *ip, FLOAT_TYPE_FFT *w)\n{\n    void makewt(int nw, int *ip, FLOAT_TYPE_FFT *w);\n    void makect(int nc, int *ip, FLOAT_TYPE_FFT *c);\n    void cftfsub(int n, FLOAT_TYPE_FFT *a, int *ip, int nw, FLOAT_TYPE_FFT *w);\n    void rftfsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c);\n    void dstsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c);\n    int j, k, l, m, mh, nw, nc;\n    FLOAT_TYPE_FFT xr, xi, yr, yi;\n    \n    nw = ip[0];\n    if (n > (nw << 3)) {\n        nw = n >> 3;\n        makewt(nw, ip, w);\n    }\n    nc = ip[1];\n    if (n > (nc << 1)) {\n        nc = n >> 1;\n        makect(nc, ip, w + nw);\n    }\n    if (n > 2) {\n        m = n >> 1;\n        mh = m >> 1;\n        for (j = 1; j < mh; j++) {\n            k = m - j;\n            xr = a[j] + a[n - j];\n            xi = a[j] - a[n - j];\n            yr = a[k] + a[n - k];\n            yi = a[k] - a[n - k];\n            a[j] = xr;\n            a[k] = yr;\n            t[j] = xi + yi;\n            t[k] = xi - yi;\n        }\n        t[0] = a[mh] - a[n - mh];\n        a[mh] += a[n - mh];\n        a[0] = a[m];\n        dstsub(m, a, nc, w + nw);\n        if (m > 4) {\n            cftfsub(m, a, ip, nw, w);\n            rftfsub(m, a, nc, w + nw);\n        } else if (m == 4) {\n            cftfsub(m, a, ip, nw, w);\n        }\n        a[n - 1] = a[1] - a[0];\n        a[1] = a[0] + a[1];\n        for (j = m - 2; j >= 2; j -= 2) {\n            a[2 * j + 1] = a[j] - a[j + 1];\n            a[2 * j - 1] = -a[j] - a[j + 1];\n        }\n        l = 2;\n        m = mh;\n        while (m >= 2) {\n            dstsub(m, t, nc, w + nw);\n            if (m > 4) {\n                cftfsub(m, t, ip, nw, w);\n                rftfsub(m, t, nc, w + nw);\n            } else if (m == 4) {\n                cftfsub(m, t, ip, nw, w);\n            }\n            a[n - l] = t[1] - t[0];\n            a[l] = t[0] + t[1];\n            k = 0;\n            for (j = 2; j < m; j += 2) {\n                k += l << 2;\n                a[k - l] = -t[j] - t[j + 1];\n                a[k + l] = t[j] - t[j + 1];\n            }\n            l <<= 1;\n            mh = m >> 1;\n            for (j = 1; j < mh; j++) {\n                k = m - j;\n                t[j] = t[m + k] + t[m + j];\n                t[k] = t[m + k] - t[m + j];\n            }\n            t[0] = t[m + mh];\n            m = mh;\n        }\n        a[l] = t[0];\n    }\n    a[0] = 0;\n}\n\n\n/* -------- initializing routines -------- */\n\n\n#include <math.h>\n\nvoid makewt(int nw, int *ip, FLOAT_TYPE_FFT *w)\n{\n    void makeipt(int nw, int *ip);\n    int j, nwh, nw0, nw1;\n    FLOAT_TYPE_FFT delta, wn4r, wk1r, wk1i, wk3r, wk3i;\n    \n    ip[0] = nw;\n    ip[1] = 1;\n    if (nw > 2) {\n        nwh = nw >> 1;\n        delta = (FLOAT_TYPE_FFT)atan(1.0) / nwh;\n        wn4r = (FLOAT_TYPE_FFT)cos(delta * nwh);\n        w[0] = 1;\n        w[1] = wn4r;\n        if (nwh == 4) {\n            w[2] = (FLOAT_TYPE_FFT)cos(delta * 2);\n            w[3] = (FLOAT_TYPE_FFT)sin(delta * 2);\n        } else if (nwh > 4) {\n            makeipt(nw, ip);\n            w[2] = (FLOAT_TYPE_FFT)( 0.5 / cos(delta * 2) );\n            w[3] = (FLOAT_TYPE_FFT)( 0.5 / cos(delta * 6) );\n            for (j = 4; j < nwh; j += 4) {\n                w[j] = (FLOAT_TYPE_FFT)cos(delta * j);\n                w[j + 1] = (FLOAT_TYPE_FFT)sin(delta * j);\n                w[j + 2] = (FLOAT_TYPE_FFT)cos(3 * delta * j);\n                w[j + 3] = (FLOAT_TYPE_FFT)( -sin(3 * delta * j) );\n            }\n        }\n        nw0 = 0;\n        while (nwh > 2) {\n            nw1 = nw0 + nwh;\n            nwh >>= 1;\n            w[nw1] = 1;\n            w[nw1 + 1] = wn4r;\n            if (nwh == 4) {\n                wk1r = w[nw0 + 4];\n                wk1i = w[nw0 + 5];\n                w[nw1 + 2] = wk1r;\n                w[nw1 + 3] = wk1i;\n            } else if (nwh > 4) {\n                wk1r = w[nw0 + 4];\n                wk3r = w[nw0 + 6];\n                w[nw1 + 2] = (FLOAT_TYPE_FFT)0.5 / wk1r;\n                w[nw1 + 3] = (FLOAT_TYPE_FFT)0.5 / wk3r;\n                for (j = 4; j < nwh; j += 4) {\n                    wk1r = w[nw0 + 2 * j];\n                    wk1i = w[nw0 + 2 * j + 1];\n                    wk3r = w[nw0 + 2 * j + 2];\n                    wk3i = w[nw0 + 2 * j + 3];\n                    w[nw1 + j] = wk1r;\n                    w[nw1 + j + 1] = wk1i;\n                    w[nw1 + j + 2] = wk3r;\n                    w[nw1 + j + 3] = wk3i;\n                }\n            }\n            nw0 = nw1;\n        }\n    }\n}\n\n\nvoid makeipt(int nw, int *ip)\n{\n    int j, l, m, m2, p, q;\n    \n    ip[2] = 0;\n    ip[3] = 16;\n    m = 2;\n    for (l = nw; l > 32; l >>= 2) {\n        m2 = m << 1;\n        q = m2 << 3;\n        for (j = m; j < m2; j++) {\n            p = ip[j] << 2;\n            ip[m + j] = p;\n            ip[m2 + j] = p + q;\n        }\n        m = m2;\n    }\n}\n\n\nvoid makect(int nc, int *ip, FLOAT_TYPE_FFT *c)\n{\n    int j, nch;\n    FLOAT_TYPE_FFT delta;\n    \n    ip[1] = nc;\n    if (nc > 1) {\n        nch = nc >> 1;\n        delta = (FLOAT_TYPE_FFT)atan(1.0) / nch;\n        c[0] = (FLOAT_TYPE_FFT)cos(delta * nch);\n        c[nch] = (FLOAT_TYPE_FFT)0.5 * c[0];\n        for (j = 1; j < nch; j++) {\n            c[j] = (FLOAT_TYPE_FFT)( 0.5 * cos(delta * j) );\n            c[nc - j] = (FLOAT_TYPE_FFT)( 0.5 * sin(delta * j) );\n        }\n    }\n}\n\n\n/* -------- child routines -------- */\n\n\n#ifdef USE_CDFT_PTHREADS\n#define USE_CDFT_THREADS\n#ifndef CDFT_THREADS_BEGIN_N\n#define CDFT_THREADS_BEGIN_N 8192\n#endif\n#ifndef CDFT_4THREADS_BEGIN_N\n#define CDFT_4THREADS_BEGIN_N 65536\n#endif\n#include <pthread.h>\n#include <stdio.h>\n#include <stdlib.h>\n#define cdft_thread_t pthread_t\n#define cdft_thread_create(thp,func,argp) { \\\n    if (pthread_create(thp, NULL, func, (void *) argp) != 0) { \\\n        fprintf(stderr, \"cdft thread error\\n\"); \\\n        exit(1); \\\n    } \\\n}\n#define cdft_thread_wait(th) { \\\n    if (pthread_join(th, NULL) != 0) { \\\n        fprintf(stderr, \"cdft thread error\\n\"); \\\n        exit(1); \\\n    } \\\n}\n#endif /* USE_CDFT_PTHREADS */\n\n\n#ifdef USE_CDFT_WINTHREADS\n#define USE_CDFT_THREADS\n#ifndef CDFT_THREADS_BEGIN_N\n#define CDFT_THREADS_BEGIN_N 32768\n#endif\n#ifndef CDFT_4THREADS_BEGIN_N\n#define CDFT_4THREADS_BEGIN_N 524288\n#endif\n#include <windows.h>\n#include <stdio.h>\n#include <stdlib.h>\n#define cdft_thread_t HANDLE\n#define cdft_thread_create(thp,func,argp) { \\\n    DWORD thid; \\\n    *(thp) = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) func, (LPVOID) argp, 0, &thid); \\\n    if (*(thp) == 0) { \\\n        fprintf(stderr, \"cdft thread error\\n\"); \\\n        exit(1); \\\n    } \\\n}\n#define cdft_thread_wait(th) { \\\n    WaitForSingleObject(th, INFINITE); \\\n    CloseHandle(th); \\\n}\n#endif /* USE_CDFT_WINTHREADS */\n\n\nvoid cftfsub(int n, FLOAT_TYPE_FFT *a, int *ip, int nw, FLOAT_TYPE_FFT *w)\n{\n    void bitrv2(int n, int *ip, FLOAT_TYPE_FFT *a);\n    void bitrv216(FLOAT_TYPE_FFT *a);\n    void bitrv208(FLOAT_TYPE_FFT *a);\n    void cftf1st(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void cftrec4(int n, FLOAT_TYPE_FFT *a, int nw, FLOAT_TYPE_FFT *w);\n    void cftleaf(int n, int isplt, FLOAT_TYPE_FFT *a, int nw, FLOAT_TYPE_FFT *w);\n    void cftfx41(int n, FLOAT_TYPE_FFT *a, int nw, FLOAT_TYPE_FFT *w);\n    void cftf161(FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void cftf081(FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void cftf040(FLOAT_TYPE_FFT *a);\n    void cftx020(FLOAT_TYPE_FFT *a);\n#ifdef USE_CDFT_THREADS\n    void cftrec4_th(int n, FLOAT_TYPE_FFT *a, int nw, FLOAT_TYPE_FFT *w);\n#endif /* USE_CDFT_THREADS */\n    \n    if (n > 8) {\n        if (n > 32) {\n            cftf1st(n, a, &w[nw - (n >> 2)]);\n#ifdef USE_CDFT_THREADS\n            if (n > CDFT_THREADS_BEGIN_N) {\n                cftrec4_th(n, a, nw, w);\n            } else \n#endif /* USE_CDFT_THREADS */\n            if (n > 512) {\n                cftrec4(n, a, nw, w);\n            } else if (n > 128) {\n                cftleaf(n, 1, a, nw, w);\n            } else {\n                cftfx41(n, a, nw, w);\n            }\n            bitrv2(n, ip, a);\n        } else if (n == 32) {\n            cftf161(a, &w[nw - 8]);\n            bitrv216(a);\n        } else {\n            cftf081(a, w);\n            bitrv208(a);\n        }\n    } else if (n == 8) {\n        cftf040(a);\n    } else if (n == 4) {\n        cftx020(a);\n    }\n}\n\n\nvoid cftbsub(int n, FLOAT_TYPE_FFT *a, int *ip, int nw, FLOAT_TYPE_FFT *w)\n{\n    void bitrv2conj(int n, int *ip, FLOAT_TYPE_FFT *a);\n    void bitrv216neg(FLOAT_TYPE_FFT *a);\n    void bitrv208neg(FLOAT_TYPE_FFT *a);\n    void cftb1st(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void cftrec4(int n, FLOAT_TYPE_FFT *a, int nw, FLOAT_TYPE_FFT *w);\n    void cftleaf(int n, int isplt, FLOAT_TYPE_FFT *a, int nw, FLOAT_TYPE_FFT *w);\n    void cftfx41(int n, FLOAT_TYPE_FFT *a, int nw, FLOAT_TYPE_FFT *w);\n    void cftf161(FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void cftf081(FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void cftb040(FLOAT_TYPE_FFT *a);\n    void cftx020(FLOAT_TYPE_FFT *a);\n#ifdef USE_CDFT_THREADS\n    void cftrec4_th(int n, FLOAT_TYPE_FFT *a, int nw, FLOAT_TYPE_FFT *w);\n#endif /* USE_CDFT_THREADS */\n    \n    if (n > 8) {\n        if (n > 32) {\n            cftb1st(n, a, &w[nw - (n >> 2)]);\n#ifdef USE_CDFT_THREADS\n            if (n > CDFT_THREADS_BEGIN_N) {\n                cftrec4_th(n, a, nw, w);\n            } else \n#endif /* USE_CDFT_THREADS */\n            if (n > 512) {\n                cftrec4(n, a, nw, w);\n            } else if (n > 128) {\n                cftleaf(n, 1, a, nw, w);\n            } else {\n                cftfx41(n, a, nw, w);\n            }\n            bitrv2conj(n, ip, a);\n        } else if (n == 32) {\n            cftf161(a, &w[nw - 8]);\n            bitrv216neg(a);\n        } else {\n            cftf081(a, w);\n            bitrv208neg(a);\n        }\n    } else if (n == 8) {\n        cftb040(a);\n    } else if (n == 4) {\n        cftx020(a);\n    }\n}\n\n\nvoid bitrv2(int n, int *ip, FLOAT_TYPE_FFT *a)\n{\n    int j, j1, k, k1, l, m, nh, nm;\n    FLOAT_TYPE_FFT xr, xi, yr, yi;\n    \n    m = 1;\n    for (l = n >> 2; l > 8; l >>= 2) {\n        m <<= 1;\n    }\n    nh = n >> 1;\n    nm = 4 * m;\n    if (l == 8) {\n        for (k = 0; k < m; k++) {\n            for (j = 0; j < k; j++) {\n                j1 = 4 * j + 2 * ip[m + k];\n                k1 = 4 * k + 2 * ip[m + j];\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += nm;\n                k1 += 2 * nm;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += nm;\n                k1 -= nm;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += nm;\n                k1 += 2 * nm;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += nh;\n                k1 += 2;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 -= nm;\n                k1 -= 2 * nm;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 -= nm;\n                k1 += nm;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 -= nm;\n                k1 -= 2 * nm;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += 2;\n                k1 += nh;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += nm;\n                k1 += 2 * nm;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += nm;\n                k1 -= nm;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += nm;\n                k1 += 2 * nm;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 -= nh;\n                k1 -= 2;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 -= nm;\n                k1 -= 2 * nm;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 -= nm;\n                k1 += nm;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 -= nm;\n                k1 -= 2 * nm;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n            }\n            k1 = 4 * k + 2 * ip[m + k];\n            j1 = k1 + 2;\n            k1 += nh;\n            xr = a[j1];\n            xi = a[j1 + 1];\n            yr = a[k1];\n            yi = a[k1 + 1];\n            a[j1] = yr;\n            a[j1 + 1] = yi;\n            a[k1] = xr;\n            a[k1 + 1] = xi;\n            j1 += nm;\n            k1 += 2 * nm;\n            xr = a[j1];\n            xi = a[j1 + 1];\n            yr = a[k1];\n            yi = a[k1 + 1];\n            a[j1] = yr;\n            a[j1 + 1] = yi;\n            a[k1] = xr;\n            a[k1 + 1] = xi;\n            j1 += nm;\n            k1 -= nm;\n            xr = a[j1];\n            xi = a[j1 + 1];\n            yr = a[k1];\n            yi = a[k1 + 1];\n            a[j1] = yr;\n            a[j1 + 1] = yi;\n            a[k1] = xr;\n            a[k1 + 1] = xi;\n            j1 -= 2;\n            k1 -= nh;\n            xr = a[j1];\n            xi = a[j1 + 1];\n            yr = a[k1];\n            yi = a[k1 + 1];\n            a[j1] = yr;\n            a[j1 + 1] = yi;\n            a[k1] = xr;\n            a[k1 + 1] = xi;\n            j1 += nh + 2;\n            k1 += nh + 2;\n            xr = a[j1];\n            xi = a[j1 + 1];\n            yr = a[k1];\n            yi = a[k1 + 1];\n            a[j1] = yr;\n            a[j1 + 1] = yi;\n            a[k1] = xr;\n            a[k1 + 1] = xi;\n            j1 -= nh - nm;\n            k1 += 2 * nm - 2;\n            xr = a[j1];\n            xi = a[j1 + 1];\n            yr = a[k1];\n            yi = a[k1 + 1];\n            a[j1] = yr;\n            a[j1 + 1] = yi;\n            a[k1] = xr;\n            a[k1 + 1] = xi;\n        }\n    } else {\n        for (k = 0; k < m; k++) {\n            for (j = 0; j < k; j++) {\n                j1 = 4 * j + ip[m + k];\n                k1 = 4 * k + ip[m + j];\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += nm;\n                k1 += nm;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += nh;\n                k1 += 2;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 -= nm;\n                k1 -= nm;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += 2;\n                k1 += nh;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += nm;\n                k1 += nm;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 -= nh;\n                k1 -= 2;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 -= nm;\n                k1 -= nm;\n                xr = a[j1];\n                xi = a[j1 + 1];\n                yr = a[k1];\n                yi = a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n            }\n            k1 = 4 * k + ip[m + k];\n            j1 = k1 + 2;\n            k1 += nh;\n            xr = a[j1];\n            xi = a[j1 + 1];\n            yr = a[k1];\n            yi = a[k1 + 1];\n            a[j1] = yr;\n            a[j1 + 1] = yi;\n            a[k1] = xr;\n            a[k1 + 1] = xi;\n            j1 += nm;\n            k1 += nm;\n            xr = a[j1];\n            xi = a[j1 + 1];\n            yr = a[k1];\n            yi = a[k1 + 1];\n            a[j1] = yr;\n            a[j1 + 1] = yi;\n            a[k1] = xr;\n            a[k1 + 1] = xi;\n        }\n    }\n}\n\n\nvoid bitrv2conj(int n, int *ip, FLOAT_TYPE_FFT *a)\n{\n    int j, j1, k, k1, l, m, nh, nm;\n    FLOAT_TYPE_FFT xr, xi, yr, yi;\n    \n    m = 1;\n    for (l = n >> 2; l > 8; l >>= 2) {\n        m <<= 1;\n    }\n    nh = n >> 1;\n    nm = 4 * m;\n    if (l == 8) {\n        for (k = 0; k < m; k++) {\n            for (j = 0; j < k; j++) {\n                j1 = 4 * j + 2 * ip[m + k];\n                k1 = 4 * k + 2 * ip[m + j];\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += nm;\n                k1 += 2 * nm;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += nm;\n                k1 -= nm;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += nm;\n                k1 += 2 * nm;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += nh;\n                k1 += 2;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 -= nm;\n                k1 -= 2 * nm;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 -= nm;\n                k1 += nm;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 -= nm;\n                k1 -= 2 * nm;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += 2;\n                k1 += nh;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += nm;\n                k1 += 2 * nm;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += nm;\n                k1 -= nm;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += nm;\n                k1 += 2 * nm;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 -= nh;\n                k1 -= 2;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 -= nm;\n                k1 -= 2 * nm;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 -= nm;\n                k1 += nm;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 -= nm;\n                k1 -= 2 * nm;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n            }\n            k1 = 4 * k + 2 * ip[m + k];\n            j1 = k1 + 2;\n            k1 += nh;\n            a[j1 - 1] = -a[j1 - 1];\n            xr = a[j1];\n            xi = -a[j1 + 1];\n            yr = a[k1];\n            yi = -a[k1 + 1];\n            a[j1] = yr;\n            a[j1 + 1] = yi;\n            a[k1] = xr;\n            a[k1 + 1] = xi;\n            a[k1 + 3] = -a[k1 + 3];\n            j1 += nm;\n            k1 += 2 * nm;\n            xr = a[j1];\n            xi = -a[j1 + 1];\n            yr = a[k1];\n            yi = -a[k1 + 1];\n            a[j1] = yr;\n            a[j1 + 1] = yi;\n            a[k1] = xr;\n            a[k1 + 1] = xi;\n            j1 += nm;\n            k1 -= nm;\n            xr = a[j1];\n            xi = -a[j1 + 1];\n            yr = a[k1];\n            yi = -a[k1 + 1];\n            a[j1] = yr;\n            a[j1 + 1] = yi;\n            a[k1] = xr;\n            a[k1 + 1] = xi;\n            j1 -= 2;\n            k1 -= nh;\n            xr = a[j1];\n            xi = -a[j1 + 1];\n            yr = a[k1];\n            yi = -a[k1 + 1];\n            a[j1] = yr;\n            a[j1 + 1] = yi;\n            a[k1] = xr;\n            a[k1 + 1] = xi;\n            j1 += nh + 2;\n            k1 += nh + 2;\n            xr = a[j1];\n            xi = -a[j1 + 1];\n            yr = a[k1];\n            yi = -a[k1 + 1];\n            a[j1] = yr;\n            a[j1 + 1] = yi;\n            a[k1] = xr;\n            a[k1 + 1] = xi;\n            j1 -= nh - nm;\n            k1 += 2 * nm - 2;\n            a[j1 - 1] = -a[j1 - 1];\n            xr = a[j1];\n            xi = -a[j1 + 1];\n            yr = a[k1];\n            yi = -a[k1 + 1];\n            a[j1] = yr;\n            a[j1 + 1] = yi;\n            a[k1] = xr;\n            a[k1 + 1] = xi;\n            a[k1 + 3] = -a[k1 + 3];\n        }\n    } else {\n        for (k = 0; k < m; k++) {\n            for (j = 0; j < k; j++) {\n                j1 = 4 * j + ip[m + k];\n                k1 = 4 * k + ip[m + j];\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += nm;\n                k1 += nm;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += nh;\n                k1 += 2;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 -= nm;\n                k1 -= nm;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += 2;\n                k1 += nh;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 += nm;\n                k1 += nm;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 -= nh;\n                k1 -= 2;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n                j1 -= nm;\n                k1 -= nm;\n                xr = a[j1];\n                xi = -a[j1 + 1];\n                yr = a[k1];\n                yi = -a[k1 + 1];\n                a[j1] = yr;\n                a[j1 + 1] = yi;\n                a[k1] = xr;\n                a[k1 + 1] = xi;\n            }\n            k1 = 4 * k + ip[m + k];\n            j1 = k1 + 2;\n            k1 += nh;\n            a[j1 - 1] = -a[j1 - 1];\n            xr = a[j1];\n            xi = -a[j1 + 1];\n            yr = a[k1];\n            yi = -a[k1 + 1];\n            a[j1] = yr;\n            a[j1 + 1] = yi;\n            a[k1] = xr;\n            a[k1 + 1] = xi;\n            a[k1 + 3] = -a[k1 + 3];\n            j1 += nm;\n            k1 += nm;\n            a[j1 - 1] = -a[j1 - 1];\n            xr = a[j1];\n            xi = -a[j1 + 1];\n            yr = a[k1];\n            yi = -a[k1 + 1];\n            a[j1] = yr;\n            a[j1 + 1] = yi;\n            a[k1] = xr;\n            a[k1 + 1] = xi;\n            a[k1 + 3] = -a[k1 + 3];\n        }\n    }\n}\n\n\nvoid bitrv216(FLOAT_TYPE_FFT *a)\n{\n    FLOAT_TYPE_FFT x1r, x1i, x2r, x2i, x3r, x3i, x4r, x4i, \n        x5r, x5i, x7r, x7i, x8r, x8i, x10r, x10i, \n        x11r, x11i, x12r, x12i, x13r, x13i, x14r, x14i;\n    \n    x1r = a[2];\n    x1i = a[3];\n    x2r = a[4];\n    x2i = a[5];\n    x3r = a[6];\n    x3i = a[7];\n    x4r = a[8];\n    x4i = a[9];\n    x5r = a[10];\n    x5i = a[11];\n    x7r = a[14];\n    x7i = a[15];\n    x8r = a[16];\n    x8i = a[17];\n    x10r = a[20];\n    x10i = a[21];\n    x11r = a[22];\n    x11i = a[23];\n    x12r = a[24];\n    x12i = a[25];\n    x13r = a[26];\n    x13i = a[27];\n    x14r = a[28];\n    x14i = a[29];\n    a[2] = x8r;\n    a[3] = x8i;\n    a[4] = x4r;\n    a[5] = x4i;\n    a[6] = x12r;\n    a[7] = x12i;\n    a[8] = x2r;\n    a[9] = x2i;\n    a[10] = x10r;\n    a[11] = x10i;\n    a[14] = x14r;\n    a[15] = x14i;\n    a[16] = x1r;\n    a[17] = x1i;\n    a[20] = x5r;\n    a[21] = x5i;\n    a[22] = x13r;\n    a[23] = x13i;\n    a[24] = x3r;\n    a[25] = x3i;\n    a[26] = x11r;\n    a[27] = x11i;\n    a[28] = x7r;\n    a[29] = x7i;\n}\n\n\nvoid bitrv216neg(FLOAT_TYPE_FFT *a)\n{\n    FLOAT_TYPE_FFT x1r, x1i, x2r, x2i, x3r, x3i, x4r, x4i, \n        x5r, x5i, x6r, x6i, x7r, x7i, x8r, x8i, \n        x9r, x9i, x10r, x10i, x11r, x11i, x12r, x12i, \n        x13r, x13i, x14r, x14i, x15r, x15i;\n    \n    x1r = a[2];\n    x1i = a[3];\n    x2r = a[4];\n    x2i = a[5];\n    x3r = a[6];\n    x3i = a[7];\n    x4r = a[8];\n    x4i = a[9];\n    x5r = a[10];\n    x5i = a[11];\n    x6r = a[12];\n    x6i = a[13];\n    x7r = a[14];\n    x7i = a[15];\n    x8r = a[16];\n    x8i = a[17];\n    x9r = a[18];\n    x9i = a[19];\n    x10r = a[20];\n    x10i = a[21];\n    x11r = a[22];\n    x11i = a[23];\n    x12r = a[24];\n    x12i = a[25];\n    x13r = a[26];\n    x13i = a[27];\n    x14r = a[28];\n    x14i = a[29];\n    x15r = a[30];\n    x15i = a[31];\n    a[2] = x15r;\n    a[3] = x15i;\n    a[4] = x7r;\n    a[5] = x7i;\n    a[6] = x11r;\n    a[7] = x11i;\n    a[8] = x3r;\n    a[9] = x3i;\n    a[10] = x13r;\n    a[11] = x13i;\n    a[12] = x5r;\n    a[13] = x5i;\n    a[14] = x9r;\n    a[15] = x9i;\n    a[16] = x1r;\n    a[17] = x1i;\n    a[18] = x14r;\n    a[19] = x14i;\n    a[20] = x6r;\n    a[21] = x6i;\n    a[22] = x10r;\n    a[23] = x10i;\n    a[24] = x2r;\n    a[25] = x2i;\n    a[26] = x12r;\n    a[27] = x12i;\n    a[28] = x4r;\n    a[29] = x4i;\n    a[30] = x8r;\n    a[31] = x8i;\n}\n\n\nvoid bitrv208(FLOAT_TYPE_FFT *a)\n{\n    FLOAT_TYPE_FFT x1r, x1i, x3r, x3i, x4r, x4i, x6r, x6i;\n    \n    x1r = a[2];\n    x1i = a[3];\n    x3r = a[6];\n    x3i = a[7];\n    x4r = a[8];\n    x4i = a[9];\n    x6r = a[12];\n    x6i = a[13];\n    a[2] = x4r;\n    a[3] = x4i;\n    a[6] = x6r;\n    a[7] = x6i;\n    a[8] = x1r;\n    a[9] = x1i;\n    a[12] = x3r;\n    a[13] = x3i;\n}\n\n\nvoid bitrv208neg(FLOAT_TYPE_FFT *a)\n{\n    FLOAT_TYPE_FFT x1r, x1i, x2r, x2i, x3r, x3i, x4r, x4i, \n        x5r, x5i, x6r, x6i, x7r, x7i;\n    \n    x1r = a[2];\n    x1i = a[3];\n    x2r = a[4];\n    x2i = a[5];\n    x3r = a[6];\n    x3i = a[7];\n    x4r = a[8];\n    x4i = a[9];\n    x5r = a[10];\n    x5i = a[11];\n    x6r = a[12];\n    x6i = a[13];\n    x7r = a[14];\n    x7i = a[15];\n    a[2] = x7r;\n    a[3] = x7i;\n    a[4] = x3r;\n    a[5] = x3i;\n    a[6] = x5r;\n    a[7] = x5i;\n    a[8] = x1r;\n    a[9] = x1i;\n    a[10] = x6r;\n    a[11] = x6i;\n    a[12] = x2r;\n    a[13] = x2i;\n    a[14] = x4r;\n    a[15] = x4i;\n}\n\n\nvoid cftf1st(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w)\n{\n    int j, j0, j1, j2, j3, k, m, mh;\n    FLOAT_TYPE_FFT wn4r, csc1, csc3, wk1r, wk1i, wk3r, wk3i, \n        wd1r, wd1i, wd3r, wd3i;\n    FLOAT_TYPE_FFT x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i, \n        y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i;\n    \n    mh = n >> 3;\n    m = 2 * mh;\n    j1 = m;\n    j2 = j1 + m;\n    j3 = j2 + m;\n    x0r = a[0] + a[j2];\n    x0i = a[1] + a[j2 + 1];\n    x1r = a[0] - a[j2];\n    x1i = a[1] - a[j2 + 1];\n    x2r = a[j1] + a[j3];\n    x2i = a[j1 + 1] + a[j3 + 1];\n    x3r = a[j1] - a[j3];\n    x3i = a[j1 + 1] - a[j3 + 1];\n    a[0] = x0r + x2r;\n    a[1] = x0i + x2i;\n    a[j1] = x0r - x2r;\n    a[j1 + 1] = x0i - x2i;\n    a[j2] = x1r - x3i;\n    a[j2 + 1] = x1i + x3r;\n    a[j3] = x1r + x3i;\n    a[j3 + 1] = x1i - x3r;\n    wn4r = w[1];\n    csc1 = w[2];\n    csc3 = w[3];\n    wd1r = 1;\n    wd1i = 0;\n    wd3r = 1;\n    wd3i = 0;\n    k = 0;\n    for (j = 2; j < mh - 2; j += 4) {\n        k += 4;\n        wk1r = csc1 * (wd1r + w[k]);\n        wk1i = csc1 * (wd1i + w[k + 1]);\n        wk3r = csc3 * (wd3r + w[k + 2]);\n        wk3i = csc3 * (wd3i + w[k + 3]);\n        wd1r = w[k];\n        wd1i = w[k + 1];\n        wd3r = w[k + 2];\n        wd3i = w[k + 3];\n        j1 = j + m;\n        j2 = j1 + m;\n        j3 = j2 + m;\n        x0r = a[j] + a[j2];\n        x0i = a[j + 1] + a[j2 + 1];\n        x1r = a[j] - a[j2];\n        x1i = a[j + 1] - a[j2 + 1];\n        y0r = a[j + 2] + a[j2 + 2];\n        y0i = a[j + 3] + a[j2 + 3];\n        y1r = a[j + 2] - a[j2 + 2];\n        y1i = a[j + 3] - a[j2 + 3];\n        x2r = a[j1] + a[j3];\n        x2i = a[j1 + 1] + a[j3 + 1];\n        x3r = a[j1] - a[j3];\n        x3i = a[j1 + 1] - a[j3 + 1];\n        y2r = a[j1 + 2] + a[j3 + 2];\n        y2i = a[j1 + 3] + a[j3 + 3];\n        y3r = a[j1 + 2] - a[j3 + 2];\n        y3i = a[j1 + 3] - a[j3 + 3];\n        a[j] = x0r + x2r;\n        a[j + 1] = x0i + x2i;\n        a[j + 2] = y0r + y2r;\n        a[j + 3] = y0i + y2i;\n        a[j1] = x0r - x2r;\n        a[j1 + 1] = x0i - x2i;\n        a[j1 + 2] = y0r - y2r;\n        a[j1 + 3] = y0i - y2i;\n        x0r = x1r - x3i;\n        x0i = x1i + x3r;\n        a[j2] = wk1r * x0r - wk1i * x0i;\n        a[j2 + 1] = wk1r * x0i + wk1i * x0r;\n        x0r = y1r - y3i;\n        x0i = y1i + y3r;\n        a[j2 + 2] = wd1r * x0r - wd1i * x0i;\n        a[j2 + 3] = wd1r * x0i + wd1i * x0r;\n        x0r = x1r + x3i;\n        x0i = x1i - x3r;\n        a[j3] = wk3r * x0r + wk3i * x0i;\n        a[j3 + 1] = wk3r * x0i - wk3i * x0r;\n        x0r = y1r + y3i;\n        x0i = y1i - y3r;\n        a[j3 + 2] = wd3r * x0r + wd3i * x0i;\n        a[j3 + 3] = wd3r * x0i - wd3i * x0r;\n        j0 = m - j;\n        j1 = j0 + m;\n        j2 = j1 + m;\n        j3 = j2 + m;\n        x0r = a[j0] + a[j2];\n        x0i = a[j0 + 1] + a[j2 + 1];\n        x1r = a[j0] - a[j2];\n        x1i = a[j0 + 1] - a[j2 + 1];\n        y0r = a[j0 - 2] + a[j2 - 2];\n        y0i = a[j0 - 1] + a[j2 - 1];\n        y1r = a[j0 - 2] - a[j2 - 2];\n        y1i = a[j0 - 1] - a[j2 - 1];\n        x2r = a[j1] + a[j3];\n        x2i = a[j1 + 1] + a[j3 + 1];\n        x3r = a[j1] - a[j3];\n        x3i = a[j1 + 1] - a[j3 + 1];\n        y2r = a[j1 - 2] + a[j3 - 2];\n        y2i = a[j1 - 1] + a[j3 - 1];\n        y3r = a[j1 - 2] - a[j3 - 2];\n        y3i = a[j1 - 1] - a[j3 - 1];\n        a[j0] = x0r + x2r;\n        a[j0 + 1] = x0i + x2i;\n        a[j0 - 2] = y0r + y2r;\n        a[j0 - 1] = y0i + y2i;\n        a[j1] = x0r - x2r;\n        a[j1 + 1] = x0i - x2i;\n        a[j1 - 2] = y0r - y2r;\n        a[j1 - 1] = y0i - y2i;\n        x0r = x1r - x3i;\n        x0i = x1i + x3r;\n        a[j2] = wk1i * x0r - wk1r * x0i;\n        a[j2 + 1] = wk1i * x0i + wk1r * x0r;\n        x0r = y1r - y3i;\n        x0i = y1i + y3r;\n        a[j2 - 2] = wd1i * x0r - wd1r * x0i;\n        a[j2 - 1] = wd1i * x0i + wd1r * x0r;\n        x0r = x1r + x3i;\n        x0i = x1i - x3r;\n        a[j3] = wk3i * x0r + wk3r * x0i;\n        a[j3 + 1] = wk3i * x0i - wk3r * x0r;\n        x0r = y1r + y3i;\n        x0i = y1i - y3r;\n        a[j3 - 2] = wd3i * x0r + wd3r * x0i;\n        a[j3 - 1] = wd3i * x0i - wd3r * x0r;\n    }\n    wk1r = csc1 * (wd1r + wn4r);\n    wk1i = csc1 * (wd1i + wn4r);\n    wk3r = csc3 * (wd3r - wn4r);\n    wk3i = csc3 * (wd3i - wn4r);\n    j0 = mh;\n    j1 = j0 + m;\n    j2 = j1 + m;\n    j3 = j2 + m;\n    x0r = a[j0 - 2] + a[j2 - 2];\n    x0i = a[j0 - 1] + a[j2 - 1];\n    x1r = a[j0 - 2] - a[j2 - 2];\n    x1i = a[j0 - 1] - a[j2 - 1];\n    x2r = a[j1 - 2] + a[j3 - 2];\n    x2i = a[j1 - 1] + a[j3 - 1];\n    x3r = a[j1 - 2] - a[j3 - 2];\n    x3i = a[j1 - 1] - a[j3 - 1];\n    a[j0 - 2] = x0r + x2r;\n    a[j0 - 1] = x0i + x2i;\n    a[j1 - 2] = x0r - x2r;\n    a[j1 - 1] = x0i - x2i;\n    x0r = x1r - x3i;\n    x0i = x1i + x3r;\n    a[j2 - 2] = wk1r * x0r - wk1i * x0i;\n    a[j2 - 1] = wk1r * x0i + wk1i * x0r;\n    x0r = x1r + x3i;\n    x0i = x1i - x3r;\n    a[j3 - 2] = wk3r * x0r + wk3i * x0i;\n    a[j3 - 1] = wk3r * x0i - wk3i * x0r;\n    x0r = a[j0] + a[j2];\n    x0i = a[j0 + 1] + a[j2 + 1];\n    x1r = a[j0] - a[j2];\n    x1i = a[j0 + 1] - a[j2 + 1];\n    x2r = a[j1] + a[j3];\n    x2i = a[j1 + 1] + a[j3 + 1];\n    x3r = a[j1] - a[j3];\n    x3i = a[j1 + 1] - a[j3 + 1];\n    a[j0] = x0r + x2r;\n    a[j0 + 1] = x0i + x2i;\n    a[j1] = x0r - x2r;\n    a[j1 + 1] = x0i - x2i;\n    x0r = x1r - x3i;\n    x0i = x1i + x3r;\n    a[j2] = wn4r * (x0r - x0i);\n    a[j2 + 1] = wn4r * (x0i + x0r);\n    x0r = x1r + x3i;\n    x0i = x1i - x3r;\n    a[j3] = -wn4r * (x0r + x0i);\n    a[j3 + 1] = -wn4r * (x0i - x0r);\n    x0r = a[j0 + 2] + a[j2 + 2];\n    x0i = a[j0 + 3] + a[j2 + 3];\n    x1r = a[j0 + 2] - a[j2 + 2];\n    x1i = a[j0 + 3] - a[j2 + 3];\n    x2r = a[j1 + 2] + a[j3 + 2];\n    x2i = a[j1 + 3] + a[j3 + 3];\n    x3r = a[j1 + 2] - a[j3 + 2];\n    x3i = a[j1 + 3] - a[j3 + 3];\n    a[j0 + 2] = x0r + x2r;\n    a[j0 + 3] = x0i + x2i;\n    a[j1 + 2] = x0r - x2r;\n    a[j1 + 3] = x0i - x2i;\n    x0r = x1r - x3i;\n    x0i = x1i + x3r;\n    a[j2 + 2] = wk1i * x0r - wk1r * x0i;\n    a[j2 + 3] = wk1i * x0i + wk1r * x0r;\n    x0r = x1r + x3i;\n    x0i = x1i - x3r;\n    a[j3 + 2] = wk3i * x0r + wk3r * x0i;\n    a[j3 + 3] = wk3i * x0i - wk3r * x0r;\n}\n\n\nvoid cftb1st(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w)\n{\n    int j, j0, j1, j2, j3, k, m, mh;\n    FLOAT_TYPE_FFT wn4r, csc1, csc3, wk1r, wk1i, wk3r, wk3i, \n        wd1r, wd1i, wd3r, wd3i;\n    FLOAT_TYPE_FFT x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i, \n        y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i;\n    \n    mh = n >> 3;\n    m = 2 * mh;\n    j1 = m;\n    j2 = j1 + m;\n    j3 = j2 + m;\n    x0r = a[0] + a[j2];\n    x0i = -a[1] - a[j2 + 1];\n    x1r = a[0] - a[j2];\n    x1i = -a[1] + a[j2 + 1];\n    x2r = a[j1] + a[j3];\n    x2i = a[j1 + 1] + a[j3 + 1];\n    x3r = a[j1] - a[j3];\n    x3i = a[j1 + 1] - a[j3 + 1];\n    a[0] = x0r + x2r;\n    a[1] = x0i - x2i;\n    a[j1] = x0r - x2r;\n    a[j1 + 1] = x0i + x2i;\n    a[j2] = x1r + x3i;\n    a[j2 + 1] = x1i + x3r;\n    a[j3] = x1r - x3i;\n    a[j3 + 1] = x1i - x3r;\n    wn4r = w[1];\n    csc1 = w[2];\n    csc3 = w[3];\n    wd1r = 1;\n    wd1i = 0;\n    wd3r = 1;\n    wd3i = 0;\n    k = 0;\n    for (j = 2; j < mh - 2; j += 4) {\n        k += 4;\n        wk1r = csc1 * (wd1r + w[k]);\n        wk1i = csc1 * (wd1i + w[k + 1]);\n        wk3r = csc3 * (wd3r + w[k + 2]);\n        wk3i = csc3 * (wd3i + w[k + 3]);\n        wd1r = w[k];\n        wd1i = w[k + 1];\n        wd3r = w[k + 2];\n        wd3i = w[k + 3];\n        j1 = j + m;\n        j2 = j1 + m;\n        j3 = j2 + m;\n        x0r = a[j] + a[j2];\n        x0i = -a[j + 1] - a[j2 + 1];\n        x1r = a[j] - a[j2];\n        x1i = -a[j + 1] + a[j2 + 1];\n        y0r = a[j + 2] + a[j2 + 2];\n        y0i = -a[j + 3] - a[j2 + 3];\n        y1r = a[j + 2] - a[j2 + 2];\n        y1i = -a[j + 3] + a[j2 + 3];\n        x2r = a[j1] + a[j3];\n        x2i = a[j1 + 1] + a[j3 + 1];\n        x3r = a[j1] - a[j3];\n        x3i = a[j1 + 1] - a[j3 + 1];\n        y2r = a[j1 + 2] + a[j3 + 2];\n        y2i = a[j1 + 3] + a[j3 + 3];\n        y3r = a[j1 + 2] - a[j3 + 2];\n        y3i = a[j1 + 3] - a[j3 + 3];\n        a[j] = x0r + x2r;\n        a[j + 1] = x0i - x2i;\n        a[j + 2] = y0r + y2r;\n        a[j + 3] = y0i - y2i;\n        a[j1] = x0r - x2r;\n        a[j1 + 1] = x0i + x2i;\n        a[j1 + 2] = y0r - y2r;\n        a[j1 + 3] = y0i + y2i;\n        x0r = x1r + x3i;\n        x0i = x1i + x3r;\n        a[j2] = wk1r * x0r - wk1i * x0i;\n        a[j2 + 1] = wk1r * x0i + wk1i * x0r;\n        x0r = y1r + y3i;\n        x0i = y1i + y3r;\n        a[j2 + 2] = wd1r * x0r - wd1i * x0i;\n        a[j2 + 3] = wd1r * x0i + wd1i * x0r;\n        x0r = x1r - x3i;\n        x0i = x1i - x3r;\n        a[j3] = wk3r * x0r + wk3i * x0i;\n        a[j3 + 1] = wk3r * x0i - wk3i * x0r;\n        x0r = y1r - y3i;\n        x0i = y1i - y3r;\n        a[j3 + 2] = wd3r * x0r + wd3i * x0i;\n        a[j3 + 3] = wd3r * x0i - wd3i * x0r;\n        j0 = m - j;\n        j1 = j0 + m;\n        j2 = j1 + m;\n        j3 = j2 + m;\n        x0r = a[j0] + a[j2];\n        x0i = -a[j0 + 1] - a[j2 + 1];\n        x1r = a[j0] - a[j2];\n        x1i = -a[j0 + 1] + a[j2 + 1];\n        y0r = a[j0 - 2] + a[j2 - 2];\n        y0i = -a[j0 - 1] - a[j2 - 1];\n        y1r = a[j0 - 2] - a[j2 - 2];\n        y1i = -a[j0 - 1] + a[j2 - 1];\n        x2r = a[j1] + a[j3];\n        x2i = a[j1 + 1] + a[j3 + 1];\n        x3r = a[j1] - a[j3];\n        x3i = a[j1 + 1] - a[j3 + 1];\n        y2r = a[j1 - 2] + a[j3 - 2];\n        y2i = a[j1 - 1] + a[j3 - 1];\n        y3r = a[j1 - 2] - a[j3 - 2];\n        y3i = a[j1 - 1] - a[j3 - 1];\n        a[j0] = x0r + x2r;\n        a[j0 + 1] = x0i - x2i;\n        a[j0 - 2] = y0r + y2r;\n        a[j0 - 1] = y0i - y2i;\n        a[j1] = x0r - x2r;\n        a[j1 + 1] = x0i + x2i;\n        a[j1 - 2] = y0r - y2r;\n        a[j1 - 1] = y0i + y2i;\n        x0r = x1r + x3i;\n        x0i = x1i + x3r;\n        a[j2] = wk1i * x0r - wk1r * x0i;\n        a[j2 + 1] = wk1i * x0i + wk1r * x0r;\n        x0r = y1r + y3i;\n        x0i = y1i + y3r;\n        a[j2 - 2] = wd1i * x0r - wd1r * x0i;\n        a[j2 - 1] = wd1i * x0i + wd1r * x0r;\n        x0r = x1r - x3i;\n        x0i = x1i - x3r;\n        a[j3] = wk3i * x0r + wk3r * x0i;\n        a[j3 + 1] = wk3i * x0i - wk3r * x0r;\n        x0r = y1r - y3i;\n        x0i = y1i - y3r;\n        a[j3 - 2] = wd3i * x0r + wd3r * x0i;\n        a[j3 - 1] = wd3i * x0i - wd3r * x0r;\n    }\n    wk1r = csc1 * (wd1r + wn4r);\n    wk1i = csc1 * (wd1i + wn4r);\n    wk3r = csc3 * (wd3r - wn4r);\n    wk3i = csc3 * (wd3i - wn4r);\n    j0 = mh;\n    j1 = j0 + m;\n    j2 = j1 + m;\n    j3 = j2 + m;\n    x0r = a[j0 - 2] + a[j2 - 2];\n    x0i = -a[j0 - 1] - a[j2 - 1];\n    x1r = a[j0 - 2] - a[j2 - 2];\n    x1i = -a[j0 - 1] + a[j2 - 1];\n    x2r = a[j1 - 2] + a[j3 - 2];\n    x2i = a[j1 - 1] + a[j3 - 1];\n    x3r = a[j1 - 2] - a[j3 - 2];\n    x3i = a[j1 - 1] - a[j3 - 1];\n    a[j0 - 2] = x0r + x2r;\n    a[j0 - 1] = x0i - x2i;\n    a[j1 - 2] = x0r - x2r;\n    a[j1 - 1] = x0i + x2i;\n    x0r = x1r + x3i;\n    x0i = x1i + x3r;\n    a[j2 - 2] = wk1r * x0r - wk1i * x0i;\n    a[j2 - 1] = wk1r * x0i + wk1i * x0r;\n    x0r = x1r - x3i;\n    x0i = x1i - x3r;\n    a[j3 - 2] = wk3r * x0r + wk3i * x0i;\n    a[j3 - 1] = wk3r * x0i - wk3i * x0r;\n    x0r = a[j0] + a[j2];\n    x0i = -a[j0 + 1] - a[j2 + 1];\n    x1r = a[j0] - a[j2];\n    x1i = -a[j0 + 1] + a[j2 + 1];\n    x2r = a[j1] + a[j3];\n    x2i = a[j1 + 1] + a[j3 + 1];\n    x3r = a[j1] - a[j3];\n    x3i = a[j1 + 1] - a[j3 + 1];\n    a[j0] = x0r + x2r;\n    a[j0 + 1] = x0i - x2i;\n    a[j1] = x0r - x2r;\n    a[j1 + 1] = x0i + x2i;\n    x0r = x1r + x3i;\n    x0i = x1i + x3r;\n    a[j2] = wn4r * (x0r - x0i);\n    a[j2 + 1] = wn4r * (x0i + x0r);\n    x0r = x1r - x3i;\n    x0i = x1i - x3r;\n    a[j3] = -wn4r * (x0r + x0i);\n    a[j3 + 1] = -wn4r * (x0i - x0r);\n    x0r = a[j0 + 2] + a[j2 + 2];\n    x0i = -a[j0 + 3] - a[j2 + 3];\n    x1r = a[j0 + 2] - a[j2 + 2];\n    x1i = -a[j0 + 3] + a[j2 + 3];\n    x2r = a[j1 + 2] + a[j3 + 2];\n    x2i = a[j1 + 3] + a[j3 + 3];\n    x3r = a[j1 + 2] - a[j3 + 2];\n    x3i = a[j1 + 3] - a[j3 + 3];\n    a[j0 + 2] = x0r + x2r;\n    a[j0 + 3] = x0i - x2i;\n    a[j1 + 2] = x0r - x2r;\n    a[j1 + 3] = x0i + x2i;\n    x0r = x1r + x3i;\n    x0i = x1i + x3r;\n    a[j2 + 2] = wk1i * x0r - wk1r * x0i;\n    a[j2 + 3] = wk1i * x0i + wk1r * x0r;\n    x0r = x1r - x3i;\n    x0i = x1i - x3r;\n    a[j3 + 2] = wk3i * x0r + wk3r * x0i;\n    a[j3 + 3] = wk3i * x0i - wk3r * x0r;\n}\n\n\n#ifdef USE_CDFT_THREADS\nstruct cdft_arg_st {\n    int n0;\n    int n;\n    FLOAT_TYPE_FFT *a;\n    int nw;\n    FLOAT_TYPE_FFT *w;\n};\ntypedef struct cdft_arg_st cdft_arg_t;\n\n\nvoid cftrec4_th(int n, FLOAT_TYPE_FFT *a, int nw, FLOAT_TYPE_FFT *w)\n{\n    void *cftrec1_th(void *p);\n    void *cftrec2_th(void *p);\n    int i, idiv4, m, nthread;\n    cdft_thread_t th[4];\n    cdft_arg_t ag[4];\n    \n    nthread = 2;\n    idiv4 = 0;\n    m = n >> 1;\n    if (n > CDFT_4THREADS_BEGIN_N) {\n        nthread = 4;\n        idiv4 = 1;\n        m >>= 1;\n    }\n    for (i = 0; i < nthread; i++) {\n        ag[i].n0 = n;\n        ag[i].n = m;\n        ag[i].a = &a[i * m];\n        ag[i].nw = nw;\n        ag[i].w = w;\n        if (i != idiv4) {\n            cdft_thread_create(&th[i], cftrec1_th, &ag[i]);\n        } else {\n            cdft_thread_create(&th[i], cftrec2_th, &ag[i]);\n        }\n    }\n    for (i = 0; i < nthread; i++) {\n        cdft_thread_wait(th[i]);\n    }\n}\n\n\nvoid *cftrec1_th(void *p)\n{\n    int cfttree(int n, int j, int k, FLOAT_TYPE_FFT *a, int nw, FLOAT_TYPE_FFT *w);\n    void cftleaf(int n, int isplt, FLOAT_TYPE_FFT *a, int nw, FLOAT_TYPE_FFT *w);\n    void cftmdl1(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    int isplt, j, k, m, n, n0, nw;\n    FLOAT_TYPE_FFT *a, *w;\n    \n    n0 = ((cdft_arg_t *) p)->n0;\n    n = ((cdft_arg_t *) p)->n;\n    a = ((cdft_arg_t *) p)->a;\n    nw = ((cdft_arg_t *) p)->nw;\n    w = ((cdft_arg_t *) p)->w;\n    m = n0;\n    while (m > 512) {\n        m >>= 2;\n        cftmdl1(m, &a[n - m], &w[nw - (m >> 1)]);\n    }\n    cftleaf(m, 1, &a[n - m], nw, w);\n    k = 0;\n    for (j = n - m; j > 0; j -= m) {\n        k++;\n        isplt = cfttree(m, j, k, a, nw, w);\n        cftleaf(m, isplt, &a[j - m], nw, w);\n    }\n    return (void *) 0;\n}\n\n\nvoid *cftrec2_th(void *p)\n{\n    int cfttree(int n, int j, int k, FLOAT_TYPE_FFT *a, int nw, FLOAT_TYPE_FFT *w);\n    void cftleaf(int n, int isplt, FLOAT_TYPE_FFT *a, int nw, FLOAT_TYPE_FFT *w);\n    void cftmdl2(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    int isplt, j, k, m, n, n0, nw;\n    FLOAT_TYPE_FFT *a, *w;\n    \n    n0 = ((cdft_arg_t *) p)->n0;\n    n = ((cdft_arg_t *) p)->n;\n    a = ((cdft_arg_t *) p)->a;\n    nw = ((cdft_arg_t *) p)->nw;\n    w = ((cdft_arg_t *) p)->w;\n    k = 1;\n    m = n0;\n    while (m > 512) {\n        m >>= 2;\n        k <<= 2;\n        cftmdl2(m, &a[n - m], &w[nw - m]);\n    }\n    cftleaf(m, 0, &a[n - m], nw, w);\n    k >>= 1;\n    for (j = n - m; j > 0; j -= m) {\n        k++;\n        isplt = cfttree(m, j, k, a, nw, w);\n        cftleaf(m, isplt, &a[j - m], nw, w);\n    }\n    return (void *) 0;\n}\n#endif /* USE_CDFT_THREADS */\n\n\nvoid cftrec4(int n, FLOAT_TYPE_FFT *a, int nw, FLOAT_TYPE_FFT *w)\n{\n    int cfttree(int n, int j, int k, FLOAT_TYPE_FFT *a, int nw, FLOAT_TYPE_FFT *w);\n    void cftleaf(int n, int isplt, FLOAT_TYPE_FFT *a, int nw, FLOAT_TYPE_FFT *w);\n    void cftmdl1(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    int isplt, j, k, m;\n    \n    m = n;\n    while (m > 512) {\n        m >>= 2;\n        cftmdl1(m, &a[n - m], &w[nw - (m >> 1)]);\n    }\n    cftleaf(m, 1, &a[n - m], nw, w);\n    k = 0;\n    for (j = n - m; j > 0; j -= m) {\n        k++;\n        isplt = cfttree(m, j, k, a, nw, w);\n        cftleaf(m, isplt, &a[j - m], nw, w);\n    }\n}\n\n\nint cfttree(int n, int j, int k, FLOAT_TYPE_FFT *a, int nw, FLOAT_TYPE_FFT *w)\n{\n    void cftmdl1(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void cftmdl2(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    int i, isplt, m;\n    \n    if ((k & 3) != 0) {\n        isplt = k & 1;\n        if (isplt != 0) {\n            cftmdl1(n, &a[j - n], &w[nw - (n >> 1)]);\n        } else {\n            cftmdl2(n, &a[j - n], &w[nw - n]);\n        }\n    } else {\n        m = n;\n        for (i = k; (i & 3) == 0; i >>= 2) {\n            m <<= 2;\n        }\n        isplt = i & 1;\n        if (isplt != 0) {\n            while (m > 128) {\n                cftmdl1(m, &a[j - m], &w[nw - (m >> 1)]);\n                m >>= 2;\n            }\n        } else {\n            while (m > 128) {\n                cftmdl2(m, &a[j - m], &w[nw - m]);\n                m >>= 2;\n            }\n        }\n    }\n    return isplt;\n}\n\n\nvoid cftleaf(int n, int isplt, FLOAT_TYPE_FFT *a, int nw, FLOAT_TYPE_FFT *w)\n{\n    void cftmdl1(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void cftmdl2(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void cftf161(FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void cftf162(FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void cftf081(FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void cftf082(FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    \n    if (n == 512) {\n        cftmdl1(128, a, &w[nw - 64]);\n        cftf161(a, &w[nw - 8]);\n        cftf162(&a[32], &w[nw - 32]);\n        cftf161(&a[64], &w[nw - 8]);\n        cftf161(&a[96], &w[nw - 8]);\n        cftmdl2(128, &a[128], &w[nw - 128]);\n        cftf161(&a[128], &w[nw - 8]);\n        cftf162(&a[160], &w[nw - 32]);\n        cftf161(&a[192], &w[nw - 8]);\n        cftf162(&a[224], &w[nw - 32]);\n        cftmdl1(128, &a[256], &w[nw - 64]);\n        cftf161(&a[256], &w[nw - 8]);\n        cftf162(&a[288], &w[nw - 32]);\n        cftf161(&a[320], &w[nw - 8]);\n        cftf161(&a[352], &w[nw - 8]);\n        if (isplt != 0) {\n            cftmdl1(128, &a[384], &w[nw - 64]);\n            cftf161(&a[480], &w[nw - 8]);\n        } else {\n            cftmdl2(128, &a[384], &w[nw - 128]);\n            cftf162(&a[480], &w[nw - 32]);\n        }\n        cftf161(&a[384], &w[nw - 8]);\n        cftf162(&a[416], &w[nw - 32]);\n        cftf161(&a[448], &w[nw - 8]);\n    } else {\n        cftmdl1(64, a, &w[nw - 32]);\n        cftf081(a, &w[nw - 8]);\n        cftf082(&a[16], &w[nw - 8]);\n        cftf081(&a[32], &w[nw - 8]);\n        cftf081(&a[48], &w[nw - 8]);\n        cftmdl2(64, &a[64], &w[nw - 64]);\n        cftf081(&a[64], &w[nw - 8]);\n        cftf082(&a[80], &w[nw - 8]);\n        cftf081(&a[96], &w[nw - 8]);\n        cftf082(&a[112], &w[nw - 8]);\n        cftmdl1(64, &a[128], &w[nw - 32]);\n        cftf081(&a[128], &w[nw - 8]);\n        cftf082(&a[144], &w[nw - 8]);\n        cftf081(&a[160], &w[nw - 8]);\n        cftf081(&a[176], &w[nw - 8]);\n        if (isplt != 0) {\n            cftmdl1(64, &a[192], &w[nw - 32]);\n            cftf081(&a[240], &w[nw - 8]);\n        } else {\n            cftmdl2(64, &a[192], &w[nw - 64]);\n            cftf082(&a[240], &w[nw - 8]);\n        }\n        cftf081(&a[192], &w[nw - 8]);\n        cftf082(&a[208], &w[nw - 8]);\n        cftf081(&a[224], &w[nw - 8]);\n    }\n}\n\n\nvoid cftmdl1(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w)\n{\n    int j, j0, j1, j2, j3, k, m, mh;\n    FLOAT_TYPE_FFT wn4r, wk1r, wk1i, wk3r, wk3i;\n    FLOAT_TYPE_FFT x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;\n    \n    mh = n >> 3;\n    m = 2 * mh;\n    j1 = m;\n    j2 = j1 + m;\n    j3 = j2 + m;\n    x0r = a[0] + a[j2];\n    x0i = a[1] + a[j2 + 1];\n    x1r = a[0] - a[j2];\n    x1i = a[1] - a[j2 + 1];\n    x2r = a[j1] + a[j3];\n    x2i = a[j1 + 1] + a[j3 + 1];\n    x3r = a[j1] - a[j3];\n    x3i = a[j1 + 1] - a[j3 + 1];\n    a[0] = x0r + x2r;\n    a[1] = x0i + x2i;\n    a[j1] = x0r - x2r;\n    a[j1 + 1] = x0i - x2i;\n    a[j2] = x1r - x3i;\n    a[j2 + 1] = x1i + x3r;\n    a[j3] = x1r + x3i;\n    a[j3 + 1] = x1i - x3r;\n    wn4r = w[1];\n    k = 0;\n    for (j = 2; j < mh; j += 2) {\n        k += 4;\n        wk1r = w[k];\n        wk1i = w[k + 1];\n        wk3r = w[k + 2];\n        wk3i = w[k + 3];\n        j1 = j + m;\n        j2 = j1 + m;\n        j3 = j2 + m;\n        x0r = a[j] + a[j2];\n        x0i = a[j + 1] + a[j2 + 1];\n        x1r = a[j] - a[j2];\n        x1i = a[j + 1] - a[j2 + 1];\n        x2r = a[j1] + a[j3];\n        x2i = a[j1 + 1] + a[j3 + 1];\n        x3r = a[j1] - a[j3];\n        x3i = a[j1 + 1] - a[j3 + 1];\n        a[j] = x0r + x2r;\n        a[j + 1] = x0i + x2i;\n        a[j1] = x0r - x2r;\n        a[j1 + 1] = x0i - x2i;\n        x0r = x1r - x3i;\n        x0i = x1i + x3r;\n        a[j2] = wk1r * x0r - wk1i * x0i;\n        a[j2 + 1] = wk1r * x0i + wk1i * x0r;\n        x0r = x1r + x3i;\n        x0i = x1i - x3r;\n        a[j3] = wk3r * x0r + wk3i * x0i;\n        a[j3 + 1] = wk3r * x0i - wk3i * x0r;\n        j0 = m - j;\n        j1 = j0 + m;\n        j2 = j1 + m;\n        j3 = j2 + m;\n        x0r = a[j0] + a[j2];\n        x0i = a[j0 + 1] + a[j2 + 1];\n        x1r = a[j0] - a[j2];\n        x1i = a[j0 + 1] - a[j2 + 1];\n        x2r = a[j1] + a[j3];\n        x2i = a[j1 + 1] + a[j3 + 1];\n        x3r = a[j1] - a[j3];\n        x3i = a[j1 + 1] - a[j3 + 1];\n        a[j0] = x0r + x2r;\n        a[j0 + 1] = x0i + x2i;\n        a[j1] = x0r - x2r;\n        a[j1 + 1] = x0i - x2i;\n        x0r = x1r - x3i;\n        x0i = x1i + x3r;\n        a[j2] = wk1i * x0r - wk1r * x0i;\n        a[j2 + 1] = wk1i * x0i + wk1r * x0r;\n        x0r = x1r + x3i;\n        x0i = x1i - x3r;\n        a[j3] = wk3i * x0r + wk3r * x0i;\n        a[j3 + 1] = wk3i * x0i - wk3r * x0r;\n    }\n    j0 = mh;\n    j1 = j0 + m;\n    j2 = j1 + m;\n    j3 = j2 + m;\n    x0r = a[j0] + a[j2];\n    x0i = a[j0 + 1] + a[j2 + 1];\n    x1r = a[j0] - a[j2];\n    x1i = a[j0 + 1] - a[j2 + 1];\n    x2r = a[j1] + a[j3];\n    x2i = a[j1 + 1] + a[j3 + 1];\n    x3r = a[j1] - a[j3];\n    x3i = a[j1 + 1] - a[j3 + 1];\n    a[j0] = x0r + x2r;\n    a[j0 + 1] = x0i + x2i;\n    a[j1] = x0r - x2r;\n    a[j1 + 1] = x0i - x2i;\n    x0r = x1r - x3i;\n    x0i = x1i + x3r;\n    a[j2] = wn4r * (x0r - x0i);\n    a[j2 + 1] = wn4r * (x0i + x0r);\n    x0r = x1r + x3i;\n    x0i = x1i - x3r;\n    a[j3] = -wn4r * (x0r + x0i);\n    a[j3 + 1] = -wn4r * (x0i - x0r);\n}\n\n\nvoid cftmdl2(int n, FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w)\n{\n    int j, j0, j1, j2, j3, k, kr, m, mh;\n    FLOAT_TYPE_FFT wn4r, wk1r, wk1i, wk3r, wk3i, wd1r, wd1i, wd3r, wd3i;\n    FLOAT_TYPE_FFT x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i, y0r, y0i, y2r, y2i;\n    \n    mh = n >> 3;\n    m = 2 * mh;\n    wn4r = w[1];\n    j1 = m;\n    j2 = j1 + m;\n    j3 = j2 + m;\n    x0r = a[0] - a[j2 + 1];\n    x0i = a[1] + a[j2];\n    x1r = a[0] + a[j2 + 1];\n    x1i = a[1] - a[j2];\n    x2r = a[j1] - a[j3 + 1];\n    x2i = a[j1 + 1] + a[j3];\n    x3r = a[j1] + a[j3 + 1];\n    x3i = a[j1 + 1] - a[j3];\n    y0r = wn4r * (x2r - x2i);\n    y0i = wn4r * (x2i + x2r);\n    a[0] = x0r + y0r;\n    a[1] = x0i + y0i;\n    a[j1] = x0r - y0r;\n    a[j1 + 1] = x0i - y0i;\n    y0r = wn4r * (x3r - x3i);\n    y0i = wn4r * (x3i + x3r);\n    a[j2] = x1r - y0i;\n    a[j2 + 1] = x1i + y0r;\n    a[j3] = x1r + y0i;\n    a[j3 + 1] = x1i - y0r;\n    k = 0;\n    kr = 2 * m;\n    for (j = 2; j < mh; j += 2) {\n        k += 4;\n        wk1r = w[k];\n        wk1i = w[k + 1];\n        wk3r = w[k + 2];\n        wk3i = w[k + 3];\n        kr -= 4;\n        wd1i = w[kr];\n        wd1r = w[kr + 1];\n        wd3i = w[kr + 2];\n        wd3r = w[kr + 3];\n        j1 = j + m;\n        j2 = j1 + m;\n        j3 = j2 + m;\n        x0r = a[j] - a[j2 + 1];\n        x0i = a[j + 1] + a[j2];\n        x1r = a[j] + a[j2 + 1];\n        x1i = a[j + 1] - a[j2];\n        x2r = a[j1] - a[j3 + 1];\n        x2i = a[j1 + 1] + a[j3];\n        x3r = a[j1] + a[j3 + 1];\n        x3i = a[j1 + 1] - a[j3];\n        y0r = wk1r * x0r - wk1i * x0i;\n        y0i = wk1r * x0i + wk1i * x0r;\n        y2r = wd1r * x2r - wd1i * x2i;\n        y2i = wd1r * x2i + wd1i * x2r;\n        a[j] = y0r + y2r;\n        a[j + 1] = y0i + y2i;\n        a[j1] = y0r - y2r;\n        a[j1 + 1] = y0i - y2i;\n        y0r = wk3r * x1r + wk3i * x1i;\n        y0i = wk3r * x1i - wk3i * x1r;\n        y2r = wd3r * x3r + wd3i * x3i;\n        y2i = wd3r * x3i - wd3i * x3r;\n        a[j2] = y0r + y2r;\n        a[j2 + 1] = y0i + y2i;\n        a[j3] = y0r - y2r;\n        a[j3 + 1] = y0i - y2i;\n        j0 = m - j;\n        j1 = j0 + m;\n        j2 = j1 + m;\n        j3 = j2 + m;\n        x0r = a[j0] - a[j2 + 1];\n        x0i = a[j0 + 1] + a[j2];\n        x1r = a[j0] + a[j2 + 1];\n        x1i = a[j0 + 1] - a[j2];\n        x2r = a[j1] - a[j3 + 1];\n        x2i = a[j1 + 1] + a[j3];\n        x3r = a[j1] + a[j3 + 1];\n        x3i = a[j1 + 1] - a[j3];\n        y0r = wd1i * x0r - wd1r * x0i;\n        y0i = wd1i * x0i + wd1r * x0r;\n        y2r = wk1i * x2r - wk1r * x2i;\n        y2i = wk1i * x2i + wk1r * x2r;\n        a[j0] = y0r + y2r;\n        a[j0 + 1] = y0i + y2i;\n        a[j1] = y0r - y2r;\n        a[j1 + 1] = y0i - y2i;\n        y0r = wd3i * x1r + wd3r * x1i;\n        y0i = wd3i * x1i - wd3r * x1r;\n        y2r = wk3i * x3r + wk3r * x3i;\n        y2i = wk3i * x3i - wk3r * x3r;\n        a[j2] = y0r + y2r;\n        a[j2 + 1] = y0i + y2i;\n        a[j3] = y0r - y2r;\n        a[j3 + 1] = y0i - y2i;\n    }\n    wk1r = w[m];\n    wk1i = w[m + 1];\n    j0 = mh;\n    j1 = j0 + m;\n    j2 = j1 + m;\n    j3 = j2 + m;\n    x0r = a[j0] - a[j2 + 1];\n    x0i = a[j0 + 1] + a[j2];\n    x1r = a[j0] + a[j2 + 1];\n    x1i = a[j0 + 1] - a[j2];\n    x2r = a[j1] - a[j3 + 1];\n    x2i = a[j1 + 1] + a[j3];\n    x3r = a[j1] + a[j3 + 1];\n    x3i = a[j1 + 1] - a[j3];\n    y0r = wk1r * x0r - wk1i * x0i;\n    y0i = wk1r * x0i + wk1i * x0r;\n    y2r = wk1i * x2r - wk1r * x2i;\n    y2i = wk1i * x2i + wk1r * x2r;\n    a[j0] = y0r + y2r;\n    a[j0 + 1] = y0i + y2i;\n    a[j1] = y0r - y2r;\n    a[j1 + 1] = y0i - y2i;\n    y0r = wk1i * x1r - wk1r * x1i;\n    y0i = wk1i * x1i + wk1r * x1r;\n    y2r = wk1r * x3r - wk1i * x3i;\n    y2i = wk1r * x3i + wk1i * x3r;\n    a[j2] = y0r - y2r;\n    a[j2 + 1] = y0i - y2i;\n    a[j3] = y0r + y2r;\n    a[j3 + 1] = y0i + y2i;\n}\n\n\nvoid cftfx41(int n, FLOAT_TYPE_FFT *a, int nw, FLOAT_TYPE_FFT *w)\n{\n    void cftf161(FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void cftf162(FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void cftf081(FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    void cftf082(FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w);\n    \n    if (n == 128) {\n        cftf161(a, &w[nw - 8]);\n        cftf162(&a[32], &w[nw - 32]);\n        cftf161(&a[64], &w[nw - 8]);\n        cftf161(&a[96], &w[nw - 8]);\n    } else {\n        cftf081(a, &w[nw - 8]);\n        cftf082(&a[16], &w[nw - 8]);\n        cftf081(&a[32], &w[nw - 8]);\n        cftf081(&a[48], &w[nw - 8]);\n    }\n}\n\n\nvoid cftf161(FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w)\n{\n    FLOAT_TYPE_FFT wn4r, wk1r, wk1i, \n        x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i, \n        y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i, \n        y4r, y4i, y5r, y5i, y6r, y6i, y7r, y7i, \n        y8r, y8i, y9r, y9i, y10r, y10i, y11r, y11i, \n        y12r, y12i, y13r, y13i, y14r, y14i, y15r, y15i;\n    \n    wn4r = w[1];\n    wk1r = w[2];\n    wk1i = w[3];\n    x0r = a[0] + a[16];\n    x0i = a[1] + a[17];\n    x1r = a[0] - a[16];\n    x1i = a[1] - a[17];\n    x2r = a[8] + a[24];\n    x2i = a[9] + a[25];\n    x3r = a[8] - a[24];\n    x3i = a[9] - a[25];\n    y0r = x0r + x2r;\n    y0i = x0i + x2i;\n    y4r = x0r - x2r;\n    y4i = x0i - x2i;\n    y8r = x1r - x3i;\n    y8i = x1i + x3r;\n    y12r = x1r + x3i;\n    y12i = x1i - x3r;\n    x0r = a[2] + a[18];\n    x0i = a[3] + a[19];\n    x1r = a[2] - a[18];\n    x1i = a[3] - a[19];\n    x2r = a[10] + a[26];\n    x2i = a[11] + a[27];\n    x3r = a[10] - a[26];\n    x3i = a[11] - a[27];\n    y1r = x0r + x2r;\n    y1i = x0i + x2i;\n    y5r = x0r - x2r;\n    y5i = x0i - x2i;\n    x0r = x1r - x3i;\n    x0i = x1i + x3r;\n    y9r = wk1r * x0r - wk1i * x0i;\n    y9i = wk1r * x0i + wk1i * x0r;\n    x0r = x1r + x3i;\n    x0i = x1i - x3r;\n    y13r = wk1i * x0r - wk1r * x0i;\n    y13i = wk1i * x0i + wk1r * x0r;\n    x0r = a[4] + a[20];\n    x0i = a[5] + a[21];\n    x1r = a[4] - a[20];\n    x1i = a[5] - a[21];\n    x2r = a[12] + a[28];\n    x2i = a[13] + a[29];\n    x3r = a[12] - a[28];\n    x3i = a[13] - a[29];\n    y2r = x0r + x2r;\n    y2i = x0i + x2i;\n    y6r = x0r - x2r;\n    y6i = x0i - x2i;\n    x0r = x1r - x3i;\n    x0i = x1i + x3r;\n    y10r = wn4r * (x0r - x0i);\n    y10i = wn4r * (x0i + x0r);\n    x0r = x1r + x3i;\n    x0i = x1i - x3r;\n    y14r = wn4r * (x0r + x0i);\n    y14i = wn4r * (x0i - x0r);\n    x0r = a[6] + a[22];\n    x0i = a[7] + a[23];\n    x1r = a[6] - a[22];\n    x1i = a[7] - a[23];\n    x2r = a[14] + a[30];\n    x2i = a[15] + a[31];\n    x3r = a[14] - a[30];\n    x3i = a[15] - a[31];\n    y3r = x0r + x2r;\n    y3i = x0i + x2i;\n    y7r = x0r - x2r;\n    y7i = x0i - x2i;\n    x0r = x1r - x3i;\n    x0i = x1i + x3r;\n    y11r = wk1i * x0r - wk1r * x0i;\n    y11i = wk1i * x0i + wk1r * x0r;\n    x0r = x1r + x3i;\n    x0i = x1i - x3r;\n    y15r = wk1r * x0r - wk1i * x0i;\n    y15i = wk1r * x0i + wk1i * x0r;\n    x0r = y12r - y14r;\n    x0i = y12i - y14i;\n    x1r = y12r + y14r;\n    x1i = y12i + y14i;\n    x2r = y13r - y15r;\n    x2i = y13i - y15i;\n    x3r = y13r + y15r;\n    x3i = y13i + y15i;\n    a[24] = x0r + x2r;\n    a[25] = x0i + x2i;\n    a[26] = x0r - x2r;\n    a[27] = x0i - x2i;\n    a[28] = x1r - x3i;\n    a[29] = x1i + x3r;\n    a[30] = x1r + x3i;\n    a[31] = x1i - x3r;\n    x0r = y8r + y10r;\n    x0i = y8i + y10i;\n    x1r = y8r - y10r;\n    x1i = y8i - y10i;\n    x2r = y9r + y11r;\n    x2i = y9i + y11i;\n    x3r = y9r - y11r;\n    x3i = y9i - y11i;\n    a[16] = x0r + x2r;\n    a[17] = x0i + x2i;\n    a[18] = x0r - x2r;\n    a[19] = x0i - x2i;\n    a[20] = x1r - x3i;\n    a[21] = x1i + x3r;\n    a[22] = x1r + x3i;\n    a[23] = x1i - x3r;\n    x0r = y5r - y7i;\n    x0i = y5i + y7r;\n    x2r = wn4r * (x0r - x0i);\n    x2i = wn4r * (x0i + x0r);\n    x0r = y5r + y7i;\n    x0i = y5i - y7r;\n    x3r = wn4r * (x0r - x0i);\n    x3i = wn4r * (x0i + x0r);\n    x0r = y4r - y6i;\n    x0i = y4i + y6r;\n    x1r = y4r + y6i;\n    x1i = y4i - y6r;\n    a[8] = x0r + x2r;\n    a[9] = x0i + x2i;\n    a[10] = x0r - x2r;\n    a[11] = x0i - x2i;\n    a[12] = x1r - x3i;\n    a[13] = x1i + x3r;\n    a[14] = x1r + x3i;\n    a[15] = x1i - x3r;\n    x0r = y0r + y2r;\n    x0i = y0i + y2i;\n    x1r = y0r - y2r;\n    x1i = y0i - y2i;\n    x2r = y1r + y3r;\n    x2i = y1i + y3i;\n    x3r = y1r - y3r;\n    x3i = y1i - y3i;\n    a[0] = x0r + x2r;\n    a[1] = x0i + x2i;\n    a[2] = x0r - x2r;\n    a[3] = x0i - x2i;\n    a[4] = x1r - x3i;\n    a[5] = x1i + x3r;\n    a[6] = x1r + x3i;\n    a[7] = x1i - x3r;\n}\n\n\nvoid cftf162(FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w)\n{\n    FLOAT_TYPE_FFT wn4r, wk1r, wk1i, wk2r, wk2i, wk3r, wk3i, \n        x0r, x0i, x1r, x1i, x2r, x2i, \n        y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i, \n        y4r, y4i, y5r, y5i, y6r, y6i, y7r, y7i, \n        y8r, y8i, y9r, y9i, y10r, y10i, y11r, y11i, \n        y12r, y12i, y13r, y13i, y14r, y14i, y15r, y15i;\n    \n    wn4r = w[1];\n    wk1r = w[4];\n    wk1i = w[5];\n    wk3r = w[6];\n    wk3i = -w[7];\n    wk2r = w[8];\n    wk2i = w[9];\n    x1r = a[0] - a[17];\n    x1i = a[1] + a[16];\n    x0r = a[8] - a[25];\n    x0i = a[9] + a[24];\n    x2r = wn4r * (x0r - x0i);\n    x2i = wn4r * (x0i + x0r);\n    y0r = x1r + x2r;\n    y0i = x1i + x2i;\n    y4r = x1r - x2r;\n    y4i = x1i - x2i;\n    x1r = a[0] + a[17];\n    x1i = a[1] - a[16];\n    x0r = a[8] + a[25];\n    x0i = a[9] - a[24];\n    x2r = wn4r * (x0r - x0i);\n    x2i = wn4r * (x0i + x0r);\n    y8r = x1r - x2i;\n    y8i = x1i + x2r;\n    y12r = x1r + x2i;\n    y12i = x1i - x2r;\n    x0r = a[2] - a[19];\n    x0i = a[3] + a[18];\n    x1r = wk1r * x0r - wk1i * x0i;\n    x1i = wk1r * x0i + wk1i * x0r;\n    x0r = a[10] - a[27];\n    x0i = a[11] + a[26];\n    x2r = wk3i * x0r - wk3r * x0i;\n    x2i = wk3i * x0i + wk3r * x0r;\n    y1r = x1r + x2r;\n    y1i = x1i + x2i;\n    y5r = x1r - x2r;\n    y5i = x1i - x2i;\n    x0r = a[2] + a[19];\n    x0i = a[3] - a[18];\n    x1r = wk3r * x0r - wk3i * x0i;\n    x1i = wk3r * x0i + wk3i * x0r;\n    x0r = a[10] + a[27];\n    x0i = a[11] - a[26];\n    x2r = wk1r * x0r + wk1i * x0i;\n    x2i = wk1r * x0i - wk1i * x0r;\n    y9r = x1r - x2r;\n    y9i = x1i - x2i;\n    y13r = x1r + x2r;\n    y13i = x1i + x2i;\n    x0r = a[4] - a[21];\n    x0i = a[5] + a[20];\n    x1r = wk2r * x0r - wk2i * x0i;\n    x1i = wk2r * x0i + wk2i * x0r;\n    x0r = a[12] - a[29];\n    x0i = a[13] + a[28];\n    x2r = wk2i * x0r - wk2r * x0i;\n    x2i = wk2i * x0i + wk2r * x0r;\n    y2r = x1r + x2r;\n    y2i = x1i + x2i;\n    y6r = x1r - x2r;\n    y6i = x1i - x2i;\n    x0r = a[4] + a[21];\n    x0i = a[5] - a[20];\n    x1r = wk2i * x0r - wk2r * x0i;\n    x1i = wk2i * x0i + wk2r * x0r;\n    x0r = a[12] + a[29];\n    x0i = a[13] - a[28];\n    x2r = wk2r * x0r - wk2i * x0i;\n    x2i = wk2r * x0i + wk2i * x0r;\n    y10r = x1r - x2r;\n    y10i = x1i - x2i;\n    y14r = x1r + x2r;\n    y14i = x1i + x2i;\n    x0r = a[6] - a[23];\n    x0i = a[7] + a[22];\n    x1r = wk3r * x0r - wk3i * x0i;\n    x1i = wk3r * x0i + wk3i * x0r;\n    x0r = a[14] - a[31];\n    x0i = a[15] + a[30];\n    x2r = wk1i * x0r - wk1r * x0i;\n    x2i = wk1i * x0i + wk1r * x0r;\n    y3r = x1r + x2r;\n    y3i = x1i + x2i;\n    y7r = x1r - x2r;\n    y7i = x1i - x2i;\n    x0r = a[6] + a[23];\n    x0i = a[7] - a[22];\n    x1r = wk1i * x0r + wk1r * x0i;\n    x1i = wk1i * x0i - wk1r * x0r;\n    x0r = a[14] + a[31];\n    x0i = a[15] - a[30];\n    x2r = wk3i * x0r - wk3r * x0i;\n    x2i = wk3i * x0i + wk3r * x0r;\n    y11r = x1r + x2r;\n    y11i = x1i + x2i;\n    y15r = x1r - x2r;\n    y15i = x1i - x2i;\n    x1r = y0r + y2r;\n    x1i = y0i + y2i;\n    x2r = y1r + y3r;\n    x2i = y1i + y3i;\n    a[0] = x1r + x2r;\n    a[1] = x1i + x2i;\n    a[2] = x1r - x2r;\n    a[3] = x1i - x2i;\n    x1r = y0r - y2r;\n    x1i = y0i - y2i;\n    x2r = y1r - y3r;\n    x2i = y1i - y3i;\n    a[4] = x1r - x2i;\n    a[5] = x1i + x2r;\n    a[6] = x1r + x2i;\n    a[7] = x1i - x2r;\n    x1r = y4r - y6i;\n    x1i = y4i + y6r;\n    x0r = y5r - y7i;\n    x0i = y5i + y7r;\n    x2r = wn4r * (x0r - x0i);\n    x2i = wn4r * (x0i + x0r);\n    a[8] = x1r + x2r;\n    a[9] = x1i + x2i;\n    a[10] = x1r - x2r;\n    a[11] = x1i - x2i;\n    x1r = y4r + y6i;\n    x1i = y4i - y6r;\n    x0r = y5r + y7i;\n    x0i = y5i - y7r;\n    x2r = wn4r * (x0r - x0i);\n    x2i = wn4r * (x0i + x0r);\n    a[12] = x1r - x2i;\n    a[13] = x1i + x2r;\n    a[14] = x1r + x2i;\n    a[15] = x1i - x2r;\n    x1r = y8r + y10r;\n    x1i = y8i + y10i;\n    x2r = y9r - y11r;\n    x2i = y9i - y11i;\n    a[16] = x1r + x2r;\n    a[17] = x1i + x2i;\n    a[18] = x1r - x2r;\n    a[19] = x1i - x2i;\n    x1r = y8r - y10r;\n    x1i = y8i - y10i;\n    x2r = y9r + y11r;\n    x2i = y9i + y11i;\n    a[20] = x1r - x2i;\n    a[21] = x1i + x2r;\n    a[22] = x1r + x2i;\n    a[23] = x1i - x2r;\n    x1r = y12r - y14i;\n    x1i = y12i + y14r;\n    x0r = y13r + y15i;\n    x0i = y13i - y15r;\n    x2r = wn4r * (x0r - x0i);\n    x2i = wn4r * (x0i + x0r);\n    a[24] = x1r + x2r;\n    a[25] = x1i + x2i;\n    a[26] = x1r - x2r;\n    a[27] = x1i - x2i;\n    x1r = y12r + y14i;\n    x1i = y12i - y14r;\n    x0r = y13r - y15i;\n    x0i = y13i + y15r;\n    x2r = wn4r * (x0r - x0i);\n    x2i = wn4r * (x0i + x0r);\n    a[28] = x1r - x2i;\n    a[29] = x1i + x2r;\n    a[30] = x1r + x2i;\n    a[31] = x1i - x2r;\n}\n\n\nvoid cftf081(FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w)\n{\n    FLOAT_TYPE_FFT wn4r, x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i, \n        y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i, \n        y4r, y4i, y5r, y5i, y6r, y6i, y7r, y7i;\n    \n    wn4r = w[1];\n    x0r = a[0] + a[8];\n    x0i = a[1] + a[9];\n    x1r = a[0] - a[8];\n    x1i = a[1] - a[9];\n    x2r = a[4] + a[12];\n    x2i = a[5] + a[13];\n    x3r = a[4] - a[12];\n    x3i = a[5] - a[13];\n    y0r = x0r + x2r;\n    y0i = x0i + x2i;\n    y2r = x0r - x2r;\n    y2i = x0i - x2i;\n    y1r = x1r - x3i;\n    y1i = x1i + x3r;\n    y3r = x1r + x3i;\n    y3i = x1i - x3r;\n    x0r = a[2] + a[10];\n    x0i = a[3] + a[11];\n    x1r = a[2] - a[10];\n    x1i = a[3] - a[11];\n    x2r = a[6] + a[14];\n    x2i = a[7] + a[15];\n    x3r = a[6] - a[14];\n    x3i = a[7] - a[15];\n    y4r = x0r + x2r;\n    y4i = x0i + x2i;\n    y6r = x0r - x2r;\n    y6i = x0i - x2i;\n    x0r = x1r - x3i;\n    x0i = x1i + x3r;\n    x2r = x1r + x3i;\n    x2i = x1i - x3r;\n    y5r = wn4r * (x0r - x0i);\n    y5i = wn4r * (x0r + x0i);\n    y7r = wn4r * (x2r - x2i);\n    y7i = wn4r * (x2r + x2i);\n    a[8] = y1r + y5r;\n    a[9] = y1i + y5i;\n    a[10] = y1r - y5r;\n    a[11] = y1i - y5i;\n    a[12] = y3r - y7i;\n    a[13] = y3i + y7r;\n    a[14] = y3r + y7i;\n    a[15] = y3i - y7r;\n    a[0] = y0r + y4r;\n    a[1] = y0i + y4i;\n    a[2] = y0r - y4r;\n    a[3] = y0i - y4i;\n    a[4] = y2r - y6i;\n    a[5] = y2i + y6r;\n    a[6] = y2r + y6i;\n    a[7] = y2i - y6r;\n}\n\n\nvoid cftf082(FLOAT_TYPE_FFT *a, FLOAT_TYPE_FFT *w)\n{\n    FLOAT_TYPE_FFT wn4r, wk1r, wk1i, x0r, x0i, x1r, x1i, \n        y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i, \n        y4r, y4i, y5r, y5i, y6r, y6i, y7r, y7i;\n    \n    wn4r = w[1];\n    wk1r = w[2];\n    wk1i = w[3];\n    y0r = a[0] - a[9];\n    y0i = a[1] + a[8];\n    y1r = a[0] + a[9];\n    y1i = a[1] - a[8];\n    x0r = a[4] - a[13];\n    x0i = a[5] + a[12];\n    y2r = wn4r * (x0r - x0i);\n    y2i = wn4r * (x0i + x0r);\n    x0r = a[4] + a[13];\n    x0i = a[5] - a[12];\n    y3r = wn4r * (x0r - x0i);\n    y3i = wn4r * (x0i + x0r);\n    x0r = a[2] - a[11];\n    x0i = a[3] + a[10];\n    y4r = wk1r * x0r - wk1i * x0i;\n    y4i = wk1r * x0i + wk1i * x0r;\n    x0r = a[2] + a[11];\n    x0i = a[3] - a[10];\n    y5r = wk1i * x0r - wk1r * x0i;\n    y5i = wk1i * x0i + wk1r * x0r;\n    x0r = a[6] - a[15];\n    x0i = a[7] + a[14];\n    y6r = wk1i * x0r - wk1r * x0i;\n    y6i = wk1i * x0i + wk1r * x0r;\n    x0r = a[6] + a[15];\n    x0i = a[7] - a[14];\n    y7r = wk1r * x0r - wk1i * x0i;\n    y7i = wk1r * x0i + wk1i * x0r;\n    x0r = y0r + y2r;\n    x0i = y0i + y2i;\n    x1r = y4r + y6r;\n    x1i = y4i + y6i;\n    a[0] = x0r + x1r;\n    a[1] = x0i + x1i;\n    a[2] = x0r - x1r;\n    a[3] = x0i - x1i;\n    x0r = y0r - y2r;\n    x0i = y0i - y2i;\n    x1r = y4r - y6r;\n    x1i = y4i - y6i;\n    a[4] = x0r - x1i;\n    a[5] = x0i + x1r;\n    a[6] = x0r + x1i;\n    a[7] = x0i - x1r;\n    x0r = y1r - y3i;\n    x0i = y1i + y3r;\n    x1r = y5r - y7r;\n    x1i = y5i - y7i;\n    a[8] = x0r + x1r;\n    a[9] = x0i + x1i;\n    a[10] = x0r - x1r;\n    a[11] = x0i - x1i;\n    x0r = y1r + y3i;\n    x0i = y1i - y3r;\n    x1r = y5r + y7r;\n    x1i = y5i + y7i;\n    a[12] = x0r - x1i;\n    a[13] = x0i + x1r;\n    a[14] = x0r + x1i;\n    a[15] = x0i - x1r;\n}\n\n\nvoid cftf040(FLOAT_TYPE_FFT *a)\n{\n    FLOAT_TYPE_FFT x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;\n    \n    x0r = a[0] + a[4];\n    x0i = a[1] + a[5];\n    x1r = a[0] - a[4];\n    x1i = a[1] - a[5];\n    x2r = a[2] + a[6];\n    x2i = a[3] + a[7];\n    x3r = a[2] - a[6];\n    x3i = a[3] - a[7];\n    a[0] = x0r + x2r;\n    a[1] = x0i + x2i;\n    a[2] = x1r - x3i;\n    a[3] = x1i + x3r;\n    a[4] = x0r - x2r;\n    a[5] = x0i - x2i;\n    a[6] = x1r + x3i;\n    a[7] = x1i - x3r;\n}\n\n\nvoid cftb040(FLOAT_TYPE_FFT *a)\n{\n    FLOAT_TYPE_FFT x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;\n    \n    x0r = a[0] + a[4];\n    x0i = a[1] + a[5];\n    x1r = a[0] - a[4];\n    x1i = a[1] - a[5];\n    x2r = a[2] + a[6];\n    x2i = a[3] + a[7];\n    x3r = a[2] - a[6];\n    x3i = a[3] - a[7];\n    a[0] = x0r + x2r;\n    a[1] = x0i + x2i;\n    a[2] = x1r + x3i;\n    a[3] = x1i - x3r;\n    a[4] = x0r - x2r;\n    a[5] = x0i - x2i;\n    a[6] = x1r - x3i;\n    a[7] = x1i + x3r;\n}\n\n\nvoid cftx020(FLOAT_TYPE_FFT *a)\n{\n    FLOAT_TYPE_FFT x0r, x0i;\n    \n    x0r = a[0] - a[2];\n    x0i = a[1] - a[3];\n    a[0] += a[2];\n    a[1] += a[3];\n    a[2] = x0r;\n    a[3] = x0i;\n}\n\n\nvoid rftfsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c)\n{\n    int j, k, kk, ks, m;\n    FLOAT_TYPE_FFT wkr, wki, xr, xi, yr, yi;\n    \n    m = n >> 1;\n    ks = 2 * nc / m;\n    kk = 0;\n    for (j = 2; j < m; j += 2) {\n        k = n - j;\n        kk += ks;\n        wkr = (FLOAT_TYPE_FFT)0.5 - c[nc - kk];\n        wki = c[kk];\n        xr = a[j] - a[k];\n        xi = a[j + 1] + a[k + 1];\n        yr = wkr * xr - wki * xi;\n        yi = wkr * xi + wki * xr;\n        a[j] -= yr;\n        a[j + 1] -= yi;\n        a[k] += yr;\n        a[k + 1] -= yi;\n    }\n}\n\n\nvoid rftbsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c)\n{\n    int j, k, kk, ks, m;\n    FLOAT_TYPE_FFT wkr, wki, xr, xi, yr, yi;\n    \n    m = n >> 1;\n    ks = 2 * nc / m;\n    kk = 0;\n    for (j = 2; j < m; j += 2) {\n        k = n - j;\n        kk += ks;\n        wkr = (FLOAT_TYPE_FFT)0.5 - c[nc - kk];\n        wki = c[kk];\n        xr = a[j] - a[k];\n        xi = a[j + 1] + a[k + 1];\n        yr = wkr * xr + wki * xi;\n        yi = wkr * xi - wki * xr;\n        a[j] -= yr;\n        a[j + 1] -= yi;\n        a[k] += yr;\n        a[k + 1] -= yi;\n    }\n}\n\n\nvoid dctsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c)\n{\n    int j, k, kk, ks, m;\n    FLOAT_TYPE_FFT wkr, wki, xr;\n    \n    m = n >> 1;\n    ks = nc / n;\n    kk = 0;\n    for (j = 1; j < m; j++) {\n        k = n - j;\n        kk += ks;\n        wkr = c[kk] - c[nc - kk];\n        wki = c[kk] + c[nc - kk];\n        xr = wki * a[j] - wkr * a[k];\n        a[j] = wkr * a[j] + wki * a[k];\n        a[k] = xr;\n    }\n    a[m] *= c[0];\n}\n\n\nvoid dstsub(int n, FLOAT_TYPE_FFT *a, int nc, FLOAT_TYPE_FFT *c)\n{\n    int j, k, kk, ks, m;\n    FLOAT_TYPE_FFT wkr, wki, xr;\n    \n    m = n >> 1;\n    ks = nc / n;\n    kk = 0;\n    for (j = 1; j < m; j++) {\n        k = n - j;\n        kk += ks;\n        wkr = c[kk] - c[nc - kk];\n        wki = c[kk] + c[nc - kk];\n        xr = wki * a[k] - wkr * a[j];\n        a[k] = wkr * a[k] + wki * a[j];\n        a[j] = xr;\n    }\n    a[m] *= c[0];\n}\n\n"
  },
  {
    "path": "src/dspcore/framer.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\ndata framer\n \n*/\n\n\n#include <dspcore/framer.hpp>\n//#include <math.h>\n\n#define MODULE \"cFramer\"\n\n\nSMILECOMPONENT_STATICS(cFramer)\n\nSMILECOMPONENT_REGCOMP(cFramer)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n\n  scname = COMPONENT_NAME_CFRAMER;\n  sdescription = COMPONENT_DESCRIPTION_CFRAMER;\n\n  // we inherit cWinToVecProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cWinToVecProcessor\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN( {} \n\n  )\n  \n  SMILECOMPONENT_MAKEINFO(cFramer);\n}\n\nSMILECOMPONENT_CREATE(cFramer)\n\n//-----\n\ncFramer::cFramer(const char *_name) :\n  cWinToVecProcessor(_name)\n{\n\n}\n\n\n// this must return the multiplier, i.e. the vector size returned for each input element (e.g. number of functionals, etc.)\nint cFramer::getMultiplier()\n{\n  return frameSizeFrames;\n}\n\n// idxi is index of input element\n// row is the input row\n// y is the output vector (part) for the input row\nint cFramer::doProcess(int idxi, cMatrix *row, FLOAT_DMEM*y)\n{\n  // copy row to matrix... simple memcpy here\n  memcpy(y,row->dataF,row->nT*sizeof(FLOAT_DMEM));\n  // return the number of components in y!!\n  return row->nT;\n}\nint cFramer::doProcess(int idxi, cMatrix *row, INT_DMEM*y)\n{\n  // copy row to matrix... simple memcpy here\n  memcpy(y,row->dataI,row->nT*sizeof(INT_DMEM));\n  // return the number of components in y!!\n  return row->nT;\n}\n\n\ncFramer::~cFramer()\n{\n}\n\n"
  },
  {
    "path": "src/dspcore/fullinputMean.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\n\n*/\n\n\n#include <dspcore/fullinputMean.hpp>\n\n#define MODULE \"cFullinputMean\"\n\nSMILECOMPONENT_STATICS(cFullinputMean)\n\nSMILECOMPONENT_REGCOMP(cFullinputMean)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CFULLINPUTMEAN;\n  sdescription = COMPONENT_DESCRIPTION_CFULLINPUTMEAN;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataProcessor\")\n  \n    SMILECOMPONENT_IFNOTREGAGAIN( {}\n    //ct->setField(\"expandFields\", \"expand fields to single elements, i.e. each field in the output will correspond to exactly one element in the input [not yet implemented]\", 0);\n    //ct->setField(\"htkcompatible\", \"1 = HTK compatible mean subtraction (this ignores (i.e. does not subtract the mean of) the 0th MFCC or energy field (and its deltas) specified by the option 'idx0')\", 0);\n    //ct->setField(\"idx0\", \"if > 0, index of field to ignore for mean subtraction (attention: 1st field is 0)\", 0);\n    ct->setField(\"meanNorm\", \"Type of mean normalisation: amean, rqmean, absmean  (arithmetic, root squared/quadratic, absolute value mean).\", \"amean\");\n    ct->setField(\"symmSubtract\", \"1 = Perform symmetric subtraction of rqmean or absmean u. I.e. for negative values add u and for positive values subtract u.\", 0);\n    ct->setField(\"subtractClipToZero\", \"1 = If symmSubtract is enabled and a value would change sign, clip it to 0. Otherwise, clip negative values to 0 when subtracting any kind of mean. 0 = do nothing special.\", 0);\n    ct->setField(\"specEnorm\", \"performs spectral magnitude energy normalisation\", 0);\n    ct->setField(\"htkLogEnorm\",\"performs HTK compatible energy normalisation on all input fields instead of the default action of mean subtraction. The energy normalisation subtracts the maximum value of each value in the sequence and adds 1.\",0);\n    ct->setField(\"multiLoopMode\", \"1 = Support the new tick loop mode which can have unlimited EOI iterations. In this mode the means will be collected until the EOI condition is signalled. During the EOI condition nothing will be done (except computing means from the remaining data). During the next non EOI condition, the means will be subtracted from the old input, and (if new data is available - e.g. from a next segment) a new set of means will be computed. If old and new data is processed, the cycle begins anew. If this option is disabled, the means are subtracted while the first EOI condition is signalled. This is for compatibility with old behaviour of the tick loop.\", 0);\n    ct->setField(\"printMeans\", \"1 = print the mean vector once it has been computed.\", 0);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cFullinputMean);\n}\n\nSMILECOMPONENT_CREATE(cFullinputMean)\n\n\n// TODO:\n// option to do something with the means:\n//   print\n//   write to second level repeatedly (\"splitter\")\n//   write to second level once\n\n//-----\n\ncFullinputMean::cFullinputMean(const char *_name) :\n  cDataProcessor(_name),\n  print_means_(0),\n  first_frame_(1),\n  reader_pointer_(0), reader_pointer2_(0),\n  multi_loop_mode_(0),\n  mean_type_(MEANTYPE_AMEAN),\n  spec_enorm_(0),\n  symm_subtract_(0),\n  symm_subtract_clip_to_zero_(0),\n  flag_(0),\n  eoi_flag_(0),\n  means_(NULL), means2_(NULL),\n  n_means_(0), n_means2_(0)\n{\n}\n\nvoid cFullinputMean::fetchConfig()\n{\n  cDataProcessor::fetchConfig();\n\n  int e_norm_mode = (int)getInt(\"htkLogEnorm\");\n  print_means_ = (int)getInt(\"printMeans\");\n  multi_loop_mode_ = (int)getInt(\"multiLoopMode\");\n  symm_subtract_ = (int)getInt(\"symmSubtract\");\n  symm_subtract_clip_to_zero_ = (int)getInt(\"subtractClipToZero\");\n  spec_enorm_ = (int)getInt(\"specEnorm\");\n  const char * s = getStr(\"meanNorm\");\n  if (s != NULL) {\n    if (!strncmp(s, \"rqm\", 3)) {\n      mean_type_ = MEANTYPE_RQMEAN;\n    } else if (!strncmp(s, \"ame\", 3)) {\n      mean_type_ = MEANTYPE_AMEAN;\n    } else if (!strncmp(s, \"absm\", 4)) {\n      mean_type_ = MEANTYPE_ABSMEAN;\n    } else {\n      COMP_ERR(\"Unknown mean type set for option 'meanNorm'. See the help (-H) for supported types.\");\n    }\n  }\n  if (e_norm_mode) {\n    mean_type_ = MEANTYPE_ENORM;\n  }\n}\n\n// Reads new data, computes stats in means_ and n_means_.\nint cFullinputMean::readNewData()\n{\n  cVector *vec = reader_->getNextFrame();\n  if (vec != NULL) {\n    if (vec->type != DMEM_FLOAT) { COMP_ERR(\"only float data-type is supported by cFullinputMean!\"); }\n    if (means_ == NULL) {\n      means_ = new cVector(vec->N, vec->type);\n      for (int i = 0; i < vec->N; i++) {\n        means_->dataF[i] = vec->dataF[i];\n      }\n      n_means_ = 1;\n    } else {\n      if (mean_type_ == MEANTYPE_ENORM) {\n        for (int i = 0; i < vec->N; i++) {\n          if (vec->dataF[i] > means_->dataF[i]) means_->dataF[i] = vec->dataF[i];\n        }\n      } else if (mean_type_ == MEANTYPE_AMEAN) {\n        for (int i = 0; i < vec->N; i++) {\n          means_->dataF[i] += vec->dataF[i];\n        }\n        n_means_++;\n      } else if (mean_type_ == MEANTYPE_RQMEAN) {\n        for (int i = 0; i < vec->N; i++) {\n          means_->dataF[i] += vec->dataF[i] * vec->dataF[i];\n        }\n        n_means_++;\n      } else if (mean_type_ == MEANTYPE_ABSMEAN) {\n        for (int i = 0; i < vec->N; i++) {\n          means_->dataF[i] += (FLOAT_DMEM)fabs(vec->dataF[i]);\n        }\n        n_means_++;\n      }\n    }\n    return 1;\n  }\n  return 0;\n}\n\nvoid cFullinputMean::meanSubtract(cVector *vec)\n{\n  if (mean_type_ == MEANTYPE_ENORM) {\n    for (int i = 0; i < means2_->N; i++) {\n      vec->dataF[i] -= means2_->dataF[i] - (FLOAT_DMEM)1.0;\n    }\n  } else if (mean_type_ == MEANTYPE_AMEAN) {\n    for (int i = 0; i < means2_->N; i++) {\n      vec->dataF[i] -= means2_->dataF[i];\n      if (symm_subtract_clip_to_zero_ && vec->dataF[i] < 0) vec->dataF[i] = 0.0;\n    }\n  } else if (mean_type_ == MEANTYPE_RQMEAN || mean_type_ == MEANTYPE_ABSMEAN) {\n    if (symm_subtract_) {\n      for (int i = 0; i < means2_->N; i++) {\n        if (vec->dataF[i] >= 0) {\n          vec->dataF[i] -= means2_->dataF[i];\n        } else {\n          vec->dataF[i] += means2_->dataF[i];\n        }\n      }\n    } else if (symm_subtract_clip_to_zero_) {\n      for (int i = 0; i < means2_->N; i++) {\n        if (vec->dataF[i] >= means2_->dataF[i]) {\n          vec->dataF[i] -= means2_->dataF[i];\n        } else {\n          if (vec->dataF[i] <= -means2_->dataF[i]) {\n            vec->dataF[i] += means2_->dataF[i];\n          } else {\n            vec->dataF[i] = 0.0;\n          }\n        }\n      }\n    } else {\n      for (int i = 0; i < means2_->N; i++) {\n        vec->dataF[i] -= means2_->dataF[i];\n      }\n    }\n  }\n}\n\nint cFullinputMean::finaliseMeans()\n{\n  if (mean_type_ != MEANTYPE_ENORM) {\n    if (n_means_ > 0) {\n      FLOAT_DMEM nM = (FLOAT_DMEM)n_means_;\n      for (int i = 0; i < means_->N; i++) {\n        means_->dataF[i] /= nM;\n      }\n      if (print_means_) {\n        for (int i = 0; i < means_->N; i++) {\n          SMILE_PRINT(\"means[%i] = %f  (n = %ld)\", i, means_->dataF[i], n_means_);\n        }\n      }\n    }\n  }\n  // copy means_ to means2_\n  if (means2_ != NULL) {\n    delete means2_;\n  }\n  // swap\n  means2_ = means_;\n  means_ = NULL;\n  n_means2_ = n_means_;\n  n_means_ = 0;\n  return n_means2_;\n}\n\nint cFullinputMean::doMeanSubtract()\n{\n  if (writer_->checkWrite(1)) {\n    cVector * vec = reader_->getFrame(reader_pointer2_);\n    if (vec != NULL) {\n      // TODO: make sure we can leave our read pointer (in the data memory) behind to ensure that the data does not get overwritten!!\n      // NOTE: the easiest way to do this is to add a second data reader...\n      //       the best way is to add multi read pointer functionality to the dataReader class\n      meanSubtract(vec);\n      writer_->setNextFrame(vec);\n      reader_pointer2_++;\n      return 1;\n    } // TODO: else { // find out if the frame is lost, if so, skip up to next readable frame and print error message }\n  }\n  return 0;\n}\n\nint cFullinputMean::myTick(long long t)\n{\n  long i;\n  if (multi_loop_mode_) {\n    if (isEOI()) {\n      if (!multi_loop_mode_) {\n        // in non-multiloop mode, du mean subtraction here for backwards compatibility...\n        if (eoi_flag_ == 0) {\n          finaliseMeans();\n          eoi_flag_ = 1;\n        }\n        if (n_means2_ > 0) {\n          return doMeanSubtract();\n        } else {\n          SMILE_IERR(1, \"No mean data available, no input was read in the first tick loop.\");\n          return 0;\n        }\n      } else {\n        eoi_flag_ = 1;\n        // read the remaining parts of the old data until no data can be read...\n        return readNewData();\n      }\n    } else {\n      int ret = 0;\n      if (eoi_flag_) {\n        if (eoi_flag_ == 1) {\n          // the real end of the data input\n          // normalise means_\n          finaliseMeans();\n          // set reader0 pointer...\n          reader_pointer2_ = reader_pointer_;\n          eoi_flag_ = 2;\n          first_frame_ = 1;\n        }\n        // we've got data to process (mean subtract, etc., use means2_ here)\n        if (means2_ != NULL) {\n          ret |= doMeanSubtract();\n        }\n      }\n      if (first_frame_) {\n        // the current read pointer, save it for later, when we need to extract means here\n        reader_pointer_ = reader_->getCurR();\n        first_frame_ = 0;\n      }\n      // TODO: set reader pointer here to reader current vidx  on first read, or first read after EOI condition\n      // Reads new data, if available and update means.\n      //reader_pointer2_ = reader_->getCurR();\n      //doMeanSubtract();\n      ret |= readNewData();\n      // Returns 1 only if at least one of new or old data frames has been read.\n      return (ret > 0);\n    }\n  } else {  // old code for compatibility...\n  // TODO: remove this code and test if the above will do the same...\n\n  if (isEOI()) {\n    if (means_ == NULL) {\n      SMILE_IWRN(1,\"sequence too short, cannot compute statistics (mean or max value)!\");\n      long N = reader_->getLevelN();\n      means_ = new cVector( N, DMEM_FLOAT );\n      for (i=0; i<N; i++) {\n        means_->dataF[i] = 0;\n      }\n      n_means_ = 1;\n    }\n\n    if (flag_==0) { \n      reader_->setCurR(0); flag_ = 1; \n      if (mean_type_ != MEANTYPE_ENORM) {\n        FLOAT_DMEM nM = (FLOAT_DMEM)n_means_;\n        if (nM <= 0.0) nM = 1.0;\n        for (i=0; i<means_->N; i++) {\n          means_->dataF[i] /= nM;\n        }\n      }\n    }\n    cVector *vec = reader_->getNextFrame();\n    if (vec!= NULL) {\n      if (mean_type_ == MEANTYPE_ENORM) {\n        for (i=0; i<means_->N; i++) {\n          vec->dataF[i] -= means_->dataF[i] - (FLOAT_DMEM)1.0;  // x - max + 1 \n        }\n      } else {\n        for (i=0; i<means_->N; i++) {\n          vec->dataF[i] -= means_->dataF[i];\n        }\n      }\n      writer_->setNextFrame(vec);\n      return 1;\n    } \n  } else {\n    // compute means, do not write data\n    cVector *vec = reader_->getNextFrame();\n    if (vec != NULL) {\n      if (vec->type != DMEM_FLOAT) { COMP_ERR(\"only float data-type is supported by cFullinputMean!\"); }\n\n      if (means_ == NULL) {\n        means_ = new cVector( vec->N, vec->type );\n        for (i=0; i<vec->N; i++) {\n          means_->dataF[i] = vec->dataF[i];\n        }\n        n_means_ = 1;\n      } else {\n        if (mean_type_ == MEANTYPE_ENORM) {\n          for (i=0; i<vec->N; i++) {\n            if (vec->dataF[i] > means_->dataF[i]) means_->dataF[i] = vec->dataF[i];\n          }\n        } else {\n          for (i=0; i<vec->N; i++) {\n            means_->dataF[i] += vec->dataF[i];\n          }\n          n_means_++;\n        }\n      }\n      return 1;\n    }\n    \n  }\n\n  }\n  return 0;\n}\n\n\ncFullinputMean::~cFullinputMean()\n{\n  if (means_ != NULL) delete means_;\n  if (means2_ != NULL) delete means2_;\n}\n\n"
  },
  {
    "path": "src/dspcore/fullturnMean.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\n\n*/\n\n\n#include <dspcore/fullturnMean.hpp>\n\n#define MODULE \"cFullturnMean\"\n\nSMILECOMPONENT_STATICS(cFullturnMean)\n\nSMILECOMPONENT_REGCOMP(cFullturnMean)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CFULLTURNMEAN;\n  sdescription = COMPONENT_DESCRIPTION_CFULLTURNMEAN;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataProcessor\")\n  \n    SMILECOMPONENT_IFNOTREGAGAIN( {}\n    //ct->setField(\"expandFields\", \"expand fields to single elements, i.e. each field in the output will correspond to exactly one element in the input [not yet implemented]\", 0);\n    //ct->setField(\"htkcompatible\", \"1 = HTK compatible mean subtraction (this ignores (i.e. does not subtract the mean of) the 0th MFCC or energy field (and its deltas) specified by the option 'idx0')\", 0);\n    //ct->setField(\"idx0\", \"if > 0, index of field to ignore for mean subtraction (attention: 1st field is 0)\", 0);\n    ct->setField(\"htkLogEnorm\",\"performs HTK compatible energy normalisation on all input fields instead of the default action of mean subtraction. The energy normalisation subtracts the maximum value of each value in the sequence and adds 1.\",0);\n    ct->setField(\"messageRecp\",\"recipient list for new (timestamp adjusted) turnFrameTime message\",(const char*)NULL);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cFullturnMean);\n}\n\nSMILECOMPONENT_CREATE(cFullturnMean)\n\n//-----\n\n/*\nreceive turnFrameTime messages,\nread all data referred to in message + (preSil/postSil)\ncompute mean, \nsubtract mean,  \nwrite to output level\nsend new turn start/end message (with corrected timestamps) to asr component, for example\n*/\n\n\ncFullturnMean::cFullturnMean(const char *_name) :\n  cDataProcessor(_name),\n  means(NULL),\n  nMeans(0),\n  eNormMode(0), dataInQue(0)\n{\n}\n\nvoid cFullturnMean::fetchConfig()\n{\n  cDataProcessor::fetchConfig();\n\n  eNormMode = (int)getInt(\"htkLogEnorm\");\n  msgRecp = getStr(\"messageRecp\");\n}\n\nint cFullturnMean::processComponentMessage(cComponentMessage *_msg)\n{\n  if (isMessageType(_msg,\"turnFrameTime\")) {\n    msgQue.push(TurnTimeMsg((long)(_msg->floatData[0]), (long)(_msg->floatData[1]), _msg->intData[0]));\n    dataInQue++;\n    return 1;\n  }\n  return 0;\n}\n\nint cFullturnMean::checkMessageQueque(long &start, long &end, long &fte)\n{\n   int ret=0;\n   lockMessageMemory();\r\n   if (!msgQue.empty()) {\r\n     start = msgQue.front().vIdxStart;\r\n     end = msgQue.front().vIdxEnd;\r\n     if (msgQue.front().isForcedTurnEnd) fte=1;\r\n     else fte = 0;\r\n     msgQue.pop(); dataInQue--;\r\n     ret = 1;\r\n   }\r\n   unlockMessageMemory();\r\n   return ret;\n}\n\nint cFullturnMean::myTick(long long t)\n{\n  // check for new message...\n  long start, end, fte;\n  if (checkMessageQueque(start, end, fte)) {\n    reader_->setCurR(start);\n\n    cMatrix *mat = reader_->getMatrix(start,end-start+1);\n    if (mat == NULL) {\n      SMILE_IWRN(2,\"the matrix containing the turn could ne read, perhaps something is wrong with the values the turn detector sends? or the timing of the levels do not match?\");\n      return 0;\n    }\n\n    // 1st pass , get statistics\n    long i,j;\n    FLOAT_DMEM *df = mat->dataF;\n    if (means == NULL) {\n      means = new cVector( mat->N, mat->type );\n    }\n    for (j=0; j<mat->N; j++) {\n      means->dataF[j] = df[j];\n    }\n    nMeans = 1;\n    \n    for (i=1; i<mat->nT; i++) {\n      if (eNormMode) {\n        for (j=0; j<mat->N; j++) {\n          if (df[j] > means->dataF[j]) means->dataF[j] = df[j];\n        }\n      } else {\n        for (j=0; j<mat->N; j++) {\n          means->dataF[j] += df[j];\n        }\n        nMeans++;\n      }\n      df += mat->N;\n    }\n\n    // 2nd pass, subtract means\n    if (means == NULL) {\n      SMILE_IWRN(1,\"sequence too short, cannot compute statistics (mean or max value)!\");\n      long N = reader_->getLevelN();\n      means = new cVector( N, DMEM_FLOAT );\n      for (i=0; i<N; i++) {\n        means->dataF[i] = 0;\n      }\n      nMeans = 1;\n    }\n    if (!eNormMode) {\n      for (i=0; i<means->N; i++) {\n        means->dataF[i] /= (FLOAT_DMEM)nMeans;\n      }\n    }\n\n    df = mat->dataF;\n    for (i=0; i<mat->nT; i++) {\n      if (eNormMode) {\n        for (j=0; j<mat->N; j++) {\n          df[j] -= means->dataF[j] - (FLOAT_DMEM)1.0;  // x - max + 1 \n        }\n      } else {\n        for (j=0; j<mat->N; j++) {\n          df[j] -= means->dataF[j]; \n        }\n      }\n      df += mat->N;\n    }\n\n    // write to output\n    writer_->setNextMatrix(mat);\n\n    // send new messages (start + end!)\n    if (msgRecp != NULL) {\n\n      /*\n      cComponentMessage cmsg(\"turnEnd\");\n      cmsg.floatData[0] = (double)nPost;\n      cmsg.floatData[1] = (double)(lastVIdx - nPost - eoiMis);\n      \n      cmsg.intData[0] = 0; // 0 = incomplete turn...\n      cmsg.intData[1] = 2;  // set forced turn end flag to EOI (2)\n      cmsg.userTime1 = lastVTime;\n      sendComponentMessage( recComp, &cmsg );\n\n      cmsg.floatData[0] = (double)nPre;\n          cmsg.floatData[1] = (double)startP;\n          cmsg.floatData[2] = (double)(reader->getLevelT());\n          cmsg.userTime1 = startSmileTime;\n          sendComponentMessage( recComp, &cmsg );\n          SMILE_IMSG(debug,\"sending turnStart message to '%s'\",recComp);\n*/\n\n      cComponentMessage _msgS(\"turnStart\");\n      _msgS.floatData[0] = 0.0;\n      _msgS.floatData[1] = curWritePos;\n      _msgS.floatData[2] = (double)(reader_->getLevelT());\n      sendComponentMessage(msgRecp, &_msgS);\n\n      curWritePos += end-start+1;\n\n      cComponentMessage _msgE(\"turnEnd\");\n      _msgE.floatData[0] = 0.0;\n      _msgE.floatData[1] = curWritePos-1-fte*5;\n      _msgE.floatData[2] = (double)(reader_->getLevelT());\n      sendComponentMessage(msgRecp, &_msgE);\n\n      \n    }\n\n    return 1;\n  }\n  \n  lockMessageMemory();\n  int diq = dataInQue;\n  unlockMessageMemory();\n  return diq;\n}\n\n\ncFullturnMean::~cFullturnMean()\n{\n  if (means != NULL) delete means;\n}\n\n"
  },
  {
    "path": "src/dspcore/monoMixdown.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nsimple mixer, which adds multiple channels (elements) to a single channel (element)\n\n*/\n\n\n#include <dspcore/monoMixdown.hpp>\n\n#define MODULE \"cMonoMixdown\"\n\nSMILECOMPONENT_STATICS(cMonoMixdown)\n\nSMILECOMPONENT_REGCOMP(cMonoMixdown)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CMONOMIXDOWN;\n  sdescription = COMPONENT_DESCRIPTION_CMONOMIXDOWN;\n\n  // we inherit cDataProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataProcessor\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN( \n    ct->setField(\"normalise\",\"1/0 = yes/no : divide by the number of channels when adding samples from multiple channels.\",1);\n    ct->setField(\"bufsize\",\"number of samples to process at once. Choose a number >> 1 for optimal performance. Too large buffer sizes may influence the latency!\",1024);\n  )\n  \n  SMILECOMPONENT_MAKEINFO(cMonoMixdown);\n}\n\n\nSMILECOMPONENT_CREATE(cMonoMixdown)\n\n//-----\n\ncMonoMixdown::cMonoMixdown(const char *_name) :\n  cDataProcessor(_name), matout(NULL)\n{\n}\n\nvoid cMonoMixdown::fetchConfig()\n{\n  cDataProcessor::fetchConfig();\n\n  normalise = getInt(\"normalise\");\n  SMILE_IDBG(2,\"normalise = %i\",normalise);\n  bufsize = getInt(\"bufsize\");\n  SMILE_IDBG(2,\"bufsize = %i\",bufsize);\n\n}\n\nint cMonoMixdown::configureWriter(sDmLevelConfig &c) \n{\n  reader_->setupSequentialMatrixReading(bufsize,bufsize);\n  return 1; /* success */\n}\n\n\nint cMonoMixdown::setupNamesForField(int i, const char *name, long nEl)\n{\n  // add a field with a single element for each input array field\n  writer_->addField(name,1);\n  return 1;\n}\n\n\nint cMonoMixdown::myFinaliseInstance()\n{\n  int ret = cDataProcessor::myFinaliseInstance();\n  return ret;\n}\n\n\nint cMonoMixdown::myTick(long long t)\n{\n  /* actually process data... */\n\n  // get next matrix from dataMemory\n  cMatrix *mat = reader_->getNextMatrix();\n  if (mat == NULL) return 0;\n\n  if (matout == NULL) matout = new cMatrix(mat->fmeta->N, mat->nT, mat->type);\n\n  // sum up channels\n  long i,j,c;\n  for (i=0; i<mat->nT; i++) {\n    for (j=0; j<matout->N; j++) {\n      matout->dataF[i*matout->N+j] = 0.0; long st = mat->fmeta->field[j].Nstart;\n      for (c=0; c<mat->fmeta->field[j].N; c++) \n        matout->dataF[i*matout->N+j] += mat->dataF[i*mat->N+st+c];\n      if ((mat->fmeta->field[j].N > 0)&&(normalise))\n        matout->dataF[i*matout->N+j] /= (FLOAT_DMEM)(mat->fmeta->field[j].N);\n    }\n  }\n\n  // if you create a new vector here and pass it to setNextFrame(),\n  // then be sure to assign a valid tmeta info for correct timing info:\n  // e.g.:\n  matout->tmetaReplace(mat->tmeta);\n\n\n  // save to dataMemory\n  writer_->setNextMatrix(matout);\n\n  return 1;\n}\n\n\ncMonoMixdown::~cMonoMixdown()\n{\n  // cleanup...\n  if (matout != NULL) delete matout;\n}\n\n"
  },
  {
    "path": "src/dspcore/preemphasis.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: preemphasis\n\nsimple preemphasis : y(t) = x(t) - k*x(t-1)\n\nk = exp( -2*pi * preemphasisFreq./samplingFreq. )\n\n*/\n\n\n#include <dspcore/preemphasis.hpp>\n//#include <math.h>\n\n#define MODULE \"cPreemphasis\"\n\n\nSMILECOMPONENT_STATICS(cPreemphasis)\n\nSMILECOMPONENT_REGCOMP(cPreemphasis)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CPREEMPHASIS;\n  sdescription = COMPONENT_DESCRIPTION_CPREEMPHASIS;\n\n  // we inherit cWindowProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cWindowProcessor\")\n\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"k\",\"The pre-emphasis coefficient k in y[n] = x[n] - k*x[n-1]\",0.97);\n    ct->setField(\"f\",\"The pre-emphasis frequency f in Hz : k = exp( -2*pi * f/samplingFreq. ) (if set, f will override k!)\",0,0,0);\n    ct->setField(\"de\",\"1 = perform de-emphasis instead of pre-emphasis (i.e. y[n] = x[n] + k*x[n-1])\",0);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cPreemphasis);\n}\n\nSMILECOMPONENT_CREATE(cPreemphasis)\n\n//-----\n\ncPreemphasis::cPreemphasis(const char *_name) :\n  cWindowProcessor(_name,1,0)\n{\n}\n\n\nvoid cPreemphasis::fetchConfig()\n{\n  cWindowProcessor::fetchConfig();\n  \n  k = (FLOAT_DMEM)getDouble(\"k\");\n\n  if (isSet(\"f\")) {\n    f = getDouble(\"f\");\n  } else {\n    f = -1.0;\n  }\n\n  if (f < 0.0) { \n    SMILE_IDBG(2,\"k = %f\",k);\n    if ((k<0.0)||(k>1.0)) {\n      SMILE_IERR(1,\"k must be in the range [0;1]! Setting k=0.0 !\");\n      k=0.0;\n    }\n  } else {\n\n    SMILE_IDBG(2,\"using preemphasis frequency f=%f Hz instead of k\",f);\n  }\n\n  de=getInt(\"de\");\n  if (de) {\n    SMILE_IDBG(2,\"performing de-emphasis instead of pre-emphasis\");\n  }\n}\n\nint cPreemphasis::dataProcessorCustomFinalise()\n{\n  int ret = cWindowProcessor::dataProcessorCustomFinalise();\n  if (f >= 0.0) {\n    double _T = reader_->getLevelT();\n    k = (FLOAT_DMEM)exp( -2.0*M_PI * f * _T );\n    SMILE_IDBG(2,\"computed k from f (%f Hz) : k = %f  (samplingRate = %f Hz)\",f,k,1.0/_T);\n  }\n  return ret;\n}\n\n// order is the amount of memory (overlap) that will be present in _in\n// buf will have nT timesteps, however also order negative indicies (i.e. you may access a negative array index up to -order!)\nint cPreemphasis::processBuffer(cMatrix *_in, cMatrix *_out, int _pre, int _post )\n{\n  long n;\n\n  if (_in->type!=DMEM_FLOAT) COMP_ERR(\"dataType (%i) != DMEM_FLOAT not yet supported!\",_in->type);\n  FLOAT_DMEM *x=_in->dataF;\n  FLOAT_DMEM *y=_out->dataF;\n  if (de) {\n    for (n=0; n<_out->nT; n++) {\n      *(y++) = *(x) + k * *(x-1);\n      x++;\n    }\n  } else {\n    for (n=0; n<_out->nT; n++) {\n      *(y++) = *(x) - k * *(x-1);\n      x++;\n    }\n  }\n  return 1;\n}\n\n\ncPreemphasis::~cPreemphasis()\n{\n}\n\n"
  },
  {
    "path": "src/dspcore/transformFft.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfast fourier transform using fft4g library\noutput: complex values of fft or real signal values (for iFFT)\n\n*/\n\n\n#include <dspcore/transformFft.hpp>\n\n#define MODULE \"cTransformFFT\"\n\nSMILECOMPONENT_STATICS(cTransformFFT)\n\nSMILECOMPONENT_REGCOMP(cTransformFFT)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CTRANSFORMFFT;\n  sdescription = COMPONENT_DESCRIPTION_CTRANSFORMFFT;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"inverse\", \"1 = perform inverse real FFT\", 0);\n    ct->setField(\"zeroPadSymmetric\", \"1 = zero pad symmetric (when zero padding to next power of 2), i.e. center frame and pad left and right with zeros. New since version 2.3: this is the default, but should not affect FFT magnitudes at all, only phase.\", 1);\n  )\n  SMILECOMPONENT_MAKEINFO(cTransformFFT);\n}\n\nSMILECOMPONENT_CREATE(cTransformFFT)\n\n//-----\n\ncTransformFFT::cTransformFFT(const char *_name) :\n  cVectorProcessor(_name),\n  ip_(NULL),\n  w_(NULL),\n  xconv_(NULL),\n  newFsSet_(0),\n  frameSizeSecOut_(0.0)\n{ }\n\nvoid cTransformFFT::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n  inverse_ = getInt(\"inverse\");\n  if (inverse_) {\n    SMILE_DBG(2, \"transformFFT set for inverse FFT.\");\n    inverse_ = -1;  // sign of exponent\n  } else {\n    inverse_ = 1; // sign of exponent\n  }\n  zeroPadSymmetric_ = getInt(\"zeroPadSymmetric\");\n}\n\nint cTransformFFT::configureWriter(sDmLevelConfig &c)\n{\n  // determine new frameSizeSec resulting from rounding up to closest power of 2\n  for (int i = 0; i < c.Nf; i++) {\n    long nEl = c.fmeta->field[i].N;\n    /* for each field we must ensure the power of 2 constraint and adjust the frameSize if necessary*/\n    if (!smileMath_isPowerOf2(nEl)) {\n      if (inverse_==-1) {\n        SMILE_IERR(1,\"cannot perform zero-padding for inverse real FFT (this would mean zero padding frequencies in the complex domain...)! A framesize which is power of 2 is required here! (current framesize = %i)\",nEl);\n        COMP_ERR(\"aborting\");\n        \n      } else {\n        long nElOld = nEl;\n        nEl = smileMath_ceilToNextPowOf2(nEl);  // TODO:: change frameSizeSec in write Level!\n        if (!newFsSet_) {\n          // compute new frame size in seconds:\n          c.lastFrameSizeSec = c.frameSizeSec; // save last frame size\n          c.frameSizeSec *= (double)nEl / (double)nElOld;\n          newFsSet_=1;\n        }\n      }\n    }\n    if (inverse_==-1) {\n       //TODO: detect frames which were originally zero-padded, and output truncated frames\n\n    }\n    if (newFsSet_) break;\n  }\n  frameSizeSecOut_ = c.frameSizeSec;\n  return 1;\n}\n\n// generate \"frequency axis information\", i.e. the frequency in Hz for each spectral bin\n// which is to be saved as meta-data in the dataMemory level field (FrameMetaInfo->FieldMetaInfo->info)\n// &infosize is initialized with the number of fft bins x 2 (= number of input samples)\n//   and should contain the number of complex bins at the end of this function\nvoid * cTransformFFT::generateSpectralVectorInfo(long &infosize)\n{\n  int i;\n  infosize /= 2;\n  infosize++; // nyquist and DC...\n  double *inf = (double*)calloc(1,sizeof(double)*infosize);\n  \n  double F0;\n  if (frameSizeSecOut_ > 0.0) {\n    F0 = (double)(1.0) / (double)frameSizeSecOut_;\n    for (i=0; i<infosize; i++) {\n      inf[i] = F0*(double)i;\n    }\n  }\n  return (void *)inf;\n}\n\nint cTransformFFT::setupNamesForField(int i, const char*name, long nEl)\n{\n  // round of nEl to closest power of 2, setup output fields (and thus, Ndst passed to processVectorXXX, etc.)\n\n  /* for each field we must ensure the power of 2 constraint and adjust the frameSize if necessary*/\n  if (!smileMath_isPowerOf2(nEl)) {\n    if (inverse_==-1) { COMP_ERR(\"error with input framesize, not a power of 2!\"); }\n    long nElOld = nEl;\n    nEl = smileMath_ceilToNextPowOf2(nEl);  \n  }\n  if (nEl < 4) nEl = 4;\n\n  //TODO? : append name \"fftc\" -> set the nameAppend field : ct->setField(\"nameAppend\",(const char*) NULL,\"fftc\");\n  int ret = cVectorProcessor::setupNamesForField(i,name,nEl);\n  long tmp = nEl;\n  void *fmap = generateSpectralVectorInfo(tmp);\n  writer_->setFieldInfo(-1,DATATYPE_SPECTRUM_BINS_COMPLEX,fmap,tmp*sizeof(double));\n  return ret;\n}\n\nint cTransformFFT::myFinaliseInstance()\n{\n  int ret = cVectorProcessor::myFinaliseInstance();\n  \n  if (ret) {\n    //?? to support re-configure once it is implemented in component manager ??\n    if (ip_ != NULL) {\n      multiConfFree(ip_);\n      ip_=NULL;\n    }\n    if (w_ != NULL) {\n      multiConfFree(w_);\n      w_ = NULL;\n    }\n    if (xconv_ != NULL) {\n      multiConfFree(xconv_);\n      xconv_ = NULL;\n    }\n    ip_ = (int**)multiConfAlloc(); \n    w_ = (FLOAT_TYPE_FFT**)multiConfAlloc();\n    xconv_ = (FLOAT_TYPE_FFT**)multiConfAlloc();\n  }\n  return ret;\n}\n\n// a derived class should override this method, in order to implement the actual processing\nint cTransformFFT::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  idxi = getFconf(idxi);\n  FLOAT_TYPE_FFT *x = xconv_[idxi];\n  FLOAT_TYPE_FFT *w_l = w_[idxi];\n  int *ip_l = ip_[idxi];\n  if (x == NULL) {\n    x = (FLOAT_TYPE_FFT *)malloc(sizeof(FLOAT_TYPE_FFT) * Ndst);\n    xconv_[idxi] = x;\n  }\n  if (inverse_ == 1) {\n    // this is the forward transform (inverse is the exponent factor..)\n    if (zeroPadSymmetric_) {\n      int padlen2 = (Ndst - Nsrc) / 2;\n      for (int i = 0; i < padlen2; i++) {  // zeropadding first half\n        x[i] = 0;\n      }\n      for (int i = 0; i < Nsrc; i++) {\n        x[i + padlen2] = (FLOAT_TYPE_FFT)src[i];\n      }\n      for (int i = Nsrc + padlen2; i < Ndst; i++) {  // zeropadding second half\n        x[i] = 0;\n      }\n    } else {\n      for (int i = 0; i < Nsrc; i++) {\n        x[i] = (FLOAT_TYPE_FFT)src[i];\n      }\n      for (int i = Nsrc; i < Ndst; i++) {  // zeropadding second half\n        x[i] = 0;\n      }\n    }\n  } else {\n    for (int i = 0; i < Nsrc; i++) {\n      x[i] = (FLOAT_TYPE_FFT)src[i];\n    }\n  }\n  if (ip_l == NULL) {\n    ip_l = (int *)calloc(1, sizeof(int) * (3 + (size_t)ceil(sqrt((float)Ndst))));\n    ip_[idxi] = ip_l;\n  }\n  if (w_l == NULL) {\n    w_l = (FLOAT_TYPE_FFT *)calloc(1, sizeof(FLOAT_TYPE_FFT) * (Ndst / 2 + 1));\n    w_[idxi] = w_l;\n  }\n    //w_l = (FLOAT_TYPE_FFT *)calloc(1,sizeof(FLOAT_TYPE_FFT)*((Ndst*5)/4+2));\n  // perform real FFT\n  rdft((int)Ndst, inverse_, x, ip_l, w_l);\n  if (inverse_==-1) {\n    FLOAT_DMEM norm = (FLOAT_DMEM)2.0 / (FLOAT_DMEM)Ndst;\n    for (int i = 0; i < Ndst; i++) {\n      dst[i] = ((FLOAT_DMEM)x[i])*norm;\n    }\n  } else {\n    for (int i = 0; i < Ndst; i++) {\n      dst[i] = (FLOAT_DMEM)x[i];\n    }\n  }\n  return 1;\n}\n\ncTransformFFT::~cTransformFFT()\n{\n  if (ip_ != NULL)\n    multiConfFree(ip_);\n  if (w_ != NULL)\n    multiConfFree(w_);\n  if (xconv_ != NULL)\n    multiConfFree(xconv_);\n}\n"
  },
  {
    "path": "src/dspcore/transformFftr.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfast fourier transform using fft4g library\noutput: complex values of fft or real signal values (for iFFT)\n\n*/\n\n\n#include <dspcore/transformFftr.hpp>\n\n#define MODULE \"cTransformFFTr\"\n\nSMILECOMPONENT_STATICS(cTransformFFTr)\n\nSMILECOMPONENT_REGCOMP(cTransformFFTr)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CTRANSFORMFFTR;\n  sdescription = COMPONENT_DESCRIPTION_CTRANSFORMFFTR;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"inverse\", \"1 = perform inverse FFT\", 0);\n  )\n  SMILECOMPONENT_MAKEINFO(cTransformFFTr);\n}\n\nSMILECOMPONENT_CREATE(cTransformFFTr)\n\n//-----\n\ncTransformFFTr::cTransformFFTr(const char *_name) :\n  cVectorProcessor(_name),\n  fftwork_(NULL),\n  newFsSet_(0),\n  frameSizeSec_out_(0.0) {}\n\nvoid cTransformFFTr::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n  \n  inverse_ = getInt(\"inverse\");\n  if (inverse_) {\n    SMILE_IDBG(2, \"transformFFT set for inverse FFT\");\n  }\n}\n\nint cTransformFFTr::configureWriter(sDmLevelConfig &c)\n{\n  // determine new frameSizeSec resulting from rounding up to closest power of 2\n  int i;\n  for (i=0; i<c.Nf; i++) {\n    long nEl = c.fmeta->field[i].N;\n\n    /* for each field we must ensure the power of 2 constraint and adjust the frameSize if necessary*/\n    if (!smileMath_isPowerOf2(nEl)) {\n      if (inverse_ == 1) {\n        SMILE_IERR(1,\"cannot perform zero-padding for inverse real FFT (this would mean zero padding frequencies in the complex domain...)! A framesize which is power of 2 is required here! (current framesize = %i)\",nEl);\n        COMP_ERR(\"aborting\");\n        \n      } else {\n        long nElOld = nEl;\n        nEl = smileMath_ceilToNextPowOf2(nEl);  // TODO:: change frameSizeSec in write Level!\n        if (!newFsSet_) {\n          // compute new frame size in seconds:\n          c.lastFrameSizeSec = c.frameSizeSec; // save last frame size\n          c.frameSizeSec *= (double)nEl / (double)nElOld;\n          newFsSet_ = 1;\n        }\n      }\n    }\n    if (inverse_ == 1) {\n       //TODO: detect frames which were originally zero-padded, and output truncated frames\n\n    }\n    if (newFsSet_) break;\n  }\n\n  frameSizeSec_out_ = c.frameSizeSec;\n  return 1;\n}\n\n// generate \"frequency axis information\", i.e. the frequency in Hz for each spectral bin\n// which is to be saved as meta-data in the dataMemory level field (FrameMetaInfo->FieldMetaInfo->info)\n// &infosize is initialized with the number of fft bins x 2 (= number of input samples)\n//   and should contain the number of complex bins at the end of this function\nvoid * cTransformFFTr::generateSpectralVectorInfo(long &infosize)\n{\n  int i;\n  infosize /= 2;\n  infosize++; // nyquist and DC...\n  double *inf = (double*)calloc(1,sizeof(double)*infosize);\n  \n  double F0;\n  if (frameSizeSec_out_ > 0.0) {\n    F0 = (double)(1.0) / (double)frameSizeSec_out_;\n    for (i=0; i<infosize; i++) {\n      inf[i] = F0*(double)i;\n    }\n  }\n\n  return (void *)inf;\n}\n\nint cTransformFFTr::setupNamesForField(int i, const char*name, long nEl)\n{\n  // round of nEl to closest power of 2, setup output fields (and thus, Ndst passed to processVectorXXX, etc.)\n\n  /* for each field we must ensure the power of 2 constraint and adjust the frameSize if necessary*/\n  if (!smileMath_isPowerOf2(nEl)) {\n    if (inverse_ == 1) { COMP_ERR(\"error with input framesize, not a power of 2!\"); }\n    long nElOld = nEl;\n    nEl = smileMath_ceilToNextPowOf2(nEl);  \n  }\n  if (nEl < 4) nEl = 4;\n\n  //TODO? : append name \"fftc\" -> set the nameAppend field : ct->setField(\"nameAppend\",(const char*) NULL,\"fftc\");\n  int ret = cVectorProcessor::setupNamesForField(i,name,nEl);\n  long tmp = nEl;\n  void *fmap = generateSpectralVectorInfo(tmp);\n  writer_->setFieldInfo(-1,DATATYPE_SPECTRUM_BINS_COMPLEX,fmap,tmp*sizeof(double));\n  return ret;\n}\n\nint cTransformFFTr::myFinaliseInstance()\n{\n  int ret = cVectorProcessor::myFinaliseInstance();\n  \n  if (ret) {\n    if (fftwork_ != NULL) { \n      multiConfFree(fftwork_); \n      fftwork_ = NULL; \n    }\n    fftwork_ = (sFftrData**)multiConfAlloc(); \n  }\n  return ret;\n}\n\n// a derived class should override this method, in order to implement the actual processing\nint cTransformFFTr::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  int i;\n  FLOAT_TYPE_FFT *x;\n\n  idxi = getFconf(idxi);\n  sFftrData *data = fftwork_[idxi];\n  \n  x = (FLOAT_TYPE_FFT*)malloc(sizeof(FLOAT_TYPE_FFT) * Ndst);\n  for (i = 0; i < Nsrc; i++) {\n    x[i] = (FLOAT_TYPE_FFT)src[i];\n  }\n\n  if (inverse_ == 0) { \n    for (i = Nsrc; i < Ndst; i++) {  // zeropadding\n      x[i] = 0.0;\n    }\n  } else {\n// TODO!  x and y loaded with symmetric complex data\n  } \n\n  //perform FFT\n  if (inverse_ == 0) {\n    fftr(x, &data, Ndst);\n  } else {\n// TODO!  x and y loaded with symmetric complex data\n//    ifftr(x, inverse, x, _ip, _w);\n  }\n\n  if (inverse_ == 1) {\n    //FLOAT_DMEM norm = (FLOAT_DMEM)2.0/((FLOAT_DMEM)Ndst+1);\n    //for (i=0; i<Ndst; i++) {\n    //  dst[i] = ((FLOAT_DMEM)x[i])*norm;\n    //}\n  } else {\n    // real part\n    dst[0] = (FLOAT_DMEM)x[0];\n    for (i=1; i<Ndst/2; i++) {\n      dst[i*2] = (FLOAT_DMEM)x[i];\n    }\n    // imaginary part\n    dst[1] = (FLOAT_DMEM)x[Ndst/2];  // nyquist\n    for (i=1; i<Ndst/2; i++) {\n      dst[i*2+1] = (FLOAT_DMEM)data->y_[i];\n    }\n  }\n  free(x);\n\n  fftwork_[idxi] = data;\n  return 1;\n}\n\ncTransformFFTr::~cTransformFFTr()\n{\n  if (fftwork_ != NULL) {\n    for (int i = 0; i < getNf(); ++i) {\n      if (fftwork_[i] != NULL) delete fftwork_[i];\n    }\n    free(fftwork_);\n  }\n}\n\n"
  },
  {
    "path": "src/dspcore/turnDetector.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nsimple silence threshold based turn detector\n\n*/\n\n\n#include <dspcore/turnDetector.hpp>\n\n#define MODULE \"cTurnDetector\"\n\n// default values (can be changed via config file...)\n#define N_PRE  10\n#define N_POST 20\n\nSMILECOMPONENT_STATICS(cTurnDetector)\n\nSMILECOMPONENT_REGCOMP(cTurnDetector)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CTURNDETECTOR;\n  sdescription = COMPONENT_DESCRIPTION_CTURNDETECTOR;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataProcessor\")\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"threshold\",\"The silence->speech threshold to use (the default value is for RMS energy, change it to -13.0 for log energy)\",0.001);\n    ct->setField(\"threshold2\",\"The speech->silence threshold to use (if this value is not set in the config, the same value as 'threshold' will be used)\",0.001);\n    \n    ct->setField(\"autoThreshold\",\"1 = automatically adjust threshold for RMS energy (EXPERIMENTAL; works for energy as input)\",0);\n    ct->setField(\"minmaxDecay\",\"The decay constant used for min/max values in auto-thresholder (a larger value means a slower recovery from loud sounds)\",0.9995);\n  //TODO: these should be given in seconds and they should be converted to frames via period or via secToVidx..?\n    ct->setField(\"nPre\",\"number of frames > threshold until a turn start is detected\",N_PRE);\n    ct->setField(\"nPost\",\"number of frames < threshold(2) until a turn end is detected\",N_POST);\n  //---  \n    ct->setField(\"useRMS\",\"1 = the provided energy field in the input is rms energy instead of log energy\",1);\n    ct->setField(\"readVad\",\"1 = use the result (bianry 0/1 or probability) from another VAD component instead of reading RMS or LOG energy ('threshold' and 'threshold2' will be set to 0.55 and 0.45 if this option is enabled, unless other values for thresholds are given in the config file)\",0);\n    ct->setField(\"idx\",\"The index of the RMS or LOG energy (or vadBin) field to use (-1 to automatically find the field)\",-1);\n\n    ct->setField(\"messageRecp\",\"The (cWinToVecProcessor type) component(s) to send 'frameTime' messages to (use , to separate multiple recepients), leave blank (NULL) to not send any messages. The messages will be sent at the turn end and (optionally) during the turn at fixed intervals configured by the 'msgInterval' parameter (if it is not 0).\",(const char *) NULL);\n    ct->setField(\"msgInterval\",\"Interval at which to send 'frameTime' messages during an ongoing turn. Set to 0 to disable sending of intra turn messages.\",0.0);\n    ct->setField(\"turnFrameTimePreRollSec\", \"Time offset which is added to the turnStart for turnFrameTimeMessages. Use this to compensate for VAD lags. Typically one would use negative values here, e.g. -0.1.\", 0.0);\n    ct->setField(\"turnFrameTimePostRollSec\", \"Time offset which is added to the turnEnd for turnFrameTimeMessages. Use this to compensate for VAD lags. CAUTION: If this value is positive, it might prevent the receiving component from working correctly, as it will not have all data (for the full segment) available in the input data memory level when it receives the message.\", 0.0);\n    ct->setField(\"msgPeriodicMaxLength\", \"If periodic message sending is enabled (msgInterval > 0), then this can limit the maximum length of the segments (going backwards from the current posiiton, i.e. a sliding window - as opposed to maxTurnLength, which limits the total turn length from the beginning of the turn). If this is 0, there is no limit (= default), the segments will grow up to maxTurnLength.\", 0.0);\n    ct->setField(\"sendTurnFrameTimeMessageAtEnd\", \"If not 0, indicates that at the end of a turn a turnFrameTime message will be sent. If it is set to 1, a full length (from turn start to turn end) message will be sent. If it is set to 2, and if periodic sending is enabled (msgInterval > 0) and msgPeriodicMaxLength is set (> 0), then only a message of msgPeriodicMaxLength (from turn end backwards) will be sent. Leave this option at the default of 1 if not using periodic message sending (msgInterval > 0).\", 1);\n    ct->setField(\"eventRecp\",\"The component(s) to send 'turnStart/turnEnd' messages to (use , to separate multiple recepients), leave blank (NULL) to not send any messages\",(const char *) NULL);\n    ct->setField(\"statusRecp\",\"The component(s) to send 'turnSpeakingStatus' messages to (use , to separate multiple recepients), leave blank (NULL) to not send any messages\",(const char *) NULL);\n    ct->setField(\"minTurnLengthTurnFrameTimeMessage\", \"The minimum turn length in seconds (<= 0 : infinite) for turnFrameTime messages. No Message will be sent if the detected turn is shorter than the given value. turnStart and turnEnd messages will still be sent though.\", 0);\n    ct->setField(\"minTurnLength\", \"[NOT YET IMPLEMENTED!] The minimum turn length in seconds (<= 0 : infinite) for turnFrameTime and turnStart messages. No Message will be sent if the detected turn is shorter than the given value. IMPORTANT: This introduces a lag of the given minimum length for turn start messages!\", 0);\n    ct->setField(\"maxTurnLength\", \"The maximum turn length in seconds (<= 0 : infinite). A turn end will be favoured by reducing nPost to 1 after this time\",0.0);\n    ct->setField(\"maxTurnLengthGrace\", \"The grace period to grant, after maxTurnLength is reached (in seconds). After a turn length of maxTurnLength + maxTurnLengthGrace an immediate turn end will be forced.\",1.0);\n    ct->setField(\"invert\", \"Invert the behaviour of turnStart/turnEnd messages. Also send a turnStart message at vIdx = 0, and a turnEnd message at the end (EOI).\", 0);\n    ct->setField(\"debug\",\"log level to show some turn detector specific debug messages on\",4);\n    ct->setField(\"timeoutSec\",\"turnEnd timeout in seconds (send turnEnd after timeoutSec seconds no input data)\",2.0);\n    ct->setField(\"eoiFramesMissing\",\"set the number of frames that will be subtracted from the last turn end position (the forced turn end that will be sent when an EOI condition (end of input) is encountered). This is necessary, e.g. if you use delta or acceleration coefficients which introduce a lag of a few frames. Increase this value if SMILExtract hangs at the end of input when using the cTumkwsjSink component or a cFunctionals component, etc.\",5);\n    ct->setField(\"unblockTimeout\",\"timeout in frames to wait after a turn block condition (started via a semaineCallback message)\",60);\n    ct->setField(\"blockStatus\",\"apply event based speech detection block  for speakingStatus messages (i.e.  the sending of these messages is supressed)\",0);\n    ct->setField(\"blockAll\",\"apply event based speech detection block for all types, i.e. the voice input is set to 0 by an incoming block message.\",1);\n\n    ct->setField(\"terminateAfterTurns\", \"Number of turns after which to terminate processing and exit openSMILE. Default 0 is for infinite, i.e. never terminate.\", 0);\n    ct->setField(\"terminatePostSil\", \"Amount of silence after last turn of terminateAfterTurns to wait for before actually exiting. This excludes (i.e. is on top of) postSil which is required to detect the end of the turn.\", 0);\n    ct->setField(\"initialBlockTime\", \"Initial time (in seconds) to block VAD (useful in conjunction with RNN vad, or if high noise occurrs after starting VAD.\", 1.0);\n\n  )\n  SMILECOMPONENT_MAKEINFO(cTurnDetector);\n}\n\nSMILECOMPONENT_CREATE(cTurnDetector)\n\n/*\n * Turndetector advanced:\n * - reads in VAD\n * - reads in Overlap\n * - reads in Gender Male/Female\n *\n * splits at vad start/stop\n * splits at overlap (over a threshold for n frames)\n * splits at gender change\n * small tolerance for the event that multiple split indicators (gender change + pause or overlap)\n *    occurr almost at the same time -> split only once.\n *\n */\n//-----\n\ncTurnDetector::cTurnDetector(const char *_name) :\n  cDataProcessor(_name),\n  turnState(0), actState(0),\n  useRMS(1),\n  threshold((FLOAT_DMEM)0.0),\n  nPost(N_POST),\n  nPre(N_PRE),\n  cnt1(0), cnt2(0), cnt1s(0), cnt2s(0), debug(4),\n  startP(0),\n  recFramer(NULL),\n  recComp(NULL),\n  statusRecp(NULL),\n  rmsIdx(-1),\n  autoRmsIdx(-1),\n  autoThreshold(0),\n  minmaxDecay((FLOAT_DMEM)0.9995),\n  nmin(0), nmax(0),\n  rmin(1.0), rmax(0.0), rmaxlast(0.0),\n  tmpmin(0.0), tmpmax(0.0),\n  dtMeanO(0.0), dtMeanAll(0.0), dtMeanT(0.0), dtMeanS(0.0),\n  nE(0.0),\n  nTurn(0), nSil(0),\n  alphaM((FLOAT_DMEM)0.9999),\n  calCnt(0),\n  msgInterval(0.0),\n  lastDataTime(0),\n  timeout(0),\n  timeoutSec(10.0),\n  forceEnd(0),\n  blockTurn(0), unblockTurnCntdn(0), blockAll(1), blockStatus(0),\n  initialBlockTime(0), initialBlockFrames(0),\n  terminateAfterTurns(0), terminatePostSil(0), nTurns(0),\n  exitFlag(0), nSilForExit(0),\n  lastVIdx(0),\n  lastVTime(0.0),\n  turnTime(0.0)\n{\n}\n\nvoid cTurnDetector::fetchConfig()\n{\n  cDataProcessor::fetchConfig();\n  \n  useRMS = getInt(\"useRMS\");\n  readVad = getInt(\"readVad\");\n  SMILE_IDBG(2,\"readVad = %i\",readVad);\n  if (readVad) {\n    useRMS = 0;\n  }\n\n  nPre = getInt(\"nPre\");\n  nPost = getInt(\"nPost\");\n\n  threshold = (FLOAT_DMEM)getDouble(\"threshold\");\n  if ((useRMS)&&(threshold<(FLOAT_DMEM)0.0)) {\n    threshold = (FLOAT_DMEM)0.001;\n  }\n\n  if (isSet(\"threshold2\")) {\n    threshold2 = (FLOAT_DMEM)getDouble(\"threshold2\");\n    if ((useRMS)&&(threshold2<(FLOAT_DMEM)0.0)) {\n      threshold2 = threshold;\n    }\n  } else {\n    threshold2 = threshold;\n  }\n  autoThreshold = getInt(\"autoThreshold\");\n\n  rmsIdx = getInt(\"idx\");\n  debug = getInt(\"debug\");\n  eoiMis = getInt(\"eoiFramesMissing\");\n\n  if (readVad) {\n    autoThreshold = 0;\n    useRMS = 0;\n    if (isSet(\"threshold2\")) {\n      if (threshold2 < 0.2 || threshold2 > 0.8) {\n        SMILE_IWRN(1,\"readVad=1, and threshold2 set to a value which looks like log- or rms-energy thresholds! You should remove the threshold option, or consider that you are setting the VAD threshold with it!\");\n      }\n    } else {\n      threshold2 = (FLOAT_DMEM)0.45;\n    }\n    if (isSet(\"threshold\")) {\n      if (threshold < 0.2 || threshold > 0.8) {\n        SMILE_IWRN(1,\"readVad=1, and threshold set to a value which looks like log- or rms-energy thresholds! You should remove the threshold option, or consider that you are setting the VAD threshold with it!\");\n      }\n    } else {\n      threshold = (FLOAT_DMEM)0.55;\n    }\n  }\n  SMILE_IDBG(2,\"nPre = %i\",nPre);\n  SMILE_IDBG(2,\"nPost = %i\",nPost);\n\n  SMILE_IDBG(2,\"useRMS = %i\",useRMS);\n  SMILE_IDBG(2,\"idx = %i\",rmsIdx);\n  SMILE_IDBG(2,\"autoThreshold = %i\",autoThreshold);\n  SMILE_IDBG(2,\"threshold = %f\",threshold);\n\n  recFramer = getStr(\"messageRecp\");\n  SMILE_IDBG(2,\"messageRecp = '%s'\",recFramer);\n\n  msgInterval = getDouble(\"msgInterval\");\n  SMILE_IDBG(2,\"msgInterval = %f\",msgInterval);\n\n  recComp = getStr(\"eventRecp\");\n  SMILE_IDBG(2,\"eventRecp = '%s'\",recComp);\n\n  statusRecp = getStr(\"statusRecp\");\n  SMILE_IDBG(2,\"statusRecp = '%s'\",statusRecp);\n\n  timeoutSec = getDouble(\"timeoutSec\");\n\n  maxTurnLengthS = getDouble(\"maxTurnLength\");\n  graceS = getDouble(\"maxTurnLengthGrace\");\n\n  unblockTimeout = getInt(\"unblockTimeout\");\n  blockAll = getInt(\"blockAll\");\n  blockStatus = getInt(\"blockStatus\");\n  initialBlockTime = getDouble(\"initialBlockTime\");\n\n  terminateAfterTurns = getInt(\"terminateAfterTurns\");\n  terminatePostSil = getInt(\"terminatePostSil\");\n  \n  invert_ = getInt(\"invert\");\n  minTurnLength_ = getDouble(\"minTurnLength\");\n  if (isSet(\"minTurnLengthTurnFrameTimeMessage\")) {\n    minTurnLengthTurnFrameTimeMessage_ = getDouble(\"minTurnLengthTurnFrameTimeMessage\");\n  } else {\n    minTurnLengthTurnFrameTimeMessage_ = minTurnLength_;\n  }\n  //~ if (msgInterval > 0.0 && minTurnLength_ > 0.0) {\n    //~ if (msgInterval < minTurnLength_) {\n      //~ SMILE_IWRN(1, \"the turnFrameTime message interval (msgInterval) (%f) is smaller than the minimum turn length (%f), this effectively causes to minTurnLength = msgInterval !! Consider fixing your config file.\", msgInterval, minTurnLength_);\n    //~ }\n  //~ }\n  \n  turnFrameTimePreRollSec_ = getDouble(\"turnFrameTimePreRollSec\");\n  turnFrameTimePostRollSec_ = getDouble(\"turnFrameTimePostRollSec\");\n  msgPeriodicMaxLengthSec_ = getDouble(\"msgPeriodicMaxLength\");\n  sendTurnFrameTimeMessageAtEnd_ = getInt(\"sendTurnFrameTimeMessageAtEnd\");\n}\n\nint cTurnDetector::setupNewNames(long nEl)\n{\n  writer_->addField( \"isTurn\" );\n  namesAreSet_ = 1;\n\n  // convert maxTurnLength from seconds to frames...\n  double T = (double)(reader_->getLevelT());\n  SMILE_IMSG(4, \"Reader T: %f\", T);\n  if (T == 0.0) \n    T = 1.0;\n  if (maxTurnLengthS < 0.0) \n    maxTurnLengthS = 0.0;\n  maxTurnLength = (long)ceil(maxTurnLengthS / T);\n  if (graceS < 0.0) \n    graceS = 0.0;\n  grace = (long)ceil(graceS / T);\n  if (minTurnLength_ < 0.0) \n    minTurnLength_ = 0.0;\n  minTurnLengthFrames_ = (long)ceil(minTurnLength_ / T);\n  if (minTurnLengthTurnFrameTimeMessage_ < 0.0) \n    minTurnLengthTurnFrameTimeMessage_ = 0.0;\n  minTurnLengthFrameTimeFrames_ = (long)ceil(minTurnLengthTurnFrameTimeMessage_ / T);\n\n  initialBlockFrames = (long)ceil(initialBlockTime / T);\n\n  if (msgPeriodicMaxLengthSec_ < 0.0) \n    msgPeriodicMaxLengthSec_ = 0.0;\n  msgPeriodicMaxLengthFrames_ = (long)ceil(msgPeriodicMaxLengthSec_ / T);\n  \n  if (msgPeriodicMaxLengthSec_ < 0.0) \n    msgPeriodicMaxLengthSec_ = 0.0;\n  msgPeriodicMaxLengthFrames_ = (long)ceil(msgPeriodicMaxLengthSec_ / T);\n  \n  turnFrameTimePreRollFrames_ = (long)ceil(turnFrameTimePreRollSec_ / T);\n  turnFrameTimePostRollFrames_ = (long)ceil(turnFrameTimePostRollSec_ / T);\n  \n  if (turnFrameTimePreRollSec_ > 0.0) {\n    SMILE_IWRN(2, \"turnFrameTimePreRollSec is a positive value! This means that the turn start will be cut off, as this value is added to the turn start. Did you mean to use a negative value?\");\n  }\n  SMILE_IMSG(3, \"postRollFrames: %i\", turnFrameTimePostRollFrames_);\n  SMILE_IMSG(3, \"preRollFrames: %i\", turnFrameTimePreRollFrames_);\n  return 1;\n}\n\n\nvoid cTurnDetector::updateThreshold(FLOAT_DMEM eRmsCurrent)\n{\n  // compute various statistics on-line:\n\n  // min \"percentile\" (robust min.)\n  // \"value below which Nmin values are..\"\n  if (eRmsCurrent < rmin) {\n    nmin++;\n    tmpmin += eRmsCurrent;\n    if (nmin > 10) {\n      rmin = tmpmin / (FLOAT_DMEM)nmin;\n      //SMILE_IDBG(2,\"adjusted rmin: %f\",rmin);\n      nmin = 0;\n      tmpmin = 0;\n    }\n  }\n\n  // auto decay..\n  rmin *= (FLOAT_DMEM)1.0 + ((FLOAT_DMEM)1.0 - minmaxDecay);\n\n  // max \"percentile\" (robust max.)\n  if (eRmsCurrent > rmax) {\n    nmax++;\n    tmpmax += eRmsCurrent;\n    if (nmax > 10) {\n      rmaxlast = rmax;\n      rmax = tmpmax / (FLOAT_DMEM)nmax;\n      //SMILE_IDBG(2,\"adjusted rmax: %f\",rmax);\n      nmax = 0;\n      tmpmax = 0.0;\n    }\n  }\n\n  // auto decay..\n  rmax *= minmaxDecay;\n\n  //}\n\n  // mean overall (exponential decay)\n  dtMeanO = minmaxDecay * (dtMeanO - eRmsCurrent) + eRmsCurrent;\n\n  // mean overall, non decaying\n  dtMeanAll = (dtMeanAll * nE + eRmsCurrent) / (nE+(FLOAT_DMEM)1.0);\n  nE+=1.0;\n\n  // mean of turns\n\n  if (turnState) {\n    nTurn++;\n    dtMeanT = alphaM * (dtMeanT - eRmsCurrent) + eRmsCurrent;\n  } else {\n    nSil++;\n  // mean of non-turns\n    dtMeanS = alphaM * (dtMeanS - eRmsCurrent) + eRmsCurrent;\n  }\n\n\n  // update threshold based on collected statistics:\n  FLOAT_DMEM newThresh;\n/*  if (dtMeanT == 0.0) {\n    //newThresh = ( rmax + (rmax - dtMeanS) ) * 1.1;\n  } else {\n    //newThresh = 0.5*(dtMeanT + ( rmax + (rmax - dtMeanS) )*1.1) ;\n    newThresh = MAX( 0.5*(dtMeanT + rmaxlast ), rmaxlast * 1.41) ;\n  }*/\n\n  if (nTurn == 0) { newThresh = dtMeanAll * (FLOAT_DMEM)2.0; }\n  else {\n    newThresh = (FLOAT_DMEM)0.15 * ( rmax + rmin ) ;\n    FLOAT_DMEM w = (FLOAT_DMEM)nTurn / ( (FLOAT_DMEM)nSil + (FLOAT_DMEM)nTurn);\n    FLOAT_DMEM w2 = sqrt((FLOAT_DMEM)1.0-w)+(FLOAT_DMEM)1.0;\n    if (dtMeanO < newThresh) { newThresh = w*newThresh + ((FLOAT_DMEM)1.0-w)*MAX(dtMeanO*w2, (FLOAT_DMEM)1.2*w2*dtMeanAll) ; }\n  }\n  \n\n  threshold = (FLOAT_DMEM)0.8*threshold + (FLOAT_DMEM)0.2*newThresh;\n\n#ifdef DEBUG\n  tmpCnt++;\n  if (tmpCnt>200) {\n    SMILE_IDBG(2,\"THRESH: %f  rmax %f  rmin %f  dtMeanO %f  dtMeanAll %f\",threshold,rmax,rmin,dtMeanO,dtMeanAll);\n    //SMILE_IDBG(2,\"dtMeanO: %f\",dtMeanO);\n    //SMILE_IDBG(2,\"dtMeanT: %f\",dtMeanT);\n    //SMILE_IDBG(2,\"dtMeanS: %f\",dtMeanS);\n    tmpCnt = 0;\n  }\n#endif\n}\n\nint cTurnDetector::isVoice(FLOAT_DMEM *src, int state)\n{\n  /* state 0: silence/noise, state 1: voice */\n  if (invert_ == 1) {\n    if (state == 0) {\n      if (src[rmsIdx] <= threshold) return 1;\n    } else {\n      if (src[rmsIdx] <= threshold2) return 1;\n    }\n  } else {\n    if (state == 0) {\n      if (src[rmsIdx] > threshold) return 1;\n    } else {\n      if (src[rmsIdx] > threshold2) return 1;\n    }\n    //if (src[0] > 0.4) return 1;\n  }\n  return 0;\n}\n\n// a derived class should override this method, in order to implement the actual processing\nint cTurnDetector::myTick(long long t)\n{\n  //static int lastVIdx = 0;\n  //static double lastVTime = 0.0;\n  \n  // Send a end-of-turn message at the end of input!\n  if ((isEOI() || timeout || isPaused()) && turnState) {\n    SMILE_IMSG(debug, \"turn end at EOI (%i|%i|%i|%i) at vIdx %i (tick nr %llu)!\",isEOI(),timeout,isPaused(),turnState,lastVIdx - eoiMis,t);\n    if (recComp!=NULL) {\n      SMILE_IDBG(3, \"forced turnEnd message!\");\n      cComponentMessage cmsg(\"turnEnd\");\n      cmsg.floatData[0] = (double)nPost;\n      cmsg.floatData[1] = (double)(lastVIdx - eoiMis);\n      cmsg.floatData[2] = (double)(reader_->getLevelT());\n      cmsg.intData[0] = 0; // 0 = incomplete turn...\n      cmsg.intData[1] = 2;  // set forced turn end flag to EOI (2)\n      cmsg.userTime1 = lastVTime;\n      sendComponentMessage( recComp, &cmsg );\n      SMILE_IMSG(debug, \"sending turnEnd message to '%s' (due to TIMEOUT)\",recComp);\n    }\n    if (recFramer!=NULL) {\n      if (sendTurnFrameTimeMessageAtEnd_\n          && (minTurnLengthFrameTimeFrames_ == 0 || lastVIdx - eoiMis - startP >= minTurnLengthFrameTimeFrames_)) {\n        cComponentMessage cmsg(\"turnFrameTime\");\n        cmsg.intData[0] = 0; /* 0=incomplete turn */\n        // send start/end in frames of input level\n        cmsg.floatData[0] = (double)startP;\n        cmsg.floatData[1] = (double)(lastVIdx - eoiMis);\n        if (sendTurnFrameTimeMessageAtEnd_ == 2 && msgPeriodicMaxLengthFrames_ > 0) {\n          if (cmsg.floatData[1] - msgPeriodicMaxLengthFrames_ > startP)\n            cmsg.floatData[0] = cmsg.floatData[1] - msgPeriodicMaxLengthFrames_;\n          else\n            cmsg.floatData[0] += turnFrameTimePreRollFrames_;\n        } else {\n          cmsg.floatData[0] += turnFrameTimePreRollFrames_;\n        }\n        if (cmsg.floatData[1] < 2)\n          cmsg.floatData[1] = 2;\n        if (cmsg.floatData[0] < 0)\n          cmsg.floatData[0] = 0;\n        if (cmsg.floatData[1] <= cmsg.floatData[0])\n          SMILE_IERR(1, \"turn has negative or zero length! Somthing is wrong! (%ld - %ld) (turn end due to timeout)\",\n              (long)cmsg.floatData[0], (long)cmsg.floatData[1]);\n        double T = (double)(reader_->getLevelT());\n        if (T != 0.0) {\n          // also send start/end as actual data time in seconds\n          cmsg.floatData[2] = ((double)startP) * T;\n          cmsg.floatData[3] = ((double)(lastVIdx - eoiMis)) * T;\n          // and send period of input level\n          cmsg.floatData[4] = T;\n        }\n        cmsg.intData[1] = 2; // intData[1] : 0=normal end / 1=forced turn end (max length) / 2=forced turn End (EOI)\n        cmsg.userTime1 = startSmileTime;\n        cmsg.userTime2 = endSmileTime;\n        sendComponentMessage(recFramer, &cmsg);\n        SMILE_IMSG(debug, \"sending turnFrameTime message (turn end) to '%s' (due to TIMEOUT) (%ld - %ld)\",\n            recFramer, (long)cmsg.floatData[0], (long)cmsg.floatData[1]);\n      } else {\n        if (!sendTurnFrameTimeMessageAtEnd_) {\n          SMILE_IMSG(debug, \"NOT sending turnFrameTime message to '%s' (due to TIMEOUT) (%ld - %ld): sending at end disabled\",\n              recFramer, startP, lastVIdx - eoiMis);\n        } else {\n          SMILE_IMSG(debug, \"NOT sending turnFrameTime message to '%s' (due to TIMEOUT) (%ld - %ld): turn too short\",\n              recFramer, startP, lastVIdx - eoiMis);\n        }\n      }\n    }\n\n    turnState = 0;\n    cnt1 = 0; cnt2 = 0; turnTime=0.0;\n  }\n\n  // get next frame from dataMemory\n  cVector *vec = NULL;\n  //if (writer_->getNFree() >= 1) {\n  vec = reader_->getNextFrame();\n  //}\n  if (vec == NULL) {\n    if ((getSmileTime()-lastDataTime > timeoutSec)&&(lastDataTime>0)) {\n      timeout = 1;\n    } else {\n      timeout = 0;\n    } // timeout flag needs to be reset when there is new data\n    return 0;\n  }\n  // Note: when paused by the component manager, we need to reset the lastDataTime to current time in the resume method\n  lastDataTime = getSmileTime();\n\n  if (vec->tmeta) {\n    lastVIdx = vec->tmeta->vIdx;\n    lastVTime = vec->tmeta->smileTime;\n  }\n  \n  cVector *vec0 = new cVector(1);  // TODO: move vec0 to class...\n  \n  FLOAT_DMEM *src = vec->dataF;\n  FLOAT_DMEM *dst = vec0->dataF;\n\n  if (rmsIdx < 0) {\n    if (autoRmsIdx < 0) { // if autoRmsIdx has not been set yet\n      if (readVad) {\n        autoRmsIdx = vec->fmeta->fieldToElementIdx( vec->fmeta->findFieldByPartialName( \"vadBin\" ) );\n        SMILE_IDBG(3,\"automatically found vadBin field at index %i in input vector\",autoRmsIdx);\n      } else {\n        if (useRMS) {\n          autoRmsIdx = vec->fmeta->fieldToElementIdx( vec->fmeta->findFieldByPartialName( \"RMS\" ) );\n          SMILE_IDBG(3,\"automatically found RMSenergy field at index %i in input vector\",autoRmsIdx);\n        } else {\n          autoRmsIdx = vec->fmeta->fieldToElementIdx( vec->fmeta->findFieldByPartialName( \"LOG\" ) );\n          SMILE_IDBG(3,\"automatically found LOGenergy field at index %i in input vector\",autoRmsIdx);\n        }\n      }\n    }\n    rmsIdx = autoRmsIdx;\n  }\n\n  /*\n   * get a second field (energy)\n   * do an automatic energy threshold updating  OR fixed threhold\n   * get the minimum from histogram\n   * set vad to 0 if below that energy threshold\n   */\n\n  // just to be sure we don't exceed arrray bounds...\n  if (rmsIdx >= vec->N)\n    rmsIdx = vec->N-1;\n  \n  //printf(\"s : %f\\n\",src[rmsIdx]);\n  if (autoThreshold) updateThreshold(src[rmsIdx]);\n\n  //if (src[rmsIdx] > threshold) {\n  if (!autoThreshold || calCnt > 200) { /* TODO: make autoThresholdCalibrationTime configurable!*/\n    int vo = isVoice(src,turnState);\n    // check for maxTurnLength...\n    if (turnState && (maxTurnLength > 0) && !forceEnd) {\n      if ((grace > 0)&&(vec->tmeta->vIdx - startP  > maxTurnLength)) {\n        // during grace period, end turn even if only 1 frame is non-voiced (no nPost smoothing)\n        if (vo==0) { \n          //cnt2 = nPost-eoiMis; // <<--offline!\n          cnt2 = nPost+1; // <--online \n          forceEnd = 1; \n        }\n      }\n      if ( (vec->tmeta->vIdx - startP)  > (maxTurnLength+grace) ) {\n        // grace period expired, hard turn end forced right here...\n        //cnt2 = nPost-eoiMis; // <<--offline!\n        cnt2 = nPost+1; // <--online \n        forceEnd = 1;\n      }\n    }\n\n    // check for smile message based speech detection block ...\n    int statusBlocked=0;\n    if (blockAll) {\n      lockMessageMemory();\n      if ((blockTurn) || (unblockTurnCntdn > 0)) {\n        /*\n        if (turnState && vo) {\n        cnt2 = nPost+1; /// <<-online only\n        }\n        */\n        vo=0;\n        if (unblockTurnCntdn > 0) {\n          unblockTurnCntdn--;\n          if ((unblockTurnCntdn == 0)&&(vo)) { cnt1 = nPre+20; }\n          // careful: this (the +20) might break things if there are sounds when the character finished speaking...\n        }\n      }\n      unlockMessageMemory();\n    } else {\n      if (blockStatus) {\n        lockMessageMemory();\n        if ((blockTurn) || (unblockTurnCntdn > 0)) {\n          statusBlocked = 1;\n          if (unblockTurnCntdn > 0) {\n            unblockTurnCntdn--;\n          }\n        }\n        unlockMessageMemory();\n      }\n    }\n\n    // apply the force turn end flag ..\n    if (forceEnd) {\n      vo = 0; \n    }\n\n    if (vec->tmeta->vIdx < initialBlockFrames) {\n      vo = 0;\n    }\n    if (vo) {  /* if voice activity */\n      cnt2 = 0;\n      cnt2s=0;\n      if (!actState) {\n        if (cnt1s<=0) { \n          if (vec->tmeta != NULL) startSmileTimeS = vec->tmeta->smileTime; \n        }\n        cnt1s++;\n        if (cnt1s > 1) {\n          actState = 1;\n          cnt1s=0;\n          cnt2s=0;\n          if (statusRecp != NULL) {\n            SMILE_IMSG(debug + 1, \"detected voice activity start at vIdx %i!\",\n                vec->tmeta->vIdx - 1);\n            cComponentMessage cmsg(\"turnSpeakingStatus\");\n            cmsg.intData[0] = 1;\n            cmsg.floatData[1] = (double)(vec->tmeta->vIdx-1);\n            cmsg.floatData[2] = (double)(reader_->getLevelT());\n            cmsg.userTime1 = startSmileTimeS;\n            sendComponentMessage( statusRecp, &cmsg );\n            SMILE_IDBG(4,\"sending turnSpeakingStatus (1) message to '%s'\",recComp);\n          }\n        }\n      }\n\n      if (!turnState) {\n        if (cnt1<=0) { \n          if (vec->tmeta != NULL) startSmileTime = vec->tmeta->smileTime;/*offline: time !  FIX THIS PERMANENTLY...*/\n        }\n        cnt1++;\n        if (cnt1 > nPre) {\n          //printf(\"XXX vo=%i turnState=%i actState=%i cnt2=%i\\n\",vo,turnState,actState,cnt2);\n          startP = vec->tmeta->vIdx - cnt1 + 1; // cnt1 was nPre ! // added the +1 to fix the vIdx=-1 issue...\n          turnState = 1; cnt1 = 0; cnt2 = 0; turnTime=0.0;\n          SMILE_IMSG(debug,\"detected turn start at vIdx %i!\",startP);\n          if (recComp!=NULL) {\n            cComponentMessage cmsg(\"turnStart\");\n            cmsg.floatData[0] = (double)nPre;\n            cmsg.floatData[1] = (double)startP;\n            cmsg.floatData[2] = (double)(reader_->getLevelT());\n            cmsg.userTime1 = startSmileTime;\n            sendComponentMessage( recComp, &cmsg );\n            SMILE_IMSG(debug,\"sending turnStart message to '%s'\",recComp);\n          }\n        }\n      }\n    } else {\n      cnt1 = 0;\n      cnt1s=0;\n      if (cnt2 <= 0) {\n        if (vec->tmeta != NULL) endSmileTime = vec->tmeta->smileTime;/*offline: time !  FIX THIS PERMANENTLY...*/\n      }\n      if (actState) {\n        cnt2s++;\n        if (cnt2s > 5) {\n          actState = 0;\n          cnt2s=0;\n          cnt1s=0;\n          if (statusRecp != NULL) {\n            SMILE_IMSG(debug + 1, \"detected voice activity end at vIdx %i!\",\n                vec->tmeta->vIdx - 2);\n            cComponentMessage cmsg(\"turnSpeakingStatus\");\n            cmsg.intData[0] = 0;\n            cmsg.floatData[1] = (double)(vec->tmeta->vIdx - 2);\n            cmsg.floatData[2] = (double)(reader_->getLevelT());\n            cmsg.userTime1 = endSmileTime;\n            sendComponentMessage( statusRecp, &cmsg );\n            SMILE_IDBG(debug+1,\"sending turnSpeakingStatus (0) message to '%s'\",recComp);\n          }\n        }\n      }\n      cnt2++;\n      if (exitFlag == 1) {\n        nSilForExit++;\n        if (nSilForExit >= terminatePostSil) {\n          exitFlag = 2;\n        }\n      }\n      if (turnState) {\n        if (cnt2 > nPost) {\n          turnState = 0;\n          cnt1 = 0;\n          cnt2 = 0;\n          SMILE_IMSG(debug,\"detected turn end at vIdx %i !\",(vec->tmeta->vIdx)-nPost);\n          // WARNING: if we set cnt2 to nPost manually we run the risk of having negative turn lengths\n          //    when we subtract nPost to get to the turn end:\n          //  solution:  introduce another variable that is either nPost, or set to 0 if we set cnt2 during forcing a turn end\n\n          long blag;\n          if (forceEnd) blag = eoiMis;\n          else blag = nPost;\n\n          if (recFramer!=NULL) {\n            if ((sendTurnFrameTimeMessageAtEnd_) &&\n                (minTurnLengthFrameTimeFrames_ == 0 || vec->tmeta->vIdx - blag - startP >= minTurnLengthFrameTimeFrames_)) {\n              cComponentMessage cmsg(\"turnFrameTime\");\n              cmsg.intData[0] = 1; /* indicates a turn end */\n              // send start/end in frames of input level\n              long thisStartP = startP;\n              long thisEnd = vec->tmeta->vIdx;\n              if (sendTurnFrameTimeMessageAtEnd_ == 2 && msgPeriodicMaxLengthFrames_ > 0) {\n                if (vec->tmeta->vIdx - msgPeriodicMaxLengthFrames_ > startP)\n                  thisStartP = vec->tmeta->vIdx - msgPeriodicMaxLengthFrames_;\n                else\n                  thisStartP += turnFrameTimePreRollFrames_;\n              } else {\n                thisStartP += turnFrameTimePreRollFrames_;\n              }\n              thisEnd += turnFrameTimePostRollFrames_;\n              if (thisStartP < 0)\n                thisStartP = 0;\n              if (thisEnd < 2)\n                thisEnd = 2;\n              cmsg.floatData[0] = (double)thisStartP;\n              cmsg.floatData[1] = (double)(thisEnd - blag);\n              double _T = (double)(reader_->getLevelT());\n              if (_T!=0.0) {\n                // also send start/end as actual data time in seconds\n                cmsg.floatData[2] = ((double)thisStartP) * _T;\n                cmsg.floatData[3] = ((double)(thisEnd - blag)) * _T;\n                // and send period of input level\n                cmsg.floatData[4] = _T;\n              }\n              cmsg.intData[1] = forceEnd; // intData[1] : 0=normal end / 1=forced turn end (max length)\n              cmsg.userTime1 = startSmileTime;\n              cmsg.userTime2 = endSmileTime;\n              sendComponentMessage(recFramer, &cmsg);\n              SMILE_IMSG(debug, \"sending turnFrameTime message (turn end) to '%s' (%ld - %ld, blag: %ld).\",\n                  recFramer, thisStartP, thisEnd - blag, blag);\n            } else {\n              if (sendTurnFrameTimeMessageAtEnd_) {\n                SMILE_IMSG(debug, \"NOT sending turnFrameTime message (turn end) to '%s': turn too short (%ld -> %ld). Min length frames = %ld\",\n                    recFramer, startP, vec->tmeta->vIdx - blag, minTurnLengthFrameTimeFrames_);\n              } else {\n                SMILE_IMSG(debug, \"NOT sending turnFrameTime message (turn end) to '%s': sending at end disabled. (%ld -> %ld)\",\n                    recFramer, startP, vec->tmeta->vIdx - blag);\n              }\n            }\n          }\n          /*\n           * TODO: turn end is never sent, always too short! check;: vec->tmeta->vIdx - blag - startP\n           * FIXME: if nPost is large, then it might happen that an intermediate message is sent\n           *     and the turn end then retrospective is detected before that point!!\n           *     Solution? We can only send intermediates up to vIdx - nPost\n           *       Then at the turn end, we have to catch up all intermediate between end and end-nPost!\n           *     We should also fix the send at end option in this context!\n           */\n          if (recComp!=NULL) {\n            cComponentMessage cmsg(\"turnEnd\");\n            cmsg.floatData[0] = (double)nPost;\n            cmsg.floatData[1] = (double)(vec->tmeta->vIdx - blag);\n            cmsg.floatData[2] = (double)(reader_->getLevelT());\n            cmsg.intData[0] = 1;  // turn end\n            cmsg.intData[1] = forceEnd; // intData[1] : 0=normal end / 1=forced turn end (max length)\n            cmsg.userTime1 = endSmileTime;\n            sendComponentMessage( recComp, &cmsg );\n            SMILE_IDBG(debug, \"sending turnEnd message to '%s'\",recComp);\n          }\n          forceEnd = 0;\n          // increase number of turns counter\n          nTurns++;\n          //printf(\"nTurns = %i\\n\", nTurns);\n          if (terminateAfterTurns > 0 && nTurns >= terminateAfterTurns) {\n            exitFlag = 1;\n            nSilForExit = 0;\n          }\n        }\n      }\n    }\n  } else {\n    calCnt++;\n  }\n\n  /* if turnState and interval timeout, then send message */\n  if ((turnState)&&(msgInterval > 0.0)) {\n    if (vec->tmeta->vIdx - startP > minTurnLengthFrameTimeFrames_) {\n      if (turnTime > msgInterval) {\n        turnTime = 0.0;\n        if (recFramer!=NULL) {\n          cComponentMessage cmsg(\"turnFrameTime\");\n          cmsg.intData[0] = 0; /* indicates an incomplete turn */\n          // send start/end in frames of input level\n          long thisStartP = startP;\n          long thisEnd = vec->tmeta->vIdx;\n          if (msgPeriodicMaxLengthFrames_ > 0) {\n            if (vec->tmeta->vIdx - msgPeriodicMaxLengthFrames_ > startP) \n              thisStartP = vec->tmeta->vIdx - msgPeriodicMaxLengthFrames_;\n            else // pre roll only applied if at real turn start\n              thisStartP += turnFrameTimePreRollFrames_;\n          } else {\n            // pre roll only applied if at real turn start\n            thisStartP += turnFrameTimePreRollFrames_;\n          }\n          // post roll is not applied, as this is intra turn!\n          if (thisStartP < 0)\n            thisStartP = 0;\n          if (thisEnd < 2)\n            thisEnd = 2;\n          cmsg.floatData[0] = (double)thisStartP;\n          cmsg.floatData[1] = (double)thisEnd;\n          double _T = (double)(reader_->getLevelT());\n          if (_T!=0.0) {\n            // also send start/end as actual data time in seconds\n            cmsg.floatData[2] = ((double)thisStartP) * _T;\n            cmsg.floatData[3] = ((double)thisEnd) * _T;\n            // and send period of input level\n            cmsg.floatData[4] = _T;\n          }\n          cmsg.userTime1 = startSmileTime;\n          if (vec->tmeta != NULL)\n            cmsg.userTime2 = vec->tmeta->smileTime;\n          else\n            cmsg.userTime2 = startSmileTime;\n          sendComponentMessage(recFramer, &cmsg);\n          SMILE_IMSG(debug, \"sending turnFrameTime message (intra turn) to '%s' (%ld -> %ld)\",\n              recFramer, thisStartP, thisEnd);\n        }\n      } \n    }\n    turnTime += (double)(reader_->getLevelT());\n  }\n\n  dst[0] = (FLOAT_DMEM)turnState;\n\n  // save to dataMemory\n  writer_->setNextFrame(vec0);\n  delete vec0;\n\n  int ret = 1;\n  if (terminateAfterTurns > 0 && exitFlag == 2) {\n    ret = 0;\n    // stop the component manager!\n    abort_processing();\n    exitFlag = 3;\n  }\n  return ret;\n}\n\nint cTurnDetector::processComponentMessage( cComponentMessage *_msg )\n{\n  if (isMessageType(_msg,\"semaineCallback\")) {\n    // determine origin by message's user-defined name, which can be set in the config file\n    SMILE_IMSG(3,\"received 'semaineCallback' message '%s'\",_msg->msgname);\n    if (!strncmp(_msg->msgname,\"start\",5)) { blockTurn = 1; unblockTurnCntdn = 0; }\n    else if (!strncmp(_msg->msgname,\"end\",3)) {\n      blockTurn = 0; unblockTurnCntdn = unblockTimeout;\n    }\n  /*  else if (!strncmp(_msg->msgname,\"present\",7)) { if (userPresence != 1) { userPresence = 1; doReset=1; } }\n    else if (!strncmp(_msg->msgname,\"absent\",6)) { if (userPresence != 0) { userPresence = 0; doReset=1; } }*/\n    return 1;  // message was processed\n  }\n  return 0; // if message was not processed\n}\n\n\ncTurnDetector::~cTurnDetector()\n{\n}\n\n"
  },
  {
    "path": "src/dspcore/vectorMVN.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: cVectorMVN\n\nThis component extends the base class cVectorTransform and implements mean/variance normalisation\n\n*/\n\n#include <dspcore/vectorMVN.hpp>\n\n#define MODULE \"cVectorMVN\"\n\n\n\nSMILECOMPONENT_STATICS(cVectorMVN)\n\nSMILECOMPONENT_REGCOMP(cVectorMVN)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CVECTORMVN;\n  sdescription = COMPONENT_DESCRIPTION_CVECTORMVN;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorTransform\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"nameAppend\",(const char *)NULL,(const char *)NULL);\n    ct->setField(\"meanEnable\",\"1 = enable normalisation to 0 mean\",1);\n    ct->setField(\"stdEnable\",\"1 = enable standardisation to stddev 1\",1);\n    ct->setField(\"normEnable\",\"1 = enable normalisation (scaling) to range -1 to +1, if meanEnable=1 (x-mean)/((max-min)*0.5), or to range 0..1 if meanEnable=0  (x-min)/(max-min) ; (this can NOT be used in conjunction with stdEnable)\",0);\n    ct->setField(\"minMaxNormEnable\",\"1 = enable normalisation (scaling) to range -1 to +1 with only min and max values: x=2*(x-min)/(max-min)-1\",0);\n    ct->setField(\"spectralFlooring\",\"1 = enable spectral subtraction by flooring all spectral bins below the mean (to the value of 'specFloor') and not touching bins above the mean (expect if you set subtractMeans=1). (works only if meanEnable=1 is the only normalisation option set)\",0);\n    ct->setField(\"subtractMeans\",\"(only relevant if spectralFlooring=1) : 1 = if input values are above the mean, subtract the mean (else floor to 'specFloor').\",0);\n    ct->setField(\"specFloor\",\"The value to which bins will be set that are floored.\",0.0000000001);\n    ct->setField(\"htkLogEnorm\",\"1 = enbale HTK compatible log energy normalisation (this also sets normEnable=1, meanEnable=0)\",0);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cVectorMVN);\n}\n\n\n\nSMILECOMPONENT_CREATE(cVectorMVN)\n\n//-----\n\ncVectorMVN::cVectorMVN(const char *_name) :\n  cVectorTransform(_name)\n{\n}\n\nvoid cVectorMVN::fetchConfig()\n{\n  cVectorTransform::fetchConfig();\n\n  meanEnable = getInt(\"meanEnable\");\n  stdEnable = getInt(\"stdEnable\");\n  normEnable = getInt(\"normEnable\");\n  minMaxNormEnable = getInt(\"minMaxNormEnable\");\n\n  specFloor = (FLOAT_DMEM)getDouble(\"specFloor\");\n  subtractMeans = getInt(\"subtractMeans\");\n  spectralFlooring = getInt(\"spectralFlooring\");\n  htkLogEnorm = getInt(\"htkLogEnorm\");\n  if (htkLogEnorm) {\n    meanEnable = 0; normEnable = 1; stdEnable = 0; minMaxNormEnable = 0;\n  }\n  SMILE_IDBG(2,\"htkLogEnorm = '%i'\",htkLogEnorm);\n\n  if (stdEnable && normEnable ) {\n    SMILE_IERR(1,\"Only ONE of stdEnable and normEnable can be enabled!! Setting normEnable=0, stdEnable=1 !\");\n    normEnable = 0;\n  }\n  if ( !(meanEnable || stdEnable || normEnable || minMaxNormEnable) ) {\n    SMILE_IERR(1,\"No normalisation option is enabled! At least one must be selected. Defaulting to meanEnable=1 !\");\n    meanEnable = 1;\n  }\n\n  SMILE_IDBG(2,\"stdEnable = '%i'\",stdEnable);\n  SMILE_IDBG(2,\"meanEnable = %i\",meanEnable);\n  SMILE_IDBG(2,\"normEnable = '%i'\",normEnable);\n}\n\nvoid cVectorMVN::allocTransformData(struct sTfData *tf, int Ndst, int idxi) \n{\n  // TODO:  get loaded transform0\n  struct sTfData * tf0 = getTransformInitData();\n  if ((tf0->vectors != NULL)&&(tf0->head.vecSize > 0)&&(tf0->head.nVec > 0)) {\n    // a valid init file has been loaded\n    // check nVec and correct our enable options if necessary (also warn the user)\n    if (tf0->head.nVec == 1) { // mean only\n      if (stdEnable||normEnable||(!meanEnable)) {\n        meanEnable=1; stdEnable=0; normEnable=0;\n        SMILE_IWRN(1,\"Your loaded transform init file seems to have 1 vector, assuming mean only normalisation. This, however, contradicts the 'enableX' options set in the config, you should check this!\");\n      }\n    } else if (tf0->head.nVec == 2) { // mvn \n      if (minMaxNormEnable) {\n        meanEnable=0; stdEnable=0; normEnable=0; minMaxNormEnable = 1;\n      }\n      else if (((!stdEnable)||normEnable||(!meanEnable)) && (!minMaxNormEnable)) {\n        meanEnable=1; stdEnable=1; normEnable=0;\n        SMILE_IWRN(1,\"Your loaded transform init file seems to have 2 vectors, assuming mean and variance normalisation. This, however, contradicts the 'enableX' options set in the config, you should check this!\");\n      }\n    } else if (tf0->head.nVec == 3) { // mrn\n      if (stdEnable||(!normEnable)||(!meanEnable)) {\n        meanEnable=1; stdEnable=0; normEnable=1;\n        SMILE_IWRN(1,\"Your loaded transform init file seems to have 3 vectors, assuming mean and range normalisation. This, however, contradicts the 'enableX' options set in the config, you should check this!\");\n      }\n    }\n  }\n\n  tf->head.nUserdata=0;\n  if (stdEnable) {\n    tf->head.nGroups = 2;\n    tf->head.nVec = 2;\n  } else if (normEnable) {\n    tf->head.nGroups = 3;\n    tf->head.nVec = 3;\n  } else if (minMaxNormEnable) {\n    /*\n    if (normEnable==1 && stdEnable == 0) { // assume min/max norm data...\n      tf->head.typeID = TRFTYPE_MRN;\n    } else if (stdEnable == 1) {\n      tf->head.typeID = TRFTYPE_MVN;\n    }\n    */\n    tf->head.nGroups = 2;\n    tf->head.nVec = 2;\n  } else { // mean only...\n    tf->head.nGroups = 1;\n    tf->head.nVec = 1;\n  }\n\n  if (stdEnable) tf->head.typeID = TRFTYPE_MVN;\n  else if (minMaxNormEnable) tf->head.typeID = TRFTYPE_MVN; /* compatibility for loading old bin format min max norm files produced by arffnorm, TODO: make this more compatible with a (to add..) option for minMaxEnable in the new smileTf format */\n  else if (normEnable) tf->head.typeID = TRFTYPE_MRN;\n  else if (meanEnable) tf->head.typeID = TRFTYPE_MNN;\n  tf->vectors = (double *)malloc(sizeof(double)*tf->head.nVec*tf->head.vecSize);\n\n  //return 1;\n}\n\nint cVectorMVN::transformDataFloat(const struct sTfData * tf, const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi)\n{\n  long i;\n  long N = tf->head.vecSize;\n  double *mean = tf->vectors;\n  double *stddev = NULL;\n  double *min = NULL;\n  double *max = NULL;\n  \n\n  if (minMaxNormEnable) {\n    max = mean;\n    min = mean+N;\n\n    for (i=0; i<MIN(Nsrc,Ndst); i++) {\n      if (!finite(max[i])) {\n        SMILE_IERR(2,\"NON-finite value: max at index %i, flooring this value with %f\\n\",i,0.0);\n        max[i] = 0.0;\n      } else if (!finite(min[i])) {\n        SMILE_IERR(2,\"NON-finite value: min at index %i, flooring this value with %f\\n\",i,0.0);\n        min[i] = 0.0;\n      } else {\n        if (max[i]-min[i] != 0.0) {\n          dst[i] = (FLOAT_DMEM)2.0 * (src[i]-(FLOAT_DMEM)min[i])/((FLOAT_DMEM)max[i] - (FLOAT_DMEM)min[i]) - (FLOAT_DMEM)1.0;\n        } else {\n          dst[i] = 0.0;\n        }\n      }\n    }\n\n  } else {\n\n    if (stdEnable) {\n      stddev = mean+N;\n    }\n    if (normEnable) {\n      min = mean+N;\n      max = min+N;\n    }\n\n    if (stdEnable) {  // MVN\n      if (meanEnable) {\n        for (i=0; i<MIN(Nsrc,Ndst); i++) {\n          if (stddev[i] == 0.0 || !finite(stddev[i])) {\n            SMILE_IERR(2,\"NON-finite or zero value: stddev at index %i, flooring this value with %f\\n\",i,STDDEV_FLOOR);\n            stddev[i] = STDDEV_FLOOR;\n          } else if (stddev[i] <= 0.0) stddev[i] = STDDEV_FLOOR;\n          dst[i] = (src[i]-(FLOAT_DMEM)mean[i])/(FLOAT_DMEM)stddev[i];\n        }\n      } else {\n        for (i=0; i<MIN(Nsrc,Ndst); i++) {\n          if (stddev[i] == 0.0 || !finite(stddev[i])) {\n            SMILE_IERR(2,\"NON-finite value: stddev at index %i, flooring this value with %f\\n\",i,STDDEV_FLOOR);\n            stddev[i] = STDDEV_FLOOR;\n          }\n          if (stddev[i] <= 0.0) stddev[i] = STDDEV_FLOOR;\n          dst[i] = ( (src[i]-(FLOAT_DMEM)mean[i])/(FLOAT_DMEM)stddev[i] + (FLOAT_DMEM)mean[i] );\n        }\n      }\n    } else if (normEnable) {\n      if (meanEnable) {\n        for (i=0; i<MIN(Nsrc,Ndst); i++) {\n          double range = (max[i]-min[i])/2.0;\n          if (range <= 0.0) range = 1.0;\n          dst[i] = (src[i]-(FLOAT_DMEM)mean[i])/(FLOAT_DMEM)range;\n        }\n      } else {\n        if (htkLogEnorm) {\n          for (i=0; i<MIN(Nsrc,Ndst); i++) {\n            // HTK compatible energy normalisation...\n            dst[i] = ( (FLOAT_DMEM)1.0-((FLOAT_DMEM)max[i]-src[i]) );\n          }\n        } else { // subtract min and divide by range  (normalises to 0..1)\n          for (i=0; i<MIN(Nsrc,Ndst); i++) {\n            double range = (max[i]-min[i]);\n            if (range <= 0.0) range = 1.0;\n            //dst[i] = ( (src[i]-(FLOAT_DMEM)mean[i])/(FLOAT_DMEM)range + (FLOAT_DMEM)mean[i]);\n            dst[i] = ( (src[i]-(FLOAT_DMEM)min[i])/(FLOAT_DMEM)range);\n          }\n        }\n\n      }\n    } else if (meanEnable) {\n      if (spectralFlooring) {\n        for (i=0; i<MIN(Nsrc,Ndst); i++) {\n          if (src[i]<(FLOAT_DMEM)mean[i]) {\n            dst[i] = specFloor;\n          } else {\n            if (subtractMeans) {\n              dst[i] = src[i] - (FLOAT_DMEM)mean[i];\n            } else {\n              dst[i] = src[i];\n            }\n          }\n        }\n      } else {\n        for (i=0; i<MIN(Nsrc,Ndst); i++) {\n          dst[i] = src[i]-(FLOAT_DMEM)mean[i];\n        }\n      }\n    } else {\n      return 0;\n    }\n\n  }\n\n  return MIN(Nsrc,Ndst);\n}\n\n//TODO: support updates for minMaxNormEnable\n\nint cVectorMVN::updateTransformFloatExp(struct sTfData * tf, const FLOAT_DMEM *src, int idxi)\n{\n  long i;\n  long N = tf->head.vecSize;\n  double *mean = tf->vectors;\n  double *stddev = NULL;\n  double *min = NULL;\n  double *max = NULL;\n\n  /* update means */ \n  for (i=0; i<N; i++) {\n    mean[i] = alpha * (mean[i] - (double)src[i]) + (double)src[i];\n  }\n\n  /* update stddev */ \n  if (stdEnable) {\n    stddev = mean+N;\n    for (i=0; i<N; i++) {\n      double x = (src[i] - mean[i]);\n      x *= x; // square it\n      stddev[i] = sqrt( alpha * (stddev[i]*stddev[i] - x) + x );\n    }\n  }\n\n  /* update range */ \n  if (normEnable) {\n    min = mean+N;\n    max = min+N;\n    FLOAT_DMEM alphaM = (((FLOAT_DMEM)1.0 - alpha)/(FLOAT_DMEM)2.0 + alpha);\n    for (i=0; i<N; i++) {\n      if ((double)src[i] > max[i]) max[i] = (double)src[i];\n      else { max[i] = alphaM * (double)src[i]; }\n      if ((double)src[i] < min[i]) min[i] = (double)src[i];\n      else { min[i] = (double)src[i] / alphaM; }\n    }\n  }\n\n  return 1;\n}\n\nint cVectorMVN::updateTransformFloatBuf(struct sTfData * tf, const FLOAT_DMEM *src, FLOAT_DMEM *buf, long Nbuf, long wrPtr, int idxi)\n{\n  long i;\n  long N = tf->head.vecSize;\n  double *mean = tf->vectors;\n  double *stddev = NULL;\n  double *min = NULL;\n  double *max = NULL;\n\n  /* update means */ \n  if (Nbuf == fixedBufferFrames) {\n    for (i=0; i<N; i++) {\n      double sum = mean[i] * (double)(Nbuf);\n      sum += src[i];\n      // remove last input in buffer from sum in means[]:\n      sum -= buf[i + N*wrPtr];\n      mean[i] = sum/(double)(Nbuf);\n    }\n  } else {\n    // TODO: maybe use initial value better here??\n    for (i=0; i<N; i++) {\n      double sum = mean[i] * (double)(Nbuf);\n      sum += src[i];\n      mean[i] = sum/(double)(Nbuf+1);\n    }\n  }\n\n  /* update stddev */ \n  if (stdEnable) {\n    stddev = mean+N;\n    if (Nbuf == fixedBufferFrames) {\n      for (i=0; i<N; i++) {\n        double x = (src[i] - mean[i])*(src[i] - mean[i]);\n        double sum = stddev[i]*stddev[i] * (double)(Nbuf);\n        sum += x;\n        // remove last input in buffer from sum in means[]:\n        sum -= (buf[i + N*wrPtr] - mean[i])*(buf[i + N*wrPtr] - mean[i]); \n          // ^^^!!! WARNING: the mean has changed, so this approximation leads to some errors...\n          //          easy workaround: always compute variance over FULL buffer... :-(\n          //          hard workaround: manage a second ring-buffer where the means are stored...\n        stddev[i] = sqrt(sum/(double)(Nbuf));\n      }\n    } else {\n      for (i=0; i<N; i++) {\n        double x = (src[i] - mean[i])*(src[i] - mean[i]);\n        double sum = stddev[i]*stddev[i] * (double)(Nbuf);\n        sum += x;\n          // TODO: see above, maybe add adding mean values to buffer...\n        stddev[i] = sqrt(sum/(double)(Nbuf+1));\n      }\n    }\n  }\n\n  /* update range */ \n  if (normEnable) {\n    min = mean+N;\n    max = min+N;\n    if (Nbuf == fixedBufferFrames) {\n      for (i=0; i<N; i++) {\n        if ((double)src[i] > max[i]) max[i] = (double)src[i];\n        else if ((double)buf[i + N*wrPtr] == max[i]) { // we have to rescan the full buffer for a new max if the old max is the last element in the buffer ...\n          long j;\n          FLOAT_DMEM newmax;\n          if (wrPtr != 0) newmax = buf[i + N*0];\n          else newmax = buf[i + N*1];\n          for (j=0; j<Nbuf; j++) {\n            if (j!=wrPtr) {\n              if (buf[i+N*j] > newmax) { newmax = buf[i+N*j]; }\n            }\n          }\n          if (src[i] > newmax) max[i] = (double)src[i];\n          else max[i] = (double)newmax;\n        }\n\n        \n        if ((double)src[i] < min[i]) min[i] = (double)src[i];\n        else if ((double)buf[i + N*wrPtr] == min[i]) { // we have to rescan the full buffer for a new min if the old min is the last element in the buffer ...\n          long j;\n          FLOAT_DMEM newmin;\n          if (wrPtr != 0) newmin = buf[i + N*0];\n          else newmin = buf[i + N*1];\n          for (j=0; j<Nbuf; j++) {\n            if (j!=wrPtr) {\n              if (buf[i+N*j] < newmin) { newmin = buf[i+N*j]; }\n            }\n          }\n          if (src[i] < newmin) min[i] = (double)src[i];\n          else min[i] = (double)newmin;\n        }\n\n      }\n    } else {\n      for (i=0; i<N; i++) {\n        if (Nbuf == 0) {\n          max[i] = (double)src[i];\n          min[i] = (double)src[i];\n        } else {\n          if ((double)src[i] > max[i]) max[i] = (double)src[i];\n          if ((double)src[i] < min[i]) min[i] = (double)src[i];\n        }\n      }\n\n    }\n  }\n\n  return 1;\n}\n\n\nint cVectorMVN::updateTransformFloatAvg(struct sTfData * tf, const FLOAT_DMEM *src, int idxi)\n{\n  long i;\n  long N = tf->head.vecSize;\n  double *mean = tf->vectors;\n  double *stddev = NULL;\n  double *min = NULL;\n  double *max = NULL;\n\n  FLOAT_DMEM nVal=(FLOAT_DMEM)(nFrames-1);\n\n  /* update means */ \n  for (i=0; i<N; i++) {\n    double sum = mean[i] * (double)(nVal+weight);\n    sum += (double)src[i];\n    mean[i] = sum/(double)(nVal+weight+1.0);\n  }\n\n  /* update stddev */ \n  if (stdEnable) {\n    stddev = mean+N;\n    for (i=0; i<N; i++) {\n      double sum = stddev[i]*stddev[i] * (double)(nVal+weight);\n      sum += ((double)src[i] - mean[i])*((double)src[i] - mean[i]);\n      stddev[i] = sqrt(sum/(double)(nVal+weight+1.0));\n    }\n  }\n\n  /* update range */ \n  if (normEnable) {\n    min = mean+N;\n    max = min+N;\n    for (i=0; i<N; i++) {\n      if ((double)src[i] < min[i]) min[i] = (double)src[i];\n      if ((double)src[i] > max[i]) max[i] = (double)src[i];\n    }\n  }\n\n  return 1;\n}\n\nint cVectorMVN::updateTransformFloatAvgI(struct sTfData * tf, const FLOAT_DMEM *src, FLOAT_DMEM *buf, long * _bufferNframes, long Nbuf, long wrPtr, int idxi)\n{\n  return updateTransformFloatAvg(tf,src,idxi);\n  /*long i;\n  long N = tf->head.vecSize;\n  double *mean = tf->head.vectors;\n  double *stddev = NULL;\n  double *min = NULL;\n  double *max = NULL;\n\n  FLOAT_DMEM nVal=(FLOAT_DMEM)(nFrames-1);\n*/\n/* all there is to do... ??\n  on turn reset, preserve current mean values (do not init from transform0, instead update transform0?)\n  reset nFrames though...\n\n  */\n\n#if 0\n  /* update means */ \n  for (i=0; i<N; i++) {\n    double sum = mean[i] * (double)(nVal+weight);\n    sum += (double)src[i];\n    mean[i] = sum/(double)(nVal+weight+1.0);\n  }\n\n  /* update stddev */ \n  if (stdEnable) {\n    stddev = mean+N;\n    for (i=0; i<N; i++) {\n      double sum = stddev[i]*stddev[i] * (double)(nVal+weight);\n      sum += ((double)src[i] - mean[i])*((double)src[i] - mean[i]);\n      stddev[i] = sqrt(sum/(double)(nVal+weight+1.0));\n    }\n  }\n\n  /* update range */ \n  if (normEnable) {\n    min = mean+N;\n    max = min+N;\n    for (i=0; i<N; i++) {\n      if ((double)src[i] < min[i]) min[i] = (double)src[i];\n      if ((double)src[i] > max[i]) max[i] = (double)src[i];\n    }\n  }\n#endif\n\n  //return 1;\n}\n\ncVectorMVN::~cVectorMVN()\n{\n}\n\n"
  },
  {
    "path": "src/dspcore/vectorPreemphasis.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\npre-emphasis per frame  (simplification, however, this is the way HTK does it... so for compatibility... here you go)\n(use before window function is applied!)\n\n*/\n\n\n#include <dspcore/vectorPreemphasis.hpp>\n\n#define MODULE \"cVectorPreemphasis\"\n\nSMILECOMPONENT_STATICS(cVectorPreemphasis)\n\nSMILECOMPONENT_REGCOMP(cVectorPreemphasis)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  \n  scname = COMPONENT_NAME_CVECTORPREEMPHASIS;\n  sdescription = COMPONENT_DESCRIPTION_CVECTORPREEMPHASIS;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"k\",\"The pre-emphasis coefficient k in y[n] = x[n] - k*x[n-1]\",0.97);\n    ct->setField(\"f\",\"The pre-emphasis frequency f in Hz : k = exp( -2*pi * f/samplingFreq. ) (this option will override k)\",0,0,0);\n    ct->setField(\"de\",\"1 = perform de- instead of pre-emphasis\",0);\n  )\n  SMILECOMPONENT_MAKEINFO(cVectorPreemphasis);\n}\n\nSMILECOMPONENT_CREATE(cVectorPreemphasis)\n\n//-----\n\ncVectorPreemphasis::cVectorPreemphasis(const char *_name) :\n  cVectorProcessor(_name),\n  k(0.0)\n{\n\n}\n\nvoid cVectorPreemphasis::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n  \n  k=(FLOAT_DMEM)getDouble(\"k\");\n\n  if (isSet(\"f\")) {\n    f = getDouble(\"f\");\n  } else {\n    f = -1.0;\n  }\n\n  if (f < 0.0) { \n    SMILE_IDBG(2,\"k = %f\",k);\n    if ((k<0.0)||(k>1.0)) {\n      SMILE_IERR(1,\"k must be in the range [0;1]! Setting k=0.0 !\");\n      k=0.0;\n    }\n  } else {\n    SMILE_IDBG(2,\"using preemphasis frequency f=%f Hz instead of k\",f);\n  }\n\n  de=getInt(\"de\");\n  SMILE_DBG(2,\"de=%f\",de);\n}\n\nint cVectorPreemphasis::dataProcessorCustomFinalise()\n{\n  int ret = cVectorProcessor::dataProcessorCustomFinalise();\n  if (f >= 0.0) {\n    double _T = getBasePeriod();\n    k = (FLOAT_DMEM)exp( -2.0*M_PI * f * _T );\n    SMILE_IDBG(2,\"computed k from f (%f Hz) : k = %f  (samplingRate = %f Hz)\",f,k,1.0/_T);\n  }\n  return ret;\n}\n\n\n// a derived class should override this method, in order to implement the actual processing\nint cVectorPreemphasis::processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  // do domething to data in *src, save result to *dst\n  // NOTE: *src and *dst may be the same...\n  \n  return 0;\n}\n\n// a derived class should override this method, in order to implement the actual processing\nint cVectorPreemphasis::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  // do domething to data in *src, save result to *dst\n  // NOTE: *src and *dst may be the same...\n\n  *(dst++) = (1-k) * *(src++); // - k * *(src-1);\n  long n;\n  if (de) {\n    for (n=1; n<Ndst; n++) {\n      *(dst++) = *(src) + k * *(src-1);\n      src++;\n    }\n  } else {\n    for (n=1; n<Ndst; n++) {\n      *(dst++) = *(src) - k * *(src-1);\n      src++;\n    }\n  }\n  return 1;\n}\n\ncVectorPreemphasis::~cVectorPreemphasis()\n{\n}\n\n"
  },
  {
    "path": "src/dspcore/windower.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\ndata windower.\ntakes frames from one level, applies window function and saves to other level\n\n*/\n\n\n#include <dspcore/windower.hpp>\n#include <math.h>\n\n#define MODULE \"cWindower\"\n\n\n\nSMILECOMPONENT_STATICS(cWindower)\n\nSMILECOMPONENT_REGCOMP(cWindower)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CWINDOWER;\n  sdescription = COMPONENT_DESCRIPTION_CWINDOWER;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"gain\",\"This option allows you to specify a scaling factor by which window function (which is by default normalised to max. 1) should be multiplied by \",1.0);\n    ct->setField(\"offset\",\"This specifies an offset which will be added to the samples after multiplying with the window function\",0.0);\n    ct->setField(\"xscale\", \"(NOT YET IMPLEMENTED!) A scale factor applied to the y-axis when computing the window. A factor of 2 will compute the window over twice the window length, and then clip it to the window, i.e. only the left half of the window function will be the actual window. In case of xscale=0.5, for example, the second half of the actual window will be zero, while the first half is the window function. Use in conjunction with 'xshift' paramter.\", 1.0);\n    ct->setField(\"xshift\", \"Specifies a shift of the window center to the left (negative) or right (positive) as percentage of the window length (ignoring xscale parameter). Allowed range is from -100% to +100%.\", 0.0);\n    ct->setField(\"winFunc\",\"Window function:\\n   Hann [Han] (= raised cosine window; use this, if you want to resynthesis from the spectral domain, also use 50% overlap in the framer!),\\n   Hamming [Ham],\\n   Rectangular [Rec],\\n   Gauss [Gau],\\n   Sine / Cosine [Sin],\\n   Triangular [Tri],\\n   Bartlett [Bar],\\n   Bartlett-Hann [BaH],\\n   Blackmann [Bla],\\n   Blackmann-Harris [BlH],\\n   Lanczos [Lac]\", \"Han\");\n    ct->setField(\"sigma\",\"Standard deviation for the Gaussian window relative to half the window length. I.e. at N/2 - (N/2 * sigma) the window amplitude will be 0.5.\", 0.4);\n    ct->setField(\"alpha0\",\"alpha0 for Blackmann(-Harris) / Bartlett-Hann windows (optional!)\",0.0,0,0);\n    ct->setField(\"alpha1\",\"alpha1 for Blackmann(-Harris) / Bartlett-Hann windows (optional!)\",0.0,0,0);\n    ct->setField(\"alpha2\",\"alpha2 for Blackmann(-Harris) / Bartlett-Hann windows (optional!)\",0.0,0,0);\n    ct->setField(\"alpha3\",\"alpha3 for Blackmann-Harris window (optional!)\",0.0,0,0);\n    ct->setField(\"alpha\",\"alpha for the Blackmann window\",0.16);\n    ct->setField(\"fade\", \"Fade percentage (0 - 0.5) for fading edges to 0 with a half raised cosine function (0 = no fade, default)\", 0.0);\n    ct->setField(\"squareRoot\",\"1 = use square root of 'winFunc' as actual window function (e.g. to get a root raised cosine window).\",0);\n    ct->setField(\"saveWindowToFile\", \"Save window to text file (comma separated coefficients) of given name. If NULL (default) nothing will be saved.\", (const char*)NULL);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cWindower);\n}\n\nSMILECOMPONENT_CREATE(cWindower)\n\n//-----\n\ncWindower::cWindower(const char *_name) :\n  cVectorProcessor(_name),\n  dtype(0),\n  win(NULL)\n{\n\n}\n\nvoid cWindower::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n\n  offset=getDouble(\"offset\");\n  gain=getDouble(\"gain\");\n\n  const char *winF = getStr(\"winFunc\");\n\n  winFunc = winFuncToInt(winF);\n  if (winFunc == WINF_UNKNOWN) {\n    SMILE_IERR(1,\"unkown window function '%s' specified in config file! setting window function to 'rectangular' (none)!\",winF);\n    winFunc = WINF_RECTANGLE;\n  }\n  \n  if (winFunc == WINF_GAUSS) sigma = getDouble(\"sigma\");\n  \n  if (winFunc == WINF_BLACKMAN) {\n    if (isSet(\"alpha0\") && isSet(\"alpha1\") && isSet(\"alpha2\")) {\n      alpha0 = getDouble(\"alpha0\");\n      alpha1 = getDouble(\"alpha1\");\n      alpha2 = getDouble(\"alpha2\");\n    } else {\n      alpha = getDouble(\"alpha\");\n      alpha0 = (1.0-alpha)*0.5;\n      alpha1 = 0.5;\n      alpha2 = alpha*0.5;\n    }\n  }\n  if (winFunc == WINF_BLACKHARR) {\n    if (isSet(\"alpha0\")) alpha0 = getDouble(\"alpha0\");\n    else alpha0 = 0.35875;\n    if (isSet(\"alpha1\")) alpha1 = getDouble(\"alpha1\");\n    else alpha1 = 0.48829;\n    if (isSet(\"alpha2\")) alpha2 = getDouble(\"alpha2\");\n    else alpha2 = 0.14128;\n    if (isSet(\"alpha3\")) alpha3 = getDouble(\"alpha3\");\n    else alpha3 = 0.01168;\n  }\n  if (winFunc == WINF_BARTHANN) {\n    if (isSet(\"alpha0\")) alpha0 = getDouble(\"alpha0\");\n    else alpha0 = 0.62;\n    if (isSet(\"alpha1\")) alpha1 = getDouble(\"alpha1\");\n    else alpha1 = 0.48;\n    if (isSet(\"alpha2\")) alpha2 = getDouble(\"alpha2\");\n    else alpha2 = 0.38;\n  }\n  xshift = getDouble(\"xshift\");\n  xscale = getDouble(\"xscale\");\n  fade = getDouble(\"fade\");\n  if (fade > 0.5) {\n    fade = 0.5;\n    SMILE_IWRN(1, \"'fade' option cannot be > 0.5. Setting to max. value 0.5.\");\n  }\n  if (fade < 0) {\n    fade = 0.0;\n    SMILE_IWRN(1, \"'fade' option cannot be < 0.0. Setting to min. value 0.0 (no fade).\");\n  }\n  squareRoot = getInt(\"squareRoot\");\n  saveWindowToFile = getStr(\"saveWindowToFile\");\n}\n\nstruct sWindowerConfigParsed * cWindower::getWindowerConfigParsed()\n{\n  struct sWindowerConfigParsed * c = (struct sWindowerConfigParsed *)malloc(sizeof(struct sWindowerConfigParsed));\n  c->winFunc = winFunc;\n  c->squareRoot = squareRoot;\n  c->offset = offset;\n  c->gain = gain;\n  c->sigma = sigma;\n  c->alpha = alpha;\n  c->alpha0 = alpha0;\n  c->alpha1 = alpha1;\n  c->alpha2 = alpha2;\n  c->alpha3 = alpha3;\n  c->win = win;\n  c->frameSizeFrames = frameSizeFrames;\n  return c;\n}\n\nint cWindower::myFinaliseInstance()\n{\n  int ret = cVectorProcessor::myFinaliseInstance();\n\n  if (ret) {\n    frameSizeFrames = reader_->getLevelN()/reader_->getLevelNf();\n    precomputeWinFunc();\n  }\n\n  return ret;\n}\n\n\nvoid cWindower::precomputeWinFunc()\n{\n  if (!isConfigured()) return;\n  long i;\n  if (win != NULL) free(win);\n  switch(winFunc) {\n    case WINF_RECTANGLE: win = smileDsp_winRec(frameSizeFrames); break;\n    case WINF_HANNING:   win = smileDsp_winHan(frameSizeFrames); break;\n    case WINF_HAMMING:   win = smileDsp_winHam(frameSizeFrames); break;\n    case WINF_TRIANGLE:  win = smileDsp_winTri(frameSizeFrames); break;\n    case WINF_BARTLETT:  win = smileDsp_winBar(frameSizeFrames); break;\n    case WINF_SINE:      win = smileDsp_winSin(frameSizeFrames); break;\n    case WINF_GAUSS:     win = smileDsp_winGau(frameSizeFrames,sigma); break;\n    case WINF_BLACKMAN:  win = smileDsp_winBla(frameSizeFrames,alpha0,alpha1,alpha2); break;\n    case WINF_BLACKHARR: win = smileDsp_winBlH(frameSizeFrames,alpha0,alpha1,alpha2,alpha3); break;\n    case WINF_BARTHANN:  win = smileDsp_winBaH(frameSizeFrames,alpha0,alpha1,alpha2); break;\n    case WINF_LANCZOS:   win = smileDsp_winLac(frameSizeFrames); break;\n    default: SMILE_ERR(1,\"unknown window function ID (%i) !\",winFunc); win=NULL;\n  }\n  if ((win != NULL)&&(squareRoot)) {\n    for (i=0; i<frameSizeFrames; i++) {\n      if (win[i] >= 0.0) win[i] = sqrt(win[i]);\n      else {\n        SMILE_IERR(1,\"window function '%s' apparently has negative values (%f) (bug?), taking the square root of this function is not possible, please correct your config! (at current, the square root of all non-negative values is computed and negative values are converted to zeros)\",getStr(\"winFunc\"),win[i]);\n        win[i] = 0.0;\n      }\n    }\n  }\n  if ((win != NULL) && (fade > 0.0)) {\n    long fadeSize = (long)((double)frameSizeFrames * fade);\n    for (i=0; i<fadeSize; i++) {\n      double a = -0.5 * (cos(M_PI * (double)i / (double)fadeSize) - 1.0);\n      win[i] *= a;\n      win[frameSizeFrames - i - 1] *= a;\n    }\n  }\n  if ((win != NULL)&&(gain!=1.0)) { // apply gain\n    for (i=0; i<frameSizeFrames; i++) {\n      win[i] *= gain;\n    }\n  }\n  // apply xshift\n  long shiftAbs = (long)((double)frameSizeFrames * xshift);\n  if (shiftAbs < 0) {  // shift left\n    shiftAbs *= -1;\n    for(i = shiftAbs; i < frameSizeFrames; i++) {\n      win[i - shiftAbs] = win[i];\n    }\n    for(i = frameSizeFrames - shiftAbs; i < frameSizeFrames; i++) {  // zero pad to the right\n      win[i] = 0.0;\n    }\n  } else if (shiftAbs > 0) {  // shift right\n    for(i = frameSizeFrames - shiftAbs - 1; i >= 0; i--) {\n      win[i + shiftAbs] = win[i];\n    }\n    for(i = 0; i < shiftAbs; i++) {  // zero pad to the left\n      win[i] = 0.0;\n    }\n  }\n}\n\nint cWindower::processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi)\n{\n  if (win != NULL) {\n    double *w = win;\n    long n;\n    for (n=0; n<Ndst; n++) { *dst = (int) round( (double)(*src) * (*(w++)) + offset ); src++; dst++; }\n  }\n  return 1;\n}\n\n// a derived class should override this method, in order to implement the actual processing\nint cWindower::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  if (win != NULL) {\n    double *w = win;\n    long n;\n    for (n=0; n<Ndst; n++) { *dst = *src * (FLOAT_DMEM)(*(w++)) + (FLOAT_DMEM)offset; src++; dst++; }\n  }\n  return 1;\n}\n\n\ncWindower::~cWindower()\n{\n  if (win!=NULL) free(win);\n}\n\n"
  },
  {
    "path": "src/examples/componentTemplate.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nvery basic and low-level cSmileComponent template ...\n\n*/\n\n\n#include <examples/componentTemplate.hpp>\n\n#define MODULE \"myComponentTemplate\"\n\n/*Library:\nsComponentInfo * registerMe(cConfigManager *_confman) {\n  cMyComponent::registerComponent(_confman);\n}\n*/\n\nSMILECOMPONENT_STATICS(cMyComponent)\n                 // vvv!!!!! change cMyComponent to ..... !\nSMILECOMPONENT_REGCOMP(cMyComponent)\n//sComponentInfo * cMyComponent::registerComponent(cConfigManager *_confman)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  cname_ = COMPONENT_NAME_CMYCOMPONENT;\n  description_ = COMPONENT_DESCRIPTION_CMYCOMPONENT;\n\n  // configure your component's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n // OR: inherit a type, e.g. cDataSink:   SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSink\")\n\n  SMILECOMPONENT_IFNOTREGAGAIN_BEGIN\n  \n  ct->setField(\"f1\", \"this is an example int\", 0);\n  if (ct->setField(\"subconf\", \"this is config of sub-component\",\n                  sconfman->getTypeObj(\"nameOfSubCompType\"), NO_ARRAY, DONT_FREE) == -1) {\n     rA=1; // if subtype not yet found, request , re-register in the next iteration\n  }\n\n  SMILECOMPONENT_IFNOTREGAGAIN_END\n\n    // vvv!!!!! change cMyComponent to ..... !\n  SMILECOMPONENT_MAKEINFO(cMyComponent);\n}\n\n\nSMILECOMPONENT_CREATE(cMyComponent)\n\n// NOTE: use this for abstract classes, e.g. dataSource, etc., which do NOT implement fetchConfig()\n//SMILECOMPONENT_CREATE_ABSTRACT(cMyComponent)\n\n\n// ----\n\n// constructor:\ncMyComponent::cMyComponent(const char *_name) : cSmileComponent(_name);\n{\n\n}\n\n/*\nvirtual int cMyComponent::configureInstance()\n{\n  if (isConfigured()) return 1;\n  \n  // ....\n}\n\nvirtual int cMyComponent::finaliseInstance()\n{\n  if (isFinalised()) return 1;\n  \n  // ....\n}\n\nvirtual int tick(long long t)\n{\n  if (!isFinalised()) return 0;\n  \n  // ....\n}\n*/\n"
  },
  {
    "path": "src/examples/exampleProcessor.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample dataProcessor\nwrites data to data memory...\n\n** you can use this as a template for custom dataProcessor components **\n\n*/\n\n\n#include <examples/exampleProcessor.hpp>\n\n#define MODULE \"cExampleProcessor\"\n\nSMILECOMPONENT_STATICS(cExampleProcessor)\n\nSMILECOMPONENT_REGCOMP(cExampleProcessor)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CEXAMPLEPROCESSOR;\n  sdescription = COMPONENT_DESCRIPTION_CEXAMPLEPROCESSOR;\n\n  // we inherit cDataProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataProcessor\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"offset\",\"The offset that this dummy component adds to the input values.\",1.0);\n  )\n  \n  SMILECOMPONENT_MAKEINFO(cExampleProcessor);\n}\n\n\nSMILECOMPONENT_CREATE(cExampleProcessor)\n\n//-----\n\ncExampleProcessor::cExampleProcessor(const char *_name) :\n  cDataProcessor(_name)\n{\n}\n\nvoid cExampleProcessor::fetchConfig()\n{\n  cDataProcessor::fetchConfig();\n\n  // load all configuration parameters you will later require fast and easy access to here:\n\n  offset = getDouble(\"offset\");\n  // note, that it is \"polite\" to output the loaded parameters at debug level 2:\n  SMILE_DBG(2,\"offset = %f\",offset);\n}\n\n/*  This method is rarely used. It is only there to improve readability of component code.\n    It is called from cDataProcessor::myFinaliseInstance just before the call to configureWriter.\n    I.e. you can do everything that you would do here, also in configureWriter()\n    However, if you implement the method, it must return 1 in order for the configure process to continue!\n*/\n/*\nint cExampleProcessor::configureReader() \n{\n  return 1;\n}\n*/\n\nint cExampleProcessor::configureWriter(sDmLevelConfig &c) \n{\n  // if you would like to change the write level parameters... do so HERE:\n\n  c.T = 0.01; /* don't forget to set the write level sample/frame period */\n  c.nT = 100; /* e.g. 100 frames buffersize for ringbuffer */\n\n  return 1; /* success */\n}\n\n/* You shouldn't need to touch this....\nint cExampleProcessor::myConfigureInstance()\n{\n  int ret = cDataProcessor::myConfigureInstance();\n  return ret;\n}\n*/\n\n/*\n  Do what you like here... this is called after the input names and number of input elements have become available, \n  so you may use them here.\n*/\n/*\nint cExampleProcessor::dataProcessorCustomFinalise()\n{\n  \n  return 1;\n}\n*/\n\n\n/* \n  Use setupNewNames() to freely set the data elements and their names in the output level\n  The input names are available at this point, you can get them via reader->getFrameMeta()\n  Please set \"namesAreSet\" to 1, when you do set names\n*/\n/*\nint cExampleProcessor::setupNewNames(long nEl) \n{\n  // namesAreSet = 1;\n  return 1;\n}\n*/\n\n/*\n  If you don't use setupNewNames() you may set the names for each input field by overwriting the following method:\n*/\n/*\nint cExampleProcessor::setupNamesForField( TODO )\n{\n  // DOC TODO...\n}\n*/\n\nint cExampleProcessor::myFinaliseInstance()\n{\n  int ret = cDataProcessor::myFinaliseInstance();\n  if (ret) {\n    // do all custom init stuff here... \n    // e.g. allocating and initialising memory (which is not used before, e.g. in setupNames, etc.),\n    // loading external data, \n    // etc.\n\n    // ...\n\n  }\n  return ret;\n}\n\n\nint cExampleProcessor::myTick(long long t)\n{\n  /* actually process data... */\n\n  SMILE_IDBG(4,\"tick # %i, processing value vector\",t);\n\n  // get next frame from dataMemory\n  cVector *vec = reader_->getNextFrame();\n\n  // add offset\n  int i;\n  for (i=0; i<vec->N; i++) {\n    vec->dataF[i] += (FLOAT_DMEM)offset;\n  }\n\n  // if you create a new vector here and pass it to setNextFrame(),\n  // then be sure to assign a valid tmeta info for correct timing info:\n  // e.g.:\n  //   myVec->tmetaReplace(vec->tmeta);\n\n\n  // save to dataMemory\n  writer_->setNextFrame(vec);\n\n  //   writer->setNextFrame(myVec);\n\n  return 1;\n}\n\n\ncExampleProcessor::~cExampleProcessor()\n{\n  // cleanup...\n\n}\n\n"
  },
  {
    "path": "src/examples/exampleSink.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample dataSink:\nreads data from data memory and outputs it to console/logfile (via smileLogger)\nthis component is also useful for debugging\n\n*/\n\n\n#include <examples/exampleSink.hpp>\n\n#define MODULE \"cExampleSink\"\n\n\nSMILECOMPONENT_STATICS(cExampleSink)\n\nSMILECOMPONENT_REGCOMP(cExampleSink)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CEXAMPLESINK;\n  sdescription = COMPONENT_DESCRIPTION_CEXAMPLESINK;\n\n  // we inherit cDataSink configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSink\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"filename\",\"The name of a text file to dump values to (this file will be overwritten, if it exists)\",(const char *)NULL);\n    ct->setField(\"lag\",\"Output data <lag> frames behind\",0,0,0);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cExampleSink);\n}\n\nSMILECOMPONENT_CREATE(cExampleSink)\n\n//-----\n\ncExampleSink::cExampleSink(const char *_name) :\n  cDataSink(_name),\n  fHandle(NULL)\n{\n  // ...\n}\n\nvoid cExampleSink::fetchConfig()\n{\n  cDataSink::fetchConfig();\n  \n  filename = getStr(\"filename\");\n  SMILE_DBG(2,\"filename = '%s'\",filename);\n  lag = getInt(\"lag\");\n  SMILE_DBG(2,\"lag = %i\",lag);\n}\n\n\n/*\nint cExampleSink::myConfigureInstance()\n{\n  return  cDataSink::myConfigureInstance();\n  \n}\n*/\n\n\nint cExampleSink::myFinaliseInstance()\n{\n  // FIRST call cDataSink myFinaliseInstance, this will finalise our dataWriter...\n  int ret = cDataSink::myFinaliseInstance();\n\n  /* if that was SUCCESSFUL (i.e. ret == 1), then do some stuff like\n     loading models or opening output files: */\n\n  if ((ret)&&(filename != NULL)) {\n    fHandle = fopen(filename,\"w\");\n    if (fHandle == NULL) {\n      SMILE_IERR(1,\"failed to open file '%s' for writing!\",filename);\n      COMP_ERR(\"aborting\");\n\t    //return 0;\n    }\n  }\n\n  return ret;\n}\n\n\nint cExampleSink::myTick(long long t)\n{\n  SMILE_DBG(4,\"tick # %i, reading value vector:\",t);\n  cVector *vec= reader_->getFrameRel(lag);  //new cVector(nValues+1);\n  if (vec == NULL) return 0;\n  //else reader->nextFrame();\n\n  long vi = vec->tmeta->vIdx;\n  double tm = vec->tmeta->time;\n  \n  // now print the vector:\n  int i;\n  for (i=0; i<vec->N; i++) {\n    //SMILE_PRINT(\"  (a=%i vi=%i, tm=%fs) %s.%s = %f\",reader->getCurR(),vi,tm,reader->getLevelName(),vec->name(i),vec->dataF[i]);\n    printf(\"  %s.%s = %f\\n\",reader_->getLevelName(),vec->name(i),vec->dataF[i]);\n  }\n  \n  if (fHandle != NULL) {\n    for (i=0; i<vec->N; i++) {\n      fprintf(fHandle, \"%s = %f\\n\",vec->name(i),vec->dataF[i]);\n    }\n  }\n\n  // tick success\n  return 1;\n}\n\n\ncExampleSink::~cExampleSink()\n{\n  if (fHandle != NULL) {\n    fclose(fHandle);\n  }\n}\n\n"
  },
  {
    "path": "src/examples/exampleSource.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample dataSource\nwrites data to data memory...\n\n*/\n\n\n#include <examples/exampleSource.hpp>\n#define MODULE \"cExampleSource\"\n\nSMILECOMPONENT_STATICS(cExampleSource)\n\nSMILECOMPONENT_REGCOMP(cExampleSource)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CEXAMPLESOURCE;\n  sdescription = COMPONENT_DESCRIPTION_CEXAMPLESOURCE;\n\n  // we inherit cDataSource configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSource\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"nValues\",\"The number of random values to generate\",1);\n    ct->setField(\"randSeed\",\"The random seed\",1.0);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cExampleSource);\n}\n\nSMILECOMPONENT_CREATE(cExampleSource)\n\n//-----\n\ncExampleSource::cExampleSource(const char *_name) :\n  cDataSource(_name)\n{\n  // ...\n}\n\nvoid cExampleSource::fetchConfig()\n{\n  cDataSource::fetchConfig();\n  \n  nValues = getInt(\"nValues\");\n  SMILE_DBG(2,\"nValues = %i\",nValues);\n  randSeed = getDouble(\"randSeed\");\n  SMILE_DBG(2,\"nValues = %f\",randSeed);\n}\n\n/*\nint cExampleSource::myConfigureInstance()\n{\n  int ret = cDataSource::myConfigureInstance();\n  // ...\n\n  return ret;\n}\n*/\n\nint cExampleSource::configureWriter(sDmLevelConfig &c)\n{\n  // configure your writer by setting values in &c\n\n  return 1;\n}\n\n// NOTE: nEl is always 0 for dataSources....\nint cExampleSource::setupNewNames(long nEl)\n{\n  // configure dateMemory level, names, etc.\n  writer_->addField(\"randVal\",nValues);\n  writer_->addField(\"const\");\n  // ...\n\n  allocVec(nValues+1);\n  return 1;\n}\n\n/*\nint cExampleSource::myFinaliseInstance()\n{\n  return cDataSource::myFinaliseInstance();\n}\n*/\n\nint cExampleSource::myTick(long long t)\n{\n  SMILE_DBG(4,\"tick # %i, writing value vector\",t);\n\n  // todo: fill with random values...\n  vec_->dataF[0] = (FLOAT_DMEM)t+(FLOAT_DMEM)3.3;\n  writer_->setNextFrame(vec_);\n  \n  return 1;\n}\n\n\ncExampleSource::~cExampleSource()\n{\n  // ..\n}\n"
  },
  {
    "path": "src/examples/exampleVectorProcessor.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample of a vector processor\n\n*/\n\n\n\n#include <examples/exampleVectorProcessor.hpp>\n\n#define MODULE \"cExampleVectorProcessor\"\n\n\nSMILECOMPONENT_STATICS(cExampleVectorProcessor)\n\nSMILECOMPONENT_REGCOMP(cExampleVectorProcessor)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CEXAMPLEVECTORPROCESSOR;\n  sdescription = COMPONENT_DESCRIPTION_CEXAMPLEVECTORPROCESSOR;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n\n  // if the inherited config type was found, we register our configuration variables\n  SMILECOMPONENT_IFNOTREGAGAIN( {} // <- this is only to avoid compiler warnings...\n    // name append has a special role: it is defined in cDataProcessor, and can be overwritten here:\n\t// if you set description to NULL, the existing description will be used, thus the following call can\n\t// be used to update the default value:\n    //ct->setField(\"nameAppend\",NULL,\"processed\");\n\n    // this is an example for adding an integer option:\n\t//ct->setField(\"inverse\",\"1 = perform inverse FFT\",0);\n  )\n\n  // The configType gets automatically registered with the config manger by the SMILECOMPONENT_IFNOTREGAGAIN macro\n  \n  // we now create out sComponentInfo, including name, description, success status, etc. and return that\n  SMILECOMPONENT_MAKEINFO(cExampleVectorProcessor);\n}\n\nSMILECOMPONENT_CREATE(cExampleVectorProcessor)\n\n//-----\n\ncExampleVectorProcessor::cExampleVectorProcessor(const char *_name) :\n  cVectorProcessor(_name)\n{\n\n}\n\nvoid cExampleVectorProcessor::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n  \n/*\n  inverse = getInt(\"inverse\");\n  if (inverse) {\n    SMILE_DBG(2,\"transformFFT set for inverse FFT\",inverse);\n    inverse = 1;  // sign of exponent\n  } else {\n    inverse = -1; // sign of exponent\n  }\n  */\n}\n\n/*\nint cExampleVectorProcessor::myConfigureInstance()\n{\n  int ret=1;\n  ret *= cVectorProcessor::myConfigureInstance();\n  if (ret == 0) return 0;\n\n//...\n\n\n  return ret;\n}\n*/\n\n/*\nint cExampleVectorProcessor::configureWriter(const sDmLevelConfig *c)\n{\n\n  // you must return 1, in order to indicate configure success (0 indicated failure)\n  return 1;\n}\n\n*/\n\n// optional\n/*\nint cExampleVectorProcessor::setupNamesForField(int i, const char*name, long nEl)\n{\n  return cVectorProcessor::setupNamesForField(i,name,nEl);\n}\n*/\n\n// use this to allocate data like filter coefficient arrays, etc...\nvoid cExampleVectorProcessor::configureField(int idxi, long __N, long nOut)\n{\n//     const sDmLevelConfig *c = reader->getLevelConfig();\n// idxc = getFconf(idxi);\n}\n\n\n\n/*\nint cExampleVectorProcessor::myFinaliseInstance()\n{\n  int ret=1;\n  ret *= cVectorProcessor::myFinaliseInstance();\n//.....\n  return ret;\n}\n*/\n\n// a derived class should override this method, in order to implement the actual processing\nint cExampleVectorProcessor::processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  // do domething to data in *src, save result to *dst\n  // NOTE: *src and *dst may be the same...\n  \n  return 1;\n}\n\n// a derived class should override this method, in order to implement the actual processing\nint cExampleVectorProcessor::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  // do domething to data in *src, save result to *dst\n  // NOTE: *src and *dst may be the same...\n\n  return 1;\n}\n\ncExampleVectorProcessor::~cExampleVectorProcessor()\n{\n}\n\n"
  },
  {
    "path": "src/examples/exampleWindowProcessor.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: \n\nan example of a windowProcessor component\n\n*/\n\n\n\n#include <examples/exampleWindowProcessor.hpp>\n//#include <math.h>\n\n#define MODULE \"cExampleWindowProcessor\"\n\n\nSMILECOMPONENT_STATICS(cExampleWindowProcessor)\n\nSMILECOMPONENT_REGCOMP(cExampleWindowProcessor)\n{\n  if (_confman == NULL) return NULL;\n  int rA = 0;\n\n  sconfman = _confman;\n  scname = COMPONENT_NAME_CEXAMPLEWINDOWPROCESSOR;\n  sdescription = COMPONENT_DESCRIPTION_CEXAMPLEWINDOWPROCESSOR;\n\n  // we inherit cWindowProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cWindowProcessor\")\n\n  // if the inherited config type was found, we register our configuration variables\n  SMILECOMPONENT_IFNOTREGAGAIN( {} // <- this is only to avoid compiler warnings...\n    // name append has a special role: it is defined in cDataProcessor, and can be overwritten here:\n\t// if you set description to NULL, the existing description will be used, thus the following call can\n\t// be used to update the default value:\n    //ct->setField(\"nameAppend\",NULL,\"processed\");\n    // this is an example for adding an integer option:\n\t//ct->setField(\"inverse\",\"1 = perform inverse FFT\",0);\n  )\n\n  // The configType gets automatically registered with the config manger by the SMILECOMPONENT_IFNOTREGAGAIN macro\n  \n  // we now create out sComponentInfo, including name, description, success status, etc. and return that\n  SMILECOMPONENT_MAKEINFO(cExampleWindowProcessor);\n}\n\nSMILECOMPONENT_CREATE(cExampleWindowProcessor)\n\n//-----\n\ncExampleWindowProcessor::cExampleWindowProcessor(const char *_name) :\n  cWindowProcessor(_name,1,0)\n{\n}\n\n\nvoid cExampleWindowProcessor::fetchConfig()\n{\n  cWindowProcessor::fetchConfig();\n  \n  k = (FLOAT_DMEM)getDouble(\"k\");\n  SMILE_DBG(2,\"k = %f\",k);\n  if ((k<0.0)||(k>1.0)) {\n    SMILE_ERR(1,\"k must be in the range [0;1]! Setting k=0.0 !\");\n    k=0.0;\n  }\n}\n\n// order is the amount of memory (overlap) that will be present in _in\n// buf will have nT timesteps, however also order negative indicies (i.e. you may access a negative array index up to -order!)\nint cExampleWindowProcessor::processBuffer(cMatrix *_in, cMatrix *_out, int _pre, int _post )\n{\n  long n;\n\n  if (_in->type!=DMEM_FLOAT) COMP_ERR(\"dataType (%i) != DMEM_FLOAT not yet supported!\",_in->type);\n  FLOAT_DMEM *x=_in->dataF;\n  FLOAT_DMEM *y=_out->dataF;\n  for (n=0; n<_out->nT; n++) {\n    *(y++) = *(x) - k * *(x-1);\n    x++;\n  }\n  return 1;\n}\n\n\ncExampleWindowProcessor::~cExampleWindowProcessor()\n{\n}\n\n"
  },
  {
    "path": "src/examples/pitchBaseExample.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nBase class for pitch components, provides standard output values and configuration\n\n*/\n\n\n\n#include <examples/pitchBaseExample.hpp>\n\n#define MODULE \"cPitchBaseExample\"\n\n\nSMILECOMPONENT_STATICS(cPitchBaseExample)\n\nSMILECOMPONENT_REGCOMP(cPitchBaseExample)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CPITCHBASEEXAMPLE;\n  sdescription = COMPONENT_DESCRIPTION_CPITCHBASEEXAMPLE;\n\n  // we inherit cPitchBase configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cPitchBase\")\n\n  // if the inherited config type was found, we register our configuration variables\n  SMILECOMPONENT_IFNOTREGAGAIN( {} // <- this is only to avoid compiler warnings...\n    // name append has a special role: it is defined in cDataProcessor, and can be overwritten here:\n\t  // if you set description to NULL, the existing description will be used, thus the following call can\n  \t// be used to update the default value:\n    //ct->setField(\"nameAppend\",NULL,\"processed\");\n\n    // add custom config here...\n\n  )\n\n  // The configType gets automatically registered with the config manger by the SMILECOMPONENT_IFNOTREGAGAIN macro\n  \n  // we now create out sComponentInfo, including name, description, success status, etc. and return that\n  SMILECOMPONENT_MAKEINFO(cPitchBaseExample);\n}\n\nSMILECOMPONENT_CREATE(cPitchBaseExample)\n\n//-----\n\ncPitchBaseExample::cPitchBaseExample(const char *_name) :\n  cPitchBase(_name)\n{\n\n}\n\nvoid cPitchBaseExample::fetchConfig()\n{\n  cPitchBase::fetchConfig();\n\n  // fetch custom config here...\n\n}\n\n/* override, if you want to set custom names!\nint cPitchBaseExample::setupNewNames(long nEl)\n{\n  int n = cPitchBase::setupNewNames(nEl);\n  // set up custom names here:\n\n  return n;\n}\n*/\n\nint cPitchBaseExample::pitchDetect(FLOAT_DMEM * _inData, long _N, double _fsSec, double _baseT, FLOAT_DMEM *_f0cand, FLOAT_DMEM *_candVoice, FLOAT_DMEM *_candScore, long _nCandidates)\n{\n  // to be implemented by child class\n\n  // return actual number of candidates on success (0 on failure...)\n  return 0;\n}\n\nint cPitchBaseExample::addCustomOutputs(FLOAT_DMEM *dstCur, long NdstLeft)\n{\n  // to be implemented by child class\n\n  // return the number of custom outputs that were added..\n  return 0;\n}\n\n\ncPitchBaseExample::~cPitchBaseExample()\n{\n\n}\n\n"
  },
  {
    "path": "src/examples/simpleMessageSender.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\n\n*/\n\n\n#include <examples/simpleMessageSender.hpp>\n\n#define MODULE \"cSimpleMessageSender\"\n\n\nSMILECOMPONENT_STATICS(cSimpleMessageSender)\n\nSMILECOMPONENT_REGCOMP(cSimpleMessageSender)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CSIMPLEMESSAGESENDER;\n  sdescription = COMPONENT_DESCRIPTION_CSIMPLEMESSAGESENDER;\n\n  // we inherit cDataSink configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSink\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"messageRecp\", \"A comma separated list of message receipients (component names). If you leave this empty, no messages will be sent.\", (const char *)NULL);\n    ct->setField(\"messageName\", \"The name of the message that will be sent.\", \"demo_message\");\n    ct->setField(\"messageType\", \"The type of the message that will be sent.\", \"simpleMessage\");\n    ct->setField(\"dataElementName\", \"The name of the input level data element to send periodically or base the event decisions on. If left empty, the first element will be used.\", (const char *)NULL);\n    ct->setField(\"sendPeriodically\", \"1 = Enable sending of periodic messages for each sample of the input data element. 2 = ignore dataElementName and send up to the first 8 floats in the input data in the float data message array.\", 0);\n    ct->setField(\"enableDebugReceiver\", \"1/0 = enable/disable the debug print functionality for received(!) messages.\", 1);\n    ct->setField(\"enableDebugSender\", \"1/0 = enable/disable the debug print functionality for sent messages (before sending).\", 1);\n    ct->setField(\"showCustDataAsText\", \"1/0 = enable/disable printing of (non NULL) custData field as text string in debug message logs.\", 0);\n    ct->setField(\"showCustData2AsText\", \"1/0 = enable/disable printing of (non NULL) custData2 field as text string in debug message logs.\", 0);\n    ct->setField(\"threshold\", \"The threshold for triggering an event on the input data element.\", 0.0);\n    ct->setField(\"condition\", \"The condition to apply to the element with dataElementName to trigger event based messages. Choose one of the following: eq, gteq, gt, leeq, le for the conditions =, >=, >, <=, <. The event will be triggered always when the condition is met. Add the suffix _s to the condition name, to trigger the event only the first time the condition changes from false to true. The condition is applied as: <input_value> <cond> <threshold>.\", \"eq\");\n  )\n\n  SMILECOMPONENT_MAKEINFO(cSimpleMessageSender);\n}\n\nSMILECOMPONENT_CREATE(cSimpleMessageSender)\n\n//-----\n\ncSimpleMessageSender::cSimpleMessageSender(const char *_name) :\n  cDataSink(_name),\n  condition(COND_UNDEF), sendPeriodically(false),\n  enableDebugReceiver(false), enableDebugSender(false),\n  dataElementIndex(0), dataElementName(NULL),\n  messageRecp(NULL), condFlag(false),\n  showCustDataAsText(false), showCustData2AsText(false)\n{\n  // ...\n}\n\nvoid cSimpleMessageSender::fetchConfig()\n{\n  cDataSink::fetchConfig();\n  messageRecp = getStr(\"messageRecp\");\n  messageName = getStr(\"messageName\");\n  messageType = getStr(\"messageType\");\n  dataElementName = getStr(\"dataElementName\");\n  int tmp = getInt(\"sendPeriodically\");\n  if (tmp) {\n    sendPeriodically = true;\n  }\n  if (tmp == 2) {\n    dataElementIndex = -1;\n  }\n  if (getInt(\"enableDebugReceiver\")) {\n    enableDebugReceiver = true;\n  }\n  if (getInt(\"enableDebugSender\")) {\n    enableDebugSender = true;\n  }\n  if (getInt(\"showCustDataAsText\")) {\n    showCustDataAsText = true;\n  }\n  if (getInt(\"showCustData2AsText\")) {\n    showCustDataAsText = true;\n  }\n  threshold = (FLOAT_DMEM)getDouble(\"threshold\");\n\n  const char *cond = getStr(\"condition\");\n  if (!strncasecmp(cond, \"eq\", 2)) {\n    if (!strncasecmp(cond, \"eq_s\", 4)) {\n      condition = COND_EQ_S;\n    } else {\n      condition = COND_EQ;\n    }\n  } else if (!strncasecmp(cond, \"gteq\", 4)) {\n    if (!strncasecmp(cond, \"gteq_s\", 6)) {\n      condition = COND_GTEQ_S;\n    } else {\n      condition = COND_GTEQ;\n    }\n  } else if (!strncasecmp(cond, \"leeq\", 4)) {\n    if (!strncasecmp(cond, \"leeq_s\", 6)) {\n      condition = COND_LEEQ_S;\n    } else {\n      condition = COND_LEEQ;\n    }\n  } else if (!strncasecmp(cond, \"gt\", 2)) {\n    if (!strncasecmp(cond, \"gt_s\", 4)) {\n      condition = COND_GT_S;\n    } else {\n      condition = COND_GT;\n    }\n  } else if (!strncasecmp(cond, \"le\", 2)) {\n    if (!strncasecmp(cond, \"le_s\", 4)) {\n      condition = COND_LE_S;\n    } else {\n      condition = COND_LE;\n    }\n  }\n}\n\n\n/*\nint cSimpleMessageSender::myConfigureInstance()\n{\n  return  cDataSink::myConfigureInstance();\n  \n}\n*/\n\n\nint cSimpleMessageSender::myFinaliseInstance()\n{\n  // FIRST call cDataSink myFinaliseInstance, this will finalise our dataWriter...\n  int ret = cDataSink::myFinaliseInstance();\n\n  /* if that was SUCCESSFUL (i.e. ret == 1), then do some stuff like\n     loading models or opening output files: */\n\n  // We find the index of dataElementName here. \n  // The lookup of this index has computational overhead, so we do not\n  // want to do it for every tick in the myTick() function.\n  \n  if (dataElementName != NULL && dataElementIndex != -1) {\n    const FrameMetaInfo * fmeta = reader_->getFrameMetaInfo();\n    dataElementIndex = fmeta->findField(dataElementName);\n  }\n  return ret;\n}\n\nint cSimpleMessageSender::processComponentMessage(cComponentMessage *msg)\n{\n  if (enableDebugReceiver && msg != NULL) {\n    SMILE_IMSG(2, \"Got component message from '%s'\", msg->sender);\n    printMessage(msg);\n    return 1;\n  }\n  return 0;\n}\n\nvoid cSimpleMessageSender::printMessage(cComponentMessage *msg)\n{\n  if (msg->sender != NULL) { \n    SMILE_PRINT(\"  Sender: %s\", msg->sender);\n  }\n  SMILE_PRINT(\"  MsgType: %s\", msg->msgtype);\n  SMILE_PRINT(\"  MsgName: %s\", msg->msgname);\n  SMILE_PRINT(\"  MsgId: %i\", msg->msgid);\n  SMILE_PRINT(\"  ReaderTime: %f\", msg->readerTime);\n  SMILE_PRINT(\"  SmileTime: %f\", msg->smileTime);\n  if (msg->userTime1 != 0.0) {\n    SMILE_PRINT(\"  UserTime1: %f\", msg->userTime1);\n  }\n  if (msg->userTime2 != 0.0) {\n    SMILE_PRINT(\"  UserTime2: %f\", msg->userTime2);\n  }\n  if (msg->userflag1 != 0) {\n    SMILE_PRINT(\"  UserFlag1: %i\", msg->userflag1);\n  }\n  if (msg->userflag2 != 0) {\n    SMILE_PRINT(\"  UserFlag2: %i\", msg->userflag2);\n  }\n  if (msg->userflag3 != 0) {\n    SMILE_PRINT(\"  UserFlag3: %i\", msg->userflag3);\n  }\n  for (int i = 0; i < CMSG_nUserData; ++i) { \n    SMILE_PRINT(\"  Float[%i]: %f\", i, msg->floatData[i]);\n  }\n  for (int i = 0; i < CMSG_nUserData; ++i) { \n    SMILE_PRINT(\"  Int[%i]: %ld\", i, msg->intData[i]);\n  }\n  SMILE_PRINT(\"  MsgText: %s\", msg->msgtext);\n  SMILE_PRINT(\"  CustDataSize: %ld, CustData2Size: %ld\", msg->custDataSize, msg->custData2Size);\n  if (showCustDataAsText && msg->custData != NULL) {\n    SMILE_PRINT(\"  CustData : '%s'\", msg->custData);\n  }\n  if (showCustData2AsText && msg->custData2 != NULL) {\n    SMILE_PRINT(\"  CustData2: '%s'\", msg->custData2);\n  }\n  SMILE_PRINT(\"--- end of message ---\\n\");\n}\n\nvoid cSimpleMessageSender::sendMessage(cComponentMessage *msg)\n{\n  if (enableDebugSender) {\n    SMILE_IMSG(2, \"Printing message that will be sent to '%s':\", messageRecp);\n    printMessage(msg);\n  }\n  sendComponentMessage(messageRecp, msg);\n}\n\nvoid cSimpleMessageSender::sendPeriodicMessage(FLOAT_DMEM *v, int Nv, long vi, double tm)\n{\n  cComponentMessage msg;\n  memset(&msg, 0, sizeof(msg));\n  strncpy(msg.msgtype, messageType, CMSG_typenameLen);\n  strncpy(msg.msgname, messageName, CMSG_typenameLen);\n  if (v != NULL) {\n    for (int i = 0; i < Nv && i < CMSG_nUserData; i++) {\n      msg.floatData[i] = v[i];\n    }\n  }\n  msg.intData[0] = 0;\n  msg.readerTime = tm;\n  msg.userTime1 = (double)vi;\n  sendMessage(&msg);\n}\n\nvoid cSimpleMessageSender::sendEventMessage(FLOAT_DMEM *v, int Nv, const char * text, FLOAT_DMEM ref, long vi, double tm)\n{\n  cComponentMessage msg;\n  memset(&msg, 0, sizeof(msg));\n  strncpy(msg.msgtype, messageType, CMSG_typenameLen);\n  strncpy(msg.msgname, messageName, CMSG_typenameLen);\n  strncpy(msg.msgtext, text, CMSG_textLen);\n  if (v != NULL) {\n    for (int i = 0; i < Nv && i < CMSG_nUserData; i++) {\n      msg.floatData[i] = v[i];\n    }\n  }\n  msg.floatData[1] = ref;\n  msg.intData[0] = (int)condition;\n  msg.readerTime = tm;\n  msg.userTime1 = (double)vi;\n  sendMessage(&msg);\n}\n\nvoid cSimpleMessageSender::eventMessage(FLOAT_DMEM v, long vi, double tm)\n{\n  int Nv = 1;\n  if (condition == COND_GTEQ && v >= threshold) {\n    sendEventMessage(&v, Nv, \"greater equal\", threshold, vi, tm);\n  } else if (condition == COND_GT && v > threshold) {\n    sendEventMessage(&v, Nv, \"greater\", threshold, vi, tm);\n  } else if (condition == COND_EQ && v == threshold) {\n    sendEventMessage(&v, Nv, \"equal\", threshold, vi, tm);\n  } else if (condition == COND_LEEQ && v <= threshold) {\n    sendEventMessage(&v, Nv, \"lesser equal\", threshold, vi, tm);\n  } else if (condition == COND_LE && v < threshold) {\n    sendEventMessage(&v, Nv, \"lesser\", threshold, vi, tm);\n  } else if (condition == COND_GTEQ_S) {\n    if (v >= threshold) {\n      if (!condFlag) {\n        sendEventMessage(&v, Nv, \"begin greater equal\", threshold, vi, tm);\n        condFlag = true;\n      }\n    } else {\n      condFlag = false;\n    }\n  } else if (condition == COND_GT_S) {\n    if (v > threshold) {\n      if (!condFlag) {\n        sendEventMessage(&v, Nv, \"begin greater\", threshold, vi, tm);\n        condFlag = true;\n      }\n    } else {\n      condFlag = false;\n    }\n  } else if (condition == COND_EQ_S) {\n    if (v == threshold) {\n      if (!condFlag) {\n        sendEventMessage(&v, Nv, \"begin equal\", threshold, vi, tm);\n        condFlag = true;\n      }\n    } else {\n      condFlag = false;\n    }\n  } else if (condition == COND_LEEQ_S) {\n    if (v <= threshold) {\n      if (!condFlag) {\n        sendEventMessage(&v, Nv, \"begin lesser equal\", threshold, vi, tm);\n        condFlag = true;\n      }\n    } else {\n      condFlag = false;\n    }\n  } else if (condition == COND_LE_S) {\n    if (v < threshold) {\n      if (!condFlag) {\n        sendEventMessage(&v, Nv, \"begin lesser\", threshold, vi, tm);\n        condFlag = true;\n      }\n    } else {\n      condFlag = false;\n    }\n  } \n}\n\nint cSimpleMessageSender::myTick(long long t)\n{\n  cVector *vec = reader_->getNextFrame();\n  if (vec == NULL) return 0;  // no data available\n\n  long vi = vec->tmeta->vIdx;   // the frame's virtual index (frame number from start of system)\n  double tm = vec->tmeta->time; // the frame's time (data time from start of system)\n  \n  if (dataElementIndex < vec->N && dataElementIndex >= 0) {\n    if (sendPeriodically) {\n      sendPeriodicMessage(&(vec->dataF[dataElementIndex]), 1, vi, tm);\n    } else {\n      eventMessage(vec->dataF[dataElementIndex], vi, tm);\n    }\n  } else if (dataElementIndex == -1) {\n    if (sendPeriodically) {\n      sendPeriodicMessage(vec->dataF, vec->N, vi, tm);\n    }\n  }\n  return 1;\n}\n\n\ncSimpleMessageSender::~cSimpleMessageSender()\n{\n}\n\n"
  },
  {
    "path": "src/examples/smileComponentExample.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample for a direct descendant of cSmileComponent\n\nno dataMemory interface functionality is used (thus, the tick method may be ignored)\n\nthe component may only process messages, if that is desired\n\n*/\n\n\n#include <examples/smileComponentExample.hpp>\n\n#define MODULE \"cSmileComponentExample\"\n\nSMILECOMPONENT_STATICS(cSmileComponentExample)\n\nSMILECOMPONENT_REGCOMP(cSmileComponentExample)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CSMILECOMPONENTEXAMPLE;\n  sdescription = COMPONENT_DESCRIPTION_CSMILECOMPONENTEXAMPLE;\n\n  // configure your component's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n  //ct->setField(\"reader\", \"dataMemory interface configuration (i.e. what slot to read from)\", sconfman->getTypeObj(\"cDataReader\"), NO_ARRAY, DONT_FREE);\n  SMILECOMPONENT_IFNOTREGAGAIN( {} )\n\n  SMILECOMPONENT_MAKEINFO(cSmileComponentExample);\n}\n\nSMILECOMPONENT_CREATE(cSmileComponentExample)\n\n\n\n//-----\n\ncSmileComponentExample::cSmileComponentExample(const char *_name) :\n  cSmileComponent(_name)\n{\n  // initialisation code...\n\n}\n\nvoid cSmileComponentExample::fetchConfig() \n{\n\n}\n\nvoid cSmileComponentExample::mySetEnvironment()\n{\n\n}\n\nint cSmileComponentExample::myRegisterInstance()\n{\n\n  return 1;\n}\n\nint cSmileComponentExample::myConfigureInstance()\n{\n\n  return 1;\n}\n\nint cSmileComponentExample::myFinaliseInstance()\n{\n\n  return 1;\n}\n\nint cSmileComponentExample::processComponentMessage( cComponentMessage *_msg ) \n{ \n  if (isMessageType(_msg,\"myXYZmessage\")) {  // see doc/messages.txt for documentation of currently available messages\n   \n    // return 1;  // if message was processed\n  }\n  return 0; // if message was not processed\n}  \n\nint cSmileComponentExample::myTick(long long t) \n{\n\n  // return 1;  // tick did succeed!\n\n  return 0; // tick did not succeed, i.e. nothing was processed or there was nothing to process\n}\n\ncSmileComponentExample::~cSmileComponentExample()\n{\n  // cleanup code...\n\n}\n\n"
  },
  {
    "path": "src/functionals/functionalComponent.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\na single statistical functional or the like....\n\n*/\n\n\n#include <functionals/functionalComponent.hpp>\n\n#define MODULE \"cFunctionalComponent\"\n\n\nSMILECOMPONENT_STATICS(cFunctionalComponent)\n\nSMILECOMPONENT_REGCOMP(cFunctionalComponent)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CFUNCTIONALCOMPONENT;\n  sdescription = COMPONENT_DESCRIPTION_CFUNCTIONALCOMPONENT;\n\n  // configure your component's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n  //  ConfigType *ct = new ConfigType(scname); if (ct == NULL) OUT_OF_MEMORY;\n  SMILECOMPONENT_IFNOTREGAGAIN( {} )\n  //   ct->setField(\"\"...);\n \n  SMILECOMPONENT_MAKEINFO_NODMEM_ABSTRACT(cFunctionalComponent);\n}\n\nSMILECOMPONENT_CREATE_ABSTRACT(cFunctionalComponent)\n\n//-----\n\ncFunctionalComponent::cFunctionalComponent(const char *_name, int _nTotal, const char*_names[]) :\n  cSmileComponent(_name),\n  nTotal(_nTotal),\n  enab(NULL),\n  functNames(_names),\n  nEnab(0),\n  timeNorm(TIMENORM_SEGMENT),\n  timeNormIsSet(0),\n  T(0.0)\n{\n  if (nTotal>0)\n    enab = (int*)calloc(1,sizeof(int)*nTotal);\n}\n\nvoid cFunctionalComponent::parseTimeNormOption()\n{\n  if (isSet(\"norm\")) { timeNormIsSet = 1; }\n\n  const char*Norm = getStr(\"norm\");\n  if (Norm != NULL) {\n    if (!strncmp(Norm,\"tur\",3)) timeNorm=TIMENORM_SEGMENT;\n    else if (!strncmp(Norm,\"seg\",3)) timeNorm=TIMENORM_SEGMENT;\n    else if (!strncmp(Norm,\"sec\",3)) timeNorm=TIMENORM_SECOND;\n    else if (!strncmp(Norm,\"fra\",3)) timeNorm=TIMENORM_FRAME;\n  }\n\n  SMILE_IDBG(2,\"timeNorm = %i (set= %i)\\n\",timeNorm,timeNormIsSet);\n}\n\nvoid cFunctionalComponent::fetchConfig()\n{\n  int i; \n  for (i=0; i<nTotal; i++) {\n    if (enab[i]) nEnab++;\n  }\n}\n\n// is called by cFunctionals::setupNamesForElement after each new field has been added\nvoid cFunctionalComponent::setFieldMetaData(cDataWriter *writer,\n    const FrameMetaInfo *fmeta, int idxi, long nEl) {\n  double * buf = (double *)malloc(fmeta->field[idxi].infoSize);\n  memcpy(buf, fmeta->field[idxi].info, fmeta->field[idxi].infoSize);\n  writer->setFieldInfo(-1 /* last field added */,\n      fmeta->field[idxi].dataType, buf,\n      fmeta->field[idxi].infoSize);\n}\n\nconst char* cFunctionalComponent::getValueName(long i)\n{\n  int j=0; int n=-1;\n  if (functNames==NULL) return NULL;\n  for (j=0; j<nTotal; j++) {\n    if (enab[j]) n++;\n    if (i==n) return functNames[j];\n  }\n  return NULL;\n}\n\nlong cFunctionalComponent::process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM *out, long Nin, long Nout)\n{\n  SMILE_ERR(1,\"dataType FLOAT_DMEM not yet supported in component '%s' of type '%s'\",getTypeName(), getInstName());\n  return 0;\n}\n\nlong cFunctionalComponent::process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout)\n{\n  SMILE_ERR(1,\"dataType INT_DMEM not yet supported in component '%s' of type '%s'\",getTypeName(), getInstName());\n  return 0;\n}\n\ncFunctionalComponent::~cFunctionalComponent()\n{\n  if (enab!=NULL) free(enab);\n}\n\n"
  },
  {
    "path": "src/functionals/functionalCrossings.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctionals: zero-crossings, mean-crossings, arithmetic mean\n\n*/\n\n\n#include <functionals/functionalCrossings.hpp>\n\n#define MODULE \"cFunctionalCrossings\"\n\n\n#define FUNCT_ZCR     0\n#define FUNCT_MCR     1\n#define FUNCT_AMEAN   2\n\n#define N_FUNCTS  3\n\n#define NAMES     \"zcr\",\"mcr\",\"amean\"\n\nconst char *crossingsNames[] = {NAMES};  // change variable name to your clas...\n\nSMILECOMPONENT_STATICS(cFunctionalCrossings)\n\nSMILECOMPONENT_REGCOMP(cFunctionalCrossings)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CFUNCTIONALCROSSINGS;\n  sdescription = COMPONENT_DESCRIPTION_CFUNCTIONALCROSSINGS;\n\n  // configure your component's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"zcr\",\"1/0=enable/disable output of zero crossing rate\",1);\n    ct->setField(\"mcr\",\"1/0=enable/disable output of mean crossing rate (the rate at which the signal crosses its arithmetic mean value (same as zcr for mean normalised signals)\",1);\n    ct->setField(\"amean\",\"1/0=enable/disable output of arithmetic mean\",0);\n  )\n\n  SMILECOMPONENT_MAKEINFO_NODMEM(cFunctionalCrossings);\n}\n\nSMILECOMPONENT_CREATE(cFunctionalCrossings)\n\n//-----\n\ncFunctionalCrossings::cFunctionalCrossings(const char *_name) :\n  cFunctionalComponent(_name,N_FUNCTS,crossingsNames)\n{\n}\n\nvoid cFunctionalCrossings::fetchConfig()\n{\n  if (getInt(\"zcr\")) enab[FUNCT_ZCR] = 1;\n  if (getInt(\"mcr\")) enab[FUNCT_MCR] = 1;\n  if (getInt(\"amean\")) enab[FUNCT_AMEAN] = 1;\n\n  cFunctionalComponent::fetchConfig();\n}\n\nlong cFunctionalCrossings::process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM *out, long Nin, long Nout)\n{\n  int i;\n  if ((Nin>0)&&(out!=NULL)) {\n    double amean;\n    long zcr=0, mcr=0;\n\n    if (enab[FUNCT_MCR]||enab[FUNCT_AMEAN]) {\n      amean = (double)*in;\n      for (i=1; i<Nin; i++) {\n        amean += in[i];\n      }\n      amean /= (double)Nin;\n    }\n    \n    for (i=1; i<Nin-1; i++) {\n      in++;\n      if (  ( (*(in-1) * *(in+1) <= 0.0) && (*(in)==0.0) ) || (*(in-1) * *(in) < 0.0)  ) zcr++;\n      if (enab[FUNCT_MCR])\n        if (  ( ((*(in-1)-amean) * (*(in+1)-amean) <= 0.0) && ((*(in)-amean)==0.0) ) || ((*(in-1)-amean) * (*(in)-amean) < 0.0)  ) mcr++;\n    }\n    \n    int n=0;\n    if (enab[FUNCT_ZCR]) out[n++]=(FLOAT_DMEM) ( (double)zcr / (double)Nin );\n    if (enab[FUNCT_MCR]) out[n++]=(FLOAT_DMEM) ( (double)mcr / (double)Nin );\n    if (enab[FUNCT_AMEAN]) out[n++]=(FLOAT_DMEM)amean;\n    return n;\n  }\n  return 0;\n}\n\n/*\nlong cFunctionalCrossings::process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout)\n{\n\n  return 0;\n}\n*/\n\ncFunctionalCrossings::~cFunctionalCrossings()\n{\n}\n\n"
  },
  {
    "path": "src/functionals/functionalDCT.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctional: dct of input data\n\n*/\n\n\n#include <functionals/functionalDCT.hpp>\n\n#define MODULE \"cFunctionalDCT\"\n\n#define N_FUNCTS  1\n\n#define NAMES     \"dct\"\n\nconst char *dctNames[] = {NAMES};  \n\nSMILECOMPONENT_STATICS(cFunctionalDCT)\n\nSMILECOMPONENT_REGCOMP(cFunctionalDCT)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CFUNCTIONALDCT;\n  sdescription = COMPONENT_DESCRIPTION_CFUNCTIONALDCT;\n\n  // configure your component's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"firstCoeff\",\"The first DCT coefficient to compute (coefficient 0 corresponds to the DC component)\",1);\n    ct->setField(\"lastCoeff\",\"The last DCT coefficient to compute\",6);\n\t  ct->setField(\"nCoeffs\",\"An alternative option to lastCoeff (this option overwrites lastCoeff, if it is set): the number DCT coefficient to compute (lastCoeff = firstCoeff+nCoeffs-1).\",6);\n  )\n\n  SMILECOMPONENT_MAKEINFO_NODMEM(cFunctionalDCT);\n}\n\nSMILECOMPONENT_CREATE(cFunctionalDCT)\n\n//-----\n\ncFunctionalDCT::cFunctionalDCT(const char *_name) :\n  cFunctionalComponent(_name,N_FUNCTS,dctNames),\n  firstCoeff(1),\n  lastCoeff(6),\n  nCo(0),\n  costable(NULL),\n  factor(0.0),\n  tmpstr(NULL),\n  costableNin(0)\n{\n}\n\nvoid cFunctionalDCT::fetchConfig()\n{\n  firstCoeff = getInt(\"firstCoeff\");\n  SMILE_IDBG(2,\"firstCoeff = %i\",firstCoeff);\n  if (firstCoeff < 0) {\n    SMILE_IWRN(2,\"firstCoeff < 0 in config. forcing firstCoeff=0 !\");\n\t  firstCoeff = 0;\n  }\n  \n  if (isSet(\"nCoeffs\")) {\n    lastCoeff = firstCoeff + getInt(\"nCoeffs\") - 1;\n\t  SMILE_IDBG(2,\"using nCoeffs = %i to overwrite lastCoeff setting\",getInt(\"nCoeffs\"));\n  } else {\n    lastCoeff = getInt(\"lastCoeff\");\n  }\n  SMILE_IDBG(2,\"lastCoeff = %i\",lastCoeff);\n  enab[0] = 1;\n\n  cFunctionalComponent::fetchConfig();\n  nEnab += lastCoeff - firstCoeff;\n}\n\nvoid cFunctionalDCT::initCostable(long Nin, long Nout)\n{\n  if ((Nin>0)&&(Nout>0)) {\n    if (costable != NULL) free(costable);\n    costable = (FLOAT_DMEM * )malloc(sizeof(FLOAT_DMEM)*Nin*Nout);\n    costableNin = Nin;\n    if (costable==NULL) OUT_OF_MEMORY;\n    int i,m;\n    nCo = lastCoeff - firstCoeff + 1;\n    N=Nin;\n    /* TODO: norm frequency of DCT components to be independent of input length!! Possible ?? */\n    for (i=firstCoeff; i<=lastCoeff; i++) {\n      for (m=0; m<Nin; m++) {\n        costable[m + (i-firstCoeff)*Nin] = (FLOAT_DMEM)cos(M_PI*(double)i/(double)(N) * ((FLOAT_DMEM)(m) + 0.5) );\n      }\n    }\n    factor = (FLOAT_DMEM)sqrt((double)2.0/(double)(Nin));\n  }\n}\n\nconst char* cFunctionalDCT::getValueName(long i)\n{\n  const char *n = cFunctionalComponent::getValueName(0);\n  // append coefficient number\n  if (tmpstr != NULL) free(tmpstr);\n  tmpstr = myvprint(\"%s%i\",n,i+firstCoeff);\n  return tmpstr;\n}\n\nlong cFunctionalDCT::process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM *out, long Nin, long Nout)\n{\n  // (DONE) FIXME: nonZeroFuncts, breaks DCT, because multiple costables will be needed in this case...\n  //        only solution, don't use costables in this case, the cos functions must be computed on the fly\n  //        therefore we have to find out from the parent component if the nonZeroFuncts option is set.\n  // DONE! FIXME 2: for on-line operation the size of the costable might also change... so we have to recompute the costable everytime the Nin is different than the size of the costable... its quite easy, this will also solve fixme 1 ;)\n\n  int i,m;\n  if ((Nin>0)&&(out!=NULL)) {\n\t\n    if (costable == NULL || costableNin != Nin) {\n      initCostable(Nin,Nout);\n\t    if (costable == NULL) SMILE_IERR(1,\"error initialising costable, probably Nin or Nout == 0 in cFunctionalDCT::process\");\n\t  }\n\n\tfor (i=0; i < nCo; i++) {\n\t  out[i] = 0.0;\n    for (m=0; m<Nin; m++) {\n      out[i] +=  in[m] * costable[m+i*Nin];\n    }\n    out[i] *= factor;\n    if (!finite(out[i])) {\n      SMILE_IERR(1,\"non-finite value dct[%i] as output, please help to solve this bug... . The value will be set to 0.\",i);\n      out[i] = 0.0;\n    }\n  }\n\n    return nCo;\n  }\n  return 0;\n}\n\n/*\nlong cFunctionalDCT::process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout)\n{\n\n  return 0;\n}\n*/\n\ncFunctionalDCT::~cFunctionalDCT()\n{\n  if (tmpstr != NULL) free(tmpstr);\n}\n\n"
  },
  {
    "path": "src/functionals/functionalExtremes.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctionals: extreme values and ranges\n\n*/\n\n\n#include <functionals/functionalExtremes.hpp>\n\n#define MODULE \"cFunctionalExtremes\"\n\n#define NORM_TURN     0\n#define NORM_SECOND   1\n#define NORM_FRAME    2\n\n#define FUNCT_MAX     0\n#define FUNCT_MIN     1\n#define FUNCT_RANGE   2\n#define FUNCT_MAXPOS   3\n#define FUNCT_MINPOS   4\n#define FUNCT_AMEAN   5\n#define FUNCT_MAXAMEANDIST   6\n#define FUNCT_MINAMEANDIST   7\n\n#define N_FUNCTS  8\n\n#define NAMES     \"max\",\"min\",\"range\",\"maxPos\",\"minPos\",\"amean\",\"maxameandist\",\"minameandist\"\n\nconst char *extremesNames[] = {NAMES};  // change variable name to your clas...\n\nSMILECOMPONENT_STATICS(cFunctionalExtremes)\n\nSMILECOMPONENT_REGCOMP(cFunctionalExtremes)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  \n  scname = COMPONENT_NAME_CFUNCTIONALEXTREMES;\n  sdescription = COMPONENT_DESCRIPTION_CFUNCTIONALEXTREMES;\n\n  // configure your component's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"max\",\"1/0=enable/disable output of maximum value\",1);\n    ct->setField(\"min\",\"1/0=enable/disable output of minimum value\",1);\n    ct->setField(\"range\",\"1/0=enable/disable output of range (max-min)\",1);\n    ct->setField(\"maxpos\",\"1/0=enable/disable output of position of maximum value (relative to the input segment length, in seconds, or in frames, see the 'norm' option or the 'masterTimeNorm' option of the cFunctionals parent component)\",1);\n    ct->setField(\"minpos\",\"1/0=enable/disable output of position of minimum value (relative to the input segment length, in seconds, or in frames, see the 'norm' option or the 'masterTimeNorm' option of the cFunctionals parent component)\",1);\n    ct->setField(\"amean\",\"1/0=enable/disable output of arithmetic mean\",0);\n    ct->setField(\"maxameandist\",\"1/0=enable/disable output of (max-arithmetic_mean)\",1);\n    ct->setField(\"minameandist\",\"1/0=enable/disable output of (arithmetic_mean-min)\",1);\n    // Please note: the default is \"frame\" here, due to compatibility with older versions. In new setting you should, however, always use \"frame\"\n    ct->setField(\"norm\",\"This option specifies how this component should normalise times (if it generates output values related to durations): \\n   'segment' (or: 'turn') : normalise to the range 0..1, the result is the relative length wrt. to the segment length )\\n   'second'  (absolute time in seconds) \\n   'frame' (absolute time in number of frames of input level)\",\"frames\");\n  )\n\n  SMILECOMPONENT_MAKEINFO_NODMEM(cFunctionalExtremes);\n}\n\nSMILECOMPONENT_CREATE(cFunctionalExtremes)\n\n//-----\n\ncFunctionalExtremes::cFunctionalExtremes(const char *_name) :\n  cFunctionalComponent(_name,N_FUNCTS,extremesNames)\n{\n}\n\nvoid cFunctionalExtremes::fetchConfig()\n{\n  parseTimeNormOption();\n\n  if (getInt(\"max\")) enab[FUNCT_MAX] = 1;\n  if (getInt(\"min\")) enab[FUNCT_MIN] = 1;\n  if (getInt(\"range\")) enab[FUNCT_RANGE] = 1;\n  if (getInt(\"maxpos\")) enab[FUNCT_MAXPOS] = 1;\n  if (getInt(\"minpos\")) enab[FUNCT_MINPOS] = 1;\n  if (getInt(\"amean\")) enab[FUNCT_AMEAN] = 1;\n  if (getInt(\"maxameandist\")) enab[FUNCT_MAXAMEANDIST] = 1;\n  if (getInt(\"minameandist\")) enab[FUNCT_MINAMEANDIST] = 1;\n\n  cFunctionalComponent::fetchConfig();\n}\n\nlong cFunctionalExtremes::process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM min, FLOAT_DMEM max, FLOAT_DMEM mean, FLOAT_DMEM *out, long Nin, long Nout)\n{\n  int i;\n  if ((Nin>0)&&(out!=NULL)) {\n    long minpos=-1, maxpos=-1;\n    \n    for (i=0; i<Nin; i++) {\n      if ((*in == max)&&(maxpos==-1)) { maxpos=i; }\n      if ((*in == min)&&(minpos==-1)) { minpos=i; }\n      in++;\n    }\n\n    FLOAT_DMEM maxposD = (FLOAT_DMEM)maxpos;\n    FLOAT_DMEM minposD = (FLOAT_DMEM)minpos;\n\n    // normalise max/min pos ...\n    if (timeNorm==TIMENORM_SEGMENT) {\n        maxposD /= (FLOAT_DMEM)(Nin);\n        minposD /= (FLOAT_DMEM)(Nin);\n    } else if (timeNorm==NORM_SECOND) {\n      FLOAT_DMEM _T = (FLOAT_DMEM)getInputPeriod();\n                           \n      if (_T != 0.0) {\n        maxposD *= _T;\n        minposD *= _T;\n      }\n    } // default is TIMENORM_FRAME...\n\n    int n=0;\n    if (enab[FUNCT_MAX]) out[n++]=max;\n    if (enab[FUNCT_MIN]) out[n++]=min;\n    if (enab[FUNCT_RANGE]) out[n++]=max-min;\n    if (enab[FUNCT_MAXPOS]) out[n++]=maxposD;\n    if (enab[FUNCT_MINPOS]) out[n++]=minposD;\n    if (enab[FUNCT_AMEAN]) out[n++]=mean;\n    if (enab[FUNCT_MAXAMEANDIST]) out[n++]=max-mean;\n    if (enab[FUNCT_MINAMEANDIST]) out[n++]=mean-min;\n    return n;\n  }\n  return 0;\n}\n\n/*\nlong cFunctionalExtremes::process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout)\n{\n\n  return 0;\n}\n*/\n\ncFunctionalExtremes::~cFunctionalExtremes()\n{\n}\n\n"
  },
  {
    "path": "src/functionals/functionalLpc.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctional: lpc of input data\n\n*/\n\n\n#include <functionals/functionalLpc.hpp>\n\n#define MODULE \"cFunctionalLpc\"\n\n#define N_FUNCTS  2\n\n#define NAMES     \"lpgain\",\"lpc\"\n#define IDX_VAR_FUNCTS 1  // start of lpc array of variable length\n\nconst char *lpcNames[] = {NAMES};  \n\nSMILECOMPONENT_STATICS(cFunctionalLpc)\n\nSMILECOMPONENT_REGCOMP(cFunctionalLpc)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CFUNCTIONALLPC;\n  sdescription = COMPONENT_DESCRIPTION_CFUNCTIONALLPC;\n\n  // configure your component's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"lpGain\",\"Output of LP gain (1=yes / 0=no).\",0);\n    ct->setField(\"lpc\",\"Output of LP coefficients (1=yes / 0=no).\",1);\n    ct->setField(\"firstCoeff\",\"The first LP coefficient to compute. The first coefficient is coeff 0 (default)\",0);\n    ct->setField(\"order\",\"The order of the linear prediction (i.e. the max number of coefficients, starting at coefficient number 0).\",5);\n  )\n\n  SMILECOMPONENT_MAKEINFO_NODMEM(cFunctionalLpc);\n}\n\nSMILECOMPONENT_CREATE(cFunctionalLpc)\n\n//-----\n\ncFunctionalLpc::cFunctionalLpc(const char *_name) :\n  cFunctionalComponent(_name,N_FUNCTS,lpcNames),\n  firstCoeff(1),\n  order(0), lpc(NULL), acf(NULL), tmpstr(NULL)\n{\n}\n\nvoid cFunctionalLpc::fetchConfig()\n{\n  firstCoeff = getInt(\"firstCoeff\");\n  SMILE_IDBG(2,\"firstCoeff = %i\",firstCoeff);\n  if (firstCoeff < 0) {\n    SMILE_IWRN(2,\"firstCoeff < 0 in config. forcing firstCoeff=0 !\");\n\t  firstCoeff = 0;\n  }\n  order = getInt(\"order\");\n  if (order <= firstCoeff) {\n    SMILE_IERR(2,\"error in config: order (%i) cannot be smaller or equal than firstCoeff (%i) (firstCoeff=0 is the first coefficient)!\",order,firstCoeff);\n    order = firstCoeff;\n  }\n\n  if (getInt(\"lpGain\")) {  enab[0] = 1;  }\n  if (getInt(\"lpc\")) {  enab[1] = 1;  }\n\n  cFunctionalComponent::fetchConfig();\n  nEnab += order - firstCoeff - 1;\n\n  if (acf == NULL) acf = (FLOAT_DMEM *)malloc(sizeof(FLOAT_DMEM)*(order+1));\n  if (lpc == NULL) lpc = (FLOAT_DMEM *)malloc(sizeof(FLOAT_DMEM)*(order+1));\n}\n\nconst char* cFunctionalLpc::getValueName(long i)\n{\n  if (i >= IDX_VAR_FUNCTS) {\n    const char *n = cFunctionalComponent::getValueName(1);\n    // append coefficient number\n    if (tmpstr != NULL) free(tmpstr);\n    tmpstr = myvprint(\"%s%i\",n,(i-1)+firstCoeff);\n    return tmpstr;\n  } else {\n    return cFunctionalComponent::getValueName(i);\n  }\n}\n\nlong cFunctionalLpc::process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM *out, long Nin, long Nout)\n{\n  long i;\n  if ((Nin>0)&&(out!=NULL)) {\n    //Durbin on input values...\n\n    FLOAT_DMEM gain = 0.0;\n    FLOAT_DMEM *refl = NULL; /* TODO: add support for reflection coefficients */\n\n    smileDsp_autoCorr(in, Nin, acf, order+1);\n    smileDsp_calcLpcAcf(acf, lpc, order, &gain, refl);\n\n    if (enab[0]) *(out++) = gain/(FLOAT_DMEM)Nin;\n\n    if (enab[1]) {\n      for (i=firstCoeff; i<order; i++) {\n        if (i-firstCoeff >= Nout) break;\n        *(out++) = lpc[i];\n      }\n    }\n\n    return enab[1]*(order-firstCoeff)+enab[0];\n  }\n  return 0;\n}\n\n/*\nlong cFunctionalLpc::process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout)\n{\n\n  return 0;\n}\n*/\n\ncFunctionalLpc::~cFunctionalLpc()\n{\n  if (tmpstr != NULL) free(tmpstr);\n  if (acf != NULL) free(acf);\n  if (lpc != NULL) free(lpc);\n}\n\n"
  },
  {
    "path": "src/functionals/functionalMeans.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctionals:\nvarious means, arithmetic, geometric, quadratic, etc.\nalso number of non-zero values, etc.\n\n*/\n\n\n#include <functionals/functionalMeans.hpp>\n#include <math.h>\n\n#define MODULE \"cFunctionalMeans\"\n\n\n#define FUNCT_AMEAN     0\n#define FUNCT_ABSMEAN   1\n#define FUNCT_QMEAN     2\n#define FUNCT_NZAMEAN   3\n#define FUNCT_NZABSMEAN 4\n#define FUNCT_NZQMEAN   5\n#define FUNCT_NZGMEAN   6\n#define FUNCT_NNZ       7  // number of Non-Zero elements\n#define FUNCT_FLATNESS  8  // flatness : geometric mean / arithmetic mean\n#define FUNCT_POSAMEAN  9  // arithmetic mean from positive values only\n#define FUNCT_NEGAMEAN  10 // arithmetic mean from negative values only\n#define FUNCT_POSQMEAN  11\n#define FUNCT_POSRQMEAN 12\n#define FUNCT_NEGQMEAN  13\n#define FUNCT_NEGRQMEAN 14\n#define FUNCT_RQMEAN    15  // *r*oot *q*uadratic mean\n#define FUNCT_NZRQMEAN  16\n\n#define N_FUNCTS  17\n\n#define NAMES     \"amean\",\"absmean\",\"qmean\",\"nzamean\",\"nzabsmean\",\"nzqmean\",\"nzgmean\",\"nnz\",\"flatness\",\"posamean\",\"negamean\",\"posqmean\",\"posrqmean\", \"negqmean\", \"negrqmean\", \"rqmean\", \"nzrqmean\"\n\nconst char *meansNames[] = {NAMES};  // change variable name to your class...\n\nSMILECOMPONENT_STATICS(cFunctionalMeans)\n\nSMILECOMPONENT_REGCOMP(cFunctionalMeans)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CFUNCTIONALMEANS;\n  sdescription = COMPONENT_DESCRIPTION_CFUNCTIONALMEANS;\n\n  // configure your component's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"amean\",\"1/0=enable/disable output of arithmetic mean\",1);\n    ct->setField(\"absmean\",\"1/0=enable/disable output of arithmetic mean of absolute values\",1);\n    ct->setField(\"qmean\",\"1/0=enable/disable output of quadratic mean\",1);\n    ct->setField(\"nzamean\",\"1/0=enable/disable output of arithmetic mean (of non-zero values only)\",1);\n    ct->setField(\"nzabsmean\",\"1/0=enable/disable output of arithmetic mean of absolute values (of non-zero values only)\",1);\n    ct->setField(\"nzqmean\",\"1/0=enable/disable output of quadratic mean (of non-zero values only)\",1);\n    ct->setField(\"nzgmean\",\"1/0=enable/disable output of geometric mean (of absolute values of non-zero values only)\",1);\n    ct->setField(\"nnz\",\"1/0=enable/disable output of number of non-zero values (relative to the input segment length, in seconds, or in frames, see the 'norm' option or the 'masterTimeNorm' option of the cFunctionals parent component)\",1); // default norm for compatibility : frames\n    ct->setField(\"flatness\",\"1/0=enable/disable output of contour flatness (ratio of geometric mean and absolute value arithmetic mean(absmean)))\",0);\n    ct->setField(\"posamean\",\"1/0=enable/disable output of arithmetic mean of positive values only (usually you would apply this to a differential signal to measure how much the original signal is rising)\",0);\n    ct->setField(\"negamean\",\"1/0=enable/disable output of arithmetic mean of negative values only\",0);\n    ct->setField(\"posqmean\",\"1/0=enable/disable output of quadratic mean of positive values only\",0);\n    ct->setField(\"posrqmean\",\"1/0=enable/disable output of root of quadratic mean of positive values only\",0);\n    ct->setField(\"negqmean\",\"1/0=enable/disable output of quadratic mean of negative values only\",0);\n    ct->setField(\"negrqmean\",\"1/0=enable/disable output of root of quadratic mean of negative values only\",0);\n    ct->setField(\"rqmean\",\"1/0=enable/disable output of square root of quadratic mean\",0);\n    ct->setField(\"nzrqmean\",\"1/0=enable/disable output of square root of quadratic mean of non zero values\",0);\n    ct->setField(\"norm\",\"This option specifies how this component should normalise times (if it generates output values related to durations): \\n   'segment' (or: 'turn') : normalise to the range 0..1, the result is the relative length wrt. to the segment length )\\n   'second'  (absolute time in seconds) \\n   'frame' (absolute time in number of frames of input level)\",\"frames\");\n  )\n\n  SMILECOMPONENT_MAKEINFO_NODMEM(cFunctionalMeans);\n}\n\nSMILECOMPONENT_CREATE(cFunctionalMeans)\n\n//-----\n\ncFunctionalMeans::cFunctionalMeans(const char *_name) :\n  cFunctionalComponent(_name,N_FUNCTS,meansNames)\n{\n}\n\nvoid cFunctionalMeans::fetchConfig()\n{\n  parseTimeNormOption();\n\n  if (getInt(\"amean\")) enab[FUNCT_AMEAN] = 1;\n  if (getInt(\"absmean\")) enab[FUNCT_ABSMEAN] = 1;\n  if (getInt(\"qmean\")) enab[FUNCT_QMEAN] = 1;\n  if (getInt(\"nzamean\")) enab[FUNCT_NZAMEAN] = 1;\n  if (getInt(\"nzabsmean\")) enab[FUNCT_NZABSMEAN] = 1;\n  if (getInt(\"nzqmean\")) enab[FUNCT_NZQMEAN] = 1;\n  if (getInt(\"nzgmean\")) enab[FUNCT_NZGMEAN] = 1;\n  if (getInt(\"nnz\")) enab[FUNCT_NNZ] = 1;\n  if (getInt(\"flatness\")) enab[FUNCT_FLATNESS] = 1;\n  if (getInt(\"posamean\")) enab[FUNCT_POSAMEAN] = 1;\n  if (getInt(\"negamean\")) enab[FUNCT_NEGAMEAN] = 1;\n  if (getInt(\"posqmean\")) enab[FUNCT_POSQMEAN] = 1;\n  if (getInt(\"posrqmean\")) enab[FUNCT_POSRQMEAN] = 1;\n  if (getInt(\"negqmean\")) enab[FUNCT_NEGQMEAN] = 1;\n  if (getInt(\"negrqmean\")) enab[FUNCT_NEGRQMEAN] = 1;\n  if (getInt(\"rqmean\")) enab[FUNCT_RQMEAN] = 1;\n  if (getInt(\"nzrqmean\")) enab[FUNCT_NZRQMEAN] = 1;\n\n  cFunctionalComponent::fetchConfig();\n}\n\nlong cFunctionalMeans::process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM min, FLOAT_DMEM max, FLOAT_DMEM mean, FLOAT_DMEM *out, long Nin, long Nout)\n{\n  int i;\n  if ((Nin>0)&&(out!=NULL)) {\n\n    double tmp=(double)*in;\n    double fa = fabs(tmp);\n\n    double absmean = fa;\n    double qmean = tmp*tmp;\n    long nnz;\n\n    double nzamean;\n    double nzabsmean;\n    double nzqmean;\n    double nzgmean;\n    double posamean=0.0, negamean=0.0;\n    double posqmean=0.0, negqmean=0.0;\n    long nPos=0,nNeg=0;\n\n    if (tmp!=0.0) {\n      nzamean = tmp;\n      nzabsmean = fa;\n      nzqmean = tmp*tmp;\n      nzgmean = log(fa);\n      nnz=1;\n      if (tmp > 0) {\n        posamean += tmp;\n        posqmean += tmp*tmp;\n        nPos++;\n      } else {\n        negamean += tmp;\n        negqmean += tmp*tmp;\n        nNeg++;\n      }\n    } else {\n      nzamean = 0.0;\n      nzabsmean = 0.0;\n      nzqmean = 0.0;\n      nzgmean = 0.0;\n      nnz=0;\n    }\n    for (i=1; i<Nin; i++) {\n      in++;\n      tmp=(double)*in;\n      fa = fabs(tmp);\n      //      amean += tmp;\n      absmean += fa;\n      if (tmp > 0) {\n        posamean += tmp;\n        nPos++;\n      }\n      if (tmp < 0) {\n        negamean += tmp;\n        nNeg++;\n      }\n      double _tmp = tmp;\n      if (tmp!=0.0) {\n        nzamean += tmp;\n        nzabsmean += fa;\n        nzgmean += log(fa);\n        tmp *= tmp;\n        nzqmean += tmp;\n        nnz++;\n        if (_tmp > 0) posqmean += tmp;\n        if (_tmp < 0) negqmean += tmp;\n        qmean += tmp;\n      }\n    }\n    tmp = (double)Nin;\n    //    amean = amean / tmp;\n    absmean = absmean / tmp;\n    qmean = qmean / tmp;\n\n    if (nnz>0) {\n      tmp = (double)nnz;\n      nzamean = nzamean / tmp;\n      nzabsmean = nzabsmean / tmp;\n      nzqmean = nzqmean / tmp;\n      nzgmean /= tmp; //pow( 1.0/nzgmean, 1.0/tmp );\n      nzgmean = exp(nzgmean);\n    }\n    if (nPos > 0) {\n      posamean /= (double)nPos;\n      posqmean /= (double)nPos;\n    }\n    if (nNeg > 0) {\n      negamean /= (double)nNeg;\n      negqmean /= (double)nNeg;\n    }\n\n    int n=0;\n    if (enab[FUNCT_AMEAN]) out[n++]=(FLOAT_DMEM)mean;\n    if (enab[FUNCT_ABSMEAN]) out[n++]=(FLOAT_DMEM)absmean;\n    if (enab[FUNCT_QMEAN]) out[n++]=(FLOAT_DMEM)qmean;\n    if (enab[FUNCT_NZAMEAN]) out[n++]=(FLOAT_DMEM)nzamean;\n    if (enab[FUNCT_NZABSMEAN]) out[n++]=(FLOAT_DMEM)nzabsmean;\n    if (enab[FUNCT_NZQMEAN]) out[n++]=(FLOAT_DMEM)nzqmean;\n    if (enab[FUNCT_NZGMEAN]) out[n++]=(FLOAT_DMEM)nzgmean;\n    if (timeNorm==TIMENORM_FRAMES) {\n      if (enab[FUNCT_NNZ]) out[n++]=(FLOAT_DMEM)nnz;\n    } else if (timeNorm==TIMENORM_SEGMENT) {\n      if (enab[FUNCT_NNZ]) out[n++]=(FLOAT_DMEM)nnz/(FLOAT_DMEM)Nin;\n    } else if (timeNorm==TIMENORM_SECONDS) {\n      if (enab[FUNCT_NNZ]) out[n++]=(FLOAT_DMEM)nnz/(FLOAT_DMEM)getInputPeriod();\n    }\n    if (enab[FUNCT_FLATNESS]) {\n      if (absmean != 0.0)\n        out[n++] = (FLOAT_DMEM)(nzgmean/absmean);\n      else out[n++] = 1.0;\n    }\n    \n    if (enab[FUNCT_POSAMEAN]) {\n      out[n++] = (FLOAT_DMEM)posamean;\n    }\n    if (enab[FUNCT_NEGAMEAN]) {\n      out[n++] = (FLOAT_DMEM)negamean;\n    }\n    if (enab[FUNCT_POSQMEAN]) {\n      out[n++] = (FLOAT_DMEM)posqmean;\n    }\n    if (enab[FUNCT_POSRQMEAN]) {\n      out[n++] = (FLOAT_DMEM)sqrt(posqmean);\n    }\n    if (enab[FUNCT_NEGQMEAN]) {\n      out[n++] = (FLOAT_DMEM)negqmean;\n    }\n    if (enab[FUNCT_NEGRQMEAN]) {\n      out[n++] = (FLOAT_DMEM)sqrt(negqmean);\n    }\n\n    if (enab[FUNCT_RQMEAN]) {\n      out[n++] = (FLOAT_DMEM)sqrt(qmean);\n    }\n    if (enab[FUNCT_NZRQMEAN]) {\n      out[n++] = (FLOAT_DMEM)sqrt(nzqmean);\n    }\n\n\n    return n;\n  }\n  return 0;\n}\n\n/*\nlong cFunctionalMeans::process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout)\n{\n\n  return 0;\n}\n*/\n\ncFunctionalMeans::~cFunctionalMeans()\n{\n}\n\n"
  },
  {
    "path": "src/functionals/functionalModulation.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctional: Modulation spectra, cepstra, etc.\n\n1. Single modulation frequencies... correlation based? fft on full input based?\n2. Overlaping windows -> fft -> average modulation spectrum\n3. Method 2 allows for average cepstrum  (Method 1 only for small windows and full input fft -> however scaling problem)\n4. Method 2 allows for higher level functionals...\n\n\nProblems: varying window size... esp. minimum required window size..  zero padding?\n\n*/\n\n\n#include <functionals/functionalModulation.hpp>\n#include <smileutil/smileUtil.h>\n#include <smileutil/smileUtilSpline.h>\n\n#define MODULE \"cFunctionalModulation\"\n\n#define N_FUNCTS  1\n#define NAMES     \"ModulationSpec\"\n\nconst char *modspecNames[] = {NAMES};\n\nSMILECOMPONENT_STATICS(cFunctionalModulation)\n\nSMILECOMPONENT_REGCOMP(cFunctionalModulation)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CFUNCTIONALMODULATION;\n  sdescription = COMPONENT_DESCRIPTION_CFUNCTIONALMODULATION;\n\n  /*\n     ct->setField(\"frequencies\", \"Custom list of modulation frequencies for which to compute the magnitudes. The frequencies will be computed via a zero padded FFT over the full input (modFrqUseFFT>0), or via correlation with sine/cosine functions (slower, but efficient for only very few frequencies).\", 0, ARRAY_TYPE);\n     ct->setField(\"modFrqUseFFT\", \"If > 0, use FFT of full input if computing more than 'modFrqUseFFT' modulation frequencies.\", 4);\n     ct->setField(\"modFrqUseACF\", \"If == 1, use ACF (via FFT) to get better temporal resolution for low modulation frequencies.\", 0);\n     ct->setField(\"stftModspec\", \"1 = Enable average Stft (Short Time Fourier Transform) modulation spectrum (and ignore 'frequencies' array, write full spectrum to output). 2 = Same as 1, however, select frequencies based on 'frequencies' array. 0 = disable.\", 0)\n     ct->setField(\"stftCepstrum\", \"1 = Enable average modulation cepstrum based on Stft.\", 0);\n     ct->setField(\"stftAcf\", \"1 = Enable average ACF based on Stft.\", 0);\n     ct->setField(\"nModSpecPeaks\", \"Number of highest modulation spectrum peaks to output the frequencies for.\", 0);\n     ct->setField(\"nCepstralPeaks\", \"Number N of N highest peaks (in range numCeps..N) in cepstrum to output position for (time in seconds).\", 0);\n     ct->setField(\"nAcfPeaks\", \"Number N of N highest peaks in ACF to output position for (time in seconds). This excludes the peak at time 0.\", 0);\n     ct->setField(\"modSpecRange\", \"Frequency range of Stft modulation spectrum output (leave empty (NULL) to output the full range covered by fftWinSize). Format: start.xx - end.xx (in Hz)\", (const char*)NULL);\n     ct->setField(\"acfRange\", \"ACF range to output. Default (NULL) is output full range\", (const char*)NULL);\n     ct->setField(\"acfRange_percentage\", \"ACF range to output. Default (NULL) is output full range\", (const char*)NULL);\n     ct->setField(\"numCeps\", \"If > 0, output only 1..numCeps cepstral coefficients, otherwise (0) output all cepstral coefficients. Only effective if, stftCepstrum==1, or if using nCepstralPeaks>0.\", 0);\n     ct->setField(\"numCeps_percentage\", \"If > 0.0, output only 1..numCeps*N cepstral coefficients.\", 0.0);\n     ct->setField(\"fftWinSize\", \"Window size for Stft FFT in frames.\", 100);\n     ct->setField(\"fftWinSize_sec\", \"Window size for Stft FFT in seconds.\", 1.0);\n     ct->setField(\"fftWinFunc\", \"Stft FFT window function.\", \"han\");\n     ct->setField(\"shortSegmentMethod\", \"How to deal with short segments, i.e. segments that are shorter than fftWinSize(_sec). One of: 'zeroPad' zero-pad the input to fftWinSize, 'zeroOutput' output all zero values (no computation), 'noOutput' no output frame, input is discarded.\");\n     */\n  // ct->setField(\"shortSegmentMethod\", \"How to deal with short segments, i.e. segments that are shorter than fftWinSize(_sec). One of: 'zeroPad' zero-pad the input to fftWinSize, 'zeroOutput' output all zero values (no computation), 'noOutput' no output frame, input is discarded.\");\n  // configure your component's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"stftWinSizeSec\", \"Window size of Short Time Fourier Transformation in seconds. Set to 0 to use (zero-padded to next power of 2) full input segment. If the input is smaller than 'stftWinSizeSec', it will be zero padded to 'stftWinSizeSec'. Segments will further be zero padded to the next higher power of 2 (in frames).\", 4.0);\n    ct->setField(\"stftWinStepSec\", \"Step size of Short Time Fourier Transformation in seconds. Default 0.0 will set the step size to the same as the window size.\", 0.0);\n    ct->setField(\"stftWinSizeFrames\", \"Window size of Short Time Fourier Transformation in input frames. Set to 0 to use (zero-padded to next power of 2) full input segment. If the input is smaller than 'stftWinSizeSec', it will be zero padded to 'stftWinSizeSec'. Segments will further be zero padded to the next higher power of 2. If this option is set, it overrides stftWinSizeSec.\", 400);\n    ct->setField(\"stftWinStepFrames\", \"Window size of Short Time Fourier Transformation in input frames. Default 0 will set the step size to the same as the window size.\", 0);\n    ct->setField(\"fftWinFunc\", \"STFT window function.\", \"ham\");\n    ct->setField(\"modSpecResolution\", \"Output resolution (in Hz) of modulation spectrum (interpolated from stft). This is preferred over num bins, but if num bins is set, it will override this option.\", 0.5);\n    ct->setField(\"modSpecNumBins\", \"Alternative to specifying the resolution, specifies the number of bins. Overrides 'modSpecResolution', if set.\", 50);\n    //ct->setField(\"modSpecRange\", \"Frequency range of Stft modulation spectrum output (leave empty (NULL) to output the full range covered by fftWinSize). Format: start.xx - end.xx (in Hz)\", (const char*)NULL);\n    ct->setField(\"modSpecMinFreq\", \"Lower bound of modulation spectrum (in Hz).\", 0.5);\n    ct->setField(\"modSpecMaxFreq\", \"Upper bound of modulation spectrum (in Hz).\", 20.0);\n    ct->setField(\"showModSpecScale\", \"(1/0 = yes/no) Print the frequency axis of the modulation spectrum during initialisation.\", 0);\n    ct->setField(\"removeNonZeroMean\", \"(1/0 = yes/no) Remove the mean of all non-zero values (use for F0 modulation spectrum for example).\", 0);\n    ct->setField(\"ignoreLastFrameIfTooShort\", \"(1/0 = yes/no) If stftWinSize is not 0 (i.e. not using full input length), ignore the last window if it is smaller than 2/3 of stftWinSize.\", 1);\n  )\n\n  SMILECOMPONENT_MAKEINFO_NODMEM(cFunctionalModulation);\n}\n\nSMILECOMPONENT_CREATE(cFunctionalModulation)\n\n// TODO: set the output field info (spectral freq. axis!) correctly\n//       In order to do this we need to add this functionality to the base class...\n//       (This is tricky, so maybe move the modulation spectrum to a separate component?)\n\n/////////////////////////////////////////////////////////\ncSmileUtilWindowedMagnitudeSpectrum::cSmileUtilWindowedMagnitudeSpectrum(\n    long Nin, int winFuncId):\n      fftWork_(NULL), winFunc_(NULL), winFuncId_(winFuncId),\n      ip_(NULL), w_(NULL), Nin_(Nin), Nfft_(0)\n{\n  if (Nin > 0) {\n    allocateFFTworkspace(Nin);\n    allocateWinFunc(Nin);\n  }\n}\n\ncSmileUtilWindowedMagnitudeSpectrum::~cSmileUtilWindowedMagnitudeSpectrum()\n{\n  freeWinFunc();\n  freeFFTworkspace();\n}\n\nvoid cSmileUtilWindowedMagnitudeSpectrum::freeFFTworkspace()\n{\n  if (fftWork_ != NULL) {\n    free(fftWork_);\n    fftWork_ = NULL;\n  }\n  if (w_ != NULL) {\n    free(w_);\n    w_ = NULL;\n  }\n  if (ip_ != NULL) {\n    free(ip_);\n    ip_ = NULL;\n  }\n}\n\nvoid cSmileUtilWindowedMagnitudeSpectrum::freeWinFunc()\n{\n  if (winFunc_ != NULL) {\n    free(winFunc_);\n  }\n}\n\nvoid cSmileUtilWindowedMagnitudeSpectrum::allocateWinFunc(long Nin)\n{\n  freeWinFunc();\n  winFunc_ = (FLOAT_DMEM *)malloc(sizeof(FLOAT_DMEM) * Nin);\n  double * winFuncD = NULL;\n  switch(winFuncId_) {\n    case WINF_RECTANGLE: winFuncD = smileDsp_winRec(Nin); break;\n    case WINF_HANNING:   winFuncD = smileDsp_winHan(Nin); break;\n    case WINF_HAMMING:   winFuncD = smileDsp_winHam(Nin); break;\n    case WINF_TRIANGLE:  winFuncD = smileDsp_winTri(Nin); break;\n    case WINF_BARTLETT:  winFuncD = smileDsp_winBar(Nin); break;\n    case WINF_SINE:      winFuncD = smileDsp_winSin(Nin); break;\n    case WINF_LANCZOS:   winFuncD = smileDsp_winLac(Nin); break;\n    default:\n      SMILE_ERR(1, \"unknown window function ID (%i). Fallback to rectangular window!\",\n          winFuncId_);\n  }\n  if (winFuncD != NULL) {\n    for (int i = 0; i < Nin; i++) {\n      winFunc_[i] = (FLOAT_DMEM)winFuncD[i];\n    }\n    free(winFuncD);\n  } else {\n    for (int i = 0; i < Nin; i++) {\n      winFunc_[i] = 1.0;\n    }\n  }\n}\n\nvoid cSmileUtilWindowedMagnitudeSpectrum::allocateFFTworkspace(long Nin)\n{\n  // compute N\n  long N = Nin;\n  if (!smileMath_isPowerOf2(Nin)) {\n    N = smileMath_ceilToNextPowOf2(Nin);\n  }\n  //fprintf(stderr, \"XXX Allocate fft: Nin %ld Npow2 %ld\\n\", Nin, N);\n  if (N < 4) N = 4;\n  // free old work areas\n  freeFFTworkspace();\n  // allocate work areas\n  Nfft_ = N;\n  Nin_ = Nin;\n  ip_ = (int *)calloc(1, sizeof(int) * (N+2));\n  w_ = (FLOAT_TYPE_FFT *)calloc(1, sizeof(FLOAT_TYPE_FFT) * ((N*5)/4+2));\n  fftWork_ = (FLOAT_TYPE_FFT*)malloc(sizeof(FLOAT_TYPE_FFT) * N);\n}\n\n// copies data to work area,\n// applies window function (if any)\n// and zero-pads\nvoid cSmileUtilWindowedMagnitudeSpectrum::copyInputAndZeropad(\n    const FLOAT_DMEM *in, long Nin, bool allowWinSmaller = false)\n{\n  // some checks\n  //fprintf(stderr, \"Nfft: %ld, Nin: %ld (Nin_ %ld)\\n\", Nfft_, Nin, Nin_);\n  // This needs to happen before allocateFFTworkspace,\n  // because otherwise Nin_ will be overwritten with Nin\n  if (Nin != Nin_) {\n    allocateWinFunc(Nin);\n    Nin_ = Nin;\n  }\n  if (Nin > Nfft_ || (Nin <= Nfft_ / 2 && allowWinSmaller)) {\n    // re-allocate fft buffers ...\n    allocateFFTworkspace(Nin);\n  }\n  // copy to work area\n  if (winFunc_ != NULL) {\n    for (long i = 0; i < Nin; i++) {\n      fftWork_[i] = in[i] * winFunc_[i];\n    }\n  } else {\n    for (long i = 0; i < Nin; i++) {\n      fftWork_[i] = in[i];\n    }\n    //memcpy(fftWork_, in, sizeof(FLOAT_DMEM) * Nin);\n  }\n  // zero pad\n  if (Nfft_ > Nin) {\n    bzero(fftWork_ + Nin, sizeof(FLOAT_TYPE_FFT) * (Nfft_ - Nin));\n  }\n}\n\nvoid cSmileUtilWindowedMagnitudeSpectrum::doFFT()\n{\n  rdft((int)Nfft_, 1, fftWork_, ip_, w_);\n}\n\nvoid cSmileUtilWindowedMagnitudeSpectrum::computeMagnitudes()\n{\n  fftWork_[0] = fabs(fftWork_[0]);\n  FLOAT_DMEM nyq = fabs(fftWork_[1]);\n  for (long n = 2; n < Nfft_; n += 2) {\n    fftWork_[n/2] = sqrt(fftWork_[n]*fftWork_[n] + fftWork_[n+1]*fftWork_[n+1]);\n  }\n  fftWork_[Nfft_ / 2] = nyq;\n}\n\nconst FLOAT_DMEM * cSmileUtilWindowedMagnitudeSpectrum::getMagnitudes(\n    const FLOAT_DMEM *in, long Nin, bool allowWinSmaller = false)\n{\n  copyInputAndZeropad(in, Nin, allowWinSmaller);\n  doFFT();\n  computeMagnitudes();\n// TODO: convert fftWork to right pointer type upon return!!!!\n// This is a temp hack to make the compiler happy, but it breaks the compontnt!!\n  return (FLOAT_DMEM*)fftWork_;\n}\n\n/////////////////////////////////////////////////////////\ncSmileUtilMappedMagnitudeSpectrum::cSmileUtilMappedMagnitudeSpectrum(long Nin,\n    long Nout, int winFuncId, double minFreq, double maxFreq, double T):\n  modSpec_(NULL), Nout_(Nout), minFreq_(minFreq), maxFreq_(maxFreq),\n  Nmag_(0), splineWork_(NULL), splineDerivs_(NULL), magFreq_(NULL),\n  T_(T)\n{\n  fft_ = new cSmileUtilWindowedMagnitudeSpectrum(Nin, winFuncId);\n  modSpec_ = (FLOAT_DMEM*)calloc(1, sizeof(FLOAT_DMEM) * Nout);\n}\n\ncSmileUtilMappedMagnitudeSpectrum::~cSmileUtilMappedMagnitudeSpectrum()\n{\n  if (modSpec_ != NULL) {\n    free(modSpec_);\n  }\n  if (fft_ != NULL) {\n    delete fft_;\n  }\n  if (splineDerivs_ != NULL) {\n    free(splineDerivs_);\n  }\n  if (splineWork_ != NULL) {\n    free(splineWork_);\n  }\n  if (magFreq_ != NULL) {\n    free(magFreq_);\n  }\n}\n\nvoid cSmileUtilMappedMagnitudeSpectrum::mapMagnitudesToModSpecBins(\n    const FLOAT_DMEM *mag, long N)\n{\n  //fprintf(stderr, \"XXX: N %ld, Nmag_ %ld\\n\", N, Nmag_);\n  if (Nmag_ != N) {\n    Nmag_ = N;\n    // if N has changed, recreate the splines\n    if (splineDerivs_ != NULL) {\n      free(splineDerivs_);\n    }\n    splineDerivs_ = (FLOAT_DMEM *)malloc(sizeof(FLOAT_DMEM)*Nmag_);\n    if (splineWork_ != NULL) {\n      free(splineWork_);\n      splineWork_ = NULL;\n    }\n    if (magFreq_ != NULL) {\n      free(magFreq_);\n    }\n    FLOAT_DMEM deltaFmag_ = fft_->getBinDeltaF(T_);\n    magFreq_ = (FLOAT_DMEM *)malloc(sizeof(FLOAT_DMEM)*Nmag_);\n    for (long i = 0; i < Nmag_; i++) {\n      magFreq_[i] = (FLOAT_DMEM)i * deltaFmag_;\n    }\n    deltaF_ = (maxFreq_ - minFreq_) / (double)Nout_;\n  }\n\n  // apply the spline interpolation to get the mapped spectrum\n  if (smileMath_spline_FLOAT_DMEM(magFreq_, mag, Nmag_, 1e30, 1e30, splineDerivs_, &splineWork_ )) {\n    // after successful spline computation, do the actual interpolation point by point\n    for (long i = 0; i < Nout_; i++) {\n      FLOAT_DMEM f = minFreq_ + (double)i * deltaF_;\n      smileMath_splint_FLOAT_DMEM(magFreq_, mag, splineDerivs_, Nmag_, f, modSpec_ + i);\n    }\n  }\n}\n\n// allowWinSmaller = false : If window gets smaller than N/2, everything will be re-allocated and an FFT of N/2 (or smaller) will be performed\n// .. = true: The smaller input window will only be zero-padded and the full fft is performed\nvoid cSmileUtilMappedMagnitudeSpectrum::compute(\n    const FLOAT_DMEM *in, long Nin, bool allowWinSmaller = false)\n{\n  const FLOAT_DMEM *mags = fft_->getMagnitudes(in, Nin, allowWinSmaller);\n  mapMagnitudesToModSpecBins(mags, fft_->getNmagnitudes());\n}\n\nconst FLOAT_DMEM * cSmileUtilMappedMagnitudeSpectrum::getModSpec()\n{\n  return modSpec_;\n}\n\n///////////////////////////////////////////////\n//-----\ncFunctionalModulation::cFunctionalModulation(const char *name) :\n  cFunctionalComponent(name, N_FUNCTS, modspecNames),\n  tmpstr_(NULL), mappedSpec_(NULL), avgModSpec_(NULL),\n  stftWinSizeFrames_(0), stftWinStepFrames_(0),\n  inNorm_(NULL), inNormN_(0)\n{\n}\n\nvoid cFunctionalModulation::fetchConfig()\n{\n  ignoreLastFrameIfTooShort_ = getInt(\"ignoreLastFrameIfTooShort\");\n  removeNonZeroMean_ = getInt(\"removeNonZeroMean\");\n\n  stftWinSizeSec_ = getDouble(\"stftWinSizeSec\");\n  stftWinStepSec_ = getDouble(\"stftWinStepSec\");\n  if (stftWinStepSec_ == 0.0) {\n    stftWinStepSec_ = stftWinSizeSec_;\n  }\n  if (isSet(\"stftWinSizeFrames\")) {\n    stftWinSizeFrames_ = getInt(\"stftWinSizeFrames\");\n    stftWinSizeSec_ = 0.0;\n  }\n  if (isSet(\"stftWinStepFrames\")) {\n    stftWinStepFrames_ = getInt(\"stftWinStepFrames\");\n    stftWinStepSec_ = 0.0;\n  }\n  if (stftWinStepFrames_ == 0) {\n    stftWinStepFrames_ = stftWinSizeFrames_;\n  }\n\n  modSpecMinFreq_ = getDouble(\"modSpecMinFreq\");\n  modSpecMaxFreq_ = getDouble(\"modSpecMaxFreq\");\n  if (isSet(\"modSpecNumBins\")) {\n    modSpecNumBins_ = getInt(\"modSpecNumBins\");\n    modSpecResolution_ = (modSpecMaxFreq_ - modSpecMinFreq_) / (double)(modSpecNumBins_ - 1);\n  } else {\n    modSpecResolution_ = getDouble(\"modSpecResolution\");\n    modSpecNumBins_ = (int)round((modSpecMaxFreq_ - modSpecMinFreq_) / modSpecResolution_) + 1;\n  }\n  SMILE_IMSG(2, \"modSpecNumBins_ = %i\", modSpecNumBins_);\n  if (getInt(\"showModSpecScale\")) {\n    for (int i = 0; i < modSpecNumBins_; i++) {\n      SMILE_IMSG(1, \"modulation spectrum bin %i : %f Hz\", i, modSpecMinFreq_ + (double)i * modSpecResolution_);\n    }\n  }\n  const char * wf = getStr(\"fftWinFunc\");\n  if (wf != NULL) {\n    winFuncId_ = winFuncToInt(wf);\n  }\n\n  enab[0] = 1;\n  cFunctionalComponent::fetchConfig();\n  nEnab += modSpecNumBins_ - 1;   // -1 because enab[0] = 1 will increase nEnab by 1\n  //nEnab = 0;\n}\n\nlong cFunctionalModulation::getNumberOfElements(long j)\n{\n  if (j == 0)\n    return modSpecNumBins_;\n  else\n    return 0;\n}\n\n// TODO: option for output of modspec frequencies!\nconst char* cFunctionalModulation::getValueName(long i)\n{\n  const char *n = cFunctionalComponent::getValueName(0);\n  // append coefficient number\n  if (tmpstr_ != NULL) free(tmpstr_);\n  tmpstr_ = myvprint(\"%s%i\", n, i);\n  return tmpstr_;\n}\n\n// is called by cFunctionals::setupNamesForElement after each new field has been added\nvoid cFunctionalModulation::setFieldMetaData(cDataWriter *writer,\n    const FrameMetaInfo *fmeta, int idxi, long nEl) {\n  long infosize = nEl * sizeof(double);\n  if (fmeta->field[idxi].infoSize > 0 && fmeta->field[idxi].infoSize != infosize) {\n    SMILE_IWRN(3, \"nEl (* sizeof(double)) in call to setFieldMetaData != infoSize from previous level. Check your setup and the code! (infoSize = %i, nEl * sizeof(double) = %i). Using nEl here...\",\n        fmeta->field[idxi].infoSize, infosize);\n  }\n\n  double * buf = (double *)malloc(infosize);\n  int i;\n  for (i = 0; i < nEl; i++) {\n    buf[i] = modSpecResolution_ * (double)i + modSpecMinFreq_;\n  }\n  writer->setFieldInfo(-1, // refers to last field added\n      DATATYPE_SPECTRUM_BINS_MAG, buf,\n      infosize);\n}\n\nint cFunctionalModulation::computeModSpecSTFTavg(const FLOAT_DMEM *in, long Nin, FLOAT_DMEM *ms)\n{\n  int nSpec = 0;\n  bzero(ms, sizeof(FLOAT_DMEM) * mappedSpec_->getModSpecN());\n  for (long n = 0; n < Nin; n += stftWinStepFrames_) {\n    long N = MIN(stftWinSizeFrames_, Nin - n - 1);\n    //fprintf(stderr, \"XXX candidate n %ld, Nin %ld, winSize %ld, chosen N %ld\\n\", n, Nin, stftWinSizeFrames_, N);\n    if (N > 2 * stftWinSizeFrames_ / 3 || nSpec == 0) {\n      //fprintf(stderr, \"XXX do compte\\n\");\n      // always pad first frame, don't pad/process the following frames if shorter than 2/3 winSize\n      mappedSpec_->compute(in + n, N, true);\n      N = mappedSpec_->getModSpecN();\n      const FLOAT_DMEM * spec = mappedSpec_->getModSpec();\n      // do the averaging...\n      for (int i = 0; i < N; i++) {\n        ms[i] += spec[i];\n      }\n      nSpec++;\n    }\n  }\n  long N = mappedSpec_->getModSpecN();\n  if (nSpec > 0) {\n    for (int i = 0; i < N; i++) {\n      ms[i] /= (FLOAT_DMEM)nSpec;\n    }\n  }\n  return N;\n}\n\nlong cFunctionalModulation::process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM *out, long Nin, long Nout)\n{\n  if (mappedSpec_ == NULL ||\n      (stftWinSizeFrames_ == 0 && mappedSpec_->getNin() != Nin)) {\n    // we need to init\n    FLOAT_DMEM T = (FLOAT_DMEM)getInputPeriod();\n    if (T == 0.0) {\n      SMILE_IERR(1, \"Cannot compute modulation spectrum when input period is unknown (asynchronous input level!). T = 0.0\");\n      return 0;\n    }\n    if (stftWinSizeFrames_ == 0 && T > 0) {\n      stftWinSizeFrames_ = stftWinSizeSec_ / T;\n      stftWinStepFrames_ = stftWinStepSec_ / T;\n    }\n    long N = Nin;\n    if (stftWinSizeFrames_ > 0) {\n      N = stftWinSizeFrames_;\n      //fprintf(stderr, \"XXX stftWinSize: %ld\\n\", stftWinSizeFrames_);\n    }\n    //fprintf(stderr, \"XXX allocate with N = %ld\\n\", N);\n    mappedSpec_ = new cSmileUtilMappedMagnitudeSpectrum(N, modSpecNumBins_,\n        winFuncId_, modSpecMinFreq_, modSpecMaxFreq_, T);\n  }\n  if (avgModSpec_ == NULL) {\n    avgModSpec_ = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM) * modSpecNumBins_);\n  }\n  if (removeNonZeroMean_) {\n    if (inNormN_ != Nin) {\n      if (inNorm_ != NULL) {\n        free(inNorm_);\n      }\n      inNorm_ = NULL;\n    }\n    if (inNorm_ == NULL) {\n      inNormN_ = Nin;\n      inNorm_ = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM) * Nin);\n    }\n    FLOAT_DMEM mean = 0.0;\n    long nMean = 0;\n    for (long i = 0; i < Nin; i++) {\n      if (in[i] != 0.0) {\n        mean += in[i];\n        nMean++;\n      }\n    }\n    if (nMean > 0) {\n      mean /= (FLOAT_DMEM)nMean;\n    }\n    for (long i = 0; i < Nin; i++) {\n      if (in[i] != 0.0) {\n        inNorm_[i] = in[i] - mean;\n      } else {\n        inNorm_[i] = 0.0;\n      }\n    }\n    in = inNorm_;\n  }\n  if (stftWinSizeFrames_ == 0) {\n    mappedSpec_->compute(in, Nin, false);\n    const FLOAT_DMEM * ms = mappedSpec_->getModSpec();\n    memcpy(avgModSpec_, ms, sizeof(FLOAT_DMEM) * modSpecNumBins_);\n  } else {\n    computeModSpecSTFTavg(in, Nin, avgModSpec_);\n  }\n  // do some transformations, like power, log\n\n  // here would be also the place to apply ACF/CEPSTRUM/DCT etc.\n\n  // copy the resulting modspec to the output vector\n  //printf(\"XXX out[1] = %f\\n\", avgModSpec_[1]);\n  for (int i = 0; i < modSpecNumBins_; i++) {\n    out[i] = avgModSpec_[i];\n  }\n  return Nout;\n}\n\n// FURTHER TODO: functionalsVecToVec..\n\n/*\nlong cFunctionalModulation::process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout)\n{\n\n  return 0;\n}\n*/\n\ncFunctionalModulation::~cFunctionalModulation()\n{\n  if (tmpstr_ != NULL) {\n    free(tmpstr_);\n  }\n  if (mappedSpec_ != NULL) {\n    delete mappedSpec_;\n  }\n  if (avgModSpec_ != NULL) {\n    free(avgModSpec_);\n  }\n  if (inNorm_ != NULL) {\n    free(inNorm_);\n  }\n}\n\n\n// TODO: modspec phases might be of interest... or rather the relative phase deviations between mod freqs.\n\n// TODO: 2D modspec component (not functional.. MVR like)\n\n/*\n This will take a log spectrogram, downsampled to 50 freq. bins?\n Time resolution downsampled to 20fps\n  Then 2D spec/cep ?  (looks more at the LF components)\n\n Or fine grained struct of non-downsampled as extra features? (HF components)\n*/\n\n"
  },
  {
    "path": "src/functionals/functionalMoments.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctionals: statistical moments\n\n*/\n\n\n\n#include <functionals/functionalMoments.hpp>\n\n#define MODULE \"cFunctionalMoments\"\n\n\n#define FUNCT_VAR        0\n#define FUNCT_STDDEV     1\n#define FUNCT_SKEWNESS   2\n#define FUNCT_KURTOSIS   3\n#define FUNCT_AMEAN      4\n#define FUNCT_STDDEV_NORM   5    // coefficient of variance, allows for negative values\n#define FUNCT_STDDEV_NORM_ABS   6    // coefficient of variance, takes abs val of mean before dividing by mean\n\n#define N_FUNCTS  7\n\n#define NAMES     \"variance\",\"stddev\",\"skewness\",\"kurtosis\",\"amean\",\"stddevNorm\",\"coeffOfVariation\"\n\nconst char *momentsNames[] = {NAMES};  // change variable name to your class...\n\nSMILECOMPONENT_STATICS(cFunctionalMoments)\n\nSMILECOMPONENT_REGCOMP(cFunctionalMoments)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CFUNCTIONALMOMENTS;\n  sdescription = COMPONENT_DESCRIPTION_CFUNCTIONALMOMENTS;\n\n  // configure your component's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"variance\",\"1/0=enable/disable output of variance\",1);\n    ct->setField(\"stddev\",\"1/0=enable/disable output of standard deviation\",1);\n    ct->setField(\"skewness\",\"1/0=enable/disable output of skewness\",1);\n    ct->setField(\"kurtosis\",\"1/0=enable/disable output of kurtosis\",1);\n    ct->setField(\"amean\",\"1/0=enable/disable output of arithmetic mean\",0);\n    ct->setField(\"stddevNorm\",\"(2)/1/0=(enable compatible)/enable/disable output of standard deviation normalised to the absolute value of the arithmetic mean (stddev/abs(mean), also referred to as 'coefficient of variance'). NOTE: in older pre 2.2-final versions of openSMILE, this option computed stddev/mean without the abs() operation. To enable a behaviour compatible to this, set this option to the value 2.\", 0);\n    ct->setField(\"doRatioLimit\", \"(1/0) = yes/no. Apply soft limiting of stddevNorm ratio feature in order to avoid high uncontrolled output values if the denominator is close to 0. For strict compatibility with pre 2.2 openSMILE releases (also release candidates 2.2rc1), set it to 0 (current default)\", 0);\n  )\n\n  SMILECOMPONENT_MAKEINFO_NODMEM(cFunctionalMoments);\n}\n\nSMILECOMPONENT_CREATE(cFunctionalMoments)\n\n//-----\n\ncFunctionalMoments::cFunctionalMoments(const char *_name) :\n  cFunctionalComponent(_name,N_FUNCTS,momentsNames)\n{\n}\n\nvoid cFunctionalMoments::fetchConfig()\n{\n  if (getInt(\"variance\")) enab[FUNCT_VAR] = 1;\n  if (getInt(\"stddev\")) enab[FUNCT_STDDEV] = 1;\n  if (getInt(\"skewness\")) enab[FUNCT_SKEWNESS] = 1;\n  if (getInt(\"kurtosis\")) enab[FUNCT_KURTOSIS] = 1;\n  if (getInt(\"amean\")) enab[FUNCT_AMEAN] = 1;\n  if (getInt(\"stddevNorm\") == 2) {\n    enab[FUNCT_STDDEV_NORM] = 1;\n    enab[FUNCT_STDDEV_NORM_ABS] = 0;\n    // NOTE: only of STDDEV_NORM or STDDEV_NORM_ABS might be enabled at once!!\n  }\n  else if (getInt(\"stddevNorm\") == 1) {\n    enab[FUNCT_STDDEV_NORM] = 0;\n    enab[FUNCT_STDDEV_NORM_ABS] = 1;\n  }\n  doRatioLimit_ = getInt(\"doRatioLimit\");\n  cFunctionalComponent::fetchConfig();\n}\n\nlong cFunctionalMoments::process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM min, FLOAT_DMEM max, FLOAT_DMEM mean, FLOAT_DMEM *out, long Nin, long Nout)\n{\n  int i;\n  if ((Nin>0)&&(out!=NULL)) {\n    double m2 = 0.0;\n    double m3 = 0.0;\n    double m4 = 0.0;\n    double Nind = (double)Nin;\n    double tmp, tmp2;\n    FLOAT_DMEM *in0=in;\n    double meanD = (double)mean;\n    for (i=0; i<Nin; i++) {\n      tmp = ((double)*(in++) - meanD);\n      tmp2 = tmp * tmp;\n      m2 += tmp2;\n      tmp2 *= tmp;\n      m3 += tmp2;\n      m4 += tmp2*tmp;\n    }\n    m2 /= Nind;  // variance\n\n    int n=0;\n    if (enab[FUNCT_VAR])\n      out[n++] = (FLOAT_DMEM)m2;\n    double sqm2 = sqrt(m2);\n    if (enab[FUNCT_STDDEV]) {\n      if (m2 > 0.0)\n        out[n++] = (FLOAT_DMEM)sqm2;\n      else\n        out[n++] = 0.0;\n    }\n    if (enab[FUNCT_SKEWNESS]) {\n      if (m2 > 0.0)\n        out[n++] = (FLOAT_DMEM)( m3/(Nind*m2*sqm2) );\n      else\n        out[n++] = 0.0;\n    }\n    if (enab[FUNCT_KURTOSIS]) {\n      if (m2 > 0.0)\n        out[n++]=(FLOAT_DMEM)( m4/(Nind*m2*m2) );\n      else\n        out[n++] = 0.0;\n    }\n    if (enab[FUNCT_AMEAN])\n      out[n++]=(FLOAT_DMEM)mean;\n    if (enab[FUNCT_STDDEV_NORM] || enab[FUNCT_STDDEV_NORM_ABS]) {\n      if (m2 > 0.0) {\n        FLOAT_DMEM meanLocal;\n        if (enab[FUNCT_STDDEV_NORM_ABS]) {\n          meanLocal = fabs(mean);\n        } else {\n          meanLocal = mean;\n        }\n        if (doRatioLimit_) {\n          if (meanLocal != 0.0) {\n            double sqm2N = smileMath_ratioLimit((FLOAT_DMEM)(sqm2 / (double)meanLocal), \n              (FLOAT_DMEM)10.0, (FLOAT_DMEM)20.0);\n            out[n++] = (FLOAT_DMEM)sqm2N;\n          } else {\n            out[n++] = 20.0;\n          }\n        } else {\n          double mean1 = (double)meanLocal;\n          if (mean1 == 0.0)\n            mean1 = 1.0;\n          double sqm2N = sqm2 / mean1;\n          out[n++]=(FLOAT_DMEM)sqm2N;\n        }\n      } else {\n        out[n++] = 0.0;\n      }\n    }\n    return n;\n  }\n  return 0;\n}\n\ncFunctionalMoments::~cFunctionalMoments()\n{\n}\n\n"
  },
  {
    "path": "src/functionals/functionalOnset.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctionals: relative position of first onset and last offset \n\n*/\n\n\n#include <functionals/functionalOnset.hpp>\n\n#define MODULE \"cFunctionalOnset\"\n\n\n#define FUNCT_ONSETPOS       0  // number of segments (relative to maxNumSeg)\n#define FUNCT_OFFSETPOS      1  // mean length of segment (relative to input length)\n#define FUNCT_NUMONSETS      2  // number of segments (relative to maxNumSeg)\n#define FUNCT_NUMOFFSETS     3  // mean length of segment (relative to input length)\n#define FUNCT_ONSETRATE      4  // rate of onsets\n\n#define N_FUNCTS  5\n\n#define NAMES     \"onsetPos\",\"offsetPos\",\"numOnsets\",\"numOffsets\",\"onsetRate\"\n\nconst char *onsetNames[] = {NAMES};  \n\nSMILECOMPONENT_STATICS(cFunctionalOnset)\n\nSMILECOMPONENT_REGCOMP(cFunctionalOnset)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CFUNCTIONALONSET;\n  sdescription = COMPONENT_DESCRIPTION_CFUNCTIONALONSET;\n\n  // configure your component's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"threshold\",\"The absolute threshold used for onset/offset detection (i.e. the first onset will be where the input value is above the threshold for the first time)\",0.0);\n    ct->setField(\"thresholdOnset\",\"A separate threshold only for onset detection. This will override the 'threshold' option, if set\",0.0,0,0);\n    ct->setField(\"thresholdOffset\",\"A separate threshold only for offset detection. This will override the 'threshold' option, if set\",0.0,0,0);\n    ct->setField(\"useAbsVal\",\"1/0=yes/no : apply thresholds to absolute input value instead of original input value\",0);\n    ct->setField(\"onsetPos\",\"1/0=enable/disable output of relative position (relative to the input segment length, in seconds, or in frames, see the 'norm' option or the 'masterTimeNorm' option of the cFunctionals parent component) of first onset found [output name: onsetPos]\",0);\n    ct->setField(\"offsetPos\",\"1/0=enable/disable output of position of last offset found (relative to the input segment length, in seconds, or in frames, see the 'norm' option or the 'masterTimeNorm' option of the cFunctionals parent component) [output name: offsetPos]\",0);\n    ct->setField(\"numOnsets\",\"1/0=enable/disable output of the number of onsets found [output name: numOnsets]\",1);\n    ct->setField(\"numOffsets\",\"1/0=enable/disable output of the number of offsets found (this is usually redundant and the same as numOnsets, use this only for special applications where it may make sense to use it) [output name: numOffsets]\",0);\n    ct->setField(\"onsetRate\",\"1/0=enable/disable output of on-set rate, i.e. the number of onsets per second.\",0);\n    ct->setField(\"norm\",\"This option specifies how this component should normalise times (if it generates output values related to durations): \\n   'segment' (or: 'turn') : normalise to the range 0..1, the result is the relative length wrt. to the segment length )\\n   'second'  (absolute time in seconds) \\n   'frame' (absolute time in number of frames of input level)\",\"segment\",0,0);\n  )\n\n  SMILECOMPONENT_MAKEINFO_NODMEM(cFunctionalOnset);\n}\n\nSMILECOMPONENT_CREATE(cFunctionalOnset)\n\n//-----\n\ncFunctionalOnset::cFunctionalOnset(const char *_name) :\n  cFunctionalComponent(_name,N_FUNCTS,onsetNames)\n{\n}\n\nvoid cFunctionalOnset::fetchConfig()\n{\n  parseTimeNormOption();\n\n  if (getInt(\"onsetPos\")) enab[FUNCT_ONSETPOS] = 1;\n  if (getInt(\"offsetPos\")) enab[FUNCT_OFFSETPOS] = 1;\n  if (getInt(\"numOnsets\")) enab[FUNCT_NUMONSETS] = 1;\n  if (getInt(\"numOffsets\")) enab[FUNCT_NUMOFFSETS] = 1;\n  if (getInt(\"onsetRate\")) enab[FUNCT_ONSETRATE] = 1;\n\n  thresholdOffset = thresholdOnset = (FLOAT_DMEM)getDouble(\"threshold\");\n  if (isSet(\"thresholdOnset\")) \n    thresholdOnset = (FLOAT_DMEM)getDouble(\"thresholdOnset\");\n  if (isSet(\"thresholdOffset\")) \n    thresholdOffset = (FLOAT_DMEM)getDouble(\"thresholdOffset\");\n\n  useAbsVal = getInt(\"useAbsVal\");\n  SMILE_IDBG(2,\"useAbsVal = %i\",useAbsVal);\n\n  SMILE_IDBG(2,\"thresholdOnset = %f\",thresholdOnset);\n  SMILE_IDBG(2,\"thresholdOffset = %f\",thresholdOffset);\n\n  cFunctionalComponent::fetchConfig();\n}\n\nlong cFunctionalOnset::process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM *out, long Nin, long Nout)\n{\n  long i;\n  if ((Nin>0)&&(out!=NULL)) {\n    long onsetPos = -1;\n    long offsetPos = -1;\n    long nOnsets = 0;\n    long nOffsets = 0;\n    int oo = 0; // sttus memory.. last value above threshold = 1\n    if (in[0] > thresholdOnset) oo = 1;\n    for (i=1; i<Nin; i++) {\n      FLOAT_DMEM cur;\n      if (useAbsVal) cur = fabs(in[i]);\n      else cur = in[i];\n      if (cur > thresholdOnset) {\n        if (oo == 0) {\n          nOnsets++;\n          if (onsetPos == -1) onsetPos = i;\n          oo = 1;\n        }\n      }\n      if (cur <= thresholdOffset) {\n        if (oo == 1) {\n          nOffsets++;\n          offsetPos = i;\n          oo = 0;\n        }\n      }\n    }\n    if (offsetPos == -1) offsetPos = Nin-1;\n    if (onsetPos == -1) onsetPos = 0;\n\n    int n=0;\n\n    if (timeNorm == TIMENORM_SEGMENT) {\n      if (enab[FUNCT_ONSETPOS]) out[n++]=(FLOAT_DMEM)onsetPos/(FLOAT_DMEM)(Nin);\n      if (enab[FUNCT_OFFSETPOS]) out[n++]=(FLOAT_DMEM)offsetPos/(FLOAT_DMEM)(Nin);\n    } else if (timeNorm == TIMENORM_SECONDS) {\n      FLOAT_DMEM _T = (FLOAT_DMEM)getInputPeriod();\n      if (enab[FUNCT_ONSETPOS]) out[n++]=(FLOAT_DMEM)onsetPos*_T;\n      if (enab[FUNCT_OFFSETPOS]) out[n++]=(FLOAT_DMEM)offsetPos*_T;\n    } else if (timeNorm == TIMENORM_FRAMES) {\n      if (enab[FUNCT_ONSETPOS]) out[n++]=(FLOAT_DMEM)onsetPos;\n      if (enab[FUNCT_OFFSETPOS]) out[n++]=(FLOAT_DMEM)offsetPos;\n    }\n\n    if (enab[FUNCT_NUMONSETS]) \n      out[n++]=(FLOAT_DMEM)nOnsets;\n\n    if (enab[FUNCT_NUMOFFSETS]) \n      out[n++]=(FLOAT_DMEM)nOffsets;\n\n    if (enab[FUNCT_ONSETRATE]) { \n      FLOAT_DMEM _T = (FLOAT_DMEM)getInputPeriod();\n      out[n++]=(FLOAT_DMEM)nOnsets/((FLOAT_DMEM)Nin * _T);\n    }\n\n    return n;\n  }\n  return 0;\n}\n\n/*\nlong cFunctionalOnset::process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout)\n{\n\n  return 0;\n}\n*/\n\ncFunctionalOnset::~cFunctionalOnset()\n{\n}\n\n"
  },
  {
    "path": "src/functionals/functionalPeaks.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctionals: number of peaks and various measures associated with peaks\n\n*/\n\n\n#include <functionals/functionalPeaks.hpp>\n\n#define MODULE \"cFunctionalPeaks\"\n\n\n#define FUNCT_NUMPEAKS         0  // number of peaks\n#define FUNCT_MEANPEAKDIST     1  // mean distance between peaks\n#define FUNCT_PEAKMEAN         2  // arithmetic mean of peaks\n#define FUNCT_PEAKMEANMEANDIST 3  // aritmetic mean of peaks - aritmetic mean\n#define FUNCT_PEAKDISTSTDDEV   4  // standard deviation of inter peak distances\n\n#define N_FUNCTS  5\n\n#define NAMES     \"numPeaks\",\"meanPeakDist\",\"peakMean\",\"peakMeanMeanDist\",\"peakDistStddev\"\n\n#define PEAKDIST_BLOCKALLOC 50\n\nconst char *peaksNames[] = {NAMES};  \n\nSMILECOMPONENT_STATICS(cFunctionalPeaks)\n\nSMILECOMPONENT_REGCOMP(cFunctionalPeaks)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CFUNCTIONALPEAKS;\n  sdescription = COMPONENT_DESCRIPTION_CFUNCTIONALPEAKS;\n\n  // configure your component's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"numPeaks\",\"1/0=enable/disable output of number of peaks [output name: numPeaks]\",1);\n    ct->setField(\"meanPeakDist\",\"1/0=enable/disable output of mean distance between peaks (relative to the input segment length, in seconds, or in frames, see the 'norm' option or the 'masterTimeNorm' option of the cFunctionals parent component) [output name: meanPeakDist]\",1);\n    ct->setField(\"peakMean\",\"1/0=enable/disable output of arithmetic mean of peaks [output name: peakMean]\",1);\n    ct->setField(\"peakMeanMeanDist\",\"1/0=enable/disable output of arithmetic mean of peaks - arithmetic mean of all values [output name: peakMeanMeanDist]\",1);\n    ct->setField(\"peakDistStddev\",\"1/0=enable/disable output of standard deviation of inter peak distances [output name: peakDistStddev]\",0);\n    ct->setField(\"norm\",\"This option specifies how this component should normalise times (if it generates output values related to durations): \\n   'segment' (or: 'turn') : normalise to the range 0..1, the result is the relative length wrt. to the segment length )\\n   'second'  (absolute time in seconds) \\n   'frame' (absolute time in number of frames of input level)\",\"frames\");\n    ct->setField(\"overlapFlag\",\"1/0=yes/no frames overlap (i.e. compute peaks locally only)\",1,0,0);\n    //TODO: unified time norm handling for all functionals components: frame, seconds, turn !\n  )\n\n  SMILECOMPONENT_MAKEINFO_NODMEM(cFunctionalPeaks);\n}\n\nSMILECOMPONENT_CREATE(cFunctionalPeaks)\n\n//-----\n\ncFunctionalPeaks::cFunctionalPeaks(const char *_name) :\n  cFunctionalComponent(_name,N_FUNCTS,peaksNames),\n  lastlastVal(0.0),\n  lastVal(0.0),\n  overlapFlag(0),\n  peakdists(NULL), nPeakdists(0)\n{\n}\n\nvoid cFunctionalPeaks::fetchConfig()\n{\n  parseTimeNormOption();\n\n  if (getInt(\"numPeaks\")) enab[FUNCT_NUMPEAKS] = 1;\n  if (getInt(\"meanPeakDist\")) enab[FUNCT_MEANPEAKDIST] = 1;\n  if (getInt(\"peakMean\")) enab[FUNCT_PEAKMEAN] = 1;\n  if (getInt(\"peakMeanMeanDist\")) enab[FUNCT_PEAKMEANMEANDIST] = 1;\n  if (getInt(\"peakDistStddev\")) enab[FUNCT_PEAKDISTSTDDEV] = 1;\n  \n  overlapFlag = getInt(\"overlapFlag\");\n\n  cFunctionalComponent::fetchConfig();\n}\n\nvoid cFunctionalPeaks::addPeakDist(int idx, long dist)\n{\n  if (peakdists == NULL) {\n    peakdists = (long*)calloc(1,sizeof(long)*(idx+PEAKDIST_BLOCKALLOC));\n    nPeakdists = idx+PEAKDIST_BLOCKALLOC;\n  } else if (idx >= nPeakdists) {\n    peakdists = (long*)crealloc(peakdists,sizeof(long)*(idx+PEAKDIST_BLOCKALLOC),sizeof(long)*nPeakdists);\n    nPeakdists = idx+PEAKDIST_BLOCKALLOC;\n  }\n  peakdists[idx] = dist;\n}\n\nlong cFunctionalPeaks::process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM *out, long Nin, long Nout)\n{\n  int i;\n  if ((Nin>0)&&(out!=NULL)) {\n    FLOAT_DMEM max = *in;\n    FLOAT_DMEM min = *in;\n    FLOAT_DMEM mean = *in;\n\n    FLOAT_DMEM peakDist = (FLOAT_DMEM)0.0;\n    long nPeakDist = 0;\n    FLOAT_DMEM peakMean = (FLOAT_DMEM)0.0;\n    long nPeaks = 0;\n\n    FLOAT_DMEM lastMin=(FLOAT_DMEM)0.0; // in[0];\n    FLOAT_DMEM lastMax=(FLOAT_DMEM)0.0; //in[0];\n    long curmaxPos=0, lastmaxPos=-1;\n\n    int peakflag = 0;  \n\n    // range, min, max, mean\n    for (i=1; i<Nin; i++) {\n      if (in[i]<min) min=in[i];\n      if (in[i]>max) max=in[i];\n      mean += in[i];\n    }\n    mean /= (FLOAT_DMEM)Nin;\n    FLOAT_DMEM range = max-min;\n\n    if (overlapFlag) i=2;\n    else i=0;\n\n    if (overlapFlag) {\n      lastlastVal=in[0];\n      lastVal=in[1];\n    }\n\n    // advanced peak detection\n    for (; i<Nin; i++) {\n      // first, find ALL peaks:\n      if ((lastlastVal < lastVal)&&(lastVal > in[i])) { // max\n        if (!peakflag) lastMax = in[i];\n        else { if (in[i] > lastMax) { lastMax = in[i]; curmaxPos = i; } }\n\n        if (lastMax - lastMin > 0.11*range) { \n          peakflag = 1; curmaxPos = i;\n        }\n\n      } else {\n        if ((lastlastVal > lastVal)&&(lastVal < in[i])) { // min\n          lastMin = in[i];\n        } \n      }\n\n      // detect peak only, if x[i] falls below lastmax - 0.09*range\n      if ((peakflag)&&( (in[i] < lastMax-0.09*range) || (i==Nin-1)) ) {\n        nPeaks++;\n        peakMean += lastMax;\n        if (lastmaxPos >= 0) {\n          FLOAT_DMEM dist = (FLOAT_DMEM)(curmaxPos-lastmaxPos);\n          peakDist += dist;\n          // add dist to list for variance computation\n          addPeakDist(nPeakDist,(long)dist);\n          nPeakDist++;\n        }\n        lastmaxPos = curmaxPos;\n        peakflag = 0;\n      }\n\n      lastlastVal = lastVal;\n      lastVal = in[i];\n    }\n\n\n    FLOAT_DMEM stddev = 0.0;\n\n    if (nPeakDist > 0.0) {\n      peakDist /= (FLOAT_DMEM)nPeakDist;\n      // compute peak distance variance / standard deviation\n      for (i=0; i<nPeakDist; i++) {\n        stddev += (peakdists[i]-peakDist)*(peakdists[i]-peakDist);\n      }\n      stddev /= (FLOAT_DMEM)nPeakDist;\n      stddev = sqrt(stddev);\n    } else {\n      peakDist = (FLOAT_DMEM)(Nin+1);\n      stddev = 0.0;\n    }\n\n\n    int n=0;\n    if (enab[FUNCT_NUMPEAKS]) out[n++]=(FLOAT_DMEM)nPeaks;\n\n    if (timeNorm==TIMENORM_SECONDS) {\n      peakDist *= (FLOAT_DMEM)getInputPeriod();\n      stddev *= (FLOAT_DMEM)getInputPeriod();\n    } else if (timeNorm==TIMENORM_SEGMENT) {\n      peakDist /= (FLOAT_DMEM)Nin;\n      stddev /= (FLOAT_DMEM)Nin;\n    }\n    if (enab[FUNCT_MEANPEAKDIST]) out[n++]=peakDist;\n\n    if (nPeaks > 0.0) {\n      peakMean /= (FLOAT_DMEM)nPeaks;\n    } else {\n      peakMean = (FLOAT_DMEM)0.0;\n    }\n    if (enab[FUNCT_PEAKMEAN]) out[n++] = peakMean;\n\n    if (enab[FUNCT_PEAKMEANMEANDIST]) out[n++]=peakMean-mean;\n\n    if (enab[FUNCT_PEAKDISTSTDDEV]) out[n++]=stddev;\n\n    return n;\n  }\n  return 0;\n}\n\n/*\nlong cFunctionalPeaks::process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout)\n{\n\n  return 0;\n}\n*/\n\ncFunctionalPeaks::~cFunctionalPeaks()\n{\n}\n\n"
  },
  {
    "path": "src/functionals/functionalPeaks2.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nFunctionals: number of peaks and various measures associated with peaks\nNew and improved algorithm for peak detection, as compared to cFunctionalPeaks component\n\n*/\n\n\n#include <functionals/functionalPeaks2.hpp>\n\n#define MODULE \"cFunctionalPeaks2\"\n\n#define FUNCT_NUMPEAKS          0  // number of peaks\n#define FUNCT_MEANPEAKDIST      1  // mean distance between peaks\n#define FUNCT_MEANPEAKDISTDELTA 2  // mean of difference of consecutive peak distances\n#define FUNCT_PEAKDISTSTDDEV    3  // standard deviation of inter peak distances\n#define FUNCT_PEAKRANGEABS      4  // absolute peak amplitude range (max peak - min peak)\n#define FUNCT_PEAKRANGEREL      5  // peak amplitude range normalised to the input contour's arithmetic mean\n#define FUNCT_PEAKMEAN          6  // arithmetic mean of peak amplitudes\n#define FUNCT_PEAKMEANMEANDIST  7  // arithmetic mean of peak amplitudes - arithmetic mean\n#define FUNCT_PEAKMEANMEANRATIO 8  // arithmetic mean of peak amplitudes / arithmetic mean\n#define FUNCT_PTPAMPMEANABS     9  // mean of peak to peak amplitude differences\n#define FUNCT_PTPAMPMEANREL     10  // mean of peak to peak amplitude differences / arithmetic mean\n#define FUNCT_PTPAMPSTDDEVABS   11  // standard deviation of peak to peak amplitude differences\n#define FUNCT_PTPAMPSTDDEVREL   12  // standard deviation of peak to peak amplitude differences / arithmetic mean\n\n#define FUNCT_MINRANGEABS       13  // absolute minima amplitude range (max peak - min peak)\n#define FUNCT_MINRANGEREL       14  // minima amplitude range normalised to the input contour's arithmetic mean\n#define FUNCT_MINMEAN           15  // arithmetic mean of minima amplitudes\n#define FUNCT_MINMEANMEANDIST   16  // arithmetic mean of minima amplitudes - arithmetic mean\n#define FUNCT_MINMEANMEANRATIO  17  // arithmetic mean of minima amplitudes / arithmetic mean\n#define FUNCT_MTMAMPMEANABS     18  // mean of minima to minima amplitude differences\n#define FUNCT_MTMAMPMEANREL     19  // mean of minima to minima amplitude differences / arithmetic mean\n#define FUNCT_MTMAMPSTDDEVABS   20  // standard deviation of min to min amplitude differences\n#define FUNCT_MTMAMPSTDDEVREL   21  // standard deviation of min to min amplitude differences / arithmetic mean\n\n#define FUNCT_MEANRISINGSLOPE     22\n#define FUNCT_MAXRISINGSLOPE      23\n#define FUNCT_MINRISINGSLOPE      24\n#define FUNCT_STDDEVRISINGSLOPE   25\n\n#define FUNCT_MEANFALLINGSLOPE    26\n#define FUNCT_MAXFALLINGSLOPE     27\n#define FUNCT_MINFALLINGSLOPE     28\n#define FUNCT_STDDEVFALLINGSLOPE  29\n\n#define FUNCT_COVFALLINGSLOPE  30\n#define FUNCT_COVRISINGSLOPE   31\n\n#define N_FUNCTS  32\n\n#define NAMES     \"numPeaks\",\"meanPeakDist\",\"meanPeakDistDelta\",\"peakDistStddev\",\\\n  \"peakRangeAbs\",\"peakRangeRel\",\"peakMeanAbs\",\"peakMeanMeanDist\",\\\n  \"peakMeanRel\",\"ptpAmpMeanAbs\",\"ptpAmpMeanRel\",\"ptpAmpStddevAbs\",\\\n  \"ptpAmpStddevRel\",\"minRangeAbs\",\"minRangeRel\",\"minMeanAbs\",\\\n  \"minMeanMeanDist\",\"minMeanRel\",\"mtmAmpMeanAbs\",\"mtmAmpMeanRel\",\\\n  \"mtmAmpStddevAbs\",\"mtmAmpStddevRel\",\"meanRisingSlope\",\"maxRisingSlope\",\\\n  \"minRisingSlope\",\"stddevRisingSlope\",\"meanFallingSlope\",\"maxFallingSlope\",\\\n  \"minFallingSlope\",\"stddevFallingSlope\",\"covFallingSlope\",\"covRisingSlope\"\n\nconst char *peaks2Names[] = {NAMES};\n\nSMILECOMPONENT_STATICS(cFunctionalPeaks2)\n\nSMILECOMPONENT_REGCOMP(cFunctionalPeaks2)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CFUNCTIONALPEAKS2;\n  sdescription = COMPONENT_DESCRIPTION_CFUNCTIONALPEAKS2;\n\n  // configure your component's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"numPeaks\",\"1/0=enable/disable output of number of peaks (if norm=segment or frame) and rate of peaks per time (1 second) if norm=second.\",0);\n    ct->setField(\"meanPeakDist\",\"1/0=enable/disable output of mean distance between peaks (relative to the input segment length, in seconds, or in frames, see the 'norm' option or the 'masterTimeNorm' option of the cFunctionals parent component)\",0);\n    ct->setField(\"meanPeakDistDelta\",\"1/0=enable/disable output of mean difference between consecutive inter peak distances (relative to the input segment length, in seconds, or in frames, see the 'norm' option or the 'masterTimeNorm' option of the cFunctionals parent component) [NOT YET IMPLEMENTED!]\",0);\n    ct->setField(\"peakDistStddev\",\"1/0=enable/disable output of standard deviation of inter peak distances\",0);\n\n    ct->setField(\"peakRangeAbs\",\"1/0=enable/disable output of peak range (max peak value - min peak value)\",0);\n    ct->setField(\"peakRangeRel\",\"1/0=enable/disable output of peak range (max peak value - min peak value) / arithmetic mean\",0);\n    ct->setField(\"peakMeanAbs\",\"1/0=enable/disable output of arithmetic mean of peaks (local maxima)\",0);\n    ct->setField(\"peakMeanMeanDist\",\"1/0=enable/disable output of arithmetic mean of peaks - arithmetic mean of all values (mean of peaks to signal mean distance)\",0);\n    ct->setField(\"peakMeanRel\",\"1/0=enable/disable output of arithmetic mean of peaks (local maxima) / arithmetic mean of all values (mean of peaks to signal mean ratio ~ peakMeanMeanRatio)\",0);\n    ct->setField(\"ptpAmpMeanAbs\",\"1/0=enable/disable output of mean peak to peak (amplitude) difference\",0);\n    ct->setField(\"ptpAmpMeanRel\",\"1/0=enable/disable output of mean peak to peak (amplitude) difference / range of signal\",0);\n    ct->setField(\"ptpAmpStddevAbs\",\"1/0=enable/disable output of mean peak to peak (amplitude) standard deviation\",0);\n    ct->setField(\"ptpAmpStddevRel\",\"1/0=enable/disable output of mean peak to peak (amplitude) standard deviation / range of signal\",0);\n\n    ct->setField(\"minRangeAbs\",\"1/0=enable/disable output of local minima range (max minmum value - min minimum value)\",0);\n    ct->setField(\"minRangeRel\",\"1/0=enable/disable output of local minima range (max minmum value - min minimum value) / arithmetic mean\",0);\n    ct->setField(\"minMeanAbs\",\"1/0=enable/disable output of arithmetic mean of local minima\",0);\n    ct->setField(\"minMeanMeanDist\",\"1/0=enable/disable output of arithmetic mean of local minima - arithmetic mean of all values\",0);\n    ct->setField(\"minMeanRel\",\"1/0=enable/disable output of arithmetic mean of local minima / arithmetic mean\",0);\n    ct->setField(\"mtmAmpMeanAbs\",\"1/0=enable/disable output of mean minimum to minimum (amplitude) difference\",0);\n    ct->setField(\"mtmAmpMeanRel\",\"1/0=enable/disable output of mean minimum to minimum (amplitude) difference / range of signal\",0);\n    ct->setField(\"mtmAmpStddevAbs\",\"1/0=enable/disable output of mean minimum to minimum (amplitude) standard deviation\",0);\n    ct->setField(\"mtmAmpStddevRel\",\"1/0=enable/disable output of mean minimum to minimum (amplitude) standard deviation / range of signal\",0);\n\n    ct->setField(\"meanRisingSlope\",\"1/0=enable/disable output of the mean of the rising slopes (rising slope is the slope of the line connecting a local minimum (or the beginning of input sample) with the following local maximum/peak or the end of input sample)\",0);\n    ct->setField(\"maxRisingSlope\",\"1/0=enable/disable output of maximum rising slope\",0);\n    ct->setField(\"minRisingSlope\",\"1/0=enable/disable output of minimum rising slope\",0);\n    ct->setField(\"stddevRisingSlope\",\"1/0=enable/disable output of the standard deviation of the rising slopes\",0);\n    ct->setField(\"covRisingSlope\",\"1/0=enable/disable output of the coefficient of variation (std. dev. divided by arithmetic mean) of the rising slopes\",0);\n    ct->setField(\"meanFallingSlope\",\"1/0=enable/disable output of the mean of the falling slopes (falling slope is the slope of the line connecting a local maximum/peak (or the beginning of input sample) with the following local minimum (or the end of input sample))\",0);\n    ct->setField(\"maxFallingSlope\",\"1/0=enable/disable output of maximum falling slope.\",0);\n    ct->setField(\"minFallingSlope\",\"1/0=enable/disable output of minimum falling slope\",0);\n    ct->setField(\"stddevFallingSlope\",\"1/0=enable/disable output of the standard deviation of the falling slopes\",0);\n    ct->setField(\"covFallingSlope\",\"1/0=enable/disable output of the coefficient of variation (std. dev. divided by arithmetic mean) of the falling slopes\",0);\n\n    ct->setField(\"norm\",\"This option specifies how this component should normalise times (if it generates output values related to durations): \\n   'segment' (or: 'turn') : normalise to the range 0..1, the result is the relative length wrt. to the segment length )\\n   'second'  (absolute time in seconds) \\n   'frame' (absolute time in number of frames of input level)\",\"frames\");\n    ct->setField(\"noClearPeakList\", \"1 = don't clear the peak list when a new segment is processed. This should never be used, unless you need compatibility with old (buggy!) behaviour. If you are using a config file with peak2 functionals from before 05. Sept. 2012, you need to enable this option to be compatible with old models and results. \", 0);\n    //TODO?: unified time norm handling for all functionals components: frame, seconds, turn !\n\n    ct->setField(\"absThresh\",\"Gives an absolute threshold for the minimum peak height. Use with caution, use only if you know what you are doing. If this option is not set, relThresh will be used.\",0.0);\n    ct->setField(\"relThresh\",\"Gives the threshold relative to the input contour range, which is used to remove peaks and minimima below this threshold. Valid values: 0..1, a higher value will remove more peaks, while a lower value will keep more and less salient peaks. If not using dynRelThresh=1 you should use a default value of ~0.10 otherwise a default of ~0.35\",0.1);\n    ct->setField(\"dynRelThresh\",\"1/0 = enable disable dynamic relative threshold. Instead of converting the relThresh to an absolute threshold relThresh*range, the threshold is applied as: abs(a/b-1.0) < relThresh , where a is always larger than b.\",0);\n\n    ct->setField(\"posDbgOutp\",\"Filename for debug output of peak positions. The file will be created initially (unless 'posDbgAppend' is set to 1) and values for consecutive input frames will be appended, separated by a '---' marker line.\",(const char *)NULL);\n    ct->setField(\"posDbgAppend\",\"Append to debug ouptut file instead of overwriting it at startup. If the file does not exist, it will be created, even if this option is set to 1.\",0);\n    ct->setField(\"consoleDbg\",\"Debug output of peak positions to console if no output file is given (an output file will override this option).\",0);\n    ct->setField(\"doRatioLimit\", \"(1/0) = yes/no. Apply soft limiting of ratio features (mean relative etc.) in order to avoid high uncontrolled output values if the denominator is close to 0. For strict compatibility with pre 2.2 openSMILE releases (also release candidates 2.2rc1), set it to 0. Default in new versions is 1 (enabled).\", 1);\n  )\n\n  SMILECOMPONENT_MAKEINFO_NODMEM(cFunctionalPeaks2);\n}\n\nSMILECOMPONENT_CREATE(cFunctionalPeaks2)\n\n//-----\n\ncFunctionalPeaks2::cFunctionalPeaks2(const char *_name) :\n  cFunctionalComponent(_name,N_FUNCTS,peaks2Names),\n  enabSlope(0), mmlistFirst(NULL), mmlistLast(NULL), dbg(NULL), consoleDbg(0), useAbsThresh(0),\n  noClearPeakList(0), doRatioLimit_(1)\n{\n}\n\nvoid cFunctionalPeaks2::fetchConfig()\n{\n  parseTimeNormOption();\n  noClearPeakList = getInt(\"noClearPeakList\");\n\n  if (getInt(\"numPeaks\")) enab[FUNCT_NUMPEAKS] = 1;\n  if (getInt(\"meanPeakDist\")) enab[FUNCT_MEANPEAKDIST] = 1;\n  if (getInt(\"meanPeakDistDelta\")) enab[FUNCT_MEANPEAKDISTDELTA] = 1;\n  if (getInt(\"peakDistStddev\")) enab[FUNCT_PEAKDISTSTDDEV] = 1;\n\n  if (getInt(\"peakRangeAbs\")) enab[FUNCT_PEAKRANGEABS] = 1;\n  if (getInt(\"peakRangeRel\")) enab[FUNCT_PEAKRANGEREL] = 1;\n  if (getInt(\"peakMeanAbs\")) enab[FUNCT_PEAKMEAN] = 1;\n  if (getInt(\"peakMeanMeanDist\")) enab[FUNCT_PEAKMEANMEANDIST] = 1;\n  if (getInt(\"peakMeanRel\")) enab[FUNCT_PEAKMEANMEANRATIO] = 1;\n  if (getInt(\"ptpAmpMeanAbs\")) enab[FUNCT_PTPAMPMEANABS] = 1;\n  if (getInt(\"ptpAmpMeanRel\")) enab[FUNCT_PTPAMPMEANREL] = 1;\n  if (getInt(\"ptpAmpStddevAbs\")) enab[FUNCT_PTPAMPSTDDEVABS] = 1;\n  if (getInt(\"ptpAmpStddevRel\")) enab[FUNCT_PTPAMPSTDDEVREL] = 1;\n\n  if (getInt(\"minRangeAbs\")) enab[FUNCT_MINRANGEABS] = 1;\n  if (getInt(\"minRangeRel\")) enab[FUNCT_MINRANGEREL] = 1;\n  if (getInt(\"minMeanAbs\")) enab[FUNCT_MINMEAN] = 1;\n  if (getInt(\"minMeanMeanDist\")) enab[FUNCT_MINMEANMEANDIST] = 1;\n  if (getInt(\"minMeanRel\")) enab[FUNCT_MINMEANMEANRATIO] = 1;\n  if (getInt(\"mtmAmpMeanAbs\")) enab[FUNCT_MTMAMPMEANABS] = 1;\n  if (getInt(\"mtmAmpMeanRel\")) enab[FUNCT_MTMAMPMEANREL] = 1;\n  if (getInt(\"mtmAmpStddevAbs\")) enab[FUNCT_MTMAMPSTDDEVABS] = 1;\n  if (getInt(\"mtmAmpStddevRel\")) enab[FUNCT_MTMAMPSTDDEVREL] = 1;\n\n  if (getInt(\"meanRisingSlope\")) { enab[FUNCT_MEANRISINGSLOPE] = 1; enabSlope = 1; }\n  if (getInt(\"maxRisingSlope\")) { enab[FUNCT_MAXRISINGSLOPE] = 1; enabSlope = 1; }\n  if (getInt(\"minRisingSlope\")) { enab[FUNCT_MINRISINGSLOPE] = 1; enabSlope = 1; }\n  if (getInt(\"stddevRisingSlope\")) { enab[FUNCT_STDDEVRISINGSLOPE] = 1; enabSlope = 1; }\n  if (getInt(\"meanFallingSlope\")) { enab[FUNCT_MEANFALLINGSLOPE] = 1; enabSlope = 1; }\n  if (getInt(\"maxFallingSlope\")) { enab[FUNCT_MAXFALLINGSLOPE] = 1; enabSlope = 1; }\n  if (getInt(\"minFallingSlope\")) { enab[FUNCT_MINFALLINGSLOPE] = 1; enabSlope = 1; }\n  if (getInt(\"stddevFallingSlope\")) { enab[FUNCT_STDDEVFALLINGSLOPE] = 1; enabSlope = 1; }\n  if (getInt(\"covFallingSlope\")) { enab[FUNCT_COVFALLINGSLOPE] = 1; enabSlope = 1; }\n  if (getInt(\"covRisingSlope\")) { enab[FUNCT_COVRISINGSLOPE] = 1; enabSlope = 1; }\n\n  relThresh = (FLOAT_DMEM)getDouble(\"relThresh\");\n  dynRelThresh = getInt(\"dynRelThresh\");\n  if (relThresh < 0) {\n    SMILE_IWRN(1,\"relThresh must be in the range [0..1]!  A value of %f is invalid. Setting to 0.0.\",relThresh);\n    relThresh = 0.0;\n  } else if (relThresh > 1.0 && !dynRelThresh) {\n    SMILE_IWRN(1,\"relThresh must be in the range [0..1]!  A value of %f is invalid. Setting to 1.0.\",relThresh);\n    relThresh = 1.0;\n  }\n\n  if (isSet(\"absThresh\")) {\n    useAbsThresh = 1;\n    absThresh = (FLOAT_DMEM)getDouble(\"absThresh\");\n    if (dynRelThresh) {\n      SMILE_IWRN(1,\"set absThresh overwrites dynRelThresh to 0!\");\n      dynRelThresh = 0;\n    }\n  }\n\n  posDbgOutp = getStr(\"posDbgOutp\");\n  posDbgAppend = getInt(\"posDbgAppend\");\n  consoleDbg = getInt(\"consoleDbg\");\n  doRatioLimit_ = getInt(\"doRatioLimit\");\n\n  cFunctionalComponent::fetchConfig();\n}\n\n\nvoid cFunctionalPeaks2::clearList()\n{\n  while (mmlistFirst != NULL) {\n    struct peakMinMaxListEl * list_next = mmlistFirst->next;\n    free(mmlistFirst);\n    mmlistFirst = list_next;\n  }\n  mmlistFirst = NULL;\n  mmlistLast = NULL;\n}\n\n// add a minimum or maximum to the minmax list\n// 1 = max, 0 = min\nvoid cFunctionalPeaks2::addMinMax(int type, FLOAT_DMEM y, long x)\n{\n  struct peakMinMaxListEl * listEl = (struct peakMinMaxListEl*)malloc(sizeof(struct peakMinMaxListEl));\n  listEl->type = type;\n  listEl->x = x;\n  listEl->y = y;\n  listEl->next = NULL;\n  listEl->prev = NULL;\n\n  if (mmlistFirst == NULL) {\n    mmlistFirst = listEl;\n    mmlistLast = listEl;\n  } else {\n    mmlistLast->next = listEl;\n    listEl->prev = mmlistLast;\n    mmlistLast = listEl;\n  }\n}\n\nvoid cFunctionalPeaks2::removeFromMinMaxList( struct peakMinMaxListEl * listEl )\n{\n  if (listEl->prev != NULL) {\n    listEl->prev->next = listEl->next;\n    if (listEl-> next != NULL) {\n      listEl->next->prev = listEl->prev;\n    } else {\n      mmlistLast = listEl->prev;\n    }\n  } else {\n    mmlistFirst = listEl->next;\n    if (listEl-> next != NULL) {\n      listEl->next->prev = NULL;\n    } else {\n      mmlistLast = NULL;\n    }\n  }\n  //  NOTE: the caller is responsible for freeing the listEl pointer after calling this function\n}\n\nvoid cFunctionalPeaks2::dbgPrintMinMaxList(struct peakMinMaxListEl * listEl)\n{\n  if (dbg != NULL) {\n    fprintf(dbg,\"---\\n\");\n    while (listEl != NULL) {\n      if (listEl->type == 1)\n        fprintf(dbg,\"XXXX_MAX: x=%lld y=%f\\n\",listEl->x,listEl->y);\n      else\n        fprintf(dbg,\"XXXX_MIN: x=%lld y=%f\\n\",listEl->x,listEl->y);\n      listEl = listEl->next;\n    }\n  } else if (consoleDbg) {\n    printf(\"---\\n\");\n    while (listEl != NULL) {\n      if (listEl->type == 1)\n        printf(\"XXXX_MAX: x=%i y=%f\\n\",listEl->x,listEl->y);\n      else\n        printf(\"XXXX_MIN: x=%i y=%f\\n\",listEl->x,listEl->y);\n      listEl = listEl->next;\n    }\n  }\n}\n\nint cFunctionalPeaks2::isBelowThresh(FLOAT_DMEM diff, FLOAT_DMEM base)\n{\n  if (dynRelThresh) {\n\n    if (base == 0.0) {\n      if (diff != 0.0) return 1;\n      else return 0;\n    }\n    if (fabs(diff/base) < relThresh) {\n      return 1;\n    }\n    return 0;\n\n  } else {\n\n    if (diff < absThresh) {\n      return 1;\n    }\n    return 0;\n\n  }\n}\n\nlong cFunctionalPeaks2::process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM min, FLOAT_DMEM max, FLOAT_DMEM mean, FLOAT_DMEM *out, long Nin, long Nout)\n{\n  long i;\n  int n=0;\n  if ((Nin>0)&&(out!=NULL)) {\n    if (posDbgOutp != NULL && dbg == NULL) {\n      if (posDbgAppend) {\n        dbg = fopen(posDbgOutp,\"a\");\n      } else {\n        dbg = fopen(posDbgOutp,\"w\");\n      }\n    }\n\n    /* algorithm:\n     *   1st: detect all local min/max\n         2nd: enforce constraint of minimum rise/fall and discard min/max from list\n         3rd: enforce constraint of alternating min/max (if double candidates, choose the highest/lowest max/min)\n     *\n     */\n\n    // clear peak list from last segment\n    if (noClearPeakList != 1) {\n      clearList();\n    }\n\n    FLOAT_DMEM range = max-min;\n    if (!useAbsThresh) absThresh = relThresh*range;\n\n    // step 1: detect ALL local min/max\n    for (i=2; i<Nin-2; i++) {\n      if (in[i] > in[i-1] && in[i] > in[i+1]) { // max\n        addMinMax(1, in[i], i);\n      } else if (in[i] < in[i-1] && in[i] < in[i+1]) { // min\n        addMinMax(0, in[i], i);\n      }\n    }\n\n\n    // step 2a: enforce constraint of mutual minimum rise/fall and discard small peaks from list\n    struct peakMinMaxListEl * listEl = mmlistFirst;\n    FLOAT_DMEM lastVal = in[0];\n    FLOAT_DMEM lastMin = in[0];\n    FLOAT_DMEM lastMax = in[0];\n    int maxFlag=0, minFlag=0;\n    struct peakMinMaxListEl * lastMaxPtr=NULL;\n    struct peakMinMaxListEl * lastMinPtr=NULL;\n    while (listEl != NULL) { // iterate through list elements\n      int doFree = 0;\n      if (listEl->type == 1) { //max\n        if (isBelowThresh( fabs(listEl->y-lastVal), MIN(listEl->y,lastVal))) {\n          if (isBelowThresh( listEl->y - lastMin, lastMin)) {\n            // discard this item from the list...\n            removeFromMinMaxList(listEl);\n            doFree=1;\n          } else {\n            // next local-global candidate\n            if (listEl->y > lastMax*1.05) {\n              // discard previous max\n              if (lastMaxPtr != NULL) {\n                removeFromMinMaxList(lastMaxPtr);\n                if (lastMaxPtr != listEl) free(lastMaxPtr);\n                else doFree = 1;\n              }\n              lastMax = listEl->y;\n              lastMaxPtr = listEl;\n            } else {\n              if (minFlag) {\n                lastMax = listEl->y;\n                lastMaxPtr = listEl;\n              } else {\n                // discard this, keep last\n                removeFromMinMaxList(listEl);\n                doFree=1;\n              }\n            }\n            maxFlag = 1;\n            minFlag = 0;\n          }\n        } else {\n          // manage the flags and pointers...\n          maxFlag = 1; minFlag = 0;\n          lastMax = listEl->y;\n          lastMaxPtr = listEl;\n        }\n\n      } else if (listEl->type == 0) { //min\n        if (!isBelowThresh( fabs(listEl->y-lastVal), MIN(listEl->y,lastVal))) {\n          // manage the flags and pointers...\n          minFlag = 1; maxFlag = 0;\n          lastMin = listEl->y;\n          lastMinPtr = listEl;\n        }\n\n      }\n      lastVal = listEl->y;\n      struct peakMinMaxListEl * nextPtr =listEl->next;\n      if (doFree) free(listEl);\n      listEl = nextPtr;\n    }\n\n    // step 2b: eliminate small minima\n    listEl = mmlistFirst;\n    lastMax = in[0];\n    while (listEl != NULL) { // iterate through list elements\n      int doFree = 0;\n      if (listEl->type == 0) { //min\n        if (isBelowThresh(lastMax - listEl->y, listEl->y)) {\n          // discard this item from the list...\n          removeFromMinMaxList(listEl);\n          doFree=1;\n        }\n      } else if (listEl->type == 1) { //max\n        lastMax = listEl->y;\n      }\n\n      struct peakMinMaxListEl * nextPtr =listEl->next;\n      if (doFree) free(listEl);\n      listEl = nextPtr;\n    }\n\n    // step 3: eliminate duplicate maxima / minima (i.e. with no min/max in between)\n    listEl = mmlistFirst;\n    lastMax = in[0]; lastMin = in[0];\n    minFlag = 0; maxFlag = 0;\n    int init = 1;\n    while (listEl != NULL) { // iterate through list elements\n      int doFree = 0;\n      if (listEl->type == 0) { //min\n        if (!minFlag || init) { // change of type..\n          lastMin = listEl->y;\n          lastMinPtr = listEl;\n          minFlag = 1;\n          init = 0;\n        } else {\n          if (listEl->y >= lastMin) {\n            // eliminate this one\n            removeFromMinMaxList(listEl);\n            doFree=1;\n          } else {\n           // eliminate the last one , if not the current one\n           if (lastMinPtr != listEl) {\n             removeFromMinMaxList(lastMinPtr);\n             free(lastMinPtr);\n             lastMinPtr = listEl;\n             lastMin = listEl->y;\n           }\n          }\n        }\n      } else if (listEl->type == 1) { //max\n        if (minFlag||init) { // change of type...\n          lastMax = listEl->y;\n          lastMaxPtr = listEl;\n          minFlag = 0;\n          init = 0;\n        } else {\n          if (listEl->y <= lastMax) {\n            // eliminate this one\n            removeFromMinMaxList(listEl);\n            doFree=1;\n          } else {\n           // eliminate the last one , if not the current one\n           if (lastMaxPtr != listEl) {\n             removeFromMinMaxList(lastMaxPtr);\n             free(lastMaxPtr);\n             lastMaxPtr = listEl;\n             lastMax = listEl->y;\n           }\n          }\n        }\n      }\n\n      struct peakMinMaxListEl * nextPtr =listEl->next;\n      if (doFree) free(listEl);\n      listEl = nextPtr;\n    }\n\n    // write peak positions to console or debug file\n    dbgPrintMinMaxList(mmlistFirst);\n//    return 1;\n\n    ////////////////////////////////// now collect statistics\n    FLOAT_DMEM peakMax = (FLOAT_DMEM)0.0, peakMin = (FLOAT_DMEM)0.0;\n    FLOAT_DMEM peakDist = (FLOAT_DMEM)0.0;\n    FLOAT_DMEM peakDiff = (FLOAT_DMEM)0.0;\n    FLOAT_DMEM peakStddevDist = (FLOAT_DMEM)0.0;\n    FLOAT_DMEM peakStddevDiff = (FLOAT_DMEM)0.0;\n    long nPeakDist = 0;\n    FLOAT_DMEM peakMean = (FLOAT_DMEM)0.0;\n    long nPeaks = 0;\n\n    FLOAT_DMEM minMax = (FLOAT_DMEM)0.0, minMin = (FLOAT_DMEM)0.0;\n    FLOAT_DMEM minDist = (FLOAT_DMEM)0.0;\n    FLOAT_DMEM minDiff = (FLOAT_DMEM)0.0;\n    FLOAT_DMEM minStddevDist = (FLOAT_DMEM)0.0;\n    FLOAT_DMEM minStddevDiff = (FLOAT_DMEM)0.0;\n    long nMinDist = 0;\n    FLOAT_DMEM minMean = (FLOAT_DMEM)0.0;\n    long nMins = 0;\n\n    // iterate through list elements, 1st pass computations\n    listEl = mmlistFirst;\n    lastMaxPtr=NULL;\n    lastMinPtr=NULL;\n    while (listEl != NULL) {\n      if (listEl->type == 0) { //min\n        // distances and amp. diff., min/max for range\n        if (lastMinPtr == NULL) {\n          lastMinPtr = listEl;\n          minMin = listEl->y;\n          minMax = listEl->y;\n        } else  {\n          nMinDist++;\n          minDist += (FLOAT_DMEM)(listEl->x - lastMinPtr->x);\n          minDiff += (FLOAT_DMEM)fabs(listEl->y - lastMinPtr->y);\n          if (minMin > listEl->y) minMin = listEl->y;\n          if (minMax < listEl->y) minMax = listEl->y;\n          lastMinPtr = listEl;\n        }\n        // mean\n        minMean += listEl->y;\n        nMins++;\n      } else { //max\n        // distances and amp. diff., min/max for range\n        if (lastMaxPtr == NULL) {\n          lastMaxPtr = listEl;\n          peakMin = listEl->y;\n          peakMax = listEl->y;\n        } else  {\n          nPeakDist++;\n          peakDist += (FLOAT_DMEM)(listEl->x - lastMaxPtr->x);\n          peakDiff += (FLOAT_DMEM)fabs(listEl->y - lastMaxPtr->y);\n          if (peakMin > listEl->y) peakMin = listEl->y;\n          if (peakMax < listEl->y) peakMax = listEl->y;\n          lastMaxPtr = listEl;\n        }\n        // mean\n        peakMean += listEl->y;\n        nPeaks++;\n      }\n\n      struct peakMinMaxListEl * nextPtr =listEl->next;\n      listEl = nextPtr;\n    }\n\n    // mean computation:\n    if (nPeaks > 1) {\n      peakMean /= (FLOAT_DMEM)nPeaks;\n      if (nPeakDist > 1) {\n        peakDist /= (FLOAT_DMEM)nPeakDist;\n        peakDiff /= (FLOAT_DMEM)nPeakDist;\n      }\n    }\n    if (nMins > 0) {\n      minMean /= (FLOAT_DMEM)nMins;\n      if (nMinDist > 1) {\n        minDist /= (FLOAT_DMEM)nMinDist;\n        minDiff /= (FLOAT_DMEM)nMinDist;\n      }\n    }\n\n    // iterate through list elements, 2nd pass computations (stddev)\n    listEl = mmlistFirst;\n    lastMaxPtr=NULL;\n    lastMinPtr=NULL;\n    while (listEl != NULL) {\n      if (listEl->type == 0) { //min\n        // stddev of distances and amp. diffs.\n        if (lastMinPtr == NULL) {\n          lastMinPtr = listEl;\n        } else  {\n          minStddevDist += ((FLOAT_DMEM)(listEl->x - lastMinPtr->x) - minDist) * ((FLOAT_DMEM)(listEl->x - lastMinPtr->x) - minDist);\n          minStddevDiff += ((FLOAT_DMEM)fabs(listEl->y - lastMinPtr->y) - minDiff) * ((FLOAT_DMEM)fabs(listEl->y - lastMinPtr->y) - minDiff);\n          lastMinPtr = listEl;\n        }\n      } else { //max\n        // stddev of distances and amp. diffs.\n        if (lastMaxPtr == NULL) {\n          lastMaxPtr = listEl;\n        } else  {\n          peakStddevDist += ((FLOAT_DMEM)(listEl->x - lastMinPtr->x) - peakDist) * ((FLOAT_DMEM)(listEl->x - lastMinPtr->x) - peakDist);\n          peakStddevDiff += ((FLOAT_DMEM)fabs(listEl->y - lastMinPtr->y) - peakDiff) * ((FLOAT_DMEM)fabs(listEl->y - lastMinPtr->y) - peakDiff);\n          lastMaxPtr = listEl;\n        }\n      }\n\n      struct peakMinMaxListEl * nextPtr =listEl->next;\n      listEl = nextPtr;\n    }\n\n    // normalise stddev:\n    if (nPeakDist > 1) {\n      peakStddevDist /= (FLOAT_DMEM)nPeakDist;\n      peakStddevDiff /= (FLOAT_DMEM)nPeakDist;\n    }\n    if (peakStddevDist > 0.0) peakStddevDist = sqrt(peakStddevDist);\n    else peakStddevDist = 0.0;\n    if (peakStddevDiff > 0.0) peakStddevDiff = sqrt(peakStddevDiff);\n    else peakStddevDiff = 0.0;\n\n    if (nMinDist > 1) {\n      minStddevDist /= (FLOAT_DMEM)nMinDist;\n      minStddevDiff /= (FLOAT_DMEM)nMinDist;\n    }\n    if (minStddevDist > 0.0) minStddevDist = sqrt(minStddevDist);\n    else minStddevDist = 0.0;\n    if (minStddevDiff > 0.0) minStddevDiff = sqrt(minStddevDiff);\n    else minStddevDiff = 0.0;\n\n\n    /// slopes....\n\n    FLOAT_DMEM meanRisingSlope = (FLOAT_DMEM)0.0; int nRising=0;\n    FLOAT_DMEM meanFallingSlope = (FLOAT_DMEM)0.0; int nFalling=0;\n    FLOAT_DMEM minRisingSlope = (FLOAT_DMEM)0.0;\n    FLOAT_DMEM maxRisingSlope = (FLOAT_DMEM)0.0;\n    FLOAT_DMEM minFallingSlope = (FLOAT_DMEM)0.0;\n    FLOAT_DMEM maxFallingSlope = (FLOAT_DMEM)0.0;\n    FLOAT_DMEM stddevRisingSlope = (FLOAT_DMEM)0.0;\n    FLOAT_DMEM stddevFallingSlope = (FLOAT_DMEM)0.0;\n\n    int lastIsMax=-1;\n\n    if (enabSlope) {\n      FLOAT_DMEM T = (FLOAT_DMEM)getInputPeriod();\n      // TODO: T should be controllable by the norm option! Make default backwards compatible...\n      // T = 1 for norm frame\n      // T = input period for form sec  (new default)\n      // T = 1/Nin  for norm segment\n      // TODO: option to discard first and last value as pseudo max/min!!\n      // iterate through list elements, slope statistics computation\n      listEl = mmlistFirst;\n      lastMax = in[0]; long lastMaxPos = 0;\n      lastMin = in[0]; long lastMinPos = 0;\n      while (listEl != NULL) {\n        if (listEl->type == 0) { //min\n          lastMin = listEl->y;\n          lastMinPos = listEl->x;\n          if (lastMinPos - lastMaxPos > 0) {\n            FLOAT_DMEM slope = (lastMax - lastMin)/((FLOAT_DMEM)(lastMinPos - lastMaxPos)*T);\n            meanFallingSlope += slope;\n            if (nFalling == 0) {\n              minFallingSlope = slope;\n              maxFallingSlope = slope;\n            } else {\n              if (slope < minFallingSlope) minFallingSlope = slope;\n              if (slope > maxFallingSlope) maxFallingSlope = slope;\n            }\n            nFalling++; lastIsMax = 0;\n          }\n        } else { //max\n          lastMax = listEl->y;\n          lastMaxPos = listEl->x;\n          if (lastMaxPos - lastMinPos > 0) {\n            FLOAT_DMEM slope = (lastMax - lastMin)/((FLOAT_DMEM)(lastMaxPos - lastMinPos)*T);\n            meanRisingSlope += slope;\n            if (nRising == 0) {\n              minRisingSlope = slope;\n              maxRisingSlope = slope;\n            } else {\n              if (slope < minRisingSlope) minRisingSlope = slope;\n              if (slope > maxRisingSlope) maxRisingSlope = slope;\n            }\n            nRising++; lastIsMax = 1;\n          }\n        }\n\n        struct peakMinMaxListEl * nextPtr =listEl->next;\n        listEl = nextPtr;\n      }\n\n      // compute slope at the end of the input\n      if (lastIsMax==1) {\n        if (Nin - 1 - lastMaxPos > 0) {\n          FLOAT_DMEM slope = (in[Nin-1] - lastMax)/((FLOAT_DMEM)(Nin - 1 - lastMaxPos)*T);\n          meanFallingSlope += slope;\n          if (nFalling == 0) {\n            minFallingSlope = slope;\n            maxFallingSlope = slope;\n          } else {\n            if (slope < minFallingSlope) minFallingSlope = slope;\n            if (slope > maxFallingSlope) maxFallingSlope = slope;\n          }\n          nFalling++;\n        }\n      } else if (lastIsMax==0) {\n        if (Nin - 1 - lastMinPos > 0) {\n          FLOAT_DMEM slope = (in[Nin-1] - lastMin)/((FLOAT_DMEM)(Nin - 1 - lastMinPos)*T);\n          meanRisingSlope += slope;\n          if (nRising == 0) {\n            minRisingSlope = slope;\n            maxRisingSlope = slope;\n          } else {\n            if (slope < minRisingSlope) minRisingSlope = slope;\n            if (slope > maxRisingSlope) maxRisingSlope = slope;\n          }\n          nRising++;\n        }\n      } else if (lastIsMax==-1) {  // no max/min at all...\n        FLOAT_DMEM slope = (in[Nin-1]-in[0])/(FLOAT_DMEM)Nin;\n        if (slope > 0) { meanRisingSlope = maxRisingSlope = minRisingSlope = slope; nRising = 1; }\n        else if (slope < 0) { meanFallingSlope = maxFallingSlope = minFallingSlope = slope; nFalling = 1; }\n      }\n\n      if (nRising > 1) meanRisingSlope /= (FLOAT_DMEM)nRising;\n      if (nFalling > 1) meanFallingSlope /= (FLOAT_DMEM)nFalling;\n\n      // iterate through list elements, slope statistics computation, 2nd pass for stddev\n      listEl = mmlistFirst;\n      lastMax = in[0]; lastMaxPos = 0;\n      lastMin = in[0]; lastMinPos = 0;\n      while (listEl != NULL) {\n        if (listEl->type == 0) { //min\n          lastMin = listEl->y;\n          lastMinPos = listEl->x;\n          if (lastMinPos - lastMaxPos > 0) {\n            FLOAT_DMEM slope = (lastMax - lastMin)/((FLOAT_DMEM)(lastMinPos - lastMaxPos)*T);\n            stddevFallingSlope += (slope-meanFallingSlope)*(slope-meanFallingSlope);\n          }\n        } else { //max\n          lastMax = listEl->y;\n          lastMaxPos = listEl->x;\n          if (lastMaxPos - lastMinPos) {\n            FLOAT_DMEM slope = (lastMax - lastMin)/((FLOAT_DMEM)(lastMaxPos - lastMinPos)*T);\n            stddevRisingSlope += (slope-meanRisingSlope)*(slope-meanRisingSlope);\n          }\n        }\n\n        struct peakMinMaxListEl * nextPtr =listEl->next;\n        listEl = nextPtr;\n      }\n\n      if (nRising > 1) stddevRisingSlope /= (FLOAT_DMEM)nRising;\n      if (nFalling > 1) stddevFallingSlope /= (FLOAT_DMEM)nFalling;\n\n      if (stddevRisingSlope > 0.0) stddevRisingSlope = sqrt(stddevRisingSlope);\n      else stddevRisingSlope = 0.0;\n      if (stddevFallingSlope > 0.0) stddevFallingSlope = sqrt(stddevFallingSlope);\n      else stddevFallingSlope = 0.0;\n    }\n\n    //// normalisation\n    if (timeNorm==TIMENORM_SECONDS) {\n      peakDist *= (FLOAT_DMEM)getInputPeriod();\n      peakStddevDist *= (FLOAT_DMEM)getInputPeriod();\n      minDist *= (FLOAT_DMEM)getInputPeriod();\n      minStddevDist *= (FLOAT_DMEM)getInputPeriod();\n    } else if (timeNorm==TIMENORM_SEGMENT) {\n      peakDist /= (FLOAT_DMEM)Nin;\n      peakStddevDist /= (FLOAT_DMEM)Nin;\n      minDist /= (FLOAT_DMEM)Nin;\n      minStddevDist /= (FLOAT_DMEM)Nin;\n    }\n\n    ///////////// value output\n\n\n    if (enab[FUNCT_NUMPEAKS]) {\n      if (timeNorm == TIMENORM_SECONDS) {\n        out[n++]= ((FLOAT_DMEM)nPeaks) / ((FLOAT_DMEM)Nin * (FLOAT_DMEM)getInputPeriod());\n      } else {\n        out[n++]= (FLOAT_DMEM)nPeaks;\n      }\n    }\n    if (enab[FUNCT_MEANPEAKDIST])\n      out[n++]=peakDist;\n    if (enab[FUNCT_MEANPEAKDISTDELTA])\n      out[n++]=0.0; // TODO!\n    if (enab[FUNCT_PEAKDISTSTDDEV])\n      out[n++]=peakStddevDist;\n    if (enab[FUNCT_PEAKRANGEABS])\n      out[n++]=peakMax-peakMin;\n    if (enab[FUNCT_PEAKRANGEREL]) {\n      if (range != 0.0) {\n        out[n++]=ratioLimitUnity((FLOAT_DMEM)fabs((peakMax-peakMin)/range));\n      } else {\n        out[n++]=peakMax-peakMin;\n      }\n    }\n    if (enab[FUNCT_PEAKMEAN])\n      out[n++]=peakMean;\n    if (enab[FUNCT_PEAKMEANMEANDIST])\n      out[n++]=peakMean - mean;\n    // TODO: better: peakMean / range  ratio !?\n    if (enab[FUNCT_PEAKMEANMEANRATIO]) {\n      if (mean != 0.0) {\n        // we need to limit the range of ratio, because\n        // if mean is near 0 (and peakMean not) it might have\n        // uncontrolled high values\n        // NOTE: only applied if doRatioLimit_ == 1\n        //printf(\"PEAK MEAN = %e, -- mean = %e (N %i)\\n\", peakMean, mean, Nin);\n        out[n++] = ratioLimit(peakMean / mean);\n      } else {\n        // use max of ratio limit in case of mean 0 for continuity\n        // peakMean is alternate value in case of compatibility mode (doRatioLimit_ == 0)\n        out[n++] = ratioLimitMax(peakMean);\n      }\n    }\n    if (enab[FUNCT_PTPAMPMEANABS])\n      out[n++] = peakDiff;\n    if (enab[FUNCT_PTPAMPMEANREL]) {\n      if (range != 0.0) {\n        out[n++] = ratioLimitUnity(peakDiff / range);\n      } else {\n        out[n++] = peakDiff;\n      }\n    }\n    if (enab[FUNCT_PTPAMPSTDDEVABS])\n      out[n++] = peakStddevDiff;\n    if (enab[FUNCT_PTPAMPSTDDEVREL]) {\n      if (range != 0.0) {\n        out[n++] = ratioLimitUnity(peakStddevDiff / range);\n      } else {\n        out[n++] = peakStddevDiff;\n      }\n    }\n\n    if (enab[FUNCT_MINRANGEABS])\n      out[n++] = minMax - minMin;\n    if (enab[FUNCT_MINRANGEREL]) {\n      if (range != 0.0) {\n        out[n++] = ratioLimitUnity((FLOAT_DMEM)fabs((minMax - minMin) / range));\n      } else {\n        out[n++] = minMax - minMin;\n      }\n    }\n    if (enab[FUNCT_MINMEAN])\n      out[n++] = minMean;\n    if (enab[FUNCT_MINMEANMEANDIST]) {\n      out[n++] = mean - minMean;\n    }\n    if (enab[FUNCT_MINMEANMEANRATIO]) {\n      if (mean != 0.0) {\n        out[n++] = ratioLimit(minMean / mean);\n      } else {\n        out[n++] = ratioLimitMax(minMean);\n      }\n    }\n    if (enab[FUNCT_MTMAMPMEANABS])\n      out[n++] = minDiff;\n    if (enab[FUNCT_MTMAMPMEANREL]) {\n      if (range != 0.0) {\n        out[n++] = ratioLimitUnity(minDiff / range);\n      } else {\n        out[n++] = minDiff;\n      }\n    }\n    if (enab[FUNCT_MTMAMPSTDDEVABS])\n      out[n++] = minStddevDiff;\n    if (enab[FUNCT_MTMAMPSTDDEVREL]) {\n      if (range != 0.0) {\n        out[n++] = ratioLimitUnity(minStddevDiff / range);\n      } else {\n        out[n++] = minStddevDiff;\n      }\n    }\n\n    if (enab[FUNCT_MEANRISINGSLOPE])\n      out[n++] = meanRisingSlope;\n    if (enab[FUNCT_MAXRISINGSLOPE])\n      out[n++] = maxRisingSlope;\n    if (enab[FUNCT_MINRISINGSLOPE])\n      out[n++] = minRisingSlope;\n    if (enab[FUNCT_STDDEVRISINGSLOPE])\n      out[n++] = stddevRisingSlope;\n\n    if (enab[FUNCT_MEANFALLINGSLOPE])\n      out[n++] = meanFallingSlope;\n    if (enab[FUNCT_MAXFALLINGSLOPE])\n      out[n++] = maxFallingSlope;\n    if (enab[FUNCT_MINFALLINGSLOPE])\n      out[n++] = minFallingSlope;\n    if (enab[FUNCT_STDDEVFALLINGSLOPE])\n      out[n++] = stddevFallingSlope;\n\n    if (enab[FUNCT_COVFALLINGSLOPE]) {\n      if (meanFallingSlope > (FLOAT_DMEM)0.0) {\n        out[n++] = ratioLimit(stddevFallingSlope / meanFallingSlope);\n      } else {\n        out[n++] = (FLOAT_DMEM)0.0;\n      }\n    }\n    if (enab[FUNCT_COVRISINGSLOPE]) {\n      if (meanRisingSlope > (FLOAT_DMEM)0.0) {\n        out[n++] = ratioLimit(stddevRisingSlope / meanRisingSlope);\n      } else {\n        out[n++] = (FLOAT_DMEM)0.0;\n      }\n    }\n    return n;\n  }\n  return 0;\n}\n\n/*\nlong cFunctionalPeaks2::process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout)\n{\n\n  return 0;\n}\n*/\n\ncFunctionalPeaks2::~cFunctionalPeaks2()\n{\n  // free the local min/max list\n  clearList();\n  if (dbg != NULL) fclose(dbg);\n}\n\n"
  },
  {
    "path": "src/functionals/functionalPercentiles.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctionals: percentiles and quartiles, and inter-percentile/quartile ranges\n\n*/\n\n\n#include <math.h>\n#include <functionals/functionalPercentiles.hpp>\n\n\n#define MODULE \"cFunctionalPercentiles\"\n\n\n#define FUNCT_QUART1        0\n#define FUNCT_QUART2        1\n#define FUNCT_QUART3        2\n#define FUNCT_IQR12         3\n#define FUNCT_IQR23         4\n#define FUNCT_IQR13         5\n#define FUNCT_PERCENTILE    6\n#define FUNCT_PCTLRANGE     7\n#define FUNCT_PCTLQUOT      8\n\n#define N_FUNCTS  9\n\n#define NAMES     \"quartile1\",\"quartile2\",\"quartile3\",\"iqr1-2\",\"iqr2-3\",\"iqr1-3\",\"percentile\",\"pctlrange\",\"pctlquotient\"\n#define IDX_VAR_FUNCTS 6  // start of percentile, pctlrange, etc. arrays of variable length\n\nconst char *percentilesNames[] = {NAMES};  // change variable name to your clas...\n\nSMILECOMPONENT_STATICS(cFunctionalPercentiles)\n\nSMILECOMPONENT_REGCOMP(cFunctionalPercentiles)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CFUNCTIONALPERCENTILES;\n  sdescription = COMPONENT_DESCRIPTION_CFUNCTIONALPERCENTILES;\n\n  // configure your component's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"quartiles\",\"1/0=enable/disable output of all quartiles (overrides individual settings quartile1, quartile2, and quartile3)\", 0);\n    ct->setField(\"quartile1\",\"1/0=enable/disable output of quartile1 (0.25)\",0,0,0);\n    ct->setField(\"quartile2\",\"1/0=enable/disable output of quartile2 (0.50)\",0,0,0);\n    ct->setField(\"quartile3\",\"1/0=enable/disable output of quartile3 (0.75)\",0,0,0);\n    ct->setField(\"iqr\",\"1/0=enable/disable output of all inter-quartile ranges (overrides individual settings iqr12, iqr23, and iqr13)\", 0);\n    ct->setField(\"iqr12\",\"1/0=enable/disable output of inter-quartile range 1-2 (quartile2-quartile1)\",0,0,0);\n    ct->setField(\"iqr23\",\"1/0=enable/disable output of inter-quartile range 2-3 (quartile3-quartile2)\",0,0,0);\n    ct->setField(\"iqr13\",\"1/0=enable/disable output of inter-quartile range 1-3 (quartile3-quartile1)\",0,0,0);\n    ct->setField(\"iqq\",\"1/0=enable/disable output of all inter-quartile quotients (ratios) (overrides individual settings iqq12, iqq23, and iqq13)\", 0);\n    ct->setField(\"iqq12\",\"1/0=enable/disable output of inter-quartile quotient q1/q2\",0,0,0);\n    ct->setField(\"iqq23\",\"1/0=enable/disable output of inter-quartile quotient q2/q3\",0,0,0);\n    ct->setField(\"iqq13\",\"1/0=enable/disable output of inter-quartile quotient q1/q3\",0,0,0);\n\n    ct->setField(\"percentile\",\"Array of p*100 percent percentiles to compute. p = 0..1. Array size indicates the number of total percentiles to compute (excluding quartiles), duplicate entries are not checked for and not removed  : percentile[n] = p (p=0..1)\",0.9,ARRAY_TYPE);\n    ct->setField(\"pctlrange\",\"Array that specifies which inter percentile ranges to compute. A range is specified as 'n1-n2' (where n1 and n2 are the indicies of the percentiles as they appear in the percentile[] array, starting at 0 with the index of the first percentile)\",\"0-1\",ARRAY_TYPE);\n    ct->setField(\"pctlquotient\",\"Array that specifies which inter percentile quotients to compute. A quotient is specified as 'n1-n2' (where n1 and n2 are the indicies of the percentiles as they appear in the percentile[] array, starting at 0 with the index of the first percentile). The quotient is computed as n1/n2.\",\"0-1\",ARRAY_TYPE);\n//    ct->setField(\"quickAlgo\",\"do not sort input, use Dejan's quick estimation method instead\",0);\n    ct->setField(\"interp\",\"If set to 1, percentile values will be linearly interpolated, instead of being rounded to the nearest index in the sorted array\",1);\n     // TOOD: implement quotients!\n  )\n  \n  SMILECOMPONENT_MAKEINFO_NODMEM(cFunctionalPercentiles);\n}\n\nSMILECOMPONENT_CREATE(cFunctionalPercentiles)\n\n//-----\n\ncFunctionalPercentiles::cFunctionalPercentiles(const char *_name) :\n  cFunctionalComponent(_name,N_FUNCTS,percentilesNames),\n  pctl(NULL),\n  pctlr1(NULL), pctlr2(NULL),\n  pctlq1(NULL), pctlq2(NULL),\n  tmpstr(NULL),\n  quickAlgo(0),\n  interp(0),\n  varFctIdx(0)\n{\n}\n\nvoid cFunctionalPercentiles::fetchConfig()\n{\n//  quickAlgo = getInt(\"quickAlgo\");\n  interp = getInt(\"interp\");\n\n  enab[FUNCT_QUART1] = enab[FUNCT_QUART2] = enab[FUNCT_QUART3] = 1;\n  if (getInt(\"quartile1\")) enab[FUNCT_QUART1] = 1;\n  if (getInt(\"quartile2\")) enab[FUNCT_QUART2] = 1;\n  if (getInt(\"quartile3\")) enab[FUNCT_QUART3] = 1;\n  if (isSet(\"quartiles\")) {\n    enab[FUNCT_QUART1] = enab[FUNCT_QUART2] = enab[FUNCT_QUART3] = getInt(\"quartiles\");\n  }\n  \n  enab[FUNCT_IQR12] = enab[FUNCT_IQR23] = enab[FUNCT_IQR13] = 1;\n  if (getInt(\"iqr12\")) enab[FUNCT_IQR12] = 1;\n  if (getInt(\"iqr23\")) enab[FUNCT_IQR23] = 1;\n  if (getInt(\"iqr13\")) enab[FUNCT_IQR13] = 1;\n  if (isSet(\"iqr\")) {\n    enab[FUNCT_IQR12] = enab[FUNCT_IQR23] = enab[FUNCT_IQR13] = getInt(\"iqr\");\n  }\n\n  int i;\n  nPctl = getArraySize(\"percentile\");\n  nPctlRange = getArraySize(\"pctlrange\");\n  nPctlQuot = getArraySize(\"pctlquotient\");\n  if (nPctl > 0) {\n    enab[FUNCT_PERCENTILE] = 1;\n    pctl = (double*)calloc(1,sizeof(double)*nPctl);\n    // load percentile info\n    for (i=0; i<nPctl; i++) {\n      pctl[i] = getDouble_f(myvprint(\"percentile[%i]\",i));\n      if (pctl[i] < 0.0) {\n        SMILE_IWRN(2,\"(inst '%s') percentile[%i] is out of range [0..1] : %f (clipping to 0.0)\",getInstName(),i,pctl[i]);\n        pctl[i] = 0.0;\n      }\n      if (pctl[i] > 1.0) {\n        SMILE_IWRN(2,\"(inst '%s') percentile[%i] is out of range [0..1] : %f (clipping to 1.0)\",getInstName(),i,pctl[i]);\n        pctl[i] = 1.0;\n      }\n    }\n    if (nPctlRange > 0) {\n      enab[FUNCT_PCTLRANGE] = 1;\n      pctlr1 = (int*)calloc(1,sizeof(int)*nPctlRange);\n      pctlr2 = (int*)calloc(1,sizeof(int)*nPctlRange);\n      for (i=0; i<nPctlRange; i++) {\n        char *tmp = strdup(getStr_f(myvprint(\"pctlrange[%i]\",i)));\n        char *orig = strdup(tmp);\n        int l = (int)strlen(tmp);\n        int err=0;\n        // remove spaces and tabs at beginning and end\n//        while ( (l>0)&&((*tmp==' ')||(*tmp=='\\t')) ) { *(tmp++)=0; l--; }\n//        while ( (l>0)&&((tmp[l-1]==' ')||(tmp[l-1]=='\\t')) ) { tmp[l-1]=0; l--; }\n        // find '-'\n        char *s2 = strchr(tmp,'-');\n        if (s2 != NULL) {\n          *(s2++) = 0;\n          char *ep=NULL;\n          int r1 = strtol(tmp,&ep,10);\n          if ((r1==0)&&(ep==tmp)) { err=1; }\n          else if ((r1 < 0)||(r1>=nPctl)) {\n                 SMILE_IERR(1,\"(inst '%s') percentile range [%i] = '%s' (X-Y):: X (=%i) is out of range (allowed: [0..%i])\",getInstName(),i,orig,r1,nPctl);\n               }\n          ep=NULL;\n          int r2 = strtol(s2,&ep,10);\n          if ((r2==0)&&(ep==tmp)) { err=1; }\n          else {\n               if ((r2 < 0)||(r2>=nPctl)) {\n                 SMILE_IERR(1,\"(inst '%s') percentile range [%i] = '%s' (X-Y):: Y (=%i) is out of range (allowed: [0..%i])\",getInstName(),i,orig,r2,nPctl);\n               } else {\n                 if ((r2 == r1)) {\n                   SMILE_IERR(1,\"(inst '%s') percentile range [%i] = '%s' (X-Y):: X must be != Y !!\",getInstName(),i,orig);\n                 }\n               }\n             }\n          if (!err) {\n            pctlr1[i] = r1;\n            pctlr2[i] = r2;\n          }\n        } else { err=1; }\n\n        if (err==1) {\n          COMP_ERR(\"(inst '%s') Error parsing percentile range [%i] = '%s'! (Range must be X-Y, where X and Y are positive integer numbers!)\",getInstName(),i,orig);\n          pctlr1[i] = -1;\n          pctlr2[i] = -1;\n        }\n        free(orig);\n        free(tmp);\n      }\n    }\n    if (nPctlQuot > 0) {\n      enab[FUNCT_PCTLQUOT] = 1;\n      pctlq1 = (int*)calloc(1,sizeof(int)*nPctlQuot);\n      pctlq2 = (int*)calloc(1,sizeof(int)*nPctlQuot);\n      for (i=0; i<nPctlQuot; i++) {\n        char *tmp = strdup(getStr_f(myvprint(\"pctlquotient[%i]\", i)));\n        char *orig = strdup(tmp);\n        int l = (int)strlen(tmp);\n        int err = 0;\n        // remove spaces and tabs at beginning and end\n        //        while ( (l>0)&&((*tmp==' ')||(*tmp=='\\t')) ) { *(tmp++)=0; l--; }\n        //        while ( (l>0)&&((tmp[l-1]==' ')||(tmp[l-1]=='\\t')) ) { tmp[l-1]=0; l--; }\n        // find '-'\n        char *s2 = strchr(tmp,'-');\n        if (s2 != NULL) {\n          *(s2++) = 0;\n          char *ep=NULL;\n          int r1 = strtol(tmp,&ep,10);\n          if ((r1==0)&&(ep==tmp)) {\n            err=1;\n          } else if ((r1 < 0)||(r1>=nPctl)) {\n            SMILE_IERR(1,\"(inst '%s') percentile quotient [%i] = '%s' (X-Y):: X (=%i) is out of range (allowed: [0..%i])\",\n                getInstName(), i, orig, r1, nPctl);\n          }\n          ep = NULL;\n          int r2 = strtol(s2,&ep,10);\n          if ((r2==0)&&(ep==tmp)) {\n            err=1;\n          } else {\n            if ((r2 < 0)||(r2>=nPctl)) {\n              SMILE_IERR(1,\"(inst '%s') percentile quotient [%i] = '%s' (X-Y):: Y (=%i) is out of range (allowed: [0..%i])\",\n                  getInstName(),i,orig,r2,nPctl);\n            } else {\n              if ((r2 == r1)) {\n                SMILE_IERR(1,\"(inst '%s') percentile quotient [%i] = '%s' (X-Y):: X must be != Y !!\",\n                    getInstName(),i,orig);\n              }\n            }\n          }\n          if (!err) {\n            pctlq1[i] = r1;\n            pctlq2[i] = r2;\n          }\n        } else { err=1; }\n\n        if (err==1) {\n          COMP_ERR(\"(inst '%s') Error parsing percentile quotient [%i] = '%s'! (Quotient range must be X-Y, where X and Y are positive integer numbers!)\",\n              getInstName(),i,orig);\n          pctlq1[i] = -1;\n          pctlq2[i] = -1;\n        }\n        free(orig);\n        free(tmp);\n      }\n    }\n  }\n\n  cFunctionalComponent::fetchConfig();\n  if (enab[FUNCT_PERCENTILE])\n    nEnab += nPctl-1;\n  if (enab[FUNCT_PCTLRANGE])\n    nEnab += nPctlRange-1;\n  if (enab[FUNCT_PCTLQUOT])\n      nEnab += nPctlQuot-1;\n\n  // compute new var index:\n  varFctIdx = 0;\n  for (i=0; i<IDX_VAR_FUNCTS; i++) {\n    if (enab[i]) varFctIdx++;\n  }\n}\n\nconst char* cFunctionalPercentiles::getValueName(long i)\n{\n  if (i<varFctIdx) {\n    return cFunctionalComponent::getValueName(i);\n  }\n  if (i>=varFctIdx) {\n    int j=varFctIdx;\n    int pr=0;\n    // check, if percentile or pctlrange is referenced:\n    i -= varFctIdx;\n    if (i>=nPctl) {\n      j++;\n      i-= nPctl;\n      pr = 1;\n      if (i >= nPctlRange) {\n        i -= nPctlRange;\n        j++;\n      }\n    }\n    const char *n = cFunctionalComponent::getValueName(j);\n    // append [i]\n    if (tmpstr != NULL) free(tmpstr);\n    if (!pr) {\n      tmpstr = myvprint(\"%s%.1f\",n,pctl[i]*100.0);\n    } else {\n      if (i >= nPctlRange) {\n        tmpstr = myvprint(\"%s%i-%i\",n,pctlq1[i],pctlq2[i]);\n      } else {\n        tmpstr = myvprint(\"%s%i-%i\",n,pctlr1[i],pctlr2[i]);\n      }\n    }\n    return tmpstr;\n  }\n  return \"UNDEF\";\n}\n\n// convert percentile to absolute index\nlong cFunctionalPercentiles::getPctlIdx(double p, long N)\n{\n  long ret = (long)round(p*(double)(N-1));\n  if (ret<0) return 0;\n  if (ret>=N) return N-1;\n  return ret;\n}\n\n// get linearly interpolated percentile\nFLOAT_DMEM cFunctionalPercentiles::getInterpPctl(double p, FLOAT_DMEM *sorted, long N)\n{\n  double idx = p*(double)(N-1);\n  long i1,i2;\n  i1=(long)floor(idx);\n  i2=(long)ceil(idx);\n  if (i1<0) i1=0;\n  if (i2<0) i2=0;\n  if (i1>=N) i1=N-1;\n  if (i2>=N) i2=N-1;\n  if (i1!=i2) {\n    double w1,w2;\n    w1 = idx-(double)i1;\n    w2 = (double)i2 - idx;\n    return sorted[i1]*(FLOAT_DMEM)w2 + sorted[i2]*(FLOAT_DMEM)w1;\n  } else {\n    return sorted[i1];\n  }\n}\n\nlong cFunctionalPercentiles::process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM *out, long Nin, long Nout)\n{\n  long i;\n  if ((Nin>0)&&(out!=NULL)) {\n    int n=0;\n    FLOAT_DMEM q1, q2, q3;\n\n    if (quickAlgo) {\n      // Not yet implemented....\n      /*\n      // use *in array...\n\n      //find min/max:\n      FLOAT_DMEM *in0 = in;\n      FLOAT_DMEM *inE = in+Nin;\n      FLOAT_DMEM max = *in;\n      FLOAT_DMEM min = *in;\n      while (in<inE) {\n        if (*in < min) min = *in;\n        if (*in > max) max = *(in++);\n      }\n      \n      //create range buffers:\n      long oversample = 10;\n      long nBins = Nin * oversample;\n      FLOAT_DMEM unit = (max-min)/(FLOAT_DMEM)nBins;\n      long *bins = (long*)calloc(1,sizeof(long)*nBins);\n\n      in=in0;\n      FLOAT_DMEM cunit = min;\n      for (i=0; i<Nin; i++) {\n//NO!! compute bin index from value!        if ((*in > cuint)&&(*in < cuint+unit)) { bins[i]++; }\n        FLOAT_DMEM idx = (*in-min)/unit;\n        bins\n        in++; cunit += unit;\n      }\n      \n      // we need all required percentiles (sorted! wiht corresp. indicies) in an array.\n\n\n\n      free(bins);\n      */\n    } else {\n      long minpos=0, maxpos=0;\n      if (inSorted == NULL) {\n        SMILE_ERR(1,\"(inst '%s') expected sorted input, however got NULL!\",getInstName());\n      }\n      // quartiles:\n      if (interp) {\n        q1 = getInterpPctl(0.25,inSorted,Nin);\n        q2 = getInterpPctl(0.50,inSorted,Nin);\n        q3 = getInterpPctl(0.75,inSorted,Nin);\n      } else {\n        q1 = inSorted[getPctlIdx(0.25,Nin)];\n        q2 = inSorted[getPctlIdx(0.50,Nin)];\n        q3 = inSorted[getPctlIdx(0.75,Nin)];\n      }\n      if (enab[FUNCT_QUART1]) out[n++]=q1;\n      if (enab[FUNCT_QUART2]) out[n++]=q2;\n      if (enab[FUNCT_QUART3]) out[n++]=q3;\n      if (enab[FUNCT_IQR12]) out[n++]=q2-q1;\n      if (enab[FUNCT_IQR23]) out[n++]=q3-q2;\n      if (enab[FUNCT_IQR13]) out[n++]=q3-q1;\n\n      // percentiles\n      if ((enab[FUNCT_PERCENTILE])||(enab[FUNCT_PCTLRANGE])||(enab[FUNCT_PCTLQUOT])) {\n        int n0 = n; // start of percentiles array (used later for computation of pctlranges)\n        if (interp) {\n          for (i=0; i<nPctl; i++) {\n            out[n++] = getInterpPctl(pctl[i],inSorted,Nin);\n          }\n        } else {\n          for (i=0; i<nPctl; i++) {\n            out[n++] = inSorted[getPctlIdx(pctl[i],Nin)];\n          }\n        }\n        if (enab[FUNCT_PCTLRANGE]) {\n          for (i=0; i<nPctlRange; i++) {\n            if ((pctlr1[i]>=0)&&(pctlr2[i]>=0)) {\n              out[n++] = fabs(out[n0+pctlr2[i]] - out[n0+pctlr1[i]]);\n            } else { out[n++] = 0.0; }\n          }\n        }\n        if (enab[FUNCT_PCTLRANGE]) {\n          for (i = 0; i < nPctlQuot; i++) {\n            if ((pctlq1[i] >= 0) && (pctlq2[i] >= 0) && (out[n0+pctlq1[i]] != 0.0)) {\n              out[n++] = smileMath_ratioLimit(out[n0+pctlq1[i]] / out[n0+pctlq2[i]],\n                  50.0, 100.0);\n            } else {\n              out[n++] = 0.0;\n            }\n          }\n        }\n      }\n    }\n\n    return n;\n  }\n  return 0;\n}\n\n/*\nlong cFunctionalPercentiles::process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout)\n{\n\n  return 0;\n}\n*/\n\ncFunctionalPercentiles::~cFunctionalPercentiles()\n{\n  if(pctl!=NULL) free(pctl);\n  if(pctlr1!=NULL) free(pctlr1);\n  if(pctlr2!=NULL) free(pctlr2);\n  if(tmpstr!=NULL) free(tmpstr);\n}\n\n"
  },
  {
    "path": "src/functionals/functionalRegression.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctionals: linear and quadratic regression coefficients\n\n*/\n\n\n#include <functionals/functionalRegression.hpp>\n\n#define MODULE \"cFunctionalRegression\"\n\n\n#define FUNCT_LINREGC1     0\n#define FUNCT_LINREGC2     1\n#define FUNCT_LINREGERRA   2\n#define FUNCT_LINREGERRQ   3\n#define FUNCT_QREGC1       4\n#define FUNCT_QREGC2       5\n#define FUNCT_QREGC3       6\n#define FUNCT_QREGERRA     7\n#define FUNCT_QREGERRQ     8\n#define FUNCT_CENTROID     9\n#define FUNCT_QREGLS       10  // left slope of parabola\n#define FUNCT_QREGRS       11  // right slope of parabola\n#define FUNCT_QREGX0       12  // vertex coordinates\n#define FUNCT_QREGY0       13  // vertex coordinates\n//#define FUNCT_QREGYL       14  // left value (t=0) of parabola  == qregc3 !!\n#define FUNCT_QREGYR       14  // right value (t=Nin) of parabola\n\n#define FUNCT_QREGY0NN    15  // vertex y coordinate, not normalised\n#define FUNCT_QREGC3NN    16  // qregc3, not normalised\n#define FUNCT_QREGYRNN    17  // not normalised\n\n#define N_FUNCTS  18\n\n#define NAMES  \"linregc1\",\"linregc2\",\"linregerrA\",\"linregerrQ\",\"qregc1\",\"qregc2\",\"qregc3\",\"qregerrA\",\"qregerrQ\",\"centroid\",\"qregls\",\"qregrs\",\"qregx0\",\"qregy0\",\"qregyr\",\"qregy0nn\",\"qregc3nn\",\"qregyrnn\"\n\nconst char *regressionNames[] = {NAMES};  // change variable name to your clas...\n\nSMILECOMPONENT_STATICS(cFunctionalRegression)\n\nSMILECOMPONENT_REGCOMP(cFunctionalRegression)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  \n  scname = COMPONENT_NAME_CFUNCTIONALREGRESSION;\n  sdescription = COMPONENT_DESCRIPTION_CFUNCTIONALREGRESSION;\n\n  // configure your component's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"linregc1\",\"1/0=enable/disable output of slope m (linear regression line)\",1);\n    ct->setField(\"linregc2\",\"1/0=enable/disable output of offset t (linear regression line)\",1);\n    ct->setField(\"linregerrA\",\"1/0=enable/disable output of linear error between contour and linear regression line\",1);\n    ct->setField(\"linregerrQ\",\"1/0=enable/disable output of quadratic error between contour and linear regression line\",1);\n    ct->setField(\"qregc1\",\"1/0=enable/disable output of quadratic regression coefficient 1 (a)\",1);\n    ct->setField(\"qregc2\",\"1/0=enable/disable output of quadratic regression coefficient 2 (b)\",1);\n    ct->setField(\"qregc3\",\"1/0=enable/disable output of quadratic regression coefficient 3 (c = offset)\",1);\n    ct->setField(\"qregerrA\",\"1/0=enable/disable output of linear error between contour and quadratic regression line (parabola)\",1);\n    ct->setField(\"qregerrQ\",\"1/0=enable/disable output of quadratic error between contour and quadratic regression line (parabola)\",1);\n    ct->setField(\"centroid\",\"1/0=enable/disable output of centroid of contour (this is computed as a by-product of the regression coefficients).\",1);\n    ct->setField(\"centroidNorm\",\"normalise time-scale of centroid to time in seconds (seconds), frame index (frame), or relative segment percentage (segment).\", \"segment\");\n    ct->setField(\"centroidUseAbsValues\", \"1/0=enable/disable. Use absolute values when computing temporal centroid. Default in pre 2.2 versions was 0. In 2.2 the default changes to 1!\", 1);\n    ct->setField(\"centroidRatioLimit\", \"(1/0) = yes/no. Apply soft limiting of centroid to valid (segment range) in order to avoid high uncontrolled output values if the denominator (absolute mean of values) is close to 0. For strict compatibility with pre 2.2 openSMILE releases (also release candidates 2.2rc1), set it to 0. Default in new versions is 1 (enabled).\", 1);\n    ct->setField(\"qregls\",\"1/0=enable/disable output of left slope of parabola (slope of the line from first point on the parabola at t=0 to the vertex).\",0);\n    ct->setField(\"qregrs\",\"1/0=enable/disable output of right slope of parabola (slope of the line from the vertex to the last point on the parabola at t=N).\",0);\n    ct->setField(\"qregx0\",\"1/0=enable/disable output of x coordinate of the parabola vertex (since for very flat parabolas this can be very large/small, it is clipped to range -Nin - +Nin ).\",0);\n    ct->setField(\"qregy0\",\"1/0=enable/disable output of y coordinate of the parabola vertex.\",0);\n    ct->setField(\"qregyr\",\"1/0=enable/disable output of y coordinate of the last point on the parabola (t=N).\",0);\n    ct->setField(\"qregy0nn\",\"1/0=enable/disable output of y coordinate of the parabola vertex. This value is unnormalised, regardless of value of normInput.\",0);\n    ct->setField(\"qregc3nn\",\"1/0=enable/disable output of y coordinate of the first point on the parabola (t=0). This value is unnormalised, regardless of value of normInput.\",0);\n    ct->setField(\"qregyrnn\",\"1/0=enable/disable output of y coordinate of the last point on the parabola (t=N). This value is unnormalised, regardless of value of normInput.\",0);\n\n    ct->setField(\"normRegCoeff\",\"If > 0, do normalisation of regression coefficients, slopes, and coordinates on the time scale.\\n  If == 1 (segment relative scaling), the coefficients are scaled (multiplied by the contour length) so that a regression line or parabola approximating the contour can be plotted over an x-axis range from 0 to 1, i.e. this makes the coefficients independent of the contour length (a longer contour with a lower slope will then have the same 'm' (slope) linear regression coefficient as a shorter but steeper slope).\\n  If == 2, normalisation of time scale to the units of seconds, i.e. slope is value_delta/second.\\n  Note: The unnormalised slope is value_delta/timestep.\", 0);\n    ct->setField(\"normInputs\",\"1/0=enable/disable normalisation of regression coefficients, coordinates, and regression errors on the value scale. If enabled all input values will be normalised to the range 0..1. Use this in conjunction with normRegCoeff.\",0);\n    ct->setField(\"oldBuggyQerr\",\"Set this to 1 (default) to output the (input lengthwise) unnormalised quadratic regression errors (if qregerr* == 1) for compatibility with older feature sets. In new setups you should always change from the default to 0 to enable the proper scaling of the quadratic error!\",1);\n    ct->setField(\"doRatioLimit\", \"(1/0) = yes/no. Apply soft limiting of ratio features (slopes etc.) in order to avoid high uncontrolled output values if the denominator is close to 0. For strict compatibility with pre 2.2 openSMILE releases (also release candidates 2.2rc1), set it to 0 (current default)\", 0);\n  )\n\n  SMILECOMPONENT_MAKEINFO_NODMEM(cFunctionalRegression);\n}\n\nSMILECOMPONENT_CREATE(cFunctionalRegression)\n\n//-----\n\ncFunctionalRegression::cFunctionalRegression(const char *_name) :\n  cFunctionalComponent(_name,N_FUNCTS,regressionNames),\n  enQreg(0)\n{\n}\n\nvoid cFunctionalRegression::fetchConfig()\n{\n  if (getInt(\"linregc1\")) enab[FUNCT_LINREGC1] = 1;\n  if (getInt(\"linregc2\")) enab[FUNCT_LINREGC2] = 1;\n  if (getInt(\"linregerrA\")) enab[FUNCT_LINREGERRA] = 1;\n  if (getInt(\"linregerrQ\")) enab[FUNCT_LINREGERRQ] = 1;\n  if (getInt(\"qregc1\")) { enab[FUNCT_QREGC1] = 1; enQreg=1; }\n  if (getInt(\"qregc2\")) { enab[FUNCT_QREGC2] = 1; enQreg=1; }\n  if (getInt(\"qregc3\")) { enab[FUNCT_QREGC3] = 1; enQreg=1; }\n  if (getInt(\"qregerrA\")) { enab[FUNCT_QREGERRA] = 1; enQreg=1; }\n  if (getInt(\"qregerrQ\")) { enab[FUNCT_QREGERRQ] = 1; enQreg=1; }\n  if (getInt(\"centroid\")) { enab[FUNCT_CENTROID] = 1; enQreg=1; }\n  if (getInt(\"qregls\")) { enab[FUNCT_QREGLS] = 1; enQreg=1; }\n  if (getInt(\"qregrs\")) { enab[FUNCT_QREGRS] = 1; enQreg=1; }\n  if (getInt(\"qregx0\")) { enab[FUNCT_QREGX0] = 1; enQreg=1; }\n  if (getInt(\"qregy0\")) { enab[FUNCT_QREGY0] = 1; enQreg=1; }\n  if (getInt(\"qregyr\")) { enab[FUNCT_QREGYR] = 1; enQreg=1; }\n  if (getInt(\"qregy0nn\")) { enab[FUNCT_QREGY0NN] = 1; enQreg=1; }\n  if (getInt(\"qregc3nn\")) { enab[FUNCT_QREGC3NN] = 1; enQreg=1; }\n  if (getInt(\"qregyrnn\")) { enab[FUNCT_QREGYRNN] = 1; enQreg=1; }\n  const char *centrNorm = getStr(\"centroidNorm\");\n  if (!strncmp(centrNorm, \"sec\", 3)) {\n    centroidNorm = TIMENORM_SECONDS;\n  } else if (!strncmp(centrNorm, \"fra\", 3)) {\n    centroidNorm = TIMENORM_FRAMES;\n  } else if (!strncmp(centrNorm, \"seg\", 3)) {\n    centroidNorm = TIMENORM_SEGMENT;\n  } else {\n    SMILE_IERR(1, \"unknown value for option 'centroidNorm' (%s). Allowed values are: fra(mes), seg(ments), sec(onds)\", centrNorm);\n  }\n  normRegCoeff = getInt(\"normRegCoeff\");\n  normInputs = getInt(\"normInputs\");\n  centroidUseAbsValues_ = getInt(\"centroidUseAbsValues\");\n  centroidRatioLimit_ = getInt(\"centroidRatioLimit\");\n  doRatioLimit_ = getInt(\"doRatioLimit\");\n  oldBuggyQerr = getInt(\"oldBuggyQerr\");\n\n  cFunctionalComponent::fetchConfig();\n}\n\nlong cFunctionalRegression::process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted,\n    FLOAT_DMEM min, FLOAT_DMEM max, FLOAT_DMEM mean, FLOAT_DMEM *out, long Nin, long Nout)\n{\n  if ((Nin>0)&&(out!=NULL)) {\n    //compute centroid\n    FLOAT_DMEM *iE = in + Nin;\n    FLOAT_DMEM *i0 = in;\n    double Nind = (double)Nin;\n    double range = max-min;\n    double rangeInv;\n    if (range <= 0.0) {\n      range = 1.0;\n      rangeInv = 0.0;\n    } else {\n      rangeInv = 1.0/range;\n    }\n\n    double num = 0.0;\n    double numAbs = 0.0;\n    double num2 = 0.0;\n    double num2Abs = 0.0;\n    double tmp = 0.0;\n    double ii = 0.0;\n    double asumAbs = 0.0;\n    double asum = mean * Nind;\n    if (centroidUseAbsValues_) {\n      while (in<iE) {\n        asumAbs += (double)fabs(*(in));\n        tmp = (double)(fabs(*(in))) * ii;\n        numAbs += tmp;\n        tmp *= ii;\n  //      ii += 1.0;\n        num2Abs += tmp;\n        tmp = (double)(*(in++)) * ii;\n        num += tmp;\n        tmp *= ii;\n        ii += 1.0;\n        num2 += tmp;\n      }\n    } else {\n      while (in<iE) {\n        tmp = (double)(*(in++)) * ii;\n        num += tmp;\n        tmp *= ii;\n        ii += 1.0;\n        num2 += tmp;\n      }\n    }\n\n    double centroid;\n    if (centroidUseAbsValues_) {\n      if (asumAbs != 0.0) {\n        centroid = numAbs / asumAbs;\n      } else {\n        centroid = 0.0;\n      }\n    } else {\n      if (asum != 0.0) {\n        centroid = num / asum;\n      } else {\n        centroid = 0.0;\n      }\n    }\n    if (centroidRatioLimit_) {\n      centroid = (double)smileMath_ratioLimit((FLOAT_DMEM)(centroid), \n        (FLOAT_DMEM)Nind, (FLOAT_DMEM)Nind);\n    }\n\n    if (centroidNorm == TIMENORM_SECONDS) {\n      centroid *= getInputPeriod();\n    } else if (centroidNorm == TIMENORM_SEGMENT) {\n      centroid /= Nind;\n    }\n    in=i0;\n\n    \n    double m=0.0,t=0.0,leq=0.0,lea=0.0;\n    double a=0.0,b=0.0,c=0.0,qeq=0.0,qea=0.0;\n    double S1,S2,S3,S4;\n    if (Nin > 1) {\n      // LINEAR REGRESSION:\n/*\n      S1 = (Nind-1.0)*Nind/2.0;  // sum of all i=0..N-1\n      S2 = (Nind-1.0)*Nind*(2.0*Nind-1.0)/6.0; // sum of all i^2 for i=0..N-1\n                                              // num: if sum of y_i*i for all i=0..N-1\n      t = ( asum - num*S1/S2) / ( Nind - S1*S1/S2 );\n      m = ( num - t * S1 ) / S2;\n*/ // optimised computation:\n      double NNm1 = (Nind)*(Nind-(double)1.0);\n\n      S1 = NNm1/(double)2.0;  // sum of all i=0..N-1\n      S2 = NNm1*((double)2.0*Nind-(double)1.0)/(double)6.0; // sum of all i^2 for i=0..N-1\n\n      // check!\n      double S1dS2 = S1/S2;\n      double tmp = ( Nind - S1*S1dS2 );\n      if (tmp == 0.0) t = 0.0;\n      else t = ( asum - num*S1dS2) / tmp;\n      m = ( num - t * S1 ) / S2;\n\n      // TEST: temporary only: compare with\n      // smileMath_getLinearRegressionLine(FLOAT_DMEM *x, long N, FLOAT_DMEM *b)\n      //FLOAT_DMEM bNew = 0.0;\n      //FLOAT_DMEM mNew = smileMath_getLinearRegressionLine(i0, Nin, &bNew);\n      //SMILE_IMSG(3, \"bNew = %.4f , bOld = %.4f -- mNew = %.4f , mOld = %.4f (min %.4f, max %.4f)\", bNew, t, mNew, m, min, max);\n\n      S3 = S1*S1;\n      double Nind1 = Nind-(double)1.0;\n      S4 = S2 * ((double)3.0*(Nind1*Nind1 + Nind1)-(double)1.0) / (double)5.0;\n\n      // QUADRATIC REGRESSION:\n      if (enQreg) {\n\n        double det;\n        double S3S3 = S3*S3;\n        double S2S2 = S2*S2;\n        double S1S2 = S1*S2;\n        double S1S1 = S3;\n        det = S4*S2*Nind + (double)2.0*S3*S1S2 - S2S2*S2 - S3S3*Nind - S1S1*S4;\n\n        if (det != 0.0) {\n          a = ( (S2*Nind - S1S1)*num2 + (S1S2 - S3*Nind)*num + (S3*S1 - S2S2)*asum ) / det;\n          b = ( (S1S2 - S3*Nind)*num2 + (S4*Nind - S2S2)*num + (S3*S2 - S4*S1)*asum ) / det;\n          c = ( (S3*S1 - S2S2)*num2 + (S3*S2-S4*S1)*num + (S4*S2 - S3S3)*asum ) / det;\n        } else {\n          a=0.0; b=0.0; c=0.0;\n        }\n\n      }\n//    printf(\"nind:%f  S1=%f,  S2=%f  S3=%f  S4=%f  num2=%f  num=%f  asum=%f t=%f\\n\",Nind,S1,S2,S3,S4,num2,num,asum,t);\n    } else {\n      m = 0; t=c=*in;\n      a = 0.0; b=0.0;\n    }\n    \n    // linear regression error:\n    ii=0.0; double e;\n    while (in<iE) {\n      e = (double)(*(in++)) - (m*ii + t);\n      if (normInputs) e *= rangeInv;\n      lea += fabs(e);\n      ii += 1.0;\n      leq += e*e;\n    }\n    in=i0;\n\n    double rs=0.0, ls=0.0;\n    double x0=0.0, y0=0.0;\n    double yr=0.0;\n    double yrnn=0.0, c3nn=0.0;\n    double x0nn=0.0, y0nn=0.0;\n\n    // quadratic regresssion error:\n    if (enQreg) {\n      ii=0.0; double e;\n      while (in<iE) {\n        e = (double)(*(in++)) - (a*ii*ii + b*ii + c);\n        if (normInputs) e *= rangeInv;\n        qea += fabs(e);\n        ii += 1.0;\n        qeq += e*e;\n      }\n      in=i0;\n\n      // parabola vertex (x coordinate clipped to range -Nind + Nind!)  // TODO: why -Nind?\n      x0 = b/(-2.0*a);\n      if (x0 < -1.0*Nind) x0 = -Nind;\n      if (x0 > Nind) x0 = Nind;\n      if (!finite(x0)) x0 = Nind;\n      x0nn = x0;\n      y0 = c - b*b/(4.0*a);  // TODO: also limit to range 0..Nind\n      if (!finite(y0)) y0 = 0.0;\n      y0nn = y0;\n\n      // parabola left / right points\n      yrnn = yr = a * (Nind-1.0)*(Nind-1.0) + b*(Nind-1.0) + c;\n      if (!finite(yr)) { yr = 0.0; yrnn = 0.0; }\n      c3nn = c;\n    }\n\n    int n=0;\n    double NOneSec = 1.0;\n    if (normRegCoeff == 2)\n      NOneSec = 1.0 / getInputPeriod();\n    \n    if (doRatioLimit_) {\n      m = smileMath_ratioLimit((FLOAT_DMEM)m, (FLOAT_DMEM)(range/10.0), \n        (FLOAT_DMEM)(range/10.0 + 0.01));\n      a = smileMath_ratioLimit((FLOAT_DMEM)a, (FLOAT_DMEM)(sqrt(range/10.0)), \n        (FLOAT_DMEM)(sqrt(range/10.0) + 0.01));\n      b = smileMath_ratioLimit((FLOAT_DMEM)b, (FLOAT_DMEM)(range/10.0), \n        (FLOAT_DMEM)(range/10.0 + 0.01));\n    }\n    if (normRegCoeff == 1) {  // normalise to segment\n      m *= Nind-1.0;\n      a *= (Nind-1.0)*(Nind-1.0);\n      b *= Nind-1.0;\n      if (Nind != 1.0)\n        x0 /= Nind-1.0;\n      else\n        x0 = 0.0;\n    }\n    else if (normRegCoeff == 2) {  // normalise to seconds\n      m *= NOneSec;\n      a *= NOneSec * NOneSec;\n      b *= NOneSec;\n      if (NOneSec != 1.0)\n        x0 /= NOneSec;\n      else\n        x0 = 0.0;\n    }\n    if (normInputs) {\n      m *= rangeInv;\n      t = (t - min) * rangeInv;\n      a *= rangeInv;\n      b *= rangeInv;\n      c = (c - min) * rangeInv;\n      y0 = (y0 - min) * rangeInv;\n      yr = (yr - min) * rangeInv;\n    }\n\n    if (enQreg) {\n      // parabola partial slopes\n      // TODO: check behaviour if vertex is outside of current window\n      if (x0 > 0)\n        ls = (y0 - c) / x0;\n      if (normRegCoeff == 1) {\n        if (x0 < 1.0)\n          rs = (yr - y0) / (1.0 - x0);\n      } else if (normRegCoeff == 2) {\n        double len_t = (Nind - 1.0) / NOneSec;\n        if (x0 < len_t)\n          rs = (yr - y0)/(len_t - x0);\n      } else {\n        if (x0 < Nind - 1.0)\n          rs = (yr - y0) / (Nind - 1.0 - x0);\n      }\n    }\n\n    // security checks:\n    if (!finite(m)) m = 0.0;\n    if (!finite(t)) t = 0.0;\n    if (!finite(lea/Nind)) lea = 0.0;\n    if (!finite(leq/Nind)) leq = 0.0;\n    if (!finite(a)) a = 0.0;\n    if (!finite(b)) b = 0.0;\n    if (!finite(c)) { c = 0.0; c3nn = 0.0; }\n    if (!finite(ls)) ls = 0.0;\n    if (!finite(rs)) rs = 0.0;\n    if (!finite(qea/Nind)) qea = 0.0;\n    if (!finite(qeq/Nind)) qeq = 0.0;\n    if (!finite(centroid)) centroid = 0.0;\n\n    // save values:\n    if (enab[FUNCT_LINREGC1]) out[n++]=(FLOAT_DMEM)m;\n    if (enab[FUNCT_LINREGC2]) out[n++]=(FLOAT_DMEM)t;\n    if (enab[FUNCT_LINREGERRA]) out[n++]=(FLOAT_DMEM)(lea/Nind);\n    if (enab[FUNCT_LINREGERRQ]) out[n++]=(FLOAT_DMEM)(leq/Nind);\n\n    if (enab[FUNCT_QREGC1]) out[n++]=(FLOAT_DMEM)a;\n    if (enab[FUNCT_QREGC2]) out[n++]=(FLOAT_DMEM)b;\n    if (enab[FUNCT_QREGC3]) out[n++]=(FLOAT_DMEM)c;\n    if (!oldBuggyQerr) {\n      if (enab[FUNCT_QREGERRA]) out[n++]=(FLOAT_DMEM)(qea/Nind);\n      if (enab[FUNCT_QREGERRQ]) out[n++]=(FLOAT_DMEM)(qeq/Nind);\n    } else {\n      if (enab[FUNCT_QREGERRA]) out[n++]=(FLOAT_DMEM)(qea);\n      if (enab[FUNCT_QREGERRQ]) out[n++]=(FLOAT_DMEM)(qeq);\n    }\n\n    if (enab[FUNCT_CENTROID]) out[n++]=(FLOAT_DMEM)centroid;\n\n    if (enab[FUNCT_QREGLS]) out[n++]=(FLOAT_DMEM)ls;\n    if (enab[FUNCT_QREGRS]) out[n++]=(FLOAT_DMEM)rs;\n    if (enab[FUNCT_QREGX0]) out[n++]=(FLOAT_DMEM)x0;\n    if (enab[FUNCT_QREGY0]) out[n++]=(FLOAT_DMEM)y0;\n    if (enab[FUNCT_QREGYR]) out[n++]=(FLOAT_DMEM)yr;\n    if (enab[FUNCT_QREGY0NN]) out[n++]=(FLOAT_DMEM)y0nn;\n    if (enab[FUNCT_QREGC3NN]) out[n++]=(FLOAT_DMEM)c3nn;\n    if (enab[FUNCT_QREGYRNN]) out[n++]=(FLOAT_DMEM)yrnn;\n\n    return n;\n  }\n  return 0;\n}\n\n/*\nlong cFunctionalRegression::process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout)\n{\n\n  return 0;\n}\n*/\n\ncFunctionalRegression::~cFunctionalRegression()\n{\n}\n\n"
  },
  {
    "path": "src/functionals/functionalSamples.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctionals: samples values\n\n*/\n\n\n#include <functionals/functionalSamples.hpp>\n\n#define MODULE \"cFunctionalSamples\"\n\n\n#define FUNCT_SAMPLES     0\n\n#define N_FUNCTS  1\n\n#define NAMES     \"samples\"\n\n#define DEFAULT_NR_SAMPLES 5\n\nconst char *samplesNames[] = {NAMES};  // change variable name to your clas...\n\nSMILECOMPONENT_STATICS(cFunctionalSamples)\n\nSMILECOMPONENT_REGCOMP(cFunctionalSamples)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CFUNCTIONALSAMPLES;\n  sdescription = COMPONENT_DESCRIPTION_CFUNCTIONALSAMPLES;\n\n  // configure your component's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"samplepos\",\"Array of positions of samples to copy to the output. The size of this array determines the number of sample frames that will be passed to the output. The given positions must be in the range from 0 to 1, indicating the relative position whithin the input segment, where 0 is the beginning and 1 the end of the segment.\",0.0,ARRAY_TYPE);\n  )\n  \n  SMILECOMPONENT_MAKEINFO_NODMEM(cFunctionalSamples);\n}\n\nSMILECOMPONENT_CREATE(cFunctionalSamples)\n\n//-----\n\ncFunctionalSamples::cFunctionalSamples(const char *_name) :\n  cFunctionalComponent(_name,N_FUNCTS,samplesNames),\n  samplepos(0)\n{\n}\n\nvoid cFunctionalSamples::fetchConfig()\n{\n  nSamples = getArraySize(\"samplepos\");\n  SMILE_IDBG(2,\"nSamples from config = %d\", nSamples);\n  if (nSamples > 0) {\n    samplepos = (double*) malloc(sizeof(double) * nSamples);\n    for (int i = 0; i < nSamples; ++i) {\n      samplepos[i] = getDouble_f(myvprint(\"samplepos[%i]\", i));\n      if (samplepos[i] < 0.0) {\n        SMILE_WRN(2,\"(inst '%s') samplepos[%i] is out of range [0..1] : %f (clipping to 0.0)\",getInstName(),i,samplepos[i]);\n        samplepos[i] = 0.0;\n      }\n      if (samplepos[i] > 1.0) {\n        SMILE_WRN(2,\"(inst '%s') samplepos[%i] is out of range [0..1] : %f (clipping to 1.0)\",getInstName(),i,samplepos[i]);\n        samplepos[i] = 1.0;\n      }\n    }\n  }\n  else {\n    nSamples = DEFAULT_NR_SAMPLES;\n    samplepos = (double*) malloc(sizeof(double) * nSamples);\n    for (int i = 0; i < nSamples; ++i) {\n      samplepos[i] = (double)i / (DEFAULT_NR_SAMPLES-1.0);\n      SMILE_IDBG(2,\"samplepos[%d] = %.2f\", i, samplepos[i]);\n    }\n  }\n  enab[0] = 1;\n  cFunctionalComponent::fetchConfig();\n  nEnab = nSamples;\n}\n\nconst char* cFunctionalSamples::getValueName(long i)\n{\n  const char *n = cFunctionalComponent::getValueName(0);\n    // append [i]\n  tmpstr = myvprint(\"%s%.3f\",n,samplepos[i]);\n  return tmpstr;\n}\n\nlong cFunctionalSamples::process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted,  FLOAT_DMEM min, FLOAT_DMEM max, FLOAT_DMEM mean, FLOAT_DMEM *out, long Nin, long Nout)\n{\n  if ((Nin>0)&&(out!=NULL)) {\n    FLOAT_DMEM Nind = (FLOAT_DMEM)Nin;\n    for (int spi = 0; spi < nSamples; ++spi) {\n      SMILE_IDBG(5,\"Nind = %.2f, samplepos[%d] = %.2f\",Nind,spi,samplepos[spi]);\n      int si = (int)((Nind - 1.0) * samplepos[spi]);\n      SMILE_IDBG(5,\"si(%d) = %d\",spi,si);\n      out[spi] = in[si];\n    }\n    return nSamples;\n  }\n  else {\n    return 0;\n  }\n}\n\n/*\nlong cFunctionalSamples::process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout)\n{\n\n  return 0;\n}\n*/\n\ncFunctionalSamples::~cFunctionalSamples()\n{\n  free(samplepos);\n  /*if (samplepos != 0) {\n    delete[] samplepos;\n    samplepos = 0;\n  }*/\n}\n\n"
  },
  {
    "path": "src/functionals/functionalSegments.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctionals: number of segments based on delta thresholding\n\n*/\n\n// TODO: support turnFrameTime message based upon detected segments, in order to apply functionals to voiced segments,\n// for example. We then only need to support second round processing of functionals that aggregate the functionals of\n// the segments in case of frameMode=full for the aggregation and the segments code.\n// For the frameMode = var method we might need to ensure that segments (or at least the status)\n// at segment boundaries is handled correct.\n\n#include <functionals/functionalSegments.hpp>\n\n#define MODULE \"cFunctionalSegments\"\n\n\n#define FUNCT_NUMSEGMENTS      0  // number of segments (relative to maxNumSeg)\n#define FUNCT_SEGMEANLEN       1  // mean length of segment (relative to input length)\n#define FUNCT_SEGMAXLEN        2  // max length of segment (relative to input length)\n#define FUNCT_SEGMINLEN        3  // min length of segment (relative to input length)\n#define FUNCT_SEGLENSTDDEV     4  // standard deviation of the length of segments (relative to input length)\n/// TODO: gap statistics, for segmentationAlgorithms *X (except chX)\n#define FUNCT_GAPMEANLEN       5  // mean length of segment (relative to input length)\n#define FUNCT_GAPMAXLEN        6  // max length of segment (relative to input length)\n#define FUNCT_GAPMINLEN        7  // min length of segment (relative to input length)\n#define FUNCT_GAPLENSTDDEV     8  // standard deviation of the length of segments (relative to input length)\n\n#define N_FUNCTS  9\n\n#define NAMES     \"numSegments\",\"meanSegLen\",\"maxSegLen\",\"minSegLen\",\"segLenStddev\",\"meanGapLen\",\"maxGapLen\",\"minGapLen\",\"gapLenStddev\"\n\nconst char *segmentsNames[] = {NAMES};  \n\nSMILECOMPONENT_STATICS(cFunctionalSegments)\n\nSMILECOMPONENT_REGCOMP(cFunctionalSegments)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CFUNCTIONALSEGMENTS;\n  sdescription = COMPONENT_DESCRIPTION_CFUNCTIONALSEGMENTS;\n\n  // configure your component's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"maxNumSeg\",\"Maximum number of segments to detect. Use growDynSegBuffer=1 to automatically increase this size if more segments are detected. Use norm=seconds or norm=frames in this time to avoid having inconsistent results.\", 20);\n    ct->setField(\"segmentationAlgorithm\",\"Method to use for segmenting the input contour. Possible values are:\\n  delta : new segments start when the signal changes more than 'rangeRelThreshold' when the current frame is compared to a running average computed over a length of ravgLng = Nin/(maxNumSeg/2) frames (Nin is the length of the input contour in frames).\\n  (m)(NA)relTh : segment boundaries each time the short term running average (over 3 frames) of the signal rises above predefined relative (to the signal range) value thresholds (NA version: don't use running average, use signal directly instead; m version: relative thresholds are relative to the arithmetic mean).\\n  (NA)absTh : segment boundaries each time the short-time running average (3 frames) of the signal rises above predefined absolute value thresholds (NA version: don't use running average, use signal values directly instead).\\n  chX : segments are regions of continuous input samples of value X and continuous segments of non-X samples, i.e. segment boundaries are at changes from X to non-X values.\\n  nonX : segment boundaries are at changes from X to non-X, but only non-X value sequences are considered as segments.\\n  eqX : segment boundaries are at changes from X to non-X, but only equal to X value sequences are considered as segments.\\n  ltX : segment boundaries are at changes from greater equal X to smaller X, but only smaller X sequences are considered as segments.\\n  gtX :  segment boundaries are at changes from smaller equal X to greater X, but only greater X sequences are considered as segments.\\n  geqX :  segment boundaries are at changes from greater equal X to smaller X, but only greater equal X sequences are considered as segments.\\n  leqX : segment boundaries are at changes from smaller equal X to greater X, but only smaller equal X sequences are considered as segments.\\n \",\"delta\");\n    ct->setField(\"ravgLng\",\"If set to a value > 0, forces the length of the running average window to this value (for the delta thresholding method).\",0);\n    ct->setField(\"thresholds\",\"An array of thresholds, used if 'segmentationAlgorithm' is set to either 'relTh' or 'absTh'. The values specified here are then either relative thresholds (relative to the range of the input), or absolute value thresholds.\",0,ARRAY_TYPE);\n    ct->setField(\"X\",\"The value of X for the 'chX','nonX','eqX','ltX','gtX','geqX', and 'leqX' segmentation methods/algorithms.\",0);\n    ct->setField(\"XisRel\",\"1= X is a threshold relative to the range of the input / 0= X is an absolute valued threshold.\",0);\n\t  ct->setField(\"rangeRelThreshold\",\"The segment threshold relative to the signal's range (max-min), when 'segmentationAlgorithm' is set to 'delta'.\",0.2);\n    ct->setField(\"numSegments\",\"1/0=enable/disable output of the number of segments (output is relative to maxNumSeg if norm=segment or the absolute value if norm=frames, and for norm=seconds the output is the number of segments per second)\",0);\n    ct->setField(\"meanSegLen\",\"1/0=enable/disable output of the mean segment length (relative to the input segment length, in seconds, or in frames, see the 'norm' option or the 'masterTimeNorm' option of the cFunctionals parent component)\",0);\n    ct->setField(\"maxSegLen\",\"1/0=enable/disable output of the maximum segment length (relative to the input segment length, in seconds, or in frames, see the 'norm' option or the 'masterTimeNorm' option of the cFunctionals parent component)\",0);\n    ct->setField(\"minSegLen\",\"1/0=enable/disable output of the minimum segment length (relative to the input segment length, in seconds, or in frames, see the 'norm' option or the 'masterTimeNorm' option of the cFunctionals parent component)\",0);\n    ct->setField(\"segLenStddev\",\"1/0=enable/disable output of the standard deviation of the segment lengths (relative to the input segment length, in seconds, or in frames, see the 'norm' option or the 'masterTimeNorm' option of the cFunctionals parent component)\",0);\n    ct->setField(\"norm\",\"This option specifies how this component should normalise times (if it generates output values related to durations): \\n   'segment' (or: 'turn') : normalise to the range 0..1, the result is the relative length wrt. to the segment length )\\n   'second'  (absolute time in seconds) \\n   'frame' (absolute time in number of frames of input level)\",\"segment\",0,0);\n    ct->setField(\"dbgPrint\",\"1= enable debug output with segment boundary begin and end coordinates\",0);\n    ct->setField(\"segMinLng\", \"Minimum segment length in input level frames. The segmentation algorithms EqX, NonX, and ChX always use this value. The old (buggy) versions of these algorithms (if useOldBuggyChX = 1), never use this value, they instead compute it as InputLength/maxNumSeg - 1. All other algorithms compute the value segMinLng as inputLength/maxNumSeg if this option is not set explicitly, otherwise they use the value this option is set to (in this case it overrides maxNumSeg, i.e. the maximum number of segments that can be detected might differ from the value maxNumSeg is set to).\", 3);\n    ct->setField(\"pauseMinLng\", \"Minimum length of a pause for the segmentation algorithms EqX and NonX in input level frames.\", 2);\n    ct->setField(\"useOldBuggyChX\", \"1 = Use old buggy version of the ChX, EqX and NonX code (configs up to 12.06.2012); available only for compatibility. Do not use in new configs!\", 0);\n    ct->setField(\"growDynSegBuffer\", \"1 = Dynamically grow the segment buffer (i.e. maxNumSeg = infinite) by maxNumSeg segments at a time if more segments are detected.\", 0);\n  ) \n  FLOAT_DMEM meanFallingSlope = (FLOAT_DMEM)0.0; \n  FLOAT_DMEM minRisingSlope = (FLOAT_DMEM)0.0;\n  FLOAT_DMEM maxRisingSlope = (FLOAT_DMEM)0.0;\n  FLOAT_DMEM minFallingSlope = (FLOAT_DMEM)0.0;\n  FLOAT_DMEM maxFallingSlope = (FLOAT_DMEM)0.0;\n  FLOAT_DMEM stddevRisingSlope = (FLOAT_DMEM)0.0;\n  FLOAT_DMEM stddevFallingSlope = (FLOAT_DMEM)0.0;\n\n  SMILECOMPONENT_MAKEINFO_NODMEM(cFunctionalSegments);\n}\n\nSMILECOMPONENT_CREATE(cFunctionalSegments)\n\n//-----\n\ncFunctionalSegments::cFunctionalSegments(const char *_name) :\n  cFunctionalComponent(_name,N_FUNCTS,segmentsNames),\n  maxNumSeg(20), thresholds(NULL), thresholdsTemp(NULL), dbgPrint(0)\n{\n}\n\nvoid cFunctionalSegments::fetchConfig()\n{\n  parseTimeNormOption();\n\n  if (getInt(\"numSegments\")) enab[FUNCT_NUMSEGMENTS] = 1;\n  if (getInt(\"meanSegLen\")) enab[FUNCT_SEGMEANLEN] = 1;\n  if (getInt(\"maxSegLen\")) enab[FUNCT_SEGMAXLEN] = 1;\n  if (getInt(\"minSegLen\")) enab[FUNCT_SEGMINLEN] = 1;\n  if (getInt(\"segLenStddev\")) enab[FUNCT_SEGLENSTDDEV] = 1;\n\n  dbgPrint = getInt(\"dbgPrint\");\n  manualRavgLng = getInt(\"ravgLng\");\n\n  growDynSegBuffer = getInt(\"growDynSegBuffer\");\n  if (growDynSegBuffer && timeNorm == TIMENORM_SEGMENT && enab[FUNCT_NUMSEGMENTS] == 1) {\n    SMILE_IWRN(1, \"growDynSegBuffer=1 and time norm=segment (which means that numSegments is normalised to maxNumSeg, which - however - will grow dynamically, so the outputs will not be consistent - use a different time norm to solve this (seconds or frames))\");\n  }\n  maxNumSeg = getInt(\"maxNumSeg\");\n  maxNumSeg0 = maxNumSeg;\n  SMILE_IDBG(2,\"maxNumSeg = %i\",maxNumSeg);\n\n  rangeRelThreshold = (FLOAT_DMEM)getDouble(\"rangeRelThreshold\");\n  SMILE_IDBG(2,\"rangeRelThreshold = %f\",rangeRelThreshold);\n\n  const char * segmentationAlgorithmStr = getStr(\"segmentationAlgorithm\");\n  SMILE_IDBG(2,\"segmentationAlgorithm = '%s'\",segmentationAlgorithmStr);\n  if (!strncmp(segmentationAlgorithmStr,\"delta\",5)) {\n    segmentationAlgorithm = SEG_DELTA;\n  } else if (!strncmp(segmentationAlgorithmStr,\"delt2\",5)) {\n    segmentationAlgorithm = SEG_DELTA2;\n  } else if (!strncmp(segmentationAlgorithmStr,\"relTh\",5)) {\n    segmentationAlgorithm = SEG_RELTH;\n  } else if (!strncmp(segmentationAlgorithmStr,\"mrelTh\",6)) {\n    segmentationAlgorithm = SEG_MRELTH;\n  } else if (!strncmp(segmentationAlgorithmStr,\"absTh\",5)) {\n    segmentationAlgorithm = SEG_ABSTH;\n  } else if (!strncmp(segmentationAlgorithmStr,\"NArelTh\",7)) {\n    segmentationAlgorithm = SEG_RELTH_NOAVG;\n  } else if (!strncmp(segmentationAlgorithmStr,\"mNArelTh\",8)) {\n    segmentationAlgorithm = SEG_MRELTH_NOAVG;\n  } else if (!strncmp(segmentationAlgorithmStr,\"NAmrelTh\",8)) {\n    segmentationAlgorithm = SEG_MRELTH_NOAVG;\n  } else if (!strncmp(segmentationAlgorithmStr,\"NAabsTh\",7)) {\n    segmentationAlgorithm = SEG_ABSTH_NOAVG;\n  } else if (!strncmp(segmentationAlgorithmStr,\"chX\",3)) {\n    segmentationAlgorithm = SEG_CHX;\n  } else if (!strncmp(segmentationAlgorithmStr,\"nonX\",4)) {\n    segmentationAlgorithm = SEG_NONX;\n  } else if (!strncmp(segmentationAlgorithmStr,\"eqX\",3)) {\n    segmentationAlgorithm = SEG_EQX;\n  } else if (!strncmp(segmentationAlgorithmStr,\"ltX\",3)) {\n    segmentationAlgorithm = SEG_LTX;\n  } else if (!strncmp(segmentationAlgorithmStr,\"gtX\",3)) {\n    segmentationAlgorithm = SEG_GTX;\n  } else if (!strncmp(segmentationAlgorithmStr,\"geqX\",3)) {\n    segmentationAlgorithm = SEG_GEQX;\n  } else if (!strncmp(segmentationAlgorithmStr,\"leqX\",3)) {\n    segmentationAlgorithm = SEG_LEQX;\n  } else {\n    SMILE_IERR(1,\"unknown segmentationAlgorithm : '%s' (or algorithm not yet implemented) , see '-H cFunctionalSegments' for a list of available methods. Using 'delta' threshold method as fallback default.\",segmentationAlgorithmStr)\n    segmentationAlgorithm = SEG_DELTA;\n  }\n\n  useOldBuggyChX = (int)getInt(\"useOldBuggyChX\");\n  if (useOldBuggyChX) {\n    SMILE_IDBG(2, \"Note: old (broken and buggy) version of ChX, EqX and NonX segmentation methods are enabled! Use only for compatibility with old configs/models!\");\n  }\n\n  segMinLng = getInt(\"segMinLng\");\n  if (segMinLng < 1) segMinLng = 1;\n  if (isSet(\"segMinLng\")) {\n    SMILE_IDBG(2, \"Using segMinLng = %i\\n\", segMinLng);\n    autoSegMinLng = 0;\n  } else {\n    autoSegMinLng = 1;\n  }\n  pauseMinLng = getInt(\"pauseMinLng\");\n  if (pauseMinLng < 1) pauseMinLng = 1;\n\n  X = (FLOAT_DMEM)getDouble(\"X\");\n  SMILE_IDBG(2,\"X = %f\",X);\n\n  XisRel = (int)getInt(\"XisRel\");\n  SMILE_IDBG(2,\"XisRel = %i\",XisRel);\n\n  if ((segmentationAlgorithm == SEG_RELTH)||(segmentationAlgorithm == SEG_RELTH_NOAVG)||(segmentationAlgorithm == SEG_ABSTH_NOAVG)||\n      (segmentationAlgorithm == SEG_MRELTH)||(segmentationAlgorithm == SEG_MRELTH_NOAVG)) {\n    // read thresholds array\n    nThresholds = getArraySize(\"thresholds\");\n    int i;\n    thresholds = (FLOAT_DMEM*) calloc(1,sizeof(FLOAT_DMEM)*nThresholds);\n    if ((segmentationAlgorithm == SEG_RELTH)||(segmentationAlgorithm == SEG_MRELTH)||(segmentationAlgorithm == SEG_MRELTH_NOAVG)||(segmentationAlgorithm == SEG_RELTH_NOAVG))\n        thresholdsTemp = (FLOAT_DMEM*) calloc(1,sizeof(FLOAT_DMEM)*nThresholds);\n    else thresholdsTemp = thresholds;\n    for (i=0; i<nThresholds; i++) {\n      thresholds[i] = (FLOAT_DMEM)getDouble_f(myvprint(\"thresholds[%i]\",i));\n      if ((segmentationAlgorithm == SEG_RELTH)||(segmentationAlgorithm == SEG_RELTH_NOAVG)) { // check threshold range 0..1\n        if (thresholds[i] < 0) {\n          thresholds[i] = 0.0;\n          SMILE_IERR(1,\"Relative threshold cannot be smaller than 0. It must be in the range 0..1. Setting threshold to 0.0.\");\n        }\n        else if (thresholds[i] > 1) {\n          thresholds[i] = 1.0;\n          SMILE_IERR(1,\"Relative threshold cannot be greater than 1. It must be in the range 0..1. Setting threshold to 1.0.\");\n        }\n      }\n    }\n  }\n  cFunctionalComponent::fetchConfig();\n}\n\nlong cFunctionalSegments::addNewSegment(long i, long lastSeg, sSegData *result)\n{\n  long segLen = i-lastSeg;\n  if (growDynSegBuffer && result->nSegments >= maxNumSeg) {\n    result->segLens = (long *)crealloc(result->segLens, (maxNumSeg+maxNumSeg0)*sizeof(long), maxNumSeg*sizeof(long));\n    SMILE_IMSG(3, \"increasing maxNumSeg from %i to %i (growDynSegBuffer = 1).\", maxNumSeg, maxNumSeg + maxNumSeg0);\n    maxNumSeg += maxNumSeg0;\n  }\n  if (result->nSegments < maxNumSeg) {\n    result->meanSegLen += segLen;\n    result->segLens[result->nSegments] = segLen;\n    result->nSegments++;\n    if (segLen > result->maxSegLen) result->maxSegLen = segLen;\n    if ((result->minSegLen==0)||(segLen<result->minSegLen)) result->minSegLen = segLen;\n  } else {\n    SMILE_IWRN(3, \"Maximum number of segments (%i) reached (frame %ld). Final result will be inaccurate for this instance.\", maxNumSeg, i);\n  }\n  return i;\n}\n\nint cFunctionalSegments::process_SegDelta(FLOAT_DMEM *in, FLOAT_DMEM *out, long Nin, long Nout, sSegData *result)\n{\n   FLOAT_DMEM segThresh = result->range * rangeRelThreshold;\n\n   if (autoSegMinLng) {\n     segMinLng = Nin/maxNumSeg-1;\n     if (segMinLng < 2) segMinLng = 2;\n   }\n   long ravgLng;\n\n   if (manualRavgLng > 0) ravgLng = manualRavgLng;\n   else ravgLng = Nin/(maxNumSeg/2);\n\n   long lastSeg = -segMinLng/2;\n\n   long i;\n   FLOAT_DMEM ravg = 0.0;\n\n   for (i=0; i<Nin; i++) {\n     ravg += in[i];\n     if (i>=ravgLng) ravg -= in[i-ravgLng];\n\n     FLOAT_DMEM ravgLngCur = (FLOAT_DMEM)( MIN(i+1,ravgLng) ); // bugfix by feyben: i+1 to avoid division by zero\n     FLOAT_DMEM ra = ravg / ravgLngCur;\n\n     if ((in[i]-ra > segThresh)&&(i - lastSeg > segMinLng) )\n     { // found new segment begin\n       lastSeg = addNewSegment(i, lastSeg, result);\n       if (dbgPrint) {\n         printf(\"XXXX_SEG_border: x=%ld y=%f\\n\",i,in[i]);\n       }\n     }\n\n   }\n\n   return 1;\n}\n\nint cFunctionalSegments::process_SegDelta2(FLOAT_DMEM *in, FLOAT_DMEM *out, long Nin, long Nout, sSegData *result)\n{\n   FLOAT_DMEM segThresh = result->range * rangeRelThreshold;\n\n   if (autoSegMinLng) {\n     segMinLng = Nin/maxNumSeg-1;\n     if (segMinLng < 2) segMinLng = 2;\n   }\n   long ravgLng;\n\n   if (manualRavgLng > 0) ravgLng = manualRavgLng;\n   else ravgLng = Nin/(maxNumSeg/2);\n\n   long lastSeg = -segMinLng/2;\n\n   long i;\n   FLOAT_DMEM ravg = in[0];\n   FLOAT_DMEM raLast = 0.0;\n\n   for (i=1; i<Nin; i++) {\n     ravg += in[i];\n     if (i>=ravgLng) ravg -= in[i-ravgLng];\n\n     FLOAT_DMEM ravgLngCur = (FLOAT_DMEM)( MIN(i+1,ravgLng) ); // bugfix by feyben: i+1 to avoid division by zero\n     FLOAT_DMEM ra = ravg / ravgLngCur;\n\n     if (dbgPrint) { printf(\"X_RA: %f\\n\",ra); }\n\n     if ((in[i-1]-raLast <= segThresh)&&(in[i]-ra > segThresh)&&(i - lastSeg > segMinLng) )\n     { // found new segment begin\n       lastSeg = addNewSegment(i, lastSeg, result);\n       if (dbgPrint) {\n         printf(\"XXXX_SEG_border: x=%ld y=%f\\n\",i,in[i]);\n       }\n     }\n     raLast = ra;\n\n   }\n\n   return 1;\n}\n\nint cFunctionalSegments::process_SegThresh(FLOAT_DMEM *in, FLOAT_DMEM *out, long Nin, long Nout, sSegData *result)\n{\n  long i,j;\n  if (segmentationAlgorithm == SEG_RELTH) {\n    // convert relative thresholds to absolute, given the range\n    for (i=0; i<nThresholds; i++) {\n      thresholdsTemp[i] = result->min + result->range * thresholds[i];\n      //SMILE_IMSG(3,\"thresh[%i]=%f\",i,thresholdsTemp[i]);\n    }\n  }\n  else if (segmentationAlgorithm == SEG_MRELTH) {\n    // convert relative thresholds to absolute, given the mean\n    for (i=0; i<nThresholds; i++) {\n      thresholdsTemp[i] = result->mean * thresholds[i];\n      //SMILE_IMSG(3,\"thresh[%i]=%f\",i,thresholdsTemp[i]);\n    }\n  }\n\n  if (autoSegMinLng) {\n    segMinLng = Nin/maxNumSeg-1;\n    if (segMinLng < 2) segMinLng = 2;\n  }\n\n  long ravgLng = 3;\n  long lastSeg = -segMinLng/2;\n\n  FLOAT_DMEM ravg = 0.0;\n  FLOAT_DMEM raLast = 0.0;\n\n  for (i=0; i<Nin; i++) {\n     ravg += in[i];\n     if (i>=ravgLng) ravg -= in[i-ravgLng];\n\n     FLOAT_DMEM ravgLngCur = (FLOAT_DMEM)( MIN(i+1,ravgLng) );\n     FLOAT_DMEM ra = ravg / ravgLngCur;\n\n     int threshCross=0;\n     for (j=0; j<nThresholds; j++) {\n       if (ra > thresholdsTemp[j] && raLast <= thresholdsTemp[j] || ra < thresholdsTemp[j] && raLast >= thresholdsTemp[j] ) {\n         threshCross = 1;\n         //printf(\"xxx: tc  ra=%f  raLast=%f\\n\",ra,raLast);\n       }\n     }\n     raLast = ra;\n     //printf(\"X_RA: %f\\n\",ra);\n\n     if ((threshCross)&&(i - lastSeg > segMinLng) )\n     { // found new segment begin\n       lastSeg = addNewSegment(i, lastSeg, result);\n       if (dbgPrint) {\n         printf(\"XXXX_SEG_border: x=%ld y=%f\\n\",i,in[i]);\n       }\n     }\n\n   }\n\n   return 1;\n}\n\nint cFunctionalSegments::process_SegThreshNoavg(FLOAT_DMEM *in, FLOAT_DMEM *out, long Nin, long Nout, sSegData *result)\n{\n  long i,j;\n  if (segmentationAlgorithm == SEG_RELTH_NOAVG) {\n    // convert relative thresholds to absolute, given the range\n    for (i=0; i<nThresholds; i++) {\n      thresholdsTemp[i] = result->min + result->range * thresholds[i];\n      //SMILE_IMSG(3,\"thresh[%i]=%f\",i,thresholdsTemp[i]);\n    }\n  }\n  else if (segmentationAlgorithm == SEG_MRELTH_NOAVG) {\n    // convert relative thresholds to absolute, given the mean\n    for (i=0; i<nThresholds; i++) {\n      thresholdsTemp[i] = result->mean * thresholds[i];\n      //SMILE_IMSG(3,\"thresh[%i]=%f\",i,thresholdsTemp[i]);\n    }\n  }\n\n  if (autoSegMinLng) {\n    segMinLng = Nin/maxNumSeg-1;\n    if (segMinLng < 2) segMinLng = 2;\n  }\n\n  long lastSeg = -segMinLng/2;\n\n  for (i=1; i<Nin; i++) {\n     int threshCross=0;\n     for (j=0; j<nThresholds; j++) {\n       if (in[i] > thresholdsTemp[j] && in[i-1] <= thresholdsTemp[j] || in[i] < thresholdsTemp[j] && in[i-1] >= thresholdsTemp[j] ) {\n         threshCross = 1;\n         //printf(\"xxx: tc  ra=%f  raLast=%f\\n\",ra,raLast);\n       }\n     }\n\n     if ((threshCross)&&(i - lastSeg > segMinLng) )\n     { // found new segment begin\n       lastSeg = addNewSegment(i, lastSeg, result);\n       if (dbgPrint) printf(\"XXXX_SEG_border: x=%ld y=%f\\n\",i,in[i]);\n     }\n\n   }\n\n   return 1;\n}\n\nint cFunctionalSegments::process_SegChX_oldBuggy(FLOAT_DMEM *in, FLOAT_DMEM *out, long Nin, long Nout, sSegData *result)\n{\n  long i;\n\n  // convert relative thresholds to the current absolute value, if the config option to do so is set\n  FLOAT_DMEM Xtmp;\n  if (XisRel) Xtmp = result->min + result->range * X;\n  else Xtmp = X;\n\n  segMinLng = Nin/maxNumSeg-1;\n  if (segMinLng < 2) segMinLng = 2;\n\n  long ravgLng = 3;\n  long lastSeg = -segMinLng/2;\n\n  FLOAT_DMEM ravg = 0.0;\n  FLOAT_DMEM raLast = 0.0;\n\n  for (i=0; i<Nin; i++) {\n     ravg += in[i];\n     if (i>=ravgLng) ravg -= in[i-ravgLng];\n\n     FLOAT_DMEM ravgLngCur = (FLOAT_DMEM)( MIN(i+1,ravgLng) );\n     FLOAT_DMEM ra = ravg / ravgLngCur;\n\n     int threshCross=0;\n     if ( (ra != Xtmp && raLast == Xtmp) || (ra == Xtmp && raLast != Xtmp)) {\n       threshCross = 1;\n     }\n     raLast = ra;\n\n     if ((threshCross)&&(i - lastSeg > segMinLng) )\n     { // found new segment begin\n       lastSeg = addNewSegment(i, lastSeg, result);\n       if (dbgPrint) printf(\"XXXX_SEG_border: x=%ld y=%f\\n\",i,in[i]);\n      }\n\n   }\n\n   return 1;\n}\n\nint cFunctionalSegments::process_SegNonX_oldBuggy(FLOAT_DMEM *in, FLOAT_DMEM *out, long Nin, long Nout, sSegData *result)\n{\n  long i;\n\n  // convert relative thresholds to the current absolute value, if the config option to do so is set\n  FLOAT_DMEM Xtmp;\n  if (XisRel) Xtmp = result->min + result->range * X;\n  else Xtmp = X;\n\n  segMinLng = Nin/maxNumSeg-1;\n  if (segMinLng < 2) segMinLng = 2;\n\n  long ravgLng = 3;\n  long lastSeg = -segMinLng/2;\n\n  FLOAT_DMEM ravg = 0.0;\n  FLOAT_DMEM raLast = 0.0;\n\n  for (i=0; i<Nin; i++) {\n     ravg += in[i];\n     if (i>=ravgLng) ravg -= in[i-ravgLng];\n\n     FLOAT_DMEM ravgLngCur = (FLOAT_DMEM)( MIN(i+1,ravgLng) );\n     FLOAT_DMEM ra = ravg / ravgLngCur;\n\n     int segStart=0;\n     int segEnd=0;\n\n     if (ra != Xtmp && raLast == Xtmp) {\n       segStart = 1;\n     }\n     if (ra == Xtmp && raLast != Xtmp) {\n       segEnd = 1;\n     }\n     raLast = ra;\n\n     if (segStart) {\n       lastSeg = i;\n     }\n     if ((segEnd)&&(i - lastSeg > segMinLng) )\n     { // found new segment end\n       if (dbgPrint) printf(\"XXXX_SEG_border: end=%ld start=%ld\\n\",i,lastSeg);\n       lastSeg = addNewSegment(i-1, lastSeg, result);\n     }\n\n   }\n\n   return 1;\n}\n\nint cFunctionalSegments::process_SegEqX_oldBuggy(FLOAT_DMEM *in, FLOAT_DMEM *out, long Nin, long Nout, sSegData *result)\n{\n  long i;\n\n  // convert relative thresholds to the current absolute value, if the config option to do so is set\n  FLOAT_DMEM Xtmp;\n  if (XisRel) Xtmp = result->min + result->range * X;\n  else Xtmp = X;\n\n  segMinLng = Nin/maxNumSeg-1;\n  if (segMinLng < 2) segMinLng = 2;\n\n  long ravgLng = 3;\n  long lastSeg = -segMinLng/2;\n\n  FLOAT_DMEM ravg = 0.0;\n  FLOAT_DMEM raLast = 0.0;\n\n  for (i=0; i<Nin; i++) {\n     ravg += in[i];\n     if (i>=ravgLng) ravg -= in[i-ravgLng];\n\n     FLOAT_DMEM ravgLngCur = (FLOAT_DMEM)( MIN(i+1,ravgLng) );\n     FLOAT_DMEM ra = ravg / ravgLngCur;\n\n     int segStart=0;\n     int segEnd=0;\n     if (ra != Xtmp && raLast == Xtmp) {\n       segEnd = 1;\n     }\n     if (ra == Xtmp && raLast != Xtmp) {\n       segStart = 1;\n     }\n     raLast = ra;\n\n     if (segStart) {\n       lastSeg = i;\n     }\n     if ((segEnd)&&(i - lastSeg > segMinLng) )\n     { // found new segment end\n       lastSeg = addNewSegment(i, lastSeg, result);\n       if (dbgPrint) printf(\"XXXX_SEG_border: end=%ld start=%ld\\n\",i,lastSeg);\n     }\n\n   }\n\n   return 1;\n}\n\n// this version actually works as expected, because it does not enforce ra==Xtmp, as the old one did\nint cFunctionalSegments::process_SegChX(FLOAT_DMEM *in, FLOAT_DMEM *out, long Nin, long Nout, sSegData *result)\n{\n  // convert relative thresholds to the current absolute value, if the config option to do so is set\n  FLOAT_DMEM Xtmp;\n  if (XisRel) Xtmp = result->min + result->range * X;\n  else Xtmp = X;\n\n  long segStartIndex = 0;\n  long segEndIndex = 0;\n  int inSegment = 0;\n  int segStart = 0;\n  int segEnd = 0;\n  long i;\n\n  /* Note: running average over 3 frames was removed,\n     as it will lead to missing the threshold \n     due to round-off errors */\n\n  for (i = 0; i < Nin; i++) {\n\n     if (in[i] != Xtmp) {\n       if (inSegment == 1) {  // possible segment candidate\n         segEnd = 0;\n         segStart++;\n         if (segStart >= segMinLng) {\n           inSegment = 2;\n           if (dbgPrint) printf(\"XXXX_SEG_eqX: end=%ld start=%ld\\n\", segStartIndex - 1, segEndIndex);\n           addNewSegment(segStartIndex - 1, segEndIndex, result);\n           segStart = 0;\n         }\n       } else if (inSegment == 0) {  // currently in pause (in == threshold X)\n         segStart++;\n         segStartIndex = i;\n         inSegment = 1;\n       } else if (inSegment == 2) {\n         segEnd = 0;\n       } else if (inSegment == 3) {\n         segStart++;\n         if (segStart >= segMinLng) {\n           inSegment = 2;\n           segEnd = 0;\n           segStart = 0;\n         }\n       }\n     }\n     if (in[i] == Xtmp) {\n       if (inSegment == 3) {\n         segStart = 0;\n         segEnd++;\n         if (segEnd >= segMinLng) {\n           inSegment = 0;\n           if (dbgPrint) printf(\"XXXX_SEG_nonX: end=%ld start=%ld\\n\", segEndIndex - 1, segStartIndex);\n           addNewSegment(segEndIndex - 1, segStartIndex, result);\n           segEnd = 0;\n         }\n       } else if (inSegment == 2) {  // currently in pause (in == threshold X)\n         segEnd++;\n         segEndIndex = i;\n         inSegment = 3;\n       } else if (inSegment == 0) {\n         segStart = 0;\n       } else if (inSegment == 1) {\n         segEnd++;\n         if (segEnd >= pauseMinLng) {\n           inSegment = 0;\n           segEnd = 0;\n           segStart = 0;\n         }\n       }\n     }\n   }\n\n   // end a valid segment at the end of the data array\n   if (inSegment == 2) {\n     segEnd++;\n     if (dbgPrint) printf(\"XXXX_SEG_nonX: end=%ld start=%ld\\n\", segEndIndex - 1, segStartIndex);\n     addNewSegment(segEndIndex - 1, segStartIndex, result);\n   } else if (inSegment == 0) {\n     segStart++;\n     if (dbgPrint) printf(\"XXXX_SEG_eqX: end=%ld start=%ld\\n\", segStartIndex - 1, segEndIndex);\n     addNewSegment(segStartIndex - 1, segEndIndex, result);\n   }\n\n   return 1;\n}\n\n// the new and proper code, always use this in new configs\nint cFunctionalSegments::process_SegNonX(FLOAT_DMEM *in, FLOAT_DMEM *out, long Nin, long Nout, sSegData *result)\n{\n  // convert relative thresholds to the current absolute value, if the config option to do so is set\n  FLOAT_DMEM Xtmp;\n  if (XisRel) Xtmp = result->min + result->range * X;\n  else Xtmp = X;\n\n  long segStartIndex = 0;\n  int inSegment = 0;\n  int segStart = 0;\n  int segEnd = 0;\n  long i;\n\n  /* Note: running average over 3 frames was removed,\n     as it will lead to missing the threshold \n     due to round-off errors */\n\n  for (i = 0; i < Nin; i++) {\n\n     if (in[i] != Xtmp) {\n       if (inSegment == 1) {  // possible segment candidate\n         segEnd = 0;\n         segStart++;\n         if (segStart >= segMinLng) {\n           segStart = 0;\n           inSegment = 2;\n         }\n       } else if (inSegment == 0) {  // currently in pause (in == threshold X)\n         segStart++;\n         segStartIndex = i;\n         inSegment = 1;\n       } else if (inSegment == 2) {\n         segEnd = 0;\n       }\n     }\n     if (in[i] == Xtmp) {\n       if (inSegment == 2) {\n         segStart = 0;\n         segEnd++;\n         if (segEnd >= pauseMinLng) {\n           inSegment = 0;\n           if (dbgPrint) printf(\"XXXX_SEG_nonX: end=%ld start=%ld\\n\", i - segEnd, segStartIndex);\n           addNewSegment(i - segEnd, segStartIndex, result);\n           segEnd = 0;\n         }\n       } else if (inSegment == 1) {\n         segEnd++;\n         if (segEnd >= pauseMinLng) {\n           inSegment = 0;\n           segEnd = 0;\n           segStart = 0;\n         }\n       }\n     }\n   }\n\n   // end a valid segment at the end of the data array\n   if (inSegment == 2) {\n     segEnd++;\n     if (dbgPrint) printf(\"XXXX_SEG_nonX: x=%ld y=%ld\\n\", i - segEnd, segStartIndex);\n     addNewSegment(i - segEnd, segStartIndex, result);\n   }\n\n   return 1;\n}\n\n// the new and proper code, always use this in new configs\nint cFunctionalSegments::process_SegEqX(FLOAT_DMEM *in, FLOAT_DMEM *out, long Nin, long Nout, sSegData *result)\n{\n  // convert relative thresholds to the current absolute value, if the config option to do so is set\n  FLOAT_DMEM Xtmp;\n  if (XisRel) Xtmp = result->min + result->range * X;\n  else Xtmp = X;\n\n  long segStartIndex = 0;\n  int inSegment = 0;\n  int segStart = 0;\n  int segEnd = 0;\n  long i;\n\n  /* Note: running average over 3 frames was removed,\n     as it will lead to missing the threshold \n     due to round-off errors */\n\n  for (i = 0; i < Nin; i++) {\n\n     if (in[i] == Xtmp) {\n       if (inSegment == 1) {  // possible segment candidate\n         segEnd = 0;\n         segStart++;\n         if (segStart >= segMinLng) {\n           segStart = 0;\n           inSegment = 2;\n         }\n       } else if (inSegment == 0) {  // currently in pause (in == threshold X)\n         segStart++;\n         segStartIndex = i;\n         inSegment = 1;\n       } else if (inSegment == 2) {\n         segEnd = 0;\n       }\n     }\n     if (in[i] != Xtmp) {\n       if (inSegment == 2) {\n         segStart = 0;\n         segEnd++;\n         if (segEnd >= pauseMinLng) {\n           inSegment = 0;\n           if (dbgPrint) printf(\"XXXX_SEG_eqX: end=%ld start=%ld\\n\", i - segEnd, segStartIndex);\n           addNewSegment(i - segEnd, segStartIndex, result);\n           segEnd = 0;\n         }\n       } else if (inSegment == 1) {\n         segEnd++;\n         if (segEnd >= pauseMinLng) {\n           inSegment = 0;\n           segEnd = 0;\n           segStart = 0;\n         }\n       }\n     }\n   }\n\n   // end a valid segment at the end of the data array\n   if (inSegment == 2) {\n     segEnd++;\n     if (dbgPrint) printf(\"XXXX_SEG_eqX: end=%ld start=%ld\\n\", i - segEnd, segStartIndex);\n     addNewSegment(i - segEnd, segStartIndex, result);\n   }\n\n   return 1;\n}\n\n\n\nlong cFunctionalSegments::process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM min, FLOAT_DMEM max, FLOAT_DMEM mean, FLOAT_DMEM *out, long Nin, long Nout)\n{\n  int i;\n  if ((Nin>0)&&(out!=NULL)) {\n    sSegData result;\n\n    result.nSegments = 0;\n    result.max = max;\n    result.min = min;\n    result.maxSegLen = 0;\n    result.minSegLen = 0;\n    result.meanSegLen = 0;\n    result.seglenStddev = 0;\n    result.segLens = (long *)calloc(1,sizeof(long)*(maxNumSeg+1));\n\n\n    result.range = result.max-result.min;\n    result.mean = mean;\n\n    if (dbgPrint) {\n      printf(\"---\\n\");\n      printf(\"range: %f\\n\",result.range);\n    }\n\n    switch (segmentationAlgorithm) {\n\n    case SEG_DELTA:\n      process_SegDelta(in, out, Nin, Nout, &result);\n      break;\n    case SEG_DELTA2:\n      process_SegDelta2(in, out, Nin, Nout, &result);\n      break;\n\n    case SEG_RELTH:\n    case SEG_MRELTH:\n    case SEG_ABSTH:\n      process_SegThresh(in, out, Nin, Nout, &result);\n      break;\n\n    case SEG_RELTH_NOAVG:\n    case SEG_MRELTH_NOAVG:\n    case SEG_ABSTH_NOAVG:\n      process_SegThreshNoavg(in, out, Nin, Nout, &result);\n      break;\n\n    case SEG_CHX:\n      if (useOldBuggyChX) {\n        process_SegChX_oldBuggy(in, out, Nin, Nout, &result);\n      } else {\n        process_SegChX(in, out, Nin, Nout, &result);\n      }\n      break;\n\n    case SEG_NONX:\n      if (useOldBuggyChX) {\n        process_SegNonX_oldBuggy(in, out, Nin, Nout, &result);\n      } else {\n        process_SegNonX(in, out, Nin, Nout, &result);\n      }\n      break;\n\n    case SEG_EQX:\n      if (useOldBuggyChX) {\n        process_SegEqX_oldBuggy(in, out, Nin, Nout, &result);\n      } else {\n        process_SegEqX(in, out, Nin, Nout, &result);\n      }\n      break;\n\n    default:\n      SMILE_IERR(1,\"selected segmentation algorithm not yet implemented! Fallback: delta method\");\n      process_SegDelta(in, out, Nin, Nout, &result);\n\n    }\n\n\n    int n=0;\n\n    // compute length variance\n    FLOAT_DMEM lenDev = 0.0;\n    FLOAT_DMEM mean;\n    if (result.nSegments > 1) mean = (FLOAT_DMEM)result.meanSegLen/((FLOAT_DMEM)result.nSegments);\n    else mean = (FLOAT_DMEM)result.meanSegLen;\n\n    for (i=0; i<result.nSegments; i++) {\n      lenDev += ((FLOAT_DMEM)result.segLens[i] - mean)*((FLOAT_DMEM)result.segLens[i] - mean);\n    }\n    if (result.nSegments > 1) {\n      lenDev /= (FLOAT_DMEM)result.nSegments;\n      lenDev = sqrt(lenDev);\n    }\n    else lenDev = 0.0;\n\n    free(result.segLens);\n\n\n    // generate output\n\n    if (enab[FUNCT_NUMSEGMENTS]) {\n      if (timeNorm == TIMENORM_SECONDS) {\n        FLOAT_DMEM _T = (FLOAT_DMEM)getInputPeriod();\n        FLOAT_DMEM Norm = 1.0;\n        if (_T != 0.0) { Norm = _T; }\n        Norm *= (FLOAT_DMEM)Nin;\n        out[n++]=(FLOAT_DMEM)result.nSegments/Norm;\n      } else if (timeNorm == TIMENORM_SEGMENT) {\n        out[n++]=(FLOAT_DMEM)result.nSegments/(FLOAT_DMEM)(maxNumSeg);\n      } else {\n        out[n++]=(FLOAT_DMEM)result.nSegments;\n      }\n    }\n    \n    if (timeNorm==TIMENORM_SEGMENT) {\n      if (enab[FUNCT_SEGMEANLEN]) {\n        out[n++]=mean/(FLOAT_DMEM)(Nin);\n/*        if (result.nSegments > 1)\n          //out[n++]=(FLOAT_DMEM)result.meanSegLen/((FLOAT_DMEM)result.nSegments*(FLOAT_DMEM)(Nin));\n        else \n          out[n++]=(FLOAT_DMEM)result.meanSegLen/((FLOAT_DMEM)(Nin));*/\n      }\n      if (enab[FUNCT_SEGMAXLEN]) out[n++]=(FLOAT_DMEM)result.maxSegLen/(FLOAT_DMEM)(Nin);\n      if (enab[FUNCT_SEGMINLEN]) out[n++]=(FLOAT_DMEM)result.minSegLen/(FLOAT_DMEM)(Nin);\n      if (enab[FUNCT_SEGLENSTDDEV]) out[n++]=lenDev/(FLOAT_DMEM)(Nin);\n    } else if (timeNorm == TIMENORM_FRAMES) {\n      if (enab[FUNCT_SEGMEANLEN]) {\n        out[n++]=mean;\n        /*if (result.nSegments > 1)\n          out[n++]=mean; //(FLOAT_DMEM)result.meanSegLen/((FLOAT_DMEM)result.nSegments);\n        else \n          out[n++]=(FLOAT_DMEM)result.meanSegLen;*/\n      }\n      if (enab[FUNCT_SEGMAXLEN]) out[n++]=(FLOAT_DMEM)result.maxSegLen;\n      if (enab[FUNCT_SEGMINLEN]) out[n++]=(FLOAT_DMEM)result.minSegLen;\n      if (enab[FUNCT_SEGLENSTDDEV]) out[n++]=lenDev;\n    } else if (timeNorm == TIMENORM_SECONDS) {\n      FLOAT_DMEM _T = (FLOAT_DMEM)getInputPeriod();\n                \n      FLOAT_DMEM Norm = 1.0;\n      if (_T != 0.0) { Norm = _T; }\n\n      if (enab[FUNCT_SEGMEANLEN]) {\n        out[n++]=mean*Norm;\n\n        /*if (result.nSegments > 1)\n          out[n++]=mean*Norm; //(FLOAT_DMEM)result.meanSegLen*Norm/((FLOAT_DMEM)result.nSegments);\n        else \n          out[n++]=(FLOAT_DMEM)result.meanSegLen*Norm;*/\n      }\n      if (enab[FUNCT_SEGMAXLEN]) out[n++]=(FLOAT_DMEM)result.maxSegLen*Norm;\n      if (enab[FUNCT_SEGMINLEN]) out[n++]=(FLOAT_DMEM)result.minSegLen*Norm;\n      if (enab[FUNCT_SEGLENSTDDEV]) out[n++]=lenDev*Norm;\n    }\n\n    return n;\n  }\n  return 0;\n}\n\n/*\nlong cFunctionalSegments::process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout)\n{\n\n  return 0;\n}\n*/\n\ncFunctionalSegments::~cFunctionalSegments()\n{\n  if (thresholdsTemp != NULL && thresholdsTemp != thresholds) free(thresholdsTemp);\n  if (thresholds != NULL) free(thresholds);\n}\n\n"
  },
  {
    "path": "src/functionals/functionalTimes.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctionals: rise/fall times, up/down-level times\n\n28/10/2009:\n added duration feature (thanks to Dino Seppi)\n\n*/\n\n\n#include <functionals/functionalTimes.hpp>\n\n#define MODULE \"cFunctionalTimes\"\n\n\n\n#define FUNCT_UPLEVELTIME25     0\n#define FUNCT_DOWNLEVELTIME25   1\n#define FUNCT_UPLEVELTIME50     2\n#define FUNCT_DOWNLEVELTIME50   3\n#define FUNCT_UPLEVELTIME75     4\n#define FUNCT_DOWNLEVELTIME75   5\n#define FUNCT_UPLEVELTIME90     6\n#define FUNCT_DOWNLEVELTIME90   7\n#define FUNCT_RISETIME      8\n#define FUNCT_FALLTIME      9\n#define FUNCT_LEFTCTIME     10\n#define FUNCT_RIGHTCTIME    11\n#define FUNCT_DURATION      12\n#define FUNCT_UPLEVELTIME        13\n#define FUNCT_DOWNLEVELTIME      14\n\n\n#define N_FUNCTS  15\n\n#define NAMES     \"upleveltime25\",\"downleveltime25\",\"upleveltime50\",\"downleveltime50\",\"upleveltime75\",\"downleveltime75\",\"upleveltime90\",\"downleveltime90\",\"risetime\",\"falltime\",\"leftctime\",\"rightctime\",\"duration\",\"upleveltime\",\"downleveltime\"\n#define IDX_VAR_FUNCTS 13  // start of uptime, downtime, arrays of variable length\n\nconst char *timesNames[] = {NAMES};  // change variable name to your clas...\n\nSMILECOMPONENT_STATICS(cFunctionalTimes)\n\nSMILECOMPONENT_REGCOMP(cFunctionalTimes)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CFUNCTIONALTIMES;\n  sdescription = COMPONENT_DESCRIPTION_CFUNCTIONALTIMES;\n\n  // configure your component's configType:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"upleveltime25\",\"(1/0=yes/no) compute time where signal is above 0.25*range\",1);\n    ct->setField(\"downleveltime25\",\"(1/0=yes/no) compute time where signal is below 0.25*range\",1);\n    ct->setField(\"upleveltime50\",\"(1/0=yes/no) compute time where signal is above 0.50*range\",1);\n    ct->setField(\"downleveltime50\",\"(1/0=yes/no) compute time where signal is below 0.50*range\",1);\n    ct->setField(\"upleveltime75\",\"(1/0=yes/no) compute time where signal is above 0.75*range\",1);\n    ct->setField(\"downleveltime75\",\"(1/0=yes/no) compute time where signal is below 0.75*range\",1);\n    ct->setField(\"upleveltime90\",\"(1/0=yes/no) compute time where signal is above 0.90*range\",1);\n    ct->setField(\"downleveltime90\",\"(1/0=yes/no) compute time where signal is below 0.90*range\",1);\n    ct->setField(\"risetime\",\"(1/0=yes/no) compute time where signal is rising\",1);\n    ct->setField(\"falltime\",\"(1/0=yes/no) compute time where signal is falling\",1);\n    ct->setField(\"leftctime\",\"(1/0=yes/no) compute time where signal has left curvature\",1);\n    ct->setField(\"rightctime\",\"(1/0=yes/no) compute time where signal has right curvature\",1);\n    ct->setField(\"duration\",\"(1/0=yes/no) compute duration time, in frames (or seconds, if (time)norm==seconds)\",1);\n    ct->setField(\"upleveltime\",\"compute time where signal is above X*range : upleveltime[n]=X\",0.9,ARRAY_TYPE);\n    ct->setField(\"downleveltime\",\"compute time where signal is below X*range : downleveltime[n]=X\",0.9,ARRAY_TYPE);\n    ct->setField(\"norm\",\"This option specifies how this component should normalise times (if it generates output values related to durations): \\n   'segment' (or: 'turn') : normalise to the range 0..1, the result is the relative length wrt. to the segment length )\\n   'second'  (absolute time in seconds) \\n   'frame' (absolute time in number of frames of input level)\",\"segment\",0,0);\n    ct->setField(\"buggySecNorm\",\"If set to 1, enables the old (prior to version 1.0.0 , 07 May 2010) second normalisation code which erroneously divides by the number of input frames. The default is kept at 1 (enabled) in order to not break compatibility with old configuration files, however you are strongly encouraged to change this to 0 in any new configuration you write in order to get the times in actual (bug-free) seconds!\",1);\n    ct->setField(\"useRobustPercentileRange\", \"Estimate range based on low/high percentiles (set by the pctlRangeMargin option) instead of single max/min values.\", 0);\n    ct->setField(\"pctlRangeMargin\", \"Minimum percentile (and 1-x for maximum percentile) for range estimation with option useRobustPercentileRange. Valid range between > 0 and < 0.5, recommended: 0.02-0.10 \", 0.05);\n  )\n  \n  SMILECOMPONENT_MAKEINFO_NODMEM(cFunctionalTimes);\n}\n\nSMILECOMPONENT_CREATE(cFunctionalTimes)\n\n//-----\n\ncFunctionalTimes::cFunctionalTimes(const char *_name) :\n  cFunctionalComponent(_name,N_FUNCTS,timesNames),\n  ultime(NULL),\n  dltime(NULL),\n  tmpstr(NULL),\n  varFctIdx(0)\n{\n}\n\nvoid cFunctionalTimes::fetchConfig()\n{\n  parseTimeNormOption();\n  \n  buggySecNorm = getInt(\"buggySecNorm\");\n\n  if (getInt(\"upleveltime25\")) enab[FUNCT_UPLEVELTIME25] = 1;\n  if (getInt(\"downleveltime25\")) enab[FUNCT_DOWNLEVELTIME25] = 1;\n  if (getInt(\"upleveltime50\")) enab[FUNCT_UPLEVELTIME50] = 1;\n  if (getInt(\"downleveltime50\")) enab[FUNCT_DOWNLEVELTIME50] = 1;\n  if (getInt(\"upleveltime75\")) enab[FUNCT_UPLEVELTIME75] = 1;\n  if (getInt(\"downleveltime75\")) enab[FUNCT_DOWNLEVELTIME75] = 1;\n  if (getInt(\"upleveltime90\")) enab[FUNCT_UPLEVELTIME90] = 1;\n  if (getInt(\"downleveltime90\")) enab[FUNCT_DOWNLEVELTIME90] = 1;\n  if (getInt(\"risetime\")) enab[FUNCT_RISETIME] = 1;\n  if (getInt(\"falltime\")) enab[FUNCT_FALLTIME] = 1;\n  if (getInt(\"leftctime\")) enab[FUNCT_LEFTCTIME] = 1;\n  if (getInt(\"rightctime\")) enab[FUNCT_RIGHTCTIME] = 1;\n  if (getInt(\"duration\")) enab[FUNCT_DURATION] = 1;\n\n  useRobustPercentileRange_ = getInt(\"useRobustPercentileRange\");\n  pctlRangeMargin_ = (FLOAT_DMEM)getDouble(\"pctlRangeMargin\");\n  if (pctlRangeMargin_ < (FLOAT_DMEM)0.0) {\n    SMILE_IERR(1, \"Error: pctlRangeMargin must be > 0 and smaller 0.5 (is: %f)! Setting to 0.01\", pctlRangeMargin_);\n    pctlRangeMargin_ = (FLOAT_DMEM)0.01;\n  }\n  if (pctlRangeMargin_ >= (FLOAT_DMEM)0.5) {\n    SMILE_IERR(1, \"Error: pctlRangeMargin must be > 0 and smaller 0.5 (is: %f)! Setting to 0.45\", pctlRangeMargin_);\n    pctlRangeMargin_ = (FLOAT_DMEM)0.45;\n  }\n\n  int i;\n  nUltime = getArraySize(\"upleveltime\");\n  nDltime = getArraySize(\"downleveltime\");\n  if (nUltime > 0) {\n    enab[FUNCT_UPLEVELTIME] = 1;\n    ultime = (double*)calloc(1,sizeof(double)*nUltime);\n\n    // load upleveltime info\n    for (i=0; i<nUltime; i++) {\n      ultime[i] = getDouble_f(myvprint(\"upleveltime[%i]\",i));\n      if (ultime[i] < 0.0) {\n        SMILE_WRN(2,\"(inst '%s') upleveltime[%i] is out of range [0..1] : %f (clipping to 0.0)\",getInstName(),i,ultime[i]);\n        ultime[i] = 0.0;\n      }\n      if (ultime[i] > 1.0) {\n        SMILE_WRN(2,\"(inst '%s') upleveltime[%i] is out of range [0..1] : %f (clipping to 1.0)\",getInstName(),i,ultime[i]);\n        ultime[i] = 1.0;\n      }\n    }\n  }\n  if (nDltime > 0) {\n    enab[FUNCT_DOWNLEVELTIME] = 1;\n    dltime = (double*)calloc(1,sizeof(double)*nDltime);\n\n    // load upleveltime info\n    for (i=0; i<nDltime; i++) {\n      dltime[i] = getDouble_f(myvprint(\"downleveltime[%i]\",i));\n      if (dltime[i] < 0.0) {\n        SMILE_WRN(2,\"(inst '%s') upleveltime[%i] is out of range [0..1] : %f (clipping to 0.0)\",getInstName(),i,dltime[i]);\n        dltime[i] = 0.0;\n      }\n      if (dltime[i] > 1.0) {\n        SMILE_WRN(2,\"(inst '%s') downleveltime[%i] is out of range [0..1] : %f (clipping to 1.0)\",getInstName(),i,dltime[i]);\n        dltime[i] = 1.0;\n      }\n    }\n  }\n\n  cFunctionalComponent::fetchConfig();\n  if (enab[FUNCT_UPLEVELTIME]) nEnab += nUltime-1;\n  if (enab[FUNCT_DOWNLEVELTIME]) nEnab += nDltime-1;\n  \n  // compute new var index:\n  varFctIdx = 0;\n  for (i=0; i<IDX_VAR_FUNCTS; i++) {\n    if (enab[i]) varFctIdx++;\n  }\n}\n\nconst char* cFunctionalTimes::getValueName(long i)\n{\n  if (i<varFctIdx) {\n    return cFunctionalComponent::getValueName(i);\n  }\n  if (i>=varFctIdx) {\n    int j=varFctIdx;\n    int dl=0;\n    // check, if up- or downleveltime is referenced:\n    i -= varFctIdx;\n    if (i>=nUltime) { j++; i-= nUltime; dl = 1; }\n    const char *n = cFunctionalComponent::getValueName(j);\n    // append [i]\n    if (tmpstr != NULL) free(tmpstr);\n    if (!dl) {\n      tmpstr = myvprint(\"%s%.1f\",n,ultime[i]*100.0);\n    } else {\n      tmpstr = myvprint(\"%s%.1f\",n,dltime[i]*100.0);\n    }\n    return tmpstr;\n  }\n  return \"UNDEF\";\n}\n\n\nFLOAT_DMEM cFunctionalTimes::getPctlMin(FLOAT_DMEM *sorted, long N)\n{\n  long idx = (long)round(pctlRangeMargin_ * (FLOAT_DMEM)(N - 1));\n  if (idx < 0)\n    idx = 0;\n  if (idx >= N)\n    idx = N - 1;\n  return sorted[idx];\n}\n\nFLOAT_DMEM cFunctionalTimes::getPctlMax(FLOAT_DMEM *sorted, long N)\n{\n  long idx = (long)round(((FLOAT_DMEM)1.0 \n    - pctlRangeMargin_) * (FLOAT_DMEM)(N - 1));\n  if (idx < 0)\n    idx = 0;\n  if (idx >= N)\n    idx = N - 1;\n  return sorted[idx];\n}\n\nlong cFunctionalTimes::process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted,  FLOAT_DMEM min,\n    FLOAT_DMEM max, FLOAT_DMEM mean, FLOAT_DMEM *out, long Nin, long Nout)\n{\n  if ((Nin>0)&&(out!=NULL)) {\n    int n=0;\n\n    FLOAT_DMEM *i0 = in;\n    FLOAT_DMEM *iE = in+Nin;\n    FLOAT_DMEM Nind = (FLOAT_DMEM)Nin;\n\n    FLOAT_DMEM Norm, Norm1, Norm2;\n    Norm=Nind; Norm1=Nind-(FLOAT_DMEM)1.0; Norm2=Nind-(FLOAT_DMEM)2.0;\n\n    FLOAT_DMEM _T = 1.0; \n    if (timeNorm==NORM_SECOND) {\n      _T = (FLOAT_DMEM)getInputPeriod();\n                           \n      if (_T != 0.0) {\n        if (buggySecNorm) {//OLD mode!!: \n          Norm /= _T; Norm1 /= _T; Norm2 /= _T;\n        } else {\n          Norm = (FLOAT_DMEM)(1.0)/_T;\n          Norm1 /= Nind*_T;\n          Norm2 /= Nind*_T;\n        }\n      }\n    }\n    if (timeNorm==NORM_FRAME) {\n      Norm = 1.0; Norm1 /= Nind; Norm2 /= Nind;\n    }\n\n    FLOAT_DMEM range;\n    if (useRobustPercentileRange_) {\n      if (inSorted == NULL) {\n        SMILE_IERR(1, \"Expected sorted input, however got NULL! Fallback to max-min range instead of percentiles\");\n        range = max - min;\n      } else {\n        // use percentiles for max/min\n        range = getPctlMax(inSorted, Nin) - getPctlMin(inSorted, Nin);\n      }\n    } else {\n      range = max - min;\n    }\n\n    FLOAT_DMEM l25, l50, l75, l90;\n    l25 = (FLOAT_DMEM)0.25*range+min;\n    l50 = (FLOAT_DMEM)0.50*range+min;\n    l75 = (FLOAT_DMEM)0.75*range+min;\n    l90 = (FLOAT_DMEM)0.90*range+min;\n    long n25=0, n50=0, n75=0, n90=0;\n    long nR=0, nF=0, nLC=0, nRC=0;\n    \n    // first pass: predefined ul/dl times AND rise/fall, etc.\n    if ((enab[FUNCT_UPLEVELTIME25])||(enab[FUNCT_DOWNLEVELTIME25]) ||\n        (enab[FUNCT_UPLEVELTIME50])||(enab[FUNCT_DOWNLEVELTIME50]) ||\n        (enab[FUNCT_UPLEVELTIME75])||(enab[FUNCT_DOWNLEVELTIME75]) ||\n        (enab[FUNCT_UPLEVELTIME90])||(enab[FUNCT_DOWNLEVELTIME90])) {\n      while (in<iE) {\n        if (*in <= l25) n25++;\n        if (*in <= l50) n50++;\n        if (*in <= l75) n75++;\n        if (*(in++) <= l90) n90++;\n      }\n      in = i0;\n    }\n    if ((enab[FUNCT_RISETIME])||(enab[FUNCT_FALLTIME])) {\n      while (++in<iE) {\n//      for (i=1; i<Nin; i++) {\n        if (*(in-1) < *in) nR++;      // rise\n        else if (*(in-1) > *in) nF++; // fall\n//        in++;\n      }\n      in = i0;\n    }\n    if ((enab[FUNCT_LEFTCTIME])||(enab[FUNCT_RIGHTCTIME])) {\n      FLOAT_DMEM a1,a2;\n      while (++in<iE-1) {\n//      for (i=1; i<Nin-1; i++) {\n        a1 = *(in)-*(in-1);\n        a2 = *(in+1)-*(in);\n        if ( a2 < a1 ) nRC++;      // right curve\n        else if ( a1 < a2) nLC++;  // left curve\n//        in++;\n      }\n      in = i0;\n    }\n\n    if (enab[FUNCT_UPLEVELTIME25]) out[n++]=((FLOAT_DMEM)(Nin-n25))/Norm;\n    if (enab[FUNCT_DOWNLEVELTIME25]) out[n++]=((FLOAT_DMEM)(n25))/Norm;\n    if (enab[FUNCT_UPLEVELTIME50]) out[n++]=((FLOAT_DMEM)(Nin-n50))/Norm;\n    if (enab[FUNCT_DOWNLEVELTIME50]) out[n++]=((FLOAT_DMEM)(n50))/Norm;\n    if (enab[FUNCT_UPLEVELTIME75]) out[n++]=((FLOAT_DMEM)(Nin-n75))/Norm;\n    if (enab[FUNCT_DOWNLEVELTIME75]) out[n++]=((FLOAT_DMEM)(n75))/Norm;\n    if (enab[FUNCT_UPLEVELTIME90]) out[n++]=((FLOAT_DMEM)(Nin-n90))/Norm;\n    if (enab[FUNCT_DOWNLEVELTIME90]) out[n++]=((FLOAT_DMEM)(n90))/Norm;\n\n    if (Norm1 != 0.0) {\n      if (enab[FUNCT_RISETIME]) out[n++]=((FLOAT_DMEM)nR)/Norm1;\n      if (enab[FUNCT_FALLTIME]) out[n++]=((FLOAT_DMEM)nF)/Norm1;\n    } else {\n      if (enab[FUNCT_RISETIME]) out[n++]=0.0;\n      if (enab[FUNCT_FALLTIME]) out[n++]=0.0;\n    }\n    if (Norm2 != 0.0) {\n      if (enab[FUNCT_LEFTCTIME]) out[n++]=((FLOAT_DMEM)nLC)/Norm2;\n      if (enab[FUNCT_RIGHTCTIME]) out[n++]=((FLOAT_DMEM)nRC)/Norm2;\n    } else {\n      if (enab[FUNCT_LEFTCTIME]) out[n++]=0.0;\n      if (enab[FUNCT_RIGHTCTIME]) out[n++]=0.0;\n    }\n\n    if (enab[FUNCT_DURATION]) {\n      if (timeNorm==NORM_SECOND) {\n        out[n++]=((FLOAT_DMEM)(Nin)*_T);\n      } else {\n        out[n++]=((FLOAT_DMEM)(Nin));\n      }\n    }\n\n    // second pass, user defined times\n    int j;\n    if (enab[FUNCT_UPLEVELTIME]) {\n      for (j=0; j<nUltime; j++) {\n        FLOAT_DMEM lX = (FLOAT_DMEM)(ultime[j]*range+min);\n        long nX=0;\n        while (in<iE) if (*(in++) > lX) nX++;\n        in = i0;\n        out[n++] = ((FLOAT_DMEM)(nX))/Norm;\n      }\n    }\n    if (enab[FUNCT_DOWNLEVELTIME]) {\n      for (j=0; j<nDltime; j++) {\n        FLOAT_DMEM lX = (FLOAT_DMEM)(dltime[j]*range+min);\n        long nX=0;\n        while (in<iE) if (*(in++) <= lX) nX++;\n        in = i0;\n        out[n++] = ((FLOAT_DMEM)(nX))/Norm;\n      }\n    }\n    \n    return n;\n  }\n  return 0;\n}\n\n/*\nlong cFunctionalTimes::process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout)\n{\n\n  return 0;\n}\n*/\n\ncFunctionalTimes::~cFunctionalTimes()\n{\n  if(ultime!=NULL) free(ultime);\n  if(dltime!=NULL) free(dltime);\n}\n\n"
  },
  {
    "path": "src/functionals/functionals.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctionals meta-component\n \n*/\n\n\n#include <core/dataMemory.hpp>\n#include <core/componentManager.hpp>\n#include <functionals/functionals.hpp>\n\n#include <math.h>\n\n#define MODULE \"cFunctionals\"\n\n\n#define N_BLOCK_ALLOC 50\n\nSMILECOMPONENT_STATICS(cFunctionals)\nint cFunctionals::rAcounter=0;\nDLLEXPORT void resetFunctionalsRaCounter() {\n  cFunctionals::rAcounter = 0;\n}\n\nSMILECOMPONENT_REGCOMP(cFunctionals)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  \n  scname = COMPONENT_NAME_CFUNCTIONALS;\n  sdescription = COMPONENT_DESCRIPTION_CFUNCTIONALS;\n\n  // we inherit cWinToVecProcessor configType and extend it:\n//use _compman to find cFunctionalXXXXX component types...\n// however, we return rA=1 twice, to allow cFunctionalXXXX to register!\n  // add corresponding config sub-types to our config type here....\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cWinToVecProcessor\")\n\n  char *funclist=NULL;\n\n  SMILECOMPONENT_IFNOTREGAGAIN_BEGIN\n\n    if (rAcounter < 2) {\n      rA=1;\n      rAcounter++;\n      SMILECOMPONENT_MAKEINFO(cFunctionals);\n    }\n\n    if (_compman != NULL) {\n  \n      int nTp = _compman->getNtypes();\n      int i,j=0;\n      for (i=0; i<nTp; i++) {\n        const char * tp = _compman->getComponentType(i,1);\n        if (tp!=NULL) {\n          if (!strncmp(tp,\"cFunctional\",11)&&strncmp(tp,COMPONENT_NAME_CFUNCTIONALS,COMPONENT_NAME_CFUNCTIONALS_LENGTH)) {\n             // find beginning \"cFunctional\" but not our own type (cFunctinals)\n            const char *fn = tp+11;\n            j++;\n            if (funclist != NULL) {\n              char * tmp = funclist;\n              funclist = myvprint(\"%s      %i.\\t%s \\t\\t%s\\n\",funclist,j,fn,_compman->getComponentDescr(i));\n              free(tmp);\n            } else {\n              funclist = myvprint(\"     (#) \\t(name)    \\t\\t(description)\\n      %i.\\t%s \\t\\t%s\\n\",j,fn,_compman->getComponentDescr(i));\n            }\n            // add config type\n            char *x = myvprint(\"functional sub-config of type %s\",tp);\n            ct->setField(fn,x,sconfman->getTypeObj(tp),NO_ARRAY,DONT_FREE);\n            free(x);\n          }\n        }\n      }\n    \n    } else { // cannot proceed without component manager!\n      rA=1;\n      SMILECOMPONENT_MAKEINFO(cFunctionals);\n    }\n\n    char *x = myvprint(\"Array that defines the enabled functionals\\n    The following functionals are available (sub-components) (Attention: the names are case-SENSITIVE!):\\n%s\",funclist);\n    ct->setField(\"functionalsEnabled\",x,(const char*)NULL, ARRAY_TYPE);\n    free(x);\n    free(funclist);\n\n    // set more fields here:\n    // NOT possible : ct->setField(\"globalDuration\",\"output duration of input segment as one value in output (this is useful for variable length inputs)\",0);\n    ct->setField(\"nonZeroFuncts\",\"If this is set to 1, functionals are only applied to input values unequal 0. If this is set to 2, functionals are only applied to input values greater than 0.\",0);\n\n    ct->setField(\"functNameAppend\",\"Specifies a string prefix to append to the functional name (which is appended to the input feature name)\",(const char*)NULL);\n    ct->setField(\"masterTimeNorm\",\"This option specifies how all components should normalise times, if they generate output values related to durations. You can change the 'norm' parameter of individual functional components to overwrite this master value. You can choose one of the following normalisation methods: \\n   'segment' (or: 'turn') : normalise to the range 0..1, the result indicates relative turn length )\\n   'second'  (absolute time in seconds) \\n   'frame' (absolute time in number of frames of input level)\",\"segment\");\n    ct->setField(\"preserveFields\", \"If set to 1, preserves the field structure (and metadata, TODO!), of the input vector structure. If set to 0 (default) the output will only have fields with a single element.\", 0);\n\n  SMILECOMPONENT_IFNOTREGAGAIN_END\n\n  SMILECOMPONENT_MAKEINFO(cFunctionals);\n}\n\nSMILECOMPONENT_CREATE(cFunctionals)\n\n//-----\n\ncFunctionals::cFunctionals(const char *_name) :\n  cWinToVecProcessor(_name),\n  functTp(NULL),\n  functI(NULL),\n  functN(NULL),\n  functTpI(NULL),\n  functObj(NULL),\n  nFunctTpAlloc(0),\n  nFunctTp(0),\n  nonZeroFuncts(0),\n  functNameAppend(NULL),\n  timeNorm(TIMENORM_UNDEFINED)\n{\n\n}\n\n\nint cFunctionals::myConfigureInstance()\n{\n  int i,j;\n\n  nonZeroFuncts = getInt(\"nonZeroFuncts\");\n  SMILE_IDBG(2,\"nonZeroFuncts = %i \\n\",nonZeroFuncts);\n\n  if (getInt(\"preserveFields\")) {\n    wholeMatrixMode = 1;\n    processFieldsInMatrixMode = 1;\n    SMILE_IDBG(2, \"Whole Matrix Mode enabled with per field processing.\");\n  }\n\n  functNameAppend = getStr(\"functNameAppend\");\n  SMILE_IDBG(2,\"functNameAppend = '%s' \\n\",functNameAppend);\n\n  if (isSet(\"masterTimeNorm\")) {\n  const char*Norm = getStr(\"masterTimeNorm\");\n  if (Norm != NULL) {\n    if (!strncmp(Norm,\"seg\",3)) timeNorm=TIMENORM_SEGMENT;\n    else if (!strncmp(Norm,\"tur\",3)) timeNorm=TIMENORM_SEGMENT;\n    else if (!strncmp(Norm,\"sec\",3)) timeNorm=TIMENORM_SECOND;\n    else if (!strncmp(Norm,\"fra\",3)) timeNorm=TIMENORM_FRAME;\n  }\n  } else {\n    timeNorm = TIMENORM_UNDEFINED;\n  }\n\n  cComponentManager *_compman = getCompMan();\n  if (_compman != NULL) {\n    int nTp = _compman->getNtypes();\n    nFunctTp = 0;\n    for (i=0; i<nTp; i++) {\n      const char * tp = _compman->getComponentType(i,1);\n      if (tp!=NULL) {\n        if (!strncmp(tp,\"cFunctional\",11)&&strcmp(tp,COMPONENT_NAME_CFUNCTIONALS)) {\n           // find beginning \"cFunctional\" but not our own type (cFunctinals)\n          const char *fn = tp+11;\n          if (nFunctTpAlloc == nFunctTp) { // realloc:\n            functTp = (char **)crealloc( functTp, sizeof(char*)*(nFunctTpAlloc+N_BLOCK_ALLOC), nFunctTpAlloc );\n            functTpI = (int *)crealloc( functTpI, sizeof(int)*(nFunctTpAlloc+N_BLOCK_ALLOC), nFunctTpAlloc );\n            functI = (int *)crealloc( functI, sizeof(int)*(nFunctTpAlloc+N_BLOCK_ALLOC), nFunctTpAlloc );\n            functN = (int *)crealloc( functN, sizeof(int)*(nFunctTpAlloc+N_BLOCK_ALLOC), nFunctTpAlloc );\n            functObj = (cFunctionalComponent **)crealloc( functObj, sizeof(cFunctionalComponent *)*(nFunctTpAlloc+N_BLOCK_ALLOC), nFunctTpAlloc );\n            nFunctTpAlloc += N_BLOCK_ALLOC;\n          }\n          functTp[nFunctTp] = strdup(fn);\n          functTpI[nFunctTp] = i;\n          nFunctTp++;\n        }\n      }\n    }\n  }\n  SMILE_DBG(2,\"(inst '%s') found %i cFunctionalXXXX component types.\",getInstName(),nFunctTp);\n\n  // fetch enabled functionals list\n  nFunctionalsEnabled = getArraySize(\"functionalsEnabled\");\n  nFunctValues = 0;\n  requireSorted = 0;\n  for (i=0; i<nFunctionalsEnabled; i++) {\n    const char *fname = getStr_f(myvprint(\"functionalsEnabled[%i]\",i));\n    char *tpname = myvprint(\"cFunctional%s\",fname);\n    for (j=0; j<nFunctTp; j++) {\n      if (!strcmp(functTp[j],fname)) {\n        functI[i] = j;\n        break;\n      }\n    }\n// TODO: find duplicates in functionalsEnabled Array!!!\n\n    if (j<nFunctTp) {\n      // and create corresponding component instances...\n        SMILE_IDBG(3,\"creating Functional object 'cFunctional%s'.\",fname);\n        char *_tmp = myvprint(\"%s.%s\",getInstName(),fname);\n        cFunctionalComponent * tmp = (cFunctionalComponent *)(_compman->createComponent)(_tmp,tpname);\n        free(_tmp);\n        if (tmp==NULL) OUT_OF_MEMORY;\n        tmp->setComponentEnvironment(_compman, -1, this);\n        tmp->setTimeNorm(timeNorm);\n        functN[i] = tmp->getNoutputValues();\n        requireSorted += tmp->getRequireSorted();\n        nFunctValues += functN[i];\n        functObj[i] = tmp;\n        //functTp[i]  = strdup(fname);\n    } else {\n      SMILE_ERR(1,\"(inst '%s') Functional object '%s' specified in 'functionalsEnabled' array, however no type 'cFunctional%s' exists!\",getInstName(),fname,fname);\n      functObj[i] = NULL;\n      functN[i] = 0;\n      free(tpname);\n      return 0;\n      //functTp[i]  = NULL;\n    }\n    free(tpname);\n  }\n  if (requireSorted) { \n    SMILE_IDBG(2,\"%i Functional components require sorted data.\",requireSorted);\n  }\n\n  return cWinToVecProcessor::myConfigureInstance();\n}\n\n// We need setupNamesForField if in wholeMatrixMode with ProcessFieldsInMatrixMode\n\nint cFunctionals::setupNamesForElement(int idxi, const char*name, long nEl)\n{\n  // in a winToVecProcessor , nEl should always be 1!\n  int i, j;\n  for (i=0; i<nFunctionalsEnabled; i++) {\n    if ( (functN[i] > 0) && (functObj[i] != NULL) ) {\n      for (j=0; j<functN[i]; j++) {\n        char * newname;\n        if (functNameAppend != NULL) {\n          newname = myvprint(\"%s__%s_%s\",name,functNameAppend,functObj[i]->getValueName(j));\n        } else {\n          newname = myvprint(\"%s_%s\",name,functObj[i]->getValueName(j));\n        }\n\n        const FrameMetaInfo * fmeta = reader_->getFrameMetaInfo();\n        int ao = 0;\n        if (fmeta != NULL && idxi < fmeta->N) {\n          ao = fmeta->field[idxi].arrNameOffset;\n        }\n        long nElementsOut = functObj[i]->getNumberOfElements(j);\n        if (nElementsOut > 0) {\n          writer_->addField(newname, nEl * nElementsOut, ao);\n          if (fmeta != NULL && idxi < fmeta->N) {\n            // copy metadata (e.g. frequency axis labels...)\n            functObj[i]->setFieldMetaData(writer_, fmeta, idxi, nEl * nElementsOut);\n/*            double * buf = (double *)malloc(fmeta->field[idxi].infoSize);\n            memcpy(buf, fmeta->field[idxi].info, fmeta->field[idxi].infoSize);\n            writer_->setFieldInfo(-1, // last field added\n                fmeta->field[idxi].dataType, buf,\n                fmeta->field[idxi].infoSize);*/\n          }\n          // TODO: we need to pass arrNameOffset through setupNamesForElement\n          // however, this will require modification of the call in winToVecProcessor\n          // and thus will require several descendant classes to be updated!\n        }\n        free(newname);\n        j += nElementsOut - 1;\n      }\n    }\n  }\n  /*\n  if (globalDuration) {\n    writer->addField(\"inputDuration\");\n  }\n  // ^ we cannot do this in this type of component..!\n  */\n  return nFunctValues * nEl;\n}\n\n// this must return the multiplier, i.e. the vector size returned for each input element (e.g. number of functionals, etc.)\nint cFunctionals::getMultiplier()\n{\n  return nFunctValues;\n}\n\nint cFunctionals::doProcessMatrix(int idx, cMatrix *rows, FLOAT_DMEM *y, long nOut)\n{\n  // call doProcess for each row...\n  cMatrix *tmpRow = NULL;\n  FLOAT_DMEM *tmpY = (FLOAT_DMEM *)calloc(1, sizeof(FLOAT_DMEM) * nOut);\n  FLOAT_DMEM *curY = tmpY;\n  long nFuncts = 0;\n  if (rows != NULL) {\n    for (int i = 0; i < rows->N; i++) {\n      tmpRow = rows->getRow(i, tmpRow);\n      long Mu = doProcess(i, tmpRow, curY);\n      curY += Mu;\n      if (nFuncts == 0) nFuncts = Mu;\n    }\n    // re-order output vector\n    for (int j = 0; j < nFuncts; j++) {\n      for (int i = 0; i < rows->N; i++) {\n        *y = tmpY[i*nFuncts + j];\n        y++;\n      }\n    }\n  }\n  if (rows->N * nFuncts != nOut) {\n    SMILE_IERR(2, \"something is wrong in doProcessMatrix in cFunctionals. expected # outputs %i vs. real num outputs %i (%i * %i)\", nOut, rows->N * nFuncts, rows->N, nFuncts);\n  }\n  free(tmpY);\n  if (tmpRow != NULL) {\n    delete tmpRow;\n  }\n  return rows->N * nFuncts;\n}\n\n\n// idxi is index of input element\n// row is the input row\n// y is the output vector (part) for the input row\nint cFunctionals::doProcess(int idxi, cMatrix *row, FLOAT_DMEM*y)\n{\n  // copy row to matrix... simple memcpy here\n  //  memcpy(y,row->dataF,row->nT*sizeof(FLOAT_DMEM));\n  // return the number of components in y!!\n  if (row->nT <= 0) {\n    SMILE_IWRN(2,\"not processing input row of size <= 0 ! (inst '%s')\",getInstName());\n    return 0;\n  }\n  SMILE_IDBG(4, \"cFunctionals::doProcess (nT = %ld) idxi %i\\n\", getInstName(), row->nT, idxi);\n\n  long i; int ok=0; long NN=row->nT;\n  FLOAT_DMEM * unsorted = row->dataF;\n  FLOAT_DMEM * sorted=NULL;\n  \n  if (nonZeroFuncts) {\n    NN = 0;\n    unsorted = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*row->nT);\n    if (nonZeroFuncts == 2) {\n      for (i=0; i<row->nT; i++) {\n        if (row->dataF[i] > 0.0) unsorted[NN++] = row->dataF[i];\n      }\n    } else {\n      for (i=0; i<row->nT; i++) {\n        if (row->dataF[i] != 0.0) unsorted[NN++] = row->dataF[i];\n      }\n    }\n  }\n\n  if (requireSorted) {\n    sorted = (FLOAT_DMEM*)malloc( sizeof(FLOAT_DMEM)*NN );\n    // quicksort:\n    memcpy( sorted, unsorted, sizeof(FLOAT_DMEM) * NN );\n    // TODO: check for float_dmem::: with #if ...\n    #if FLOAT_DMEM_NUM == FLOAT_DMEM_FLOAT\n    smileUtil_quickSort_float( sorted, NN );\n    #else\n    smileUtil_quickSort_double( sorted, NN );\n    #endif\n  }\n\n  // find max and min value, also compute arithmetic mean\n  // these 3 values are required by a lot of functionals, so we do it here..\n  FLOAT_DMEM *x=unsorted;\n  FLOAT_DMEM min=*x,max=*x;\n  double mean=*x;\n  FLOAT_DMEM *xE = unsorted+NN;\n  while (++x<xE) {\n    if (*x<min) min=*x;\n    if (*x>max) max=*x;\n    mean += (double)*x;\n  } mean /= (double)NN;\n  \n  FLOAT_DMEM *curY = y;\n  for (i=0; i<nFunctionalsEnabled; i++) {\n    if (functObj[i] != NULL) {\n      functObj[i]->setInputPeriod(getInputPeriod());\n      int ret;\n      ret = functObj[i]->process( unsorted, sorted, min, max, (FLOAT_DMEM)mean, curY, NN, functN[i] );\n      if (ret < functN[i]) {\n        int j;\n        for (j=ret; j<functN[i]; j++) curY[j] = 0.0;\n      }\n      if (ret>0) ok++;\n  \t  curY += functN[i];\n    }\n  }\n\n  if (requireSorted) {\n    free(sorted);\n  }\n  if (nonZeroFuncts) {\n    free(unsorted);\n  }\n  \n  return nFunctValues;\n\n/*\n  } else if (row->type == DMEM_INT) {\n    // TODO....\n    SMILE_ERR(1,\"type DMEM_INT not yet supported in cFunctionals!\");\n    return 0;\n  } else {\n    SMILE_ERR(1,\"unknown datatype encountered in cFunctionals doProcess!\");\n    return 0;\n  }\n*/\n\n}\n\n/* TODO\nint cFunctionals::doProcess(int idxi, cMatrix *row, INT_DMEM*y)\n{\n  // copy row to matrix... simple memcpy here\n  //memcpy(y,row->dataI,row->nT*sizeof(INT_DMEM));\n  // return the number of components in y!!\n  return nFunctsEnabled;\n}\n*/\n\ncFunctionals::~cFunctionals()\n{\n  int i;\n  if (functTp != NULL) {\n    for (i=0; i<nFunctTpAlloc; i++)\n      if (functTp[i] != NULL) free(functTp[i]);\n    free(functTp);\n  }\n  if (functI != NULL) free(functI);\n  if (functN != NULL) free(functN);\n  if (functTpI != NULL) free(functTpI);\n  if (functObj != NULL) {\n    for (i=0; i<nFunctTpAlloc; i++)\n      if (functObj[i] != NULL) delete(functObj[i]);\n    free(functObj);\n  }\n}\n\n////  to implement in a cFunctionalXXXX object:\n/*\n(fetchConfig)\nNO myCOnfigure / my Finalise !!\ngetNoutputValues\ngetValueName\ngetRequireSorted\nprocess\n*/\n"
  },
  {
    "path": "src/include/android/jniMessageInterface.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n#ifndef __CJNIMESSAGEINTERFACE_HPP\n#define __CJNIMESSAGEINTERFACE_HPP\n\n#include <core/smileCommon.hpp>\n#ifdef __ANDROID__\n#define BUILD_COMPONENT_JniMessageInterface\n#ifdef BUILD_COMPONENT_JniMessageInterface\n#include <list>\n#include <jni.h>\n#include <core/smileComponent.hpp>\n\n#define COMPONENT_DESCRIPTION_CJNIMESSAGEINTERFACE \"Component for transferring smile component messages from native C to Java via JNI interface.\\n\"\n#define COMPONENT_NAME_CJNIMESSAGEINTERFACE \"cJniMessageInterface\"\n\n#undef class\nclass DLLEXPORT cJniMessageInterface : public cSmileComponent {\nprivate:\n\nprotected:\n  SMILECOMPONENT_STATIC_DECL_PR\n\n  int debugPrintJson_;\n  int sendMessagesInTick_;\n  jstring JNIcallbackClassJstring_;\n  JNIEnv *env_;\n  JavaVM *jvm_;\n  jobject * gClassLoader_;\n  jmethodID * gFindClassMethod_;\n  const char * JNIcallbackClass_;\n  const char * JNIstringReceiverMethod_;\n  std::list<cComponentMessage> in_buffer_;\n\n  virtual void fetchConfig();\n\n  JNIEnv * AttachToThreadAndGetEnv();\n  void DetachFromThread(JNIEnv * env);\n  int sendTextToJava(JNIEnv * env, const char * str);\n  int sendMessageToJava(cComponentMessage &msg, JNIEnv * env);\n\n  virtual int sendMessagesFromQueue();\n\npublic:\n  SMILECOMPONENT_STATIC_DECL\n\n  cJniMessageInterface(const char *_name);\n  void setJavaVmPointer(JavaVM * jvm) {\n    jvm_ = jvm;\n  }\n  virtual int processComponentMessage(cComponentMessage *_msg);\n  virtual int myFinaliseInstance();\n  virtual int myTick(long long t);\n  virtual ~cJniMessageInterface();\n};\n\n#endif  // BUILD_COMPONENT\n#endif  // __ANDROID__\n#endif  // __CJNIMESSAGEINTERFACE_HPP\n"
  },
  {
    "path": "src/include/android/openslesSource.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n***\n***(c) 2014-2015 audEERING UG. All rights reserved.\n***\n***Fixed and updated by Florian Eyben, fe@audeering.com\n***\n***by Bernd Huber, 2014\n***   berndbhuber@gmail.com\n\nreads openSL audio buffer input into datamemory\n\n*/\n\n#ifndef __COPENSLESSOURCE_HPP\n#define __COPENSLESSOURCE_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataSource.hpp>\n\n#ifdef __ANDROID__\n#ifndef __STATIC_LINK\n#ifdef HAVE_OPENSLES\n\n#define BUILD_COMPONENT_OpenslesSource\n\n#define COMPONENT_DESCRIPTION_COPENSLESSOURCE \"This component reads opensl audio buffer input into datamemory.\"\n#define COMPONENT_NAME_COPENSLESSOURCE \"cOpenslesSource\"\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <cstring>\n#include <fstream>\n#include <sstream>\n#include <vector>\n#include <iostream>\n\n#include <SLES/OpenSLES.h>\n#include <SLES/OpenSLES_Android.h>\n//#include <pthread.h>   // check if this is really required, as we use smileThread pthread layer!\n\n/*typedef struct threadLock_{\n  pthread_mutex_t m;\n  pthread_cond_t  c;\n  unsigned char   s;\n} threadLock;\n*/\n\nusing namespace std;\n#define BUFFERFRAMES 1024\n#define VECSAMPS_MONO 64\n#define VECSAMPS_STEREO 128\n#define SR 44100\n#define CONV16BIT 32768\n#define CONVMYFLT (1./32768.)\n\n#define NUM_RECORDING_BUFFERS  2\n#define NUM_PLAYBACK_BUFFERS   2\n\ntypedef struct opensl_stream22 {\n  // engine interfaces\n  SLObjectItf engineObject;\n  SLEngineItf engineEngine;\n  // output mix interfaces\n  SLObjectItf outputMixObject;\n  // buffer queue player interfaces\n  SLObjectItf bqPlayerObject;\n  SLPlayItf bqPlayerPlay;\n  SLAndroidSimpleBufferQueueItf bqPlayerBufferQueue;\n  SLEffectSendItf bqPlayerEffectSend;\n  // recorder interfaces\n  SLObjectItf recorderObject;\n  SLRecordItf recorderRecord;\n  SLAndroidSimpleBufferQueueItf recorderBufferQueue;\n  // buffer indexes\n  int currentInputIndex;\n  int currentOutputIndex;\n  // current buffer half (0, 1)\n  int currentOutputBuffer;\n  int currentInputBuffer;\n  // buffers\n  int16_t * outputBuffer[NUM_RECORDING_BUFFERS];\n  int16_t * inputBuffer[NUM_PLAYBACK_BUFFERS];\n  // size of buffers\n  int outBufSamples;\n  int inBufSamples;\n  double inBufMSeconds;\n  // locks\n  smileCond  recorderCondition_;\n  smileCond  playerCondition_;\n  smileMutex newDataMutex_;\n  int hasNewInputData_;\n  bool doNotEnqueue_;\n  double time;\n  int inchannels;\n  int outchannels;\n  int sr;  // sampling rate\n} opensl_stream2;\n\n\n#undef class\nclass DLLEXPORT cOpenslesSource : public cDataSource {\nprivate:\n\n  opensl_stream2 * audioDevice_;\n\n      // if set to 1, multi-channel files will be mixed down to 1 channel\n  //long curReadPos;   // in samples\n  //int eof, abort; // NOTE : when setting abort, first lock the callbackMtx!!!\n\n  long blockSizeReader_;\n\n  // audio settings\n  int monoMixdown_;\n  int nChannels_;\n  int nChannelsEffective_;   // nChannels or 1 if monoMixdown\n  int sampleRate_;\n  int nBits_;\n  int nBPS_;\n  int selectChannel_;\n  long audioBuffersize_;\n  double audioBuffersize_sec_;\n\n  bool agcDebug_;\n  int agcDebugCounter_;\n  FLOAT_DMEM agcTarget_;\n  FLOAT_DMEM agcGain_;\n  FLOAT_DMEM agcPeakLp_;\n  FLOAT_DMEM agcGainMin_;\n  FLOAT_DMEM agcGainMax_;\n  FLOAT_DMEM agcErrorIntegrated_;\n\n  // variables for the background thread sync:\n  smileMutex dataFlagMutex_;\n  smileMutex threadMutex_;\n  smileCond  threadCondition_;\n  cMatrix *threadMatrix_;\n  bool dataFlag_;\n  bool threadActive_;\n  bool threadStarted_;\n  //int isInTickLoop_;\n  bool agcEnabled_;\n\n  // other\n  bool warned_;\n  const char *outFieldName_;\n\n  // Audio recording queue thread\n  smileThread recordingThread_;\n  static SMILE_THREAD_RETVAL recordingThreadEntry(void *param);\n  void recordingThreadLoop();\n\n\nprotected:\n  SMILECOMPONENT_STATIC_DECL_PR\n\n  virtual void fetchConfig();\n  virtual int myConfigureInstance();\n  virtual int myTick(long long t);\n\n  virtual int configureWriter(sDmLevelConfig &c);\n  virtual int setupNewNames(long nEl);\n  virtual int myFinaliseInstance();\n\npublic:\n  SMILECOMPONENT_STATIC_DECL\n\n  cOpenslesSource(const char *_name);\n  void performAgc(cMatrix * samples);\n  /*\n  void setNewDataFlag() {\n    smileMutexLock(dataFlagMtx);\n    dataFlag = 1;\n    lastDataCount=0;\n    smileMutexUnlock(dataFlagMtx);\n  }\n*/\n\n  bool setupAudioDevice();\n  bool startRecordingThread();\n  void terminateAudioRecordingThread();\n\n  //socket flags\n  //int isReaderThreadStarted,isComponentConfigured,isReaderConfigured;\n  //int isStillReading;\n  //bool isReaderSet;\n\n  //datamemory parameters\n  //int frameN,frameSizeSec,fieldN,nChannels;\n  //double blockSizeR,frameT;\n\n\n\n\n\n\n  /*\n\tOpen the audio device with a given sampling rate (sr), input and output channels and IO buffer size\n\tin frames. Returns a handle to the OpenSL stream\n   */\n  opensl_stream2 * android_OpenAudioDevice(int sr,\n      int inchannels, int outchannels, int bufferframes,\n      bool openPlayer, bool openRecording);\n  /*\n\tClose the audio device\n   */\n  void android_CloseAudioDevice(opensl_stream2 *p);\n  /*\n\tRead a buffer from the OpenSL stream *p, of size samples. Returns the number of samples read.\n   */\n  int android_AudioIn(opensl_stream2 *p, int16_t * buffer, int size);\n  /*\n\tWrite a buffer to the OpenSL stream *p, of size samples. Returns the number of samples written.\n   */\n  int android_AudioOut(opensl_stream2 *p, float *buffer,int size);\n  /*\n\tGet the current IO block time in seconds\n   */\n  double android_GetTimestamp(opensl_stream2 *p);\n\n  virtual ~cOpenslesSource();\n};\n\nvoid bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context);\nvoid bqRecorderCallback(SLAndroidSimpleBufferQueueItf bq, void *context);\n\nSLresult openSLCreateEngine(opensl_stream2 *p);\nSLresult openSLPlayOpen(opensl_stream2 *p);\nSLresult openSLRecOpen(opensl_stream2 *p);\nSLresult openSLstartRecording(opensl_stream2 *p);\nSLresult openSLstopRecording(opensl_stream2 *p);\nvoid openSLDestroyEngine(opensl_stream2 *p);\n\n#endif // HAVE_OPENSLES\n#endif // !__STATIC_LINK\n#endif // __ANDROID__\n\n#endif // __COPENSLESSOURCE_HPP\n"
  },
  {
    "path": "src/include/classifiers/julius/juliusSink.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nTUM keyword spotter (Julius version)\n\n*/\n\n\n#ifndef __CJULIUSSINK_HPP\n#define __CJULIUSSINK_HPP\n\n#include <core/smileCommon.hpp>\n\n//#define HAVE_JULIUSLIB\n#ifdef HAVE_JULIUSLIB\n\n#include <core/dataSink.hpp>\n\n// STL includes for the queue\n#include <queue>\n\n// apr seems to define its own true, so we undefine it here... (we just have to make sure that we include this header file after any other apr/semaine/etc. headers\n#ifdef TRUE\n#undef TRUE\n#endif \n\nextern \"C\" {\n#undef LOG_DEBUG\n#include <julius/juliuslib.h>\n// julius defines min, max, abs, which collides with GNU stdlib and XQilla abs()\n// there might be more of these silly lowercase(!) defines... Isn't it common practice to have all defines in uppercase where possible??\n#undef abs\n#undef min\n#undef max\n}\n\n\n#define COMPONENT_DESCRIPTION_CJULIUSSINK \"keyword spotter using Julius decoder\"\n#define COMPONENT_NAME_CJULIUSSINK \"cJuliusSink\"\n\n#define MAX_PHONEME_STRLEN  5\n\n#include <classifiers/julius/kwsjKresult.h>\n\n#undef class\n\n\n\n\nclass DLLEXPORT cJuliusSink : public cDataSink {\n  private:\n    TurnMsgQueue tsq;   // turn start queue\n    TurnMsgQueue teq;   // turn end queue\n    int maxTurnQue;\n    int running;\n    int nopass2;\n    int offlineMode;\n    int noTurns;\n    int purgeQue;\n    long midx;\n\n    const char * configfile;\n    smileMutex terminatedMtx;\n    smileThread decoderThread;\n    smileMutex dataFlgMtx;\n    smileCond  tickCond;\n    int juliusIsSetup, juliusIsRunning;\n    double period;\n\n    int sendKwsResult;\n    int sendJuliusResult;\n    const char * kwsResultRecp;\n    const char * juliusResultRecp;\n\n \n\n    // number of silence frames to keep at beginning and end of turn\n    int preSil, postSil;\n    long lag, endWait;\n    int nPre, nPost;\n    long curVidx, vIdxStart, vIdxEnd;\n\n\t  const char * logfile;\n    FILE *fp;\n    Recog *recog;\n    Jconf *jconf;\n\n    int decoderThreadPriority;\n\n    bool terminated;\n    int dataFlag;\n    int turnEnd; int turnStart; int isTurn;\n    const cVector *curVec;\n\n    double turnStartSmileTime, turnStartSmileTimeLast, turnStartSmileTimeCur;\n\n    const char *keywordList;\n    char **keywords;\n    int kwIndexStart[27*26];\n    int kwIndexEnd[27*26];\n    int numKw;\n    int nExclude;\n    const char **excludeWords;\n\n    /*\n    char * sentence;\n    int speakingIndex,seqIdx;\n    int nFeaturesSelected;\n    int *featureIndex;\n    long long curTime;\n    int wasSpeaking;\n  */  \n    \n/*\nint prevSpeakingIndex;\n    int thisSpeakingIndex;\n    int countdown;\n    bool outputtrigger;\n*/\n\n    /* required by julius output functions ? */\n    int writelen;\n    int wst;\n\n    int setupJulius();\n    int startJuliusDecoder();\n\n    void setupCallbacks(Recog *recog, void *data);\n\n//    void juPutHypoPhoneme(WORD_ID *seq, int n, WORD_INFO *winfo);\n    void juAlignPass1Keywords(RecogProcess *r, HTK_Param *param);\n\n    int excludeWord(const char * w);\n    juliusResult * fillJresult(Sentence *s, WORD_INFO *winfo, int numOfFrames);\n    void loadKeywordList();\n    int makeKwIndex(const char *kw);\n    int isKeyword(const char *word);\n    int tagKeywords(juliusResult *r);\n    void keywordFilter(juliusResult *r);\n\n    int checkMessageQueue();\n    \n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    int printResult;\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n    //virtual void processResult(long long tick, long frameIdx, double time);\n    virtual int processComponentMessage( cComponentMessage *_msg );\n\n  public:\n    //static sComponentInfo * registerComponent(cConfigManager *_confman);\n    //static cSmileComponent * create(const char *_instname);\n    SMILECOMPONENT_STATIC_DECL\n\n   \n    void ATKresultThread();\n    cJuliusSink(const char *_name);\n\n    void juliusDecoderThread();\n\n      \n      /* callbacks for julius : */\n\n    int getFv(float *vec, int n);\n\n    LOGPROB cbUserlmUni(WORD_INFO *winfo, WORD_ID w, LOGPROB ngram_prob);\n    LOGPROB cbUserlmBi(WORD_INFO *winfo, WORD_ID context, WORD_ID w, LOGPROB ngram_prob);\n    LOGPROB cbUserlmLm(WORD_INFO *winfo, WORD_ID *contexts, int clen, WORD_ID w, LOGPROB ngram_prob);\n\n    void cbResultPass1(Recog *recog, void *dummy);\n    void cbResultPass1Current(Recog *recog, void *dummy);\n    void cbStatusPass1Begin(Recog *recog, void *dummy);\n\n    void cbResultPass2(Recog *recog, void *dummy);\n\n    virtual ~cJuliusSink();\n};\n\n\n\n#endif //HAVE_JULIUSLIB\n\n\n\n#endif // __CJULIUSSINK_HPP\n"
  },
  {
    "path": "src/include/classifiers/julius/kwsjKresult.h",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n#ifndef __KWSJ_RESULT_H\n#define __KWSJ_RESULT_H\n\n\n// STL includes for the queue\n#include <queue>\n\n// A message received from the turn detector.\nstruct TurnMsg {\n    TurnMsg() : time(0), vIdx(0), isForcedTurnEnd(0) {}\n    double time;     // smile time or whatever\n    long vIdx;        // vector index\n    int isForcedTurnEnd;  // forced turn end = at end of input\n    long midx;\n};\n\n// A queue of turn detector messages.\ntypedef std::queue<TurnMsg> TurnMsgQueue;\n\n\n/* keyword spotter result message */\n#define MAXNUMKW 100\n// old message:\ntypedef struct kresult {\n  int numOfKw;\n  int turnDuration;\n  double kwStartTime[MAXNUMKW]; // time in seconds\n  const char* keyword[MAXNUMKW];\n  float kwConf[MAXNUMKW];\n} Kresult;\n\n\n// new message:\n#define JULIUSRESULT_FLAG_KEYWORD   1\n\nclass juliusResult {\n  public:\n    int numW;\n    char ** word; // word array\n    unsigned int * wordFlag;\n    char ** phstr; // phoneme string for each word (phonemes are space separated)\n    float * conf;\n    float * start;\n    float * end;\n    long userFlag;\n    double amScore, lmScore, score;\n    double duration;\n\n    juliusResult() : numW(0), word(NULL), phstr(NULL), conf(NULL), start(NULL), end(NULL), wordFlag(NULL), amScore(0.0), lmScore(0.0), score(0.0), duration(0.0), userFlag(0) {}\n\n    juliusResult( int N ) : numW(N), word(NULL), phstr(NULL), conf(NULL), start(NULL), end(NULL), wordFlag(NULL), amScore(0.0), lmScore(0.0), score(0.0), duration(0.0), userFlag(0) {\n      if (numW > 0) {\n        word = (char**) calloc(1, sizeof(char*) * numW * 2);\n        phstr = word + numW;\n        conf = (float*) calloc(1, sizeof(float) * numW * 3);\n        start = conf + numW;\n        end = start + numW;\n        wordFlag = (unsigned int*)calloc(1,sizeof(unsigned int) * numW);\n      }\n    }\n\n    ~juliusResult() {\n      int i;\n      if (word != NULL) {\n        for (i=0; i<numW*2; i++) { if (word[i] != NULL) free(word[i]); }\n        free(word);\n      }\n      if (conf != NULL) { free(conf); }\n      if (wordFlag != NULL) { free(wordFlag); }\n    }\n};\n\n#endif // __KWSJ_RESULT_H\n"
  },
  {
    "path": "src/include/classifiers/libsvm/COPYRIGHT",
    "content": "\nCopyright (c) 2000-2008 Chih-Chung Chang and Chih-Jen Lin\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n\n1. Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright\nnotice, this list of conditions and the following disclaimer in the\ndocumentation and/or other materials provided with the distribution.\n\n3. Neither name of copyright holders nor the names of its contributors\nmay be used to endorse or promote products derived from this software\nwithout specific prior written permission.\n\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR\nCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\nEXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\nPROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\nPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
  },
  {
    "path": "src/include/classifiers/libsvm/svm.h",
    "content": "/*\nLibSVM header file\n\nCopyright (c) 2000-2008 Chih-Chung Chang and Chih-Jen Lin\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n\n1. Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright\nnotice, this list of conditions and the following disclaimer in the\ndocumentation and/or other materials provided with the distribution.\n\n3. Neither name of copyright holders nor the names of its contributors\nmay be used to endorse or promote products derived from this software\nwithout specific prior written permission.\n\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR\nCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\nEXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\nPROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\nPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n***************************\nChanges from original code:\n***************************\n\n2009:\n\n* This header file was modified by Florian Eyben in order to better\n  integrate LibSVM into openSMILE\n\n* Functions for saving and loading binary SVM model files were added\n  by Florian Eyben\n\n*/\n\n\n#ifndef _LIBSVM_H\n#define _LIBSVM_H\n\n#define LIBSVM_VERSION 287\n\n#ifndef NOSMILE\n#include <core/smileCommon.hpp>\n#else\n#define DLLEXPORT\n#define BUILD_LIBSVM\n#endif\n\n#ifdef BUILD_LIBSVM\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nstruct svm_node\n{\n\tint index;\n\tdouble value;\n};\n\nstruct svm_problem\n{\n\tint l;\n\tdouble *y;\n\tstruct svm_node **x;\n};\n\nenum { C_SVC, NU_SVC, ONE_CLASS, EPSILON_SVR, NU_SVR };\t/* svm_type */\nenum { LINEAR, POLY, RBF, SIGMOID, PRECOMPUTED }; /* kernel_type */\n\nstruct svm_parameter\n{\n\tint svm_type;\n\tint kernel_type;\n\tint degree;\t/* for poly */\n\tdouble gamma;\t/* for poly/rbf/sigmoid */\n\tdouble coef0;\t/* for poly/sigmoid */\n\n\t/* these are for training only */\n\tdouble cache_size; /* in MB */\n\tdouble eps;\t/* stopping criteria */\n\tdouble C;\t/* for C_SVC, EPSILON_SVR and NU_SVR */\n\tint nr_weight;\t\t/* for C_SVC */\n\tint *weight_label;\t/* for C_SVC */\n\tdouble* weight;\t\t/* for C_SVC */\n\tdouble nu;\t/* for NU_SVC, ONE_CLASS, and NU_SVR */\n\tdouble p;\t/* for EPSILON_SVR */\n\tint shrinking;\t/* use the shrinking heuristics */\n\tint probability; /* do probability estimates */\n};\n\nDLLEXPORT struct svm_model *svm_train(const struct svm_problem *prob, const struct svm_parameter *param);\nDLLEXPORT void svm_cross_validation(const struct svm_problem *prob, const struct svm_parameter *param, int nr_fold, double *target);\n\nDLLEXPORT int svm_save_binary_model(const char *model_file_name, const svm_model *model);\nDLLEXPORT struct svm_model *svm_load_binary_model(const char *model_file_name);\n\nDLLEXPORT struct svm_model *svm_load_ascii_model(const char *model_file_name);\n/* autodetect binary/ascii model: */\nDLLEXPORT struct svm_model *svm_load_model(const char *model_file_name);\n\nDLLEXPORT int svm_save_model(const char *model_file_name, const struct svm_model *model);\n\nDLLEXPORT int svm_get_svm_type(const struct svm_model *model);\nDLLEXPORT int svm_get_sv_size(const struct svm_model *model);\nDLLEXPORT int svm_get_nr_class(const struct svm_model *model);\nDLLEXPORT void svm_get_labels(const struct svm_model *model, int *label);\nDLLEXPORT double svm_get_svr_probability(const struct svm_model *model);\n\nDLLEXPORT void svm_predict_values(const struct svm_model *model, const struct svm_node *x, double* dec_values);\nDLLEXPORT double svm_predict(const struct svm_model *model, const struct svm_node *x);\nDLLEXPORT double svm_predict_probability(const struct svm_model *model, const struct svm_node *x, double* prob_estimates);\n\nDLLEXPORT void svm_destroy_model(struct svm_model *model);\nDLLEXPORT void svm_destroy_param(struct svm_parameter *param);\n\nDLLEXPORT const char *svm_check_parameter(const struct svm_problem *prob, const struct svm_parameter *param);\nDLLEXPORT int svm_check_probability_model(const struct svm_model *model);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif // #ifdef BUILD_LIBSVM\n\n#endif /* _LIBSVM_H */\n"
  },
  {
    "path": "src/include/classifiers/libsvmliveSink.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nLibSVM live classifier/regressor\n\ninherit this class, if you want custom handling of classifier output values..\n\n*/\n\n\n#ifndef __CLIBSVMLIVESINK_HPP\n#define __CLIBSVMLIVESINK_HPP\n\n#include <core/smileCommon.hpp>\n\n//#define BUILD_LIBSVM  // only temporary\n//#define BUILD_LIBLINEAR\n\n#ifdef BUILD_LIBSVM\n#define BUILD_COMPONENT_LibsvmLiveSink\n\n#include <core/smileComponent.hpp>\n#include <core/dataSink.hpp>\n#include <classifiers/libsvm/svm.h>\n#ifdef BUILD_LIBLINEAR\n#include <classifiers/liblinear/linear.h>\n#endif\n\n#define COMPONENT_DESCRIPTION_CLIBSVMLIVESINK \"This component classifies data from dataMemory 'on-the-fly' using the LibSVM or LibLINEAR library. Loading of ASCII and binary LibSVM models is supported, as well as application of LibSVM scale files and openSMILE feature selection lists.\"\n#define COMPONENT_NAME_CLIBSVMLIVESINK \"cLibsvmLiveSink\"\n\nclass DLLEXPORT sClassifierResults {\npublic:\n  sClassifierResults() : res(NULL), prob(NULL), resnameA(NULL), resnameB(NULL), nFilled(0), nResults(0) {}\n\n  ~sClassifierResults() \n  {\n    if (res != NULL) free(res);\n    if (prob != NULL) free(prob);\n    //int i;\n    if (resnameA != NULL) {\n      //for (i=0; i<nResults; i++) if (resnameA[i] != NULL) free(resnameA[i]);\n      free(resnameA);\n    }\n    if (resnameB != NULL) {\n      //for (i=0; i<nResults; i++) if (resnameB[i] != NULL) free(resnameB[i]);\n      free(resnameB);\n    }\n\n  }\n\n  void alloc() {\n    if (nResults > 0) {\n      res = (double *)calloc(1,sizeof(double)*nResults);\n      prob = (double *)calloc(1,sizeof(double)*nResults*nTargets);\n      resnameA = (const char **)calloc(1,sizeof(const char *)*nResults);\n      resnameB = (const char **)calloc(1,sizeof(const char *)*nResults);\n    }\n  }\n\n  int nFilled;\n  int nResults; // N\n  int nTargets; // C = number of classes or regression outputs\n  double *res;  // dim: 1xN\n  double *prob; // dim: CxN\n  const char ** resnameA; // custom name1 of result\n  const char ** resnameB; // custom name2 of result (can be NULL)\n} ;\n\n/**************************************************************************/\n/*********              LibSVM   addon:   scale functions  ****************/\n/**************************************************************************/\n\nstruct svm_scale {\n  int max_index;\n  int y_scaling;\n  double lower,upper;\n  double y_lower,y_upper;\n  double y_min,y_max;\n  double *feature_max;\n  double *feature_min;\n};\nstruct svm_scale * svm_load_scale(const char* restore_filename);\nvoid svm_destroy_scale(struct svm_scale *scale);\nvoid svm_apply_scale(struct svm_scale *scale, struct svm_node * x);\n\n/**************************************************************************/\n\ntypedef struct{\n  long n;\n  char **names;\n} sOutputSelectionStr;  // list of names of selected features (more flexible..)\ntypedef sOutputSelectionStr *pOutputSelectionStr;\n\ntypedef struct{\n  long nFull;   // n here is the full length of the \"unselected\" feature vector\n  long nSel;\n  long *map;\n  long *enabled;  // flag : 0 or 1  when feature is disabled/enabled respectively\n} sOutputSelectionIdx;  \ntypedef sOutputSelectionIdx *pOutputSelectionIdx;\n\ntypedef struct{\n  const char *fselection;\n  int fselType; long Nsel;\n  sOutputSelectionStr outputSelStr;\n  sOutputSelectionIdx outputSelIdx;\n} sFselectionData;\n\n#undef class\n\n\nclass DLLEXPORT lsvmDataFrame \n{ public:\n\n  int isLast; // indicates the last frame for batchMode (a result message will be sent)\n  long dataSize; // size of input data struct allocated memory in bytes\n  svm_node *x; // the input data\n  int modelchoice;\n  long long tick;\n  long frameIdx;\n  double time;\n  double res;\n  double svr_confidence;\n  double *probEstim; // a copy of the probEstim memory... must be freed\n  int nClasses;\n  double dur;\n  int isFinal;\n  int ID;  // custom ID field, 32-bit, usually read from tmeta->metadata.iData[1]\n\n  lsvmDataFrame() : probEstim(NULL), dur(0.0), isFinal(1), isLast(0), svr_confidence(0.0) {}\n\n  lsvmDataFrame(svm_node *_x, long _dataSize, int _modelchoice, long long _tick, long _frameIdx, double _time, double _res, int doProbEstim, int _nClasses, double _dur=0.0, int _isFinal=1, int _ID = 0) :\n    dataSize(_dataSize), tick(_tick), modelchoice(_modelchoice), frameIdx(_frameIdx), time(_time), res(_res), nClasses(_nClasses), dur(_dur), isFinal(_isFinal), isLast(0), ID(_ID), svr_confidence(0.0)\n  {\n    // copy input data\n    if (_x!=NULL) {\n      x = (svm_node*)malloc(dataSize);\n      memcpy(x,_x,dataSize);\n    } else {\n      x = NULL;\n    }\n    // copy probEstim, if not NULL\n    if (doProbEstim) {\n      probEstim = (double *) malloc(nClasses*sizeof(double));\n    } else {\n      probEstim = NULL;\n    }\n    //  memcpy(probEstim,_probEstim,nClasses*sizeof(double));\n  }\n\n  void setLast() { isLast = 1; }\n\n  ~lsvmDataFrame() { \n    if (x != NULL) free(x);\n    if (probEstim != NULL) free(probEstim); \n  }\n};\n\n\n// STL includes for the queue\n#include <queue>\n\n// a queue of data frames\ntypedef std::queue<lsvmDataFrame *> lsvmDataFrameQueue;\n\n// a model wrapper containing, the model itself, the scaling, the feature selection and the class labels, etc.\nclass svmModelWrapper {\npublic:\n  svmModelWrapper(int pred=0) : \n      model(NULL), labels(NULL), \n#ifdef BUILD_LIBLINEAR\n      modelLinear(NULL),\n#endif\n      alienScale(0), scale(NULL),\n      alienClassnames(0), classNames(NULL),\n      alienFselection(0), fselection(NULL),\n      templ(NULL), predictProbability(pred),\n      modelFile(NULL), scaleFile(NULL), fselectionFile(NULL), classesFile(NULL),\n      modelResultName(NULL), nIgnoreEndSelection(0), isLibLinearModel(0)\n  {}\n\n  ~svmModelWrapper() {\n    int i;\n    if (model != NULL) {\n      svm_destroy_model(model);\n    }\n#ifdef BUILD_LIBLINEAR\n    if (modelLinear != NULL) {\n      liblinear_free_and_destroy_model(&modelLinear);\n    }\n#endif\n    if (labels != NULL) free(labels);\n    //if (probEstimates != NULL) free(probEstimates);\n\n    if ((!alienScale)&&(scale != NULL)) svm_destroy_scale(scale);\n    if ((!alienClassnames)&&(classNames != NULL)) {\n      for (i=0; i<nClassNames; i++) { if (classNames[i] != NULL) free(classNames[i]); }\n      free(classNames);\n    }\n    if ((!alienFselection)&&(fselection != NULL)) {\n      if (fselection->outputSelIdx.enabled != NULL) { \n        free(fselection->outputSelIdx.enabled);\n      }\n      if (fselection->outputSelIdx.map != NULL) { \n        free(fselection->outputSelIdx.map);\n      }\n      int n;\n      if (fselection->outputSelStr.names != NULL) {\n        for(n=0; n<fselection->outputSelStr.n; n++) {\n          if (fselection->outputSelStr.names[n] != NULL) free(fselection->outputSelStr.names[n]);\n        }                             \n        free( fselection->outputSelStr.names );\n      }\n      free(fselection);\n    }\n  }\n\n  void setTemplate(svmModelWrapper *t) {\n    templ = t;\n  }\n\n  int loadClasses( const char *file, char *** names );\n  int loadSelection( const char *selFile, sFselectionData **fselections );\n  int load(); // load everything (model, scale, ...)\n\n  int isLibLinearModel;\n  const char *modelResultName;\n  const char *modelFile;\n  const char *scaleFile;\n  const char *fselectionFile;\n  const char *classesFile;\n  svmModelWrapper *templ;  \n\n  struct svm_model * model;\n#ifdef BUILD_LIBLINEAR\n  struct liblinear_model * modelLinear;\n#endif\n  int nClasses, svmType, predictProbability;\n  //double * probEstimates;\n  int *labels;\n  \n  int alienScale; // a \"1\" indicates that we don't have our own scale object and use the 0'th object for all models\n  struct svm_scale * scale; \n  int alienClassnames; // a \"1\" indicates that we don't have our own class name list and use the 0'th object for all models\n  char ** classNames;\n  int nClassNames;\n  int nIgnoreEndSelection; // number of elements to ignore from end of selection list\n  int noVerify;\n\n  int alienFselection; // a \"1\" indicates that we don't have our own class name list and use the 0'th object for all models\n  sFselectionData *fselection;\n};\n\n\nclass DLLEXPORT cLibsvmLiveSink : public cDataSink {\nprivate:\n  int sendResult;\n  int predictProbability;\n  int classifierThreadBusy;\n  int bgThreadPriority;\n\n  int saveResult;\n  const char * resultFile;\n\n  int forceScale;\n  const char * resultRecp;\n  const char * resultMessageName;\n  //const char **fselection;//, *classes;\n  //const char *scalefile, *modelfile;;\n  char **modelarray;\n  char **classesarray;\n  char **scalearray;\n\n  sClassifierResults resCache; // for batchMode\n\n  svmModelWrapper *models;\n  int nModels;\n  int nScales, nFselections, nClassFiles;\n  int currentModel;\n  int multiModelMode;\n  int batchMode;\n  int singlePreprocessMultiModel;\n\n  //long nCls;\n  //char ** classNames;\n  //int classnames_run;\n\n  lsvmDataFrameQueue *dataFrameQue;\n  int threadRunning;\n  int loadModelBg;\n  int modelLoaded;\n  int useThread;\n  int threadQueSize;\n\n  int abortLater;\n  int noVerify;\n  int nIgnoreEndSelection;\n\n  //int buildEnabledSelFromNames(long N, const FrameMetaInfo *fmeta, int index);\n  int buildEnabledSelFromNames(long N, const FrameMetaInfo *fmeta, sFselectionData *fselection);\n  //int loadSelection( const char *selFile, sFselectionData **fsel );\n  //int loadClasses( const char *file, char *** names );\n  int loadClassifier();\n\n  void processDigestFrame(lsvmDataFrame * f, int modelIdx);\n  void digestFrame(lsvmDataFrame * f, int modelIdx);\n\n  struct svm_node * preprocessFrame(int modelIdx, cVector *vec);\n\nprotected:\n  SMILECOMPONENT_STATIC_DECL_PR\n  int printResult;\n  int printParseableResult;\n  smileCond dataCond;\n  smileMutex dataMtx, runningMtx;\n  smileThread bgThread;\n\n  virtual void fetchConfig();\n  //virtual int myConfigureInstance();\n  virtual int myFinaliseInstance();\n  virtual int myTick(long long t);\n  //\n  virtual int processComponentMessage( cComponentMessage *_msg );\n\n  int queFrameToClassify(lsvmDataFrame *fr);\n\n  //virtual void processResult(long long tick, long frameIdx, double time, float res, double *probEstim, int nClasses, double dur=0.0, int isFinal=1);\n  virtual void processResult(lsvmDataFrame *f, int modelIdx, int mmm /* multiModelMode */);\n\npublic:\n  //static sComponentInfo * registerComponent(cConfigManager *_confman);\n  //static cSmileComponent * create(const char *_instname);\n  SMILECOMPONENT_STATIC_DECL\n\n\n  cLibsvmLiveSink(const char *_name);\n  void classifierThread();\n\n  virtual ~cLibsvmLiveSink();\n};\n\n\n#endif // BUILD_LIBSVM\n\n#endif // __CLIBSVMLIVESINK_HPP\n"
  },
  {
    "path": "src/include/classifiers/svmSink.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample dataSink:\nreads data from data memory and outputs it to console/logfile (via smileLogger)\nthis component is also useful for debugging\n\n*/\n\n\n#ifndef __CSVMSINK_HPP\n#define __CSVMSINK_HPP\n\n#include <core/smileCommon.hpp>\n\n#ifdef BUILD_SVMSMO\n\n#include <core/dataSink.hpp>\n#define BUILD_COMPONENT_SvmSink\n#define COMPONENT_DESCRIPTION_CSVMSINK \"This is an example of a cDataSink descendant. It reads data from the data memory and prints it to the console. This component is intended as a template for developers.\"\n#define COMPONENT_NAME_CSVMSINK \"cSvmSink\"\n\n#undef class\n\n#define SMILESVM_KERNEL_UNKNOWN 0  // unknown or unsupported kernel type\n\n// supported kernel types:\n#define SMILESVM_KERNEL_LINEAR        1\n#define SMILESVM_KERNEL_POLYNOMIAL    2\n#define SMILESVM_KERNEL_RBF           3\n#define SVMSINK_WINNING_CLASS_PROB\t  0\n#define SVMSINK_WINNING_CLASS_VOTE\t  1\n\n\nstruct smileBinarySvmModel\n{\n  int nSV;\n  int has_logit;\n  char * c1; int ic1;\n  char * c2; int ic2;\n  FLOAT_DMEM * SV;\n  FLOAT_DMEM bias;\n  double logit_coeff1;\n  double logit_intercept;\n};\n\n\nclass smileSvmModel\n{\n\nprivate:\n  int showStatsDebug;\n  int lineNr;\n  int kernelType;\n  int nClasses;\n  int nPairs;\n  char ** classnames;\n  int vectorDim;\n  char ** attributeNames;\n  struct smileBinarySvmModel * binSvm;\n  int * ftSelMap;\n  int nFtSel;\n  int ignoreLogitModel;\n\n  const char * model;\n\n  cSmileComponent * parent;\n  const char * getInstName() { return parent->getInstName(); }\n\n  int prepareModelStruct();\n  int parseKernelType(char *line);\n  int parseNClasses(char * line);\n  char ** parseClassnames(char * line, int nClasses);\n  int parseInt(char * line);\n  FLOAT_DMEM parseDouble(char * line);\n  FLOAT_DMEM parseBias(char * line);\n  int parseLogisticModel(struct smileBinarySvmModel *_s, char *inp);\n  int parseClassPair(struct smileBinarySvmModel *_s, char *inp);\n  int parseSVs(FLOAT_DMEM **_SV, int *_nSV, char * line, int idx);\n  int parseEnd(char * line);\n\n  // get the distance from the hyperplane of model <index> for the vector in <v>\n  double evalBinSvm(FLOAT_DMEM *v, int index);\n  double evalLogit(int index, double d);\n  FLOAT_DMEM * getPairwiseProbabilities(double **ps);\n\npublic:\n  smileSvmModel(cSmileComponent *_parent, const char * _model) : parent(_parent), model(_model),\n    classnames(NULL), attributeNames(NULL), binSvm(NULL), ftSelMap(NULL), nFtSel(0), showStatsDebug(0),\n    ignoreLogitModel(0)\n    {}\n\n  void setIgnoreLogitModel() {\n    ignoreLogitModel = 1;\n  }\n\n  // load the model from file\n  int load();\n\n  int getNclasses() { return nClasses; }\n\n  // compute the output for a given vector v (length N, must match vectorDim variable (vector size in model))\n  int evaluate(FLOAT_DMEM *v , long N, const char ** winningClass = NULL, FLOAT_DMEM ** probs=NULL, FLOAT_DMEM *conf=NULL, int winningClassMethod=SVMSINK_WINNING_CLASS_VOTE, int usePairwiseCoupling=1);\n\n  const char * className(int i) {\n    if (i<nClasses && i >= 0) \n      return classnames[i];\n    else\n      return NULL;\n  }\n\n  int getClassIndex(const char * c);\n  void setStatsDebug() { showStatsDebug = 1; }\n\n  int buildFtSelMap(int n, const char * name);\n  int checkFtSelMap();\n\n  ~smileSvmModel();\n};\n\n\nclass DLLEXPORT cSvmSink : public cDataSink {\n  private:\n    const char * model;\n    const char * resultRecp;\n    const char * resultMessageName;\n    const char * resultFile;\n    const char * winningClassMethodName;\n    int sendResult, printResult, saveResult;\n    int printParseableResult;\n    int ignoreLogitModel;\n    int winningClassMethod, usePairwiseCoupling;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    smileSvmModel * modelObj;\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cSvmSink(const char *_name);\n\n    virtual ~cSvmSink();\n};\n\n\n#endif // BUILD_SVMSMO\n\n#endif // __CSVMSINK_HPP\n"
  },
  {
    "path": "src/include/core/commandlineParser.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n#ifndef COMMANDLINE_PARSER_HPP\n#define COMMANDLINE_PARSER_HPP\n\n#include <core/smileCommon.hpp>\n\n#ifdef __WINDOWS\n#ifndef __MINGW32\n// windows stdlib.h does not seem to define those, even though msdn library says it would ???\n#define EINVAL 22\n#define ERANGE 34\n#else\n#include <errno.h>\n#endif\n#else\n#include <errno.h>\n#endif\n\n#define N_ALLOC_BLOCK 50\n#define STRLEN_NAME 255\n\n#define CMDOPT_BOOLEAN  0\n#define CMDOPT_INT      1\n#define CMDOPT_DOUBLE   2\n#define CMDOPT_STR      3\n\nstruct sCmdlineOpt {\n  char name[STRLEN_NAME];\n  char abbr;\n  char *description;\n  int type;\n  int dfltInt;\n  double dfltDouble;\n  char *dfltStr;\n  int argMandatory;\n  int isMandatory;\n  int isSet;\n  int nArgSet;\n};\n\n#undef class\nclass DLLEXPORT cCommandlineParser {\n\n  private:\n    int argc;\n    const char **argv;\n    int N,Nalloc;\n    int active;\n    struct sCmdlineOpt * opt;\n\n    int getWrIdx();\n    int addOpt( const char *name, char abbr, const char *description, int argMandatory, int isMandatory);\n\n    /* find index of option \"name\", return index upon success, else return -1 */\n    int findOpt( const char *name ) const;\n\n  public:\n\n    cCommandlineParser(int _argc, const char ** _argv);\n\n    int addBoolean(const char *name, char abbr, const char *description , int dflt=0, int argMandatory=0, int isMandatory=0 );\n    int addInt(const char *name, char abbr, const char *description , int dflt=0, int argMandatory=1, int isMandatory=0 );\n    int addDouble(const char *name, char abbr, const char *description, double dflt=0.0, int argMandatory=1, int isMandatory=0 );\n    int addStr(const char *name, char abbr, const char *description, const char *dflt=NULL, int argMandatory=1, int isMandatory=0 );\n\n    void showUsage(const char *binname=NULL);\n    int doParse(int ignDupl=0, int ignUnknown=1);  // return value: 0 on normal parse, -1 if usage was requested with '-h' (in this case the application should terminate after doParse() has finished\n\n    int getBoolean(const char *name ) const;\n    int getInt(const char *name ) const;\n    int isSet(const char *name ) const;\n    bool optionExists(const char *name) const {\n      return (findOpt(name) != -1);\n    }\n\n    double getDouble(const char *name) const;\n    const char * getStr(const char *name) const;\n\n    ~cCommandlineParser();\n};\n\n#endif // COMMANDLINE_PARSER_HPP\n"
  },
  {
    "path": "src/include/core/componentList.hpp",
    "content": "/*F***************************************************************************\n * openSMILE - the open-Source Multimedia Interpretation by Large-scale\n * feature Extraction toolkit\n * \n * (c) 2008-2011, Florian Eyben, Martin Woellmer, Bjoern Schuller: TUM-MMK\n * \n * (c) 2012-2013, Florian Eyben, Felix Weninger, Bjoern Schuller: TUM-MMK\n * \n * (c) 2013-2014 audEERING UG, haftungsbeschränkt. All rights reserved.\n * \n * Any form of commercial use and redistribution is prohibited, unless another\n * agreement between you and audEERING exists. See the file LICENSE.txt in the\n * top level source directory for details on your usage rights, copying, and\n * licensing conditions.\n * \n * See the file CREDITS in the top level directory for information on authors\n * and contributors. \n ***************************************************************************E*/\n\n\n// basic functionality / SMILE API\n#include <core/dataMemory.hpp>\n#include <core/dataReader.hpp>\n#include <core/dataWriter.hpp>\n#include <core/dataSource.hpp>\n#include <core/dataSink.hpp>\n#include <core/dataProcessor.hpp>\n#include <core/dataSelector.hpp>\n#include <core/vectorProcessor.hpp>\n#include <core/vectorTransform.hpp>\n#include <core/windowProcessor.hpp>\n#include <core/winToVecProcessor.hpp>\n#include <core/vecToWinProcessor.hpp>\n\n// examples:\n#include <examples/simpleMessageSender.hpp>\n#include <examples/exampleSource.hpp>\n#include <examples/exampleSink.hpp>\n\n// basic operations:\n#include <other/vectorConcat.hpp>\n#include <dspcore/windower.hpp>\n#include <dspcore/framer.hpp>\n#include <other/vectorOperation.hpp>\n#include <other/valbasedSelector.hpp>\n#include <other/maxIndex.hpp>\n#include <dspcore/fullinputMean.hpp>\n#include <dspcore/fullturnMean.hpp>\n\n// sources:\n#include <iocore/waveSource.hpp>\n#include <iocore/arffSource.hpp>\n#include <iocore/csvSource.hpp>\n#include <iocore/htkSource.hpp>\n\n// sinks:\n#include <core/nullSink.hpp>\n#include <iocore/csvSink.hpp>\n#include <iocore/datadumpSink.hpp>\n#include <iocore/arffSink.hpp>\n#include <iocore/htkSink.hpp>\n#include <iocore/waveSink.hpp>\n#include <iocore/waveSinkCut.hpp>\n\n//\"fake\" sources / producers:\n#include <other/bowProducer.hpp>\n#include <dsp/signalGenerator.hpp>\n\n// portaudio code:\n#ifdef HAVE_PORTAUDIO\n #include <portaudio/portaudioWavplayer.hpp>\n #include <portaudio/portaudioSource.hpp>\n #include <portaudio/portaudioSink.hpp>\n #include <portaudio/portaudioDuplex.hpp>\n#endif\n\n#ifdef __ANDROID__\n #include <android/openslesSource.hpp>\n #include <android/jniMessageInterface.hpp>\n#endif\n\n// live sinks (classifiers):\n#ifdef BUILD_LIBSVM\n #include <classifiers/libsvmliveSink.hpp>\n#endif\n#ifdef BUILD_SVMSMO\n #include <classifiers/svmSink.hpp>\n#endif\n#ifdef BUILD_RNN\n #include <rnn/rnnSink.hpp>\n #include <rnn/rnnProcessor.hpp>\n #include <rnn/rnnVad2.hpp>\n#endif\n\n#ifdef HAVE_JULIUSLIB\n#include <classifiers/julius/juliusSink.hpp>\n#endif\n\n// dsp core:\n#include <dspcore/monoMixdown.hpp>\n#include <dspcore/transformFft.hpp>\n#include <dspcore/fftmagphase.hpp>\n#include <dspcore/amdf.hpp>\n#include <dspcore/acf.hpp>\n#include <dspcore/preemphasis.hpp>\n#include <dspcore/vectorPreemphasis.hpp>\n#include <dspcore/vectorMVN.hpp>\n#include <dspcore/turnDetector.hpp>\n#include <dspcore/deltaRegression.hpp>\n#include <dspcore/contourSmoother.hpp>\n\n// dsp advanced:\n#include <dsp/smileResample.hpp>\n#include <dsp/specResample.hpp>\n#include <dsp/dbA.hpp>\n#include <dsp/vadV1.hpp>\n#include <dsp/specScale.hpp>\n\n// LLD core:\n#include <lldcore/mzcr.hpp>\n#include <lldcore/energy.hpp>\n#include <lldcore/intensity.hpp>\n#include <lldcore/melspec.hpp>\n#include <lldcore/mfcc.hpp>\n#include <lldcore/plp.hpp>\n#include <lldcore/spectral.hpp>\n#include <lldcore/pitchBase.hpp>\n#include <lldcore/pitchACF.hpp>\n#include <lldcore/pitchSmoother.hpp>\n\n// LLD (low-level descriptors):\n#include <lld/tonespec.hpp>\n#include <lld/tonefilt.hpp>\n#include <lld/chroma.hpp>\n#include <lld/cens.hpp>\n#include <lld/harmonics.hpp>\n#include <lld/pitchSmootherViterbi.hpp>\n#include <lld/pitchJitter.hpp>\n#include <lld/pitchDirection.hpp>\n#include <lld/pitchShs.hpp>\n#include <lld/lpc.hpp>\n#include <lld/lsp.hpp>\n#include <lld/formantLpc.hpp>\n#include <lld/formantSmoother.hpp>\n\n// functionals:\n#include <functionals/functionals.hpp>\n#include <functionals/functionalExtremes.hpp>\n#include <functionals/functionalMeans.hpp>\n#include <functionals/functionalPeaks.hpp>\n#include <functionals/functionalPeaks2.hpp>\n#include <functionals/functionalSegments.hpp>\n#include <functionals/functionalOnset.hpp>\n#include <functionals/functionalMoments.hpp>\n#include <functionals/functionalCrossings.hpp>\n#include <functionals/functionalPercentiles.hpp>\n#include <functionals/functionalRegression.hpp>\n#include <functionals/functionalSamples.hpp>\n#include <functionals/functionalTimes.hpp>\n#include <functionals/functionalDCT.hpp>\n#include <functionals/functionalLpc.hpp>\n\n// advanced io\n#include <io/libsvmSink.hpp>\n\n// OpenCV:\n#ifdef HAVE_OPENCV\n  #include <video/openCVSource.hpp>\n#endif\n\n\nDLLEXPORT const registerFunction componentlist[] = {\n  // basic functionality / SMILE API\n  cDataMemory::registerComponent,\n  cDataWriter::registerComponent,\n  cDataReader::registerComponent,\n  cDataSource::registerComponent,\n  cDataSink::registerComponent,\n  cDataProcessor::registerComponent,\n  cDataSelector::registerComponent,\n  cVectorProcessor::registerComponent,\n  cVectorTransform::registerComponent,\n  cWindowProcessor::registerComponent,\n  cWinToVecProcessor::registerComponent,\n  cVecToWinProcessor::registerComponent,\n\n  // examples\n#ifdef BUILD_COMPONENT_ExampleSource\n  cExampleSource::registerComponent,\n#endif\n#ifdef BUILD_COMPONENT_ExampleSink\n  cExampleSink::registerComponent,\n#endif\n#ifdef BUILD_COMPONENT_SimpleMessageSender\n  cSimpleMessageSender::registerComponent,\n#endif\n\n  // basic operations:\n  cVectorConcat::registerComponent,\n  cFramer::registerComponent,\n  cWindower::registerComponent,\n  cVectorOperation::registerComponent,\n  cValbasedSelector::registerComponent,\n  cMaxIndex::registerComponent,\n  cFullinputMean::registerComponent,\n  cFullturnMean::registerComponent,\n\n  // sources:\n  cWaveSource::registerComponent,\n  cArffSource::registerComponent,\n  cCsvSource::registerComponent,\n  cHtkSource::registerComponent,\n\n  // sinks:\n  cNullSink::registerComponent,\n  cCsvSink::registerComponent,\n  cDatadumpSink::registerComponent,\n  cArffSink::registerComponent,\n  cHtkSink::registerComponent,\n  cWaveSink::registerComponent,\n  cWaveSinkCut::registerComponent,\n\n  //\"fake\" sources / producers:\n  cBowProducer::registerComponent,\n  cSignalGenerator::registerComponent,\n\n  #ifdef HAVE_PORTAUDIO\n   cPortaudioWavplayer::registerComponent,\n   cPortaudioSource::registerComponent,\n   cPortaudioSink::registerComponent,\n   cPortaudioDuplex::registerComponent,\n  #endif\n\n  #ifdef __ANDROID__\n   #ifdef BUILD_COMPONENT_OpenslesSource\n   cOpenslesSource::registerComponent,\n   #endif\n   cJniMessageInterface::registerComponent,\n  #endif\n\n  // live sinks (classifiers):\n  #ifdef BUILD_LIBSVM\n   cLibsvmLiveSink::registerComponent,\n  #endif\n  #ifdef BUILD_SVMSMO\n   cSvmSink::registerComponent,\n  #endif\n  #ifdef BUILD_RNN\n   cRnnSink::registerComponent,\n   cRnnProcessor::registerComponent,\n   cRnnVad2::registerComponent,\n  #endif\n\n  #ifdef HAVE_JULIUSLIB\n   cJuliusSink::registerComponent,\n  #endif\n\n  // dsp core:\n  cMonoMixdown::registerComponent,\n  cTransformFFT::registerComponent,\n  cFFTmagphase::registerComponent,\n  cAmdf::registerComponent,\n  cAcf::registerComponent,\n  cPreemphasis::registerComponent,\n  cVectorPreemphasis::registerComponent,\n  cVectorMVN::registerComponent,\n  cTurnDetector::registerComponent,\n  cDeltaRegression::registerComponent,\n  cContourSmoother::registerComponent,\n\n  // dsp advanced:\n  cSmileResample::registerComponent,\n  cSpecResample::registerComponent,\n  cDbA::registerComponent,\n  cVadV1::registerComponent,\n  cSpecScale::registerComponent,\n\n  // LLD core:\n  cMZcr::registerComponent,\n  cEnergy::registerComponent,\n  cIntensity::registerComponent,\n  cMelspec::registerComponent,\n  cMfcc::registerComponent,\n  cPlp::registerComponent,\n  cSpectral::registerComponent,\n  cPitchBase::registerComponent,\n  cPitchACF::registerComponent,\n  cPitchSmoother::registerComponent,\n\n  // LLD advanced:\n  cTonespec::registerComponent,\n  cTonefilt::registerComponent,\n  cChroma::registerComponent,\n  cCens::registerComponent,\n  cHarmonics::registerComponent,\n  cPitchSmootherViterbi::registerComponent,\n  cPitchJitter::registerComponent,\n  cPitchDirection::registerComponent,\n  cPitchShs::registerComponent,\n  cLpc::registerComponent,\n  cLsp::registerComponent,\n  cFormantLpc::registerComponent,\n  cFormantSmoother::registerComponent,\n\n  // functionals:\n  cFunctionals::registerComponent,\n  cFunctionalExtremes::registerComponent,\n  cFunctionalMeans::registerComponent,\n  cFunctionalPeaks::registerComponent,\n  cFunctionalPeaks2::registerComponent,\n  cFunctionalSegments::registerComponent,\n  cFunctionalOnset::registerComponent,\n  cFunctionalMoments::registerComponent,\n  cFunctionalCrossings::registerComponent,\n  cFunctionalPercentiles::registerComponent,\n  cFunctionalRegression::registerComponent,\n  cFunctionalSamples::registerComponent,\n  cFunctionalTimes::registerComponent,\n  cFunctionalDCT::registerComponent,\n  cFunctionalLpc::registerComponent,\n\n  // io advanced:\n  cLibsvmSink::registerComponent,\n  \n  #ifdef HAVE_OPENCV\n    cOpenCVSource::registerComponent,\n  #endif\n\n  NULL   // the last element must always be NULL !\n};\n"
  },
  {
    "path": "src/include/core/componentManager.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n#ifndef __COMPONENT_MANAGER_HPP\n#define __COMPONENT_MANAGER_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/smileComponent.hpp>\n\n// this is the name of the configuration instance in the config file the component manager will search for:\n#define CM_CONF_INST  \"componentInstances\"\n\n\n// global component list: -----------------\n#undef class\nclass DLLEXPORT cComponentManager;\ntypedef sComponentInfo * (*registerFunction)(cConfigManager *_confman, cComponentManager *_compman);\ntypedef void (*unRegisterFunction)();\n\nextern DLLEXPORT const registerFunction componentlist[];\n\n// default number of initial component variable space and plugin variable space to allocate:\n#define COMPONENTMANAGER_DEFAULT_NCOMPS  200\n\n// Max. iterations for register type, register instance, configure, and finalise process of components\n#define MAX_REG_ITER  4\n#define MAX_REGI_ITER 2\n#define MAX_CONF_ITER 4  // <- should be nComponents!!\n#define MAX_FIN_ITER  4\n\n\n// openSMILE component runner thread status:\n#define THREAD_ACTIVE   0\n#define THREAD_WAIT_A   1\n#define THREAD_WAIT_B   2\n#define THREAD_END      3\n#define THREAD_INACTIVE 4\n\ntypedef struct {\n  cComponentManager *obj;\n  long long maxtick;\n  int threadId;\n  int status;\n} sThreadData;\n\n\nclass DLLEXPORT cComponentManager {\nprotected:\n  int printPlugins;\n//#ifdef DEBUG\n  int execDebug;\n//#endif\n#ifdef __WINDOWS\n  HINSTANCE *handlelist;\n#else\n  void **handlelist;\n#endif\n\n  registerFunction * regFnlist;\n  int nPluginHandles, nPluginHandlesAlloc;\n\n  int loadPlugin(const char * path, const char * fname);\n  int registerPlugins();\n  int checkPluginFilename(const char * str);\n\n  // you may overwrite this method in a derived class to implement custom processing in every tick\n  // return 1 on success and 0 on failure (a return value of 0 will terminate the processing loop)\n  // threadID = -1 ==> single threaded mode   threadID >= 0  ==> multi-threaded mode with 1 or more threads\n  virtual int userOnTick(long long tickNr, int EOI=0, int threadID=-1) { return 1; }\n\n  int pausedNotifyComponents(int threadId, int isPause);\n\npublic:\n  static void registerType(cConfigManager *_confman);\n\n  cComponentManager(cConfigManager *_confman, const registerFunction _clist[] = componentlist);               // create component manager\n\n  int compIsDm(const char *_compn);\n  int ciRegisterComps(int _dm);\n  int ciConfigureComps(int _dm);\n  int ciFinaliseComps(int _dm, int *_n=NULL);\n  int ciConfFinComps(int _dm, int *_n=NULL);\n\n  void createInstances(int readConfig=1); // read config file and create instances as specified in config file\n\n  // end-of-input handling:\n  void setEOIcounterInComponents();\n  void setEOI() {\n    EOI++;\n    EOIcondition = 1;\n  }\n  void unsetEOI() {\n    EOIcondition = 0;\n  }\n\n  // check for EOIcondition\n  int isEOI() { return EOIcondition; }\n  // get the EOI counter\n  int getEOIcounter() { return EOI; }\n\n  long long tickLoopA(long long maxtick, int threadId, sThreadData *_data);\n  void controlLoopA(void);\n\n  long tick(int threadId, long long tickNr, long lastNrun=-1);  // call all components to process one time step ('tick')\n\n  // this function calls tick() until 0 components run successfully, returns total number of ticks\n  long long runSingleThreaded(long long maxtick=-1);\n\n  // still a bit todo, basically same as runSingleThreaded with multiple threads, total number of ticks not yet fully supported!!\n  long long runMultiThreaded(long long maxtick=-1);\n\n  int addComponent(const char *_instname, const char *_type, const char *_ci=NULL, int _threadId=-1);  // create + register\n  cSmileComponent * createComponent(const char *_name, const char *_type);\n  cSmileComponent * createComponent(const char *_name, int n);\n\n  // return number of registered component types\n  int getNtypes() { return nCompTs; } \n\n  // filter=0: no filter, filter=1 : no abstract components, filter=2 non abstract and no non-Dmem (non-standalone) components (= sub-components)\n  const char * getComponentType(int i, int filter=2, int *isAbstract=NULL, int *isNoDmem=NULL); // get name of component Type \"i\". abstract=1 = include abstract types (if abstract = 0 , then NULL will be returned if the type is abstract), or you may use the isAbstract flag, which is set by this function\n\n  // get description of component \"i\"\n  const char * getComponentDescr(int i); \n\n  int registerComponent(sComponentInfo *c, int noFree=0); // register a component type\n  int findComponentType(const char *_type);\n  int registerComponentTypes(const registerFunction _clist[]); // register component types by scanning given struct\n\n  // filter=0: no filter, filter=1 : no abstract components, filter=2 non abstract and no non-Dmem (non-standalone) components (= sub-components)\n  int printComponentList(int filter=2, int details=1);\n\n  int registerComponentInstance(cSmileComponent * _component, const char *_typename, int _threadId=-1);  // register a component, return value: component id\n  void unregisterComponentInstance(int id, int noDM=0);  // unregister and free component object\n  int findComponentInstance(const char *_compname) const;\n  cSmileComponent * getComponentInstance(int n);\n  const char * getComponentInstanceType(int n);\n  cSmileComponent * getComponentInstance(const char *_compname);\n  const char * getComponentInstanceType(const char *_compname);\n\n  // send inter component messages directly to component:\n  int sendComponentMessage(const char *_compname, cComponentMessage *_msg);\n  // send inter component messages directly to component:\n  int sendComponentMessage(int compid, cComponentMessage *_msg);\n\n  // get time in seconds (accurate up to the millisecond or microsecond (depending on the system)) since creation if componentManager\n  double getSmileTime();\n\n  void resetInstances(void);  // delete all component instances and reset componentManger to state before createInstances\n  void waitForAllThreads(int threadID);\n  void waitForController(int threadID, int stage);\n  void decreaseNActive();\n\n  /* pause tick loop:\nhow=0  :  resume tick loop\nhow=1  :  notify components, halt loop in a sleep\nhow=2  :  notify components,  wait for nRun = 0 (force NOT EOI!), then put loop to sleep\ntimeout :  if how=2, then max number of ticks of nRun>0 , after which pause request is discarded and EOI is assumed again when nRun=0  (irrelevant when how=1)\n*/\n  void pause(int how=1, int timeout=20);\n  void resume() { pause(0,0); }\n\n  // request program loop termination (works for single and multithreaded)\n  void requestAbort() {\n    resume();\n    smileMutexLock(abortMtx);\n    abortRequest = 1;\n    if (nThreads != 1) { smileCondSignal(controlCond); }\n    smileMutexUnlock(abortMtx);\n  }\n  int isAbort() { \n    smileMutexLock(abortMtx);\n    int ret = abortRequest;\n    smileMutexUnlock(abortMtx);\n    return ret;\n  }\n\n  int isReady() {\n    return ready;\n  }\n\n  ~cComponentManager();              // unregister and free all component objects\n\nprivate:\n  cConfigManager *confman;\n  void fetchConfig(); // read config from confman\n\n  int printLevelStats;\n  int profiling;\n\n  struct timeval startTime;\n  int nCompTs, nCompTsAlloc;\n  sComponentInfo *compTs; // component types\n\n  int ready;    // flag that indicates if all components are set up and ready...\n  int isConfigured;\n  int isFinalised;\n  int EOI;            // EOI iteration counter\n  int EOIcondition;   // EOI flag\n\n  //long long tickNr;\n  int nComponents, nComponentsAlloc;\n  int nActiveComponents;  // number of non-passive (i.e. non-dataMemory components)\n  int nThreads;\n  int threadPriority; /* default thread priority, or single thread priority */\n\n  int lastComponent;\n  cSmileComponent ** component;   // array of component instances\n  char **componentInstTs;    // component instance corresponding type names\n  int  * componentThreadId;\n\n  long messageCounter;\n  int oldSingleIterationTickLoop;\n\n  long long pauseStartNr;\n  int tickLoopPaused;\n  int tickLoopPauseTimeout;\n  smileCond pauseCond;\n  smileMutex pauseMtx;\n\n  smileMutex    messageMtx;\n  smileMutex    waitEndMtx;\n  smileCond     waitEndCond;\n  smileCond     waitControllerCond;\n  int waitEndCnt;\n\n  // mutli thread sync variables:\n  smileMutex    syncCondMtx;\n  smileMutex    abortMtx;\n  smileCond     syncCond;\n  smileCond     controlCond;\n  int nWaiting, nProbe, nActive;\n  int runStatus, compRunFlag, probeFlag, controllerPresent; // communication flags between controller thread and component runner threads\n  int *runFlag;\n  int globalRunState;\n  int abortRequest, endOfLoop;\n\n  int getNextComponentId();\n\n  \n  // pause the current tick loop (by either sleeping or polling, specified via tickLoopPaused variable) and notify all associated components about pause/resume correctly\n  // return value: nRun\n  int pauseThisTickLoop(int threadID, int nRun, long long tickNr);\n\n};\n\n\n#endif  // __COMPONENT_MANAGER_HPP\n"
  },
  {
    "path": "src/include/core/configManager.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n//***** TODO(?):  implement isMandatory option for configType fields! (and check for those fields)//\n\n#ifndef __CONFIG_MANAGER_HPP\n#define __CONFIG_MANAGER_HPP\n\n\n#define CONFIGTYPE_STRLEN 255\n#define NEL_ALLOC_BLOCK   10\n\n#include <core/smileCommon.hpp>\n#include <core/commandlineParser.hpp>\n#include <map>\n#include <string>\n\nint instNameSplit(const char *n, char **b, const char **s);\n\n\n#define CFTP_NUM   0\n#define CFTP_STR   1\n#define CFTP_CHR   2\n#define CFTP_OBJ   3\n#define CFTP_ARR   99\n#define CFTP_NUM_ARR   100\n#define CFTP_STR_ARR   101\n#define CFTP_CHR_ARR   102\n#define CFTP_OBJ_ARR   103\n\n#undef class\nclass DLLEXPORT ConfigInstance;\n\nclass DLLEXPORT ConfigValue {\n  protected:\n    int set;\n    int type;\n\n  public:\n    virtual void setValue(int n=0) {}\n    virtual void setValue(double v, int n=0) {}\n    virtual void setValue(const char *v, int n=0) {}\n    virtual void setValue(char v, int n=0) {}\n    virtual void setValue(ConfigInstance *v, int n=0) {}\n    virtual void setValue(ConfigValue *v, int n=0) {}\n\n    virtual int getInt(int n=0) const { return 0; }\n    virtual double getDouble(int n=0) const { return 0.0; }\n    virtual const char* getStr(int n=0) const { return NULL; }\n    virtual char getChar(int n=0) const { return 0; }\n    virtual ConfigInstance* getObj(int n=0) const { return NULL; }\n    virtual ConfigValue* getValue(int n=0) const { return NULL; }\n\n    virtual void copyFrom(const ConfigValue *val) {};\n    virtual int missingFrom(const ConfigValue *val) {\n      if (!isSet()) { copyFrom(val); return 1; }\n      else { return 0; }\n    }\n    virtual int updateWith(const ConfigValue *val) {\n      if ((val!=NULL)&&(val->isSet())) { copyFrom(val); return 1; }  \n      else { return 0; }\n    }\n\n    virtual int findField(const char *_name=NULL, int noerr=0) const { return -1; }\n    virtual int findFieldWr(const char *_name=NULL) { return -1; }\n\n    virtual int getType() const { return type; }\n    virtual int isSet(int n=-1) const { return set; }\n    virtual int getN() const { return -1; }\n    virtual int getSize() const { return -1; }\n    virtual char ** getAAkeys() const { return NULL; }  // get keys of associative array fields\n    int unset() { set = 0; return 1; }\n    \n    virtual ~ConfigValue() {}\n};\n\n\nclass DLLEXPORT ConfigValueNum : public ConfigValue {\n  private:\n    int valueI;\n    double valueD;\n  public:\n    ConfigValueNum() : valueI(0), valueD(0) { type = CFTP_NUM; set = 0; }\n    ConfigValueNum(int value) : valueI(value), valueD((double)value) { type = CFTP_NUM; set = 1; }\n    ConfigValueNum(double value) : valueI((int)value), valueD(value) { type = CFTP_NUM; set = 1; }\n\n    virtual int getInt(int n=0) const { return valueI; }\n    virtual double getDouble(int n=0) const { return valueD; }\n\n    void setValue(int value, int n=0) { valueI = value; valueD = (double)value; set=1; }\n    void setValue(double value, int n=0) { valueD = value; valueI = (int)value; set=1; }\n\n    void copyFrom(const ConfigValue *val);\n    \n    ~ConfigValueNum() {}\n};\n\nclass DLLEXPORT ConfigValueStr : public ConfigValue {\n  private:\n    char *str;  // string data\n    size_t N;      // string length\n  public:\n    ConfigValueStr() : str(NULL), N(0) { type = CFTP_STR; set = 0; }\n    ConfigValueStr(const char * value) : str(NULL), N(0) {\n      type = CFTP_STR;\n      setValue(value);\n    }\n    const char * getStr(int n=0) const { return str; }\n    char getChar(int n=0) const { if (str!=NULL) return str[0]; else return 0; }\n\n    void setValue(const char * value, int n=0) {\n      if (str != NULL) { free(str); str=NULL; }\n      if (value==NULL) { set = 0; return; }\n      str = strdup(value); N=strlen(value);\n      set=1;\n    }\n    void copyFrom(const ConfigValue *val);\n\n    ~ConfigValueStr() { if (str != NULL) free(str); }\n};\n\nclass DLLEXPORT ConfigValueChr : public ConfigValue {\n  private:\n    char c;\n\n  public:\n    char s[2];\n    \n    ConfigValueChr() : c(0) { type = CFTP_CHR; set = 0; }\n    ConfigValueChr(const char _c) : c(_c) { s[0]=_c; s[1]=0; type = CFTP_CHR; set = 1; }\n    char getChar(int n=0) const { return c; }\n    const char * getStr(int n=0) const { return s; }\n    void setValue(char _c, int n=0) { c=_c; set=1; } // XXX mod : removed const\n    void copyFrom(const ConfigValue *val);\n    ~ConfigValueChr() {}\n};\n\n\nclass DLLEXPORT ConfigValueObj : public ConfigValue {\n  private:\n    ConfigInstance *obj;\n    int freeObj;\n\n  public:\n    ConfigValueObj() : obj(NULL), freeObj(0) { type = CFTP_OBJ; set = 0; }\n    ConfigValueObj(ConfigInstance *_obj, int _freeObj=1) :\n      obj(_obj), freeObj(_freeObj) { type = CFTP_OBJ; set = 1; }\n\n    ConfigInstance * getObj(int n=0) const { return obj; }\n    void setValue(ConfigInstance * value, int n=0);\n    void setFreeObj(int _f=1) { freeObj = _f; }\n    void copyFrom(const ConfigValue *val);\n    int missingFrom(const ConfigValue *val);\n    int updateWith(const ConfigValue *val);\n\n    ~ConfigValueObj();\n};\n\n// TODO: associative array functionality by over loading operators (int n  AND const char *name)\nclass DLLEXPORT ConfigValueArr : public ConfigValue {\n  protected:\n    ConfigValue **el;\n    char **aName;  // names for associative array\n    int N, maxN;  // N is total number of elements allocated, maxN is the maximum index that was set\n\n    int checkIdx(int n) const;\n    int checkIdxWr(int n);\n    \n  public:\n    ConfigValueArr(int initN=NEL_ALLOC_BLOCK);\n    // : N(0), el(NULL)\n\n    virtual ~ConfigValueArr();\n\n    virtual ConfigValue * operator[](int n) const;\n    virtual ConfigValue * operator[](const char *_name) const;\n\n    int findField(const char *_name, int noerr=0) const;\n    int findFieldWr(const char *_name);\n\n    virtual void setValue(ConfigValue *v, int n);\n    void copyFrom(const ConfigValue *val);\n//    void copyFrom(const ConfigValue *val, int arrIdx);  // copy single element ??\n    int missingFrom(const ConfigValue *val);\n    int updateWith(const ConfigValue *val);\n    int getN() const { return N; }\n    int getSize() const { return maxN+1; }\n    char ** getAAkeys() const { return aName; }  // get keys of associative array fields\n\n    virtual int isSet(int n=-1) const {\n      if (n<0) return set;\n      else { if ((n<=maxN)&&(el[n]!=NULL)&&(el[n]->isSet())) return 1; else return 0; }\n    }\n};\n\nclass DLLEXPORT ConfigValueNumArr : public ConfigValueArr {\n  public:\n    ConfigValueNumArr(int initN=NEL_ALLOC_BLOCK) : ConfigValueArr(initN) { type=CFTP_NUM_ARR; }\n\n    virtual int getInt(int n=0) const {\n      if (checkIdx(n)&&(el[n] != NULL)) return ((ConfigValueNum *)(el[n]))->getInt();  // get value via () operator\n      else return 0;\n    }\n\n    virtual double getDouble(int n=0) const {\n      if (checkIdx(n)&&(el[n] != NULL)) return ((ConfigValueNum *)(el[n]))->getDouble();  // get value via () operator\n      else return 0.0;\n    }\n\n    virtual void setValue(double v, int n=0);\n    virtual void setValue(int v, int n=0);\n};\n\nclass DLLEXPORT ConfigValueStrArr : public ConfigValueArr {\n  public:\n    ConfigValueStrArr(int initN=NEL_ALLOC_BLOCK) : ConfigValueArr(initN) { type=CFTP_STR_ARR; }\n\n    virtual const char* getStr(int n=0) const {\n      if (checkIdx(n)&&(el[n] != NULL))\n        return ((ConfigValueStr *)(el[n]))->getStr();  // get value via () operator\n      else return NULL;\n    }\n    virtual void setValue(const char *v, int n=0);\n};\n\nclass DLLEXPORT ConfigValueChrArr : public ConfigValueArr {\n  public:\n    ConfigValueChrArr(int initN=NEL_ALLOC_BLOCK) : ConfigValueArr(initN) { type=CFTP_CHR_ARR; }\n\n    virtual char getChar(int n=0) const {\n      if (checkIdx(n)&&(el[n] != NULL))\n        return ((ConfigValueChr *)(el[n]))->getChar();  // get value via () operator\n      else return 0;\n    }\n    virtual void setValue(char v, int n=0);\n};\n\nclass DLLEXPORT ConfigValueObjArr : public ConfigValueArr {\n  public:\n    ConfigValueObjArr(int initN=NEL_ALLOC_BLOCK) : ConfigValueArr(initN) { type=CFTP_OBJ_ARR; }\n\n    virtual ConfigInstance* getObj(int n=0) const {\n      if (checkIdx(n)&&(el[n] != NULL))\n        return ((ConfigValueObj *)(el[n]))->getObj();  // get value via () operator\n      else return NULL;\n    }\n    virtual void setValue(ConfigInstance *v, int n=0);\n};\n\n\n/*********** Config Type **********/\nclass DLLEXPORT ConfigType;\n#define NO_ARRAY        0\n#define ARRAY_TYPE      1\n#define DONT_FREE       0\n\ntypedef struct sConfigDescription {\n  int type;                          /* CFTP_XXX constants */\n  int subtype;                       /* reserved */\n  int freeType;\n  const ConfigType * subType;              /* if type==CFTP_OBJ or CFTP_OBJARR -> subType */\n  int fieldLen;                      /* field length (e.g. for strings), -1 for dynamic (pointer), 0 for use sizeof(type) */\n  int N;                             /* number of elements for array types: 0 = no array, 1 = variable length array */\n  int enabled;                       /* if set to 0, the field will not be shown by printTypeHelp, it will be, however, still available! */\n  int printDflt;                     /* if set to 1, this field will be printed with the -configDflt option */\n  char name[CONFIGTYPE_STRLEN+1];    /* name of field (UNIQUE per type) */\n  char *description;                 /* description of field in human readable form */\n  // default values... will be read by configInstance upon creation\n  // for arrays: all field will be initialised with the same value, CFTP_OBJ has no default value\n  char dfltChar;\n  double dfltDouble;\n  char *dfltStr;\n  int isMandatory;       // 0=optional parameter, 1=mandatory parameter (exception will be generated, if parameter is not found in config file!)\n} ConfigDescription;\n\nclass DLLEXPORT ConfigType {\n  private:\n    char                       name[CONFIGTYPE_STRLEN+1];  /* name of type */\n    char                       parentName[CONFIGTYPE_STRLEN+1];  /* name of parent type, has length 0 if there is no parent type */\n\n    int                        N,I;  // I points to current Field that is to be set by setField()\n    ConfigDescription  *       element;\n\n  public:\n    const ConfigDescription * operator[] (int n);\n\n    ConfigType( const char *_name, int N_=10);\n    ConfigType( ConfigType const& copy, const char *_newname=NULL);\n    \n    // disable field by setting \"enabled = 0\", the field is still available normally, however, it will not be shown by printTypeHelp anymore!\n    int disableField(const char *_name);\n    int setField(const char *_name, const char *description, int type, int subtype, const ConfigType *subType, int freeType=1, int N_=0, int printDflt=1);\n\n    int setField(const char *_name, const char *description, int dflt, int arr=0, int printDflt=1);\n    int setField(const char *_name, const char *description, double dflt, int arr=0, int printDflt=1);\n    int setField(const char *_name, const char *description, const char * dflt, int arr=0, int printDflt=1);\n    int setField(const char *_name, const char *description, char dflt, int arr=0, int printDflt=1);\n    int setField(const char *_name, const char *description, const ConfigType *dflt, int arr=0, int freeType=1);\n    int makeMandatory(int _id) {\n      if ((_id >= 0)&&(_id < I)) { element[_id].isMandatory = 1; return 1; }\n      else return 0;\n    }\n    \n    double getDfltNum(int n) const { if ((n<I)&&(n>=0)) return element[n].dfltDouble; else return 0.0; }\n    char * getDfltStr(int n) const { if ((n<I)&&(n>=0)) return element[n].dfltStr; else return NULL; }\n    char getDfltChr(int n) const { if ((n<I)&&(n>=0)) return element[n].dfltChar; else return 0; }\n    const ConfigType * getDfltObj(int n) const { if ((n<I)&&(n>=0)) return element[n].subType;  else return NULL; }\n    \n    // get index of field _name, and optionally an array index specified in _name\n    int findField(const char *_name, int *arrI=NULL, char **arrS=NULL) const;\n    int findFieldH(const char *_name, int *n, const ConfigType **tp, int *aIdx, char **aStr) const;\n\n    // set a new name:\n    void setName(const char *_name );\n    // get name of ConfigType, if no argument is given\n    const char * getName() const { return name; }\n    // set or change name of this type (use this for derived types created via copy constructor...)\n    void setName();\n\n    // get name of element, if an index is given as argument\n    const char * getName(int n) const;\n\n    int getType(int n) const;\n    const ConfigType * getTypeObj(int n) const; // for subTypes..\n    int getN() const { return I; }\n\n    // print description of fields in this type (and all sub-types, if subtype=1)\n    void printTypeHelp(char *basestr=NULL, int _subtype=1) const;  \n\n    // print default config section for fields of this type (and all sub-types, if subtype=1)\n    // if withDescription == 1, then also print description of each value as comment\n    void printTypeDfltConfig(char *basestr=NULL, int _subtype=1, int withDescription=0, int ignInternal=2) const; \n\n    virtual ~ConfigType();\n};\n\n\n/******* Config Instance *********/\nclass DLLEXPORT ConfigInstance {\n  private:\n    char                       name[CONFIGTYPE_STRLEN];\n    const ConfigType *type;          /* single type class */\n    int freeType;              /* flag that indicates whether to free type or not */\n    int N;                     /* same as in type, number of values */\n    ConfigValue **field;       /* array of field values */\n\n    int findField(const char *_name, int *n, ConfigInstance **in, int *aIdx, char **aStr);\n    void setVal(int n, ConfigValue *val, int idx=-1);\n    const ConfigValue* getVal(int n, int idx=-1) const;\n\n    int sanityCheck(ConfigInstance *_match) const;\n\n  public:\n    ConfigInstance(const char *_name, const ConfigType *_type, int _freeType=0);\n    int missingFrom(ConfigInstance *_default); /* update missing values, take values from _default */\n    int updateWith(ConfigInstance *_new); /* values in _new overwrite values in current instance */\n\n    const int getN() const { return N; }\n    const char * getName() const { return name; }  // get name of instance\n    const char * getName(int n) const { return type->getName(n); } // get name of field n\n\n    const ConfigType * getType() const { return type; } // get type object\n    const char * getTypeName() const { return type->getName(); } // get type object\n    int getType(int n) const { return type->getType(n); } // get type of field n\n    int getType(const char *_name); /* recursively dereference, via findField */\n    //const ConfigType * getTypeObj(const char *_name) const; // get type object  xxx\n    \n    /* either N or name may be specified. if not specified name=NULL and N=-1 */\n    void setValue(ConfigValue *val, int n=-1, const char *_name=NULL, int arrIdx=-1);   /* recursively dereference subobj pointers */\n    void setValue(const char *_name, ConfigValue *val) {\n      setValue(val,-1,_name);\n    }\n    const ConfigValue *getValue(int n=-1, const char *_name=NULL, int arrIdx=-1) const; /* recursively dereference subobj pointers */\n    const ConfigValue *getValue(const char *_name, int arrIdx=-1) const {\n      return getValue(-1,_name,arrIdx);\n    }\n    ConfigInstance *getSubInstance(const char *_name);\n\n\t// note: added \"const\" here...?\n    int getInt(const char *_name) { const ConfigValue *r = getValue(-1,_name); if (r!=NULL) return r->getInt(); else return 0; }\n    double getDouble(const char *_name) { const ConfigValue *r = getValue(-1,_name); if (r!=NULL) return r->getDouble(); else return 0; }\n    const char* getStr(const char *_name) { const ConfigValue *r = getValue(-1,_name); if (r!=NULL) return r->getStr(); else return 0; }\n    char getChar(const char *_name) { const ConfigValue *r = getValue(-1,_name); if (r!=NULL) return r->getChar(); else return 0; }\n    ConfigInstance * getObj(const char *_name) { const ConfigValue *r = getValue(-1,_name); if (r!=NULL) return r->getObj(); else return 0; }\n\n\t// when setting hierarchical config names such as \"reader.dmLevel\" via setStr(), etc. the \"reader\" field of type CFTP_OBJ should automatically be created by setStr()... if not, please report this bug!\n    void setInt(const char *_name, int value) { ConfigValue *r = new ConfigValueNum(value); if (r!=NULL) setValue(_name,r); }\n    void setDouble(const char *_name, double value) { ConfigValue *r = new ConfigValueNum(value); if (r!=NULL) setValue(_name,r); }\n    void setStr(const char *_name, const char * value) { ConfigValue *r = new ConfigValueStr(value); if (r!=NULL) setValue(_name,r); }\n    void setChar(const char *_name, char value) { ConfigValue *r = new ConfigValueChr(value); if (r!=NULL) setValue(_name,r); }\n    void setObj(const char *_name, ConfigInstance *value) { ConfigValue *r = new ConfigValueObj(value); if (r!=NULL) setValue(_name,r); }\n\n    ~ConfigInstance();\n};\n\n\n/******* Config Reader *******/\nclass DLLEXPORT cConfigManager;\n\nclass DLLEXPORT cConfigReader {\n  protected:\n    char *inputPath;      // top level config file\n    char *lastLevelFile;  // config file that was previously included (can be pointer identical to inputPath or NULL in this case)\n    int  inputId;\n    cCommandlineParser *cmdparser;\n    \n  public:\n    cConfigReader(const char *_inputPath, int _inputId=-1, cCommandlineParser *cmdparser_=NULL);\n    void setCmdparser(cCommandlineParser *_parser) { cmdparser = _parser; }\n    virtual void setId(int _id) { if (_id>=0) inputId = _id; }\n    virtual int openInput(const char*name, int *idx0=NULL) { return 0; }\n    virtual int closeInput() { return 0; }\n    virtual char ** findInstancesByTypeName(const char *_typename, int *N)=0;  /* returns names (and no.) of instances of type \"typename\" */\n    char ** findInstances(const ConfigType *_type, int *N);  /* returns names (and no.) of instances of type \"typename\" */\n    void destroyStrArray(char **arr, int n);\n    virtual ConfigInstance *getInstance(const char *_instname, const ConfigType *_type, cConfigManager *cman=NULL)=0;    /* get an instance with name _instname */\n    virtual ~cConfigReader();\n};\n\n\n\nstruct fileInstance {\n  char *name;\n  char *type;\n  char **lines;\n  int *lineNr;  // absolute line numbers (as in file)\n  int N;  // number of lines\n  int Nalloc;\n};\n\nclass DLLEXPORT cFileConfigReader : public cConfigReader {\n  private:\n    fileInstance *inst;\n    int nInst, nInstAlloc;\n\n    void setNlines(int n, int nlines);\n    int addInst(const char*_instname, const char*_typename);\n    int addLine(int n, const char *line, int lineNr);\n\n  public:\n    cFileConfigReader(const char *filename, int id=-1, cCommandlineParser *cmdparser_=NULL) : cConfigReader(filename,id,cmdparser_), inst(NULL), nInst(0), nInstAlloc(0) { openInput(); }\n    virtual int openInput(const char*name=NULL, int *idx0=NULL);\n    virtual int closeInput() { return 0; }\n\n    virtual char ** findInstancesByTypeName(const char *_typename, int *N);  /* returns names (and no.) of instances of type \"typename\" */\n    virtual ConfigInstance *getInstance(const char *_instname, const ConfigType *_type, cConfigManager *cman=NULL);    /* get an instance with name _instname */\n    virtual ~cFileConfigReader();\n};\n\n\n/**** Config Manager ****/\n#ifndef MODULE\n#define MODULE \"configManager\"\n\nclass DLLEXPORT cConfigManager {\n  private:\n    int nTypes, nTypesAlloc;\n    ConfigInstance **defaults;\n    int nInst, nInstAlloc;\n    ConfigInstance **inst;\n    int nReaders, nReadersAlloc;\n    cConfigReader   **reader;\n    cCommandlineParser *cmdparser;\n    std::map <std::string, void *> *externalObjectMap_;\n    \n  protected:\n    //int findInstance(const char *_instname);\n\n  public:\n    cConfigManager(cCommandlineParser *_parser = NULL);\n    int addReader(cConfigReader *_reader);\n    int registerType(ConfigInstance *_type);\n    void readConfig();                     /* read the config, after readers and types have been registered */\n    int addInstance(ConfigInstance *_inst);   /* stores inst object in configManager, inst object will be freed by configManager */\n    int deleteInstance(const char *_instname);   /* deletes instance \"_instname\" */\n\t  int updateInstance(ConfigInstance *_inst);  /* only uses content from inst to update existing object. object is only added if it does not yet exist  (return value 1 indicated an update, while 0 indicates an adding)*/\n    int findInstance(const char *_instname) const; // first level only\n    int findType(const char *_typename) const;  // first level only\n    const ConfigType *getTypeObj(int n) const;\n    const ConfigType *getTypeObj(const char *_typename) const;  // hierarchical type resolving...\n\n    \n    /* get an instance object or value... resolve hierachical names */\n    ConfigInstance * getInstance(const char *_instname);\n    /* the _f getXXX functions free the memory allocated for _name before they return normally! */\n    ConfigInstance * getInstance_f(char *_name) {  /* return value is read only! */\n      ConfigInstance *inst = getInstance(_name);\n      if (_name != NULL) free(_name);\n      return inst;\n    }\n\n    const ConfigValue    * getValue(const char *_name) const;  /* return value is read only! */\n    /* the _f getXXX functions free the memory allocated for _name before they return normally! */\n    const ConfigValue    * getValue_f(char *_name) const {  /* return value is read only! */\n      const ConfigValue *v = getValue(_name);\n      if (_name != NULL) free(_name);\n      return v;\n    }\n\n    int getArraySize(const char *_name) const;\n    /* the _f getXXX functions free the memory allocated for _name before they return normally! */\n    int getArraySize_f(char *_name) const {  /* return value is read only! */\n      int s = getArraySize(_name);\n      if (_name != NULL) free(_name);\n      return s;\n    }\n\n    \n    /* get keys of an associative array, and optionally the number N of elements\n       NOTE: some keys in the returned array might be NULL if the element was not set!! */\n    char **getArrayKeys(const char *_name, int *N=NULL) const;\n    /* the _f getXXX functions free the memory allocated for _name before they return normally! */\n    char **getArrayKeys_f(char *_name, int *N=NULL) const {  /* return value is read only! */\n      char ** k = getArrayKeys(_name, N);\n      if (_name != NULL) free(_name);\n      return k;\n    }\n\n    \n    const int getInt(const char *_name, int *isSet=NULL) const {\n      const ConfigValue *v = getValue(_name);\n      if (v!=NULL) {\n        if (v->getType() >= CFTP_ARR) CONF_MANAGER_ERR(\"getInt('%s') called on array element without array index!\",_name);\n        if (isSet != NULL) *isSet = v->isSet();\n        return v->getInt();\n      }\n      return 0;\n    }\n\n    /* the _f getXXX functions free the memory allocated for _name before they return normally! */\n    const int getInt_f(char *_name, int *isSet=NULL) const {  /* return value is read only! */\n      int d = getInt(_name, isSet);\n      if (_name != NULL) free(_name);\n      return d;\n    }\n\n    const double getDouble(const char *_name, int *isSet=NULL) const {\n      const ConfigValue *v = getValue(_name);\n      if (v!=NULL) {\n        if (v->getType() >= CFTP_ARR) CONF_MANAGER_ERR(\"getDouble('%s') called on array element without array index!\",_name);\n        if (isSet != NULL) *isSet = v->isSet();\n        return v->getDouble();\n      }\n      return 0.0;\n    }\n\n    /* the _f getXXX functions free the memory allocated for _name before they return normally! */\n    const double getDouble_f(char *_name, int *isSet=NULL) const {  /* return value is read only! */\n      double d = getDouble(_name, isSet);\n      if (_name != NULL) free(_name);\n      return d;\n    }\n\n    const char    * getStr(const char *_name, int *isSet=NULL) const {  /* return value is read only! */\n      const ConfigValue *v = getValue(_name);\n      if (v!=NULL) {\n        if (v->getType() >= CFTP_ARR) CONF_MANAGER_ERR(\"getStr('%s') called on array element without array index!\",_name);\n        if (isSet != NULL) *isSet = v->isSet();\n        return v->getStr();\n      }\n      return NULL;\n    }\n\n    /* the _f getXXX functions free the memory allocated for _name before they return normally! */\n    const char    * getStr_f(char *_name, int *isSet=NULL) const {  /* return value is read only! */\n      const char *s = getStr(_name, isSet);\n      if (_name != NULL) free(_name);\n      return s;\n    }\n    \n    const char getChar(const char *_name, int *isSet=NULL) const {\n      const ConfigValue *v = getValue(_name);\n      if (v!=NULL) {\n        if (v->getType() >= CFTP_ARR) CONF_MANAGER_ERR(\"getChar('%s') called on array element without array index!\",_name);\n        if (isSet != NULL) *isSet = v->isSet();\n        return v->getChar();\n      }\n      return 0;\n    }\n\n    /* the _f getXXX functions free the memory allocated for _name before they return normally! */\n    const char    getChar_f(char *_name, int *isSet=NULL) const {  /* return value is read only! */\n      const char c = getChar(_name, isSet);\n      if (_name != NULL) free(_name);\n      return c;\n    }\n\n    int isSet(const char *_name) const {\n      try {\n        const ConfigValue *v = getValue(_name);\n        if (v!=NULL) {\n          return v->isSet();\n        } else return 0;\n      } catch (cConfigException) { // removed &c ??\n        return 0;\n      }\n    }\n\n    /* the _f getXXX functions free the memory allocated for _name before they return normally! */\n    int isSet_f(char *_name) const {\n      int s = isSet(_name);\n      if (_name != NULL) free(_name);\n      return s;\n    }\n\n    /* print help for all registered config types, if selection==NULL, \n       else print help for type(s) beginning with the name given in *selection */\n    void printTypeHelp(int _subtype=1, const char *selection=NULL, int dfltConf=0);\n\n    /* print a default config file section for the type given in selection, \n       or for all types if selection == NULL. \n       If _subtype == 1, explicitely print default values of all subtypes. */\n    void printTypeDfltConfig(const char *selection=NULL, int _subtype=1, int fullMode=0, int withDescription=1);\n\n    // support for dirty pointer passing from external (pre tick loop) code\n    // into components\n    void addExternalPointer(const char * name, void * ptr) {\n      if (externalObjectMap_->find(name) != externalObjectMap_->end()) {\n        SMILE_WRN(1, \"configManager: duplicate assignment of external pointer '%s'\", name);\n      }\n      (*externalObjectMap_)[name] = ptr;\n    }\n\n    void * getExternalPointer(const char * name) {\n      if (externalObjectMap_->find(name) != externalObjectMap_->end()) {\n        return (*externalObjectMap_)[name];\n      } else {\n        SMILE_WRN(1, \"configManager: external pointer with name '%s' not found! Returning NULL.\", name);\n      }\n      return NULL;\n    }\n    /*\n    naming conventions\n    */\n    ~cConfigManager();\n};\n\n#undef MODULE\n#endif\n\n\n\n\n\n#endif  // __CONFIG_MANAGER_HPP\n"
  },
  {
    "path": "src/include/core/dataMemory.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n#ifndef __DATA_MEMORY_HPP\n#define __DATA_MEMORY_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/smileComponent.hpp>\n#include <math.h>\n#ifdef HAVE_UNISTD_H\n#include <unistd.h>\n#endif\n\n// temporal frame ID\n#define DMEM_IDX_ABS    -1   // no special index\n#define DMEM_IDX_CURR   -11   // current read index\n#define DMEM_IDX_CURW   -12   // current write index\n#define DMEM_IDXR_CURR  -13   // start is relative to current read index\n#define DMEM_IDXR_CURW  -14   // start is relative to current write index\n#define DMEM_PAD_ZERO   -101   // pad with zeros\n#define DMEM_PAD_FIRST  -102   // pad with first/last available frame (default)\n#define DMEM_PAD_NONE   -103   // truncate frame (matrix) to actual available length\n\n/*\n#define FLOAT_DMEM_FLOAT  0\n#define FLOAT_DMEM_DOUBLE  1\n\n// this defines the float type used throughout the data memory, either 'float' or 'double'\n#define FLOAT_DMEM  float\n#define FLOAT_DMEM_NUM  FLOAT_DMEM_FLOAT   // this numeric constant MUST equal the float type set above ...\n                                           // 0 = float, 1 = double:\n// this defines the int type used throughout the data memory, either 'short', 'int' or 'long'\n#define INT_DMEM    int\n*/\n\n#define DMEM_FLOAT   0\n#define DMEM_INT     1\n\n#define LOOKAHEAD_ALLOC  20\n\n/***** frame field dataType definitions *********/\n\n#define DATATYPE_UNKNOWN  0\n#define DATATYPE_SIGNAL   0x0100    // raw signal (pcm, etc.)\n#define DATATYPE_SIGNAL_PCM  0x0101\n#define DATATYPE_SIGNAL_IMG  0x0102\n#define DATATYPE_SPECTRUM  0x0200\n#define DATATYPE_SPECTRUM_BINS_FIRST    0x201\n#define DATATYPE_SPECTRUM_BINS_COMPLEX  0x0201\n#define DATATYPE_SPECTRUM_BINS_MAG  0x0202   /* magnitude spectrum */\n#define DATATYPE_SPECTRUM_BINS_MAGPHASE  0x0242   /* magnitude spectrum and phase in one array (mag first half, phase second half) */\n#define DATATYPE_SPECTRUM_BINS_PHASE  0x0203 /* spectral phase */\n#define DATATYPE_SPECTRUM_BINS_DBPSD  0x0204 /* power spectral density in dB SPL */\n#define DATATYPE_SPECTRUM_BINS_POWSPECDENS  0x0205   /* power spectral density */\n#define DATATYPE_SPECTRUM_BINS_POWSPEC  0x0206 /* power spectrum */\n#define DATATYPE_SPECTRUM_BINS_SPECDENS  0x0207 /* magnitude spectral density */\n#define DATATYPE_SPECTRUM_BINS_LAST    0x207\n#define DATATYPE_SPECTRUM_BANDS_MAG  0x0220\n#define DATATYPE_COEFFICIENTS  0x0300\n#define DATATYPE_ACF        0x0380\n#define DATATYPE_CEPSTRAL  0x0400\n#define DATATYPE_MIXED_LLD  0x1000  // mixed low-level descriptors (e.g. pitch, etc.)\n#define DATATYPE_FUNCTIONALS  0x2000  // functionals of lld, etc.\n\n\n/**** frame meta information *********\n   names, indicies (for each row)\n **************************************/\n\n#undef class\n// meta information for one field...\nclass DLLEXPORT FieldMetaInfo {\n  public:\n\n  char *name;\n  int Nstart;  // start index (position in FrameMetaInfo\n  int N;  //  number of elements (>1 ==> array)\n  int dataType; // dataType flag indicating type of data in this field (NEW feature, see dataType definitions in dataMemory.hpp)\n  long infoSize; // size of info struct in BYTES!\n  int infoSet;  // flag that indicates whether the info has been set or not (dataType, *info, infoSize)\n  void *info;   // custom info data (e.g. spectral scaling for spectra) \n  int arrNameOffset;\n\n  FieldMetaInfo() : name(NULL), info(NULL), infoSize(0), dataType(0), N(0),arrNameOffset(0) {}\n  void copyFrom(FieldMetaInfo *f) {\n    if (f!=NULL) {\n      Nstart=f->Nstart;\n      N = f->N;\n      arrNameOffset = f->arrNameOffset;\n      dataType = f->dataType;\n      infoSize = f->infoSize;\n      if (info != NULL) free(info);\n      info = malloc(infoSize);\n      memcpy(info, f->info, infoSize);\n      if (name != NULL) free(name);\n      if (f->name != NULL) name = strdup(f->name);\n      else name = NULL;\n    }\n  }\n  ~FieldMetaInfo() { \n    if (name!=NULL) free(name); \n    if (info!=NULL) free(info);\n  }\n};\n\nclass DLLEXPORT cVectorMeta { public:\n  int ID; /* ID identifying the meta data type */\n  int iData[8]; /* freely usable ints */\n  FLOAT_DMEM fData[8]; /* freely usable floats */\n  char * text; /* custom meta-data text, will be auto-freed using free() if not NULL */\n  void * custom; /* custom meta data, will be auto-freed using free() if not NULL */\n  long customLength; /* length of data in custom (in bytes!), this is required for cloning a cVectorMeta data object! Set this to <= 0 to only copy the pointer and not free the pointer when the cVectorMeta object is freeed!*/\n  cVectorMeta() : ID(0), text(NULL), custom(NULL), customLength(0)\n  {\n    iData[0] = iData[1] = iData[2] = iData[3] = 0;\n    iData[4] = iData[5] = iData[6] = iData[7] = 0;\n    fData[0] = fData[1] = fData[2] = fData[3] = 0.0;\n    fData[4] = fData[5] = fData[6] = fData[7] = 0.0;\n  }\n\n  void clear() {\n    ID = 0;\n    if (text != NULL) {\n      free(text);\n      text = NULL;\n    }\n    if (custom != NULL) {\n      free(custom);\n      custom = NULL;\n    }\n    customLength = 0;\n    iData[0] = iData[1] = iData[2] = iData[3] = 0;\n    iData[4] = iData[5] = iData[6] = iData[7] = 0;\n    fData[0] = fData[1] = fData[2] = fData[3] = 0.0;\n    fData[4] = fData[5] = fData[6] = fData[7] = 0.0;\n  }\n\n  void cloneFrom(const cVectorMeta *v)\n  {\n    if (v!=NULL) {\n      int i;\n      ID = v->ID;\n      for (i=0; i<8; i++) iData[i] = v->iData[i];\n      for (i=0; i<8; i++) fData[i] = v->fData[i];\n      if (v->text != NULL) {\n        if (text != NULL) free(text);\n        text = strdup(v->text);\n      }\n      if ((v->customLength > 0)&&(v->custom != NULL)) {\n        if ((custom != NULL)&&(customLength>0)) free(custom);\n        custom = malloc(v->customLength);\n        memcpy(custom, v->custom, v->customLength);\n        customLength = v->customLength;\n      }\n    }\n  }\n  ~cVectorMeta() { \n    if (text != NULL) free(text); \n    if ((customLength>0)&&(custom != NULL)) free(custom); \n  }\n};\n\n\n// meta information for a complete vector \nclass DLLEXPORT FrameMetaInfo {\n  public:\n    smileMutex myMtx;\n    long N, Ne;   // number of fields..\n    FieldMetaInfo *field;\n    \n    // global metadata for the whole level (use tmeta->metadata for per frame meta data)\n    cVectorMeta metaData;\n\n    FrameMetaInfo() : N(0), Ne(0), field(NULL) \n    {\n      smileMutexCreate(myMtx);\n    }\n    \n    /* find a field by its full name (optionally including array index */\n    // returned *arrIdx will be the real index in the data structure, i.e. named index - arrNameOffset\n    // if more != NULL, then *more (if > 0) will be used as a start field index for the search (i>=*more)\n    //                  and *more will be filled with the number of additional matches found (0 if the returned field is the only match)\n    int findField(const char*_fieldName, int *arrIdx=NULL, int *more=NULL) const;\n    /* find a field by a part of its name (optionally including array index) */\n    // returned *arrIdx will be the real index in the data structure, i.e. named index - arrNameOffset\n    // NOTE: if multiple names contain the same part, only the first one found will be returned! Solution: use the 'more' parameter:\n    //   if more != NULL, then *more (if > 0) will be used as a start field index for the search (i>=*more)\n    //                    and *more will be filled with the number of additional matches found (0 if the returned field is the only match)\n    int findFieldByPartialName(const char*_fieldNamePart, int *arrIdx=NULL, int *more=NULL) const;\n\n    long fieldToElementIdx(long _field, long _arrIdx=0) const;\n    long elementToFieldIdx(long _element, long *_arrIdx=NULL) const;\n\n    void printFieldNames() const {\n      SMILE_PRINT(\"  Field name & dimension:\");\n      for (int i = 0; i < N; i++) {\n        SMILE_PRINT(\"    %s %i\", field[i].name, field[i].N);\n      }\n    }\n\n    const char *getName(int n, int *arrIdx=NULL); // n is element(!) index\n    ~FrameMetaInfo() {\n      if (field != NULL) {\n        int i;\n        for (i=0; i<N; i++) { \n          if (field[i].name != NULL) free(field[i].name); \n          if (field[i].info!=NULL) free(field[i].info);\n        }\n        free(field);\n      }\n      smileMutexDestroy(myMtx);\n    }\n};\n\n/**** temporal meta information *********\n   length, times, etc. (for each column)\n **************************************/\n\nclass DLLEXPORT TimeMetaInfo;\n\n// used for non-overlapping frames, at fixed rate\n// i.e. for audio samples\nclass DLLEXPORT TimeMetaInfoMinimal { public:\n  long vIdx;     // index of this frame in data memory level ?\n  float period;  // frame period of this level\n//  double time;    // real start time in seconds  = 0\n//  double lengthSec; // real length in seconds  = 1/T\n//  double vLengthSec;  // actual length in seconds (e.g. zero padded fft)   = 1/T\n//  long lengthFrames;  // real length in frames  = 1\n//  long vLengthFrames;  // actual length in frames  (e.g. zero padded fft)  = 1\n//  double framePeriod;      // frame period of previous level  = T\n//  long lengthSamples;  // real length in samples (samplerate = frame rate of top most level)  = 1\n//  long vLengthSamples;  // actual length in samples (samplerate =  frame rate of top most level)  = 1\n//  double samplePeriod;      // sampleperiod = 1/samplerate (top most level)  =  T\n//  double smileTime;    // smile time at which the frame (or a parent) was initially written to the data memory by a source (time measured in seconds since creation of component manager object)\n//  int noAutoSmileTime; // if this is set to 1, smile time will not be updated (unless it is -1.0) when this frame is written to the datamemory (this can be used by components (esp. sources) in offline mode, to set valid timestamps)\n//  cVectorMeta metadata; // custom meta-data for each vector/matrix\n  TimeMetaInfoMinimal() : vIdx(0), period(0.0) {}\n\n  void cloneFrom(const TimeMetaInfoMinimal *tm) {\n    if (tm != NULL) {\n      vIdx = tm->vIdx;\n      period = tm->period;\n    }\n  }\n  void cloneFrom(const TimeMetaInfo *tm);\n};\n\nclass DLLEXPORT TimeMetaInfo { public:\n  int filled;    // whether info in this struct was already completed by setTimeMeta or the calling code\n  int level;    // originating level idx\n  long vIdx;     // index of this frame in data memory level ?\n  double period; // frame period of this level\n  double time;    // real start time in seconds\n  double lengthSec; // real length in seconds\n  double vLengthSec;  // actual length in seconds (e.g. zero padded fft)\n  long lengthFrames;  // real length in frames\n  long vLengthFrames;  // actual length in frames  (e.g. zero padded fft)\n  double framePeriod;      // frame period of previous level\n  long lengthSamples;  // real length in samples (samplerate = frame rate of top most level)\n  long vLengthSamples;  // actual length in samples (samplerate =  frame rate of top most level)\n  double samplePeriod;      // sampleperiod = 1/samplerate (top most level)\n  double smileTime;    // smile time at which the frame (or a parent) was initially written to the data memory by a source (time measured in seconds since creation of component manager object)\n  int noAutoSmileTime; // if this is set to 1, smile time will not be updated (unless it is -1.0) when this frame is written to the datamemory (this can be used by components (esp. sources) in offline mode, to set valid timestamps)\n  cVectorMeta metadata; // custom meta-data for each vector/matrix\n  TimeMetaInfo() :\n    filled(0), level(0), vIdx(0), period(0.0), time(0.0),\n    lengthSec(0.0), vLengthSec(0.0), lengthFrames(0),\n    vLengthFrames(0), framePeriod(0.0), lengthSamples(0),\n    vLengthSamples(0), samplePeriod(0.0), smileTime(-1.0), noAutoSmileTime(0)\n  {}\n\n  void cloneFrom(const TimeMetaInfo *tm) {\n    if (tm!=NULL) {\n      filled = tm->filled;\n      level = tm->level;\n      vIdx = tm->vIdx;\n      period = tm->period;\n      time = tm->time;\n      lengthSec = tm->lengthSec;\n      vLengthSec = tm->vLengthSec;\n      lengthFrames = tm->lengthFrames;\n      vLengthFrames = tm->vLengthFrames;\n      framePeriod = tm->framePeriod;\n      lengthSamples = tm->lengthSamples;\n      vLengthSamples = tm->vLengthSamples;\n      samplePeriod = tm->samplePeriod;\n      smileTime = tm->smileTime;\n      metadata.cloneFrom(&(tm->metadata));\n    }\n  }\n\n  void cloneFrom(const TimeMetaInfoMinimal *tm, int originating_level = -1) {\n    if (tm!=NULL) {\n      filled = 1;\n      level = originating_level;\n      vIdx = tm->vIdx;\n      period = tm->period;\n      time = (double)tm->vIdx * (double)tm->period;\n      lengthSec = 1.0 / (double)period;\n      vLengthSec = lengthSec;\n      lengthFrames = 1;\n      vLengthFrames = 1;\n      framePeriod = period;\n      lengthSamples = 1;\n      vLengthSamples = 1;\n      samplePeriod = period;\n      smileTime = time;\n      metadata.clear();\n    }\n  }\n};\n\n\n\n/**** dataMemory datatypes *********\n **************************************/\n\nclass DLLEXPORT cVector { public:\n  // frame data + meta information\n  long N;  // number of elements (?)\n  int type;\n  int tmetaArr; /* 1=tmeta is array, 0=tmeta is single object */\n  TimeMetaInfo *tmeta; // usually tmeta is allocated individually for each vector\n  TimeMetaInfoMinimal *tmeta_minimal; // usually tmeta is allocated individually for each vector\n  double tmeta_minimal_period; // usually tmeta is allocated individually for each vector\n  int tmetaAlien; // .. except if tmetaAlien is set, then tmeta is a pointer to a struct allocated elsewhere\n  FrameMetaInfo *fmeta; // fmeta is always a pointer to memory in the dataMemory\n  FLOAT_DMEM *dataF;\n  INT_DMEM *dataI;\n  char *ntmp; // temporary name for name(n) function\n  // (obsolete: ? TODO:  add name of origin level to his vector in order to build unique field names!)\n  \n  // TODO: add clear() method!\n  \n  cVector(int lN, int ltype=DMEM_FLOAT);\n  // get name of expanded element n\n  const char *name(int n, int *lN=NULL);\n  // TODO: getval/setval functions for Int and Float\n  FLOAT_DMEM getF(int n) { return dataF[n]; } // WARNING: index n is not checked!\n  INT_DMEM getI(int n) { return dataI[n]; } // WARNING: index n is not checked!\n\n  void tmetaReplace(TimeMetaInfo *xtmeta) {\n    if ((tmeta != NULL)&&(!tmetaAlien)) {\n      if (tmetaArr) delete[] tmeta;\n      else delete tmeta;\n    }\n    tmetaAlien = 1;\n    tmetaArr = 0;\n    tmeta = xtmeta;\n  }\n  void tmetaReplace(TimeMetaInfoMinimal *xtmeta, double period = 0.0) {\n    if ((tmeta_minimal != NULL)&&(!tmetaAlien)) {\n      if (tmetaArr) delete[] tmeta_minimal;\n      else delete tmeta_minimal;\n    }\n    tmetaAlien = 1;\n    tmetaArr = 0;\n    tmeta_minimal = xtmeta;\n    tmeta_minimal_period = period;\n  }\n  void tmetaReplaceFromMatrix(TimeMetaInfo *xtmeta) {\n    tmetaReplace(xtmeta);\n    tmetaArr = 1;\n  }\n  void tmetaReplaceFromMatrix(TimeMetaInfoMinimal *xtmeta, double period = 0.0) {\n    tmetaReplace(xtmeta);\n    tmetaArr = 1;\n    tmeta_minimal_period = period;\n  }\n\n  void tmetaClone(TimeMetaInfo *xtmeta) {\n    if ((tmeta != NULL)&&(!tmetaAlien)) {\n      if (tmetaArr) delete[] tmeta;\n      else delete tmeta;\n    }\n    tmeta = new TimeMetaInfo();\n    tmeta->cloneFrom(xtmeta);\n    tmetaAlien = 0;\n    tmetaArr=0;\n  }\n  void tmetaClone(TimeMetaInfoMinimal *xtmeta) {\n    if ((tmeta_minimal != NULL)&&(!tmetaAlien)) {\n      if (tmetaArr) delete[] tmeta_minimal;\n      else delete tmeta_minimal;\n    }\n    tmeta_minimal = new TimeMetaInfoMinimal();\n    tmeta_minimal->cloneFrom(xtmeta);\n    tmetaAlien = 0;\n    tmetaArr = 0;\n  }\n  void tmetaCloneToFull(TimeMetaInfoMinimal *xtmeta) {\n    if ((tmeta_minimal != NULL)&&(!tmetaAlien)) {\n      if (tmetaArr) delete[] tmeta_minimal;\n      else delete tmeta_minimal;\n    }\n    if ((tmeta != NULL)&&(!tmetaAlien)) {\n      if (tmetaArr) delete[] tmeta;\n      else delete tmeta;\n    }\n    tmeta = new TimeMetaInfo();\n    tmeta->cloneFrom(xtmeta);\n    tmetaAlien = 0;\n    tmetaArr = 0;\n  }\n  void tmetaCloneToMinimal(TimeMetaInfo *xtmeta) {\n    if ((tmeta_minimal != NULL)&&(!tmetaAlien)) {\n      if (tmetaArr) delete[] tmeta_minimal;\n      else delete tmeta_minimal;\n    }\n    if ((tmeta != NULL)&&(!tmetaAlien)) {\n      if (tmetaArr) delete[] tmeta;\n      else delete tmeta;\n    }\n    tmeta_minimal = new TimeMetaInfoMinimal();\n    tmeta_minimal->cloneFrom(xtmeta);\n    tmetaAlien = 0;\n    tmetaArr = 0;\n  }\n\n  void tmetaCloneFromMatrix(TimeMetaInfo *xtmeta) {\n    tmetaClone(xtmeta);\n    /*if ((tmeta != NULL)&&(!tmetaAlien)) {\n      if (tmetaArr) delete[] tmeta;\n      else delete tmeta;\n    }\n    tmeta = new TimeMetaInfo();\n    tmeta->cloneFrom(xtmeta);\n    tmetaAlien = 0;\n    tmetaArr = 0;*/\n  }\n  void tmetaCloneFromMatrix(TimeMetaInfoMinimal *xtmeta) {\n    tmetaClone(xtmeta);\n    /*\n    if ((tmeta_minimal != NULL)&&(!tmetaAlien)) {\n      if (tmetaArr) delete[] tmeta_minimal;\n      else delete tmeta_minimal;\n    }\n    //tmeta = new TimeMetaInfo(_tmeta[0]); // copy constructor\n    tmeta_minimal = new TimeMetaInfo();\n    tmeta_minimal->cloneFrom(xtmeta);\n    tmetaAlien = 0; tmetaArr=0; //??\n    */\n  }\n  void tmetaCloneFromMatrixToFull(TimeMetaInfoMinimal *xtmeta) {\n    tmetaCloneToFull(xtmeta);\n  }\n  void tmetaCloneFromMatrixToMinimal(TimeMetaInfo *xtmeta) {\n    tmetaCloneToMinimal(xtmeta);\n  }\n\n  void tmetaResample(long sourceRate, long targetRate, long vIdxStart) {\n   // TODO\n  }\n\n  void setF(int n, FLOAT_DMEM v) { dataF[n]=v; } // WARNING: index n is not checked!\n  void setI(int n, INT_DMEM v) { dataI[n]=v; } // WARNING: index n is not checked!\n\n  virtual ~cVector();\n};\n\n\n// memory organsisation of cMatrix:\n// array index x = col*N + row   ( t*N + n )\nclass DLLEXPORT cMatrix : public cVector { public:\n  long nT;\n\n  cMatrix(int lN, int lnT, int ltype=DMEM_FLOAT);\n  // TODO: overwritten getval/setval functions for Int and Float\n  FLOAT_DMEM getF(int n, int t) { return dataF[n+t*N]; } // WARNING: index n is not checked!\n  INT_DMEM getI(int n, int t) { return dataI[n+t*N]; } // WARNING: index n is not checked!\n  void setF(int n, int t, FLOAT_DMEM v) { dataF[n+t*N]=v; } // WARNING: index n is not checked!\n  void setI(int n, int t, INT_DMEM v) { dataI[n+t*N]=v; } // WARNING: index n is not checked!\n  // transpose matrix\n  void transpose();\n  // reshape to given dimensions, perform sanity check...\n  void reshape(long R, long C);\n  cMatrix * getRow(long R) {\n    cMatrix *r = new cMatrix(1,nT,type);\n    cMatrix *ret = getRow(R,r);\n    if (ret==NULL) delete r;\n    return ret;\n/*    long i;\n    if (type==DMEM_FLOAT) for (i=0; i<nT; i++) { r->dataF[i] = dataF[i*N+R]; }\n    else if (type==DMEM_INT) for (i=0; i<nT; i++) { r->dataI[i] = dataI[i*N+R]; }\n    else { delete r; return NULL; }\n    r->tmetaReplace(tmeta);\n    return r;*/\n  }\n\n  void tmetaReplace(TimeMetaInfo *_tmeta) {\n    if ((tmeta != NULL)&&(!tmetaAlien)) {\n      if (tmetaArr) delete[] tmeta;\n      else delete tmeta;\n      tmetaAlien = 1;\n    }\n    tmeta = _tmeta; tmetaArr=1;\n  }\n  void tmetaClone(TimeMetaInfo *_tmeta, long _nT=-1) {\n    if (_nT == -1) _nT = nT;\n    if ((tmeta != NULL)&&(!tmetaAlien)) {\n      if (tmetaArr) delete[] tmeta;\n      else delete tmeta;\n    }\n    tmeta = new TimeMetaInfo[nT];\n    // TODO: use copy constructors???\n    memcpy(tmeta,_tmeta,sizeof(TimeMetaInfo)*MIN(nT,_nT));\n    // strdup the metadata->text field??\n    if (_nT < nT) {\n      // TODO: manually free the variables in metadata here!!!\n      bzero( tmeta + _nT, sizeof(TimeMetaInfo)*(nT-_nT) );\n    }\n    tmetaAlien = 0; tmetaArr=1;\n  }\n  void tmetaResample(long sourceRate, long targetRate, long vIdxStart) {\n    // TODO\n  }\n\n\n  cMatrix * getRow(long R, cMatrix *r) {\n    long i;\n    if (r==NULL) r = new cMatrix(1,nT,type);\n    else {\n      if (r->nT != nT) { delete r; r = new cMatrix(1,nT,type); }\n      if (type != r->type) return NULL;\n    }\n    long nn = MIN(nT,r->nT);\n    if (type==DMEM_FLOAT) {\n      FLOAT_DMEM *df = dataF+R;\n      for (i=0; i<nn; i++) { r->dataF[i] = *df; df += N; /*dataF[i*N+R];*/ }\n      for ( ; i<r->nT; i++) { r->dataF[i] = 0.0; }\n    } else if (type==DMEM_INT) {\n      INT_DMEM *di = dataI+R;\n      for (i=0; i<nn; i++) { r->dataI[i] = *di; di += N; /*dataI[i*N+R];*/ }\n    } else { /*delete r;*/ return NULL; }\n    r->tmetaReplace(tmeta);\n    return r;\n  }\n\n  cVector* getCol(long C) {\n    cVector *c = new cVector(N,type);\n    long i;\n    if (type==DMEM_FLOAT) for (i=0; i<N; i++) { c->dataF[i] = dataF[N*C+i]; }\n    else if (type==DMEM_INT) for (i=0; i<N; i++) { c->dataI[i] = dataI[N*C+i]; }\n    else { delete c; return NULL; }\n    c->tmetaReplace(tmeta);\n    return c;\n  }\n  cVector* getCol(long C, cVector *c) {\n    if (c==NULL) c = new cVector(N,type);\n    long i;\n    if (type==DMEM_FLOAT) for (i=0; i<N; i++) { c->dataF[i] = dataF[N*C+i]; }\n    else if (type==DMEM_INT) for (i=0; i<N; i++) { c->dataI[i] = dataI[N*C+i]; }\n    else { delete c; return NULL; }\n    c->tmetaReplace(tmeta);\n    return c;\n  }\n\n  void setRow(long R, cMatrix *row) { // NOTE: set row does not change tmeta!!\n    long i;\n    if (row!=NULL) {\n      long nn = MIN(nT,row->nT);\n      if (row->type == type) {\n        if (type==DMEM_FLOAT) for (i=0; i<nn; i++) { dataF[i*N+R] = row->dataF[i]; }\n        else if (type==DMEM_INT) for (i=0; i<nn; i++) { dataI[i*N+R] = row->dataI[i]; }\n      } else {\n        if (type==DMEM_FLOAT) for (i=0; i<nn; i++) { dataF[i*N+R] = (FLOAT_DMEM)(row->dataI[i]); }\n        else if (type==DMEM_INT) for (i=0; i<nn; i++) { dataI[i*N+R] = (INT_DMEM)(row->dataF[i]); }\n      }\n    }\n  }\n  // convert a matrix tmeta to a vector tmeta spanning the whole matrix by adjusting size, period, etc.\n  void tmetaSquash(double period=-1.0) {\n    if (tmeta != NULL) {\n      tmeta[0].framePeriod = tmeta[0].period;\n      if (period != -1.0)\n        tmeta[0].period = period;\n      //else   // TODO::: there is bug here......\n      //  tmeta[0].period = tmeta[nT-1].time - tmeta[0].time + tmeta[nT-1].lengthSec;\n      tmeta[0].lengthSec = tmeta[nT-1].time - tmeta[0].time + tmeta[nT-1].lengthSec;\n      tmeta[0].vLengthSec = tmeta[0].lengthSec;\n      tmeta[0].lengthFrames = (long)ceil(tmeta[0].lengthSec / tmeta[0].framePeriod);\n      tmeta[0].vLengthFrames = (long)ceil(tmeta[0].vLengthSec / tmeta[0].framePeriod);\n      tmeta[0].lengthSamples = (long)ceil(tmeta[0].lengthSec / tmeta[0].samplePeriod);\n      tmeta[0].vLengthSamples = (long)ceil(tmeta[0].vLengthSec / tmeta[0].samplePeriod);\n    }\n  }\n  \n  int resize(long _new_nT) {\n    int ret=1;\n    if (_new_nT < nT) return 1;\n\n    // dataF / dataI\n    if (type == DMEM_FLOAT) {\n      FLOAT_DMEM *tmp = (FLOAT_DMEM *)crealloc(dataF, _new_nT*sizeof(FLOAT_DMEM)*N, nT*sizeof(FLOAT_DMEM)*N);\n      if (tmp==NULL) ret = 0;\n      else dataF = tmp;\n    } else if (type == DMEM_INT) {\n      INT_DMEM *tmp = (INT_DMEM *)crealloc(dataI, _new_nT*sizeof(INT_DMEM)*N, nT*sizeof(INT_DMEM)*N);\n      if (tmp==NULL) ret = 0;\n      else dataI = tmp;\n    }\n\n    if (ret) {\n      // tmeta\n      TimeMetaInfo *old = tmeta;\n      tmeta = new TimeMetaInfo[_new_nT];\n      if (tmeta == NULL) { ret=0; tmeta = old; }\n      else {\n        memcpy(tmeta,old,sizeof(TimeMetaInfo)*nT);\n        memset(tmeta+nT,0,sizeof(TimeMetaInfo)*(_new_nT-nT));\n        if ((old != NULL)&&(!tmetaAlien)) {\n          delete[] old;\n        }\n        tmetaAlien = 0;\n      }\n    }\n\n    if (ret) nT = _new_nT;\n\n    return ret;\n  }\n\n  // convert matrix to long vector with all columns concatenated ...\n  const cVector* expand();\n  \n  ~cMatrix();\n};\n\n/******* dataMemory level class ************/\n\n#ifndef MODULE\n#define MODULE \"dataMemory\"\n#define UNDEFMOD\n#endif\n\n/* result codes for getFrame/Matrix setFrame/Matrix */\n#define DMRES_OK        0\n#define DMRES_ERR       1\n#define DMRES_OORleft   4\n#define DMRES_OORright  8\n#define DMRES_OORbs     16\n\n/* level configuration */\nclass DLLEXPORT sDmLevelConfig { public:\n  /* timing configuration */\n  double T;       // period of frames in this level (\"frameStep\" in seconds)\n  double frameSizeSec; // size of ONE frame in seconds\n  double lastFrameSizeSec; // size of ONE frame in seconds, previous level (or level before frameSizeSec was modifed)\n  long nT;        // level bufferSize in frames\n  double lenSec;  // length of buffer in seconds (\"frameStep\"*nT)\n  double basePeriod; // period of top most level, if available, else 0\n\n  long blocksizeWriter, blocksizeReader; // blocksize of writer, max. blocksize of reader(s)\n\n  /* level type */\n  int isRb;\n  int noHang;\n  int growDyn;\n  int type;\n\n  /* config state: if no flag is set: only  timing and type config is set */\n  int finalised; /* timing, type, blocksize, and names config is ready AND level mem is allocated */\n  int blocksizeIsSet; /* timing, type, and blocksize config is ready */\n  int namesAreSet; /* timing, type, blocksize, and names config is ready */\n\n  long N, Nf;         // number of elements, number of fields (Nf is same as fmeta->N)\n  FrameMetaInfo *fmeta; // pointer to fmeta, which is allocated in the corresponding dataMemory level\n  char *name;  // level name\n\n  sDmLevelConfig(double _T, double _frameSizeSec, long _nT=10, int _type=DMEM_FLOAT, int _isRb=1) :\n    T(_T), frameSizeSec(_frameSizeSec), lastFrameSizeSec(_frameSizeSec), nT(_nT), lenSec(0.0), basePeriod(0.0),\n    blocksizeWriter(1), blocksizeReader(1),\n    isRb(_isRb), noHang(1), growDyn(0),\n    type(_type),\n    finalised(0), blocksizeIsSet(0), namesAreSet(0),\n    N(0), Nf(0), \n    fmeta(NULL),\n    name(NULL) \n  { \n    lenSec = T*(double)nT; \n  }\n\n  sDmLevelConfig(double _T, double _frameSizeSec, double _lenSec=1.0, int _type=DMEM_FLOAT, int _isRb=1) :\n    T(_T), frameSizeSec(_frameSizeSec), lastFrameSizeSec(_frameSizeSec), nT(0), lenSec(_lenSec), basePeriod(0.0),\n    blocksizeWriter(1), blocksizeReader(1),\n    isRb(_isRb), noHang(1), growDyn(0),\n    type(_type),\n    finalised(0), blocksizeIsSet(0), namesAreSet(0),\n    N(0), Nf(0), \n    fmeta(NULL),\n    name(NULL) \n  { \n    if (T!=0.0) nT = (long)ceil(lenSec/T); \n  }\n\n  sDmLevelConfig(const char *_name, double _T, double _frameSizeSec, long _nT=10, int _type=DMEM_FLOAT, int _isRb=1) :\n    T(_T), frameSizeSec(_frameSizeSec), lastFrameSizeSec(_frameSizeSec), nT(_nT), lenSec(0.0), basePeriod(0.0),\n    blocksizeWriter(1), blocksizeReader(1),\n    isRb(_isRb), noHang(1), growDyn(0),\n    type(_type),\n    finalised(0), blocksizeIsSet(0), namesAreSet(0),\n    N(0), Nf(0), \n    fmeta(NULL),\n    name(NULL) \n  { \n    lenSec = T*(double)nT; \n    if (_name != NULL) name = strdup(_name);\n  }\n\n  sDmLevelConfig(const char *_name, double _T, double _frameSizeSec, double _lenSec=1.0, int _type=DMEM_FLOAT, int _isRb=1) :\n    T(_T), frameSizeSec(_frameSizeSec), lastFrameSizeSec(_frameSizeSec), nT(0), lenSec(_lenSec), basePeriod(0.0),\n    blocksizeWriter(1), blocksizeReader(1),\n    isRb(_isRb), noHang(1), growDyn(0),\n    type(_type),\n    finalised(0), blocksizeIsSet(0), namesAreSet(0),\n    N(0), Nf(0), \n    fmeta(NULL),\n    name(NULL) \n  { \n    if (T!=0.0) nT = (long)ceil(lenSec/T); \n    if (_name != NULL) name = strdup(_name);  \n  }\n//lcfg(_name, 0.0, 0.0, _nT, _type, rb),\n\n  sDmLevelConfig() :\n    T(0.0), frameSizeSec(0.0), lastFrameSizeSec(0.0), nT(0), lenSec(0.0), basePeriod(0.0),\n    blocksizeWriter(1), blocksizeReader(1),\n    isRb(1), noHang(1), growDyn(0),\n    type(DMEM_FLOAT),\n    finalised(0), blocksizeIsSet(0), namesAreSet(0),\n    N(0), Nf(0), \n    fmeta(NULL),\n    name(NULL) {}\n\n  sDmLevelConfig(sDmLevelConfig const &orig) :\n    T(orig.T), frameSizeSec(orig.frameSizeSec), lastFrameSizeSec(orig.lastFrameSizeSec), nT(orig.nT), lenSec(orig.lenSec), basePeriod(orig.basePeriod),\n    blocksizeWriter(orig.blocksizeWriter), blocksizeReader(orig.blocksizeReader),\n    isRb(orig.isRb), noHang(orig.noHang), growDyn(orig.growDyn),\n    type(orig.type),\n    finalised(orig.finalised), blocksizeIsSet(orig.blocksizeIsSet), namesAreSet(orig.namesAreSet),\n    N(orig.N), Nf(orig.Nf), \n    fmeta(orig.fmeta),\n    name(NULL) { \n      if (orig.name != NULL) name = strdup(orig.name); \n    }\n\n\n  sDmLevelConfig(const char *_name, sDmLevelConfig &orig) :\n    T(orig.T), frameSizeSec(orig.frameSizeSec), lastFrameSizeSec(orig.lastFrameSizeSec), nT(orig.nT), lenSec(orig.lenSec), basePeriod(orig.basePeriod),\n    blocksizeWriter(orig.blocksizeWriter), blocksizeReader(orig.blocksizeReader),\n    isRb(orig.isRb), noHang(orig.noHang), growDyn(orig.growDyn),\n    type(orig.type),\n    finalised(orig.finalised), blocksizeIsSet(orig.blocksizeIsSet), namesAreSet(orig.namesAreSet),\n    N(orig.N), Nf(orig.Nf), \n    fmeta(orig.fmeta),\n    name(NULL) { \n      if (_name != NULL) name = strdup(_name); \n      else if (orig.name != NULL) name = strdup(orig.name); \n    }\n\n  void updateFrom(sDmLevelConfig const &orig) \n  {\n    T = orig.T;\n    frameSizeSec = orig.frameSizeSec;\n    lastFrameSizeSec = orig.lastFrameSizeSec;\n    nT = orig.nT;\n    lenSec = orig.lenSec;\n    basePeriod = orig.basePeriod;\n    blocksizeWriter = orig.blocksizeWriter;\n    blocksizeReader = orig.blocksizeReader;\n    isRb = orig.isRb;\n    noHang = orig.noHang;\n    growDyn = orig.growDyn;\n    type = orig.type;\n    finalised = orig.finalised;\n    blocksizeIsSet = orig.blocksizeIsSet;\n    namesAreSet = orig.namesAreSet;\n    N = orig.N; \n    Nf = orig.Nf; \n    fmeta = orig.fmeta;\n    if (name != NULL) {\n      free(name);\n      name = NULL;\n    }  \n    if (orig.name != NULL) name = strdup(orig.name);\n  }\n\n  void setName(const char *_name) \n  {\n    if (_name != NULL) {\n      if (name != NULL) free(name);\n      name = strdup(_name);\n    }\n  }\n\n  ~sDmLevelConfig() { if (name != NULL) free(name); }\n};\n\nclass DLLEXPORT cDataMemory;\n\nclass DLLEXPORT cDataMemoryLevel {\n  private:\n    //char *name;\n\n    int myId;\n    cDataMemory * _parent;\n\n// -------- variables for mutex access and locking:\n   smileMutex RWptrMtx;  // mutex to lock global curW / curR pointers\n   smileMutex RWmtx;     // mutex to lock data area during read / write\n   smileMutex RWstatMtx; // mutex to lock nCurRdr and writeReq variables for mut.ex. write/read op. while allowing mutliple parallel reads\n   int nCurRdr;\n   int writeReqFlag;\n// --------\n    \n    /* level configuration */\n    sDmLevelConfig lcfg;\n    FrameMetaInfo fmeta;\n    int fmetaNalloc;\n\n    /* THIS is now obsolete... it is stored in lcfg \n    FrameMetaInfo fmeta;\nint  noHang;\n    int  type;   // DMEM_INT or DMEM_FLOAT\n    long N;    // number of fields?? (elements??)\n    long nT;   // number of timesteps  (for ringbuffers T: actual size, else T=max size)\n    int isRb;      // ringbuffer flag..\n    int growDyn; // grow dynamically in time..?\n    int finalised, namesSet;\n    double T;  // period of frames, 0.0 for unperiodic\n    double frameSizeSec;  // frameSize (N) in seconds\n    */\n\n    /* level buffer */\n    cMatrix *data;\n    /* level buffer status */\n    long curW,curR;  //current write pos, current read pos    (min (read) over all readers / max (write))\n    long *curRr;  //current current read pos for each registered reader\n    int nReaders;    // number of registered readers (all registered readers will be \"waited\" for! if you don't want that, don't register your reader)\n\n    /* timing information for every frame in the buffer */ /* ISN'T THIS IN *data ?? */\n    TimeMetaInfo  *tmeta;\n\n\n    int EOI;\n    int EOIcondition;\n    \n\n\n    /*\n    // ???: is this still used??? TODO!\n    long rbClip(long vIdx) {  // convert indicies if ringbuffer , otherwise perform range check, return -1 if out of range\n      if (isRb) return vIdx%nT;\n      else {\n           if (vIdx < 0) return -1;\n           if (vIdx >= nT) return -1;\n           return vIdx;\n      }\n    }\n*/\n\n    /* check current read indicies of all registered readers fro this level and update global (minimal) read index curRm\n       also update single reader's read index if the have fallen behind the global read index for whatever reason. */\n    void checkCurRr() {\n      if (nReaders>0) {\n        long newCurR=curRr[0];\n        int i;\n        for (i=1; i<nReaders; i++) {\n          if (curRr[i] < curR) {\n            SMILE_DBG(3,\"(level='%s') auto increasing reader %i 's read index to %i\",getName(),i,curR);\n            curRr[i] = curR;\n          }\n          if (curRr[i] < newCurR) newCurR=curRr[i];\n        }\n        curR = newCurR;\n      }\n    }\n    \n    // validate write index, and if applicable increase curW write counter\n    long validateIdxW(long *vIdx, int special=-1)\n    {\n      // TODO: growdyn for ringbuffers\n      SMILE_DBG(5,\"validateIdxW ('%s')\\n         vidx=%i special=%i curW=%i curR=%i nT=%i\",getName(),*vIdx,special,curW,curR,lcfg.nT);\n\n      if (special == DMEM_IDX_CURW) *vIdx = curW;\n      else if (special != -1) return -1;\n      if (*vIdx < 0) return -1;\n      int nh=0;\n      if (lcfg.noHang==1) { if (nReaders == 0) nh = 1; }\n      else if (lcfg.noHang==2) nh = 1;\n\n      if ( (lcfg.isRb)&&(*vIdx <= curW)&&(nh||((lcfg.nT - (curW-curR)) > 0)) )\n      { \n\n        if (*vIdx==curW) curW++; \n        if ((lcfg.noHang==2)&&((lcfg.nT - (curW-curR)) <= 0)) {\n          SMILE_DBG(3,\"data lost while writing value to ringbuffer level '%s'\",getName());\n          curR = curW-lcfg.nT+1;\n        }\n        return *vIdx%lcfg.nT; \n      \n      } else {\n\n        if ((!lcfg.isRb)&&(*vIdx <= curW)) {\n          if (*vIdx >= lcfg.nT) { \n            // if growDyn is set, realloc level size....\n            if (lcfg.growDyn) {\n              SMILE_DBG(3,\"increasing buffer size of level '%s' from nT=%i to nT=%i\",getName(),lcfg.nT,lcfg.nT*2);\n\n              if (data->resize(lcfg.nT*2)) {\n                // new code for \"crealloc\" of tmeta to properly deal with c++ class array...\n                TimeMetaInfo * tmeta_new = new TimeMetaInfo[lcfg.nT*2]();\n                long ii;\n                for (ii=0; ii<lcfg.nT; ii++) { tmeta_new[ii].cloneFrom(tmeta+ii); }\n                delete [] tmeta;\n                tmeta = tmeta_new;\n                // OLD: tmeta = (TimeMetaInfo *)crealloc(tmeta,sizeof(TimeMetaInfo) * lcfg.nT*2, sizeof(TimeMetaInfo) * lcfg.nT);\n                lcfg.nT *= 2;\n                lcfg.lenSec *= 2.0;\n                if (*vIdx==curW) curW++; return *vIdx;\n              }\n            } else {\n              // else\n              SMILE_DBG(3,\"data lost while writing value to level '%s'\",getName());\n            }\n          } else\n          { if (*vIdx==curW) curW++; return *vIdx; }\n        }\n        return -1;\n\n      }\n    }\n\n    // validate write index range, and if applicable set curW write counter to end of range+1\n    long validateIdxRangeW(long *vIdx, long vIdxEnd, int special=-1)\n    {\n      // TODO: growdyn for ringbuffers\n      SMILE_DBG(5,\"validateIdxRangeW ('%s')\\n         vidx=%i vidxend=%i special=%i curW=%i curR=%i nT=%i\",getName(),*vIdx,vIdxEnd,special,curW,curR,lcfg.nT);\n\n      if (vIdxEnd < *vIdx) { SMILE_ERR(3,\"validateIdxRangeW: vIdxEnd (%i) cannot be smaller than vIdx (%i)!\",vIdxEnd,*vIdx); return -1; }\n      if (special == DMEM_IDX_CURW) { vIdxEnd -= *vIdx; *vIdx = curW; vIdxEnd += curW; }\n      else if (special != -1) return -1;\n      if (*vIdx < 0) return -1;\n      SMILE_DBG(5,\"validateIdxRangeW(2) vidx=%i vidxend=%i special=%i curW=%i curR=%i nT=%i\",*vIdx,vIdxEnd,special,curW,curR,lcfg.nT);\n\n      int nh=0;\n      if (lcfg.noHang==1) { if (nReaders == 0) nh = 1; }\n      else if (lcfg.noHang==2) nh = 1;\n\n      if ( (lcfg.isRb)&&(*vIdx <= curW)&&(nh||(vIdxEnd-*vIdx <= (lcfg.nT - (curW-curR)))) ) {\n\n        if (vIdxEnd>=curW) curW = vIdxEnd;\n        if ((lcfg.noHang==2)&&(vIdxEnd-*vIdx >= (lcfg.nT - (curW-curR)))) {\n          SMILE_DBG(3,\"data lost while writing matrix to ringbuffer level '%s' (vIdxEnd %i, *vIdx %i, lcfg.nT %i, curW %i, curR %i)\",getName(),vIdxEnd,*vIdx,lcfg.nT,curW,curR);\n        }\n        return *vIdx%lcfg.nT;\n\n      } else {\n\n        if ((!lcfg.isRb)&&(*vIdx <= curW)) {\n          if ((*vIdx >= lcfg.nT)||(vIdxEnd >= lcfg.nT)) {\n            // if growDyn is set, realloc level size....\n            if (lcfg.growDyn) {\n              long newS = lcfg.nT*2;\n              if (newS < vIdxEnd) newS = vIdxEnd+10;\n              if (newS < *vIdx) newS = *vIdx+10;\n\n              SMILE_DBG(3,\"increasing buffer size of level '%s' from nT=%i to nT=%i\",getName(),lcfg.nT,newS);\n              if (data->resize(newS)) {\n                // new code for \"crealloc\" of tmeta to properly deal with c++ class array...\n                TimeMetaInfo * tmeta_new = new TimeMetaInfo[newS]();\n                for (long ii = 0; ii < lcfg.nT; ii++) {\n                  tmeta_new[ii].cloneFrom(tmeta + ii);\n                }\n                delete[] tmeta;\n                tmeta = tmeta_new;\n                // OLD: // tmeta = (TimeMetaInfo *)crealloc(tmeta,sizeof(TimeMetaInfo) * newS, sizeof(TimeMetaInfo) * lcfg.nT);\n                lcfg.nT = newS;\n                lcfg.lenSec *= (double)newS/(double)lcfg.nT;\n                if (vIdxEnd>=curW) curW = vIdxEnd;\n                return *vIdx;\n              }\n            } else {\n              // else\n              SMILE_ERR(3, \"Data lost while writing matrix of size %ld to level '%s'\", vIdxEnd - *vIdx, getName());\n            }\n          } \n          else\n          { if (vIdxEnd>=curW) curW = vIdxEnd; return *vIdx; }\n        }\n        return -1;\n      }\n    }\n\n    // validate read index, \n    // return value: -1 invalid param, -2 vidx OOR_left, -3 vidx OOR_right, -4 vidx OOR_buffersize(noRb)\n    long validateIdxR(long *vIdx, int special=-1, int rdId=-1, int noUpd=0)\n    {\n\n      long *_curR;\n      if ((rdId >= 0)&&(rdId<nReaders)) _curR = curRr+rdId;\n      else _curR=&curR;\n      SMILE_DBG(5,\"validateIdxR ('%s')\\n         vidx=%i special=%i curW=%i curR=%i nT=%i\",getName(),*vIdx,special,curW,*_curR,lcfg.nT);\n\n      if ((lcfg.isRb) && (*_curR < curW-lcfg.nT)) { *_curR = curW-lcfg.nT; SMILE_DBG(3,\"validateIdxR: rb data possibly lost, curR < curW-nT, curR was automatically increased!\"); }\n      if (special == DMEM_IDX_CURR) *vIdx = *_curR;\n      else if (special != -1) return -1;\n      if (*vIdx < 0) return -2;\n      // TODO:: set curR to min curRr\n      if (lcfg.isRb) {\n        if ((*vIdx < curW)&&(*vIdx >= curW-lcfg.nT)) { \n          if (!noUpd) { \n            if ((*vIdx>=*_curR)&&(!noUpd)) *_curR = *vIdx+1; \n            if (rdId >= 0) checkCurRr(); \n          } \n          return *vIdx%lcfg.nT; \n        } else if (*vIdx >= curW) { return -3; } // OOR_right\n        else if (*vIdx < curW-lcfg.nT) { return -2; } // OOR_left\n      }\n      else { // no ringbuffer\n        if ((*vIdx < curW)&&(*vIdx < lcfg.nT)) { \n          if (!noUpd) { \n            if (*vIdx>=*_curR) *_curR = *vIdx+1; \n            if (rdId >= 0) checkCurRr(); \n          } \n          return *vIdx; \n        } else if (*vIdx >= curW) { return -3; } // OOR_right\n        else if (*vIdx >= lcfg.nT) { return -4; } // OOR_buffersize\n      }\n      return -1;\n    }\n\n    //validate read index range, vIdxEnd   is the index after the last index to read... (i.e. vIdx + len)\n    // TODO: error codes\n    long validateIdxRangeR(long actualVidx, long *vIdx, long vIdxEnd, int special=-1, int rdId=-1, int noUpd=0, int *padEnd=NULL)\n    {\n      SMILE_DBG(5,\"validateIdxRangeR ('%s')\\n         vidx=%i vidxend=%i special=%i curW=%i curR=%i nT=%i\",getName(),*vIdx,vIdxEnd,special,curW,curR,lcfg.nT);\n      long *_curR;\n      if ((rdId >= 0)&&(rdId<nReaders)) _curR = curRr+rdId;\n      else _curR=&curR;\n      SMILE_DBG(5,\"validateIdxRangeR(2) '%s' vidx=%i vidxend=%i special=%i curW=%i _curR=%i nT=%i\",this->lcfg.name,*vIdx,vIdxEnd,special,curW,*_curR,lcfg.nT);\n\n      if ((lcfg.isRb) && (*_curR < curW-lcfg.nT)) {\n        *_curR = curW-lcfg.nT;\n        SMILE_WRN(4, \"level: '%s': validateIdxRangeR: rb data possibly lost, curR < curW-nT, curR was automatically increased!\", lcfg.name);\n      }\n      if (vIdxEnd < *vIdx) { SMILE_ERR(2,\"validateIdxRangeR: vIdxEnd (%i) cannot be smaller than vIdx (%i)!\",vIdxEnd,*vIdx); return -1; }\n      if (special == DMEM_IDX_CURR) { vIdxEnd -= *vIdx; actualVidx = *vIdx = *_curR; vIdxEnd += *_curR; }\n      else if ((special != -1)&&(special!=DMEM_PAD_ZERO)&&(special!=DMEM_PAD_FIRST)&&(special!=DMEM_PAD_NONE)) return -1;\n      if (*vIdx < 0) return -1;\n\n      if ((vIdxEnd > curW)&&(isEOI())) { // pad\n        if (padEnd != NULL) {\n          *padEnd = vIdxEnd - curW;\n          if (*padEnd >= vIdxEnd-*vIdx) { *padEnd = vIdxEnd-*vIdx;  return -1; }\n        }\n      \t// TODO: pad option for \"truncate\" at the end of input!\n        vIdxEnd = curW;\n      }\n      if ((lcfg.isRb)&&(*vIdx < curW)&&(vIdxEnd <= curW)&&(*vIdx >= curW-lcfg.nT))\n      { \n        if (!noUpd) { \n          //if (vIdxEnd>=*_curR) *_curR = *vIdx+1; if (rdId >= 0) checkCurRr(); \n          if (vIdxEnd>=*_curR) *_curR = actualVidx+1; if (rdId >= 0) checkCurRr(); \n        } \n        return *vIdx%lcfg.nT; \n      } else                                              // +1 ????? XXX\n        if ((!lcfg.isRb)&&(*vIdx < curW)&&(*vIdx < lcfg.nT)&&(vIdxEnd <= curW)&&(vIdxEnd <= lcfg.nT))\n        { \n          if (!noUpd) { \n            if (vIdxEnd>=*_curR) *_curR = actualVidx+1; if (rdId >= 0) checkCurRr(); \n            //if (vIdxEnd>=*_curR) *_curR = *vIdx+1; if (rdId >= 0) checkCurRr(); \n          } \n          return *vIdx; \n        }\n      if (padEnd != NULL) *padEnd = 0;\n      return -1;\n    }\n\n    // write frame data from *_data to level's data matrix at pos rIdx\n    void frameWr(long rIdx, FLOAT_DMEM *_data);\n    void frameWr(long rIdx, INT_DMEM *_data);\n\n    // write frame data from level's data matrix at pos rIdx to *_data\n    void frameRd(long rIdx, FLOAT_DMEM *_data);\n    void frameRd(long rIdx, INT_DMEM *_data);\n\n    void setTimeMeta(long rIdx, long vIdx, const TimeMetaInfo *tm);\n    void getTimeMeta(long rIdx, TimeMetaInfo *tm);\n\n  public:\n\n    // create level from given level configuration struct, the name in &cfg will be overwritten via _name parameter\n    cDataMemoryLevel(int _levelId, sDmLevelConfig &cfg, const char *_name = NULL) :\n      myId(_levelId), _parent(NULL),\n      lcfg(_name, cfg), fmetaNalloc(0),\n      data(NULL), tmeta(NULL), EOI(0), EOIcondition(0),\n      curW(0), curR(0), curRr(NULL), nReaders(0), \n      nCurRdr(0), writeReqFlag(0)\n    {\n      //if ((nT == 0)&&(cfg.lenSec > 0.0)&&(cfg.T>0.0)) { nT = (long)ceil( cfg.lenSec / cfg.T ); }\n      if (lcfg.T < 0.0) COMP_ERR(\"cannot create dataMemoryLevel with period (%f) < 0.0\",lcfg.T);\n      if (lcfg.nT <= 0) COMP_ERR(\"cannot create empty dataMemoryLevel nT = %i <= 0\",lcfg.nT);\n      lcfg.fmeta = &fmeta;\n    }\n\n    // create level from minimal set of parameters  // ??? is this still used ?? shouldn't there be a _T at least!!?? //\n    cDataMemoryLevel(int _levelId, const char *_name, long _nT, int rb=1, int dyn=0, int _type=DMEM_FLOAT) :\n      myId(_levelId), _parent(NULL),\n      lcfg(_name, 0.0, 0.0, _nT, _type, rb),\n        //sDmLevelConfig(const char *_name, double _T, double _frameSizeSec, long _nT=10, int _type=DMEM_FLOAT, int _isRb=1) :\n      fmetaNalloc(0),\n      data(NULL),  tmeta(NULL), EOI(0), EOIcondition(0),\n      curW(0), curR(0), curRr(NULL), nReaders(0),\n      //,RWptrMtx(NULL), RWstatMtx(NULL), RWmtx(NULL),\n      nCurRdr(0), writeReqFlag(0)\n    {\n      if (lcfg.nT <= 0) COMP_ERR(\"temporal size of dataMemoryLevel cannot be <= 0  (= %i)!\",lcfg.nT);\n      if (lcfg.nT < 2) lcfg.nT = 2;\n      lcfg.fmeta = &fmeta;\n    }\n\n    // get level name\n    const char *getName() const { return lcfg.name; }\n\n    // set level ID\n    void setMyId(int _id) { myId = _id; }\n    void setEOI() { EOIcondition = 1; }\n    void setEOIcounter(int cnt) { EOI = cnt; };\n    int getEOIcounter() { return EOI; }\n    void unsetEOI() { EOIcondition = 0; }\n    int isEOI() const { return EOIcondition; }\n\n    // query, if names are set, i.e. if level was fixated\n    int namesAreSet() const { return lcfg.namesAreSet; }\n    // after the names were set by the writer, this must be indicated to the level via a call to fixateLevel()\n    void fixateLevel() { \n      lcfg.namesAreSet = 1; \n//      lcfg.fmeta = &fmeta;\n    }\n\n    // set parent dataMemory object\n    void setParent(cDataMemory * __parent) { _parent = __parent; }\n\n    // adds a field to this level, _N is the number of elements in an array field, set to 0 or 1 for scalar field\n    // arrNameOffset: start index for creating array element names\n    int addField(const char *lname, int lN, int arrNameOffset=0);\n    \n    // set info for field i (dataType and custom data pointer)\n    int setFieldInfo(int i, int _dataType, void *_info, long _infoSize);\n    \n    // set info for field 'name' (dataType and custom data pointer). Do NOT include array indicies in field name!\n    int setFieldInfo(const char *__name, int _dataType, void *_info, long _infoSize) {\n      return setFieldInfo(fmeta.findField(__name), _dataType, _info, _infoSize);\n    }\n\n    // register a new data reader... IS THAT ALL ??? yes: we only need to know how many there are, the rest is done in allocReaders()\n    int registerReader() { return nReaders++; }\n\n    // allocate config for the readers and initialize it with standard values\n    void allocReaders();\n\n    // configure level (check buffersize and config)\n    int configureLevel();   \n    // finalize config and allocate data memory\n    int finaliseLevel();   \n\n\n    // find a field by it's full name in a finalised level:\n    // *arrIdx (if not NULL) will be set to the array index of the requested element, if it is in an array field\n    int findField(const char*_fieldName, int *arrIdx) const { return fmeta.findField( _fieldName, arrIdx ); }\n\n    // sets the arrNameOffset (see addField) of the field that was added last\n    void setArrNameOffset(int arrNameOffset);\n   \n    // get a pointer to the custom level meta data (in fmeta), a cVetorMeta class (same class as for each frame in tmeta, but different data!)\n    cVectorMeta * getLevelMetaDataPtr() { return &(fmeta.metaData); }\n\n\n    /* set a frame or matrix beginnig at vIdx, or special index (overrides value of vIdx, see below) */\n    // per level always a complete frame must be set...\n    // int special = special index, e.g. DMEM_IDX_CURR, DMEM_IDX_CURW\n    int setFrame(long vIdx, const cVector *vec, int special=-1);  \n    int setMatrix(long vIdx, const cMatrix *mat, int special=-1); \n\n\n    /* get a frame or matrix beginning at vIdx, or special index (overrides value of vIdx, see below) */\n    // int special = special index, e.g. DMEM_IDX_CURR, DMEM_IDX_CURW\n    // *result (if not NULL) will contain a result code indicating success or reason of failure (left or right buffer margin exceeded, etc.)\n    // rdId is the id of the current reader (or -1 for an unregistered or global reader)\n    cVector * getFrame(long vIdx, int special=-1, int rdId=-1, int *result=NULL);  \n    cMatrix * getMatrix(long vIdx, long vIdxEnd, int special=-1, int rdId=-1, int *result=NULL);  \n\n    /* check if a read of length \"len\" at vIdx or \"special\" will succeed for reader rdId */\n    // *result (if not NULL) will contain a result code indicating success or reason of failure (left or right buffer margin exceeded, etc.)\n    // possible result values: (Doc TODO) -1 invalid param, -2 vidx OOR_left, -3 vidx OOR_right, -4 vidx OOR_buffersize(noRb)\n    int checkRead(long vIdx, int special=-1, int rdId=-1, long len=1, int *result=NULL) \n    {\n      long rIdx;\n      long vIdxEnd = vIdx + len;\n      long vIdxold = vIdx;\n      if ((vIdx < 0)&&(vIdxEnd > 0)) vIdx = 0;\n      if (len < 0) return 0;\n\n      smileMutexLock(RWptrMtx);\n      if (len<=1) rIdx = validateIdxR(&vIdx,special,rdId,1);\n      else rIdx = validateIdxRangeR(vIdxold,&vIdx,vIdxEnd,special,rdId,1);\n\n      smileMutexUnlock(RWptrMtx);\n      if (result!=NULL) {\n        if (rIdx == -2) *result=DMRES_OORleft|DMRES_ERR;\n        else if (rIdx == -3) *result=DMRES_OORright|DMRES_ERR;\n        else if (rIdx == -4) *result=DMRES_OORbs|DMRES_ERR;\n        else if (rIdx >= 0) *result=DMRES_OK;\n        else *result=DMRES_ERR;\n      }\n      //XXX TODO: it might be possible that checkRead returns ok, then another reader reads data, \n      //          a writer writes new data, and the read will fail which was confirmed by checkRead.... \n      //          ?? what do we do about it ??\n      //        maybe use level lock() functions, that the caller may (or may not) use...\n\n      if (rIdx >= 0) return 1;  // a read will likely succeed (see above TODO notice)\n      else return 0;  // an error occurred, read is not possible\n    }\n\n\n    /* set read index of reader rdId (or global read index, if rdId=-1) \n       to user defined _curR or to write index curW+1, if _curR=-1 or omitted.\n       if _curR=-1 or omitted, thus, the level buffer will be cleared (not physically but logically)\n       use this, if your reader only requires data \"part time\" (e.g. reading only voiced segments of speech, etc.)\n      */\n    void catchupCurR(int rdId=-1, int _curR = -1);\n\n    /* methods to get info about current level fill status */\n    // (e.g. number of frames written, curW, curR(global) and freeSpace, etc.)\n\n    /* get current write index (index that will be written to NEXT) */\n    long getCurW() \n    {\n      smileMutexLock(RWptrMtx);\n      long res = curW;\n      smileMutexUnlock(RWptrMtx);\n      return res;\n    }  \n\n    /* current read index (index that will be read NEXT) of reader rdId or global (min of all readers) if rdId is omitted */\n    long getCurR(int rdId=-1) \n    {\n      long res;\n      smileMutexLock(RWptrMtx);\n      if ((rdId < 0)||(rdId >= nReaders)) { \n        res = curR;\n      } else {\n        res = curRr[rdId];\n      }\n      smileMutexUnlock(RWptrMtx);\n      return res;\n    }  \n\n    /* get number of free frames in current level (for ringbuffers: nT-(curW-curR)) */\n    // NOTE: this is not the actual number of free frames, but the number of frames that currently can be written to,\n    //       i.e. the result depends on the value of the lcfg.noHang setting\n    long getNFree(int rdId=-1) \n    { \n\t    if ((lcfg.noHang == 1) && (nReaders<=0))\n\t      return lcfg.nT;\n\t    if ((lcfg.noHang == 2))\n\t      return lcfg.nT;\n\t    if ((lcfg.growDyn == 1))\n\t      return 1000000;  // default value, because level will grow\n\n      long ret=0;\n      smileMutexLock(RWptrMtx);\n      if (lcfg.isRb) {\n        if ((rdId>=0)&&(rdId<nReaders)) {\n          SMILE_DBG(5,\"getNFree(rdId=%i) level='%s' curW=%i curRr=%i nT=%i free=%i\",rdId,getName(),curW,curRr[rdId],lcfg.nT,lcfg.nT - (curW-curRr[rdId]));\n          ret = lcfg.nT - (curW-curRr[rdId]);\n        } else {\n          SMILE_DBG(5,\"getNFree:: level='%s' curW=%i curR=%i nT=%i free=%i\",getName(),curW,curR,lcfg.nT,lcfg.nT - (curW-curR));\n          ret = lcfg.nT - (curW-curR);\n        }\n      } else {\n        ret = (lcfg.nT - curW);\n      }\n      smileMutexUnlock(RWptrMtx);\n      return ret;\n    }\n    \n    /* get number of available frames for reader rdId */\n    long getNAvail(int rdId=-1)\n    { \n      long ret=0;\n      smileMutexLock(RWptrMtx);\n      if (lcfg.isRb) {\n        if ((rdId>=0)&&(rdId<nReaders)) {\n          SMILE_DBG(5,\"getNAvail(rdId=%i) level='%s' curW=%i curRr=%i nT=%i avail=%i\",rdId,getName(),curW,curRr[rdId],lcfg.nT,(curW-curRr[rdId]));\n          ret = curW - curRr[rdId];\n        } else {\n          SMILE_DBG(5,\"getNAvail:: level='%s' curW=%i curR=%i nT=%i avail=%i\",getName(),curW,curR,lcfg.nT,(curW-curR));\n          ret = curW - curR;\n        }\n      } else {\n        ret = curW;\n      }\n      smileMutexUnlock(RWptrMtx);\n      return ret;\n    }\n\n    /* maximum readable index (\"last\" index where data was written to) */\n    long getMaxR();\n\n    /* minimum readable index \n       (relevant only for ringbuffers, for regular buffers this function will always return 0) */\n    long getMinR();  \n\n\n    /**** get level configuration *****/\n    const sDmLevelConfig * getConfig() { return &lcfg; }\n\n    /* get number of registered readers ( if the level is not finalised, it is the number of readers *currently* registered ! ) */\n    long getNreaders() { return nReaders; }\n\n    /* check if level is ready for reading, get level config (WITHOUT NAMES!) and update blocksizeReader */\n    const sDmLevelConfig * queryReadConfig( long _blocksizeReader )\n    {\n      if (!lcfg.blocksizeIsSet) {\n        if (lcfg.blocksizeReader < _blocksizeReader) lcfg.blocksizeReader = _blocksizeReader;\n        return &lcfg; \n      } else {\n        SMILE_ERR(1,\"attempt to update blocksizeReader, however blocksize config for level '%s' is already fixed!\",lcfg.name);\n        return NULL;\n      }\n    }\n\n    /* check if level is ready for reading, get level config (WITHOUT NAMES!) and update blocksizeReader */\n    const sDmLevelConfig * queryReadConfig( double _blocksizeReaderSeconds )\n    {\n      if (lcfg.T != 0.0) return queryReadConfig( (long)ceil(_blocksizeReaderSeconds/lcfg.T) );\n      else return queryReadConfig( (long)ceil(_blocksizeReaderSeconds) );\n    }\n\n//OBSOLETE:    long getLevelSize() { return lcfg.nT; } // get size of level in frames\n\n    // TODO: should these methods be passed to fmeta... or should on use getConfig() and call the proper fmeta methods??\n    /* get name of field with index \"n\" (n = 0..lcfg.Nf-1  OR equivalent: n = 0..lcfg.fmeta.N-1), \n         *_N will be filled with number of elements in this field. \n         for *_arrNameOffset see documentation of addField */\n    const char * getFieldName(int n, int *lN=NULL, int *larrNameOffset=NULL);\n\n    /* get name of element \"n\"  (n= 0..lcfg.N) */\n     // IMPORTANT! the caller must free() the returned string!!\n    char * getElementName(int n); \n    \n    /**** set config functions ***/\n    /* set frame size in seconds */\n    void setFrameSizeSec(double fss) { if (fss > 0.0) lcfg.frameSizeSec = fss; }\n    void setBlocksizeWriter(long _bsw, int _force=0) { \n      if (_force) { lcfg.blocksizeWriter = _bsw; }\n      else if (_bsw > lcfg.blocksizeWriter) { lcfg.blocksizeWriter = _bsw; }\n    }\n\n    /**** vIdx to real time conversion functions (preferred method) */\n    /* seconds to vIdx (for THIS level!) */\n    long secToVidx(double sec); // returns a vIdx, TODO: (for periodic levels this function is easy, however for aperiodic levels we must iterate through all frames... maybe also for periodic to compensate round-off errors?)\n    /* vIdx (for THIS level!) to real time in seconds */\n    double vIdxToSec(long vIdx); \n\n    /** print number of readers, and size of level in frames and seconds, etc.. **/\n    // available levels of detail : 0, 1, 2\n    void printLevelStats(int detail=1);\n    \n\n    /*** level locking functions : manually lock/unlock level for exclusive access (for multi-threaded environments) ***/\n    // PLEASE USE THESE RESPONSIBLE, YOU MAY BREAK YOUR APPLICATION IF YOU FORGET TO UNLOCK A LEVEL!!!\n    /* TODO */\n    void lock() {} // use a fourth mutex, LVLmtx or so? hm... better to use RWstatMtx..?\n    void unlock() {} // use a fourth mutex, LVLmtx or so\n\n\n    /**** destructor.. clean up everything ******/\n    ~cDataMemoryLevel() {\n      // TODO: these might have not been initialized.... !!!???\n      smileMutexDestroy(RWptrMtx);\n      smileMutexDestroy(RWstatMtx);\n      smileMutexDestroy(RWmtx);\n      //--------\n      if (tmeta != NULL) delete[] tmeta; // was: free(tmeta) !\n      if (data != NULL) delete data;\n      if (curRr != NULL) free(curRr);\n    }\n\n};\n\n#ifdef UNDEFMOD\n#undef MODULE\n#undef UNDEFMOD\n#endif\n\n\n/************** dataMemory class ***********************/\n\nclass DLLEXPORT cSmileList {\nprivate:\n  long nEl, nElAlloc, blockAlloc;\n  long elSize;\n  void *el;\npublic:\n  // get pointer to element n, for reading and writing, if n>nElAlloc a new element will be allocated \n  void * getElementPtr(long n=-1) {\n    if (n==-1) n=nEl;\n    if (n<0) return NULL;\n    if (n >= nElAlloc) {\n      void *tmp = (void *)crealloc(el, elSize * (n+blockAlloc), elSize*nElAlloc);\n      if (tmp==NULL) OUT_OF_MEMORY;\n      el = tmp;\n      nElAlloc = (n+blockAlloc);\n    }\n    if (n>=nEl) nEl = n+1;\n    return (void*)( ((char*)el)+(n*elSize) );\n  }\n\n  // get number of elements in list\n  long getNEl() { return nEl; }\n\n  cSmileList(long _elSize=1, long _blockAlloc=50) : nEl(0), nElAlloc(0), blockAlloc(_blockAlloc), elSize(_elSize), el(NULL)\n    { if (elSize < 1) { elSize=1; } }\n  ~cSmileList() { if (el!=NULL) free(el); }\n};\n\nclass DLLEXPORT cCharStrList : public cSmileList { \npublic:\n  cCharStrList(long _blockAlloc=50) :\n      cSmileList(sizeof(const char *), _blockAlloc)\n  {\n  }\n \n  const char * getElement(long n=-1) {\n    return (const char *)getElementPtr(n);\n  }\n};\n\n// data for read or write request\nclass DLLEXPORT sDmLevelRWRequest{ public:\n  const char * instanceName;\n  const char * levelName;\n};\n\nclass DLLEXPORT cDmLevelRWRequestList : public cSmileList { \npublic:\n  cDmLevelRWRequestList(long _blockAlloc=50) :\n      cSmileList(sizeof(sDmLevelRWRequest), _blockAlloc)\n  {\n  }\n \n  sDmLevelRWRequest * getElement(long n=-1) {\n    return (sDmLevelRWRequest *)getElementPtr(n);\n  }\n\n  int findRequest(const char *lvl, const char *instName) {\n    int i;\n    for (i=0; i<getNEl(); i++) {\n      sDmLevelRWRequest *x = getElement(i);\n      if (x!=NULL) {\n        if ( (!strcmp(lvl,x->levelName)) && ((instName==NULL)||(!strcmp(instName,x->instanceName))) ) return i+1;\n      }\n    }\n    return 0;\n  }\n};\n\n\n#define COMPONENT_DESCRIPTION_CDATAMEMORY \"central data memory component\"\n#define COMPONENT_NAME_CDATAMEMORY \"cDataMemory\"\n\nclass DLLEXPORT cDataMemory : public cSmileComponent {\n  private:\n    cDataMemoryLevel **level;\n    int nLevelsAlloc /*N*/, nLevels /*I*/;   // N: total number allocated, I actual number of levels initialized - 1\n\n    cDmLevelRWRequestList rrq;  // read requests\n    cDmLevelRWRequestList wrq;  // write requests\n\n    // used internally...\n    void _addLevel();\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    void fetchConfig() {}\n    virtual int myRegisterInstance(int *runMe=NULL);\n    virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t) { return 0; }\n    \n  public:\n    SMILECOMPONENT_STATIC_DECL\n\n    cDataMemory() : cSmileComponent(\"dataMemory\"), level(NULL), \n      nLevelsAlloc(0), nLevels(-1) {}\n\n    cDataMemory(const char *_name) : cSmileComponent(_name), level(NULL),\n      nLevelsAlloc(0), nLevels(-1) {}\n\n    /* register a read request (during \"register\" phase) */\n    void registerReadRequest(const char *lvl, const char *componentInstName=NULL);\n    void registerWriteRequest(const char *lvl, const char *componentInstName=NULL);\n\n    /* register a new level, and check for uniqueness of name */\n    int registerLevel(cDataMemoryLevel *l);\n\n    /* add a new level with given _lcfg parameters */\n    int addLevel(sDmLevelConfig *_lcfg, const char *_name=NULL);\n\n    /* set end-of-input flag */\n    virtual void setEOI() {\n      int i;\n      // set end-of-input for all levels:\n      for (i=0; i<=nLevels; i++) level[i]->setEOI();\n      // set end-of-input in this component:\n      cSmileComponent::setEOI();\n    }\n\n    virtual void unsetEOI() {\n      int i;\n      // set end-of-input for all levels:\n      for (i=0; i<=nLevels; i++) level[i]->unsetEOI();\n      // set end-of-input in this component:\n      cSmileComponent::unsetEOI();\n    }\n\n    virtual int setEOIcounter(int cnt) {\n      int i;\n      // set end-of-input for all levels:\n      for (i=0; i<=nLevels; i++) level[i]->setEOIcounter(cnt);\n      // set end-of-input in this component:\n      return cSmileComponent::setEOIcounter(cnt);\n    }\n\n    // get index of level 'name'\n    int findLevel(const char *name);\n\n    /**** functions which will be forwarded to the corresponding level *****/\n\n    /* check if level is ready for reading, get level config (WITHOUT NAMES!) and update blocksizeReader */\n    const sDmLevelConfig * queryReadConfig( int _level, long _blocksizeReader=1 )\n      { if ((_level>=0)&&(_level<=nLevels)) return level[_level]->queryReadConfig(_blocksizeReader); else return NULL; }\n    const sDmLevelConfig * queryReadConfig( int _level, double _blocksizeReaderSeconds=1 )\n      { if ((_level>=0)&&(_level<=nLevels)) return level[_level]->queryReadConfig(_blocksizeReaderSeconds); else return NULL; }\n\n    // adds a field to level <level>, _N is the size of an array field, set to 0 or 1 for scalar field\n    // the name must be unique per level...\n    int addField(int llevel, const char *lname, int lN, int arrNameOffset=0)\n    {  \n       if ((llevel>=0)&&(llevel<=nLevels)) \n         return level[llevel]->addField(lname, lN, arrNameOffset);\n       else \n         return 0; \n    }\n\n    // set info for field i (dataType and custom data pointer)\n    int setFieldInfo(int _level, int i, int _dataType, void *_info, long _infoSize) {\n      if ((_level>=0)&&(_level<=nLevels)) return level[_level]->setFieldInfo(i,_dataType,_info,_infoSize); else return 0;\n    }\n    \n    // set info for field 'name' (dataType and custom data pointer). Do NOT include array indicies in field name!\n    int setFieldInfo(int _level, const char *_name, int _dataType, void *_info, long _infoSize) {\n      if ((_level>=0)&&(_level<=nLevels)) return level[_level]->setFieldInfo(_name,_dataType,_info,_infoSize); else return 0;\n    }\n\n    // registers a reader for level _level, returns the reader id assigned to the new reader\n    int registerReader(int _level)\n      { if ((_level>=0)&&(_level<=nLevels)) return level[_level]->registerReader(); else return -1; }\n\n  // OBOSOLETE : ???\n    // get index of level 'name' and finalise this level\n    int finaliseLevel(const char *name);\n    // finalise level n, return 1 on success, 0 on failure\n    int finaliseLevel(int n);\n\n    int setFrame(int _level, long vIdx, const cVector *vec, int special=-1/*, int *result=NULL*/)\n      { if ((_level>=0)&&(_level<=nLevels)) return level[_level]->setFrame(vIdx,vec,special/*, result*/); else return 0; }\n    int setMatrix(int _level, long vIdx, const cMatrix *mat, int special=-1/*, int *result=NULL*/)\n      { if ((_level>=0)&&(_level<=nLevels)) return level[_level]->setMatrix(vIdx,mat,special/*, result*/); else return 0; }\n\n    /* check if a read will succeed */\n    int checkRead(int _level, long vIdx, int special=-1, int rdId=-1, long len=1, int *result=NULL)\n      { if ((_level>=0)&&(_level<=nLevels)) return level[_level]->checkRead(vIdx,special,rdId,len,result); else return -1; }\n\n    // the memory pointed to by the return value must be freed via delete() by the calling code!!\n    // TODO: optimise this... don't allocate a new frame everytime something is returned!! maybe provide an option\n         // for passing a buffer frame or so...\n    cVector * getFrame(int _level, long vIdx, int special=-1, int rdId=-1, int *result=NULL)\n      { if ((_level>=0)&&(_level<=nLevels)) return level[_level]->getFrame(vIdx,special,rdId,result); else return NULL; }\n    cMatrix * getMatrix(int _level, long vIdx, long vIdxEnd, int special=-1, int rdId=-1, int *result=NULL)\n      { if ((_level>=0)&&(_level<=nLevels)) return level[_level]->getMatrix(vIdx,vIdxEnd,special,rdId,result); else return NULL; }\n\n    // set current read index to current write index to prevent hangs, if the readers do not read data sequentially, or if the readers skip data\n    void catchupCurR(int _level, int rdId=-1, long _curR=-1 /* if >= 0, value that curR[rdId] will be set to! */ ) \n      { if ((_level>=0)&&(_level<=nLevels)) level[_level]->catchupCurR(rdId,_curR); }\n\n\n\n    // TODO: methods to get info about current level fill status (e.g. number of frames written, curW, curR(global) and freeSpace, etc.)\n    long getCurW(int _level)  // current write index\n      { if ((_level>=0)&&(_level<=nLevels)) return level[_level]->getCurW(); else return -1; }\n    long getCurR(int _level, int rdId=-1)  // current read index\n      { if ((_level>=0)&&(_level<=nLevels)) return level[_level]->getCurR(rdId); else return -1; }\n    long getNFree(int _level,int rdId=-1) // get number of free frames in current level (rb: nT-(curW-curR))\n      { if ((_level>=0)&&(_level<=nLevels)) return level[_level]->getNFree(rdId); else return -1; }\n    long getNAvail(int _level,int rdId=-1) // get number of available frames in current level (curW-curR)\n      { if ((_level>=0)&&(_level<=nLevels)) return level[_level]->getNAvail(rdId); else return -1; }\n    //long getLevelSize(int _level) // get size of level in frames\n//      { if ((_level>=0)&&(_level<=nLevels)) return level[_level]->getLevelSize(); else return -1; }\n    long getMaxR(int _level)  // maximum readable index (index where data was written to)\n      { if ((_level>=0)&&(_level<=nLevels)) return level[_level]->getMaxR(); else return -1; }\n    long getMinR(int _level)  // minimum readable index (relevant only for ringbuffers, otherwise it will always return 0)\n      { if ((_level>=0)&&(_level<=nLevels)) return level[_level]->getMinR(); else return -1; }\n    long getNreaders(int _level)  // number of registered readers\n      { if ((_level>=0)&&(_level<=nLevels)) return level[_level]->getNreaders(); else return -1; }\n\n    // query, if names are set, i.e. if level was fixated\n    int namesAreSet(int _level) \n      { if ((_level>=0)&&(_level<=nLevels)) { return level[_level]->namesAreSet(); } else return 0; }\n    void fixateLevel(int _level) \n      { if ((_level>=0)&&(_level<=nLevels)) level[_level]->fixateLevel(); }\n\n    /* functions for manually obtaining exclusive level access */\n    void lockLevel(int _level)\n      { if ((_level>=0)&&(_level<=nLevels)) level[_level]->lock(); }  \n    void unlockLevel(int _level)\n      { if ((_level>=0)&&(_level<=nLevels)) level[_level]->unlock(); }  \n\n    const sDmLevelConfig * getLevelConfig(int _level)\n      { if ((_level>=0)&&(_level<=nLevels)) return level[_level]->getConfig(); else return NULL; }\n    \n    const char * getLevelName(int _level)\n      { if ((_level>=0)&&(_level<=nLevels)) return level[_level]->getName(); else return NULL; }\n\n    const char * getFieldName(int _level, int n, int *lN=NULL, int *_arrNameOffset=NULL)\n      { if ((_level>=0)&&(_level<=nLevels)) return level[_level]->getFieldName(n, lN, _arrNameOffset); else return NULL; }\n    char * getElementName(int _level, int n) // caller must free() returned string!!\n      { if ((_level>=0)&&(_level<=nLevels)) return level[_level]->getElementName(n); else return NULL; }\n\n    cVectorMeta * getLevelMetaDataPtr(int _level)\n      { if ((_level>=0)&&(_level<=nLevels)) return level[_level]->getLevelMetaDataPtr(); else return NULL; }\n \t  void setArrNameOffset(int _level, int arrNameOffset)\n\t    { if ((_level>=0)&&(_level<=nLevels)) level[_level]->setArrNameOffset(arrNameOffset); }\n    void setFrameSizeSec(int _level, double fss)\n      { if ((_level>=0)&&(_level<=nLevels)) level[_level]->setFrameSizeSec(fss);  }\n    void setBlocksizeWriter(int _level, long _bsw)\n      { if ((_level>=0)&&(_level<=nLevels)) level[_level]->setBlocksizeWriter(_bsw);  }\n\n    /* print an overview over registered levels and their configuration */\n    void printDmLevelStats(int detail=1)\n      { int i; for (i=0; i<=nLevels; i++) level[i]->printLevelStats(detail); }\n\n    // TODO: functions to convert absolute times (in seconds) to level frame indicies!\n    long secToVidx(int _level, double sec) // returns a vIdx\n      { if ((_level>=0)&&(_level<=nLevels)) return level[_level]->secToVidx(sec); else return -1; }\n    //(for period levels this function is easy, however for aperiodic levels we must iterate through all frames... maybe also for periodic to compensate round-off errors?)\n    double vIdxToSec(int _level, long vIdx) // returns a time in seconds as double\n      { if ((_level>=0)&&(_level<=nLevels)) return level[_level]->vIdxToSec(vIdx); else return -1; }\n    \n    virtual ~cDataMemory();\n};\n\n\n\n/****************** data memory logger functions ***************************/\n\n/*\nThese functions can be used for debugging the data flow. they log every read, write, and check operation, thus producing a lot of data.\n\nLog message fields:\n-level\n(-component?)\n-read/write/check\n-write/read/check counter\n-vIdx\n(-rIdx?)\n-length\n-curR\n-curW\n-nT\n-DATA\n*/\n\nvoid datamemoryLogger(const char *name, const char*dir, long cnt, long vIdx0, long vIdx, long rIdx, long nT, int special, long curR, long curW, long EOI, int nReaders, long *curRr, cVector *vec);\n\nvoid datamemoryLogger(const char *name, long vIdx0, long vIdx, long rIdx, long nT, int special, long curR, long curW, long EOI, int nReaders, long *curRr, cMatrix *mat);\n\n#endif // __DATA_MEMORY_HPP\n"
  },
  {
    "path": "src/include/core/dataProcessor.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: cDataProcessor \n\nThis is an abstract base class for all components which read data from the data memory and write new data to the data memory.\n\n*/\n\n\n#ifndef __DATA_PROCESSOR_HPP\n#define __DATA_PROCESSOR_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataWriter.hpp>\n#include <core/dataReader.hpp>\n\n#define COMPONENT_DESCRIPTION_CDATAPROCESSOR \"This is an abstract base class for all components which read data from the data memory and write new data to the data memory.\"\n#define COMPONENT_NAME_CDATAPROCESSOR \"cDataProcessor\"\n\n#undef class\nclass DLLEXPORT cDataProcessor : public cSmileComponent {\n  private:\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    long nInput_, inputStart_;\n    const char *inputName_;\n\n    cDataWriter *writer_;\n    cDataReader *reader_;\n    int namesAreSet_;\n    \n    double buffersize_sec_; /* buffersize of write level, as requested by config file (in seconds)*/\n    double blocksizeR_sec_, blocksizeW_sec_; /* blocksizes for block processing (in seconds)*/\n    long buffersize_; /* buffersize of write level, as requested by config file (in frames)*/\n    long blocksizeR_, blocksizeW_; /* blocksizes for block processing (in frames)*/\n    \n    int copyInputName_; /* 1=copy input name and append \"nameAppend\" (if != NULL) , 0 = do not copy and set name only to \"nameAppend\" */\n    const char * nameAppend_; /* suffix to append to element names */\n    void addNameAppendField(const char *base, const char *append, int N=1, int arrNameOffset=0);\n    void addNameAppendFieldAuto(const char *base, const char *customFixed, int N=1, int arrNameOffset=0);\n\n    // get the size of input frames in seconds\n    double getFrameSizeSec();\n\n    // get the period of the base level (e.g. sampling rate for wave input)\n    double getBasePeriod();\n\n    //\n    // find a field in the input level by a part of its name or its full name\n    // set the internal variables nInput, inputStart, and inputName\n    //\n    // nEl specifies the maximum number of input elements (for checking valid range of field index)\n    // (optional) fullName = 1: match full field name instead of part of name\n    long findInputField(const char *namePartial, int fullName=0, long nEl=-1);\n\n    //\n    // find a field in the input level by a part of its name or its full name\n    //\n    // nEl specifies the maximum number of input elements (for checking valid range of field index)\n    // *N , optional, a pointer to variable (long) that will be filled with the number of elements in the field\n    // **_fieldName : will be set to a pointer to the name of the field\n    // (optional) fullName = 1: match full field name instead of part of name\n    long findField(const char *namePartial, int fullName=0, long *N=NULL, const char **fieldName=NULL, long nEl=-1, int *more=NULL, int *fieldIdx=NULL);\n\n    //\n    // search for an element by its partial name (if multiple matches are found, only the first is returned)\n    // if fullName==1 , then do only look for exact name matches\n    // the return value will be the element(!) index , i.e. the index of the element in the data vector\n    //\n    long findElement(const char *namePartial, int fullName, long *N, const char **fieldName, int *more, int *fieldIdx=NULL);\n\n    // get data from input field (previously found by findInputField())\n    // stores nInput elements in **_in, the memory is allocated if necessary (i.e. *_in == NULL)\n    int getInputFieldData(const FLOAT_DMEM *src, long Nsrc, FLOAT_DMEM **in);\n\n    virtual void fetchConfig();\n    virtual void mySetEnvironment();\n\n    virtual int myRegisterInstance(int *runMe=NULL);\n    virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    \n    //---- *runMe return value for component manager : 0, don't call my tick of this component, 1, call myTick\n    virtual int runMeConfig() { return 1; }\n\n    //---- HOOKs during configure (for setting level parameters, buffersize/type, blocksize requirements)\n    // overwrite this, to configure the writer AFTER the reader config is available\n    // possible return values (others will be ignored): \n    // -1 : configureWriter has overwritten c->nT value for the buffersize, myConfigureInstance will not touch nT !\n    virtual int configureWriter(sDmLevelConfig &c) { return 1; }\n    \n    // configure reader, i.e. setup matrix reading, blocksize requests etc...\n    // c: currently existing reader config\n    virtual int configureReader(const sDmLevelConfig &c);\n\n    //---- HOOKs during finalise (for setting names)\n    virtual int dataProcessorCustomFinalise() { return 1; }\n\n    virtual int setupNewNames(long nEl);\n\n    // clone the input field info of field 'sourceIdx' to target field 'targetIdx' (can be -1 for last field..)\n    // force = 1: overwrite existing data (which was set by custom code, for example)\n    virtual int cloneInputFieldInfo(int sourceFidx, int targetFidx=-1, int force = 0);\n\n    virtual int setupNamesForField(int i, const char*name, long nEl);\n    virtual void configureField(int idxi, long N, long nOut) {}\n\n    virtual void setEOI() {\n      cSmileComponent::setEOI();\n      if (reader_!=NULL) reader_->setEOI();\n      if (writer_!=NULL) writer_->setEOI();\n    }\n\n    virtual void unsetEOI() {\n      cSmileComponent::unsetEOI();\n      if (reader_!=NULL) reader_->unsetEOI();\n      if (writer_!=NULL) writer_->unsetEOI();\n    }\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n \n    virtual int setEOIcounter(int cnt) {\n      if (reader_ != NULL) {\n        reader_->setEOIcounter(cnt);\n      }\n      if (writer_ != NULL) {\n        writer_->setEOIcounter(cnt);\n      }\n      return cSmileComponent::setEOIcounter(cnt);\n    }\n \n    cDataProcessor(const char *_name);\n    virtual ~cDataProcessor();\n};\n\n\n\n\n#endif // __DATA_PROCESSOR_HPP\n"
  },
  {
    "path": "src/include/core/dataReader.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: dataReader */\n\n\n\n#ifndef __DATA_READER_HPP\n#define __DATA_READER_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/smileComponent.hpp>\n#include <core/dataMemory.hpp>\n\n#define COMPONENT_DESCRIPTION_CDATAREADER  \"This is the dataMemory interface component that reads data as vector or matrix from dataMemory component. It is used internally by all dataProcessor, dataSource, and dataSink components. A cDataReader can read from one or more data memory levels. In the latter case a single vector is returned which consists of all individual vectors concattenated. Reading from multiple levels implies waiting for data on the 'slowest' level, since only completely concattenated frames are read.\"\n#define COMPONENT_NAME_CDATAREADER  \"cDataReader\"\n\n#undef class\nclass DLLEXPORT cDataReader : public cSmileComponent {\n  private:\n    \n    cDataMemory * dm;\n    const char *dmInstName;\n    \n    int nLevels; /* number of levels this reader is configured to read from */\n    const char **dmLevel; /* array of level names of the levels this reader is configured to read from */\n    int *level; /* mapping of level names to level indicies in the data memory */\n    int *rdId; /* data memory assigned reader id's of the registered readers */\n    \n    //int dtype;\n    \n    /* various config parameters */\n    int forceAsyncMerge;\n    int errorOnFullInputIncomplete;\n\n    // current frame TO read\n    long curR; \n    \n    // temporary vector...\n    cVector *V;\n    // temporary matrix...\n    cMatrix *m;\n\n    /* reader parameters for sequential matrix reading */\n    long stepM, lengthM;  /* parameters in frames */\n    int ignMisBegM;\n    double stepM_sec, lengthM_sec;  /* parameters in seconds */\n    double ignMisBegM_sec;\n    \n    /* various mappings for multiple read levels */\n    int *Lf,*Le;\n    int *fToL;  // field->level map\n    int *eToL;  // element->level map\n\n    /* input level config */\n    //long N,Nf;\n    //double T;\n    FrameMetaInfo *myfmeta;\n    sDmLevelConfig *myLcfg; //??\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    virtual int myRegisterInstance(int *runMe=NULL);\n    virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t) { return 1; } // tick is not implemented for the readers and writers\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n\n    cDataReader(const char *_name);\n\n\n    //TODO:(partially)  internal frame and matrix pointer (auto free mechanism, if next frame is read)\n    // privateVec=1 : allocates a new vector, which can and must be freed by the calling code (instead of returning a pointer to an internally allocated object, which will be only valid till the next getXXXX() call to the same dataReader\n    // absolute\n    cVector * getFrame(long vIdx, int special=-1, int privateVec=0, int *result=NULL);\n    cMatrix * getMatrix(long vIdx, long length, int special=-1, int privateVec=0); // vIdx: start index of matrix (absolute)\n    \n    // relative:\n    cVector * getFrameRel(long vIdxRelE, int privateVec=0, int noInc=0, int *result=NULL);\n    cMatrix * getMatrixRel(long vIdxRelE, long length, int privateVec=0);  // vIdxRelE: end of matrix relative to end of data\n\n    // sequential\n    void nextFrame() { curR++; }  // only increase frame counter\n    void nextMatrix() { curR += stepM; }  // only increase frame counter\n    cVector * getNextFrame(int privateVec=0, int *result=NULL);\n    cMatrix * getNextMatrix(int privateVec=0, int readToEnd=0, int special=-1);  // readToEnd == 1 will read all remaining input, even if stepM was not set to 0 or the current read pointer is no longer at vIdx 0\n\n    void catchupCurR(long _curR=-1); // set curR in dataMemory to curW-1 or to user defined value (for all input levels)\n\n    /* set matrix reading parameters in FRAMES */\n    int setupSequentialMatrixReading(long step, long length, long ignoreMissingBegin=0);\n    /* set matrix reading parameters in SECONDS */\n    int setupSequentialMatrixReading(double step, double length, double ignoreMissingBegin=0.0);\n\n    // these two functions must be used *before* reader->configure() is called!\n    /* set the required blocksize for reads (the default is 1, if you don't read blocks this is ok. You should use \n       setupSequentialMatrixReading() instead, if you want to use block reading (you don't need to use setBlocksize then!)\n    */\n    int setBlocksize(long length) { \n      if (isConfigured()) {\n        lengthM = length;\n        return updateBlocksize(length);\n      }\n      if (length >= 0) { lengthM = length; lengthM_sec = -1.0; return 1; }\n      return 0;\n    }\n    /* same as above, however, takes time in seconds as parameter */\n    int setBlocksizeSec(double length) { \n      if (isConfigured()) {\n        if (myLcfg->T != 0.0) {\n          lengthM = (long)ceil( length / myLcfg->T );\n        } else {\n          lengthM = (long)ceil( length );\n        }\n        return updateBlocksize((long)lengthM);\n      }\n      if (length >= 0.0) { lengthM_sec = length; lengthM = -1; return 1; }\n      return 0;\n    }\n\n    // these updateBlocksize functions may be used *after* reader->configure, but *before* finalise()\n    int updateBlocksize(long length) { \n      int i;\n      for (i=0; i<nLevels; i++) {\n        dm->queryReadConfig(level[i], length);\n      }\n      return 1;\n    }\n\n    /* same as above, however, takes time in seconds as parameter */\n    int updateBlocksizeSec(double length) { \n      if (myLcfg != NULL) {\n        long _bs = 1;\n        if (myLcfg->T != 0.0) {\n          _bs = (long)ceil( length / myLcfg->T );\n        } else {\n          _bs = (long)ceil( length );\n        }\n        updateBlocksize((long)_bs);\n        return 1;\n      }\n      return 0;\n    }\n\n    // set the current read index (negative values are also allowed!)\n    void setCurR(long _curR) { curR = _curR; }\n    long getCurR() { return curR; }\n\n    // get pointer to meta data of the read level, (levelIdx-th input level)\n    // WARN: we cannot merge metadata from multiple levels, thus we just use the first by default (the caller can change this via _levelIdx). This may not be correct in all cases!\n    cVectorMeta * getLevelMetaDataPtr(int _levelIdx=0) {\n      if ((_levelIdx < nLevels)&&(_levelIdx>=0)) {\n        return dm->getLevelMetaDataPtr(level[_levelIdx]); \n      } else {\n        return NULL;\n      }\n    }\n\n    // return number in input levels\n    int getNLevels() { return nLevels; }\n\n    // number of elements\n    int getLevelN() {  return myLcfg->N; }\n    // number of fields\n    int getLevelNf() {  return myLcfg->Nf; }\n\n    // frame period (or 0.0 for unperiodic)\n    double getLevelT() { return myLcfg->T; }\n    // frame size in seconds \n    double getFrameSizeSec() \n    {\n       // XXX: TODO: check if frameSizeSec is unique for all inputs... else return min/max/mean ??\n       return myLcfg->frameSizeSec;\n    }\n\n    // names of fields, etc.\n    const FrameMetaInfo * getFrameMetaInfo() { return myfmeta; }\n\n    // get full config of input level, get this config directly from the DM..\n    const sDmLevelConfig * getLevelConfig() \n      { return dm->getLevelConfig(level[0]);\n             // XXX TODO: merge level config from all input levels\n\n      }\n\n    // get full config of input level, return locally stored myLcfg\n    const sDmLevelConfig * getConfig() { return myLcfg; }\n\n    long getMinR();\n\n    long getNFree();\n    long getNAvail();\n    \n    int isNextMatrixReadOk() { \n      int r = 1; int i;\n      int nL = nLevels;\n      if (nL < 1) nL=1;\n      for (i=0; i<nL; i++) {\n        r &= dm->checkRead(level[i],curR,-1,rdId[i],lengthM);\n      }\n      return r;\n    }\n\n    int isNextFrameReadOk(int lag=0) { \n      int r = 1; int i;\n      int nL = nLevels;\n      if (nL < 1) nL=1;\n      for (i=0; i<nL; i++) {\n        r &= dm->checkRead(level[i],curR,-1,rdId[i]);\n      }\n      return r;\n    }\n\n    const char * getFieldName(int n, int *N=NULL, int *arrNameOffset=NULL)    // name of field n\n    { \n        if ((n >= 0) && (n < myLcfg->Nf)) {\n          return dm->getFieldName(level[fToL[n]], n - Lf[fToL[n]], N, arrNameOffset);\n        } else { \n          return NULL; \n        }\n    }\n    \n    char * getElementName(int n)    // name of element n , // caller must free() returned string!!\n    { \n        if ((n>=0)&&(n<myLcfg->N)) {\n          return dm->getElementName(level[eToL[n]],n-Le[eToL[n]]);\n        } else { return NULL; }\n    }\n\n    const char * getLevelName(int i=-1) { \n      if (i==-1) { return dmLevel[0]; }\n\t    // XXX: todo: return all input levels concatenated??\n\t    return \"concatNameNotSupportedYet\";\n    }\n    \n    const cDataMemory * getDmObj() const { return dm; }\n    \n    virtual ~cDataReader();\n};\n\n\n\n\n#endif // __DATA_READER_HPP\n\n"
  },
  {
    "path": "src/include/core/dataSelector.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample for dataProcessor descendant\n\n*/\n\n\n#ifndef __CDATASELECTOR_HPP\n#define __CDATASELECTOR_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CDATASELECTOR \"This component copies data from one level to another, thereby selecting frame fields and elements by their element/field name.\"\n#define COMPONENT_NAME_CDATASELECTOR \"cDataSelector\"\n\ntypedef struct {\n  long eIdx; // element index\n\n// actually these two are not needed... ??\n  long fIdx; // field index\n  long aIdx; // array index, if field is an array, else 0\n  long N;\n} sDataSelectorSelData;\n\n#undef class\nclass DLLEXPORT cDataSelector : public cDataProcessor {\n  private:\n    int elementMode, selectionIsRange, dummyMode;\n    const char *outputSingleField;\n    cVector *vecO;\n\n    const char * selFile;\n    int nSel; // number of names in names array\n    char **names;\n    \n    int nElSel, nFSel;  // actual number of elements(!) or fields selected (size of mapping array)\n    sDataSelectorSelData *mapping; // actual data selection map\n    long *idxSelected;\n\n    // for loading files...\n    int fselType;\n\n    int loadSelection();\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n    virtual int setupNewNames(long nEl);\n    //virtual int configureWriter(const sDmLevelConfig *c);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cDataSelector(const char *_name);\n\n    virtual ~cDataSelector();\n};\n\n\n\n\n#endif // __CDATASELECTOR_HPP\n"
  },
  {
    "path": "src/include/core/dataSink.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\ndataSink\n\n*/\n\n\n#ifndef __DATA_SINK_HPP\n#define __DATA_SINK_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/smileComponent.hpp>\n#include <core/dataReader.hpp>\n\n#define COMPONENT_DESCRIPTION_CDATASINK \"This is a base class for components reading from (and not writing to) the dataMemory and dumping/passing data to external entities.\"\n#define COMPONENT_NAME_CDATASINK \"cDataSink\"\n\n#undef class\nclass DLLEXPORT cDataSink : public cSmileComponent {\n  private:\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    int errorOnNoOutput_;\n    long nWritten_;\n    long blocksizeR_;\n    double blocksizeR_sec_;\n    cDataReader *reader_;\n\n    virtual void fetchConfig();\n    virtual void mySetEnvironment();\n    virtual int myRegisterInstance(int *runMe=NULL);\n    virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n\n    // *runMe return value for component manager : 0, don't call my tick of this component, 1, call myTick\n    virtual int runMeConfig() { return 1; }\n\n    // Configures the reader, i.e. set blocksize requests etc.\n    virtual int configureReader();\n\n    // Proper handling of EOI events, passing them to the reader.\n    virtual int setEOIcounter(int cnt) {\n      int ret = cSmileComponent::setEOIcounter(cnt);\n      if (reader_!=NULL) return reader_->setEOIcounter(cnt);\n      return ret;\n    }\n\n    // Proper handling of EOI events, passing them to the reader.\n    virtual void setEOI() {\n      cSmileComponent::setEOI();\n      if (reader_!=NULL) reader_->setEOI();\n    }\n\n    // Proper handling of EOI events, passing them to the reader.\n    virtual void unsetEOI() {\n      cSmileComponent::unsetEOI();\n      if (reader_!=NULL) reader_->unsetEOI();\n    }\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n\n    cDataSink(const char *_name);\n    virtual ~cDataSink();\n};\n\n\n\n\n#endif // __DATA_SINK_HPP\n"
  },
  {
    "path": "src/include/core/dataSource.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\n\n*/\n\n\n#ifndef __DATA_SOURCE_HPP\n#define __DATA_SOURCE_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/smileComponent.hpp>\n#include <core/dataWriter.hpp>\n\n#define COMPONENT_DESCRIPTION_CDATASOURCE \"This is a base class for components, which write data to dataMemory, but do not read from it.\"\n#define COMPONENT_NAME_CDATASOURCE \"cDataSource\"\n\n#undef class\nclass DLLEXPORT cDataSource : public cSmileComponent {\n  private:\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    cDataWriter *writer_;\n    cVector     *vec_;    // current vector to be written\n    cMatrix     *mat_;    // current matrix to be written\n    double buffersize_sec_; /* buffersize of write level, as requested by config file (in seconds)*/\n    double blocksizeW_sec; /* blocksizes for block processing (in seconds)*/\n    long buffersize_; /* buffersize of write level, as requested by config file (in frames)*/\n    long blocksizeW_; /* blocksizes for block processing (in frames)*/\n    double period_; /* period, as set by config */\n    double basePeriod_; \n    int namesAreSet_;\n\n    virtual void fetchConfig();\n    virtual void mySetEnvironment();\n    virtual int myRegisterInstance(int *runMe=NULL);\n    virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    void allocVec(int n);\n    void allocMat(int n, int t);\n\n    // *runMe return value for component manager : 0, don't call my tick of this component, 1, call myTick\n    virtual int runMeConfig() { return 1; }\n    virtual int configureWriter(sDmLevelConfig &c) { return 1; }\n    virtual int setupNewNames(long nEl=0) { return 1; }\n\n    virtual int setEOIcounter(int cnt) {\n      int ret = cSmileComponent::setEOIcounter(cnt);\n      if (writer_!=NULL) return writer_->setEOIcounter(cnt);\n      return ret;\n    }\n\n    virtual void setEOI() {\n      cSmileComponent::setEOI();\n      if (writer_!=NULL) writer_->setEOI();\n    }\n\n    virtual void unsetEOI() {\n      cSmileComponent::unsetEOI();\n      if (writer_!=NULL) writer_->unsetEOI();\n    }\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cDataSource(const char *_name);\n    virtual ~cDataSource();\n};\n\n\n\n\n#endif // __DATA_SOURCE_HPP\n"
  },
  {
    "path": "src/include/core/dataWriter.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: dataWriter */\n\n#ifndef __DATA_WRITER_HPP\n#define __DATA_WRITER_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/smileComponent.hpp>\n#include <core/dataMemory.hpp>\n\n#define COMPONENT_DESCRIPTION_CDATAWRITER  \"This is the dataMemory interface component that writes vector or matrix data to a dataMemory level. A writer can write only to a single level in the dataMemory, this level cannot be changed during the run-time phase.\"\n#define COMPONENT_NAME_CDATAWRITER  \"cDataWriter\"\n\n#undef class\nclass DLLEXPORT cDataWriter : public cSmileComponent {\n  private:\n    cDataMemory * dm;\n    const char *dmInstName;\n    const char *dmLevel;\n    int level;\n    //int namesSet;\n    sDmLevelConfig cfg;\n    int override_nT;\n    //long blocksize;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance(int isRb, long nT, double period, double lenSec, int dyn, int _type);\n    virtual int myRegisterInstance(int *runMe=NULL);\n    virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t) { return 1; } // tick is not implemented for the readers and writers\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cDataWriter(const char *_name);\n    \n    void setBuffersize(long nT); // assume override = 1 when calling this method to set the Blocksize!\n    long getBuffersize() { return cfg.nT; }\n/*\n    void setConfig(int isRb, long nT, double period, double lenSec, int dyn, int _type, int _override=1);\n    void setConfig(int isRb, long nT, double period, double lenSec, double frameSizeSec, int dyn, int _type, int _override=1);\n    */\n    void setConfig(sDmLevelConfig &_cfg, int _override=1);\n\n    /* data writer configuration process:\n            # = called from parent's configureInstance\n      #  configureInstance(...) to set the level timing and size parameters.\n      #  addField(...) to add fields and thus set the vec. size in this level\n      finaliseInstance() to finalise config.\n    */\n    int addField(const char * lname, int lN = 1, int arrNameOffset=0);\n    \n    /* set field info (by field index), dataType and custom data record. index -1 refers to the last added field */\n    int setFieldInfo(int i, int _dataType, void *_info=NULL, long _infoSize=0) { // special value for i : -1 , last field that was added (N-1)\n      if (i==-1) {\n        /*const sDmLevelConfig *c = dm->getLevelConfig(level);\n        if (c != NULL) {\n          const FrameMetaInfo * fmeta = c->fmeta;*/\n          const FrameMetaInfo * fmeta = getFrameMetaInfo();\n          if (fmeta == NULL) {\n            SMILE_IERR(2,\"cannot read FrameMetaInfo from write level!\\n\");\n            i=-1; // was: i==-1 ??\n          } else {\n            i = fmeta->N-1;\n          }\n        //}\n      }\n      return dm->setFieldInfo(level,i,_dataType, _info, _infoSize);\n    }\n\n    /* set field info (by field name), dataType and custom data record. */\n    int setFieldInfo(const char* __name, int _dataType, void *_info=NULL, long _infoSize=0) {\n      return dm->setFieldInfo(level,__name,_dataType, _info, _infoSize);\n    }\n\n    /* set field info (by field name), custom data record only, dataType is not changed. */\n    int setFieldInfo(const char* __name, void *_info, long _infoSize) {\n      return setFieldInfo(__name,0,_info,_infoSize);\n    }\n\n    /* set field info (by field index), custom data record only, dataType is not changed. index -1 refers to the last added field */\n    int setFieldInfo(int i, void *_info, long _infoSize) {\n      return setFieldInfo(i,0,_info,_infoSize);\n    }\n\n\t  void setArrNameOffset(int arrNameOffset);\n\t\n    // get pointer to meta data of the write level\n    cVectorMeta * getLevelMetaDataPtr() {\n      return dm->getLevelMetaDataPtr(level);\n    }\n\n    //void setBlocksize(long _bs) { blocksize = _bs; }\n\n// absolute position write functions:\n    int setFrame(long vIdx, const cVector *vec, int special=-1);\n    int setMatrix(long vIdx, const cMatrix *mat, int special=-1);\n// sequential write functions: write next frame(s)\n    int setNextFrame(const cVector *vec);  // append at end in dataMemory level\n    int setNextMatrix(const cMatrix *mat);  // append at end in dataMemory (no overlap)\n// TODO: meta-data handling...\n\n    int checkWrite(long len);\n    int getNAvail() { return dm->getNAvail(level); }\n    int getNFree() { return dm->getNFree(level); }\n\n    void setFrameSizeSec(double _fss) { dm->setFrameSizeSec(level,_fss); }\n    void setBlocksize(long _bsw) { dm->setBlocksizeWriter(level,_bsw); }\n\n    // number of elements (arrays expaned = frameSize)\n    int getLevelN() { return cfg.N; }\n    // number of fields (arrays not expanded ! i.e. this is not the vecSize!)\n    int getLevelNf() { return cfg.Nf; }\n    \n    // frame period (or 0.0 for unperiodic)\n    double getLevelT() { return cfg.T; }\n\n    // names of fields, etc.\n    const FrameMetaInfo * getFrameMetaInfo() { \n      //OLD: //return cfg.fmeta; \n      // NEW:\n      const sDmLevelConfig *c = dm->getLevelConfig(level);\n      if (c != NULL) {\n        return c->fmeta;\n      } else {\n        return NULL;\n      }\n    }\n\n    // full level config\n    const sDmLevelConfig * getLevelConfig() { \n      return dm->getLevelConfig(level);\n      //return &cfg; \n    }\n    \n    // name of field n, optionally returns number of elements in field in *_N\n    const char * getFieldName(int n, int *lN = NULL)\n    { \n      return dm->getFieldName(level, n, lN); \n    }\n\n    // full name of element n (incl. array index, etc.)\n    const char * getElementName(int n)  \n      { return dm->getElementName(level,n); }\n\n    const char * getLevelName() { return dmLevel; }\n    \n    cDataMemory * getDmObj() const { return dm; }\n\n    virtual ~cDataWriter() {}\n};\n\n\n\n\n#endif // __DATA_WRITER_HPP\n"
  },
  {
    "path": "src/include/core/exceptions.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*\n\n  SMILE exception classes\n  ===========================\n\n  Exception base class:\n    cSMILException:\n      + int getCode()\n      + int getType()\n        valid type constants:\n          EX_GENERIC, EX_MEMORY, EX_COMPONENT, EX_IO, EX_CONFIG, EX_USER\n      + getText()  : get human readable error message\n\n  GenericException: (cSMILException) [Internal errors, usually not displayed or loggged, only informative purpose]\n    > GenericException(int code)\n    - int getCode()\n\n  MemoryException: (cSMILException) [Memory allocation errors, etc.]\n    > MemoryException(int code)\n    - int getCode()\n\n  ----------------------------------------------------------------------------\n  ComponentException: (cSMILException) [Any error in a smile component]\n    > ComponentException([const char* module], const char* text)\n    > ComponentException([const char* module], FMT(const char* fmt, ...))\n    + getText()  : get full verbose text of error message\n    - int getCode()\n\n\n  ConfigException: (ComponentException) [Any configuration error]\n    > ConfigException(int origin, [const char *module], const char* text)\n    > ConfigException(int origin, [const char *module], FMT(const char* fmt, ...))\n    + int getOrigin()\n   origin: (exception raised when...)\n          a) errors occur during config file parsing (origin = CE_PARSER)\n          b) a module detects a bogus configuration, invalid value, etc.  (origin = CE_INVALID)\n          c) mandatory parameters are not specified, etc. (origin = CE_MANAGER)\n\n  IOException: (ComponentException) [Any I/O error, drive, network, sound, ...]\n    > IOException([const char *module], [int code], const char* text, )\n    > IOException([const char *module], [int code], FMT(const char* fmt, ...))\n\n  UserException: (ComponentException) [Any other error, user defined...]\n    > UserException([const char *module], int code, const char* text, )\n    > UserException([const char *module], int code, FMT(const char* fmt, ...))\n\n */\n\n\n#ifndef __EXCEPTIONS_HPP\n#define __EXCEPTIONS_HPP\n\n#include <core/smileLogger.hpp>\n\n#define EX_GENERIC    0   // fast , integer based, exception\n#define EX_COMPONENT  1\n#define EX_IO         2\n#define EX_CONFIG     3\n#define EX_MEMORY     4\n#define EX_USER       9\n\n#undef class\n/* The base class for all exception classes in openSMILE */\nclass DLLEXPORT cSMILException {\n  protected:\n    int code;\n    int type;\n\n  public:\n    cSMILException(int _type, int _code=0) { type=_type; code=_code; }\n    virtual int getCode() { return code; }\n    int getType() { return type; }\n\n    // get Error message as human readable text\n    virtual char * getText() {\n        const char *etype;\n        switch(type) {\n          case EX_GENERIC: etype=\"\"; break;\n          case EX_MEMORY: etype=\"Memory\"; break;\n          default: etype=\"Unknown\";\n        }\n        return myvprint(\"%s ERROR : code = %i\",etype,code);\n    }\n\n    virtual ~cSMILException() {}\n};\n\n/* generic exception, only contains an error code */\nclass DLLEXPORT cGenericException : public cSMILException {\n  public:\n    cGenericException(int _code) : cSMILException(EX_GENERIC, _code) { }\n    virtual ~cGenericException() {}\n};\n\n/* memory exception, only contains an error code */\nclass DLLEXPORT cMemoryException : public cSMILException {\n  public:\n    cMemoryException(int _code) : cSMILException(EX_MEMORY, _code) { }\n    virtual ~cMemoryException() {}\n};\n\n#define OUT_OF_MEMORY throw(cMemoryException(0))\n\n\n/* Component Exception, base class for all exceptions with a text message and module name */\nclass DLLEXPORT cComponentException : public cSMILException {\n  private:\n    char *tmp;\n\n  protected:\n    char *text;\n    const char *module;\n\n  public:\n    cComponentException(char *t, const char *m=NULL):\n      cSMILException(EX_COMPONENT),\n      tmp(NULL),\n      text(NULL)\n      { module=m; text=t; logException(); }\n    cComponentException(int _type, char *t, const char *m=NULL):\n      cSMILException(_type),\n      tmp(NULL),\n      text(NULL)\n      { module=m; text=t; logException(); }\n\n    virtual char * getText() {\n      if (text!=NULL) {\n        const char *etype;\n        switch(type) {\n          case EX_COMPONENT: etype=\"Component\"; break;\n          case EX_IO: etype=\"I/O\"; break;\n          case EX_CONFIG: etype=\"Config\"; break;\n          case EX_USER: etype=\"\"; break;\n          default: etype=\"Unknown\"; break;\n        }\n        if (module != NULL) {\n          tmp = myvprint(\"%s Exception in %s : %s [code = %i]\",etype,module,text,code);\n        } else {\n          tmp = myvprint(\"%s Exception : %s [code = %i]\",etype,text,code);\n        }\n      }\n      return tmp;\n    }\n\n    // automatically log the exception to smileLog component\n    virtual void logException() {\n      #ifdef AUTO_EXCEPTION_LOGGING\n      #ifdef SMILE_LOG_GLOBAL\n      SMILE_LOG_GLOBAL.error(text,1,module);\n      text = NULL;\n      #endif\n      #endif\n    }\n\n    virtual ~cComponentException() {\n      if (tmp!=NULL) free(tmp);\n      if (text != NULL) free(text);\n    }\n};\n\n// throw a component exception\n#define COMP_ERR(...)  throw(cComponentException(myvprint(__VA_ARGS__), MODULE))\n\n#define CE_PARSER  1\n#define CE_INVALID 2\n#define CE_MANAGER 3\n\n/*\n ConfigException:\n   raised when:\n          a) errors occur during config file parsing (origin = CE_PARSER)\n          b) a module detects a bogus configuration, invalid value, etc.  (origin = CE_INVALID)\n          c) mandatory parameters are not specified, etc. (origin = CE_MANAGER)\n*/\nclass DLLEXPORT cConfigException : public cComponentException {\n  private:\n    int origin;\n\n  public:\n    cConfigException(int _origin, char *t, const char *m=NULL) :\n      cComponentException(EX_CONFIG,t,m),\n      origin(_origin)\n      { }\n    virtual int getOrigin() { return origin; }\n    virtual ~cConfigException() {}\n};\n\n// throw config exceptions:\n#ifdef _MSC_VER\n#define CONF_INVALID_ERR(...) { SMILE_ERR(1, myvprint(__VA_ARGS__)); throw(cConfigException(CE_INVALID, myvprint(__VA_ARGS__), MODULE)); }\n#define CONF_PARSER_ERR(...) { SMILE_ERR(1, myvprint(__VA_ARGS__));  throw(cConfigException(CE_PARSER, myvprint(__VA_ARGS__), MODULE)); }\n#define CONF_MANAGER_ERR(...) { SMILE_ERR(1, myvprint(__VA_ARGS__));  throw(cConfigException(CE_MANAGER, myvprint(__VA_ARGS__), MODULE)); }\n#else\n#define CONF_INVALID_ERR(...)  throw(cConfigException(CE_INVALID, myvprint(__VA_ARGS__), MODULE))\n#define CONF_PARSER_ERR(...)  throw(cConfigException(CE_PARSER, myvprint(__VA_ARGS__), MODULE))\n#define CONF_MANAGER_ERR(...)  throw(cConfigException(CE_MANAGER, myvprint(__VA_ARGS__), MODULE))\n#endif\n\nclass DLLEXPORT cIOException : public cComponentException {\n  public:\n    cIOException(char *t, int _code=0, const char *m=NULL) :\n      cComponentException(EX_IO,t,m)\n      { code = _code; }\n    virtual ~cIOException() {}\n};\n\n#define IO_ERR(...)  throw(cIOException(FMT(__VA_ARGS__),0,MODULE));\n\nclass DLLEXPORT cUserException : public cComponentException {\n  public:\n    cUserException(char *t, int _code, const char *m=NULL) :\n      cComponentException(EX_USER,t,m)\n     { code = _code; }\n    virtual ~cUserException() {}\n};\n\n#define USER_ERR(CODE, ...)  throw(cIOException(FMT(__VA_ARGS__),CODE,MODULE));\n\n\n/**** typedefs *****************************/\n\ntypedef cGenericException GenericException;\ntypedef cMemoryException MemoryException;\n\ntypedef cComponentException ComponentException;\ntypedef cConfigException ConfigException;\ntypedef cIOException IOException;\ntypedef cUserException UserException;\n\n\n//#define MIN_LOG_STRLEN   255\n\n\n#endif  // __EXCEPTIONS_HPP\n\n"
  },
  {
    "path": "src/include/core/nullSink.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: cNullSink\n----------------------------------\nNULL sink: reads data vectors from data memory and destroys them without writing them anywhere\n----------------------------------\n\n11/2009  Written by Florian Eyben\n*/\n\n\n#ifndef __CNULLSINK_HPP\n#define __CNULLSINK_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataSink.hpp>\n\n#define COMPONENT_DESCRIPTION_CNULLSINK \"This component reads data vectors from the data memory and 'destroys' them, i.e. does not write them anywhere. This component has no configuration options.\"\n#define COMPONENT_NAME_CNULLSINK \"cNullSink\"\n\nclass cNullSink : public cDataSink {\n  private:\n    //int lag;    \n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    virtual int myTick(long long t);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cNullSink(const char *_name);\n    virtual ~cNullSink();\n};\n\n\n\n\n#endif // __CNULLSINK_HPP\n"
  },
  {
    "path": "src/include/core/smileCommon.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*\n\nCommon defines, config, etc.\n\nthis file also contains openSMILE's small and dirty platform independence layer \nand thread implementations\n\n*/\n\n\n#ifndef __SMILE_COMMON_H\n#define __SMILE_COMMON_H\n\n#ifdef HAVE_CONFIG_H\n#include <config.h>\n#endif\n\n#ifdef __VISTA\n#define WINVER 0x0600\n#define _WIN32_WINNT 0x0600\n#else\n // NT & XP compatibility\n#define WINVER 0x0400\n#define _WIN32_WINNT 0x0400\n#endif\n\n#ifdef HAVE_NET\n#ifdef __WINDOWS\n#include <winsock2.h>\n#endif\n#endif\n\n//#include <cstdlib>\n//#include <limits>\n\n// enable debugging output....\n#ifdef _DEBUG\n#define DEBUG\n#endif\n#ifdef __DEBUG\n#define DEBUG\n#endif\n\n\n#include <stdlib.h>\n#include <stdio.h>\n#include <stdarg.h>\n#include <string.h>\n#include <math.h>\n\n#ifdef HAVE_STRINGS_H\n#include <strings.h>\n#endif\n\n#ifdef __WINDOWS\n \n\n#include <windows.h>\n/* winspool.h defines these as macros, \n   however they confilct with member varibale definitions \n   in Thread.h of the APR library,\n   so we undef them for compatibility here */\n#ifdef MIN_PRIORITY\n#undef MIN_PRIORITY\n#endif\n#ifdef MAX_PRIORITY\n#undef MAX_PRIORITY\n#endif\n\n#endif\n\n#include <core/smileTypes.h>\n\n#ifdef __WINDOWS\n#ifndef __MINGW32\n#ifndef SILLY_VS2010_C_LIB_HAD_NO_ROUND_WE_DEFINED_IT_NOW\ninline double round(double x) { return floor(x + 0.5); }\n#define SILLY_VS2010_C_LIB_HAD_NO_ROUND_WE_DEFINED_IT_NOW\n#endif\n#define strdup _strdup\n#define strcasecmp _stricmp\n#define strncasecmp _strnicmp\n#include <float.h>\n#define isnan _isnan\n#define isinf(x) ((!_finite(x))&&(!_isnan(x)))\n#define finite _finite\n#endif\n#endif\n\n#include <locale.h>\n\n/*\n#ifdef HAVE_INTTYPES_H\n#include <inttypes.h>\n#else\n#define uint8_t UINT8\n#define uint16_t UINT16\n#define uint32_t UINT32\n#define uint64_t UINT64\n#define int8_t INT8\n#define int16_t INT16\n#define int32_t INT32\n#define int64_t INT64\n#endif\n*/\n\n#ifndef M_PI\n#define M_PI 3.14159265358979323846264338327950288\n#endif\n\n#ifdef _DEBUG\n#ifndef DEBUG\n#define DEBUG\n#endif\n#endif\n\n#define AUTO_EXCEPTION_LOGGING   1     // automatically log exceptions to smileLog global object\n\n#ifndef __STATIC_LINK\n#define SMILE_SUPPORT_PLUGINS\n#endif\n\n\n#ifdef _MSC_VER // Visual Studio specific macro\n  #ifdef BUILDING_DLL\n    #define DLLEXPORT __declspec(dllexport)\n    #define class class __declspec(dllexport)\n  #else\n    #define DLLEXPORT __declspec(dllimport)\n    #define class class __declspec(dllimport)\n  #endif\n  #define DLLLOCAL \n#else \n    #define DLLEXPORT \n    #define DLLLOCAL  \n#endif\n\n#if defined(_MSC_VER) && _MSC_VER < 1900\r\n\r\n#define snprintf c99_snprintf\r\n#define vsnprintf c99_vsnprintf\r\n\r\n__inline int c99_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap)\r\n{\r\n    int count = -1;\r\n\r\n    if (size != 0)\r\n        count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);\r\n    if (count == -1)\r\n        count = _vscprintf(format, ap);\r\n\r\n    return count;\r\n}\r\n\r\n__inline int c99_snprintf(char *outBuf, size_t size, const char *format, ...)\r\n{\r\n    int count;\r\n    va_list ap;\r\n\r\n    va_start(ap, format);\r\n    count = c99_vsnprintf(outBuf, size, format, ap);\r\n    va_end(ap);\r\n\r\n    return count;\r\n}\r\n\r\n#endif\n\n#include <core/versionInfo.hpp>\n\n#define EXIT_SUCCESS   0\n#define EXIT_ERROR    -1\n#define EXIT_CTRLC   -10\n\nDLLEXPORT void smilePrintHeader();\nDLLEXPORT int checkVectorFinite(FLOAT_DMEM *x, long N);\n\n// realloc and initialize additional memory with zero,like calloc\nDLLEXPORT void * crealloc(void *a, size_t size, size_t old_size);\n#define MIN_LOG_STRLEN   255\nDLLEXPORT char *myvprint(const char *fmt, ...);\n#define FMT(...)   myvprint(__VA_ARGS__)\nDLLEXPORT void * memdup(const void *in, size_t size);\n\n#ifdef __WINDOWS\n// for the windows MINGW32 environment, we have to implement some GNU library functions ourselves...\n//void bzero(void *s, size_t n);\n#define bzero(s,n) memset(s,0,n)\n#define __HAVENT_GNULIBS\n#ifndef _MSC_VER\nvoid GetSystemTimeAsFileTime(FILETIME*);\n#endif\nDLLEXPORT void gettimeofday(timeval* p, void* tz /* IGNORED */);\n//typedef \n//struct timeval {\n//     long tv_sec;     /* seconds */\n//     long tv_usec;    /* microseconds */\n//};\n#endif\n\n#if defined(__HAVENT_GNULIBS) || defined(__ANDROID__)\n// for the windows MINGW32 environment and Mac, we have to implement some GNU library functions ourselves...\nDLLEXPORT long smile_getline (char **lineptr, size_t *n, FILE *stream);\nDLLEXPORT long getstr (char **lineptr, size_t *n, FILE *stream, char terminator, int offset);\n#else\nstatic ssize_t  (*smile_getline)(char **, size_t *, FILE *) = getline;\n#endif\n\n#ifndef __WINDOWS\n#include <sys/time.h>\n#endif\n\n#ifndef INFINITY\n#define INFINITY (std::numeric_limits<double>::infinity())\n#endif\n\n#ifdef __MACOS\n\n#include <time.h>\n//#include <sys/time.h>\n\nDLLEXPORT int clock_gettime(int clock_id, struct timespec *tp);\n#ifndef CLOCK_REALTIME\n#define CLOCK_REALTIME 0\n#endif\n\n#endif\n\n// THREADS & MUTEXES:\n\n//#include <windows.h>\n//#include <process.h>\n//#ifdef HAVE_PTHREAD\n#if defined(HAVE_PTHREAD) || defined(__ANDROID_API__)\n\n#include <pthread.h>\n\n#define SMILE_THREAD_RETVAL void *\n#define SMILE_THREAD_RET return NULL\n\n#define smileThread  pthread_t\n#define smileThreadCreate(THRD,T_MAIN,ARG) (pthread_create(&(THRD), NULL, T_MAIN, ARG)==0)\n#define smileThreadJoinWret(THRD,RET) pthread_join(THRD,&RET)\n#define smileThreadJoin(THRD) pthread_join(THRD,NULL)\n\n#define smileMutex pthread_mutex_t\n#define smileMutexInitVar(mtx) mtx = PTHREAD_MUTEX_INITIALIZER\n#define smileMutexCreate(mtx) pthread_mutex_init(&(mtx), NULL)\n#define smileMutexLock(mtx) (pthread_mutex_lock(&(mtx))==0)\n#define smileMutexUnlock(mtx) pthread_mutex_unlock(&(mtx))\n#define smileMutexTryLock(mtx) pthread_mutex_trylock(&(mtx))\n#define smileMutexDestroy(mtx) pthread_mutex_destroy(&(mtx))\n\ntypedef struct {\n  pthread_mutex_t mtx;\n  pthread_cond_t  cond;\n  int signaled;\n} smileCond;\n\n#define smileCondInitVar(COND) COND.mtx = PTHREAD_MUTEX_INITIALIZER; COND.cond = PTHREAD_COND_INITIALIZER\n#define smileCondCreate(COND) { pthread_mutex_init(&(COND.mtx), NULL); \\\n                                pthread_cond_init(&(COND.cond), NULL); COND.signaled = 0; }\n#define smileCondWait(COND) { pthread_mutex_lock(&(COND.mtx)); \\\n                              if (!COND.signaled) { \\\n                                pthread_cond_wait(&(COND.cond), &(COND.mtx)); \\\n                              } COND.signaled = 0; \\\n                              pthread_mutex_unlock(&(COND.mtx)); }\n#define smileCondWaitWMtx(COND,MTX) pthread_cond_wait(&(COND.cond), &(MTX))\n\n// this function returns !=0 upon timeout and 0 upon success (i.e. signal!)\n#include <time.h>\n#define smileCondTimedWait(COND,MSEC) { pthread_mutex_lock(&(COND.mtx)); \\\n                                        if (!COND.signaled) { \\\n                                          struct timespec __TOut; \\\n                                          clock_gettime(CLOCK_REALTIME, &__TOut); \\\n                                          __TOut.tv_sec += (long)MSEC/1000; \\\n                                          __TOut.tv_nsec += ( (long)MSEC-1000*((long)MSEC/1000) )*1000000; \\\n                                          pthread_cond_timedwait(&(COND.cond), &(COND.mtx), &__TOut); \\\n                                        } COND.signaled = 0; \\\n                                        pthread_mutex_unlock(&(COND.mtx)); }\n#define smileCondTimedWaitWMtx(COND,MSEC,MTX) { if (!COND.signaled) { \\\n                                        struct timespec __TOut; \\\n                                        clock_gettime(CLOCK_REALTIME, &__TOut); \\\n                                        __TOut.tv_sec += (long)MSEC/1000; \\\n                                        __TOut.tv_nsec += ( (long)MSEC-1000*((long)MSEC/1000) )*1000000; \\\n                                        pthread_cond_timedwait(&(COND.cond), &(MTX), &__TOut); \\\n                                      } COND.signaled = 0; }\n\n#define smileCondSignal(COND) { pthread_mutex_lock(&(COND.mtx)); \\\n                                COND.signaled = 1; \\\n                                pthread_cond_signal(&(COND.cond)); \\\n                                pthread_mutex_unlock(&(COND.mtx)); }\n#define smileCondSignalRaw(COND) pthread_cond_signal(&(COND.cond))\n#define smileCondBroadcast(COND) { pthread_mutex_lock(&(COND.mtx)); \\\n                                   COND.signaled = 1; \\\n                                   pthread_cond_broadcast(&(COND.cond)); \\\n                                   pthread_mutex_unlock(&(COND.mtx)); }\n#define smileCondBroadcastRaw(COND) pthread_cond_broadcast(&(COND.cond))\n#define smileCondDestroy(COND) { smileCondSignal(COND); \\\n                                 pthread_cond_destroy(&(COND.cond)); \\\n                                 pthread_mutex_destroy(&(COND.mtx)); \\\n                                }\n\n#define smileSleep(msec)  usleep((msec)*1000)\n#define smileYield()      sched_yield()\n\n#else //not HAVE_PTHREAD\n\n#ifdef __WINDOWS\n\n#include <process.h>\n\n#define SMILE_THREAD_RETVAL DWORD\n#define SMILE_THREAD_RET return 0\n\n#define smileThread  HANDLE\n/*\nHANDLE CreateThread(\n  LPSECURITY_ATTRIBUTES lpThreadAttributes,  // pointer to security attributes\n  DWORD dwStackSize,                         // initial thread stack size\n  LPTHREAD_START_ROUTINE lpStartAddress,     // pointer to thread function\n  LPVOID lpParameter,                        // argument for new thread\n  DWORD dwCreationFlags,                     // creation flags\n  LPDWORD lpThreadId                         // pointer to receive thread ID\n);\n*/\n//#define smileThreadCreate(THRD,T_MAIN,ARG) ((long)(THRD = (HANDLE)_beginthread(T_MAIN,0,ARG)) != -1)\n#define smileThreadCreate(THRD,T_MAIN,ARG) ((void *)(THRD = (HANDLE)CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)T_MAIN,ARG,0,NULL)) != NULL)\n//#define smileThreadJoinWret(THRD,RET) pthread_join(THRD,&RET)\n#define smileThreadJoinWret(THRD,RET) WaitForSingleObject(THRD, INFINITE)\n//#define smileThreadJoin(THRD) pthread_join(THRD,NULL)\n#define smileThreadJoin(THRD) WaitForSingleObject(THRD, INFINITE)\n\n\n#define smileMutex CRITICAL_SECTION\n// #define smileMutex CRITICAL_SECTION\n//#define smileMutexInitVar(mtx) mtx = PTHREAD_MUTEX_INITIALIZER\n#define smileMutexInitVar(mtx) \n// #define smileMutexInitVar(mtx) mtx = ?????\n//#define smileMutexCreate(mtx) ( (mtx = CreateMutex( NULL, FALSE, NULL )) != NULL )\n#define smileMutexCreate(mtx) InitializeCriticalSection(&mtx)\n//#define smileMutexLock(mtx) (pthread_mutex_lock(&(mtx))==0)\n//#define smileMutexLock(mtx) WaitForSingleObject( mtx, INFINITE )\ninline int enterCSstub(smileMutex *mtx) {\n  EnterCriticalSection(mtx);\n  return 1;\n}\n#define smileMutexLock(mtx) enterCSstub(&mtx) //EnterCriticalSection(&mtx)\n//#define smileMutexUnlock(mtx) ReleaseMutex( mtx )\n#define smileMutexUnlock(mtx) LeaveCriticalSection(&mtx)\n//#define smileMutexTryLock(mtx) pthread_mutex_trylock(&(mtx))\n//#define smileMutexTryLock(mtx) WaitForSingleObject( mtx, 0 )\n#define smileMutexTryLock(mtx) (TryEnterCriticalSection( &mtx ) == TRUE)\n//#define smileMutexDestroy(mtx) CloseHandle( mtx )\n#define smileMutexDestroy(mtx) DeleteCriticalSection( &mtx )\n\n\n//------ condition variables:\n/*\ntypedef struct\n{\n  int waiters_count_;\n  // Number of waiting threads.\n\n  CRITICAL_SECTION waiters_count_lock_;\n  // Serialize access to <waiters_count_>.\n\n  HANDLE sema_;\n  // Semaphore used to queue up threads waiting for the condition to\n  // become signaled. \n\n  HANDLE waiters_done_;\n  // An auto-reset event used by the broadcast/signal thread to wait\n  // for all the waiting thread(s) to wake up and be released from the\n  // semaphore. \n\n  size_t was_broadcast_;\n  // Keeps track of whether we were broadcasting or signaling.  This\n  // allows us to optimize the code if we're just signaling.\n} pthread_cond_t;\n\ntypedef HANDLE pthread_mutex_t;\n\n\ntypedef struct {\n  pthread_mutex_t mtx;\n  pthread_cond_t  cond;\n} smileCond;\n\n\ninline int \npthread_cond_init (pthread_cond_t *cv\n                   )\n{\n  cv->waiters_count_ = 0;\n  cv->was_broadcast_ = 0;\n  cv->sema_ = CreateSemaphore (NULL,       // no security\n                                0,          // initially 0\n                                0x7fffffff, // max count\n                                NULL);      // unnamed \n  InitializeCriticalSection (&cv->waiters_count_lock_);\n  cv->waiters_done_ = CreateEvent (NULL,  // no security\n                                   FALSE, // auto-reset\n                                   FALSE, // non-signaled initially\n                                   NULL); // unnamed\n\n  return 1;\n}\n\ninline int\npthread_cond_wait (pthread_cond_t *cv, \n                   pthread_mutex_t *external_mutex)\n{\n  // Avoid race conditions.\n  EnterCriticalSection (&cv->waiters_count_lock_);\n  cv->waiters_count_++;\n  LeaveCriticalSection (&cv->waiters_count_lock_);\n\n  // This call atomically releases the mutex and waits on the\n  // semaphore until <pthread_cond_signal> or <pthread_cond_broadcast>\n  // are called by another thread.\n  SignalObjectAndWait (*external_mutex, cv->sema_, INFINITE, FALSE);\n\n  // Reacquire lock to avoid race conditions.\n  EnterCriticalSection (&cv->waiters_count_lock_);\n\n  // We're no longer waiting...\n  cv->waiters_count_--;\n\n  // Check to see if we're the last waiter after <pthread_cond_broadcast>.\n  int last_waiter = cv->was_broadcast_ && cv->waiters_count_ == 0;\n\n  LeaveCriticalSection (&cv->waiters_count_lock_);\n\n  // If we're the last waiter thread during this particular broadcast\n  // then let all the other threads proceed.\n  if (last_waiter)\n    // This call atomically signals the <waiters_done_> event and waits until\n    // it can acquire the <external_mutex>.  This is required to ensure fairness. \n    SignalObjectAndWait (cv->waiters_done_, *external_mutex, INFINITE, FALSE);\n  else\n    // Always regain the external mutex since that's the guarantee we\n    // give to our callers. \n    WaitForSingleObject (*external_mutex, INFINITE);\n\n  return 1;\n}\n\ninline int\nwpthread_cond_timedwait (pthread_cond_t *cv, \n                   pthread_mutex_t *external_mutex, long Msec)\n{\n  // Avoid race conditions.\n  EnterCriticalSection (&cv->waiters_count_lock_);\n  cv->waiters_count_++;\n  LeaveCriticalSection (&cv->waiters_count_lock_);\n\n  // This call atomically releases the mutex and waits on the\n  // semaphore until <pthread_cond_signal> or <pthread_cond_broadcast>\n  // are called by another thread.\n  SignalObjectAndWait (*external_mutex, cv->sema_, Msec, FALSE);\n\n  // Reacquire lock to avoid race conditions.\n  EnterCriticalSection (&cv->waiters_count_lock_);\n\n  // We're no longer waiting...\n  cv->waiters_count_--;\n\n  // Check to see if we're the last waiter after <pthread_cond_broadcast>.\n  int last_waiter = cv->was_broadcast_ && cv->waiters_count_ == 0;\n\n  LeaveCriticalSection (&cv->waiters_count_lock_);\n\n  // If we're the last waiter thread during this particular broadcast\n  // then let all the other threads proceed.\n  if (last_waiter)\n    // This call atomically signals the <waiters_done_> event and waits until\n    // it can acquire the <external_mutex>.  This is required to ensure fairness. \n    SignalObjectAndWait (cv->waiters_done_, *external_mutex, INFINITE, FALSE);\n  else\n    // Always regain the external mutex since that's the guarantee we\n    // give to our callers. \n    WaitForSingleObject (*external_mutex, INFINITE);\n\n  return 1;\n}\n\ninline int\npthread_cond_signal (pthread_cond_t *cv)\n{\n  EnterCriticalSection (&cv->waiters_count_lock_);\n  int have_waiters = cv->waiters_count_ > 0;\n  LeaveCriticalSection (&cv->waiters_count_lock_);\n\n  // If there aren't any waiters, then this is a no-op.  \n  if (have_waiters)\n    ReleaseSemaphore (cv->sema_, 1, 0);\n}\n\ninline int\npthread_cond_broadcast (pthread_cond_t *cv)\n{\n  // This is needed to ensure that <waiters_count_> and <was_broadcast_> are\n  // consistent relative to each other.\n  EnterCriticalSection (&cv->waiters_count_lock_);\n  int have_waiters = 0;\n\n  if (cv->waiters_count_ > 0) {\n    // We are broadcasting, even if there is just one waiter...\n    // Record that we are broadcasting, which helps optimize\n    // <pthread_cond_wait> for the non-broadcast case.\n    cv->was_broadcast_ = 1;\n    have_waiters = 1;\n  }\n\n  if (have_waiters) {\n    // Wake up all the waiters atomically.\n    ReleaseSemaphore (cv->sema_, cv->waiters_count_, 0);\n\n    LeaveCriticalSection (&cv->waiters_count_lock_);\n\n    // Wait for all the awakened threads to acquire the counting\n    // semaphore. \n    WaitForSingleObject (cv->waiters_done_, INFINITE);\n    // This assignment is okay, even without the <waiters_count_lock_> held \n    // because no other waiter threads can wake up to access it.\n    cv->was_broadcast_ = 0;\n  }\n  else\n    LeaveCriticalSection (&cv->waiters_count_lock_);\n  \n  return 1;\n}\n*/\n\n// if vista or > , use native windows condition variables\n#ifdef __VISTA\n\ntypedef struct {\n  CRITICAL_SECTION mtx;\n  CONDITION_VARIABLE cond;\n} smileCond;\n\n#define smileCondInitVar(COND) InitializeCriticalSection(&(COND.mtx)); InitializeConditionVariable(&(COND.cond));\n#define smileCondCreate(COND) InitializeCriticalSection(&(COND.mtx)); InitializeConditionVariable(&(COND.cond));\n#define smileCondWait(COND) { EnterCriticalSection(&(COND.mtx)); \\\n                              SleepConditionVariableCS(&(COND.cond), &(COND.mtx), INFINITE); \\\n\t\t\t\t\t\t\t                LeaveCriticalSection(&(COND.mtx)); }\n\n#define smileCondWaitWMtx(COND,MTX) { SleepConditionVariableCS(&(COND.cond), &(MTX), INFINITE); }\n\n// this function returns !=0 upon timeout and 0 upon success (i.e. signal!)\n//#include <time.h>\n#define smileCondTimedWait(COND,MSEC) {  EnterCriticalSection(&(COND.mtx)); \\\n                                         SleepConditionVariableCS(&(COND.cond), &(COND.mtx), MSEC); \\\n                                         LeaveCriticalSection(&(COND.mtx)); }\n\n#define smileCondTimedWaitWMtx(COND,MSEC,MTX) { SleepConditionVariableCS(&(COND.cond), &(COND.mtx), MSEC); }\n\n#define smileCondSignal(COND) { EnterCriticalSection(&(COND.mtx)); \\\n                                WakeConditionVariable(&(COND.cond)); \\\n                                LeaveCriticalSection(&(COND.mtx)); }\n#define smileCondSignalRaw(COND) { WakeConditionVariable(&(COND.cond)); }\n#define smileCondBroadcast(COND) { EnterCriticalSection(&(COND.mtx)); \\\n                                   WakeAllConditionVariable(&(COND.cond)); \\\n                                   LeaveCriticalSection(&(COND.mtx)); }\n#define smileCondBroadcastRaw(COND) { WakeAllConditionVariable(&(COND.cond)); }\n#define smileCondDestroy(COND)  { DeleteCriticalSection(&(COND.mtx)); }\n\n#else // provide a little hacked implementation for older windowses ...\n\ntypedef struct\n{\n  int waiters_count_;\n  // Count of the number of waiters.\n\n  CRITICAL_SECTION waiters_count_lock_;\n  // Serialize access to <waiters_count_>.\n\n  int release_count_;\n  // Number of threads to release via a <pthread_cond_broadcast> or a\n  // <pthread_cond_signal>. \n  \n  int wait_generation_count;\n  // Keeps track of the current \"generation\" so that we don't allow\n  // one thread to steal all the \"releases\" from the broadcast.\n\n  HANDLE event_;\n  // A manual-reset event that's used to block and release waiting\n  // threads. \n} pthread_cond_t;\n\ntypedef CRITICAL_SECTION pthread_mutex_t;\n\ntypedef struct {\n  pthread_mutex_t mtx;\n  pthread_cond_t  cond;\n} smileCond;\n\n\n\ninline int \npthread_cond_init (pthread_cond_t *cv)\n{\n  cv->waiters_count_ = 0;\n  cv->wait_generation_count = 0;\n  cv->release_count_ = 0;\n\n  // Create a manual-reset event.\n  cv->event_ = CreateEvent (NULL,  // no security\n                            TRUE,  // manual-reset\n                            FALSE, // non-signaled initially\n                            NULL); // unnamed\n\n  InitializeCriticalSection(&(cv->waiters_count_lock_));\n\n  return 1;\n}\n\ninline int\npthread_cond_wait (pthread_cond_t *cv,\n                   pthread_mutex_t *external_mutex)\n{\n  // Avoid race conditions.\n  EnterCriticalSection (&(cv->waiters_count_lock_));\n\n  // Increment count of waiters.\n  cv->waiters_count_++;\n\n  // Store current generation in our activation record.\n  int my_generation = cv->wait_generation_count;\n\n  LeaveCriticalSection (&(cv->waiters_count_lock_));\n  LeaveCriticalSection (external_mutex);\n\n  for (;;) {\n    // Wait until the event is signaled.\n    WaitForSingleObject (cv->event_, INFINITE);\n\n    EnterCriticalSection (&(cv->waiters_count_lock_));\n    // Exit the loop when the <cv->event_> is signaled and\n    // there are still waiting threads from this <wait_generation>\n    // that haven't been released from this wait yet.\n    int wait_done = cv->release_count_ > 0\n                    && cv->wait_generation_count != my_generation;\n    LeaveCriticalSection (&(cv->waiters_count_lock_));\n\n    if (wait_done)\n      break;\n  }\n\n  EnterCriticalSection (external_mutex);\n  EnterCriticalSection (&(cv->waiters_count_lock_));\n  cv->waiters_count_--;\n  cv->release_count_--;\n  int last_waiter = cv->release_count_ == 0;\n  LeaveCriticalSection (&(cv->waiters_count_lock_));\n\n  if (last_waiter)\n    // We're the last waiter to be notified, so reset the manual event.\n    ResetEvent (cv->event_);\n\n  return 1;\n}\n\ninline int\npthread_cond_timedwait (pthread_cond_t *cv,\n                   pthread_mutex_t *external_mutex,\n                   long msec)\n{\n  // Avoid race conditions.\n  EnterCriticalSection (&(cv->waiters_count_lock_));\n\n  // Increment count of waiters.\n  cv->waiters_count_++;\n\n  // Store current generation in our activation record.\n  int my_generation = cv->wait_generation_count;\n\n  LeaveCriticalSection (&(cv->waiters_count_lock_));\n  LeaveCriticalSection (external_mutex);\n\n  for (;;) {\n    // Wait until the event is signaled.\n    int ret = WaitForSingleObject (cv->event_, msec);\n\n    EnterCriticalSection (&(cv->waiters_count_lock_));\n    // Exit the loop when the <cv->event_> is signaled and\n    // there are still waiting threads from this <wait_generation>\n    // that haven't been released from this wait yet.\n    int wait_done = cv->release_count_ > 0\n                    && cv->wait_generation_count != my_generation;\n    LeaveCriticalSection (&(cv->waiters_count_lock_));\n\n\tif (ret == WAIT_TIMEOUT) break;\n\n    if (wait_done)\n      break;\n  }\n\n  EnterCriticalSection (external_mutex);\n  EnterCriticalSection (&(cv->waiters_count_lock_));\n  cv->waiters_count_--;\n  cv->release_count_--;\n  int last_waiter = cv->release_count_ == 0;\n  LeaveCriticalSection (&(cv->waiters_count_lock_));\n\n  if (last_waiter)\n    // We're the last waiter to be notified, so reset the manual event.\n    ResetEvent (cv->event_);\n\n  return 1;\n}\n\ninline int\npthread_cond_signal (pthread_cond_t *cv)\n{\n  EnterCriticalSection (&(cv->waiters_count_lock_));\n  if (cv->waiters_count_ > cv->release_count_) {\n    SetEvent (cv->event_); // Signal the manual-reset event.\n    cv->release_count_++;\n    cv->wait_generation_count++;\n  }\n  LeaveCriticalSection (&(cv->waiters_count_lock_));\n  return 1;\n}\n\ninline int\npthread_cond_broadcast (pthread_cond_t *cv)\n{\n  EnterCriticalSection (&(cv->waiters_count_lock_));\n  if (cv->waiters_count_ > 0) {  \n    SetEvent (cv->event_);\n    // Release all the threads in this generation.\n    cv->release_count_ = cv->waiters_count_;\n\n    // Start a new generation.\n    cv->wait_generation_count++;\n  }\n  LeaveCriticalSection (&cv->waiters_count_lock_);\n  return 1;\n}\n\ninline int\npthread_cond_destroy (pthread_cond_t *cv) \n{\n  DeleteCriticalSection(&(cv->waiters_count_lock_));\n  CloseHandle(cv->event_);\n  return 1;\n}\n\n#define smileCondInitVar(COND) \n#define smileCondCreate(COND) InitializeCriticalSection(&(COND.mtx)); pthread_cond_init(&(COND.cond));\n#define smileCondWait(COND) {  EnterCriticalSection(&(COND.mtx)); \\\n                              pthread_cond_wait(&(COND.cond), &(COND.mtx)) \\\n\t\t\t\t\t\t\t  LeaveCriticalSection(&(COND.mtx)); }\n\n#define smileCondWaitWMtx(COND,MTX) pthread_cond_wait(&(COND.cond), &(MTX))\n\n// this function returns !=0 upon timeout and 0 upon success (i.e. signal!)\n#include <time.h>\n#define smileCondTimedWait(COND,MSEC) {  EnterCriticalSection(&(COND.mtx)); \\\n                                        pthread_cond_timedwait(&(COND.cond), &(COND.mtx), MSEC); \\\n                                        LeaveCriticalSection(&(COND.mtx)); }\n\n#define smileCondTimedWaitWMtx(COND,MSEC,MTX) { pthread_cond_timedwait(&(COND.cond), &(MTX), MSEC); }\n\n#define smileCondSignal(COND) { EnterCriticalSection(&(COND.mtx)); \\\n                                pthread_cond_signal(&(COND.cond)); \\\n                                LeaveCriticalSection(&(COND.mtx)); }\n#define smileCondSignalRaw(COND) { pthread_cond_signal(&(COND.cond)); }\n#define smileCondBroadcast(COND) { EnterCriticalSection(&(COND.mtx)); \\\n                                   pthread_cond_broadcast(&(COND.cond)); \\\n                                   LeaveCriticalSection(&(COND.mtx)); }\n#define smileCondBroadcastRaw(COND) pthread_cond_broadcast(&(COND.cond))\n#define smileCondDestroy(COND)  DeleteCriticalSection(&(COND.mtx)); pthread_cond_destroy(&(COND.cond));\n/* TODO: destroy condition */\n\n#endif // __VISTA\n\n//#define smileSleep(msec)  usleep((msec)*1000)\n#define smileSleep(msec)  Sleep( msec )\n//#define smileYield()      sched_yield()\n#define smileYield()   SwitchToThread() //Sleep( 0 )\n\n\n\n#endif // __WINDOWS\n#endif // HAVE_PTHREAD\n\n\n//--------------------------------------------------\n\n#define smileCommon_fixLocaleEnUs() { setlocale(LC_NUMERIC, \"en_US\"); }\n\n#include <core/exceptions.hpp>\n#include <smileutil/smileUtil.h>\n\n\n\n\n//#define XERCESC_NS  xercesc_3_0\n\n#endif  // __SMILE_COMMON_H\n"
  },
  {
    "path": "src/include/core/smileComponent.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n#ifndef __SMILE_COMPONENT_HPP\n#define __SMILE_COMPONENT_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/configManager.hpp>\n#include <string>\n\n#define COMPONENT_DESCRIPTION_XXXX  \"example description\"\n#define COMPONENT_NAME_XXXX         \"exampleName\"\n\n#undef class\nclass DLLEXPORT cComponentManager;\nclass DLLEXPORT cSmileComponent;\n\n#define CMSG_textLen      64\n#define CMSG_typenameLen  32\n#define CMSG_nUserData     8\n\ntypedef enum  {\n  CUSTDATA_BINARY = 0, // unknown binary data\n  CUSTDATA_TEXT = 100,   // null terminated string\n  CUSTDATA_CHAR = 110,   // char array (size given in bytes by custDataSize)\n  CUSTDATA_INT  = 200,    // array of ints (size given in bytes by custDataSize)\n  CUSTDATA_FLOAT = 300,   // array of floats (size given in bytes by custDataSize)\n  CUSTDATA_DOUBLE = 400,   // array of doubles (size given in bytes by custDataSize)\n  CUSTDATA_FLOAT_DMEM = 500,   // array of float_dmem (size given in bytes by custDataSize)\n} eSmileMessageCustDataType;\n\nclass DLLEXPORT cComponentMessage {\npublic:\n  char msgtype[CMSG_typenameLen];     // message type name (used by receiver to identify message), set by constructor\n  char msgname[CMSG_typenameLen];     // custom message name\n  const char * sender;  // name of sender component (filled in by sendComponentMessage in cSmileComponent)\n  double smileTime;  // seconds (accurate up to milliseconds) since componentManager startup (filled in by componentManager, TODO!)\n  double userTime1;  // user defined time\n  double userTime2;  // user defined time\n  double readerTime; // readerTime in seconds (derived from vec->tmeta->vIdx and reader period in the tick the message ist sent), can also be -1.0 if not used!\n  long msgid;           // custom message id\n  // -- message data --\n  double floatData[CMSG_nUserData];  // 8 freely usable doubles for message data, initialized with 0\n  long intData[CMSG_nUserData];      // 8 freely usable ints\n  char msgtext[CMSG_textLen];     // 64 characters for message text, freely usable, initialized with all 0\n  int userflag1, userflag2, userflag3;\n  void * custData;      // pointer to custom message data (allocated by sender, to be freed by sender after call to sendComponentMessage)\n  void * custData2;     // pointer to custom message data (allocated by sender, to be freed by sender after call to sendComponentMessage)\n  long custDataSize, custData2Size;   // size (in bytes) of custData arrays. Used for network message senders (TODO: implement this properly in all components that allocate custData!)\n  eSmileMessageCustDataType custDataType, custData2Type;   // Type of custData arrays. Used for network message senders (TODO: implement this properly in all components that allocate custData!)\n\n  cComponentMessage() {\n    memset(this, 0, sizeof(cComponentMessage));\n  }\n\n  cComponentMessage(const char *type, const char *name=NULL) :\n    msgid(-1), sender(NULL), userflag1(0), userflag2(0), userflag3(0),\n    smileTime(0.0), readerTime(-1.0), userTime1(0.0), userTime2(0.0),\n    custData(NULL), custData2(NULL), custDataSize(0), custData2Size(0),\n    custDataType(CUSTDATA_BINARY), custData2Type(CUSTDATA_BINARY)\n  {\n    if (type == NULL)\n      memset(msgtype, 0, sizeof(char) * CMSG_typenameLen);\n    else\n      strncpy(msgtype, type, CMSG_typenameLen);\n    if (name == NULL)\n      memset(msgname, 0, sizeof(char) * CMSG_typenameLen);\n    else\n      strncpy(msgname, name, CMSG_typenameLen);\n    memset(floatData, 0, sizeof(double) * CMSG_nUserData);\n    memset(intData, 0, sizeof(long) * CMSG_nUserData);\n    memset(msgtext, 0, sizeof(char) * CMSG_textLen);\n    //printf(\"XXX: msgtype = '%s'\\n\", msgtype);\n    //printf(\"XXX: msgname = '%s'\\n\", msgname);\n  }\n\n  char * createCustDataString(void * myCustData, int mySize, eSmileMessageCustDataType myType)\n  {\n    char * custDataText = NULL;\n    if (myCustData != NULL) {\n      if (myType == CUSTDATA_CHAR || myType == CUSTDATA_TEXT) {\n        custDataText = (char *)calloc(1, sizeof(char) * (mySize + 3));\n        strncpy(custDataText + 1, (char *)myCustData, sizeof(char) * mySize);\n        custDataText[0] = '\"';\n        custDataText[mySize + 1] = '\"';\n      } else if (myType == CUSTDATA_FLOAT_DMEM) {\n        std::string custDataFloats = \"[ \";\n        const FLOAT_DMEM *cdFloat = (const FLOAT_DMEM *)myCustData;\n        int nSize = mySize / sizeof(FLOAT_DMEM);\n        for (int i = 0; i < nSize - 1; i++) {\n          char *tmp = myvprint(\"%f,\", cdFloat[i]);\n          custDataFloats += tmp;\n          free(tmp);\n        }\n        if (nSize > 0) {\n          char *tmp = myvprint(\"%f\", cdFloat[nSize - 1]);\n          custDataFloats += tmp;\n          free(tmp);\n        }\n        custDataFloats += \" ]\";\n        custDataText = (char *)calloc(1, sizeof(char) * (custDataFloats.length() + 2) );\n        strncpy(custDataText, custDataFloats.c_str(), custDataFloats.length());\n      }\n    }\n    return custDataText;\n  }\n\n  // this function is outdated and will be removed in future releases...\n  // it is advised to migrate to the new class\n  //   cSmileTcpJsonMessageFunctions\n\n  /*\n   * detail:\n   * 0: print fewer fields, floatData 0 and intData 0 only\n   * 10: print fewer fields, floatData 0-3 and intData 0-3 only\n   * 20: print fewer field, float/int full\n   * 30: print all fields, custData null\n   * 40: print all fields, include custData\n   */\n  // returned string must be freed by caller\n  char * serializeToJson(int detail = 99, const char *recepient = NULL) {\n    char msgtypeNullterminated[CMSG_typenameLen + 1];\n    char msgnameNullterminated[CMSG_typenameLen + 1];\n    strncpy(msgtypeNullterminated, msgtype, CMSG_typenameLen);\n    strncpy(msgnameNullterminated, msgname, CMSG_typenameLen);\n    msgtypeNullterminated[CMSG_typenameLen] = 0;\n    msgnameNullterminated[CMSG_typenameLen] = 0;\n\n    char *recepientJson = NULL;\n    if (recepient != NULL) {\n      recepientJson = myvprint(\"\\\"recepient\\\": \\\"%s\\\",\\n\", recepient);\n    } else {\n      recepientJson = myvprint(\"\");\n    }\n    std::string floatDataString = \"\";\n    int nUserData = CMSG_nUserData;\n    if (detail < 10) {\n      nUserData = 1;\n    } else if (detail < 20) {\n      nUserData = 4;\n    }\n    for (int i = 0; i < CMSG_nUserData; ++i) {\n      char * tmp = NULL;\n      if (i != (CMSG_nUserData-1)) {\n        tmp = myvprint(\"  \\\"%i\\\": %e,\\n\", i, floatData[i]);\n      } else {\n        tmp = myvprint(\"  \\\"%i\\\": %e\\n\", i, floatData[i]);\n      }\n      floatDataString += tmp;\n      free(tmp);\n    }\n    std::string intDataString = \"\";\n    for (int i = 0; i < CMSG_nUserData; ++i) {\n      char * tmp = NULL;\n      if (i != (CMSG_nUserData-1)) {\n        tmp = myvprint(\"  \\\"%i\\\": %ld,\\n\", i, intData[i]);\n      } else {\n        tmp = myvprint(\"  \\\"%i\\\": %ld\\n\", i, intData[i]);\n      }\n      intDataString += tmp;\n      free(tmp);\n    }\n    char * custDataText = NULL; // custDataType\n    char * custData2Text = NULL;\n    if (detail >= 40) {\n      custDataText = createCustDataString(custData, custDataSize, custDataType);\n      custData2Text = createCustDataString(custData2, custData2Size, custData2Type);\n    }\n    char * json = NULL;\n    if (detail < 30) {\n      json = myvprint(\"{%s\\n\"\n          \"\\\"msgtype\\\": \\\"%s\\\",\\n\"\n          \"\\\"msgname\\\": \\\"%s\\\",\\n\"\n          \"\\\"sender\\\": \\\"%s\\\",\\n\"\n          \"\\\"smileTime\\\": %f,\\n\"\n          \"\\\"userTime1\\\": %f,\\n\"\n          \"\\\"msgid\\\": %ld,\\n\"\n          \"\\\"floatData\\\": {\\n%s},\\n\"\n          \"\\\"intData\\\": {\\n%s},\\n\"\n          \"\\\"msgtext\\\": \\\"%s\\\"\\n}\",\n          recepientJson,\n          msgtypeNullterminated,\n          msgnameNullterminated,\n          sender,\n          smileTime,\n          userTime1,\n          msgid,\n          floatDataString.c_str(),\n          intDataString.c_str(),\n          msgtext);\n    } else {\n      json = myvprint(\"{%s\\n\"\n          \"\\\"msgtype\\\": \\\"%s\\\",\\n\"\n          \"\\\"msgname\\\": \\\"%s\\\",\\n\"\n          \"\\\"sender\\\": \\\"%s\\\",\\n\"\n          \"\\\"smileTime\\\": %f,\\n\"\n          \"\\\"userTime1\\\": %f,\\n\"\n          \"\\\"userTime2\\\": %f,\\n\"\n          \"\\\"readerTime\\\": %f,\\n\"\n          \"\\\"msgid\\\": %ld,\\n\"\n          \"\\\"floatData\\\": {\\n%s},\\n\"\n          \"\\\"intData\\\": {\\n%s},\\n\"\n          \"\\\"msgtext\\\": \\\"%s\\\",\\n\"\n          \"\\\"userflag1\\\": %i,\\n\"\n          \"\\\"userflag2\\\": %i,\\n\"\n          \"\\\"userflag3\\\": %i,\\n\"\n          \"\\\"custData\\\": %s,\\n\"\n          \"\\\"custData2\\\": %s\\n}\",\n          recepientJson,\n          msgtypeNullterminated,\n          msgnameNullterminated,\n          sender,\n          smileTime,\n          userTime1,\n          userTime2,\n          readerTime,\n          msgid,\n          floatDataString.c_str(),\n          intDataString.c_str(),\n          msgtext,\n          userflag1,\n          userflag2,\n          userflag3,\n          custDataText,\n          custData2Text\n      );\n    }\n    if (custDataText != NULL)\n      free(custDataText);\n    if (custData2Text != NULL)\n      free(custData2Text);\n    if (recepientJson != NULL)\n      free(recepientJson);\n    return json;\n  }\n};\n\nclass DLLEXPORT sComponentInfo { public:\n  int registerAgain;\n  const char *componentName;\n  const char *description;\n  int abstract;   // flag that indicates whether component is 'abstract' only (i.e. without practical functionality)\n  int noDmem;\n  int builtIn;   // 1= built in component ; 0= dynamically linked component\n  cSmileComponent * (*create) (const char *_instname);\n  sComponentInfo * next;\n};\n\n// create for a real class (which implements fetchConfig() )\n#define SMILECOMPONENT_CREATE(TP) cSmileComponent * TP::create(const char*_instname) { \\\n                                                  cSmileComponent *c = new TP(_instname); \\\n                                                  if (c!=NULL) c->setComponentInfo(sconfman,scname,sdescription); \\\n                                                  return c; \\\n                                                  }\n                                                  \n// create for an abstract class\n#define SMILECOMPONENT_CREATE_ABSTRACT(TP) cSmileComponent * TP::create(const char*_instname) { return NULL; }\n\n// static declaration in Cpp file of derived class\n#define SMILECOMPONENT_STATICS(TP)  cConfigManager *TP::sconfman; \\\n                                    const char *TP::scname; \\\n                                    const char *TP::sdescription;\n                                    \n// static declarations in derived class (public)\n#define SMILECOMPONENT_STATIC_DECL  static sComponentInfo * registerComponent(cConfigManager *_confman, cComponentManager *_compman);    \\\n                                    static cSmileComponent * create(const char *_instname);\n                                    \n// static declarations in derived class (protected)\n#define SMILECOMPONENT_STATIC_DECL_PR    static cConfigManager *sconfman;    \\\n                                         static const char *scname;  \\\n                                         static const char *sdescription;\n\n#define SMILECOMPONENT_REGCOMP(TP)  sComponentInfo * TP::registerComponent(cConfigManager *_confman, cComponentManager *_compman)\n#define SMILECOMPONENT_REGCOMP_INIT  if (_confman == NULL) return NULL; \\\n                                     int rA = 0; \\\n\t\t\t\t\t\t\t\t\t sconfman = _confman;\n\n#define SMILECOMPONENT_CREATE_CONFIGTYPE    ConfigType *ct = new ConfigType(scname); \\\n\t                                        if (ct == NULL) OUT_OF_MEMORY;\n#define SMILECOMPONENT_INHERIT_CONFIGTYPE(configtype)  ConfigType *ct = NULL; \\\n\t                                                   const ConfigType *r = sconfman->getTypeObj(configtype); \\\n\t\t\t\t\t\t\t\t\t\t\t\t\t   if (r == NULL) {  \\\n\t\t\t\t\t\t\t\t\t\t\t\t\t     SMILE_WRN(4,\"%s config Type not found!\",\"configtype\"); \\\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t rA=1; \\\n\t\t\t\t\t\t\t\t\t\t\t\t\t   } else { \\\n\t\t\t\t\t\t\t\t\t\t\t\t\t     ct = new ConfigType( *(r) , scname ); \\\n\t\t\t\t\t\t\t\t\t\t\t\t\t   }\n\n#define SMILECOMPONENT_REGISTER_CONFIGTYPE     if (rA==0) { \\\n\t                                             ConfigInstance *Tdflt = new ConfigInstance( scname, ct, 1 );  \\\n\t\t\t\t\t\t\t\t\t\t\t\t sconfman->registerType(Tdflt); \\\n                                               }\n\n#define SMILECOMPONENT_IFNOTREGAGAIN_BEGIN  if (rA==0) {\n#define SMILECOMPONENT_IFNOTREGAGAIN_END  SMILECOMPONENT_REGISTER_CONFIGTYPE }\n#define SMILECOMPONENT_IFNOTREGAGAIN(__code__) SMILECOMPONENT_IFNOTREGAGAIN_BEGIN __code__ ; SMILECOMPONENT_IFNOTREGAGAIN_END\n\n#define SMILECOMPONENT_MAKEINFO(TP)  if ((rA!=0)&&(ct!=NULL)) delete ct; \\\n\t                                 return makeInfo(sconfman, scname, sdescription, TP::create, rA)\n#define SMILECOMPONENT_MAKEINFO_ABSTRACT(TP) if ((rA!=0)&&(ct!=NULL)) delete ct; \\\n\t                                         return makeInfo(sconfman, scname, sdescription, TP::create, rA, 1, 1)\n\n// make info for non-datamemory components (e.g. the cFunctionalXXXX components), e.g. components that are sub-components of other components\n#define SMILECOMPONENT_MAKEINFO_NODMEM(TP) if ((rA!=0)&&(ct!=NULL)) delete ct; \\\n\t                                       return makeInfo(sconfman, scname, sdescription, TP::create, rA, 0, 1)\n\n// make info for non-datamemory components (e.g. the cFunctionalXXXX components), e.g. components that are sub-components of other components\n#define SMILECOMPONENT_MAKEINFO_NODMEM_ABSTRACT(TP) if ((rA!=0)&&(ct!=NULL)) delete ct; \\\n\t                                                return makeInfo(sconfman, scname, sdescription, TP::create, rA, 1, 1)\n\n\n#undef class\nclass DLLEXPORT cSmileComponent {\n  private:\n    int id_;           // component ID in componentManager\n    int EOI_;          // EOI counter, 0 only in first loop, then +1 for every nonEOI/EOI loop pair\n    int EOIcondition_; // flag that indicates end of input\n                      // i.e. if EOI is 1, myTick should show a different behaviour\n                      //  esp. dataReaders should return right padded matrices, in getMatrix , getNextMatrix etc..\n    int EOIlevel_;   // If set to >= 1, the isEOI will report EOI condition true only if EOI_  == EOIlevel_ ;\n    int paused_; // flag that indicates whether processing (the tick loop) has been paused or is active\n    \n    smileMutex  messageMtx_;\n\n    cComponentManager *compman_;  // pointer to component manager this component instance belongs to\n    cSmileComponent *parent_;     // pointer to parent component (for dataReaders, etc.)\n    char *iname_;   // name of component instance\n    char *cfname_;  // name of config instance associated with this component instance\n\n    // variables used for component profiling\n    int doProfile_, printProfile_;\n    double profileCur_, profileSum_; // exec. time of last tick, exec time total\n    struct timeval startTime_;\n    struct timeval endTime_;\n\n    long lastNrun_;   // the number of Nrun in the last tickloop?\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    cConfigManager *confman_;  // pointer to configManager\n    const char *cname_;        // name of the component (type)\n    const char *description_;  // component description and usage information\n\n    // component state variables\n    int isRegistered_, isConfigured_, isFinalised_, isReady_;\n    int runMe_;\n\n    int manualConfig_;\n    int override_;\n    \n    static sComponentInfo * makeInfo(cConfigManager *_confman,\n                                     const char *_name, const char *_description,\n                                     cSmileComponent * (*create) (const char *_instname),\n                                     int regAgain=0, int _abstract=0, int _nodmem=0);\n\n    // Gets a pointer to the component instance *name via the component manager.\n    cSmileComponent * getComponentInstance(const char * name);\n\n    // Gets the component instance type of the instance *name as string via the component manager.\n    const char * getComponentInstanceType(const char * name);\n\n    // Create a component instance of given type with instance name \"name\" in the component manager.\n    cSmileComponent * createComponent(const char *name, const char *component_type);\n    \n    // Gets the number of components ran during the last tick.\n    long getLastNrun() { return lastNrun_; }\n\n    // Functions to get config values from the config manager from our config instance.\n    // The _f functions internally free the string *name. Use these in conjunction with myvprint()...\n    // NOTE: Yes, this is ineffective. TODO: smile memory manager, and fixed length text buffer which can be reused (can also grow if needed).\n    void * getExternalPointer(const char *name) {\n      if (confman_ != NULL) {\n        return confman_->getExternalPointer(name);\n      } else {\n        return NULL;\n      }\n    }\n    void addExternalPointer(const char *name, void * ptr) {\n      if (confman_ != NULL) {\n        confman_->addExternalPointer(name, ptr);\n      }\n    }\n\n    double getDouble(const char*name) {\n      return confman_->getDouble_f(myvprint(\"%s.%s\",cfname_,name));\n    }\n    double getDouble_f(char*name) {\n      double d = getDouble(name);\n      if (name!=NULL) free(name);\n      return d;\n    }\n\n    int getInt(const char*name) {\n      return confman_->getInt_f(myvprint(\"%s.%s\",cfname_,name));\n    }\n    int getInt_f(char*name) {\n      int d = getInt(name);\n      if (name!=NULL) free(name);\n      return d;\n    }\n\n    const char *getStr(const char*name){\n      return confman_->getStr_f(myvprint(\"%s.%s\",cfname_,name));\n    }\n    const char * getStr_f(char*name) {\n      const char * s = getStr(name);\n      if (name!=NULL) free(name);\n      return s;\n    }\n\n    char getChar(const char*name) {\n      return confman_->getChar_f(myvprint(\"%s.%s\",cfname_,name));\n    }\n    const char getChar_f(char*name) {\n      const char c = getChar(name);\n      if (name!=NULL) free(name);\n      return c;\n    }\n\n    const ConfigValue *getValue(const char*name) {\n      return confman_->getValue_f(myvprint(\"%s.%s\",cfname_,name));\n    }\n    const ConfigValue * getValue_f(char*name) {\n      const ConfigValue * v = getValue(name);\n      if (name!=NULL) free(name);\n      return v;\n    }\n\n    const ConfigValueArr *getArray(const char*name) {\n      return (ConfigValueArr *)(confman_->getValue_f(myvprint(\"%s.%s\",cfname_,name)));\n    }\n    const ConfigValueArr * getArray_f(char*name) {\n      const ConfigValueArr * a = getArray(name);\n      if (name!=NULL) free(name);\n      return a;\n    }\n\n    int getArraySize(const char*name) {\n      return (confman_->getArraySize_f(myvprint(\"%s.%s\",cfname_,name)));\n    }\n    int getArraySize_f(char*name) {\n      int s = getArraySize(name);\n      if (name!=NULL) free(name);\n      return s;\n    }\n\n    int isSet(const char*name) {\n      return (confman_->isSet_f(myvprint(\"%s.%s\",cfname_,name)));\n    }\n    int isSet_f(char*name) {\n      int s = isSet(name);\n      if (name!=NULL) free(name);\n      return s;\n    }\n\n    // Returns 1 if we are in an abort state (user requested abort).\n    int isAbort();\n\n    // Function that is called during initialisation. It should be used to fetch config variables\n    // from the config manager and store them in local variables.\n    // Each derived class is responsible for fetching configuration from confman or setting it manually BEFORE configureInstance is called!\n    virtual void fetchConfig()=0;\n\n    // Functions to be implemented by derived classes:\n\n    // Sets the environment (pointers to parent, component manager, config manager).\n    virtual void mySetEnvironment() { }\n    \n    // Registers the component instance after creation (by the component Manager).\n    virtual int myRegisterInstance(int *runMe=NULL) { return 1; }\n\n    // Configures the component instance. Data-memory levels and level parameters such as T are created and set here.\n    virtual int myConfigureInstance() { return 1; }\n\n    // Finalises the component instance. Data-memory level names (fields and elements) are set here.\n    virtual int myFinaliseInstance() { return 1; }\n\n    // Holds the actual implementation of the tick loop code for the derived component.\n    // This function should return 1 if the component did process data, and 0 otherwise.\n    // If all components return 0 (nothng to process), the component manager will switch\n    // to the EOI (end-of-input) state (or advance to the next tick loop iteration).\n    virtual int myTick(long long t) { return 0; }\n\n    // Called by the component manager when the tick loop is to be paused.\n    // If the component needs to reject the pausing of the tick loop, it should return 0, otherwise always 1!\n    virtual int pauseEvent() { return 1; }\n\n    // Called by the component manager when the tick loop is to be resumed.\n    virtual void resumeEvent() { }\n\n    // Signals EOI to componentManager (theoretically only useful for dataSource components, however we make it accessible to all smile components)\n    // NOTE: you do not need to do this explicitely.. if all components fail, EOI is assumed, then a new tickLoop is started by the component manager\n    // TODO: is this actually used and/or implemented properly?\n    void signalEOI();\n\n    // Checks if the given component message is of type \"msgtype\" (string name).\n    int isMessageType(cComponentMessage *msg, const char * msgtype) {\n      if (msg != NULL) {\n        return (!strncmp(msg->msgtype, msgtype, CMSG_typenameLen));\n      } else {\n        return 0;\n      }\n    }\n\n    // Functions for component message handling.\n    // Note on data synchronisation for messages: The messages can arrive at any time, if\n    // they are sent from another thread. Thus, a mutex is used to prevent collision when\n    // accessing variables from processComponentMessage and the rest of the component code\n    // (especially myTick). The mutex is automatically locked before processComponentMessage\n    // is called, and unlocked afterwards. In the rest of the code, however, lockMessageMemory()\n    // and unlockMessageMemory() must be used.\n\n    // This function is called by the component manager, if there is a new message for this component.\n    // A derived component must override this to receive and process messages.\n    // Do NOT call lockMessageMemory() in this function! The *msg pointer is always valid.\n    // Return value: 0, message was not processed; != 0, message was processed.\n    // The return value will be passed on to the sender (?).\n    // NOTE: the custData pointer in cComponentMessage (as well as the whole cComponentMessage object)\n    //       is valid ONLY until processComponentMessage() returns!\n    //       Thus, you are advised to copy data to local memory\n    // NOTE2: This function is called directly from the context of another component/thread.\n    //        Do NOT do anything here that is time consuming. It will block the other thread\n    //        or the execution of the tick loop. Esp. don't wait here until your own myTick() is called.\n    //        In signle threaded mode this will never happen!\n    //        Always, only accept the message data and put it into a buffer. Process the buffer in myTick()\n    //        or in a background thread.\n    virtual int processComponentMessage(cComponentMessage *msg) { return 0; }\n    \n    // this function forwards the message to the componentMananger and sets the *sender pointer correctly\n    // Return value: 0, message was not processed; != 0, message was processed.\n    // TODO: return value passing for multiple recepients?\n    int sendComponentMessage(const char *recepient, cComponentMessage *msg);\n\n    // Locks the \"message memory\" (variables that are accessed by processComponentMessage).\n    // You must call this function prior to accessing variables you are accessing in processComponentMessage().\n    // Do not use this function in processComponentMessage() itself, though!\n    void lockMessageMemory() { smileMutexLock(messageMtx_); }\n\n    // Unlocks the \"message memory\" (variables that are accessed by processComponentMessage).\n    void unlockMessageMemory() { smileMutexUnlock(messageMtx_); }\n    \n    // Gets the smile time from the component manager (time since start of the system).\n    double getSmileTime();\n\n    // Returns 1 if we are in an end-of-input condition.\n    int isEOI() { \n      return EOIcondition_;\n    }\n\n    // Get the EOI counter, i.e. the number of repeated tick loop sequences.\n    int getEOIcounter() { return EOI_; }\n\n    // Request stopping of processing in tickLoop of component manager.\n    // Calling this will make openSMILE stop the processing.\n    virtual void abort_processing();\n\n  public:\n    // Statics:\n    // these two must be overridden in a base class:\n    //static sComponentInfo * registerComponent(cConfigManager *_confman);\n    //static cSmileComponent * create(const char *_instname);\n    SMILECOMPONENT_STATIC_DECL\n\n    //method for setting config... a base class may implement it with arbirtrary parameters\n    // values set will override those obtained by fetchConfig if override=1\n    // if override=0, then only those which are not set are updated\n    // void setConfig(..., int override=1);\n    int isManualConfigSet() { return manualConfig_; }\n    \n    // Returns whether the tick loop is paused (1) or running (0).\n    int isPaused() { return paused_; }\n\n    // Gets pointer to the associated component manager object,\n    // i.e. the object that created this smile component instance.\n    cComponentManager *getCompMan() { return compman_; }\n\n    // Constructor that creates an instance of this component with instance name \"instname\".\n    cSmileComponent(const char *instname);  \n    \n    // Sets component info after component creation, and calls fetchConfig.\n    //  Pointer to config manager, component name and description\n    virtual void setComponentInfo(cConfigManager *cm, const char *cname, const char *description) {\n      confman_ = cm;\n      cname_= cname;\n      description_ = description;\n      if (cm != NULL) fetchConfig();\n    }\n    \n    // Sets component manager pointer and the component ID, as used by the component manager.\n    // Called by the creator component (parent) or directly by the component manager.\n    virtual void setComponentEnvironment(cComponentManager *compman, int id, cSmileComponent *parent=NULL);\n    \n    // Sets the name of the associated config instance this component instance is linked to.\n    void setConfigInstanceName(const char *cfname) {\n      if (cfname != NULL) {\n        if ((cfname_ != NULL) && (cfname_ != iname_)) {\n          free(cfname_);\n          cfname_ = NULL;\n        }\n        cfname_ = strdup(cfname);\n      }\n    }\n\n    // Gets the name of the associated config instance.\n    const char * getConfigInstanceName() {\n      return cfname_;\n    }\n\n    // Performs component specific register operation, e.g. write/read requests with dataMemory..\n    // *runMe return value for component manager : 0, don't call my tick of this component, 1, call myTick\n    int registerInstance(int *runMe=NULL) {\n      if (runMe != NULL) *runMe = runMe_;\n      if (isRegistered_) return 1;\n      isRegistered_ = myRegisterInstance(runMe);\n      if (runMe != NULL) runMe_ = *runMe;\n      return isRegistered_;\n    }\n    int isRegistered() { return isRegistered_; }\n\n    // Performs component configuration (data memory level configuration, creation of readers/writers etc.).\n    int configureInstance() {\n      if (isConfigured_) return 1;\n      isConfigured_ = myConfigureInstance();\n      return isConfigured_;\n    }\n    int isConfigured() { return isConfigured_; }\n\n    // Performs component finalisation (loading of models, opening of files, data memory level names, ...).\n    int finaliseInstance();\n    int isFinalised() { return isFinalised_; }\n\n    // Returns 1, if component has been finalised and is ready for the tick loop. Returns 0 otherwise.\n    int isReady() { return isReady_; }\n\n    // The tick() function. This is called by the component manager, and internally executes myTick(),\n    int tick(long long t, int EOIcond=0, long _lastNrun=-1) {\n      lastNrun_ = _lastNrun;\n      if (EOIcond) {\n        if (!isEOI()) {\n          setEOI();\n          return 1; // one \"successful\" tick to set up all components in EOI state\n        }\n      } else {\n        unsetEOI();\n      }\n      if (isReady_) {\n        if (doProfile_) {\n          startProfile(t, EOIcondition_);\n        }\n        int ret = myTick(t);\n        if (doProfile_) {\n          endProfile(t, EOIcondition_);\n        }\n        return ret;\n      }\n      else return 0;\n    }\n    \n    // Configures profiling (measuring of the time spent in each tick).\n    void setProfiling(int enable=1, int print=0) {\n      doProfile_ = enable;\n      printProfile_ = print;\n    }\n\n    // Starts time measurement (called at the beginning of the tick).\n    void startProfile(long long t, int EOI);\n\n    // Ends time measurement (called at the end of the tick).\n    void endProfile(long long t, int EOI);\n\n    // Gets the current profiling statistics.\n    // If sum == 1, it returns the accumulated run-time in seconds\n    // (i.e. the time spent in tick() by this component).\n    // If sum == 0, the duration of the last tick() is returned.\n    // NOTE: For multi-threaded code this method of profiling is not exact.\n    //       The tick() function can be interrupted by other threads, but\n    //       time measurement is done via the system timer from start to end of tick().\n    double getProfile(int sum=1) { \n      if (!sum) return profileCur_;\n      else return profileSum_;\n    }\n\n    // Gets the component instance name.\n    const char *getInstName() const {\n      return iname_;\n    }\n\n    // Gets the component type name.\n    const char *getTypeName() const {\n      return cname_;\n    }\n\n    // Sets the EOI counter. Used by the component manager once a new tick loop with EOIcondition=1 starts.\n    // NOTE: it would be possible for the components to manage their own EOI counters, however, like this we ensure sync and better performance.\n    // If derived components create sub-components internally (without tick function - e.g. dataReaders/Writers),\n    // they must override this, in order to properly set the EOI status in the sub-components.\n    virtual int setEOIcounter(int cnt) {\n      EOI_ = cnt;\n      return cnt;\n    }\n\n    // Sets and unsets the EOIcondition variable. This is called internally from tick() only.\n    // If derived components create sub-components internally (without tick function - e.g. dataReaders/Writers),\n    // they must override this, in order to properly set the EOI status in the sub-components.\n    virtual void setEOI() {\n      EOIcondition_ = 1;\n    }\n    virtual void unsetEOI() {\n      EOIcondition_ = 0;\n    }\n\n    virtual void setEOIlevel(int level) {\n      EOIlevel_ = level;\n    }\n    virtual int EOIlevelIsMatch() {\n      if (EOIlevel_ == EOI_ || EOIlevel_ <= 0) {\n        return 1;\n      }\n      return 0;\n    }\n    virtual int getEOIlevel() {\n      return EOIlevel_;\n    }\n\n    // Called by the component manager. Notifies this component about a tick loop pause.\n    virtual int pause() {\n      if (!paused_) {\n        paused_ = 1; \n        return pauseEvent();\n      }\n      return 1;\n    }\n\n    // Called by the component manager. Notifies this component about a tick loop resume.\n    virtual void resume() { \n      if (paused_) {\n        paused_ = 0; \n        resumeEvent();\n      }\n    }\n\n    // This function is called externally by the component manager,\n    //   if another component calls sendComponentMessage.\n    // It receives the message, takes care of memory access synchronisation, and processes the message.\n    int receiveComponentMessage(cComponentMessage *msg) {\n      int ret = 0;\n      if (msg != NULL)  {\n        lockMessageMemory();\n        ret = processComponentMessage(msg);\n        unlockMessageMemory();\n      }\n      return ret;\n    }\n\n    virtual ~cSmileComponent();\n};\n\n#endif //__SMILE_COMPONENT_HPP\n"
  },
  {
    "path": "src/include/core/smileLogger.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/******************************************************************************/\n\n /*\n\n openSMILE Message Logging\n\n\nLog Levels for Messages:\n0 . important messages, always displayed\n1 . informative messages concerning functionality\n2 . program status information (what we are currently doing, not very detailed though)\n3 . more detailed status, report on success of operations\n4 . component initialisation messages\n\nLog Levels for Debug Messages:\n0.  only very obvious information, status, etc.\n1.\n2.  warnings\n3.  detailed information (not in internal loops)\n4.\n5.  detailed information from internal loops (e.g. every line from config file)\n6.  extended details in internal loops\n\n\nLog Levels for Errors:\n\n\nLog Levels for Warnings:\n\n\n\n\n\n */\n\n\n#ifndef __SMILE_LOGGER_HPP\n#define __SMILE_LOGGER_HPP\n\n#include <core/smileCommon.hpp>\n#ifdef __ANDROID__\n#include <android/log.h>\n#endif\n\n#define LOG_ALL     0\n#define LOG_MESSAGE 1\n#define LOG_WARNING 2\n#define LOG_ERROR   3\n#define LOG_DEBUG   4\n#define LOG_PRINT   5\n\n#undef class\nclass DLLEXPORT cSmileLogger {\n  private:\n    smileMutex logmsgMtx;\n    char * logfile;\n    FILE * logf;\n    int stde;    // flag that indicates wheter stderr output is enabled or not\n    int silence; // if set, logger will NOT produce ANY output!\n    int _enableLogPrint;  // set, if you want log messages ('print') to be duplicated to the logfile\n    int ll_msg;\n    int ll_wrn;\n    int ll_err;\n    int ll_dbg;\n\n    char *msg;  // current log message\n\n    void openLogfile(int append=0);\n    void closeLogfile();\n\n    // formating of log message, save result in msg\n    void fmtLogMsg(const char *type, char *t, int level, const char *m);\n\n    // write a log message in *msg to current logfile (if open)\n    // add a date- and timestamp to message\n    void writeMsgToFile(int pr=0);\n\n    // print message to console , without a timestamp\n    void printMsgToConsole();\n\n    // main log message dispatcher\n    void logMsg(int itype, char *s, int level, const char *m);\n\n  public:\n    cSmileLogger(int _loglevel=0, const char *_logfile=NULL, int _append=0);  // logfile == NULL: output to stderr\n                                                             // loglevel is the OVERALL loglevel\n    cSmileLogger(int loglevel_msg, int loglevel_wrn, int loglevel_err, int loglevel_dbg, const char *logfile=NULL, int _append=0);\n    ~cSmileLogger();\n\n    void setLogLevel(int level);\n    void setLogLevel(int type, int level);\n    void setLogFile(char *file, int _append = 0, int _stde=0);\n    void setLogFile(const char *file, int _append = 0, int _stde=0);\n\n    int getLogLevel_msg() { return ll_msg; }\n    int getLogLevel_wrn() { return ll_wrn; }\n    int getLogLevel_err() { return ll_err; }\n    int getLogLevel_dbg() { return ll_dbg; }\n    \n    void enableLogPrint() { _enableLogPrint = 1; } // enable printing of 'print' messages to log file (they are by default only written to the console)\n    void enableConsoleOutput() { stde=1; }    // enable printing of log messages to console, even if a logfile is specified\n    void muteLogger() { silence=1; }  // surpress all log messages\n    void unmuteLogger() { silence=0; }  // back to normal logging\n\n\n    /* similar to message, only that no formatting is performed and no extra information is printed\n       the messages also do NOT go to the logfile by default (except, the enableLogPrint is set)\n    */\n\t\tvoid log(int type, char *s, int level=0, const char *module=NULL)\n\t\t      { logMsg(type,s,level,module); }\n\n\t\tvoid print(char *s, int level=0)\n\t\t  { logMsg(LOG_PRINT,s,level,NULL); }\n\n\t\tvoid message(char *s, int level=0, const char *module=NULL)\n\t\t  { logMsg(LOG_MESSAGE,s,level,module); }\n\n\t\tvoid warning(char *s, int level=0, const char *module=NULL)\n\t\t  { logMsg(LOG_WARNING,s,level,module); }\n\n\t\tvoid error(char *s, int level=0, const char *module=NULL)\n\t\t  { logMsg(LOG_ERROR,s,level,module); }\n\n    #ifdef DEBUG\n    void debug(char *s, int level=0, const char *module=NULL)\n      { logMsg(LOG_DEBUG,s,level,module); }\n    #else\n    void debug(char *s, int level=0, const char *module=NULL) { if (s!=NULL) free(s); }\n    #endif\n};\n\n// Global logger variable (used by exception classes for automatically logging...)\n#define LOGGER   smileLog\n#define SMILE_LOG_GLOBAL smileLog\nextern DLLEXPORT cSmileLogger SMILE_LOG_GLOBAL;\n\n\n// The \"I\" logger functions (e.g. SMILE_IMSG) are meant to be used within cSmileComponent descendants. They will print the actual instance name instead of the component name\n#ifdef SMILE_LOG_GLOBAL\n#define SMILE_PRINT(...) SMILE_LOG_GLOBAL.print(FMT(__VA_ARGS__))\n\n#define SMILE_PRINTL(level, ...) { if (level <= SMILE_LOG_GLOBAL.getLogLevel_msg()) SMILE_LOG_GLOBAL.print(FMT(__VA_ARGS__), level); }\n\n#define SMILE_MSG(level, ...) { if (level <= SMILE_LOG_GLOBAL.getLogLevel_msg()) SMILE_LOG_GLOBAL.message(FMT(__VA_ARGS__), level, MODULE); }\n\n#define SMILE_IMSG(level, ...) { if (level <= SMILE_LOG_GLOBAL.getLogLevel_msg()) { char *__mm = FMT(\"instance '%s'\",getInstName()); SMILE_LOG_GLOBAL.message(FMT(__VA_ARGS__), level, __mm); free(__mm); } }\n\n#define SMILE_ERR(level, ...) { if (level <= SMILE_LOG_GLOBAL.getLogLevel_err()) SMILE_LOG_GLOBAL.error(FMT(__VA_ARGS__), level, MODULE); }\n#define SMILE_IERR(level, ...) { if (level <= SMILE_LOG_GLOBAL.getLogLevel_err()) { char *__mm = FMT(\"instance '%s'\",getInstName()); SMILE_LOG_GLOBAL.error(FMT(__VA_ARGS__), level, __mm); free(__mm); } }\n\n#define SMILE_WRN(level, ...) { if (level <= SMILE_LOG_GLOBAL.getLogLevel_wrn()) SMILE_LOG_GLOBAL.warning(FMT(__VA_ARGS__), level, MODULE); }\n#define SMILE_IWRN(level, ...) { if (level <= SMILE_LOG_GLOBAL.getLogLevel_wrn()) { char *__mm = FMT(\"instance '%s'\",getInstName()); SMILE_LOG_GLOBAL.warning(FMT(__VA_ARGS__), level, __mm); free(__mm); } }\n\n/*\n#define SMILE_PRINTL(level,rest...) SMILE_LOG_GLOBAL.print(FMT(rest), level)\n#define SMILE_MSG(level, rest...) SMILE_LOG_GLOBAL.message(FMT(rest), level, MODULE)\n#define SMILE_IMSG(level, rest...) SMILE_LOG_GLOBAL.message(FMT(rest), level, FMT(\"instance '%s'\",getInstName()))\n#define SMILE_ERR(level, rest...) SMILE_LOG_GLOBAL.error(FMT(rest), level, MODULE)\n#define SMILE_IERR(level, rest...) SMILE_LOG_GLOBAL.error(FMT(rest), level, FMT(\"instance '%s'\",getInstName()))\n#define SMILE_WRN(level, rest...) SMILE_LOG_GLOBAL.warning(FMT(rest), level, MODULE)\n#define SMILE_IWRN(level, rest...) SMILE_LOG_GLOBAL.warning(FMT(rest), level, FMT(\"instance '%s'\",getInstName()))\n*/\n\n#ifdef DEBUG\n#define SMILE_DBG(level, ...) { if (level <= SMILE_LOG_GLOBAL.getLogLevel_dbg()) SMILE_LOG_GLOBAL.debug(FMT(__VA_ARGS__), level, MODULE); }\n#define SMILE_IDBG(level, ...) { if (level <= SMILE_LOG_GLOBAL.getLogLevel_dbg()) { char *__mm = FMT(\"instance '%s'\",getInstName()); SMILE_LOG_GLOBAL.debug(FMT(__VA_ARGS__), level, __mm); free(__mm); } }\n\n/*\n#define SMILE_DBG(level, rest...) SMILE_LOG_GLOBAL.debug(FMT(rest), level, MODULE)\n#define SMILE_IDBG(level, rest...) SMILE_LOG_GLOBAL.debug(FMT(rest), level, FMT(\"instance '%s'\",getInstName()))\n*/\n\n#else\n#define SMILE_DBG(level, ...)\n#define SMILE_IDBG(level, ...)\n#endif\n#else\n#define SMILE_PRINT(...)\n#define SMILE_PRINTL(level, ...)\n#define SMILE_MSG(level, ...)\n#define SMILE_IMSG(level, ...)\n#define SMILE_ERR(level, ...)\n#define SMILE_IERR(level, ...)\n#define SMILE_WRN(level, ...)\n#define SMILE_IWRN(level, ...)\n#define SMILE_DBG(level, ...)\n#define SMILE_IDBG(level, ...)\n#endif\n\n\n#endif // __SMILE_LOGGER_HPP\n"
  },
  {
    "path": "src/include/core/smileTypes.h",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE type definitions */\n\n\n#ifndef __SMILE_TYPES_H\n#define __SMILE_TYPES_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifdef HAVE_CONFIG_H\n#include <config.h>\n#endif\n\n/* int types, platform independent (hopefully...) */\n#ifdef HAVE_INTTYPES_H  // prefer inttypes.h if available\n#include <inttypes.h>\n#else\n#ifdef _MSC_VER // Visual Studio specific macro, use MSVC built-in int types\ntypedef unsigned __int8 uint8_t;\ntypedef unsigned __int16 uint16_t;\ntypedef unsigned __int32 uint32_t;\ntypedef unsigned __int64 uint64_t;\ntypedef signed __int8 int8_t;\ntypedef signed __int16 int16_t;\ntypedef signed __int32 int32_t;\ntypedef signed __int64 int64_t;\n#else\n#ifdef __WINDOWS  // UINT8, etc., constants should be defined in Windows Platform SDK 2003\ntypedef UINT8 uint8_t ;\ntypedef UINT16 uint16_t ;\ntypedef UINT32 uint32_t ;\ntypedef UINT64 uint64_t ;\ntypedef INT8 int8_t ;\ntypedef INT16 int16_t ;\ntypedef INT32 int32_t ;\ntypedef INT64 int64_t ;\n#else\n#ifdef __ANDROID__\ntypedef unsigned char uint8_t ;\ntypedef unsigned short uint16_t;\ntypedef unsigned int uint32_t;\ntypedef signed char int8_t;\ntypedef signed short int16_t;\ntypedef signed int int32_t;\n#else  // last resort, use C standards.. warning, int is not very portable, also long long, etc...\ntypedef unsigned char uint8_t ;\ntypedef unsigned short uint16_t;\ntypedef unsigned int uint32_t;\ntypedef unsigned long int uint64_t;\ntypedef signed char int8_t;\ntypedef signed short int16_t;\ntypedef signed int int32_t;\ntypedef signed long int int64_t;\n#endif\n#endif\n#endif\n\n#endif\n\n#include <float.h>\n/* opensmile internal types */\n#define FLOAT_DMEM_FLOAT  0\n#define FLOAT_DMEM_DOUBLE  1\n\n\n// this defines the float type used throughout the data memory, either 'float' or 'double'\ntypedef float FLOAT_DMEM;\n#define FLOAT_DMEM_NUM  FLOAT_DMEM_FLOAT // this numeric constant MUST equal the float type set above ...\n                                           // 0 = float, 1 = double:\n#define FLOAT_DMEM_MAX FLT_MAX\n#define FLOAT_DMEM_MIN FLT_MIN\n\n\n// this defines the int type used throughout the data memory, either 'short', 'int' or 'long'\ntypedef int INT_DMEM;\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif // __SMILE_TYPES_H\n\n"
  },
  {
    "path": "src/include/core/svn_version.hpp",
    "content": "#define OPENSMILE_SOURCE_REVISION \"2014:2043\"\n#define OPENSMILE_BUILD_BRANCH \"opensmile-2.3.0\"\n#define OPENSMILE_BUILD_DATE \"UNKNOWN-BUILD-DATE\"\n"
  },
  {
    "path": "src/include/core/vecToWinProcessor.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nreads in frames , outputs windows\n*/\n\n\n#ifndef __CVECTOWINPROCESSOR_HPP\n#define __CVECTOWINPROCESSOR_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataProcessor.hpp>\n#include <dspcore/windower.hpp>\n\n#define COMPONENT_DESCRIPTION_CVECTOWINPROCESSOR \"Base class: reads in frames , outputs windows\"\n#define COMPONENT_NAME_CVECTOWINPROCESSOR \"cVecToWinProcessor\"\n\nstruct sVecToWinProcessorOla\n{\n  double * norm;\n  FLOAT_DMEM * buffer;\n  long bufferPtr;\n  long bufferReadPtr;\n  long buffersize;\n  double overlap;\n  long framelen;\n};\n\n\n#undef class\nclass DLLEXPORT cVecToWinProcessor : public cDataProcessor {\n  private:\n    \n    int   dtype;     // data type (DMEM_FLOAT, DMEM_INT)\n    int   noPostEOIprocessing;\n    int   processArrayFields;\n    int   normaliseAdd;\n    int   useWinAasWinB;\n    FLOAT_DMEM gain;\n\n    long Nfi;\n    long No;\n\n    cWindower * ptrWinA;\n    cWindower * ptrWinB;\n\n    long inputPeriodS;\n    double inputPeriod;\n    double samplePeriod;\n    \n    int hasOverlap;\n    struct sVecToWinProcessorOla * ola;\n\n    cMatrix *mat;\n\n  protected:\n\n    SMILECOMPONENT_STATIC_DECL_PR\n    double getInputPeriod(){ return inputPeriod; }\n    double getSamplePeriod(){ return samplePeriod; }\n\n    long getNfi() { return Nfi; } // number of fields\n    \n\n    virtual void fetchConfig();\n    //virtual int myFinaliseInstance();\n    //virtual int myConfigureInstance();\n    virtual int dataProcessorCustomFinalise();\n    virtual int myTick(long long t);\n\n    virtual int configureWriter(sDmLevelConfig &c);\n    //virtual int setupNamesForElement(int idxi, const char*name, long nEl);\n    //virtual int setupNamesForField(int idxi, const char*name, long nEl);\n\n    void initOla(long n, double _samplePeriod, double _inputPeriod, int idx);\n    void computeOlaNorm(long n, int idx);\n    double * getWindowfunction(cWindower *_ptrWin, long n, int *didAlloc = NULL);\n    //void setOlaBuffer(long i, long j, FLOAT_DMEM val);\n    void setOlaBufferNext(long idx, FLOAT_DMEM val);\n    int flushOlaBuffer(cMatrix *mat);\n    \n    virtual int doProcess(int i, cMatrix *row, FLOAT_DMEM*x);\n    virtual int doProcess(int i, cMatrix *row, INT_DMEM*x);\n    virtual int doFlush(int i, FLOAT_DMEM*x);\n    virtual int doFlush(int i, INT_DMEM*x);\n    \n\n    //virtual int processComponentMessage( cComponentMessage *_msg );\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cVecToWinProcessor(const char *_name);\n\n    virtual ~cVecToWinProcessor();\n};\n\n\n\n\n#endif // __CVECTOWINPROCESSOR_HPP\n"
  },
  {
    "path": "src/include/core/vectorProcessor.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nvector Processor :  (abstract class only)\n       specialised dataProcessor, which takes one frame as input an produces one frame as output\n       however, each array field is processed individually as a vector\n       for each field the output dimension can be set in derived components\n\n*/\n\n\n#ifndef __VECTOR_PROCESSOR_HPP\n#define __VECTOR_PROCESSOR_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CVECTORPROCESSOR \"dataProcessor, where each array field is processed individually as a vector\"\n#define COMPONENT_NAME_CVECTORPROCESSOR \"cVectorProcessor\"\n\n#undef class\nclass DLLEXPORT cVectorProcessor : public cDataProcessor {\n  private:\n    long Nfi, Nfo, Ni, No;\n    long *fNi, *fNo;\n    cVector * vecO;\n\n    int includeSingleElementFields;\n\t  int processArrayFields;\n    int preserveFieldNames;\n    //mapping of field indicies to config indicies: (size of these array is maximum possible size: Nfi)\n    int Nfconf;\n    int *fconf, *fconfInv;\n    long *confBs;  // blocksize for configurations\n\n    int addFconf(long bs, int field); // return value is index of assigned configuration\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    int getProcessArrayFields() { return processArrayFields; }\n\n    /*\n      since a vector processor can process individual fields of a vector seperately,\n      these fields might require different configuration and thus different internal variables/parameters.\n      this is especially true for things like state variables, histories, etc.\n      THUS, you must use the following functions to allocate arrays, holding multiple variants\n      of your configuration/state/etc. variables, one for each field.\n    */\n\n    // (input) field configuration, may be used in setupNamesForField\n    int getFconf(int field) { return fconf[field]; } // caller must check for return value -1 (= no conf available for this field)\n    /* get number of fields of input vector (matched number of fields in output vector) */\n    int getNf() { \n      if (!processArrayFields) return 1;\n      else return reader_->getLevelNf(); // return Nfi; ??? \n    }\n\n    /* free an array of pointers to configuration variables */\n    void multiConfFree( void * x );\n    /* free only a single value array allocated by multiConfAllocLong/Float() */\n    void multiConfFree1D( void * x ) {\n      if (x != NULL) free(x);\n    }\n\n\n    /* allocate an array of N (=num. fields=) pointers for storing multiple configurations */\n    void *multiConfAlloc() {\n      return calloc(1,sizeof(void*)*getNf());\n    }\n    /* allocate only single value arrays for type long for float */\n    long *multiConfAllocLong() {\n      return (long*)calloc(1,sizeof(long)*getNf());\n    }\n    FLOAT_DMEM *multiConfAllocFloat() {\n      return (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*getNf());\n    }\n    \n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n    virtual int dataProcessorCustomFinalise();\n\n    //virtual int configureWriter(sDmLevelConfig &c);\n\n    /* cVectorProcessor::myTick calls customVecProcess at the beginning, giving the vector processor a\n       chance to access and process the raw vector data.  */\n    virtual int customVecProcess(cVector *vecIn, cVector* vecOut) {\n      if (vecIn == NULL) {\n        // do flushing here if no new input\n        // ...\n        // return 1;\n        // or return that we've done nothing:\n        return 0;\n      }\n      // return value of 1 means that we have processed data,\n      // process vector float will not be called in this case!\n      // return 1;\n      // A return value of 0 means that we have done nothing, or only modified incoming data\n      // processVectorFloat on fields etc. will still be called!\n      return 0;\n    }\n    \n    //virtual void configureField(int idxi, long __N, long nOut);\n    //virtual int setupNamesForField(int i, const char*name, long nEl);\n\n    /* these functions process an input vector and produce an output vector\n       by default for each field in the input vector processVectorX will be called\n       with the field index in idxi, the field data in *src, the number of elements in the field in Nsrc \n       in this case for each input field a corresponding output field exists\n       IF the option processArrayFields is set to 0, then the full input and output vector is passed\n       to processVectorX and processVectorX is only called once per vector (idxi = 0)*/\n    virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n    /* these methods are called at the end of processing (end-of-input) to allow the component\n       to flush data, save final results to files, etc. \n       you should also use these functions for components that collect data/statistics over the\n       full input, instead of doing incremental processing */\n    virtual int flushVectorInt(INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int flushVectorFloat(FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    \n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cVectorProcessor(const char *_name);\n\n    virtual ~cVectorProcessor();\n};\n\n\n\n\n#endif // __VECTOR_PROCESSOR_HPP\n"
  },
  {
    "path": "src/include/core/vectorTransform.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\ncompute gliding mean of input vectors and subtract it from the vectors\n(used for cepstral mean subtraction (CMS), for example)\n\n*/\n\n\n#ifndef __CVECTORTRANSFORM_HPP\n#define __CVECTORTRANSFORM_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n#include <math.h>\n\n#define COMPONENT_DESCRIPTION_CVECTORTRANSFORM \"this is a base class for vector transforms which require history data or precomputed data (e.g. cepstral mean subtraction, etc.)\"\n#define COMPONENT_NAME_CVECTORTRANSFORM \"cVectorTransform\"\n\n/* available mean update methods */\n#define UPDMETHOD_NUL   0  /* only inital values */\n#define UPDMETHOD_EXP   1  /* exponentially decaying mean */\n#define UPDMETHOD_FIX   2  /* fixed buffer */\n#define UPDMETHOD_AVG   3  /* weighted sum: incremental average and w. inital mean */\n#define UPDMETHOD_AVGI  4  /* weighted sum: incremental average and w. inital mean (incl. mean update) */\n#define UPDMETHOD_FIXI   6  /* fixed buffer */\n#define UPDMETHOD_USR   100  /* user defined, set by child class */\n\n/* operation modes */\n#define MODE_ANALYSIS       1\n#define MODE_TRANSFORMATION 2\n#define MODE_INCREMENTAL    0   /* transformation and analysis (incremental updates) */\n\n/* header of transform data file (see .cpp for more info on file formats) */\n/*\nC) advanced smile transformation format: Binary\n   (note: this format is used interally)\n  Header: \n    Magic     (int32)  0xEE 0x11 0x11 0x00\n    N vectors (int32)\n    N groups  (int32)\n    N timeunits(int32)\n    Vecsize   (int32)\n    N userData(int32)\n    TypeID    (int32)  [defined in the header file of the component implementing the transform]\n    Reserved  (16 byte)\n  User data : N userData (double)\n  Matrix data: N vec x Vecsize (double, 8 byte)\n*/\nstruct sTfHeader {\n  unsigned char magic[4];\n  int32_t nVec;\n  int32_t nGroups;\n  int64_t nTimeunits;  // e.g. for cummulative averages: number of values, etc.\n  int32_t vecSize;\n  int32_t nUserdata;  /* additional data besides parameter vectors */\n  int32_t typeID; /* ID describing data loaded, e.g. MVN data, HEQ data, CMS, ... */\n  unsigned char reserved[16]; /* reserved for future extension, should be zeroe'd */\n  /* user data:  nUserdata x sizeof(double) */\n  /* matrix data:  nVec x vecSize x sizeof(double) */\n};\n\n/* struct for storing transformation data */\nstruct sTfData {\n  struct sTfHeader head;\n  double * userData;  /* this can be NULL if no user data is present, i.e. when nUserdata = 0 */\n  double * vectors;   /* this can be NULL if only userData is present and no vectors (nVec = 0) */\n  /* NOTE: at least one of the two above pointers must be != NULL */\n  void * user;  /* optional workspace data, if required by child classes */\n};\n\nconst unsigned char smileMagic[] = {(char)0xEE, (char)0x11, (char)0x11, (char)0x00};\n\n/* we define some transform type IDs here, other will be defined in child classes */\n#define TRFTYPE_MNN     10    /* mean normalisation, mean vector only */\n#define TRFTYPE_MVN     20    /* mean variance normalisation, mean vector + stddev vector */\n#define TRFTYPE_MRN     21    /* mean and range normalisation, mean vector + min & max vector */\n#define TRFTYPE_UNDEF    0    /* undefined, un-initialized */\n#define TRFTYPE_USR      1    /* user-defined, reserved */\n\n// #define TRFTYPE_HEQ   101  // --> defined in vectorHEQ.hpp\n\n#undef class\nclass DLLEXPORT cVectorTransform : public cVectorProcessor {\n  private:\n    const char * initFile;\n    const char * saveFile;\n    int err, flushed;\n\n    int invertMVNdata;\n    int zeroThIsLast; // flag that indicates wheter last coeff in initFile is loaded into means[0]\n    int skipNfirst;\n\n    double fixedBuffer;\n    \n    const char * turnStartMessage;  // name of turnStartMessage\n    const char * turnEndMessage;    // name of turnEndMessage\n\n    struct sTfData transform0;   // initial transform as loaded from file\n    struct sTfData transform;    // current (computed/updated) transform\n\n    int loadHTKCMNdata(const char *filename, struct sTfData  * tf);\n    int loadMVNtextdata(const char *filename, struct sTfData  * tf);\n    int loadMVNdata(const char *filename, struct sTfData  * tf);\n    int loadSMILEtfData(const char *filename, struct sTfData  * tf);\n\n    void checkDstFinite(FLOAT_DMEM *dst, long N) { // check for nan/inf in output\n      int ret = checkVectorFinite(dst,N);\n      if (ret==0) SMILE_IERR(2,\"Non-finite #INF# or #NAN# value encountered in output (This value is now automatically set to 0, but somewhere there is a bug)!\");\n    }\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    int updateMethod;\n    int mode;\n\n    FLOAT_DMEM alpha, weight;\n    long fixedBufferFrames;\n    long nFrames;\n\n    FLOAT_DMEM * buffer; /* ring-buffer for sums or values (depending on update method) */\n    long *bufferNframes; /* ring-buffer of number of frames (update method 'avg'), same size as buffer, same r/w pointers */\n    long nAvgBuffer; /* currently present number of elements in above ring buffer */\n    long wPtr, rPtr; /* write and read pointers, real indicies */\n\n    int turnOnlyNormalise, turnOnlyOutput;\n    int invertTurn;\n    int resetOnTurn;\n    int turnOnlyUpdate;\n    \n    int isTurn, resetMeans;\n\n    void prepareUnstandardise(struct sTfData * tf);\n\n    /* loads data, the format (HTK, old MVN, smile native) is determined automatically */\n    int loadTransformData(const char * filename, struct sTfData * tf);\n    \n    /* saves transform data in smile native format,\n       other formats are not supported and will not be supported */\n    int saveTransformData(const char * filename, struct sTfData * tf); \n\n    /* free the vectors and user data */\n    void freeTransformData(struct sTfData * tf); \n    \n    /* returns a pointer to the internal (private) transform data struct */\n    struct sTfData * getTransformData() { return &transform; }\n\n    /* returns a pointer to the internal (private) initial transform data struct */\n    struct sTfData * getTransformInitData() { return &transform0; }\n\n    virtual void initTransform(struct sTfData *tf, struct sTfData *tf0);\n\n    /**** refactoring hooks ****/\n    /* to modify or validate the initial transform directly aafter it has been loaded from a file,\n       overwrite this method */\n    virtual void modifyInitTransform(struct sTfData *tf0) {}\n    /* allocate the memory for vectors and userData, initialise header\n       the only field that has been set is head.vecSize ! \n       This function is always called and should always allocate memory, even if data was loaded */\n    virtual void allocTransformData(struct sTfData *tf, int Ndst, int idxi) = 0;\n    /* For mode == ANALYSIS or TRANSFORMATION, this functions allows for a final processing step\n       at the end of input and just before the transformation data is saved to file */\n    virtual void computeFinalTransformData(struct sTfData *tf, int idxi) {}\n    /* this will be called BEFORE the transform will be reset to initial values (at turn beginning/end) \n       you may modify the initial values here or the new values, \n       if you return 1 then no further changes to tf will be done,\n       if you return 0 then tf0 will be copied to tf after running this function */\n    virtual int transformResetNotify(struct sTfData *tf, struct sTfData *tf0) { return 0; }\n\n    /* this method is called after a transform (re-)init. Data from tf0 (if available) has already \n       been copied to tf once this function is called */\n    virtual void transformInitDone(struct sTfData *tf, struct sTfData *tf0) {  }\n\n    /* you may override this, if you want to modify the management of the ringbuffer! */\n    virtual void updateRingBuffer(const FLOAT_DMEM *src, long Nsrc);\n\n    /* Do the actual transformation (do NOT use this to calculate parameters!) \n       This function will only be called if not in ANALYSIS mode \n       Please return the number of output samples (0, if you haven't produced output) */\n    virtual int transformDataFloat(const struct sTfData * tf, const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) = 0;\n    //virtual int transformDataInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n    /* Update transform parameters incrementally\n       This function will only be called if not in TRANSFORMATIONs mode \n       *buf is a pointer to a buffer if updateMethod is fixedBuffer */\n    // return value: 0: no update was performed , 1: successfull update\n    virtual int updateTransformFloatExp(struct sTfData * tf, const FLOAT_DMEM *src, int idxi) { return 0; }\n    virtual int updateTransformFloatBuf(struct sTfData * tf, const FLOAT_DMEM *src, FLOAT_DMEM *buf, long Nbuf, long wrPtr, int idxi) { return 0; }\n    virtual int updateTransformFloatAvg(struct sTfData * tf, const FLOAT_DMEM *src, int idxi) { return 0; }\n    virtual int updateTransformFloatAvgI(struct sTfData * tf, const FLOAT_DMEM *src, FLOAT_DMEM *buf, long * _bufferNframes, long Nbuf, long wrPtr, int idxi) { return 0; }\n\n    /* generic method, default version will select one of the above methods,\n       overwrite to implement your own update strategy ('usr' option) */\n    virtual int updateTransformFloat(struct sTfData * tf, const FLOAT_DMEM *src, FLOAT_DMEM *buf, long * _bufferNframes, long Nbuf, long wrPtr, int idxi);\n\n/////////////////////////////////////////////\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    //virtual int myTick(long long t);\n\n    virtual int configureWriter(sDmLevelConfig &c);\n\n    virtual int processComponentMessage( cComponentMessage *_msg );\n    //virtual int setupNamesForField(int i, const char*name, long nEl);\n    //virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int flushVectorFloat(FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cVectorTransform(const char *_name);\n\n    virtual ~cVectorTransform();\n};\n\n\n\n\n#endif // __CVECTORTRANSFORM_HPP\n"
  },
  {
    "path": "src/include/core/versionInfo.hpp",
    "content": "\n#ifndef __CORE_VERSION_INFO_HPP\n#define __CORE_VERSION_INFO_HPP\n\n#define APPNAME  \"openSMILE\"\n#define APPVERSION \"2.3.0\"\n//#define APPVERSION  \"svn-internal\"\n#include <core/svn_version.hpp>\n#define APPCPAUTHOR   \"audEERING GmbH\"\n#define APPCPYEAR \"2014-2016\"\n#define APPDATE \"28 Oct 2016\"\n#define APPCPINST  \"Lead author: Florian Eyben\"\n#define NEWLINE \"\\n\"\n\n#ifndef OPENSMILE_BUILD_BRANCH\n#define OPENSMILE_BUILD_BRANCH \"unknown\"\n#endif\n#ifndef OPENSMILE_BUILD_DATE\n#define OPENSMILE_BUILD_DATE \"unknown\"\n#endif\n#ifndef OPENSMILE_SOURCE_REVISION\n#define OPENSMILE_SOURCE_REVISION \"unknown\"\n#endif\n\n#endif  // __CORE_VERSION_INFO_HPP\n"
  },
  {
    "path": "src/include/core/winToVecProcessor.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nreads in windows and outputs vectors (frames)\n\n*/\n\n\n#ifndef __CWINTOVECPROCESSOR_HPP\n#define __CWINTOVECPROCESSOR_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CWINTOVECPROCESSOR \"reads input windows, outputs frame(s)\"\n#define COMPONENT_NAME_CWINTOVECPROCESSOR \"cWinToVecProcessor\"\n\n#define FRAME_MSG_QUE_SIZE 10\n#define MATBUF_ALLOC_STEP  200\n\n#define FRAMEMODE_FIXED 0 \n#define FRAMEMODE_FULL  1\n#define FRAMEMODE_VAR   2\n#define FRAMEMODE_LIST  3\n#define FRAMEMODE_META  4\n\n\n#undef class\nclass DLLEXPORT cWinToVecProcessor : public cDataProcessor {\n  private:\n    int   frameMode;\n    int   fsfGiven;   // flag that indicates whether frameSizeFrame, etc. was specified directly (to override frameSize in seconds)\n    int   fstfGiven;   // flag that indicates whether frameStepFrame, etc. was specified directly (to override frameStep in seconds)\n    int   dtype;     // data type (DMEM_FLOAT, DMEM_INT)\n    int   noPostEOIprocessing;\n    int   nIntervals;  // number of intervals for frameMode = list\n    double *ivSec; //interleaved array : start/end in seconds (frameList, frameMode = list)\n    long *ivFrames; //interleaved array : start/end in frames (vIdx) (frameList, frameMode = list)\n    long frameIdx; // next frame index, (frameMode== list)\n\n    long Mult;\n    long matBufN; // number of valid elements in matbuf\n    long matBufNalloc; // backup of matbuf->nT\n    char * lastText, *lastCustom;\n    double inputPeriod;\n    \n    cMatrix *matBuf;\n    cMatrix *tmpRow;\n    cVector *tmpVec;\n    FLOAT_DMEM *tmpFrameF;\n    INT_DMEM *tmpFrameI;\n\n    //mapping of field indicies to config indicies: (size of these array is maximum possible size: Nfi)\n    int Nfconf;\n    int *fconf, *fconfInv;\n    long *confBs;  // blocksize for configurations\n\n    int addFconf(long bs, int field); // return value is index of assigned configuration\n    \n    // message memory:\n    int nQ; // number of frames quequed\n    double Qstart[FRAME_MSG_QUE_SIZE]; // start time array\n    double Qend[FRAME_MSG_QUE_SIZE];   // end time array\n    int Qflag[FRAME_MSG_QUE_SIZE];     // final frame flag (turn end..)\n    int QID[FRAME_MSG_QUE_SIZE];     // final frame flag (turn end..)\n    int getNextFrameData(double *start, double *end, int *flag, int *ID);\n    int peakNextFrameData(double *start, double *end, int *flag, int *ID);\n    int clearNextFrameData();\n    int queNextFrameData(double start, double end, int flag, int ID);\n    void addVecToBuf(cVector *ve);\n\n  protected:\n    long Ni, Nfi;\n    long No; //, Nfo;\n    int   allow_last_frame_incomplete_;\n    int   wholeMatrixMode; // this is 0 by default, but child classes can overwrite it, if they implement the doProcessMatrix method instead of the doProcess method\n    int   processFieldsInMatrixMode; // <- this variable is set from the config by the child class, the config option must also be populated by the child class; by default the value is 0\n\n    double frameSize, frameStep, frameCenter;\n    long  frameSizeFrames, frameStepFrames, frameCenterFrames, pre;\n\n    SMILECOMPONENT_STATIC_DECL_PR\n    double getInputPeriod(){return inputPeriod;}\n    long getNi() { return Ni; } // number of elements\n    long getNfi() { return Nfi; } // number of fields\n    long getNf() { return Ni; } // return whatever will be processed (Ni: winToVec, Nfi, vecProc.)\n\n    // converts a string time (framemode=list index list) to a float time value\n    double stringToTimeval(char *x, int *isSec);\n\n    // (input) field configuration, may be used in setupNamesForField\n    int getFconf(int field) { return fconf[field]; } // caller must check for return value -1 (= no conf available for this field)\n    void multiConfFree( void * x );\n    void *multiConfAlloc() {\n      return calloc(1,sizeof(void*)*getNf());\n    }\n    \n    virtual void fetchConfig();\n    //virtual int myFinaliseInstance();\n    //virtual int myConfigureInstance();\n    virtual int dataProcessorCustomFinalise();\n    virtual int myTick(long long t);\n\n    // this must return the multiplier, i.e. the vector size returned for each input element (e.g. number of functionals, etc.)\n    virtual int getMultiplier();\n    \n    // get the number of outputs given a number of inputs, \n    // this is used for wholeMatrixMode, where the quantitative relation between inputs and outputs may be non-linear\n    // this replaces getMultiplier, which is used in the standard row-wise processing mode\n    virtual long getNoutputs(long nIn);\n\n    virtual int configureWriter(sDmLevelConfig &c);\n    virtual int setupNamesForElement(int idxi, const char*name, long nEl);\n    //virtual int setupNamesForField(int idxi, const char*name, long nEl);\n    virtual int doProcessMatrix(int i, cMatrix *in, FLOAT_DMEM *out, long nOut);\n    virtual int doProcessMatrix(int i, cMatrix *in, INT_DMEM *out, long nOut);\n    virtual int doProcess(int i, cMatrix *row, FLOAT_DMEM*x);\n    virtual int doProcess(int i, cMatrix *row, INT_DMEM*x);\n    virtual int doFlush(int i, FLOAT_DMEM*x);\n    virtual int doFlush(int i, INT_DMEM*x);\n\n    virtual int processComponentMessage( cComponentMessage *_msg );\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cWinToVecProcessor(const char *_name);\n\n    virtual ~cWinToVecProcessor();\n};\n\n\n\n\n#endif // __CWINTOVECPROCESSOR_HPP\n"
  },
  {
    "path": "src/include/core/windowProcessor.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfilter :  (abstract class only)\n       linear N-th order filter for single value data streams\n       this class processed every element of a frame independently\n       derived classes only need to implement the filter algorithm\n\n*/\n\n\n#ifndef __CWINDOWPROCESSOR_HPP\n#define __CWINDOWPROCESSOR_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CWINDOWPROCESSOR \"filter dataProcessor, filters each element in a dataMemory level independently\"\n#define COMPONENT_NAME_CWINDOWPROCESSOR \"cWindowProcessor\"\n\n#undef class\nclass DLLEXPORT cWindowProcessor : public cDataProcessor {\n  private:\n    //int blocksize;         // block size for filter (speed up purpose only)\n    long Ni;\n    int isFirstFrame;\n    int pre, post, winsize;\n    int noPostEOIprocessing;\n    \n    cMatrix * matnew;\n    cMatrix * rowout;\n    cMatrix * rowsout;\n    cMatrix * row;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    int multiplier;\n\n    void setWindow(int _pre, int _post);\n    int firstFrame() { return isFirstFrame; }\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n    virtual int configureWriter(sDmLevelConfig &c);\n\n\n   // buffer must include all (# order) past samples\n    virtual int processBuffer(cMatrix *_in, cMatrix *_out,  int _pre, int _post );\n    virtual int processBuffer(cMatrix *_in, cMatrix *_out,  int _pre, int _post, int rowGlobal );\n    virtual int dataProcessorCustomFinalise();\n\n/*\n    virtual int setupNamesForField(int i, const char*name, long nEl);\n    virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n*/\n    \n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cWindowProcessor(const char *_name, int _pre=0, int _post=0);\n\n    virtual ~cWindowProcessor();\n};\n\n\n\n\n#endif // __CWINDOWPROCESSOR_HPP\n"
  },
  {
    "path": "src/include/dsp/dbA.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: dbA\n\napplies dbX weighting to fft magnitudes\n\n*/\n\n\n#ifndef __CDBA_HPP\n#define __CDBA_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n#include <math.h>\n\n#define BUILD_COMPONENT_DbA\n#define COMPONENT_DESCRIPTION_CDBA \"This component performs dbX (dbA,dbB,dbC,...) equal loudness weighting of FFT bin magnitudes. Currently only dbA weighting is implemented.\"\n#define COMPONENT_NAME_CDBA \"cDbA\"\n\n#define CURVE_DBA 0\n#define CURVE_DBB 1\n#define CURVE_DBC 2\n\nextern void computeDBA(FLOAT_DMEM *x, long blocksize, FLOAT_DMEM F0);\n\n#undef class\nclass DLLEXPORT cDbA : public cVectorProcessor {\n  private:\n    int curve;\n    int usePower;\n    FLOAT_DMEM **filterCoeffs;\n    \n    int computeFilters( long blocksize, double frameSizeSec, int idxc );\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    //virtual int myTick(long long t);\n\n    //virtual int configureWriter(const sDmLevelConfig *c);\n\n    virtual int dataProcessorCustomFinalise();\n    virtual int setupNamesForField(int i, const char*name, long nEl);\n    //virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cDbA(const char *_name);\n\n    virtual ~cDbA();\n};\n\n\n\n\n#endif // __CDBA_HPP\n"
  },
  {
    "path": "src/include/dsp/signalGenerator.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nSignal source. Generates various noise types and pre-defined signals.\n\n*/\n\n\n#ifndef __CSIGNALGENERATOR_HPP\n#define __CSIGNALGENERATOR_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataSource.hpp>\n\n#define BUILD_COMPONENT_SignalGenerator\n#define COMPONENT_DESCRIPTION_CSIGNALGENERATOR \"This component provides a signal source. This source generates various noise types and pre-defined signals and value patterns. See the configuration documentation for a list of currently implemented types.\"\n#define COMPONENT_NAME_CSIGNALGENERATOR \"cSignalGenerator\"\n\n#define NOISE_WHITE   0   // white gaussian noise 'white'\n#define SIGNAL_SINE   1   // sinusodial signal (single frequency) 'sine'\n#define SIGNAL_CONST  2   // constant value 'const'\n#define SIGNAL_RECT   3   // rectangular periodic signal 'rect'\n//...\n\n#undef class\nclass DLLEXPORT cSignalGenerator : public cDataSource {\n  private:\n    long nValues;\n    int randSeed;\n    FLOAT_DMEM stddev, mean;\n    FLOAT_DMEM constant;\n    double signalPeriod, phase;\n    double myt ; // current time\n    double samplePeriod;\n    double lastP;\n    double scale;\n    double val;\n\n    int * nElements;\n    char ** fieldNames;\n    int nFields;\n    \n    int noiseType;\n    long lengthFrames;\n    long curT;\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n    virtual int configureWriter(sDmLevelConfig &c);\n    virtual int setupNewNames(long nEl);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cSignalGenerator(const char *_name);\n\n    virtual ~cSignalGenerator();\n};\n\n\n\n\n#endif // __CSIGNALGENERATOR_HPP\n"
  },
  {
    "path": "src/include/dsp/smileResample.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nsimple preemphasis : x(t) = x(t) - k*x(t-1)\n\n*/\n\n\n#ifndef __CSMILERESAMPLE_HPP\n#define __CSMILERESAMPLE_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataProcessor.hpp>\n\n#define BUILD_COMPONENT_SmileResample\n#define COMPONENT_DESCRIPTION_CSMILERESAMPLE \"This component implements a spectral domain resampling component. Input frames are transferred to the spectral domain, then the spectra are shifted, and a modified DFT is performed to synthesize samples at the new rate.\"\n#define COMPONENT_NAME_CSMILERESAMPLE \"cSmileResample\"\n\n\n#undef class\nclass DLLEXPORT cSmileResample : public cDataProcessor {\n  private:\n    cMatrix *matnew; cMatrix *rowout;\n    cMatrix *row;\n    int flushed;\n    int useQuickAlgo;\n\n    double ND;\n    double resampleRatio, targetFs, pitchRatio;\n    double winSize, winSizeTarget;\n    long winSizeFramesTarget, winSizeFrames;\n\n    FLOAT_DMEM *outputBuf, *lastOutputBuf;\n    FLOAT_TYPE_FFT *inputBuf;\n    sResampleWork *resampleWork;\n    long Ni;\n\n    int getOutput(FLOAT_DMEM *cur, FLOAT_DMEM *last, long N, FLOAT_DMEM *out, long Nout);\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n\n    virtual void fetchConfig();\n/*\n    virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    \n*/\n\n    virtual int myTick(long long t);\n    virtual int configureWriter(sDmLevelConfig &c);\n\n   // buffer must include all (# order) past samples\n    //virtual int processBuffer(cMatrix *_in, cMatrix *_out, int _pre, int _post );\n    virtual int dataProcessorCustomFinalise();\n/*\n    virtual int setupNamesForField(int i, const char*name, long nEl);\n    virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n*/\n    //virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n    \n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cSmileResample(const char *_name);\n\n    virtual ~cSmileResample();\n};\n\n\n\n\n#endif // __CSMILERESAMPLE_HPP\n"
  },
  {
    "path": "src/include/dsp/specResample.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexperimental resampling by ideal fourier interpolation and band limiting\nthis component takes a complex (!) dft spectrum (generated from real values) as input\n\n*/\n\n\n#ifndef __CSPECRESAMPLE_HPP\n#define __CSPECRESAMPLE_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n\n#define BUILD_COMPONENT_SpecResample\n#define COMPONENT_DESCRIPTION_CSPECRESAMPLE \"This component implements a spectral domain resampling component. Input frames are complex valued spectral domain data, which will be shifted and scaled by this component, and a modified DFT is performed to synthesize samples at the new rate.\"\n#define COMPONENT_NAME_CSPECRESAMPLE \"cSpecResample\"\n\n#undef class\nclass DLLEXPORT cSpecResample : public cVectorProcessor {\n  private:\n    int antiAlias;\n    long kMax;\n    double sr;\n    double fsSec;\n    double targetFs;\n    double resampleRatio;\n    long _Nin, _Nout;\n    FLOAT_DMEM *inData;\n    const char * inputFieldPartial;\n\n    sDftWork * dftWork;\n    //FLOAT_DMEM *costable, *sintable;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n\t  virtual int setupNewNames(long nEl);\n    virtual int configureWriter(sDmLevelConfig &c);\n    //virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cSpecResample(const char *_name);\n    virtual ~cSpecResample();\n};\n\n\n\n\n#endif // __CSPECRESAMPLE_HPP\n"
  },
  {
    "path": "src/include/dsp/specScale.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\n*/\n\n\n#ifndef __CSPECSCALE_HPP\n#define __CSPECSCALE_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n\n#define BUILD_COMPONENT_SpecScale\n#define COMPONENT_DESCRIPTION_CSPECSCALE \"This component performs linear/non-linear axis scaling of FFT magnitude spectra with spline interpolation.\"\n#define COMPONENT_NAME_CSPECSCALE \"cSpecScale\"\n\n/*\n#define SPECTSCALE_LINEAR   0\n#define SPECTSCALE_LOG      1\n#define SPECTSCALE_BARK     2\n#define SPECTSCALE_MEL      3\n#define SPECTSCALE_SEMITONE 4\n#define SPECTSCALE_BARK_SCHROED     5\n#define SPECTSCALE_BARK_SPEEX       6\n*/\n\n#define INTERP_NONE       0\n#define INTERP_LINEAR     1\n#define INTERP_SPLINE     2\n\n#undef class\nclass DLLEXPORT cSpecScale : public cVectorProcessor {\n  private:\n    int scale; // target scale\n    int sourceScale;\n    int interpMethod;\n    int specSmooth, specEnhance;\n    int auditoryWeighting;\n    double logScaleBase, logSourceScaleBase;\n    double minF, maxF, fmin_t, fmax_t;\n    long nPointsTarget;\n    double firstNote, param;\n\n    long nMag, magStart;\n    double fsSec;\n    double deltaF, deltaF_t;\n\n    double *f_t;\n    double *spline_work;\n    double *y, *y2;\n    double *audw;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n\t  virtual int setupNewNames(long nEl);\n    virtual int dataProcessorCustomFinalise();\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cSpecScale(const char *_name);\n    \n    virtual ~cSpecScale();\n};\n\n#endif // __CSPECSCALE_HPP\n"
  },
  {
    "path": "src/include/dsp/vadV1.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nvoice activity detection based on LSF and Pitch features + smoothing\n\n*/\n\n\n#ifndef __CVADV1_HPP\n#define __CVADV1_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataProcessor.hpp>\n\n#define BUILD_COMPONENT_VadV1\n#define COMPONENT_DESCRIPTION_CVADV1 \"A voice activity detector based on Line-Spectral-Frequencies, Mel spectra and energy + smoothing. This component requires input of the following type in the following order: MelSpec;lsf;energy. See vadV1.hpp for an example config!\"\n#define COMPONENT_NAME_CVADV1 \"cVadV1\"\n\n/* what we have to read from the input level:\n\nLSF\nPitch F0 (raw)\nEnergy\n\n*********** example config ***********\n\n[enV:cEnergy]\nreader.dmLevel=frame\nwriter.dmLevel=energy\nnameAppend=energy\nrms=1\nlog=1\n\n[lpc:cLpc]\nreader.dmLevel=frames\nsaveRefCoeff=0\nwriter.dmLevel=lpc\np=10\n\n[mspecV:cMelspec]\nreader.dmLevel=fftmagnitude\nwriter.dmLevel=mspec\nhtkcompatible = 0\nusePower = 0\nnBands = 14\nlofreq = 50\nhifreq = 4000\n\n[lsp:cLsp]\nreader.dmLevel=lpc\nwriter.dmLevel=lsp\n\n[vad:cVadV1]\nreader.dmLevel=mspec;lsp;energy\nwriter.dmLevel=vad11\nwriter.levelconf.noHang=1\ndebug=\\cm[vaddebug{0}:1=debug vad]\nthreshold=\\cm[threshold{-13}:VAD threshold]\ndisableDynamicVAD=\\cm[disableDynamicVAD{0}:disable dynamic threshold vad, instead use energy based vad only, the energy threshold can be set via the 'threshold' option]\n;threshold=\\cm[threshold{-13.0}:VAD energy threshold, minimum energy for dynamic vad, can be very small, it is used only as a backup; real threshold if disableDynamicVAD is set, in that case you should set the threshold to approx.]\n\n*/\n \n#define NINIT  50  // NINIT must be < FTBUF!!\n#define FTBUF  100\n#define FUZBUF 10\n\n#undef class\nclass DLLEXPORT cVadV1 : public cDataProcessor {\n  private:\n    int debug, disableDynamicVAD;\n\n    long specIdx, specN, lsfN;\n    long F0rawIdx, voiceProbIdx, eIdx;\n\n    FLOAT_DMEM *spec;\n    int t0histIdx; int vadBin;\n    FLOAT_DMEM t0hist[8];\n    FLOAT_DMEM div0;\n    FLOAT_DMEM turnSum, turnN;\n\n    // history for smooting:\n    FLOAT_DMEM f0v_0, ent_0, E_0;\n    FLOAT_DMEM ar0, ar1, arU, arV;\n\n    // adaptive thresholds:\n    long nInit;\n    FLOAT_DMEM uF0v, uEnt, uE;\n    FLOAT_DMEM vF0v, vEnt, vE;\n    FLOAT_DMEM tuF0v, tuEnt, tuE;\n    FLOAT_DMEM tvF0v, tvEnt, tvE;\n    FLOAT_DMEM F0vH[FTBUF], entH[FTBUF], EH[FTBUF];\n    int F0vHidx, entHidx, EHidx;\n    FLOAT_DMEM tF0vH[FTBUF], tentH[FTBUF], tEH[FTBUF];\n    int tF0vHidx, tentHidx, tEHidx;\n    int nInitT, nInitN;\n    \n    FLOAT_DMEM vadFuzH[FUZBUF];\n    int vadFuzHidx;\n\n    FLOAT_DMEM minE, minEn, maxEn;\n\n\n    FLOAT_DMEM threshold;\n    int nPost, nPre;\n    int useRMS;\n    int turnState, actState;\n    long startP, startP0, endP0;\n    double endSmileTime, startSmileTime;\n   \n    int cnt1, cnt2;\n\n    const char *recFramer, *recComp, *statusRecp;\n    \n    void findInputMapping();\n    //FLOAT_DMEM specEntropy(FLOAT_DMEM *lsf, int N);\n    FLOAT_DMEM pitchVariance(FLOAT_DMEM curF0raw);\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    //virtual int isVoice(FLOAT_DMEM *src);\n    //virtual void updateThreshold(FLOAT_DMEM eRmsCurrent);\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n    //virtual int configureWriter(sDmLevelConfig &c);\n    virtual int setupNewNames(long nEl);\n    //virtual void configureField(int idxi, long __N, long nOut);\n    //virtual int setupNamesForField(int i, const char*name, long nEl);\n//    virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n//    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cVadV1(const char *_name);\n\n    virtual ~cVadV1();\n};\n\n\n\n\n#endif // __CVADV1_HPP\n"
  },
  {
    "path": "src/include/dspcore/acf.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nAutocorrelation Function (ACF)\n\n*/\n\n\n#ifndef __CACF_HPP\n#define __CACF_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n#include <dspcore/fftXg.h>\n#include <math.h>\n\n#define COMPONENT_DESCRIPTION_CACF \"This component computes the autocorrelation function (ACF) by sqauring a magnitude spectrum and applying an inverse Fast Fourier Transform. This component mus read from a level containing *only* FFT magnitudes in a single field. Use the 'cTransformFFT' and 'cFFTmagphase' components to compute the magnitude spectrum from PCM frames. Computation of the Cepstrum is also supported (this applies a log() function to the magnitude spectra).\"\n#define COMPONENT_NAME_CACF \"cAcf\"\n\n#undef class\nclass DLLEXPORT cAcf : public cVectorProcessor {\n  private:\n    int absCepstrum_;\n    int oldCompatCepstrum_;\n    int acfCepsNormOutput_;\n    int symmetricData;\n    int expBeforeAbs;\n    int cosLifterCepstrum;\n    int usePower, cepstrum, inverse;\n    FLOAT_TYPE_FFT **data;\n    FLOAT_TYPE_FFT **w;\n    FLOAT_DMEM **winFunc;\n    int **ip;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n//    virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    //virtual int myTick(long long t);\n\n    virtual int dataProcessorCustomFinalise();\n\n//    virtual void configureField(int idxi, long __N, long nOut);\n    virtual int setupNamesForField(int i, const char*name, long nEl);\n    //virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cAcf(const char *_name);\n\n    virtual ~cAcf();\n};\n\n\n\n\n#endif // __CACF_HPP\n"
  },
  {
    "path": "src/include/dspcore/amdf.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nAverage Magnitude Difference Function (AMDF)\n\n*/\n\n\n#ifndef __CAMDF_HPP\n#define __CAMDF_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CAMDF \"This component computes the Average Magnitude Difference Function (AMDF) for each input frame. Various methods for padding or warping at the border exist.\"\n#define COMPONENT_NAME_CAMDF \"cAmdf\"\n\n\n#define AMDF_LIMIT    0\n#define AMDF_WARP     1\n#define AMDF_ZEROPAD  2\n\n#undef class\nclass DLLEXPORT cAmdf : public cVectorProcessor {\n  private:\n    //int htkcompatible;\n    int nLag;\n    int method;\n    int invert;\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    //virtual int myTick(long long t);\n\n    //virtual int configureWriter(const sDmLevelConfig *c);\n\n    virtual int setupNamesForField(int i, const char*name, long nEl);\n    //virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cAmdf(const char *_name);\n\n    virtual ~cAmdf();\n};\n\n\n\n\n#endif // __CAMDF_HPP\n"
  },
  {
    "path": "src/include/dspcore/contourSmoother.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: contour smoother\n\nsmooth data contours by moving average filter\n\n*/\n\n\n\n#ifndef __CCONTOURSMOOTHER_HPP\n#define __CCONTOURSMOOTHER_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/windowProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CCONTOURSMOOTHER \"This component smooths data contours by applying a moving average filter of configurable length.\"\n#define COMPONENT_NAME_CCONTOURSMOOTHER \"cContourSmoother\"\n\n#undef class\nclass DLLEXPORT cContourSmoother : public cWindowProcessor {\n  private:\n    int smaWin;\n    int noZeroSma;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n\n    virtual void fetchConfig();\n\n    //virtual int configureWriter(const sDmLevelConfig *c);\n    //virtual int setupNamesForField(int i, const char*name, long nEl);\n\n    // buffer must include all (# order) past samples\n    virtual int processBuffer(cMatrix *_in, cMatrix *_out, int _pre, int _post );\n    \n    \n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cContourSmoother(const char *_name);\n\n    virtual ~cContourSmoother();\n};\n\n\n#endif // __CCONTOURSMOOTHER_HPP\n"
  },
  {
    "path": "src/include/dspcore/deltaRegression.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: delta coefficients\n\ncompute delta regression using regression formula\n\n*/\n\n\n\n#ifndef __CDELTAREGRESSION_HPP\n#define __CDELTAREGRESSION_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/windowProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CDELTAREGRESSION \"This component computes delta regression coefficients using the regression equation from the HTK book.\"\n#define COMPONENT_NAME_CDELTAREGRESSION \"cDeltaRegression\"\n\n#undef class\nclass DLLEXPORT cDeltaRegression : public cWindowProcessor {\nprivate:\n  int halfWaveRect, absOutput;\n  int deltawin;\n  FLOAT_DMEM norm;\n\n  int zeroSegBound;\n  int onlyInSegments;\n\nprotected:\n  SMILECOMPONENT_STATIC_DECL_PR\n\n\n  int isNoValue(FLOAT_DMEM x) {\n    if (onlyInSegments && x==0.0) return 1;\n    if (isnan(x)) return 1;\n    return 0;\n  }\n\n  virtual void fetchConfig();\n\n  //virtual int configureWriter(const sDmLevelConfig *c);\n  //virtual int setupNamesForField(int i, const char*name, long nEl);\n\n  // buffer must include all (# order) past samples\n  virtual int processBuffer(cMatrix *_in, cMatrix *_out, int _pre, int _post );\n\n\npublic:\n  SMILECOMPONENT_STATIC_DECL\n\n    cDeltaRegression(const char *_name);\n\n  virtual ~cDeltaRegression();\n};\n\n\n#endif // __CDELTAREGRESSION_HPP\n"
  },
  {
    "path": "src/include/dspcore/fftXg.h",
    "content": "/*\n * http://www.kurims.kyoto-u.ac.jp/~ooura/fft.html\n * Copyright Takuya OOURA, 1996-2001\n *\n * You may use, copy, modify and distribute this code for any purpose (include\n * commercial use) and without fee. Please refer to this package when you modify\n * this code.\n *\n * Changes:\n * Type modifications and ifdefs by the openSMILE authors.\n */\n\n#ifndef __FFTXG_H\n#define __FFTXG_H\n\n#define FLOAT_TYPE_FFT float\n#define FLOAT_FFT_NUM  0      // 0 = float, 1 = double\n\n#ifdef __cplusplus\nextern \"C\" \n{\n#endif\n\n  void cdft(int n, int isgn, FLOAT_TYPE_FFT *a, int *ip, FLOAT_TYPE_FFT *w);\n  void rdft(int n, int isgn, FLOAT_TYPE_FFT *a, int *ip, FLOAT_TYPE_FFT *w);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif // __FFTXG_H\n"
  },
  {
    "path": "src/include/dspcore/fftmagphase.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\n\n*/\n\n\n#ifndef __FFT_MAGPHASE_HPP\n#define __FFT_MAGPHASE_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n//#include \"fftXg.h\"\n\n#define COMPONENT_DESCRIPTION_CFFTMAGPHASE \"This component computes magnitude and phase of each array in the input level (it thereby assumes that the arrays contain complex numbers with real and imaginary parts alternating, as computed by the cTransformFFT component).\"\n#define COMPONENT_NAME_CFFTMAGPHASE \"cFFTmagphase\"\n\n#undef class\nclass DLLEXPORT cFFTmagphase : public cVectorProcessor {\n  private:\n    int inverse;\n    int magnitude;\n    int phase;\n    int joinMagphase;\n    int power;\n    int normalise, dBpsd;\n    FLOAT_DMEM dBpnorm;\n    FLOAT_DMEM mindBp;\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n\n    virtual int setupNamesForField(int i, const char*name, long nEl);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cFFTmagphase(const char *_name);\n\n    virtual ~cFFTmagphase();\n};\n\n\n\n\n#endif // __FFT_MAGPHASE_HPP\n"
  },
  {
    "path": "src/include/dspcore/framer.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\ndataFramer\n\n*/\n\n\n#ifndef __CFRAMER_HPP\n#define __CFRAMER_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/winToVecProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CFRAMER \"This component creates frames from single dimensional input stream. It is possible to specify the frame step and frame size independently, thus allowing for overlapping frames or non continuous frames.\"\n#define COMPONENT_NAME_CFRAMER \"cFramer\"\n\n#undef class\nclass DLLEXPORT cFramer : public cWinToVecProcessor {\n  private:\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    //virtual void fetchConfig();\n    //virtual int myFinaliseInstance();\n    //virtual int myTick(long long t);\n\n    virtual int getMultiplier();\n    //virtual int configureWriter(const sDmLevelConfig *c);\n    //virtual int setupNamesForField(int idxi, const char*name, long nEl);\n    virtual int doProcess(int i, cMatrix *row, FLOAT_DMEM*x);\n    virtual int doProcess(int i, cMatrix *row, INT_DMEM*x);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cFramer(const char *_name);\n\n    virtual ~cFramer();\n};\n\n\n\n\n#endif // __CFRAMER_HPP\n"
  },
  {
    "path": "src/include/dspcore/fullinputMean.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\ncomputes mean of full input ?\n\n*/\n\n\n#ifndef __CFULLINPUTMEAN_HPP\n#define __CFULLINPUTMEAN_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CFULLINPUTMEAN \"This component performs mean normalizing on a data series. A 2-pass analysis of the data is performed, which makes this component unusable for on-line analysis. In the first pass, no output is produced and the mean value (over time) is computed for each input element. In the second pass the mean vector is subtracted from all input frames, and the result is written to the output dataMemory level. Attention: Due to the 2-pass processing the input level must be large enough to hold the whole data sequence.\"\n#define COMPONENT_NAME_CFULLINPUTMEAN \"cFullinputMean\"\n\nenum cFullinputMean_meanType {\n  MEANTYPE_AMEAN = 0,\n  MEANTYPE_RQMEAN = 1,\n  MEANTYPE_ABSMEAN = 2,\n  MEANTYPE_ENORM = 3   // htk compatible energy normalisation\n};\n\n#undef class\nclass DLLEXPORT cFullinputMean : public cDataProcessor {\n  private:\n    int print_means_;\n    int first_frame_;\n    long reader_pointer_, reader_pointer2_;\n    int multi_loop_mode_;\n    enum cFullinputMean_meanType mean_type_;\n    int spec_enorm_;\n    int symm_subtract_;\n    int symm_subtract_clip_to_zero_;\n    int flag_; //, htkcompatible; long idx0;\n    int eoi_flag_;  // this is set after an EOI condition\n    cVector *means_, *means2_;\n    long n_means_, n_means2_;\n\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    int readNewData();\n    void meanSubtract(cVector *vec);\n    int doMeanSubtract();\n    int finaliseMeans();\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n    //virtual int configureWriter(sDmLevelConfig &c);\n\n    //virtual void configureField(int idxi, long __N, long nOut);\n    //virtual int setupNamesForField(int i, const char*name, long nEl);\n    //virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    //virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cFullinputMean(const char *_name);\n\n    virtual ~cFullinputMean();\n};\n\n\n\n\n#endif // __CFULLINPUTMEAN_HPP\n"
  },
  {
    "path": "src/include/dspcore/fullturnMean.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\ncomputes mean of full input ?\n\n*/\n\n\n#ifndef __CFULLTURNMEAN_HPP\n#define __CFULLTURNMEAN_HPP\n\n#pragma warning( disable : 4251 )\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n\n// STL includes for the queue\r\n#include <queue>\r\n\r\n\n#define COMPONENT_DESCRIPTION_CFULLTURNMEAN \"This component performs mean normalizing on a data series. A 2-pass analysis of the data is performed, which makes this component unusable for on-line analysis. In the first pass, no output is produced and the mean value (over time) is computed for each input element. In the second pass the mean vector is subtracted from all input frames, and the result is written to the output dataMemory level. Attention: Due to the 2-pass processing the input level must be large enough to hold the whole data sequence.\"\n#define COMPONENT_NAME_CFULLTURNMEAN \"cFullturnMean\"\n\n\n#undef class\n\n// A message received from the turn detector.\r\nstruct TurnTimeMsg {\r\n  TurnTimeMsg() : vIdxStart(0), vIdxEnd(0), isForcedTurnEnd(0) {}\r\n  TurnTimeMsg(long _vIdxStart, long _vIdxEnd, int forceend=0) : vIdxStart(_vIdxStart), vIdxEnd(_vIdxEnd), isForcedTurnEnd(forceend) {}\r\n  long vIdxStart, vIdxEnd;        // vector index\r\n  int isForcedTurnEnd;  // forced turn end = at end of input\r\n};\r\n\r\n// A queue of turn detector messages.\r\ntypedef std::queue<TurnTimeMsg> TurnTimeMsgQueue;\r\n\nclass DLLEXPORT cFullturnMean : public cDataProcessor {\n  private:\n    TurnTimeMsgQueue msgQue;\r\n\n    int dataInQue;\n    long curWritePos;\n    //TODO: postSil / preSil option for adding extra data at beginning and end of turn\n\n    const char *msgRecp;\n    int eNormMode;\n    cVector *means;\n    long nMeans;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n    int checkMessageQueque(long &start, long &end, long &fte);\n    virtual int processComponentMessage(cComponentMessage *_msg);\n    //virtual int configureWriter(sDmLevelConfig &c);\n\n    //virtual void configureField(int idxi, long __N, long nOut);\n    //virtual int setupNamesForField(int i, const char*name, long nEl);\n    //virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    //virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cFullturnMean(const char *_name);\n\n    virtual ~cFullturnMean();\n};\n\n\n\n\n#endif // __CFULLTURNMEAN_HPP\n"
  },
  {
    "path": "src/include/dspcore/monoMixdown.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nsimple mixer, which adds multiple channels (elements) to a single channel (element)\n\n*/\n\n\n#ifndef __CMONOMIXDOWN_HPP\n#define __CMONOMIXDOWN_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CMONOMIXDOWN \"This is a simple mixer, which adds multiple channels (elements) to a single channel (element).\"\n#define COMPONENT_NAME_CMONOMIXDOWN \"cMonoMixdown\"\n\n#undef class\nclass DLLEXPORT cMonoMixdown : public cDataProcessor {\n  private:\n    int normalise;\n    long bufsize;\n    cMatrix *matout;\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n    // virtual int dataProcessorCustomFinalise();\n    // virtual int setupNewNames(long nEl);\n    virtual int setupNamesForField(int i, const char*name, long nEl);\n    virtual int configureWriter(sDmLevelConfig &c);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cMonoMixdown(const char *_name);\n\n    virtual ~cMonoMixdown();\n};\n\n\n\n\n#endif // __CMONOMIXDOWN_HPP\n"
  },
  {
    "path": "src/include/dspcore/preemphasis.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nsimple preemphasis : x(t) = x(t) - k*x(t-1)\n\n*/\n\n\n#ifndef __CPREEMPHASIS_HPP\n#define __CPREEMPHASIS_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/windowProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CPREEMPHASIS \"This component performs pre- and de-emphasis of speech signals using a 1st order difference equation: y(t) = x(t) - k*x(t-1)  (de-emphasis: y(t) = x(t) + k*x(t-1))\"\n#define COMPONENT_NAME_CPREEMPHASIS \"cPreemphasis\"\n\n\n#undef class\nclass DLLEXPORT cPreemphasis : public cWindowProcessor {\n  private:\n    FLOAT_DMEM k;\n    double f;\n    int de;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n\n    virtual void fetchConfig();\n/*\n    virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n*/\n\n    //virtual int configureWriter(const sDmLevelConfig *c);\n\n   // buffer must include all (# order) past samples\n    virtual int processBuffer(cMatrix *_in, cMatrix *_out, int _pre, int _post );\n    virtual int dataProcessorCustomFinalise();\n/*\n    virtual int setupNamesForField(int i, const char*name, long nEl);\n    virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n*/\n    \n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cPreemphasis(const char *_name);\n\n    virtual ~cPreemphasis();\n};\n\n\n\n\n#endif // __CPREEMPHASIS_HPP\n"
  },
  {
    "path": "src/include/dspcore/transformFft.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfast fourier transform using fft4g library\noutput: complex values of fft or real signal values (for iFFT)\n\n*/\n\n\n#ifndef __TRANSFORM_FFT_HPP\n#define __TRANSFORM_FFT_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n#include <dspcore/fftXg.h>\n\n#define COMPONENT_DESCRIPTION_CTRANSFORMFFT \"This component performs an FFT on a sequence of real values (one frame), the output is the complex domain result of the transform. Use the cFFTmagphase component to compute magnitudes and phases from the complex output.\"\n#define COMPONENT_NAME_CTRANSFORMFFT \"cTransformFFT\"\n\n#undef class\nclass DLLEXPORT cTransformFFT : public cVectorProcessor {\n  private:\n    int inverse_;\n    int **ip_;\n    FLOAT_TYPE_FFT **w_;\n    FLOAT_TYPE_FFT **xconv_;\n    int newFsSet_;\n    double frameSizeSecOut_;\n    int zeroPadSymmetric_;\n\n    // generate \"frequency axis information\", i.e. the frequency in Hz for each spectral bin\n    // which is to be saved as meta-data in the dataMemory level field (FrameMetaInfo->FieldMetaInfo->info)\n    // &infosize is initialized with the number of fft bins x 2 (= number of input samples)\n    //   and should contain the number of complex bins at the end of this function\n    void * generateSpectralVectorInfo(long &infosize);\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    virtual int myFinaliseInstance();\n\n    virtual int configureWriter(sDmLevelConfig &c);\n    virtual int setupNamesForField(int i, const char*name, long nEl);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cTransformFFT(const char *_name);\n\n    virtual ~cTransformFFT();\n};\n\n\n\n\n#endif // __TRANSFORM_FFT_HPP\n"
  },
  {
    "path": "src/include/dspcore/turnDetector.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nsimple silence threshold based turn detector\n\n*/\n\n\n#ifndef __CTURNDETECTOR_HPP\n#define __CTURNDETECTOR_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CTURNDETECTOR \"Speaker turn detector using data from cVadV1 component or cSemaineSpeakerID1 (adaptive VAD) to determine speaker turns and identify continuous segments of voice activity.\"\n#define COMPONENT_NAME_CTURNDETECTOR \"cTurnDetector\"\n\n\n#undef class\nclass DLLEXPORT cTurnDetector : public cDataProcessor {\n  private:\n    int lastVIdx;\n    double lastVTime;\n    FLOAT_DMEM threshold, threshold2;\n    int nPost, nPre;\n    int useRMS;\n    int turnState, actState;\n    long startP, startP0, endP0;\n    double endSmileTime, startSmileTime, startSmileTimeS;\n    double turnTime, turnStep, msgInterval;\n    double maxTurnLengthS, graceS;\n    long maxTurnLength, grace;\n    long minTurnLengthFrames_, minTurnLengthFrameTimeFrames_;\n    double minTurnLength_;\n    double minTurnLengthTurnFrameTimeMessage_;\n\n    double turnFrameTimePreRollSec_;\n    long turnFrameTimePreRollFrames_;\n    double turnFrameTimePostRollSec_;\n    long turnFrameTimePostRollFrames_;\n    double msgPeriodicMaxLengthSec_;\n    long msgPeriodicMaxLengthFrames_;\n    int sendTurnFrameTimeMessageAtEnd_;\n  \n    int blockAll, blockStatus;\n    int blockTurn, unblockTurnCntdn, unblockTimeout;\n    double initialBlockTime;\n    long initialBlockFrames;\n\n    int terminateAfterTurns, terminatePostSil, nTurns;\n    int exitFlag;\n    long nSilForExit;\n\n    long eoiMis;\n    int forceEnd;\n    int timeout; double lastDataTime;\n    double timeoutSec;\n\n    int debug;\n    int cnt1, cnt2, cnt1s, cnt2s;\n\n    long rmsIdx, autoRmsIdx, readVad;\n    int autoThreshold;\n    int invert_;\n\n    // variables for auto threshold statistics:\n    int nmin, nmax;\n    FLOAT_DMEM minmaxDecay;\n    FLOAT_DMEM rmin, rmax, rmaxlast;\n    FLOAT_DMEM tmpmin, tmpmax;\n    FLOAT_DMEM dtMeanO, dtMeanT, dtMeanS;\n    FLOAT_DMEM alphaM;\n    FLOAT_DMEM nE, dtMeanAll;\n    long nTurn, nSil;\n    int tmpCnt;\n    int calCnt;\n\n    const char *recFramer, *recComp, *statusRecp;\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual int isVoice(FLOAT_DMEM *src, int state=0);  /* state 0: silence/noise, state 1: voice */\n    virtual void updateThreshold(FLOAT_DMEM eRmsCurrent);\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n    virtual int processComponentMessage( cComponentMessage *_msg );\n\n    //virtual int configureWriter(sDmLevelConfig &c);\n    virtual int setupNewNames(long nEl);\n    virtual void resumeEvent() {\n      lastDataTime = getSmileTime();\n    }\n    //virtual void configureField(int idxi, long __N, long nOut);\n    //virtual int setupNamesForField(int i, const char*name, long nEl);\n//    virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n//    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cTurnDetector(const char *_name);\n\n    virtual ~cTurnDetector();\n};\n\n\n\n\n#endif // __CTURNDETECTOR_HPP\n"
  },
  {
    "path": "src/include/dspcore/vectorMVN.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nThis component extends the base class cVectorTransform and implements mean/variance normalisation\n\n*/\n\n\n#ifndef __CVECTORMVN_HPP\n#define __CVECTORMVN_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorTransform.hpp>\n#include <math.h>\n\n#define COMPONENT_DESCRIPTION_CVECTORMVN \"This component extends the base class cVectorTransform and implements mean/variance normalisation. You can use this component to perform on-line cepstral mean normalisation. See cFullinputMean for off-line cepstral mean normalisation.\"\n#define COMPONENT_NAME_CVECTORMVN \"cVectorMVN\"\n\n/* we define some transform type IDs, other will be defined in child classes */\n//#define TRFTYPE_CMN     10    /* mean normalisation, mean vector only */\n//#define TRFTYPE_MVN     20    /* mean variance normalisation, mean vector + stddev vector */\n//#define TRFTYPE_UNDEF    0    /* undefined, or custom type */\n\n#define STDDEV_FLOOR  0.0000001\n\n\n#undef class\nclass DLLEXPORT cVectorMVN : public cVectorTransform {\n  private:\n    FLOAT_DMEM specFloor;\n    int spectralFlooring, subtractMeans;\n    int meanEnable;\n    int stdEnable, normEnable;\n    int minMaxNormEnable;\n    int htkLogEnorm;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n      \n    /**** refactoring hooks ****/\n    /* allocate the memory for vectors and userData, initialise header\n       the only field that has been set is head.vecSize ! \n       This function is only called in modes analysis and incremental if no data was loaded */\n    virtual void allocTransformData(struct sTfData *tf, int Ndst, int idxi);\n    /* For mode == ANALYSIS or TRANSFORMATION, this functions allows for a final processing step\n       at the end of input and just before the transformation data is saved to file */\n    //virtual void computeFinalTransformData(struct sTfData *tf, int idxi) {}\n\n    /* this will be called BEFORE the transform will be reset to initial values (at turn beginning/end) \n       you may modify the initial values here or the new values, \n       if you return 1 then no further changes to tf will be done,\n       if you return 0 then tf0 will be copied to tf after running this function */\n    //virtual int transformResetNotify(struct sTfData *tf, struct sTfData *tf0) { return 0; }\n\n    /* Do the actual transformation (do NOT use this to calculate parameters!) \n       This function will only be called if not in ANALYSIS mode \n       Please return the number of output samples (0, if you haven't produced output) */\n    virtual int transformDataFloat(const struct sTfData * tf, const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n    //virtual int transformDataInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n    /* Update transform parameters incrementally\n       This function will only be called if not in TRANSFORMATIONs mode \n       *buf is a pointer to a buffer if updateMethod is fixedBuffer */\n    // return value: 0: no update was performed , 1: successfull update\n    virtual int updateTransformFloatExp(struct sTfData * tf, const FLOAT_DMEM *src, int idxi);\n    virtual int updateTransformFloatBuf(struct sTfData * tf, const FLOAT_DMEM *src, FLOAT_DMEM *buf, long Nbuf, long wrPtr, int idxi);\n    virtual int updateTransformFloatAvg(struct sTfData * tf, const FLOAT_DMEM *src, int idxi);\n    virtual int updateTransformFloatAvgI(struct sTfData * tf, const FLOAT_DMEM *src, FLOAT_DMEM *buf, long * bufferNframes, long Nbuf, long wrPtr, int idxi);\n\n    /* generic method, default version will select one of the above methods,\n       overwrite to implement your own update strategy ('usr' option) */\n    //virtual int updateTransformFloat(struct sTfData * tf, const FLOAT_DMEM *src, FLOAT_DMEM *buf, long * bufferNframes, long Nbuf, int idxi);\n\n/////////////////////////////////////////////\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    //virtual int myTick(long long t);\n\n    //virtual int configureWriter(sDmLevelConfig &c);\n\n    //virtual int processComponentMessage( cComponentMessage *_msg );\n    //virtual int setupNamesForField(int i, const char*name, long nEl);\n    //virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    //virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    //virtual int flushVectorFloat(FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cVectorMVN(const char *_name);\n\n    virtual ~cVectorMVN();\n};\n\n\n\n\n#endif // __CVECTORMVN_HPP\n"
  },
  {
    "path": "src/include/dspcore/vectorPreemphasis.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\npre-emphasis per frame  (simplification, however, this is the way HTK does it... so for compatibility... here you go)\n(use before window function is applied!)\n\n*/\n\n\n#ifndef __CVECTORPREEMPHASIS_HPP\n#define __CVECTORPREEMPHASIS_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CVECTORPREEMPHASIS \"This component performs per frame pre-emphasis without an inter-frame state memory. (This is the way HTK does pre-emphasis). Pre-emphasis: y(t) = x(t) - k*x(t-1) ; de-emphasis : y(t) = x(t) + k*x(t-1)\"\n#define COMPONENT_NAME_CVECTORPREEMPHASIS \"cVectorPreemphasis\"\n\n#undef class\nclass DLLEXPORT cVectorPreemphasis : public cVectorProcessor {\n  private:\n    FLOAT_DMEM k;\n    double f;\n    int de;\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    //virtual int myTick(long long t);\n\n    //virtual int configureWriter(const sDmLevelConfig *c);\n\n    virtual int dataProcessorCustomFinalise();\n//    virtual int setupNamesForField(int i, const char*name, long nEl);\n    virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cVectorPreemphasis(const char *_name);\n\n    virtual ~cVectorPreemphasis();\n};\n\n\n\n\n#endif // __CVECTORPREEMPHASIS_HPP\n"
  },
  {
    "path": "src/include/dspcore/windower.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\ndata windower.\ntakes frames from one level, applies window function, and saves to other level\n\n*/\n\n\n#ifndef __WINDOWER_HPP\n#define __WINDOWER_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CWINDOWER \"This component applies applies window function to pcm frames.\"\n#define COMPONENT_NAME_CWINDOWER \"cWindower\"\n\n\nstruct sWindowerConfigParsed\n{\n  int winFunc;\n  int squareRoot;\n  double offset, gain;\n  double sigma, alpha, alpha0, alpha1, alpha2, alpha3;\n  double * win;\n  long frameSizeFrames;\n};\n\n\n// WINF_XXXXXX constants are defined in smileUtil.hpp !\n#undef class\nclass DLLEXPORT cWindower : public cVectorProcessor {\n  private:\n    double offset, gain;\n    double sigma, alpha, alpha0, alpha1, alpha2, alpha3;\n    long  frameSizeFrames;\n    int   winFunc;    // winFunc as numeric constant (see #defines above)\n    int   squareRoot;\n    double xscale;\n    double xshift;\n    double fade;\n    const char *saveWindowToFile;\n    int   dtype;     // data type (DMEM_FLOAT, DMEM_INT)\n    double *win;\n    \n    void precomputeWinFunc();\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    virtual int myFinaliseInstance();\n\n    virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cWindower(const char *_name);\n\n    // return the parsed windower config. If this function is called after the component was finalised, the *win variable will point to the precomputed window.\n    struct sWindowerConfigParsed * getWindowerConfigParsed();\n\n    virtual ~cWindower();\n};\n\n\n\n\n#endif // __WINDOWER_HPP\n"
  },
  {
    "path": "src/include/examples/componentTemplate.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\n\n*/\n\n\n#ifndef __MY_COMPONENT_HPP\n#define __MY_COMPONENT_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/smileComponent.hpp>\n\n#define COMPONENT_DESCRIPTION_CMYCOMPONENT \"a good template...\"\n#define COMPONENT_NAME_CMYCOMPONENT \"cMyComponent\"\n\n#undef class\nclass DLLEXPORT cMyComponent : public cSmileComponent {\n  private:\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n\tvirtual void fetchConfig();\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n\n    //cMyComponent(cConfigManager *cm) : cSmileComponent(\"myComponentTemplate\",cm) {}\n    cMyComponent(const char *_name);\n\n    virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n    virtual int manualConfig(); // custom function with arbirtrary parameters, use instead of fetchConfig when passing NULL for cConfigManager to constructor\n\n    virtual ~cMyComponent() {}\n};\n\n\n\n\n#endif // __MY_COMPONENT_HPP\n"
  },
  {
    "path": "src/include/examples/exampleProcessor.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample for dataProcessor descendant\n\n*/\n\n\n#ifndef __EXAMPLE_PROCESSOR_HPP\n#define __EXAMPLE_PROCESSOR_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CEXAMPLEPROCESSOR \"This is an example of a cDataProcessor descendant. It has no meaningful function, this component is intended as a template for developers.\"\n#define COMPONENT_NAME_CEXAMPLEPROCESSOR \"cExampleProcessor\"\n\n#undef class\nclass DLLEXPORT cExampleProcessor : public cDataProcessor {\n  private:\n    double offset;\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n    // virtual int dataProcessorCustomFinalise();\n    // virtual int setupNewNames(long nEl);\n    // virtual int setupNamesForField();\n    virtual int configureWriter(sDmLevelConfig &c);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cExampleProcessor(const char *_name);\n\n    virtual ~cExampleProcessor();\n};\n\n\n\n\n#endif // __EXAMPLE_PROCESSOR_HPP\n"
  },
  {
    "path": "src/include/examples/exampleSink.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample dataSink:\nreads data from data memory and outputs it to console/logfile (via smileLogger)\nthis component is also useful for debugging\n\n*/\n\n\n#ifndef __EXAMPLE_SINK_HPP\n#define __EXAMPLE_SINK_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataSink.hpp>\n\n#define COMPONENT_DESCRIPTION_CEXAMPLESINK \"This is an example of a cDataSink descendant. It reads data from the data memory and prints it to the console. This component is intended as a template for developers.\"\n#define COMPONENT_NAME_CEXAMPLESINK \"cExampleSink\"\n#define BUILD_COMPONENT_ExampleSink\n\n#undef class\nclass DLLEXPORT cExampleSink : public cDataSink {\n  private:\n    const char *filename;\n    FILE * fHandle;\n    int lag;\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cExampleSink(const char *_name);\n\n    virtual ~cExampleSink();\n};\n\n\n\n\n#endif // __EXAMPLE_SINK_HPP\n"
  },
  {
    "path": "src/include/examples/exampleSource.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample dataSource\nwrites data to data memory...\n\n*/\n\n\n#ifndef __EXAMPLE_SOURCE_HPP\n#define __EXAMPLE_SOURCE_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataSource.hpp>\n\n#define COMPONENT_DESCRIPTION_CEXAMPLESOURCE \"This is an example of a cDataSource descendant. It writes random data to the data memory. This component is intended as a template for developers.\"\n#define COMPONENT_NAME_CEXAMPLESOURCE \"cExampleSource\"\n#define BUILD_COMPONENT_ExampleSource\n\n#undef class\nclass DLLEXPORT cExampleSource : public cDataSource {\n  private:\n    int nValues;\n    double randSeed;\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n    virtual int configureWriter(sDmLevelConfig &c);\n    virtual int setupNewNames(long nEl);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cExampleSource(const char *_name);\n\n    virtual ~cExampleSource();\n};\n\n\n\n\n#endif // __EXAMPLE_SOURCE_HPP\n"
  },
  {
    "path": "src/include/examples/exampleVectorProcessor.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample vectorProcessor descendant\n\n*/\n\n\n#ifndef __EXAMPLEVECTORPROCESSOR_HPP\n#define __EXAMPLEVECTORPROCESSOR_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CEXAMPLEVECTORPROCESSOR \"This is an example of a cVectorProcessor descendant. It has no meaningful function, this component is intended as a template for developers.\"\n#define COMPONENT_NAME_CEXAMPLEVECTORPROCESSOR \"cExampleVectorProcessor\"\n\n#undef class\nclass DLLEXPORT cExampleVectorProcessor : public cVectorProcessor {\n  private:\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    //virtual int myTick(long long t);\n\n    //virtual int configureWriter(const sDmLevelConfig *c);\n\n    virtual void configureField(int idxi, long __N, long nOut);\n    //virtual int setupNamesForField(int i, const char*name, long nEl);\n    virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cExampleVectorProcessor(const char *_name);\n\n    virtual ~cExampleVectorProcessor();\n};\n\n\n\n\n#endif // __EXAMPLEVECTORPROCESSOR_HPP\n"
  },
  {
    "path": "src/include/examples/exampleWindowProcessor.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample of a windowProcessor component\n\n*/\n\n\n#ifndef __CEXAMPLEWINDOWPROCESSOR_HPP\n#define __CEXAMPLEWINDOWPROCESSOR_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/windowProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CEXAMPLEWINDOWPROCESSOR \"This is an example of a cWindowProcessor descendant. It has no meaningful function, this component is intended as a template for developers.\"\n#define COMPONENT_NAME_CEXAMPLEWINDOWPROCESSOR \"cExampleWindowProcessor\"\n\n#undef class\nclass DLLEXPORT cExampleWindowProcessor : public cWindowProcessor {\n  private:\n    FLOAT_DMEM k;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n\n    virtual void fetchConfig();\n/*\n    virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n*/\n\n    //virtual int configureWriter(const sDmLevelConfig *c);\n\n   // buffer must include all (# order) past samples\n    virtual int processBuffer(cMatrix *_in, cMatrix *_out, int _pre, int _post );\n    \n/*\n    virtual int setupNamesForField(int i, const char*name, long nEl);\n*/\n    \n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cExampleWindowProcessor(const char *_name);\n\n    virtual ~cExampleWindowProcessor();\n};\n\n\n\n\n#endif // __CEXAMPLEWINDOWPROCESSOR_HPP\n"
  },
  {
    "path": "src/include/examples/pitchBaseExample.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nThis component computes pitch via the Harmonic Product Spectrum method.\nAs input it requires FFT magnitude data. \nNote that the type of input data is not checked, thus be careful when writing your configuration files!\n\n*/\n\n\n#ifndef __CPITCHBASEEXAMPLE_HPP\n#define __CPITCHBASEEXAMPLE_HPP\n\n#include <core/smileCommon.hpp>\n#include <lldcore/pitchBase.hpp>\n\n#define COMPONENT_DESCRIPTION_CPITCHBASEEXAMPLE \"Base class for all pitch classes, no functionality on its own!\"\n#define COMPONENT_NAME_CPITCHBASEEXAMPLE \"cPitchBaseExample\"\n\n\n#undef class\nclass DLLEXPORT cPitchBaseExample : public cPitchBase {\n  private:\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    virtual void fetchConfig();\n/*\t  virtual int setupNewNames(long nEl); */\n    \n    // to be overwritten by child class:\n    virtual int pitchDetect(FLOAT_DMEM * _inData, long _N, double _fsSec, double _baseT, FLOAT_DMEM *_f0cand, FLOAT_DMEM *_candVoice, FLOAT_DMEM *_candScore, long _nCandidates);\n    virtual int addCustomOutputs(FLOAT_DMEM *dstCur, long NdstLeft);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cPitchBaseExample(const char *_name);\n    \n    virtual ~cPitchBaseExample();\n};\n\n\n\n\n#endif // __CPITCHBASEEXAMPLE_HPP\n"
  },
  {
    "path": "src/include/examples/simpleMessageSender.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nSimple message sender for debugging and testing purposes. \nReads data from an input level,\nsends a message based on a threshold event in a selectable input channel, \nor sends all read data periodically as a message.\n\n*/\n\n\n#ifndef __SIMPLE_MESSAGE_SENDER_HPP\n#define __SIMPLE_MESSAGE_SENDER_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataSink.hpp>\n\n#define COMPONENT_DESCRIPTION_CSIMPLEMESSAGESENDER \"This is an example of a cDataSink descendant. It reads data from the data memory and prints it to the console. This component is intended as a template for developers.\"\n#define COMPONENT_NAME_CSIMPLEMESSAGESENDER \"cSimpleMessageSender\"\n#define BUILD_COMPONENT_SimpleMessageSender\n\n#undef class\n\nenum cSimpleMessageSender_Conditions {\n  COND_UNDEF=0,\n  COND_GTEQ=1, // trigger event, always when input greater or equal to the reference (threshold parameter)\n  COND_GT=2,   // trigger event, always when greater\n  COND_EQ=3,   // trigger event, always when equal\n  COND_LE=4,   // trigger event, always when lesser\n  COND_LEEQ=5, // trigger event, always when lesser or equal\n  COND_GTEQ_S=101, // trigger event, only the first time the value is greater or equal\n  COND_GT_S=102,   // trigger event, only the first time the value is greater\n  COND_EQ_S=103,   // trigger event, only the first time the value is equal\n  COND_LE_S=104,   // trigger event, only the first time the value is lesser\n  COND_LEEQ_S=105, // trigger event, only the first time the value is lesser or equal\n};\n\nclass DLLEXPORT cSimpleMessageSender : public cDataSink {\n  private:\n    const char *messageRecp;  // the comma separated list of message receipients (component names)\n    const char *messageName;\n    const char *messageType;\n    bool showCustDataAsText, showCustData2AsText;\n    bool sendPeriodically;        // Flag to enable/disable sending of periodic messages (sending of every value read from the input)\n    bool enableDebugReceiver;     // Flag to enable/disable the debug print functionality for received(!) messages.\n    bool enableDebugSender;       // Flag to enable/disable the debug print functionality for sent messages (before sending).\n    const char *dataElementName;  // the name of the input element to send periodically or base event decisions on\n    long dataElementIndex;\n    FLOAT_DMEM threshold;         // the threshold for triggering an event\n    cSimpleMessageSender_Conditions condition;  // the operation to apply to the element with dataElementName to trigger event based messages\n\n    bool condFlag;   // used as state variable for the _S event conditions\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n    // Implements a debug message receiver here. It prints all received messages to the log.\n    virtual int processComponentMessage(cComponentMessage *_msg);\n\n    void sendMessage(cComponentMessage *msg);\n    void printMessage(cComponentMessage *msg);\n    void sendPeriodicMessage(FLOAT_DMEM *v, int Nv, long vi, double tm);\n    void sendEventMessage(FLOAT_DMEM *v, int Nv, const char * text, FLOAT_DMEM ref, long vi, double tm);\n    void eventMessage(FLOAT_DMEM v, long vi, double tm);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cSimpleMessageSender (const char *_name);\n\n    virtual ~cSimpleMessageSender();\n};\n\n\n\n\n#endif // __SIMPLE_MESSAGE_SENDER_HPP\n"
  },
  {
    "path": "src/include/examples/smileComponentExample.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample for a cSmileComponent descendant\n\n*/\n\n\n#ifndef __CSMILECOMPONENTEXAMPLE_HPP\n#define __CSMILECOMPONENTEXAMPLE_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/smileComponent.hpp>\n\n#define COMPONENT_DESCRIPTION_CSMILECOMPONENTEXAMPLE \"example for a cSmileComponent descendant\"\n#define COMPONENT_NAME_CSMILECOMPONENTEXAMPLE \"cSmileComponentExample\"\n\n\n#undef class\nclass DLLEXPORT cSmileComponentExample : public cSmileComponent {\n  private:\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    virtual void mySetEnvironment();\n    virtual int myRegisterInstance();\n    virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n    virtual int processComponentMessage( cComponentMessage *_msg );\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n\n    cSmileComponentExample(const char *_name);\n    virtual ~cSmileComponentExample();\n};\n\n\n\n\n#endif // __CSMILECOMPONENTEXAMPLE_HPP\n"
  },
  {
    "path": "src/include/functionals/functionalComponent.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\na single statistical functional or the like....\n(template class)\n\n*/\n\n\n#ifndef __CFUNCTIONAL_HPP\n#define __CFUNCTIONAL_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataMemory.hpp>\n#include <core/dataWriter.hpp>\n\n#define COMPONENT_DESCRIPTION_CFUNCTIONALCOMPONENT \"This is an abstract functional class, it is the base for all functional extractor classes.\"\n#define COMPONENT_NAME_CFUNCTIONALCOMPONENT \"cFunctionalComponent\"\n\n#define TIMENORM_UNDEFINED   -1\n#define TIMENORM_SEGMENT   0\n#define TIMENORM_SECOND    1\n#define TIMENORM_SECONDS   1\n#define TIMENORM_FRAME     2\n#define TIMENORM_FRAMES    2\n#define TIMENORM_SAMPLE    3  // currently not implemented\n#define TIMENORM_SAMPLES   3  // currently not implemented\n#define _TIMENORM_MAX      3\n\n// obsolete: please use TIMENORM_XXX constants in new code..!\n#define NORM_TURN     0\n#define NORM_SECOND   1\n#define NORM_FRAME    2\n#define NORM_SAMPLES  3\n\n\n#undef class\nclass DLLEXPORT cFunctionalComponent : public cSmileComponent {\n  private:\n    double T;\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    int nEnab, nTotal;\n    int *enab;\n    int timeNorm, timeNormIsSet;\n    const char **functNames;\n    \n    virtual void fetchConfig();\n    // get size of one input element/frame in seconds\n    double getInputPeriod() {\n      return T;\n    }\n    // parse a custom 'norm' (timeNorm) option if set (call this from fetchConfig)\n    void parseTimeNormOption();\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cFunctionalComponent(const char *_name, int _nTotal=0, const char *_names[]=NULL);\n    void setInputPeriod(double _T) { T=_T; }\n\n    void setTimeNorm(int _norm) { \n      if (!timeNormIsSet) {\n        if ((_norm >= 0)&&(_norm <= _TIMENORM_MAX)&&(_norm!=TIMENORM_UNDEFINED)) {\n          timeNorm = _norm;\n        }\n      }\n    }\n\n    // inputs: sorted and unsorted array of values, out: pointer to space in output array,\n    // You may not return MORE than Nout elements, please return as return value the number\n    // of actually computed elements (usually Nout)\n    virtual long process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM *out, long Nin, long Nout);\n    virtual long process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM min,\n        FLOAT_DMEM max, FLOAT_DMEM mean, FLOAT_DMEM *out, long Nin, long Nout)\n    {\n      return process(in,inSorted,out,Nin,Nout);\n    }\n    \n    virtual long process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout);\n    virtual long process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM min,\n        INT_DMEM max, INT_DMEM mean, INT_DMEM *out, long Nin, long Nout)\n    {\n      return process(in,inSorted,out,Nin,Nout);\n    }\n\n    virtual void setFieldMetaData(cDataWriter *writer,\n        const FrameMetaInfo *fmeta, int idxi, long nEl);\n    virtual long getNoutputValues() { return nEnab; }\n    virtual long getNumberOfElements(long j) { return 1; }\n    virtual const char* getValueName(long i);\n    virtual int getRequireSorted() { return 0; }\n\n    virtual ~cFunctionalComponent();\n};\n\n\n\n\n#endif // __CFUNCTIONAL_HPP\n"
  },
  {
    "path": "src/include/functionals/functionalCrossings.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctionals: zero-crossings, mean-crossings, arithmetic mean\n\n*/\n\n\n#ifndef __CFUNCTIONALCROSSINGS_HPP\n#define __CFUNCTIONALCROSSINGS_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataMemory.hpp>\n#include <functionals/functionalComponent.hpp>\n\n#define COMPONENT_DESCRIPTION_CFUNCTIONALCROSSINGS \"  zero-crossing rate, mean crossing rate, dc offset, min, and max value\"\n#define COMPONENT_NAME_CFUNCTIONALCROSSINGS \"cFunctionalCrossings\"\n\n#undef class\nclass DLLEXPORT cFunctionalCrossings : public cFunctionalComponent {\n  private:\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    virtual void fetchConfig();\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cFunctionalCrossings(const char *_name);\n    // inputs: sorted and unsorted array of values, out: pointer to space in output array, You may not return MORE than Nout elements, please return as return value the number of actually computed elements (usually Nout)\n    virtual long process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM *out, long Nin, long Nout);\n    //virtual long process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout);\n\n//    virtual long getNoutputValues() { return nEnab; }\n    virtual int getRequireSorted() { return 0; }\n\n    virtual ~cFunctionalCrossings();\n};\n\n\n\n\n#endif // __CFUNCTIONALCROSSINGS_HPP\n"
  },
  {
    "path": "src/include/functionals/functionalDCT.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nnumber of segments based on delta thresholding\n\n*/\n\n\n#ifndef __CFUNCTIONALDCT_HPP\n#define __CFUNCTIONALDCT_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataMemory.hpp>\n#include <functionals/functionalComponent.hpp>\n\n#define COMPONENT_DESCRIPTION_CFUNCTIONALDCT \"  DCT coefficients\"\n#define COMPONENT_NAME_CFUNCTIONALDCT \"cFunctionalDCT\"\n\n#undef class\nclass DLLEXPORT cFunctionalDCT : public cFunctionalComponent {\nprivate:\n  int firstCoeff, lastCoeff;\n  int nCo;\n  long N;\n  long costableNin;\n  FLOAT_DMEM * costable;\n  FLOAT_DMEM factor;\n  char *tmpstr;\n\nprotected:\n  SMILECOMPONENT_STATIC_DECL_PR\n    virtual void fetchConfig();\n  virtual void initCostable(long Nin, long Nout);\n\npublic:\n  SMILECOMPONENT_STATIC_DECL\n\n    cFunctionalDCT(const char *_name);\n  // inputs: sorted and unsorted array of values, out: pointer to space in output array, You may not return MORE than Nout elements, please return as return value the number of actually computed elements (usually Nout)\n  virtual long process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM *out, long Nin, long Nout);\n  //virtual long process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout);\n  virtual const char * getValueName(long i);\n\n  virtual long getNoutputValues() { return nEnab; }\n  virtual int getRequireSorted() { return 0; }\n\n  virtual ~cFunctionalDCT();\n};\n\n\n\n\n#endif // __CFUNCTIONALDCT_HPP\n"
  },
  {
    "path": "src/include/functionals/functionalExtremes.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctionals: extreme values and ranges\n\n*/\n\n\n\n#ifndef __CFUNCTIONALEXTREMES_HPP\n#define __CFUNCTIONALEXTREMES_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataMemory.hpp>\n#include <functionals/functionalComponent.hpp>\n\n#define COMPONENT_DESCRIPTION_CFUNCTIONALEXTREMES \"  extreme values (max, min, range, maxPos, minPos, ...)\"\n#define COMPONENT_NAME_CFUNCTIONALEXTREMES \"cFunctionalExtremes\"\n\n#undef class\nclass DLLEXPORT cFunctionalExtremes : public cFunctionalComponent {\n  private:\n    int norm;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    virtual void fetchConfig();\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cFunctionalExtremes(const char *_name);\n    // inputs: sorted and unsorted array of values, out: pointer to space in output array, You may not return MORE than Nout elements, please return as return value the number of actually computed elements (usually Nout)\n    virtual long process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM min, FLOAT_DMEM max, FLOAT_DMEM mean, FLOAT_DMEM *out, long Nin, long Nout);\n    //virtual long process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout);\n\n    virtual long getNoutputValues() { return nEnab; }\n    virtual int getRequireSorted() { return 0; }\n\n    virtual ~cFunctionalExtremes();\n};\n\n\n\n\n#endif // __CFUNCTIONALEXTREMES_HPP\n"
  },
  {
    "path": "src/include/functionals/functionalLpc.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nnumber of segments based on delta thresholding\n\n*/\n\n\n#ifndef __CFUNCTIONALLPC_HPP\n#define __CFUNCTIONALLPC_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataMemory.hpp>\n#include <functionals/functionalComponent.hpp>\n\n#define COMPONENT_DESCRIPTION_CFUNCTIONALLPC \"  LP coefficients as functionals\"\n#define COMPONENT_NAME_CFUNCTIONALLPC \"cFunctionalLpc\"\n\n#undef class\nclass DLLEXPORT cFunctionalLpc : public cFunctionalComponent {\nprivate:\n  int firstCoeff, lastCoeff, order;\n  FLOAT_DMEM *acf, *lpc;\n  char * tmpstr;\n\nprotected:\n  SMILECOMPONENT_STATIC_DECL_PR\n    virtual void fetchConfig();\n\npublic:\n  SMILECOMPONENT_STATIC_DECL\n\n    cFunctionalLpc(const char *_name);\n  // inputs: sorted and unsorted array of values, out: pointer to space in output array, You may not return MORE than Nout elements, please return as return value the number of actually computed elements (usually Nout)\n  virtual long process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM *out, long Nin, long Nout);\n  //virtual long process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout);\n  virtual const char * getValueName(long i);\n\n  virtual long getNoutputValues() { return nEnab; }\n  virtual int getRequireSorted() { return 0; }\n\n  virtual ~cFunctionalLpc();\n};\n\n\n\n\n#endif // __CFUNCTIONALLPC_HPP\n"
  },
  {
    "path": "src/include/functionals/functionalMeans.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctionals:\nvarious means, arithmetic, geometric, quadratic, etc.\nalso number of non-zero values, etc.\n\n*/\n\n\n\n#ifndef __CFUNCTIONALMEANS_HPP\n#define __CFUNCTIONALMEANS_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataMemory.hpp>\n#include <functionals/functionalComponent.hpp>\n\n#define COMPONENT_DESCRIPTION_CFUNCTIONALMEANS \"  various mean values (arithmetic, geometric, quadratic, ...)\"\n#define COMPONENT_NAME_CFUNCTIONALMEANS \"cFunctionalMeans\"\n\n#undef class\nclass DLLEXPORT cFunctionalMeans : public cFunctionalComponent {\n  private:\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    virtual void fetchConfig();\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cFunctionalMeans(const char *_name);\n    // inputs: sorted and unsorted array of values, out: pointer to space in output array, You may not return MORE than Nout elements, please return as return value the number of actually computed elements (usually Nout)\n    virtual long process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM min, FLOAT_DMEM max, FLOAT_DMEM mean, FLOAT_DMEM *out, long Nin, long Nout);\n    //virtual long process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout);\n\n    virtual long getNoutputValues() { return nEnab; }\n    virtual int getRequireSorted() { return 0; }\n\n    virtual ~cFunctionalMeans();\n};\n\n\n\n\n#endif // __CFUNCTIONALMEANS_HPP\n"
  },
  {
    "path": "src/include/functionals/functionalModulation.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nnumber of segments based on delta thresholding\n\n*/\n\n\n#ifndef __CFUNCTIONALMODULATION_HPP\n#define __CFUNCTIONALMODULATION_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataMemory.hpp>\n#include <functionals/functionalComponent.hpp>\n\n#define COMPONENT_DESCRIPTION_CFUNCTIONALMODULATION \"  Modulation Spectrum\"\n#define COMPONENT_NAME_CFUNCTIONALMODULATION \"cFunctionalModulation\"\n\nclass cSmileUtilWindowedMagnitudeSpectrum {\nprivate:\n  FLOAT_TYPE_FFT * fftWork_;  // fft work area (size Nfft)\n  int * ip_;\n  FLOAT_TYPE_FFT * w_;\n  FLOAT_DMEM * winFunc_;\n  int winFuncId_;\n  long Nfft_;  // number of samples to perform FFT on (after zero-padding)\n  long Nin_;  // number of inputs (for window function)\n\nprotected:\n  void allocateWinFunc(long Nin);\n  void allocateFFTworkspace(long Nin);\n  void freeFFTworkspace();\n  void freeWinFunc();\n  void copyInputAndZeropad(const FLOAT_DMEM *in, long Nin, bool allowWinSmaller);\n  void doFFT();\n  void computeMagnitudes();\n\npublic:\n  cSmileUtilWindowedMagnitudeSpectrum():\n    fftWork_(NULL),\n    ip_(NULL), w_(NULL),\n    winFunc_(NULL), winFuncId_(0),\n    Nin_(0), Nfft_(0) {}\n\n  long getNin() {\n    return Nin_;\n  }\n  cSmileUtilWindowedMagnitudeSpectrum(long Nin, int winFuncId);\n  ~cSmileUtilWindowedMagnitudeSpectrum();\n\n  // T is the period of one input sample\n  // Returns the frequency width of each FFT magnitude bin (deltaF)\n  double getBinDeltaF(double T) {\n    if (T == 0.0) {\n      return 0.0;\n    } else {\n      return 1.0 / (T * (double)Nfft_);\n    }\n  }\n  const FLOAT_DMEM * getMagnitudes(const FLOAT_DMEM *in,\n      long Nin, bool allowWinSmaller);\n  long getNmagnitudes() {\n    return Nfft_ / 2 + 1;\n  }\n};\n\nclass cSmileUtilMappedMagnitudeSpectrum {\nprivate:\n  long Nmag_;\n  long Nout_;  // number of output bins\n  cSmileUtilWindowedMagnitudeSpectrum *fft_;\n  FLOAT_DMEM * modSpec_;  // the actual modulation spectrum\n  double minFreq_;\n  double maxFreq_;\n  FLOAT_DMEM * splineWork_;\n  FLOAT_DMEM * splineDerivs_;\n  FLOAT_DMEM * magFreq_;\n  double deltaF_;\n  double T_;\n\nprotected:\n  void mapMagnitudesToModSpecBins(const FLOAT_DMEM *mag, long N);\n\npublic:\n  cSmileUtilMappedMagnitudeSpectrum():\n    modSpec_(NULL), fft_(NULL), Nmag_(0),\n    splineWork_(NULL), splineDerivs_(NULL), magFreq_(NULL) {}\n\n  long getNin() {\n    if (fft_ != NULL)\n      return fft_->getNin();\n    return 0;\n  }\n\n  cSmileUtilMappedMagnitudeSpectrum(\n      long Nin,       // number of input samples (before zero padding)\n      long Nout,      // number of modulation spectrum bins\n      int winFuncId,  // window function numeric ID (see smileutil)\n      double minFreq, double maxFreq, // min/max frequency of modulation spectrum\n      double T        // T is the sample/frame period  (to be able to map FFT bins to frequencies)\n      );\n  ~cSmileUtilMappedMagnitudeSpectrum();\n\n  void compute(const FLOAT_DMEM *in, long Nin, bool allowWinSmaller);\n  const FLOAT_DMEM * getModSpec();\n  long getModSpecN() {\n    return Nout_;\n  }\n};\n\n\n////////////////////////\n\n#undef class\nclass DLLEXPORT cFunctionalModulation : public cFunctionalComponent {\nprivate:\n  double stftWinSizeSec_;\n  double stftWinStepSec_;\n  long stftWinSizeFrames_;\n  long stftWinStepFrames_;\n  double modSpecMinFreq_;\n  double modSpecMaxFreq_;\n  int modSpecNumBins_;\n  double modSpecResolution_;\n  int winFuncId_;\n  int removeNonZeroMean_;\n  int ignoreLastFrameIfTooShort_;\n\n  FLOAT_DMEM *inNorm_;\n  long inNormN_;\n  FLOAT_DMEM *avgModSpec_;\n  cSmileUtilMappedMagnitudeSpectrum *mappedSpec_;\n  char * tmpstr_;\n\nprotected:\n  SMILECOMPONENT_STATIC_DECL_PR\n  virtual void fetchConfig();\n  void computeModSpecSTFT(const FLOAT_DMEM *in, long Nin);\n  int computeModSpecSTFTavg(const FLOAT_DMEM *in, long Nin, FLOAT_DMEM *ms);\n\npublic:\n  SMILECOMPONENT_STATIC_DECL\n\n  cFunctionalModulation(const char *_name);\n  // inputs: sorted and unsorted array of values, out: pointer to space in output array, You may not return MORE than Nout elements, please return as return value the number of actually computed elements (usually Nout)\n  virtual long process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM *out, long Nin, long Nout);\n  //virtual long process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout);\n  virtual const char * getValueName(long i);\n  virtual void setFieldMetaData(cDataWriter *writer,\n          const FrameMetaInfo *fmeta, int idxi, long nEl);\n  virtual long getNumberOfElements(long j);\n  virtual long getNoutputValues() { return nEnab; }\n  virtual int getRequireSorted() { return 0; }\n\n  virtual ~cFunctionalModulation();\n};\n\n\n\n\n#endif // __CFUNCTIONALMODULATION_HPP\n"
  },
  {
    "path": "src/include/functionals/functionalMoments.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctionals: statistical moments\n\n*/\n\n\n\n#ifndef __CFUNCTIONALMOMENTS_HPP\n#define __CFUNCTIONALMOMENTS_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataMemory.hpp>\n#include <functionals/functionalComponent.hpp>\n\n#define COMPONENT_DESCRIPTION_CFUNCTIONALMOMENTS \"  statistical moments (standard deviation, variance, skewness, kurtosis)\"\n#define COMPONENT_NAME_CFUNCTIONALMOMENTS \"cFunctionalMoments\"\n\n#undef class\nclass DLLEXPORT cFunctionalMoments : public cFunctionalComponent {\n  private:\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    virtual void fetchConfig();\n    int doRatioLimit_;\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cFunctionalMoments(const char *_name);\n    // inputs: sorted and unsorted array of values, out: pointer to space in output array, You may not return MORE than Nout elements, please return as return value the number of actually computed elements (usually Nout)\n    virtual long process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM min, FLOAT_DMEM max, FLOAT_DMEM mean, FLOAT_DMEM *out, long Nin, long Nout);\n    //virtual long process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout);\n\n    virtual long getNoutputValues() { return nEnab; }\n    virtual int getRequireSorted() { return 0; }\n\n    virtual ~cFunctionalMoments();\n};\n\n\n\n\n#endif // __CFUNCTIONALMOMENTS_HPP\n"
  },
  {
    "path": "src/include/functionals/functionalOnset.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nnumber of segments based on delta thresholding\n\n*/\n\n\n#ifndef __CFUNCTIONALONSET_HPP\n#define __CFUNCTIONALONSET_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataMemory.hpp>\n#include <functionals/functionalComponent.hpp>\n\n#define COMPONENT_DESCRIPTION_CFUNCTIONALONSET \"  relative position of the first onset and the last offset based on simple thresholding. Number of onsets and offsets can also be computed.\"\n#define COMPONENT_NAME_CFUNCTIONALONSET \"cFunctionalOnset\"\n\n#undef class\nclass DLLEXPORT cFunctionalOnset : public cFunctionalComponent {\n  private:\n    int useAbsVal;\n    FLOAT_DMEM thresholdOnset, thresholdOffset;\n\t//int overlapFlag;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    virtual void fetchConfig();\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cFunctionalOnset(const char *_name);\n    // inputs: sorted and unsorted array of values, out: pointer to space in output array, You may not return MORE than Nout elements, please return as return value the number of actually computed elements (usually Nout)\n    virtual long process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM *out, long Nin, long Nout);\n    //virtual long process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout);\n\n    virtual long getNoutputValues() { return nEnab; }\n    virtual int getRequireSorted() { return 0; }\n\n    virtual ~cFunctionalOnset();\n};\n\n\n\n\n#endif // __CFUNCTIONALONSET_HPP\n"
  },
  {
    "path": "src/include/functionals/functionalPeaks.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctionals: number of peaks and various measures associated with peaks\n\n*/\n\n\n#ifndef __CFUNCTIONALPEAKS_HPP\n#define __CFUNCTIONALPEAKS_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataMemory.hpp>\n#include <functionals/functionalComponent.hpp>\n\n#define COMPONENT_DESCRIPTION_CFUNCTIONALPEAKS \"  number of peaks and various measures associated with peaks, such as mean of peaks, mean distance between peaks, etc. Peak finding is based on : x(t-1) < x(t) > x(t+1).\"\n#define COMPONENT_NAME_CFUNCTIONALPEAKS \"cFunctionalPeaks\"\n\n\n#undef class\nclass DLLEXPORT cFunctionalPeaks : public cFunctionalComponent {\n  private:\n    FLOAT_DMEM lastVal, lastlastVal;\n\t  int overlapFlag;\n\t  int nPeakdists;\n\t  long *peakdists;\n\t  void addPeakDist(int idx, long dist);\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    virtual void fetchConfig();\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cFunctionalPeaks(const char *_name);\n    // inputs: sorted and unsorted array of values, out: pointer to space in output array, You may not return MORE than Nout elements, please return as return value the number of actually computed elements (usually Nout)\n    virtual long process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM *out, long Nin, long Nout);\n    //virtual long process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout);\n\n    virtual long getNoutputValues() { return nEnab; }\n    virtual int getRequireSorted() { return 0; }\n\n    virtual ~cFunctionalPeaks();\n};\n\n\n\n\n#endif // __CFUNCTIONALPEAKS_HPP\n"
  },
  {
    "path": "src/include/functionals/functionalPeaks2.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctionals: number of peaks and various measures associated with peaks\n\n*/\n\n\n#ifndef __CFUNCTIONALPEAKS2_HPP\n#define __CFUNCTIONALPEAKS2_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataMemory.hpp>\n#include <functionals/functionalComponent.hpp>\n\n#define COMPONENT_DESCRIPTION_CFUNCTIONALPEAKS2 \"  number of peaks and various measures associated with peaks, such as mean of peaks, mean distance between peaks, etc. Peak finding is based on : x(t-1) < x(t) > x(t+1) plus an advanced post filtering of low relative amplitude peaks. See source code for brief description of peak picking algorithm. This component provideas a new and improved algorithm for peak detection, as compared to cFunctionalPeaks component.\"\n#define COMPONENT_NAME_CFUNCTIONALPEAKS2 \"cFunctionalPeaks2\"\n\n\n#undef class\nstruct peakMinMaxListEl {\n  int type;\n  FLOAT_DMEM y;\n  long x;\n  struct peakMinMaxListEl * next, *prev;\n};\n\nclass DLLEXPORT cFunctionalPeaks2 : public cFunctionalComponent {\n  private:\n    int enabSlope;\n    int noClearPeakList;\n\n    FLOAT_DMEM relThresh;\n    FLOAT_DMEM absThresh;\n    int useAbsThresh;\n    int dynRelThresh;\n    int isBelowThresh(FLOAT_DMEM diff, FLOAT_DMEM base);\n\n    struct peakMinMaxListEl * mmlistFirst;\n    struct peakMinMaxListEl * mmlistLast;\n    void addMinMax(int type, FLOAT_DMEM y, long x);\n    void dbgPrintMinMaxList(struct peakMinMaxListEl * listEl);\n    void removeFromMinMaxList( struct peakMinMaxListEl * listEl );\n    void clearList();\n\n    FILE *dbg;\n    int consoleDbg;\n    const char *posDbgOutp;\n    int posDbgAppend;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    virtual void fetchConfig();\n    int doRatioLimit_;\n\n    // soft limit to [-10;10] (linear) and non-linear hard-limit\n    // to [-20;20] for inputs [-inf;+inf]\n    FLOAT_DMEM ratioLimit(FLOAT_DMEM x) {\n      if (doRatioLimit_) {\n        return smileMath_ratioLimit(x, 10.0, 10.0);\n      }\n      return x;\n    }\n    FLOAT_DMEM ratioLimitMax(FLOAT_DMEM altValue) {\n      if (doRatioLimit_) {\n        return 20.0;  // sum of limit1 + limit2 in above function\n      }\n      return altValue;\n    }\n\n    // limit to -1..+1\n    FLOAT_DMEM ratioLimitUnity(FLOAT_DMEM x) {\n      if (doRatioLimit_) {\n        //printf(\"Ratio unity limit: In: %e\\n\", x);\n        if (x > (FLOAT_DMEM)1.0)\n          return (FLOAT_DMEM)1.0;\n        if (x < (FLOAT_DMEM)-1.0)\n          return (FLOAT_DMEM)-1.0;\n      }\n      return x;\n    }\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cFunctionalPeaks2(const char *_name);\n    // inputs: sorted and unsorted array of values, out: pointer to space in output array, You may not return MORE than Nout elements, please return as return value the number of actually computed elements (usually Nout)\n    virtual long process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM min, FLOAT_DMEM max, FLOAT_DMEM mean, FLOAT_DMEM *out, long Nin, long Nout);\n    //virtual long process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout);\n\n    virtual long getNoutputValues() { return nEnab; }\n    virtual int getRequireSorted() { return 0; }\n\n    virtual ~cFunctionalPeaks2();\n};\n\n\n\n\n#endif // __CFUNCTIONALPEAKS2_HPP\n"
  },
  {
    "path": "src/include/functionals/functionalPercentiles.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctionals: percentiles and quartiles, and inter-percentile/quartile ranges\n\n*/\n\n\n#ifndef __CFUNCTIONALPERCENTILES_HPP\n#define __CFUNCTIONALPERCENTILES_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataMemory.hpp>\n#include <functionals/functionalComponent.hpp>\n\n#define COMPONENT_DESCRIPTION_CFUNCTIONALPERCENTILES \"  percentile values and inter-percentile ranges (including quartiles, etc.). This component sorts the input array and then chooses the value at the index closest to p*buffer_len for the p-th percentile (p=0..1).\"\n#define COMPONENT_NAME_CFUNCTIONALPERCENTILES \"cFunctionalPercentiles\"\n\n#undef class\nclass DLLEXPORT cFunctionalPercentiles : public cFunctionalComponent {\n  private:\n    int nPctl, nPctlRange, nPctlQuot;\n    double *pctl;\n    int *pctlr1, *pctlr2;\n    int *pctlq1, *pctlq2;\n    char *tmpstr;\n    int quickAlgo, interp;\n    long varFctIdx;\n\n    long getPctlIdx(double p, long N);\n    FLOAT_DMEM getInterpPctl(double p, FLOAT_DMEM *sorted, long N);\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    virtual void fetchConfig();\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cFunctionalPercentiles(const char *_name);\n    // inputs: sorted and unsorted array of values, out: pointer to space in output array, You may not return MORE than Nout elements, please return as return value the number of actually computed elements (usually Nout)\n    virtual long process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM *out, long Nin, long Nout);\n    //virtual long process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout);\n\n    //virtual long getNoutputValues() { return nEnab; }\n    virtual const char* getValueName(long i);\n    virtual int getRequireSorted() { if (quickAlgo) return 0; else return 1; }\n\n    virtual ~cFunctionalPercentiles();\n};\n\n\n\n\n#endif // __CFUNCTIONALPERCENTILES_HPP\n"
  },
  {
    "path": "src/include/functionals/functionalRegression.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctionals: linear and quadratic regression coefficients\n\n*/\n\n\n#ifndef __CFUNCTIONALREGRESSION_HPP\n#define __CFUNCTIONALREGRESSION_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataMemory.hpp>\n#include <functionals/functionalComponent.hpp>\n\n#define COMPONENT_DESCRIPTION_CFUNCTIONALREGRESSION \"  linear and quadratic regression coefficients and corresponding linear and quadratic regression errors. Linear regression line: y = m*x + t ; quadratic regression parabola: y = a*x^2 + b*x + c . Algorithm used: Minimum mean square error, direct analytic solution. This component also computes the centroid of the contour.\"\n#define COMPONENT_NAME_CFUNCTIONALREGRESSION \"cFunctionalRegression\"\n\n#undef class\nclass DLLEXPORT cFunctionalRegression : public cFunctionalComponent {\n  private:\n    int enQreg;\n    int oldBuggyQerr;\n    int normRegCoeff;\n    int normInputs;\n    int centroidNorm;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    virtual void fetchConfig();\n\n    int doRatioLimit_;\n    int centroidRatioLimit_;\n    int centroidUseAbsValues_;\n\n    // soft limit to [-10;10] (linear) and non-linear hard-limit\n    // to [-20;20] for inputs [-inf;+inf]\n    FLOAT_DMEM ratioLimit(FLOAT_DMEM x) {\n      if (doRatioLimit_) {\n        return smileMath_ratioLimit(x, 10.0, 10.0);\n      }\n      return x;\n    }\n    FLOAT_DMEM ratioLimitMax(FLOAT_DMEM altValue) {\n      if (doRatioLimit_) {\n        return 20.0;  // sum of limit1 + limit2 in above function\n      }\n      return altValue;\n    }\n\n    // limit to -1..+1\n    FLOAT_DMEM ratioLimitUnity(FLOAT_DMEM x) {\n      if (doRatioLimit_) {\n        if (x > (FLOAT_DMEM)1.0)\n          return (FLOAT_DMEM)1.0;\n        if (x < (FLOAT_DMEM)-1.0)\n          return (FLOAT_DMEM)-1.0;\n      } \n      return x;\n    }\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cFunctionalRegression(const char *_name);\n    // inputs: sorted and unsorted array of values, out: pointer to space in output array, You may not return MORE than Nout elements, please return as return value the number of actually computed elements (usually Nout)\n    virtual long process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM min, FLOAT_DMEM max, FLOAT_DMEM mean, FLOAT_DMEM *out, long Nin, long Nout);\n    //virtual long process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout);\n\n    virtual long getNoutputValues() { return nEnab; }\n    virtual int getRequireSorted() { return 0; }\n\n    virtual ~cFunctionalRegression();\n};\n\n\n\n\n#endif // __CFUNCTIONALREGRESSION_HPP\n"
  },
  {
    "path": "src/include/functionals/functionalSamples.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctionals: rise/fall times, up/down-level times\n\n*/\n\n#ifndef __CFUNCTIONALSAMPLES_HPP\n#define __CFUNCTIONALSAMPLES_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataMemory.hpp>\n#include <functionals/functionalComponent.hpp>\n\n#define COMPONENT_DESCRIPTION_CFUNCTIONALSAMPLES \"sampled values at equidistant frames\"\n#define COMPONENT_NAME_CFUNCTIONALSAMPLES \"cFunctionalSamples\"\n\n#undef class\nclass DLLEXPORT cFunctionalSamples : public cFunctionalComponent {\n  private:\n    double* samplepos;\n    int nSamples;\n    char *tmpstr;\n    /*int nUltime, nDltime;\n    double *ultime, *dltime;\n    int norm;\n    int varFctIdx;*/\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    virtual void fetchConfig();\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cFunctionalSamples(const char *_name);\n    // inputs: sorted and unsorted array of values, out: pointer to space in output array, You may not return MORE than Nout elements, please return as return value the number of actually computed elements (usually Nout)\n    virtual long process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM min, FLOAT_DMEM max, FLOAT_DMEM mean, FLOAT_DMEM *out, long Nin, long Nout);\n    //virtual long process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout);\n\n    //virtual long getNoutputValues() { return nEnab; }\n    virtual const char* getValueName(long i);\n    virtual int getRequireSorted() { return 0; }\n\n    virtual ~cFunctionalSamples();\n};\n\n\n\n\n#endif // __CFUNCTIONALSAMPLES_HPP\n"
  },
  {
    "path": "src/include/functionals/functionalSegments.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nnumber of segments based on delta thresholding\n\n*/\n\n\n#ifndef __CFUNCTIONALSEGMENTS_HPP\n#define __CFUNCTIONALSEGMENTS_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataMemory.hpp>\n#include <functionals/functionalComponent.hpp>\n\n#define COMPONENT_DESCRIPTION_CFUNCTIONALSEGMENTS \"  number of segments based on simple delta thresholding\"\n#define COMPONENT_NAME_CFUNCTIONALSEGMENTS \"cFunctionalSegments\"\n\n\n#define SEG_DELTA  1\n#define SEG_ABSTH  2\n#define SEG_RELTH  3\n#define SEG_ABSTH_NOAVG  4\n#define SEG_RELTH_NOAVG  5\n#define SEG_MRELTH  6\n#define SEG_MRELTH_NOAVG  7\n#define SEG_DELTA2  8\n\n#define SEG_CHX  101\n#define SEG_NONX  102\n#define SEG_EQX  103\n#define SEG_LTX  104\n#define SEG_GTX  105\n#define SEG_LEQX  106\n#define SEG_GEQX  107\n\nstruct sSegData {\n  FLOAT_DMEM mean;\n  FLOAT_DMEM range;\n  FLOAT_DMEM max,min;\n  long * segLens;\n\n  long nSegments;\n  long meanSegLen;\n  long maxSegLen;\n  long minSegLen;\n  long seglenStddev;\n};\n\n#undef class\nclass DLLEXPORT cFunctionalSegments : public cFunctionalComponent {\n  private:\n    int dbgPrint;\n    int useOldBuggyChX;   // use old buggy version of ChX, EqX and NonX\n    int autoSegMinLng;\n    long manualRavgLng;\n    int segmentationAlgorithm;\n    long maxNumSeg;\n    long maxNumSeg0;\n    int growDynSegBuffer;\n    long segMinLng, pauseMinLng;\n    FLOAT_DMEM rangeRelThreshold;\n    FLOAT_DMEM X;\n    int XisRel;\n    int nThresholds;\n    FLOAT_DMEM *thresholds, *thresholdsTemp;\n    //int overlapFlag;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    virtual void fetchConfig();\n\n    long addNewSegment(long i, long lastSeg, sSegData *result);\n    int process_SegDelta(FLOAT_DMEM *in, FLOAT_DMEM *out, long Nin, long Nout, sSegData *result);\n    int process_SegDelta2(FLOAT_DMEM *in, FLOAT_DMEM *out, long Nin, long Nout, sSegData *result);\n    int process_SegThresh(FLOAT_DMEM *in, FLOAT_DMEM *out, long Nin, long Nout, sSegData *result);\n    int process_SegThreshNoavg(FLOAT_DMEM *in, FLOAT_DMEM *out, long Nin, long Nout, sSegData *result);\n    int process_SegChX_oldBuggy(FLOAT_DMEM *in, FLOAT_DMEM *out, long Nin, long Nout, sSegData *result);\n    int process_SegNonX_oldBuggy(FLOAT_DMEM *in, FLOAT_DMEM *out, long Nin, long Nout, sSegData *result);\n    int process_SegEqX_oldBuggy(FLOAT_DMEM *in, FLOAT_DMEM *out, long Nin, long Nout, sSegData *result);\n    int process_SegChX(FLOAT_DMEM *in, FLOAT_DMEM *out, long Nin, long Nout, sSegData *result);\n    int process_SegNonX(FLOAT_DMEM *in, FLOAT_DMEM *out, long Nin, long Nout, sSegData *result);\n    int process_SegEqX(FLOAT_DMEM *in, FLOAT_DMEM *out, long Nin, long Nout, sSegData *result);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cFunctionalSegments(const char *_name);\n\n\n    // inputs: sorted and unsorted array of values, out: pointer to space in output array, You may not return MORE than Nout elements, please return as return value the number of actually computed elements (usually Nout)\n    virtual long process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM min, FLOAT_DMEM max, FLOAT_DMEM mean, FLOAT_DMEM *out, long Nin, long Nout);\n    //virtual long process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout);\n\n    virtual long getNoutputValues() { return nEnab; }\n    virtual int getRequireSorted() { return 0; }\n\n    virtual ~cFunctionalSegments();\n};\n\n\n\n\n#endif // __CFUNCTIONALSEGMENTS_HPP\n"
  },
  {
    "path": "src/include/functionals/functionalTimes.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctionals: rise/fall times, up/down-level times\n\n*/\n\n#ifndef __CFUNCTIONALTIMES_HPP\n#define __CFUNCTIONALTIMES_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataMemory.hpp>\n#include <functionals/functionalComponent.hpp>\n\n#define COMPONENT_DESCRIPTION_CFUNCTIONALTIMES \"  up- and down-level times + rise and fall, left- and right-curve times, duration, etc.\"\n#define COMPONENT_NAME_CFUNCTIONALTIMES \"cFunctionalTimes\"\n\n#undef class\nclass DLLEXPORT cFunctionalTimes : public cFunctionalComponent {\n  private:\n    int nUltime, nDltime;\n    double *ultime, *dltime;\n    char *tmpstr;\n    int varFctIdx;\n    int buggySecNorm;\n    int useRobustPercentileRange_;\n    FLOAT_DMEM pctlRangeMargin_;\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    virtual void fetchConfig();\n    FLOAT_DMEM getPctlMin(FLOAT_DMEM *sorted, long N);\n    FLOAT_DMEM getPctlMax(FLOAT_DMEM *sorted, long N);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cFunctionalTimes(const char *_name);\n    // inputs: sorted and unsorted array of values, out: pointer to space in output array, You may not return MORE than Nout elements, please return as return value the number of actually computed elements (usually Nout)\n    virtual long process(FLOAT_DMEM *in, FLOAT_DMEM *inSorted, FLOAT_DMEM min, FLOAT_DMEM max, FLOAT_DMEM mean, FLOAT_DMEM *out, long Nin, long Nout);\n    //virtual long process(INT_DMEM *in, INT_DMEM *inSorted, INT_DMEM *out, long Nin, long Nout);\n\n    //virtual long getNoutputValues() { return nEnab; }\n    virtual const char* getValueName(long i);\n    virtual int getRequireSorted() {\n      if (useRobustPercentileRange_)\n        return 1;\n      return 0;\n    }\n\n    virtual ~cFunctionalTimes();\n};\n\n\n\n\n#endif // __CFUNCTIONALTIMES_HPP\n"
  },
  {
    "path": "src/include/functionals/functionals.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nfunctionals container\n\npasses unsorted row data array AND (if required) sorted row data array to functional processors\n\n*/\n\n\n#ifndef __CFUNCTIONALS_HPP\n#define __CFUNCTIONALS_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/winToVecProcessor.hpp>\n#include <functionals/functionalComponent.hpp>\n\n#define BUILD_COMPONENT_Functionals\n#define COMPONENT_DESCRIPTION_CFUNCTIONALS \"computes functionals from input frames, this component uses various cFunctionalXXXX sub-components, which implement the actual functionality\"\n#define COMPONENT_NAME_CFUNCTIONALS \"cFunctionals\"\n#define COMPONENT_NAME_CFUNCTIONALS_LENGTH 12\n\n#undef class\nclass DLLEXPORT cFunctionals : public cWinToVecProcessor {\n  private:\n    int nFunctTp, nFunctTpAlloc;  // number of cFunctionalXXXX types found\n    char **functTp;  // type names (without cFunctional prefix)\n    int *functTpI;   // index of cFunctionalXXXX type in componentManager\n    int *functI;   // index of cFunctionalXXXX type in componentManager\n    int *functN;   // number of output values of each functional object\n    cFunctionalComponent **functObj;\n    int requireSorted;\n    int nonZeroFuncts;\n    const char * functNameAppend;\n    int timeNorm;\n\n  protected:\n    int nFunctionalsEnabled;\n    int nFunctValues;  // size of output vector\n\n    SMILECOMPONENT_STATIC_DECL_PR\n\n//    virtual void fetchConfig();\n    virtual int myConfigureInstance();\n\n    //virtual int myFinaliseInstance();\n    //virtual int myTick(long long t);\n\n    virtual int getMultiplier();\n    //virtual int configureWriter(const sDmLevelConfig *c);\n    virtual int setupNamesForElement(int idxi, const char*name, long nEl);\n    virtual int doProcess(int i, cMatrix *row, FLOAT_DMEM*x);\n    virtual int doProcessMatrix(int i, cMatrix *in, FLOAT_DMEM *out, long nOut);\n\n//    virtual int doProcess(int i, cMatrix *row, INT_DMEM*x);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    static int rAcounter;\n    cFunctionals(const char *_name);\n\n    virtual ~cFunctionals();\n};\n\n\n\n\n#endif // __CFUNCTIONALS_HPP\n"
  },
  {
    "path": "src/include/io/libsvmSink.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nLibSVM file output\n\n*/\n\n\n#ifndef __CLIBSVMSINK_HPP\n#define __CLIBSVMSINK_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataSink.hpp>\n\n#define BUILD_COMPONENT_LibsvmSink\n#define COMPONENT_DESCRIPTION_CLIBSVMSINK \"This component writes data to a text file in LibSVM feature file format. For the 'on-the-fly' classification component see 'cLibsvmliveSink'.\"\n#define COMPONENT_NAME_CLIBSVMSINK \"cLibsvmSink\"\n\n\n#undef class\nclass DLLEXPORT cLibsvmSink : public cDataSink {\n  private:\n    FILE * filehandle;\n    const char *filename;\n    int lag;\n    int append, timestamp;\n    const char *instanceBase, *instanceName;\n    \n    int targetNumAll;\n    int nClasses;\n    long nInst;\n    long inr;\n    char **classname;\n    int *target;\n\n    int getClassIndex(const char *_name)\n    {\n      int i;\n      if (_name == NULL) return -1;\n      if (classname == NULL) return -1;\n      for (i=0; i<nClasses; i++) {\n        if ((classname[i]!=NULL)&&(!strcmp(_name,classname[i]))) return i;\n      }\n      return -1;\n    }\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n\n  public:\n    //static sComponentInfo * registerComponent(cConfigManager *_confman);\n    //static cSmileComponent * create(const char *_instname);\n    SMILECOMPONENT_STATIC_DECL\n    \n    cLibsvmSink(const char *_name);\n\n    virtual ~cLibsvmSink();\n};\n\n\n\n\n#endif // __CLIBSVMSINK_HPP\n"
  },
  {
    "path": "src/include/iocore/arffSink.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nARFF file output (for WEKA)\n\n*/\n\n\n#ifndef __ARFF_SINK_HPP\n#define __ARFF_SINK_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataSink.hpp>\n\n#define COMPONENT_DESCRIPTION_CARFFSINK \"This component writes dataMemory data to an ARFF file (WEKA). Depending on your config an instance name field, a frame index, and a frame time field can be added as well as multiple class/target attributes. See the config type documentation for more details.\"\n#define COMPONENT_NAME_CARFFSINK \"cArffSink\"\n\n#undef class\nclass DLLEXPORT cArffSink : public cDataSink {\n  private:\n    FILE * filehandle;\n    double frameTimeAdd;\n    const char *filename;\n    int lag;\n    int append, timestamp, number, prname, frameLength;\n    int instanceNameFromMetadata, useTargetsFromMetadata;\n    const char *relation;\n    const char *instanceBase, *instanceName;\n    bool disabledSink_;\n\n    int printDefaultClassDummyAttribute;    \n    int nClasses; long nInst;\n    long inr;\n    char **classname;\n    char **classtype;\n    \n    char **targetall;\n    char ***targetinst;\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n\n  public:\n    //static sComponentInfo * registerComponent(cConfigManager *_confman);\n    //static cSmileComponent * create(const char *_instname);\n    SMILECOMPONENT_STATIC_DECL\n    \n    cArffSink(const char *_name);\n\n    virtual ~cArffSink();\n};\n\n\n\n\n#endif // __ARFF_SINK_HPP\n"
  },
  {
    "path": "src/include/iocore/arffSource.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\n\n*/\n\n\n#ifndef __CARFFSOURCE_HPP\n#define __CARFFSOURCE_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataSource.hpp>\n\n#define COMPONENT_DESCRIPTION_CARFFSOURCE \"This component reads WEKA ARFF files. The full ARFF format is not yet supported, but a simplified form, such as the files generated by the cArffSink component can be parsed and read. This component reads all (and only!!) 'numeric' or 'real' attributes from an ARFF file (WEKA file format) into the specified data memory level. Thereby each instance (i.e. one line in the arff file's data section) corresponds to one frame. The frame period is 0 by default (aperiodic level), use the 'period' option to change this and use a fixed period for each frame/instance. Automatic generation of frame timestamps from a 'timestamp' field in the Arff file is not yet supported.\"\n#define COMPONENT_NAME_CARFFSOURCE \"cArffSource\"\n\n#undef class\nclass DLLEXPORT cArffSource : public cDataSource {\n  private:\n    int nAttr;\n    int saveClassesAsMetadata;\n    int lastNumeric;\n    int useInstanceID;\n    int strField;\n    FILE *filehandle;\n    const char *filename;\n    int *field;\n    int fieldNalloc;\n    int nFields,nNumericFields;\n    int eof;\n    int skipClasses;\n    long lineNr;\n    size_t lineLen;\n    char *origline;\n    int skipFirst;\n \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n    virtual int setupNewNames(long nEl=0);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cArffSource(const char *_name);\n\n    virtual ~cArffSource();\n};\n\n\n\n\n#endif // __CARFFSOURCE_HPP\n"
  },
  {
    "path": "src/include/iocore/csvSink.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nComma Separated Value file output (CSV)\n\n*/\n\n\n#ifndef __CCSVSINK_HPP\n#define __CCSVSINK_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataSink.hpp>\n\n#define COMPONENT_DESCRIPTION_CCSVSINK \"This component exports data in CSV (comma-separated-value) format used in many spreadsheet applications. As the first line of the CSV file a header line may be printed, which contains a delimiter separated list of field names of the output values.\"\n#define COMPONENT_NAME_CCSVSINK \"cCsvSink\"\n\n#undef class\nclass DLLEXPORT cCsvSink : public cDataSink {\n  private:\n    FILE * filehandle;\n    const char *filename;\n    const char *instanceName;\n    const char *instanceBase;\n    bool disabledSink_;\n    char delimChar;\n    int lag;\n    int flush;\n    int prname;\n    int append, timestamp, number, printHeader;\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n\n  public:\n    //static sComponentInfo * registerComponent(cConfigManager *_confman);\n    //static cSmileComponent * create(const char *_instname);\n    SMILECOMPONENT_STATIC_DECL\n    \n    cCsvSink(const char *_name);\n\n    virtual ~cCsvSink();\n};\n\n\n\n\n#endif // __CCSVSINK_HPP\n"
  },
  {
    "path": "src/include/iocore/csvSource.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nCSV (Comma seperated value) file reader. \nThis component reads all columns as attributes into the data memory. One line thereby represents one frame or sample. The first line may contain a header with the feature names (see header=yes/no/auto option).\n\n*/\n\n\n#ifndef __CCSVSOURCE_HPP\n#define __CCSVSOURCE_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataSource.hpp>\n\n#define COMPONENT_DESCRIPTION_CCSVSOURCE \"This component reads CSV (Comma seperated value) files. It reads all columns as attributes into the data memory. One line represents one frame. The first line may contain a header with the feature names (see header=yes/no/auto option).\"\n#define COMPONENT_NAME_CCSVSOURCE \"cCsvSource\"\n\n#undef class\nclass DLLEXPORT cCsvSource : public cDataSource {\n  private:\n    //int nAttr;\n    FILE *filehandle;\n    const char *filename;\n\n    int *field;\n    //int fieldNalloc;\n    int nFields, nCols;\n    int eof;\n\n    int header;\n    char delimChar;\n\n    long lineNr;\n    long start;\n    long end;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    void setGenericNames(int nDelim);\n    void setNamesFromCSVheader(char *line, int nDelim);\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n    virtual int setupNewNames(long nEl=0);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cCsvSource(const char *_name);\n\n    virtual ~cCsvSource();\n};\n\n\n\n\n#endif // __CCSVSOURCE_HPP\n"
  },
  {
    "path": "src/include/iocore/datadumpSink.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nARFF file output (for WEKA)\n\n*/\n\n\n#ifndef __CDATADUMPSINK_HPP\n#define __CDATADUMPSINK_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataSink.hpp>\n\n#define COMPONENT_DESCRIPTION_CDATADUMPSINK \"This component writes dataMemory data to a raw binary file (e.g. for matlab import). The binary file consits of 32-bit float values representing the data values, concattenated frame by frame along the time axis. The first two float values in the file resemble the file header, an thus indicate the dimension of the matrix (1: size of frames, 2: number of frames in file). The total file size in bytes is thus <size of frames>x<number of frames>x4 + 2.\"\n#define COMPONENT_NAME_CDATADUMPSINK \"cDatadumpSink\"\n\n#undef class\nclass DLLEXPORT cDatadumpSink : public cDataSink {\n  private:\n    FILE * filehandle;\n    const char *filename;\n    int lag;\n    int append;\n    long nVec,vecSize;\n    \n    void writeHeader();\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n\n  public:\n    //static sComponentInfo * registerComponent(cConfigManager *_confman);\n    //static cSmileComponent * create(const char *_instname);\n    SMILECOMPONENT_STATIC_DECL\n    \n    cDatadumpSink(const char *_name);\n\n    virtual ~cDatadumpSink();\n};\n\n\n\n\n#endif // __CDATADUMPSINK_HPP\n"
  },
  {
    "path": "src/include/iocore/htkSink.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nARFF file output (for WEKA)\n\n*/\n\n\n#ifndef __CHTKSINK_HPP\n#define __CHTKSINK_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/smileComponent.hpp>\n#include <core/dataSink.hpp>\n\n#define COMPONENT_DESCRIPTION_CHTKSINK \"This component writes dataMemory data to a binary HTK parameter file.\"\n#define COMPONENT_NAME_CHTKSINK \"cHtkSink\"\n\n\n#undef class\nclass DLLEXPORT cHtkSink : public cDataSink {\n  private:\n    FILE * filehandle;\n    int vax;\n    const char *filename;\n    int lag;\n    int append;\n    uint16_t parmKind;\n    uint32_t vecSize;\n    uint32_t nVec;\n    double period;\n    double forcePeriod_;\n    sHTKheader header;\n    bool disabledSink_;\n\n    void prepareHeader( sHTKheader *h )\n    {\n      smileHtk_prepareHeader(h);\n    }\n\n    int writeHeader();\n    \n    int readHeader() \n    {\n      return smileHtk_readHeader(filehandle,&header);\n    }\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n\n  public:\n\n\n    //static sComponentInfo * registerComponent(cConfigManager *_confman);\n    //static cSmileComponent * create(const char *_instname);\n    SMILECOMPONENT_STATIC_DECL\n    \n    cHtkSink(const char *_name);\n\n    virtual ~cHtkSink();\n};\n\n\n\n\n#endif // __CHTKSINK_HPP\n"
  },
  {
    "path": "src/include/iocore/htkSource.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: cHtkSource\n-----------------------------------\n\nHTK Source:\n\nReads data from an HTK parameter file.\n\n-----------------------------------\n\n11/2009 - Written by Florian Eyben\n*/\n\n\n#ifndef __CHTKSOURCE_HPP\n#define __CHTKSOURCE_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataSource.hpp>\n//#include <htkSink.hpp>   // include this for the HTK header type and endianness functions\n\n#define COMPONENT_DESCRIPTION_CHTKSOURCE \"This component reads data from binary HTK parameter files.\"\n#define COMPONENT_NAME_CHTKSOURCE \"cHtkSource\"\n\nclass cHtkSource : public cDataSource {\n  private:\n    sHTKheader head;\n    int vax;\n    const char * featureName;\n    int N; // <-- sampleSize\n    float *tmpvec;\n\n    FILE *filehandle;\n    const char *filename;\n    int eof;\n \n    void prepareHeader( sHTKheader *h )\n    {\n      smileHtk_prepareHeader(h);\n    }\n\n    int readHeader() \n    {\n      return smileHtk_readHeader(filehandle,&head);\n    }\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n\n    virtual void fetchConfig();\n    virtual int configureWriter(sDmLevelConfig &c);\n    virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n    virtual int setupNewNames(long nEl=0);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cHtkSource(const char *_name);\n\n    virtual ~cHtkSource();\n};\n\n\n\n\n#endif // __CHTKSOURCE_HPP\n"
  },
  {
    "path": "src/include/iocore/waveSink.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nwaveSink:\nwrites data to an uncompressed PCM WAVE file\n\n*/\n\n\n#ifndef __CWAVESINK_HPP\n#define __CWAVESINK_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataSink.hpp>\n#include <iocore/waveSource.hpp>\n\n#define COMPONENT_DESCRIPTION_CWAVESINK \"This component saves data to an uncompressed PCM WAVE file\"\n#define COMPONENT_NAME_CWAVESINK \"cWaveSink\"\n\n#undef class\nclass DLLEXPORT cWaveSink : public cDataSink {\nprivate:\n  const char *filename;\n  FILE * fHandle;\n  //int lag;\n  int frameRead;\n  int buffersize;\n  int flushData;\n  void *sampleBuffer; long sampleBufferLen;\n\n  int nBitsPerSample;\n  int nBytesPerSample;\n  int sampleFormat;\n  int nChannels;\n\n  //double start, end, endrel;\n  //long startSamples, endSamples, endrelSamples;\n\n  long curWritePos;   // in samples??\n  long nBlocks;\n  //int eof;\n\n  int writeWaveHeader();\n  int writeData(cMatrix *m=NULL);\n\nprotected:\n  SMILECOMPONENT_STATIC_DECL_PR\n\n  virtual void fetchConfig();\n  //virtual int myConfigureInstance();\n  virtual int myFinaliseInstance();\n  virtual int myTick(long long t);\n\n  virtual int configureReader();\n\npublic:\n  SMILECOMPONENT_STATIC_DECL\n\n    cWaveSink(const char *_name);\n\n  virtual ~cWaveSink();\n};\n\n\n\n\n#endif // __CWAVESINK_HPP\n"
  },
  {
    "path": "src/include/iocore/waveSinkCut.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nwaveSink:\nwrites data to an uncompressed PCM WAVE file\n\n*/\n\n\n#ifndef __CWAVESINKCUT_HPP\n#define __CWAVESINKCUT_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataSink.hpp>\n#include <iocore/waveSource.hpp>\n\n#define COMPONENT_DESCRIPTION_CWAVESINKCUT \"This component writes data to uncompressed PCM WAVE files. Only chunks, based on timings received via smile messages are written to files. The files may have consecutive numbers appended to the file name.\"\n#define COMPONENT_NAME_CWAVESINKCUT \"cWaveSinkCut\"\n\n#undef class\nclass DLLEXPORT cWaveSinkCut : public cDataSink {\n  private:\n    const char *fileExtension;\n    const char *filebase;\n    const char *fileNameFormatString;\n    int multiOut;\n    long curFileNr;\n    \n    long forceSampleRate;\n    long preSil, postSil;\n    int turnStart, turnEnd, nPre, nPost, vIdxStart, vIdxEnd, curVidx;\n    float startSec0_, startSec_, endSec_;\n    long curStart, curEnd;\n    int isTurn, endWait;\n\n    FILE * fHandle;\n    void *sampleBuffer; long sampleBufferLen;\n\n  \tint nBitsPerSample;\n\t  int nBytesPerSample;\n\t  int sampleFormat;\n    int nChannels;\n    long fieldSize;\n\t\n    long nOvl;\n\n  \tlong curWritePos;   // in samples??\n\t  long nBlocks;\n\t  int showSegmentTimes_;\n\t  const char * saveSegmentTimes_;\n\n    int writeWaveHeader();\n    int writeDataFrame(cVector *m=NULL);\n    char * getCurFileName();\n    void saveAndPrintSegmentData(long n);\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    virtual void fetchConfig();\n    virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n    virtual int processComponentMessage( cComponentMessage *_msg );\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cWaveSinkCut(const char *_name);\n\n    virtual ~cWaveSinkCut();\n};\n\n\n\n\n#endif // __CWAVESINKCUT_HPP\n"
  },
  {
    "path": "src/include/iocore/waveSource.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nwaveSource : reads PCM WAVE files (RIFF format)\n\nSupport for a negative start index was added by Benedikt Gollan (TUM).\n\n*/\n\n\n#ifndef __WAVE_SOURCE_HPP\n#define __WAVE_SOURCE_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataSource.hpp>\n\n#define COMPONENT_DESCRIPTION_CWAVESOURCE \"This component reads an uncompressed RIFF (PCM-WAVE) file and saves it as a stream to the data memory. For most feature extraction tasks you will now require a cFramer component.\"\n#define COMPONENT_NAME_CWAVESOURCE \"cWaveSource\"\n\n/*\n#define BYTEORDER_LE    0\n#define BYTEORDER_BE    1\n#define MEMORGA_INTERLV 0\n#define MEMORGA_SEPCH   1\n\ntypedef struct {\n  long sampleRate;\n  int sampleType;\n  int nChan;\n  int blockSize;\n  int nBPS;       // actual bytes per sample\n  int nBits;       // bits per sample (precision)\n  int byteOrder;  // BYTEORDER_LE or BYTEORDER_BE\n  int memOrga;    // MEMORGA_INTERLV  or MEMORGA_SEPCH\n  long nBlocks;  // nBlocks in buffer\n} sWaveParameters;\n*/\n\n#undef class\nclass DLLEXPORT cWaveSource : public cDataSource {\n  private:\n    const char *filename;\n    //long buffersize;\n    FILE *filehandle;\n    sWaveParameters pcmParam;\n\n    int properTimestamps_;\n    int negativestart;\n    long negstartoffset;\n    double start, end, endrel;\n    long startSamples, endSamples, endrelSamples;\n    \n    int monoMixdown;    // if set to 1, multi-channel files will be mixed down to 1 channel\n    long pcmDataBegin;  // in bytes\n    long curReadPos;   // in samples\n    int eof;\n    const char *outFieldName;\n\n    int readWaveHeader();\n    int readData(cMatrix *m=NULL);\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    virtual void fetchConfig();\n    virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n    virtual int configureWriter(sDmLevelConfig &c);\n    virtual int setupNewNames(long nEl);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cWaveSource(const char *_name);\n\n    virtual ~cWaveSource();\n};\n\n\n\n\n#endif // __EXAMPLE_SOURCE_HPP\n"
  },
  {
    "path": "src/include/lld/cens.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nComponent to compute chroma features from a semi-tone spectrum. \n\nThis component is based on original code from Moritz Dausinger (wave2chroma). \nThe openSMILE chroma component was implemented by Christoph Kozielski.\n\n*/\n\n\n#ifndef __CCENS_HPP\n#define __CCENS_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n\n#define BUILD_COMPONENT_Cens\n#define COMPONENT_DESCRIPTION_CCENS \"This component computes CENS (energy normalised and smoothed chroma features) from raw Chroma features generated by the 'cChroma' component.\"\n#define COMPONENT_NAME_CCENS \"cCens\"\n\n#undef class\nclass DLLEXPORT cCens : public cVectorProcessor {\n  private:\n\t  double **winf;\n    FLOAT_DMEM **buffer;\n    long *bptr, *dsidx;\n    int downsampleRatio;\n\n    int l2norm;\n    int window;\n    long winlength;\n\n    void chromaDiscretise(const FLOAT_DMEM *in, FLOAT_DMEM *out, long N);\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    //virtual int myTick(long long t);\n\t\n    virtual int configureWriter(sDmLevelConfig &c);\n    //virtual void configureField(int idxi, long __N, long nOut);\n    virtual int setupNamesForField(int i, const char*name, long nEl);\n    //virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cCens(const char *_name);\n\n    virtual ~cCens();\n};\n\n\n\n\n#endif // __CCENS_HPP\n"
  },
  {
    "path": "src/include/lld/chroma.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nComponent to compute chroma features from a semi-tone spectrum. \n\nThis component is based on original code from Moritz Dausinger (wave2chroma). \nThe openSMILE chroma component was implemented by Christoph Kozielski.\n\n*/\n\n\n#ifndef __CCHROMA_HPP\n#define __CCHROMA_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n\n#define BUILD_COMPONENT_Chroma\n#define COMPONENT_DESCRIPTION_CCHROMA \"This component computes CHROMA features from a semi-tone scaled spectrum generated by the 'cTonespec' component.\"\n#define COMPONENT_NAME_CCHROMA \"cChroma\"\n\n#undef class\nclass DLLEXPORT cChroma : public cVectorProcessor {\n  private:\n\t  FLOAT_DMEM silThresh;\n    int octaveSize;\n    int nOctaves;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    //virtual int myTick(long long t);\n\t\n\n    //virtual void configureField(int idxi, long __N, long nOut);\n    virtual int setupNamesForField(int i, const char*name, long nEl);\n    //virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cChroma(const char *_name);\n\n    virtual ~cChroma();\n};\n\n\n\n\n#endif // __CCHROMA_HPP\n"
  },
  {
    "path": "src/include/lld/formantLpc.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nLPC, compute LPC coefficients from wave data (PCM) frames\n\n*/\n\n\n#ifndef __CFORMANTLPC_HPP\n#define __CFORMANTLPC_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n\n#define BUILD_COMPONENT_FormantLpc\n#define COMPONENT_DESCRIPTION_CFORMANTLPC \"This component computes formant frequencies and bandwidths by solving for the roots of the LPC polynomial. The formant trajectories can and should be smoothed by the cFormantSmoother component.\"\n#define COMPONENT_NAME_CFORMANTLPC \"cFormantLpc\"\n\n#undef class\nclass DLLEXPORT cFormantLpc : public cVectorProcessor {\n  private:\n    int nFormants;\n    int saveFormants;\n    int saveIntensity;\n    int saveBandwidths;\n    int saveNumberOfValidFormants;\n    int useLpSpec;\n    int nSmooth;\n    int medianFilter, octaveCorrection;\n\n    int nLpc;\n    long lpcCoeffIdx;\n    long lpcGainIdx;\n    long lpSpecIdx, lpSpecN;\n\n    double minF, maxF;\n    \n    double T;\n    double *lpc, *roots;\n    double *formant, *bandwidth;\n\n    FLOAT_DMEM calcFormantLpc(const FLOAT_DMEM *x, long Nsrc, FLOAT_DMEM * lpc, long nCoeff, FLOAT_DMEM *refl);\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    virtual int setupNewNames(long nEl);\n    virtual void findInputFields();\n\n    virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cFormantLpc(const char *_name);\n\n    virtual ~cFormantLpc();\n};\n\n#endif // __CFORMANTLPC_HPP\n"
  },
  {
    "path": "src/include/lld/formantSmoother.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nInput: candidates produced by a pitchBase descendant\n\n*/\n\n\n#ifndef __CFORMANTSMOOTHER_HPP\n#define __CFORMANTSMOOTHER_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n\n#define BUILD_COMPONENT_FormantSmoother\n#define COMPONENT_DESCRIPTION_CFORMANTSMOOTHER \"This component performs temporal formant smoothing. Input: candidates produced by a formant** component AND(!) - appended - an F0final or voicing field (which is 0 for unvoiced frames and non-zero for voiced frames). Output: Smoothed formant frequency contours.\"\n#define COMPONENT_NAME_CFORMANTSMOOTHER \"cFormantSmoother\"\n\n#define FPOSTSMOOTHING_NONE   0\n#define FPOSTSMOOTHING_SIMPLE 1\n#define FPOSTSMOOTHING_MEDIAN 2\n\n#undef class\nclass DLLEXPORT cFormantSmoother : public cVectorProcessor {\n  private:\n    int firstFrame;\n    int no0f0;\n    int medianFilter0;\n    int postSmoothing, postSmoothingMethod;\n    int saveEnvs;\n\n    long F0fieldIdx, formantFreqFieldIdx, formantBandwidthFieldIdx, formantFrameIntensField;\n    long nFormantsIn;\n\n    int nFormants, bandwidths, formants, intensity;\n    //int onsFlag, onsFlagO;\n    //int octaveCorrection;\n\n    FLOAT_DMEM *median0WorkspaceF0cand;\n    FLOAT_DMEM *lastFinal;\n\n    FLOAT_DMEM *fbin;\n    FLOAT_DMEM *fbinLastVoiced;\n    // NOTE: difficulty when analysing data from multiple pdas : \n    // the scores and voicing probs. may be scaled differently, although they should all be in the range 0-1\n    // thus, a direct comparion of these may not be feasible\n    // We thus start comparison for each field (pda output) individually and then (TODO) merge information from multiple pdas\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    FLOAT_DMEM *voicingCutoff;\n\n    virtual void fetchConfig();\n\t  virtual int setupNewNames(long nEl);\n    \n    //virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cFormantSmoother(const char *_name);\n    \n    virtual ~cFormantSmoother();\n};\n\n\n\n\n#endif // __CFORMANTSMOOTHER_HPP\n"
  },
  {
    "path": "src/include/lld/harmonics.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nstatistics of F0 harmonics\n\n*/\n\n\n#ifndef __CHARMONICS_HPP\n#define __CHARMONICS_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n\n#define BUILD_COMPONENT_Harmonics\n#define COMPONENT_DESCRIPTION_CHARMONICS \"This component computes statistics of F0 harmonics. It requires an F0 (Hertz) input field and a linear frequency axis magnitude spectrum as input.\"\n#define COMPONENT_NAME_CHARMONICS \"cHarmonics\"\n\ntypedef struct {\n  int bin;\n  int belowThreshold;   // 1 = non harmonic, because amplitude falls below threshold\n  float freqExpected;\n  float freqFromBin;\n  float freqInterpolated;\n  float magnitude;\n  float magnitudeInterpolated;\n  float magnitudeLogRelF0;  // magnitude relative to F0 magnitude, in dB\n} sF0Harmonic;\n\ntypedef struct {\n  int h1idx;   // index1 - index2\n  int h1formant;  // -1 : h1idx is harmonic, >= 0, formant index for h1\n  int h2idx;\n  int h2formant;\n  const char *text;  // name of difference pair from config\n} sHarmonicDifferences;\n\n/*\n * Outputs:\n * hnr log\n * hnr linear\n * nHarmonicMagnitudes_ x logrel mags\n * nHarmonicMagnitudes_ x linear mags\n * nHarmonicDifferences_ x (linear, logrel)\n * formantAmplitudesEnd_ - formantAmplitudesStart_ + 1\n */\n#undef class\nclass DLLEXPORT cHarmonics : public cVectorProcessor {\n  private:\n    int nHarmonics_;\n    int nHarmonicMagnitudes_;\n    int firstHarmonicMagnitude_;\n    int outputLogRelMagnitudes_;\n    int outputLinearMagnitudes_;\n    int nHarmonicDifferences_;\n    sHarmonicDifferences * harmonicDifferences_;\n    int harmonicDifferencesLog_;\n    int harmonicDifferencesLinear_;\n    int formantAmplitudes_;\n    int formantAmplitudesLinear_;\n    int formantAmplitudesLogRel_;\n    int formantAmplitudesStart_;\n    int formantAmplitudesEnd_;\n    int computeAcfHnrLinear_;\n    int computeAcfHnrLogdB_;\n    const char * formantFrequencyFieldName_;\n    const char * formantBandwidthFieldName_;\n    const char * f0ElementName_;\n    const char * magSpecFieldName_;\n    int f0ElementNameIsFull_;\n    int magSpecFieldNameIsFull_;\n    int formantFrequencyFieldNameIsFull_;\n    int formantBandwidthFieldNameIsFull_;\n\n    FLOAT_DMEM logRelValueFloorUnvoiced_;\n    sF0Harmonic *harmonics_;\n    FLOAT_TYPE_FFT *w_;\n    int * ip_;\n    FLOAT_TYPE_FFT *acfdata_;\n    FLOAT_DMEM *acf_;\n\n    bool haveFormantDifference_;\n    int cnt_;\n    double *frq_;\n    long nFrq_;\n    double fsSec;\n    long idxF0;\n    long idxSpec;\n    int idxSpecField_;\n    long nSpecBins;\n    long idxFFreq_;\n    long nFFreq_;\n    long idxFBandw_;\n    long nFBandw_;\n\n    sHarmonicDifferences * parseHarmonicDifferences(int * Ndiff, bool *haveFormant, int *maxHarmonic);\n    int isPeak(const FLOAT_DMEM * x, long N, long n);\n    int findHarmonicPeaks(float pitchFreq, const FLOAT_DMEM * magSpec, long nBins,\n        sF0Harmonic * harmonics, int nHarmonics, const double * frq, float F0);\n    int freqToBin(float freq, int startBin);\n    int freqToAcfBinLin(float freq);\n    int computeAcf(const FLOAT_DMEM *magSpec, FLOAT_DMEM *acf, long nBins, bool squareInput);\n    FLOAT_DMEM computeAcfHnr_linear(const FLOAT_DMEM *a, long N, long F0bin = -1);\n    FLOAT_DMEM computeAcfHnr_dB(const FLOAT_DMEM *a, long N, long F0bin = -1);\n    long getClosestPeak(const FLOAT_DMEM *x, long N, long idx);\n    void postProcessHarmonics(sF0Harmonic * harmonics, int nHarmonics, bool logRelMagnitude = true);\n    int * getFormantAmplitudeIndices(const FLOAT_DMEM * centreFreq, const FLOAT_DMEM *bandw, int N);\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    virtual int setupNewNames(long nEl);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    cHarmonics(const char *_name);\n    virtual ~cHarmonics();\n};\n\n#endif // __CHARMONICS_HPP\n\n"
  },
  {
    "path": "src/include/lld/lpc.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nLPC, compute LPC coefficients from wave data (PCM) frames\n\n*/\n\n\n#ifndef __CLPC_HPP\n#define __CLPC_HPP\n\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n\n#include <dspcore/fftXg.h>\n\n#define BUILD_COMPONENT_Lpc\n#define COMPONENT_DESCRIPTION_CLPC \"This component computes linear predictive coding (LPC) coefficients from PCM frames. Burg's algorithm and the standard ACF/Durbin based method are implemented for LPC coefficient computation. The output of LPC filter coefficients, reflection coefficients, residual signal, and LP spectrum is supported.\"\n\n#define COMPONENT_NAME_CLPC \"cLpc\"\n\n#define LPC_METHOD_ACF   0\n#define LPC_METHOD_BURG   5\n\n\n#undef class\nclass DLLEXPORT cLpc : public cVectorProcessor {\n  private:\n    int p;\n    int saveLPCoeff, saveRefCoeff;\n    int residual;\n    int residualGainScale;\n    int method;\n    int lpGain;\n    int forwardRes;\n    int lpSpectrum;\n    int forwardLPspec;\n    double lpSpecDeltaF;\n    int lpSpecBins;\n\n    FLOAT_DMEM forwardLPspecFloor;\n    FLOAT_DMEM *latB;\n    FLOAT_DMEM lastGain;\n    FLOAT_TYPE_FFT *lSpec;\n\n    int *_ip;\n    FLOAT_TYPE_FFT *_w;\n\n    FLOAT_DMEM *acf;\n    FLOAT_DMEM *lpCoeff, *lastLpCoeff, *refCoeff;\n\n    FLOAT_DMEM *gbb, *gb2, *gaa;\n\n    FLOAT_DMEM calcLpc(const FLOAT_DMEM *x, long Nsrc, FLOAT_DMEM * lpc, long nCoeff, FLOAT_DMEM *refl);\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    virtual int setupNamesForField(int i, const char*name, long nEl);\n\n    virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cLpc(const char *_name);\n\n    virtual ~cLpc();\n};\n\n\n#endif // __CLPC_HPP\n"
  },
  {
    "path": "src/include/lld/lsp.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*****************************************************************\n  This code uses functions from the Speex codec library,\n  which are distributed under the following license terms:\n\nCopyright 2002-2008     Xiph.org Foundation\nCopyright 2002-2008     Jean-Marc Valin\nCopyright 2005-2007     Analog Devices Inc.\nCopyright 2005-2008     Commonwealth Scientific and Industrial Research\n                        Organisation (CSIRO)\nCopyright 1993, 2002, 2006 David Rowe\nCopyright 2003          EpicGames\nCopyright 1992-1994     Jutta Degener, Carsten Bormann\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n\n- Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n\n- Redistributions in binary form must reproduce the above copyright\nnotice, this list of conditions and the following disclaimer in the\ndocumentation and/or other materials provided with the distribution.\n\n- Neither the name of the Xiph.org Foundation nor the names of its\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR\nCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\nEXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\nPROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\nPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n****************************/\n\n\n/*  openSMILE component:\n\nComputes LSP (line spectral pairs) from LPC coefficients\n\n*/\n\n\n#ifndef __CLSP_HPP\n#define __CLSP_HPP\n\n\n#include <core/smileCommon.hpp>\n\n#include <core/vectorProcessor.hpp>\n#define BUILD_COMPONENT_Lsp\n#define COMPONENT_DESCRIPTION_CLSP \"This component computes LSP (line spectral pair frequencies, also known as LSF) from LPC coefficients by partial factorisation of the LPC polynomial.\"\n#define COMPONENT_NAME_CLSP \"cLsp\"\n\n#undef class\nclass DLLEXPORT cLsp : public cVectorProcessor {\n  private:\n\n    long lpcIdx, nLpc;\n\n    FLOAT_DMEM cheb_poly_eva(FLOAT_DMEM *coef, FLOAT_DMEM x, int m);\n    int lpc_to_lsp (const FLOAT_DMEM *a, int lpcrdr, FLOAT_DMEM *freq, int nb, FLOAT_DMEM delta);\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    virtual int setupNewNames(long nEl);\n\n    virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cLsp(const char *_name);\n\n    virtual ~cLsp();\n};\n\n#endif // __CLSP_HPP\n"
  },
  {
    "path": "src/include/lld/pitchDirection.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample for dataProcessor descendant\n\n*/\n\n\n#ifndef __CPITCHDIRECTION_HPP\n#define __CPITCHDIRECTION_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataProcessor.hpp>\n\n#define BUILD_COMPONENT_PitchDirection\n#define COMPONENT_DESCRIPTION_CPITCHDIRECTION \"This component reads pitch data, detects pseudo syllables, and computes pitch direction estimates per syllable. Thereby the classes falling, flat, and rising are distinguished. \\n    Required input fields: F0, F0env, and 'loudness' or 'RMSenergy'.\"\n#define COMPONENT_NAME_CPITCHDIRECTION \"cPitchDirection\"\n\n#undef class\nclass DLLEXPORT cPitchDirection : public cDataProcessor {\n  private:\n    cVector *myVec;\n    long F0field, F0envField, LoudnessField, RMSField;\n    double stbs, ltbs;\n    long stbsFrames, ltbsFrames;\n    FLOAT_DMEM * stbuf, * ltbuf;\n    FLOAT_DMEM F0non0, lastF0non0, f0s;\n    long stbufPtr, ltbufPtr; /* ring-buffer pointers */\n    long bufInit; /* indicates wether buffer has been filled and valid values are to be expected */\n    double ltSum, stSum;\n    FLOAT_DMEM longF0Avg;\n    long nFall,nRise,nFlat;\n\n    int insyl;\n    int f0cnt;\n    FLOAT_DMEM lastE;\n    FLOAT_DMEM startE, maxE, minE, endE;\n    long sylen, maxPos, minPos, sylenLast;\n    long sylCnt;\n    double inpPeriod, timeCnt, lastSyl;\n\n    FLOAT_DMEM startF0, lastF0, maxF0, minF0;\n    long maxF0Pos, minF0Pos;\n\n    const char *directionMsgRecp;\n    int speakingRateBsize;\n\n    int F0directionOutp, directionScoreOutp;\n    int speakingRateOutp;\n    int F0avgOutp, F0smoothOutp;\n\n    /* speaking rate variables (buf0 is always the first half of buf1) */\n    int nBuf0,nBuf1; /* number of frames collected in bufferA and bufferB */\n    int nSyl0,nSyl1; /* number of syllable starts in bufferA and bufferB */\n    double curSpkRate;\n\n    int nEnabled;\n    \n    int isTurn, onlyTurn, invertTurn;\n    int resetTurnData;\n    const char * turnStartMessage, * turnEndMessage;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n    virtual void sendPitchDirectionResult(int result, double _smileTime, const char * _directionMsgRecp);\n\n    virtual int processComponentMessage( cComponentMessage *_msg );\n\n    // virtual int dataProcessorCustomFinalise();\n     virtual int setupNewNames(long nEl);\n    // virtual int setupNamesForField();\n    virtual int configureWriter(sDmLevelConfig &c);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cPitchDirection(const char *_name);\n\n    virtual ~cPitchDirection();\n};\n\n\n\n\n#endif // __CPITCHDIRECTION_HPP\n"
  },
  {
    "path": "src/include/lld/pitchJitter.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample for dataProcessor descendant\n\n*/\n\n\n#ifndef __CPITCHJITTER_HPP\n#define __CPITCHJITTER_HPP\n\n#include <core/smileCommon.hpp>\n#include <smileutil/smileUtil.h>\n#include <core/dataProcessor.hpp>\n\n#define BUILD_COMPONENT_PitchJitter\n#define COMPONENT_DESCRIPTION_CPITCHJITTER \"This component computes Voice Quality parameters Jitter (pitch period deviations) and Shimmer (pitch period amplitude deviations). It requires the raw PCM frames and the corresponding fundamental frequency (F0) as inputs.\"\n#define COMPONENT_NAME_CPITCHJITTER \"cPitchJitter\"\n\n#undef class\nclass DLLEXPORT cPitchJitter : public cDataProcessor {\n  private:\n    int onlyVoiced;\n    long savedMaxDebugPeriod;\n    int jitterLocal, jitterDDP, shimmerLocal, shimmerLocalDB;\n    int jitterLocalEnv, jitterDDPEnv, shimmerLocalEnv, shimmerLocalDBEnv;\n    int shimmerUseRmsAmplitude;\n    int harmonicERMS, noiseERMS, linearHNR, logHNR;\n    int sourceQualityRange, sourceQualityMean;\n    int useBrokenJitterThresh_;\n\n    int periodLengths, periodStarts;\n    long F0fieldIdx;\n    long lastIdx, lastMis;\n    int refinedF0;\n    int usePeakToPeakPeriodLength_;\n    FLOAT_DMEM threshCC_;\n    int minNumPeriods;\n\n    FILE *filehandle;\n    long input_max_delay_;\n    double searchRangeRel;\n    double minF0;\n    const char * F0field;\n    cDataReader *F0reader;\n    cVector *out;\n    long Nout;\n\n    // jitter data memory:\n    FLOAT_DMEM lastT0;\n    FLOAT_DMEM lastDiff;\n    FLOAT_DMEM lastJitterDDP, lastJitterLocal;\n    FLOAT_DMEM lastJitterDDP_b, lastJitterLocal_b;\n\n    // shimmer data memory:\n    FLOAT_DMEM lastShimmerLocal;\n    FLOAT_DMEM lastShimmerLocal_b;\n\n    FLOAT_DMEM lgHNRfloor;\n\n    double crossCorr(FLOAT_DMEM *x, long Nx, FLOAT_DMEM *y, long Ny);\n    FLOAT_DMEM amplitudeDiff(FLOAT_DMEM *x, long Nx, FLOAT_DMEM *y, long Ny,\n        double *maxI0, double *maxI1, FLOAT_DMEM *_A0, FLOAT_DMEM *_A1);\n    FLOAT_DMEM rmsAmplitudeDiff(FLOAT_DMEM *x, long Nx, FLOAT_DMEM *y, long Ny,\n        double *maxI0, double *maxI1, FLOAT_DMEM *_A0, FLOAT_DMEM *_A1);\n    void saveDebugPeriod(long sample, double sampleInterp);\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    virtual void mySetEnvironment();\n    virtual int myRegisterInstance(int *runMe=NULL);\n    virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n    // virtual int dataProcessorCustomFinalise();\n    virtual int setupNewNames(long nEl);\n    // virtual int setupNamesForField();\n    virtual int configureReader(const sDmLevelConfig &c);\n    virtual int configureWriter(sDmLevelConfig &c);\n\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cPitchJitter(const char *_name);\n\n    virtual ~cPitchJitter();\n};\n\n\n\n\n#endif // __CPITCHJITTER_HPP\n"
  },
  {
    "path": "src/include/lld/pitchShs.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nThis component computes pitch via the Harmonic Product Spectrum method.\nAs input it requires FFT magnitude data. \nNote that the type of input data is not checked, thus be careful when writing your configuration files!\n\n*/\n\n\n#ifndef __CPITCHSHS_HPP\n#define __CPITCHSHS_HPP\n\n#include <core/smileCommon.hpp>\n#include <lldcore/pitchBase.hpp>\n\n#define BUILD_COMPONENT_PitchShs\n#define COMPONENT_DESCRIPTION_CPITCHSHS \"This component computes the fundamental frequency via the Sub-Harmonic-Sampling (SHS) method (this is related to the Harmonic Product Spectrum method).\"\n#define COMPONENT_NAME_CPITCHSHS \"cPitchShs\"\n\n\n#undef class\nclass DLLEXPORT cPitchShs : public cPitchBase {\n  private:\n    int nHarmonics;\n    int greedyPeakAlgo;\n    FLOAT_DMEM Fmint, Fstept;\n    FLOAT_DMEM nOctaves, nPointsPerOctave;\n    FLOAT_DMEM *SS;\n    FLOAT_DMEM *Fmap;\n    FLOAT_DMEM compressionFactor;\n    double base;\n    double lfCut_;\n    int shsSpectrumOutput;\n\n    void addNameAppendFieldShs(const char*base, const char*append, int N, int arrNameOffset);\n    int cloneInputFieldInfoShs(int sourceFidx, int targetFidx, int force);\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    cDataWriter * shsWriter_;\n    cVector * shsVector_;\n\n    virtual void fetchConfig();\n    virtual int setupNewNames(long nEl);\n    \n    virtual void mySetEnvironment();\n    virtual int myRegisterInstance(int *runMe);\n    virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n\n    // to be overwritten by child class:\n    virtual int pitchDetect(FLOAT_DMEM * inData, long N_, double _fsSec, double baseT, FLOAT_DMEM *f0cand, FLOAT_DMEM *candVoice, FLOAT_DMEM *candScore, long nCandidates);\n    virtual int addCustomOutputs(FLOAT_DMEM *dstCur, long NdstLeft);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cPitchShs(const char *_name);\n    \n    virtual ~cPitchShs();\n};\n\n\n\n\n#endif // __CPITCHSHS_HPP\n"
  },
  {
    "path": "src/include/lld/pitchSmootherViterbi.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample for dataProcessor descendant\n\n*/\n\n\n#ifndef __CPITCHSMOOTHERVITERBI_HPP\n#define __CPITCHSMOOTHERVITERBI_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataProcessor.hpp>\n\n#define BUILD_COMPONENT_PitchSmootherViterbi\n#define COMPONENT_DESCRIPTION_CPITCHSMOOTHERVITERBI \"Viterbi algorithm to smooth pitch contours and remove octave jumps.\"\n#define COMPONENT_NAME_CPITCHSMOOTHERVITERBI \"cPitchSmootherViterbi\"\n\n#undef class\nclass DLLEXPORT cSmileViterbi\n{\nprivate:\n  /* Memory: buflen input data (candidates&scores and (from inp: voicingC1, F0raw, voicingClip)) in ring buffer, NOT full matrix type of full input vector)\n   *\n   * Memory: n best paths:\n   *   n x buflen matrix\n   *   n dim array for current costs\n   * previous paths will always have to be copied at each step: attention! don't overwrite paths still needed by other nodes!? (-> double buffering with 2 matricies?)\n   */\n  long wrIdx, rdIdx;\n  long buflen; /* length of viterbi workspace / input buffer */\n  int nStates; /* number of pitch candidates and scores supplied in input vector */\n\n  int frameSize;\n  FLOAT_DMEM * buf; /* pointer to (2 * nCandidates + 3) x buflen  array of FLOAT_DMEM (inputs) */\n  FLOAT_DMEM * prev; /* pointer to last frame for quick referencing */\n\n  int pathBuf; /* index of current path buffer (double buffering) */\n  long pathIdx; /* index of current position in path buffer */\n  long convIdx; /* index where paths merge, will be -1 for no convergence at all */\n  int * paths[2]; /* pointers to two  nCandidates x buflen matricies to hold best paths */\n  int * bestPath; /* converged (or forced/flushed) best path */\n  double * pathCosts; /* array with current path costs, size: nCandidates */\n  double * pathCostsNew; /* workspace array for path cost updates, size: nCandidates */\n  double * pathCostsTemp; /* workspace array for path cost updates, size: nCandidates */\n\nprotected:\n  /***** user definable re-factoring hooks *****/\n   virtual double localCost(int i, FLOAT_DMEM * frame) /* compute local cost for state i for current frame */\n   {\n     return getStateValueFromFrame(i,frame);\n   }\n\n   /* compute transition cost from state i (previous frame) to state j (current frame) */\n   virtual double transitionCost(int i, int j, FLOAT_DMEM * previousFrame, FLOAT_DMEM * currentFrame)\n   {\n     return 0.0;\n   }\n\n   virtual FLOAT_DMEM getStateValueFromFrame(int i, FLOAT_DMEM *frame)\n   {\n     return frame[i];\n   }\n\n   /*****************************/\n\n   int getnStates() { return nStates; }\n\npublic:\n  cSmileViterbi(int _nStates, long _buflen, int _frameSize) :\n    nStates(_nStates), buflen(_buflen), frameSize(_frameSize), wrIdx(0), rdIdx(0), prev(NULL), convIdx(-1)\n  {\n    /* allocate memory for buffer */\n    buf = (FLOAT_DMEM *)malloc(sizeof(FLOAT_DMEM)*(frameSize)*buflen);\n    paths[0] = (int *)malloc(sizeof(int)*nStates*buflen);\n    paths[1] = (int *)malloc(sizeof(int)*nStates*buflen);\n    bestPath = (int *)malloc(sizeof(int)*nStates*buflen);\n    pathIdx = 0; pathBuf = 0;\n    pathCosts = (double *)calloc(1,sizeof(double)*nStates);\n    pathCostsNew = (double *)calloc(1,sizeof(double)*nStates);\n    pathCostsTemp = (double *)calloc(1,sizeof(double)*nStates);\n  }\n\n  /* add a new data frame (size: frameSize), and compute updated path costs and best paths (perform one step of the incremental viterbi algorithm)\n   * returns >0 if new output frames are available (return val = number of output frames available)\n   * returns 0 if no output frames are available\n   * returns -1 if the input buffer is full and the user must first call getNextOutputFrame\n   * */\n  long addFrame(FLOAT_DMEM * frame);\n\n  /* get the number of available output frames, where the viterbi algorithm has converged on one path */\n  long getNAvail() { return (convIdx+1 - rdIdx); }\n\n  /*\n   * flush the trellis, by applying current best path up to current time\n   * after calling this function you may read all the data in the buffer with getNextOutputFrame()\n   * the function returns the number of frames that can now be read from the buffer\n   */\n  long flushTrellis() {\n    long i;\n\n    /* find current path with minimal cost */\n    int minState = 0;\n    for (i=1; i<nStates; i++) {\n      if (pathCosts[i] < pathCosts[minState]) {\n        minState = i;\n      }\n    }\n\n    /* update best path */\n    for (i=convIdx+1; i<pathIdx; i++) {\n      convIdx++;\n      int x = paths[pathBuf][minState*buflen + (convIdx)%buflen];\n      bestPath[convIdx%buflen] = x;\n    }\n\n    // TODO: put proper value here...\n    return 1;\n  }\n\n  /* reset the trellis and the input buffer (you should call flushTrellis() and read all data before that) */\n  void resetTrellis() {\n    pathIdx = 0;\n    convIdx=-1;\n    wrIdx=0;\n    rdIdx=0;\n    pathBuf = 0;\n  }\n\n  /* return next output value, optionally returns a pointer to the full input frame\n   * !this pointer is only valid until the next call to any function in this class!\n   *  */\n  FLOAT_DMEM getNextOutputFrame(FLOAT_DMEM ** frame, int *avail, int *state);\n\n\n\n  ~cSmileViterbi() {\n    if (buf != NULL) free(buf);\n    if (paths[0] != NULL) free(paths[0]);\n    if (paths[1] != NULL) free(paths[1]);\n    if (pathCosts != NULL) free(pathCosts);\n    if (bestPath != NULL) free(bestPath);\n    if (pathCostsNew != NULL) free(pathCostsNew);\n    if (pathCostsTemp != NULL) free(pathCostsTemp);\n  }\n\n};\n\n\n//-----------------------------------\n\nclass DLLEXPORT cSmileViterbiPitchSmooth : public cSmileViterbi\n{\nprivate:\n  FLOAT_DMEM voiceThresh;\n  double wLocal, wTvv, wTvvd, wTvuv, wTuu, wThr, wRange;\n  double lastChange;\n\nprotected:\n\n  virtual double getFweight(FLOAT_DMEM f) {\n    //default built-in weighting, piecewise linear\n    /* old:\n    if (f>0.0 && f<100.0) {\n      return -(1.0/100.0)*f + 1.0;\n    } else if (f>=100.0 && f<500.0) {\n      return ((1.0/400.0) * f - 0.25);\n    } else if (f > 500.0) { return 1.1; } else if (f<=0) { return 2.0; }\n     */\n    if (f>0.0 && f<100.0) {\n      return -(1.0/100.0)*f + 1.0;\n    } else if (f>=100.0 && f<350.0) {\n      return 0.0;\n    } else if (f>=350.0 && f<600.0) {\n      return (((f-350.0)/250.0));\n    } else\n      if (f >= 600.0) { return 1.2; } else if (f<=0) { return 2.0; } // penalty for out of bound frequencies\n\n    /*\n    if (f>0.0 && f<90.0) {\n      return -(0.8/90.0)*f + 1.0;\n    } else if (f>=90.0 && f<200) {\n      return (- (0.2/110.0) * f + (40.0/110.0));\n    } else if (f>=200 && f < 350) {\n      return ((0.2/150.0)*f - 4.0/15.0);\n    } else if (f>=350 && f < 600) {\n      return ((0.8/250.0)*f - 4.0/15.0);\n    } else if (f > 600.0) { return 1.0; } else if (f<=0) { return 2.0; }\n    */\n      return 0.0;\n  }\n\n  /* frame structure:\n   * [f0, voiceprob0, f1, voiceprob1, ... , fn, voiceprobn]\n   */\n  virtual double localCost(int i, FLOAT_DMEM * frame) /* compute local cost for state i for current frame */\n  {\n    double pv = (double)frame[i*2+1];\n    double thr = 0.0;\n    if (pv < 0.01) pv=0.01;\n    if (pv > 1.00) pv=1.00;\n    if (pv < voiceThresh) thr = wThr;\n    if (i<getnStates()-1) {\n      // TODO: speaker dependent frequency range weighting\n      double fWght = getFweight(frame[i*2]); /* frequency range weight */\n      return (-log(pv) + thr)*wLocal + fWght * wRange;\n    }\n    else {\n      int j; double flag = 0.0;\n      for (j=0; j < getnStates(); j++) {\n        if (frame[j*2+1] >= voiceThresh) { flag = wThr; break; }\n      }\n      return wLocal*(double)flag;\n    }\n  }\n\n  /* compute transition cost from state i (previous frame) to state j (current frame) */\n  virtual double transitionCost(int i, int j, FLOAT_DMEM * previousFrame, FLOAT_DMEM * currentFrame)\n  {\n    //FLOAT_DMEM pv0 = previousFrame[j*2+1];\n    //FLOAT_DMEM pv1 = currentFrame[i*2+1];\n    /* determine transition type */\n    if (i == j == getnStates()-1) { /* u->u */\n      return wTuu;\n    }\n    if (i < getnStates()-1 && j < getnStates()-1) { /* v->v */\n      FLOAT_DMEM f0 = previousFrame[j*2];\n      FLOAT_DMEM f1 = currentFrame[i*2];\n      if (f0 == 0 || f1 == 0) return 999.0 ; //wTvv*wTvuv; /* high cost, so we don't choose empty candidates */\n      else {\n        double r = log((double)(f1/f0));\n        double x = wTvv * fabs(r)  + wTvvd * fabs( r - lastChange ) ;  /* novel delta continuity constraint here.. */\n        lastChange = r;\n        /* FIXME: the lastChange will always reflect the lastChange of the previous path combination and not the last timestep!\n         * it should rather be the lastchange on the most likely path previously\n         * OR: easier to implement, the minimum (non-null - if any - otherwise null) lastchange of the previous timestep!\n         * */\n        return x;\n      }\n    }\n    if ((i==getnStates()-1 && j < getnStates()-1)||(i < getnStates()-1 && j==getnStates()-1))  { /* v->u , u->v */\n      lastChange=0.0;\n      return wTvuv;\n    }\n    // should not happen... just in case... (add some penalty to this unknown path...)\n    return 1.0;\n\n#if 0\n    //???\n    if (pv0 < voiceThresh && pv1 < voiceThresh) { /* u->u */\n      return wTuu;\n    }\n    if (pv0 >= voiceThresh && pv1 >= voiceThresh) { /* v->v */\n      FLOAT_DMEM f0 = previousFrame[j*2];\n      FLOAT_DMEM f1 = currentFrame[i*2];\n      return fabs(log());\n    }\n    if ((pv0 < voiceThresh && pv1 >= voiceThresh)||(pv0 >= voiceThresh && pv1 < voiceThresh))  { /* u->v , v->u */\n      return wTvuv;\n    }\n#endif\n\n  }\n\n  virtual FLOAT_DMEM getStateValueFromFrame(int i, FLOAT_DMEM *frame)\n  {\n    if (i<getnStates()-1)\n      return frame[i*2];\n    else\n      return 0.0;\n  }\n\npublic:\n\n  cSmileViterbiPitchSmooth(int _nCandidates, long _buflen, int _frameSize, FLOAT_DMEM thresh=0.5) :\n     cSmileViterbi(_nCandidates+1, _buflen, _frameSize),\n     wLocal(2.0), wTvv(20.0), wTvvd(0.0), wTvuv(10.0), wTuu(0.0), wThr(5.0), wRange(5.0),\n     voiceThresh(thresh), lastChange(1.0)\n   {\n   }\n\n   /* set the viterbi pitch and voicing scaling weights. Defaults are:\n    * wLocal(2.0), wTvv(20.0), wTvuv(10.0), wTuu(0.0), wThr(5.0)\n    */\n   void setWeights(double local=2.0, double tvv=20.0, double tvvd=20.0, double tvuv=10.0, double thr=5.0, double range=5.0, double tuu=0) {\n     wLocal = local;\n     wTvv = tvv;\n     wTvvd = tvv;\n     wTvuv = tvuv;\n     wThr = thr;\n     wRange=range;\n     wTuu = tuu;\n   }\n\n};\n\n\n//-------------------------------\n\nclass DLLEXPORT cPitchSmootherViterbi : public cDataProcessor {\n  private:\n    cSmileViterbiPitchSmooth *viterbi;\n    FLOAT_DMEM *framePtr;\n    cVector *vecO;\n    FLOAT_DMEM voiceThresh;\n    long buflen;\n    int outpVecSize;\n    int nInputLevels;\n    FLOAT_DMEM lastValidf0;\n\n    int F0finalLog, F0final, F0finalEnv, F0finalEnvLog;\n    int voicingFinalClipped, voicingFinalUnclipped;\n    int F0raw, voicingC1, voicingClip;\n\n    FLOAT_DMEM *voicingCutoff;\n    long *nCandidates; // array holding max. number of candidates for each pda; array of size nInputLevels;\n    // index lookup:\n    int *f0candI, *candVoiceI, *candScoreI;  // array of size nInputLevels;\n    int *F0rawI, *voicingClipI, *voicingC1I;\n\n    double wLocal, wTvv, wTvvd, wTvuv, wTuu, wThr, wRange;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    cDataReader * reader2;\n\n    virtual void fetchConfig();\n    virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n    virtual int setupNewNames(long nEl);\n    virtual int configureReader(const sDmLevelConfig &c);\n    virtual void mySetEnvironment();\n    virtual int myRegisterInstance(int *runMe);\n    virtual int configureWriter(sDmLevelConfig &c);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cPitchSmootherViterbi(const char *_name);\n\n    virtual ~cPitchSmootherViterbi();\n};\n\n\n\n\n#endif // __CPITCHSMOOTHERVITERBI_HPP\n"
  },
  {
    "path": "src/include/lld/tonefilt.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\non-line semi-tone filter bank\n\n*/\n\n\n#ifndef __CTONEFILT_HPP\n#define __CTONEFILT_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataProcessor.hpp>\n\n#define BUILD_COMPONENT_Tonefilt\n#define COMPONENT_DESCRIPTION_CTONEFILT \"This component implements an on-line, sample by sample semi-tone filter bank which can be used as first step for the computation of CHROMA features as a replacement of cTonespec. The filter is based on correlating with a sine wave of the exact target frequency of a semi-tone for each note in the filter-bank.\"\n#define COMPONENT_NAME_CTONEFILT \"cTonefilt\"\n\n#undef class\nclass DLLEXPORT cTonefilt : public cDataProcessor {\n  private:\n    double outputPeriod; /* in seconds */\n    long  /*outputBuffersize,*/ outputPeriodFrames; /* in frames */\n    int nNotes;\n    double firstNote;\n    long N, Nf;\n    double inputPeriod;\n    double decayFN, decayF0;\n    \n    cVector *tmpVec;\n    FLOAT_DMEM *tmpFrame;\n\n    double **corrS, **corrC;\n    double *decayF;\n    double *freq;\n    long * pos;\n\n    void doFilter(int i, cMatrix *row, FLOAT_DMEM*x);\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    //virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n    virtual int configureWriter(sDmLevelConfig &c);\n    virtual int setupNewNames(long nEl);\n      \n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cTonefilt(const char *_name);\n\n    virtual ~cTonefilt();\n};\n\n\n\n\n#endif // __CTONEFILT_HPP\n"
  },
  {
    "path": "src/include/lld/tonespec.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\ncomputes (or rather estimates) semi-tone spectrum from fft spectrum\n\n*/\n\n\n#ifndef __CTONESPEC_HPP\n#define __CTONESPEC_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n#include <math.h>\n\n#define BUILD_COMPONENT_Tonespec\n#define COMPONENT_DESCRIPTION_CTONESPEC \"This component computes (or rather estimates) a semi-tone spectrum from an FFT magnitude spectrum.\"\n#define COMPONENT_NAME_CTONESPEC \"cTonespec\"\n\n#undef class\nclass DLLEXPORT cTonespec : public cVectorProcessor {\n  private:\n    int nOctaves, nNotes;\n    int usePower, dbA;\n  #ifdef DEBUG\n    int printBinMap, printFilterMap;\n  #endif\n  \n    FLOAT_DMEM firstNote;  // frequency of first note\n    FLOAT_DMEM lastNote;   // frequency of last note (will be computed)\n\n    FLOAT_DMEM **pitchClassFreq;\n    FLOAT_DMEM **distance2key;\n    FLOAT_DMEM **filterMap;\n    FLOAT_DMEM **db;\n    \n    int **binKey;\n    int **pitchClassNbins;\n    int **flBin;\n    \n    int filterType;\n\n    void computeFilters( long blocksize, double frameSizeSec, int idxc );\n    void setPitchclassFreq( int idxc );\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    //virtual int myTick(long long t);\n\n    //virtual int configureWriter(const sDmLevelConfig *c);\n    virtual int dataProcessorCustomFinalise();\n    virtual int setupNamesForField(int i, const char*name, long nEl);\n    //virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cTonespec(const char *_name);\n\n    virtual ~cTonespec();\n};\n\n\n\n\n#endif // __CTONESPEC_HPP\n"
  },
  {
    "path": "src/include/lldcore/energy.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\ncompute RMS and log frame energy\n\n*/\n\n\n#ifndef __CENERGY_HPP\n#define __CENERGY_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CENERGY \"This component computes logarithmic (log) and root-mean-square (rms) signal energy from PCM frames.\"\n#define COMPONENT_NAME_CENERGY \"cEnergy\"\n\n#undef class\nclass DLLEXPORT cEnergy : public cVectorProcessor {\n  private:\n    int htkcompatible;\n\t  int erms, elog;\n\t  int energy2;\n    FLOAT_DMEM escaleRms, escaleLog, escaleSquare;\n    FLOAT_DMEM ebiasLog, ebiasRms, ebiasSquare;\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    //virtual int myTick(long long t);\n\n    //virtual int configureWriter(const sDmLevelConfig *c);\n\n    virtual int setupNamesForField(int i, const char*name, long nEl);\n    //virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cEnergy(const char *_name);\n\n    virtual ~cEnergy();\n};\n\n\n\n\n#endif // __CENERGY_HPP\n"
  },
  {
    "path": "src/include/lldcore/intensity.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\ncompute simplified intensity according to :\n Andreas Kieling - Extraktion und Klassifikation prosodischer Merkmale in der automatischen Sprachverarbeitung\n Pg. 156-157\n\n*/\n\n\n#ifndef __CINTENSITY_HPP\n#define __CINTENSITY_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CINTENSITY \"This component computes simplified frame intensity (narrow band approximation). IMPORTANT: It expects UNwindowed raw PCM frames as input!! A Hamming window is internally applied and the resulting signal is squared bevore applying loudness compression, etc.\"\n#define COMPONENT_NAME_CINTENSITY \"cIntensity\"\n\n#undef class\nclass DLLEXPORT cIntensity : public cVectorProcessor {\n  private:\n    double I0;\n    double *hamWin;\n    long nWin;\n    double winSum;\n\n    int intensity, loudness;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    //virtual int myTick(long long t);\n\n    //virtual int configureWriter(const sDmLevelConfig *c);\n\n    virtual int setupNamesForField(int i, const char*name, long nEl);\n    //virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cIntensity(const char *_name);\n\n    virtual ~cIntensity();\n};\n\n\n\n\n#endif // __CINTENSITY_HPP\n"
  },
  {
    "path": "src/include/lldcore/melspec.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nMel-frequency spectrum\n\n*/\n\n\n#ifndef __MELSPEC_HPP\n#define __MELSPEC_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n#include <math.h>\n\n#define COMPONENT_DESCRIPTION_CMELSPEC \"This component computes an N-band Mel/Bark/Semitone-frequency spectrum (critical band spectrum) by applying overlapping triangular filters equidistant on the Mel/Bark/Semitone-frequency scale to an FFT magnitude or power spectrum.\"\n#define COMPONENT_NAME_CMELSPEC \"cMelspec\"\n\n/*\n#define SPECSCALE_MEL      0\n#define SPECSCALE_BARK     2\n#define SPECSCALE_BARK_SCHROED    3\n#define SPECSCALE_BARK_SPEEX     4\n#define SPECSCALE_SEMITONE 10\n*/\n\n#define TWELFTH_ROOT_OF_2  1.1224620483093729814335330496787\n\n\n#undef class\nclass DLLEXPORT cMelspec : public cVectorProcessor {\n  private:\n    int hfcc;\n    int inverse;\n    int nBands, htkcompatible, usePower;\n    FLOAT_DMEM **filterCoeffs;\n    FLOAT_DMEM **filterCfs;\n    long **chanMap;\n    long bs;\n    FLOAT_DMEM lofreq, hifreq;\n    long *nLoF, *nHiF;\n    int specScale;\n    double firstNote, logScaleBase, param;\n    int customBandwidth;\n    double halfBwTarg;\n\n    // Hertz to Mel/Bark/..\n/*    FLOAT_DMEM Mel(FLOAT_DMEM fhz) {\n      switch(specScale) {\n        case SPECSCALE_MEL : \n          return (FLOAT_DMEM)(1127.0*log(1.0+(double)fhz/700.0));\n        case SPECSCALE_BARK:\n          if (fhz>0) {\n            return (26.81 / (1.0 + 1960.0/fhz)) - 0.53;\n          } else return 0.0;\n        case SPECSCALE_BARK_SCHROED : \n          if (fhz>0) {\n            double f6 = fhz/600.0;\n            return (6.0 * log(f6 + sqrt(f6*f6 + 1.0) ) );\n          } else return 0.0;\n        case SPECSCALE_BARK_SPEEX :  \n          return (FLOAT_DMEM)(13.1*atan(.00074*(double)fhz)+2.24*atan(((double)fhz)*((double)fhz)*1.85e-8)+1e-4*((double)fhz));\n        // EXPERIMENTAL:\n        case SPECSCALE_SEMITONE : {\n                          if (fhz < 27.5) fhz = 27.5;\n                          return (FLOAT_DMEM)( log( (double)(fhz) / 27.5 ) / log (TWELFTH_ROOT_OF_2) ) ;\n                       }\n        default: // =Mel\n          return (FLOAT_DMEM)(1127.0*log(1.0+(double)fhz/700.0));\n      }\n    }\n\n    \n    // Mel to Hertz\n    FLOAT_DMEM Hertz(FLOAT_DMEM fmel) {\n      switch(specScale) {\n        case SPECSCALE_MEL : \n          return (FLOAT_DMEM)(700.0*(exp((double)fmel/1127.0)-1.0));        \n        case SPECSCALE_BARK:        \n          double z0 = (z+0.53)/26.81;\n          if (z0 != 1.0) return (1960.0 * z0)/(1.0-z0);\n          else return 0.0;\n        case SPECSCALE_BARK_SCHROED: SMILE_IERR(1,\"bark to hertz not yet implemented!\"); break;\n        case SPECSCALE_BARK_SPEEX:  SMILE_IERR(1,\"bark to hertz not yet implemented!\"); break;\n        // EXPERIMENTAL:\n        case SPECSCALE_SEMITONE : {\n                          return (FLOAT_DMEM)( exp(fmel * log( TWELFTH_ROOT_OF_2 )) * 27.5 ) ;\n                       }\n        default: // =Mel\n          return (FLOAT_DMEM)(700.0*(exp((double)fmel/1127.0)-1.0));\n      }\n      return 0.0;\n    }\n*/\n\n    // convert frequency (hz) to FFT bin number\n    long FtoN(FLOAT_DMEM fhz, FLOAT_DMEM baseF)\n    {\n      return (long)round((double)(fhz/baseF));\n    }\n\n    // convert FFT bin number to frequency (hz)\n    FLOAT_DMEM NtoF(long bin, FLOAT_DMEM baseF)\n    {\n      return ((FLOAT_DMEM)bin * baseF);\n    }\n\n    // convert bin number to frequency in Mel/Bark/...\n    FLOAT_DMEM NtoFmel(long N, FLOAT_DMEM baseF)\n    {\n      return (FLOAT_DMEM)smileDsp_specScaleTransfFwd( ((FLOAT_DMEM)N)*baseF , specScale, param );\n    }\n\n    int computeFilters( long blocksize, double frameSizeSec, int idxc );\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    //virtual int myTick(long long t);\n\n    //virtual int configureWriter(const sDmLevelConfig *c);\n    virtual int dataProcessorCustomFinalise();\n\n    virtual void configureField(int idxi, long myN, long _nOut);\n    virtual int setupNamesForField(int i, const char*name, long nEl);\n    //virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cMelspec(const char *_name);\n\n    virtual ~cMelspec();\n};\n\n\n\n\n#endif // __MELSPEC_HPP\n"
  },
  {
    "path": "src/include/lldcore/mfcc.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\ncomputes MFCC from Mel-spectrum (see cMelspec)\n\n*/\n\n\n#ifndef __CMFCC_HPP\n#define __CMFCC_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n#include <math.h>\n\n#define COMPONENT_DESCRIPTION_CMFCC \"This component computes Mel-frequency cepstral coefficients (MFCC) from a critical band spectrum (see 'cMelspec'). An I-DCT of type-II is used from transformation from the spectral to the cepstral domain. Liftering of cepstral coefficients is supported. HTK compatible values can be computed.\"\n#define COMPONENT_NAME_CMFCC \"cMfcc\"\n\n#undef class\nclass DLLEXPORT cMfcc : public cVectorProcessor {\n  private:\n    int printDctBaseFunctions;\n    int inverse;\n    int nBands, htkcompatible, usePower;\n    FLOAT_DMEM **costable;\n    FLOAT_DMEM **sintable;\n    int firstMfcc, lastMfcc, nMfcc;\n    FLOAT_DMEM melfloor;\n    FLOAT_DMEM cepLifter;\n    int doLog_;\n    \n    int initTables( long blocksize, int idxc );\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    //virtual int myTick(long long t);\n\n    //virtual int configureWriter(const sDmLevelConfig *c);\n    virtual int dataProcessorCustomFinalise();\n    virtual int setupNamesForField(int i, const char*name, long nEl);\n    //virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cMfcc(const char *_name);\n\n    virtual ~cMfcc();\n};\n\n\n\n\n#endif // __CMFCC_HPP\n"
  },
  {
    "path": "src/include/lldcore/mzcr.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\ntime signal properties: min/max sample value, mean and zero crossing rates\n\n*/\n\n\n#ifndef __CMZCR_HPP\n#define __CMZCR_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CMZCR \"This component computes time signal properties, zero-corssing rate, mean-crossing rate, dc offset, max/min value, and absolute maximum value of a PCM frame.\"\n#define COMPONENT_NAME_CMZCR \"cMZcr\"\n\n\n#undef class\nclass DLLEXPORT cMZcr : public cVectorProcessor {\n  private:\n    int zcr, mcr, amax, maxmin, dc;\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    //virtual int myTick(long long t);\n\n    //virtual int configureWriter(const sDmLevelConfig *c);\n\n    virtual int setupNamesForField(int i, const char*name, long nEl);\n    //virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cMZcr(const char *_name);\n\n    virtual ~cMZcr();\n};\n\n\n\n\n#endif // __CMZCR_HPP\n"
  },
  {
    "path": "src/include/lldcore/pitchACF.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample vectorProcessor descendant\n\n*/\n\n\n#ifndef __CPITCHACF_HPP\n#define __CPITCHACF_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CPITCHACF \"This component computes the fundamental frequency and the probability of voicing via an acf and cepstrum based method. The input must be an acf field and a cepstrum field (both generated by a cAcf component).\"\n#define COMPONENT_NAME_CPITCHACF \"cPitchACF\"\n\n#undef class\nclass DLLEXPORT cPitchACF : public cVectorProcessor {\n  private:\n    int HNR;\n    int HNRdB, linHNR;\n\t  int F0, F0raw;\n\t  int F0env;\n    int voiceProb, voiceQual;\n\t  int onsFlag;\n    double maxPitch;\n\t  double voicingCutoff;\n\t  FLOAT_DMEM lastPitch, lastlastPitch, glMeanPitch, pitchEnv;\n\t  float fsSec;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    //virtual int myTick(long long t);\n\n    //virtual int configureWriter(const sDmLevelConfig *c);\n\n    //virtual void configureField(int idxi, long __N, long nOut);\n    //virtual int setupNamesForField(int i, const char*name, long nEl);\n\t  virtual int setupNewNames(long nEl);\n    //virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    double computeHNR(const FLOAT_DMEM *a, int f0Idx);\n    double computeHNR_dB(const FLOAT_DMEM *a, int f0Idx);\n    double computeHNR_lin(const FLOAT_DMEM *a, int f0Idx);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cPitchACF(const char *_name);\n    \n    double voicingProb(const FLOAT_DMEM *a, int n, int skip, double *Zcr);\n    long pitchPeak(const FLOAT_DMEM *a, long n, long skip);\n\n    virtual ~cPitchACF();\n};\n\n\n\n\n#endif // __CPITCHACF_HPP\n"
  },
  {
    "path": "src/include/lldcore/pitchBase.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nThis component computes pitch via the Harmonic Product Spectrum method.\nAs input it requires FFT magnitude data. \nNote that the type of input data is not checked, thus be careful when writing your configuration files!\n\n*/\n\n\n#ifndef __CPITCHBASE_HPP\n#define __CPITCHBASE_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CPITCHBASE \"Base class for all pitch classes, no functionality on its own!\"\n#define COMPONENT_NAME_CPITCHBASE \"cPitchBase\"\n\n\n#undef class\nclass DLLEXPORT cPitchBase : public cVectorProcessor {\n  private:\n    const char *inputFieldPartial;\n    int nCandidates;\n    int scores, voicing;\n    int F0C1, voicingC1;\n    int F0raw;\n    int voicingClip;\n\n    double maxPitch, minPitch;\n\n    FLOAT_DMEM *inData;\n    FLOAT_DMEM *f0cand, *candVoice, *candScore;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    FLOAT_DMEM voicingCutoff;\n    int octaveCorrection;\n\n    virtual void fetchConfig();\n\t  virtual int setupNewNames(long nEl);\n    \n    //virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n    // to be overwritten by child class:\n    virtual int pitchDetect(FLOAT_DMEM * inData, long N_, double _fsSec, double baseT, FLOAT_DMEM *f0cand, FLOAT_DMEM *candVoice, FLOAT_DMEM *candScore, long nCandidates);\n    virtual int addCustomOutputs(FLOAT_DMEM *dstCur, long NdstLeft);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cPitchBase(const char *_name);\n    \n    virtual ~cPitchBase();\n};\n\n\n\n\n#endif // __CPITCHBASE_HPP\n"
  },
  {
    "path": "src/include/lldcore/pitchSmoother.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nInput: candidates produced by a pitchBase descendant\n\n*/\n\n\n#ifndef __CPITCHSMOOTHER_HPP\n#define __CPITCHSMOOTHER_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CPITCHSMOOTHER \"This component performs temporal pitch smoothing. Input: candidates produced by a pitchBase descendant (e.g. cPitchSHS). The voicing cutoff threshold is inherited from the input component, thus this smoother component does not provide its own threshold option.\"\n#define COMPONENT_NAME_CPITCHSMOOTHER \"cPitchSmoother\"\n\n#define POSTSMOOTHING_NONE   0\n#define POSTSMOOTHING_SIMPLE 1\n#define POSTSMOOTHING_MEDIAN 2\n\n#undef class\nclass DLLEXPORT cPitchSmoother : public cVectorProcessor {\n  private:\n    int firstFrame;\n    int no0f0;\n    int medianFilter0;\n    int postSmoothing, postSmoothingMethod;\n    int onsFlag, onsFlagO;\n    int octaveCorrection;\n\n    int F0final, F0finalEnv, voicingFinalClipped, voicingFinalUnclipped;\n    int F0raw, voicingC1, voicingClip;\n\n    int nInputLevels; // number of input fields called F0cand (= number of input pdas (algos))\n    int voicing, scores; // are candVoicing and candScores fields also present? (1/0 flag)\n    \n    FLOAT_DMEM lastVoice;\n    FLOAT_DMEM pitchEnv;\n\n    // per frame data:\n    int *nCands; // array holding number of candidates for each pda (current)\n    // global:\n    int totalCands;\n    int *nCandidates; // array holding max. number of candidates for each pda; array of size nInputLevels;\n    FLOAT_DMEM *f0cand, *candVoice, *candScore;\n\n    // index lookup:\n    int *f0candI, *candVoiceI, *candScoreI;  // array of size nInputLevels;\n    int *F0rawI, *voicingClipI, *voicingC1I;\n\n    FLOAT_DMEM *median0WorkspaceF0cand;\n    FLOAT_DMEM *lastFinal;\n    FLOAT_DMEM lastFinalF0;\n\n    // NOTE: difficulty when analysing data from multiple pdas : \n    // the scores and voicing probs. may be scaled differently, although they should all be in the range 0-1\n    // thus, a direct comparion of these may not be feasible\n    // We thus start comparison for each field (pda output) individually and then (TODO) merge information from multiple pdas\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    FLOAT_DMEM *voicingCutoff;\n\n    virtual void fetchConfig();\n\t  virtual int setupNewNames(long nEl);\n    \n    //virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cPitchSmoother(const char *_name);\n    \n    virtual ~cPitchSmoother();\n};\n\n\n\n\n#endif // __CPITCHSMOOTHER_HPP\n"
  },
  {
    "path": "src/include/lldcore/plp.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: cPlp\n\nThis component computes PLP and RASTA-PLP cepstral coefficients from a critical band spectrum (generated by the cMelspec component, for example).\n\nThe component is capable of performing the following processing steps:\n   1) Take the natural logarithm of the critical band powers (doLog)\n   2) RASTA filtering\n   3) Computation of auditory spectrum (equal loudness curve and loudness compression)\n   4) Inverse of the natural logarithm\n   5) Inverse DFT to obtain autocorrelation coefficients\n   6) Linear prediction analysis on autocorr. coeff.\n   7) Computation of cepstral coefficients from lp coefficients\n   8) Cepstral 'liftering'\n\n*/\n\n\n\n#ifndef __CPLP_HPP\n#define __CPLP_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n#include <math.h>\n\n#define COMPONENT_DESCRIPTION_CPLP \"This component computes PLP and RASTA-PLP (currently the RASTA filter is not yet implemented) cepstral coefficients from a critical band spectrum (generated by the cMelspec component, for example).\\n   The component is capable of performing the following processing steps: \\n   1) Take the natural logarithm of the critical band powers (doLog)\\n   2) RASTA filtering\\n   3) Computation of auditory spectrum (equal loudness curve and loudness compression)\\n   4) Inverse of the natural logarithm\\n   5) Inverse DFT to obtain autocorrelation coefficients\\n   6) Linear prediction analysis on autocorr. coeff.\\n   7) Computation of cepstral coefficients from lp coefficients\\n   8) Cepstral 'liftering'\";\n\n#define COMPONENT_NAME_CPLP \"cPlp\"\n\n#undef class\nclass DLLEXPORT cPlp : public cVectorProcessor {\n  private:\n    int htkcompatible;\n    int nAuto, nFreq, nScale;\n    int lpOrder;\n    int nCeps, firstCC, lastCC;\n\n    int doLog, doAud, doInvLog, doIDFT, RASTA, newRASTA, doLP, doLpToCeps;\n    FLOAT_DMEM rastaUpperCutoff, rastaLowerCutoff;\n\n    FLOAT_DMEM rasta_iir;\n    FLOAT_DMEM rasta_fir[5];\n    // rasta filter history:\n    FLOAT_DMEM **rasta_buf_iir; /* size: n bands */\n    FLOAT_DMEM **rasta_buf_fir; /* size: n bands * 5 (nCoeff) */\n    int rasta_buf_fir_ptr; // buffer pointer (cyclic shifting)\n    int rasta_init;\n\n    FLOAT_DMEM cepLifter;\n    \n    FLOAT_DMEM **acf;\n    FLOAT_DMEM **lpc;\n    FLOAT_DMEM **ceps;\n\n    FLOAT_DMEM compression;\n    FLOAT_DMEM **eqlCurve; // equal loudness curve\n    FLOAT_DMEM **costable; // IDFT\n    FLOAT_DMEM **sintable; // cepstral liftering\n\n    FLOAT_DMEM melfloor;\n\n    int initTables( long blocksize, int idxc, int fidx );\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    virtual int dataProcessorCustomFinalise();\n    virtual int setupNamesForField(int i, const char*name, long nEl);\n\n    //virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cPlp(const char *_name);\n\n    virtual ~cPlp();\n};\n\n\n\n\n#endif // __CPLP_HPP\n"
  },
  {
    "path": "src/include/lldcore/spectral.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\ncomputes spectral features such as flux, roll-off, centroid, etc.\n\n*/\n\n\n#ifndef __CSPECTRAL_HPP\n#define __CSPECTRAL_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CSPECTRAL \"This component computes spectral features such as flux, roll-off, centroid, and user defined band energies (rectangular summation of FFT magnitudes), etc.\"\n#define COMPONENT_NAME_CSPECTRAL \"cSpectral\"\n\n#undef class\nclass DLLEXPORT cSpectral : public cVectorProcessor {\n  private:\n    int frqScale;\n    int normBandEnergies;\n    double frqScaleParam;\n\n    int squareInput, centroid, nBands, nSlopes, nRollOff, entropy;\n    int specDiff, specPosDiff;\n    int flux, fluxCentroid, fluxAtFluxCentroid;\n    int standardDeviation, variance, skewness, kurtosis, slope;\n    int sharpness, tonality, harmonicity, flatness;\n    int alphaRatio, hammarbergIndex;\n\n    long specRangeLower, specRangeUpper, specRangeLowerBin, specRangeUpperBin;\n    long nScale;\n    int maxPos, minPos;\n    long *bandsL, *bandsH; // frequencies\n    long *slopesL, *slopesH; // frequencies    \n    double *bandsLi, *bandsHi; // indicies (fft bins), real values\n    double *wghtLi, *wghtHi; // indicies (fft bins), real values\n    double *slopeBandsLi, *slopeBandsHi; // indicies (fft bins), real values\n    double *slopeWghtLi, *slopeWghtHi; // indicies (fft bins), real values\n    double *rollOff;\n    double fsSec;\n    const double *frq;\n    int buggyRollOff, buggySlopeScale;\n    int useLogSpectrum;\n    int logFlatness;\n    FLOAT_DMEM specFloor, logSpecFloor;\n    bool requireMagSpec, requirePowerSpec, requireLogSpec;\n\n    FLOAT_DMEM **prevSpec;\n    long nFieldsPrevSpec;\n    long *nSrcPrevSpec;\n\n\n    void setRequireLorPspec();\n    \n    int isBandValid(long start, long end)\n    {\n      if ((start>=0)&&(end>0)) return 1;\n      else return 0;\n    }\n    \n    void parseRange(const char *val, long *lowerHz, long *upperHz);\n    int parseBandsConfig(const char * field, long ** bLow, long ** bHigh);\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n\n    virtual int setupNamesForField(int i, const char*name, long nEl);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cSpectral(const char *_name);\n\n    virtual ~cSpectral();\n};\n\n\n\n\n#endif // __CSPECTRAL_HPP\n"
  },
  {
    "path": "src/include/other/bowProducer.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample dataSource\nwrites data to data memory...\n\n*/\n\n\n#ifndef __CBOWPRODUCER_HPP\n#define __CBOWPRODUCER_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataSource.hpp>\n\n#define BUILD_COMPONENT_BowProducer\n#define COMPONENT_DESCRIPTION_CBOWPRODUCER \"This component produces a bag-of-words vector from the keyword spotter result message.\"\n#define COMPONENT_NAME_CBOWPRODUCER \"cBowProducer\"\n\n#undef class\nclass DLLEXPORT cBowProducer : public cDataSource {\n  private:\n    const char *kwList;\n    const char *prefix;\n    const char *textfile;\n    const char *singleSentence;\n    int count;\n    int dataFlag;\n    int kwListPrefixFilter;\n    int syncWithAudio;\n\n    int numKw;\n    char ** keywords;\n    \n    FILE * filehandle;\n    long lineNr;\n    char * line;\n    size_t line_n;\n    int txtEof;\n\n    int loadKwList();\n    int buildBoW( cComponentMessage *_msg );\n    int buildBoW( const char * str );\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    virtual int processComponentMessage( cComponentMessage *_msg );\n    virtual int myTick(long long t);\n\n    virtual int configureWriter(sDmLevelConfig &c);\n    virtual int setupNewNames(long nEl);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cBowProducer(const char *_name);\n\n    virtual ~cBowProducer();\n};\n\n\n\n\n#endif // __CBOWPRODUCER_HPP\n"
  },
  {
    "path": "src/include/other/maxIndex.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\ncomputes the index of the feature with the maximum index\n\n*/\n\n\n#ifndef __CMAXINDEX_HPP\n#define __CMAXINDEX_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n#include <math.h>\n\n#define COMPONENT_DESCRIPTION_CMAXINDEX \"This component computes the indices of the features with the maximum absolute values per frame.\"\n#define COMPONENT_NAME_CMAXINDEX \"cMaxIndex\"\n\n#undef class\nclass DLLEXPORT cMaxIndex : public cVectorProcessor {\n  private:\n    int nIndices, minFeature, maxFeature;\n    FLOAT_DMEM noise;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    //virtual int myTick(long long t);\n\n    //virtual int configureWriter(const sDmLevelConfig *c);\n    //virtual int dataProcessorCustomFinalise();\n    virtual int setupNamesForField(int i, const char*name, long nEl);\n    //virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cMaxIndex(const char *_name);\n\n    virtual ~cMaxIndex();\n};\n\n\n\n\n#endif // __CMAXINDEX_HPP\n"
  },
  {
    "path": "src/include/other/valbasedSelector.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nvector selector based on threshold of value <idx>\n\n*/\n\n\n#ifndef __CVALBASEDSELECTOR_HPP\n#define __CVALBASEDSELECTOR_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CVALBASEDSELECTOR \"This component copies only those frames from the input to the output that match a certain threshold criterion, i.e. where a specified value N exceeds a certain threshold.\"\n#define COMPONENT_NAME_CVALBASEDSELECTOR \"cValbasedSelector\"\n\n#undef class\nclass DLLEXPORT cValbasedSelector : public cDataProcessor {\n  private:\n    long idx;\n    int removeIdx, invert, allowEqual, zerovec;\n    int adaptiveThreshold_;\n    int debugAdaptiveThreshold_;\n    FLOAT_DMEM outputVal;\n    FLOAT_DMEM threshold;\n    cVector *myVec;\n    long elI;\n    FLOAT_DMEM *valBuf_;\n    FLOAT_DMEM valBufSum_;\n    FLOAT_DMEM valBufN_;\n    int valBufSize_, valBufIdx_;\n    int valBufRefreshCnt_;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n    virtual int setupNamesForField(int i, const char*name, long nEl);\n\n    // virtual int dataProcessorCustomFinalise();\n    // virtual int setupNewNames(long nEl);\n    //virtual int setupNamesForField(int i, const char*name, long nEl);\n    //virtual int configureWriter(sDmLevelConfig &c);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cValbasedSelector(const char *_name);\n\n    virtual ~cValbasedSelector();\n};\n\n\n\n\n#endif // __CVALBASEDSELECTOR_HPP\n"
  },
  {
    "path": "src/include/other/vectorConcat.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nconcatenates vectors from multiple levels and copy to another level\n\n*/\n\n\n#ifndef __CVECTORCONCAT_HPP\n#define __CVECTORCONCAT_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CVECTORCONCAT \"concatenates vectors from multiple levels and copy to another level\"\n#define COMPONENT_NAME_CVECTORCONCAT \"cVectorConcat\"\n\n\n#undef class\nclass DLLEXPORT cVectorConcat : public cVectorProcessor {\n  private:\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    //virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    //virtual int myFinaliseInstance();\n    //virtual int myTick(long long t);\n\n    //virtual int configureWriter(sDmLevelConfig &c);\n\n    //virtual void configureField(int idxi, long __N, long nOut);\n    //virtual int setupNamesForField(int i, const char*name, long nEl);\n    virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cVectorConcat(const char *_name);\n\n    virtual ~cVectorConcat();\n};\n\n\n\n\n#endif // __CVECTORCONCAT_HPP\n"
  },
  {
    "path": "src/include/other/vectorOperation.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\ndo elementary operations on vectors \n(i.e. basically everything that does not require history or context,\n everything that can be performed on single vectors w/o external data (except for constant parameters, etc.))\n\n*/\n\n\n#ifndef __CVECTOROPERATION_HPP\n#define __CVECTOROPERATION_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/vectorProcessor.hpp>\n\n#define COMPONENT_DESCRIPTION_CVECTOROPERATION \"This component performs elementary operations on vectors (i.e. basically everything that does not require history or context, everything that can be performed on single vectors w/o external data (except for constant parameters, etc.))\"\n#define COMPONENT_NAME_CVECTOROPERATION \"cVectorOperation\"\n\n// n->n mapping operations\n#define VOP_NORMALISE 0\n#define VOP_ADD       1\n#define VOP_MUL       2\n#define VOP_LOG       3\n#define VOP_NORMALISE_L1 4\n#define VOP_SQRT      5\n#define VOP_LOGA      6\n#define VOP_POW       7\n#define VOP_EXP       8\n#define VOP_E         9\n#define VOP_ABS      10\n#define VOP_AGN      11\n#define VOP_FLATTEN  12\n#define VOP_NORM_RANGE0  13\n#define VOP_NORM_RANGE1  14\n#define VOP_MIN      15\n#define VOP_MAX      16\n#define VOP_DB_POW   17\n#define VOP_DB_MAG   18\n#define VOP_FCONV    20\n\n// begin of n->1 mapping operations\n#define VOP_X          1000 \n// n->1 mapping operations\n#define VOP_X_SUM      1001\n#define VOP_X_SUMSQ    1002\n#define VOP_X_L1       1003\n#define VOP_X_L2       1004\n\n\n#undef class\nclass DLLEXPORT cVectorOperation : public cVectorProcessor {\n  private:\n    int powOnlyPos;\n    double gnGenerator();\n    char * operationString_;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    int operation;\n    int fscaleA, fscaleB;\n    const char * nameBase;\n    const char * targFreqScaleStr;\n\n    FLOAT_DMEM param1,param2,logfloor;\n\n    virtual void fetchConfig();\n  \n    virtual int setupNamesForField(int i, const char*name, long nEl);\n    //virtual int setupNewNames(long ni);\n    virtual int processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n    virtual int processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cVectorOperation(const char *_name);\n\n    virtual ~cVectorOperation();\n};\n\n\n\n\n#endif // __CVECTOROPERATION_HPP\n"
  },
  {
    "path": "src/include/portaudio/portaudioDuplex.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nportAudio dataSink for live audio playback\n(?? known to work on windows, linux, and mac)\n\n*/\n\n\n#ifndef __CPORTAUDIODUPLEX_HPP\n#define __CPORTAUDIODUPLEX_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataProcessor.hpp>\n\n#ifdef HAVE_PORTAUDIO\n\n#include <portaudio.h>\n\n#define COMPONENT_DESCRIPTION_CPORTAUDIODUPLEX \"dataProcessor for full-duplex playback and recording of live audio using PortAudio library\"\n#define COMPONENT_NAME_CPORTAUDIODUPLEX \"cPortaudioDuplex\"\n\n\n#define PA_STREAM_STOPPED 0\n#define PA_STREAM_STARTED 1\n\n#undef class\nclass DLLEXPORT cPortaudioDuplex : public cDataProcessor {\n  private:\n    PaStream *stream;\n    long paFrames;\n    int deviceId;\n    int streamStatus;\n    int listDevices;\n    int numDevices;\n    int lastDataCount;\n    int isPaInit;\n    \n    long audioBuffersize;\n    double audioBuffersize_sec;\n    //long mBuffersize;    \n\n    int monoMixdownPB, monoMixdownREC;    // if set to 1, multi-channel files will be mixed down to 1 channel\n\n    int eof, abort; // NOTE : when setting abort, first lock the callbackMtx!!!\n    int channels, sampleRate, nBits, nBPS;\n    \n    //int setupDevice();\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    virtual void fetchConfig();\n    virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n\n    virtual int configureWriter(sDmLevelConfig &c);\n    virtual int setupNewNames(long nEl);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    // variables for the callback method:\n    //smileMutex dataFlagMtx;\n    smileMutex callbackMtx;\n    smileCond  callbackCond;\n    int dataFlagR, dataFlagW;\n    cMatrix *callbackMatrix;\n    \n    cPortaudioDuplex(const char *_name);\n\n    void printDeviceList();\n\n    int startDuplex();\n    int stopDuplex();\n    int stopDuplexWait();\n    \n    cDataReader * getReader() { return reader_; }\n    cDataWriter * getWriter() { return writer_; }\n\n    /*void setReadDataFlag() {\n      smileMutexLock(dataFlagMtx);\n      dataFlag = 1;\n      //lastDataCount=0;\n      smileMutexUnlock(dataFlagMtx);\n    }*/\n\n    int getNBPS() { return nBPS; }\n    int getNBits() { return nBits; }\n    int getChannels() { return channels; }\n    int getSampleRate() { return sampleRate; }\n    \n    int isAbort() { return abort; }\n    int isMonoMixdownPB() { return monoMixdownPB; }\n    int isMonoMixdownREC() { return monoMixdownREC; }\n    \n    virtual ~cPortaudioDuplex();\n};\n\n\n#endif // HAVE_PORTAUDIO\n\n\n#endif // __CPORTAUDIODUPLEX_HPP\n"
  },
  {
    "path": "src/include/portaudio/portaudioSink.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nportAudio dataSink for live audio playback\n(?? known to work on windows, linux, and mac)\n\n*/\n\n\n#ifndef __CPORTAUDIOSINK_HPP\n#define __CPORTAUDIOSINK_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataSink.hpp>\n\n#ifdef HAVE_PORTAUDIO\n\n#include <portaudio.h>\n\n#define COMPONENT_DESCRIPTION_CPORTAUDIOSINK \"This component handles live audio playback via the PortAudio library\"\n#define COMPONENT_NAME_CPORTAUDIOSINK \"cPortaudioSink\"\n\n\n#define PA_STREAM_STOPPED 0\n#define PA_STREAM_STARTED 1\n\n#undef class\nclass DLLEXPORT cPortaudioSink : public cDataSink {\n  private:\n    PaStream *stream;\n    long paFrames;\n    int deviceId;\n    int streamStatus;\n    int listDevices;\n    int numDevices;\n    int lastDataCount;\n    int isPaInit;\n    \n    long audioBuffersize;\n    double audioBuffersize_sec;\n    \n    int monoMixdown;    // if set to 1, multi-channel files will be mixed down to 1 channel\n\n    int eof, abort; // NOTE : when setting abort, first lock the callbackMtx!!!\n    int channels, sampleRate, nBits, nBPS;\n    \n    int setupDevice();\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    virtual void fetchConfig();\n    virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n    virtual int configureReader();\n\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    // variables for the callback method:\n    smileMutex dataFlagMtx;\n    smileMutex callbackMtx;\n    smileCond  callbackCond;\n    int dataFlag;\n    cMatrix *callbackMatrix;\n    \n    cPortaudioSink(const char *_name);\n\n    void printDeviceList();\n\n\tint startPlayback();\n    int stopPlayback();\n    int stopPlaybackWait();\n    \n    cDataReader * getReader() { return reader_; }\n\n    void setReadDataFlag() {\n      smileMutexLock(dataFlagMtx);\n      dataFlag = 1;\n      //lastDataCount=0;\n      smileMutexUnlock(dataFlagMtx);\n    }\n\n\tint getNBPS() { return nBPS; }\n    int getNBits() { return nBits; }\n    int getChannels() { return channels; }\n    int getSampleRate() { return sampleRate; }\n    \n\tint isAbort() { return abort; }\n    int isMonoMixdown() { return monoMixdown; }\n    \n    virtual ~cPortaudioSink();\n};\n\n\n#endif // HAVE_PORTAUDIO\n\n\n#endif // __CPORTAUDIOSINK_HPP\n"
  },
  {
    "path": "src/include/portaudio/portaudioSource.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nportAudio dataSource for live recording from sound device\nknown to work on windows, linux, and mac\n\n*/\n\n\n#ifndef __CPORTAUDIOSOURCE_HPP\n#define __CPORTAUDIOSOURCE_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataSource.hpp>\n\n#ifdef HAVE_PORTAUDIO\n\n//#ifdef HAVE_PTHREAD\n//#include <pthread.h>\n//#endif\n\n#define COMPONENT_DESCRIPTION_CPORTAUDIOSOURCE \"This component handles live audio recording from the soundcard via the PortAudio library\"\n#define COMPONENT_NAME_CPORTAUDIOSOURCE \"cPortaudioSource\"\n\n\n#define PA_STREAM_STOPPED 0\n#define PA_STREAM_STARTED 1\n\n/*\ntypedef struct {\n  long sampleRate;\n  int sampleType;\n  int nChan;\n  int blockSize;\n  int nBPS;       // actual bytes per sample\n  int nBits;       // bits per sample (precision)\n  int byteOrder;  // BYTEORDER_LE or BYTEORDER_BE\n  int memOrga;    // MEMORGA_INTERLV  or MEMORGA_SEPCH\n  long nBlocks;  // nBlocks in buffer\n} sWaveParameters;\n*/\n\ntypedef void PaStream;\n\n#undef class\nclass DLLEXPORT cPortaudioSource : public cDataSource {\n  private:\n    PaStream *stream;\n    int byteSwap;\n    long paFrames;\n    int deviceId;\n    int streamStatus;\n    int listDevices;\n    int numDevices;\n    int lastDataCount;\n    int isPaInit;\n    int warned;\n\n    long audioBuffersize;\n    double audioBuffersize_sec;\n    //long mBuffersize;\n    \n    //sWaveParameters pcmParam;\n\n    int monoMixdown;    // if set to 1, multi-channel files will be mixed down to 1 channel\n\n    long curReadPos;   // in samples\n    int eof, abort; // NOTE : when setting abort, first lock the callbackMtx!!!\n    int channels, sampleRate, nBits, nBPS, selectChannel;\n    \n    int setupDevice();\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    virtual void fetchConfig();\n    virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n    virtual int pauseEvent();\n    virtual void resumeEvent(); \n\n    virtual int configureWriter(sDmLevelConfig &c);\n    virtual int setupNewNames(long nEl);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    // variables for the callback method:\n    smileMutex dataFlagMtx;\n    smileMutex callbackMtx;\n    smileCond  callbackCond;\n    int dataFlag;\n    cMatrix *callbackMatrix;\n    \n    cPortaudioSource(const char *_name);\n\n    void printDeviceList();\n    int startRecording();\n    int stopRecording();\n    int stopRecordingWait();\n    \n    cDataWriter * getWriter() { return writer_; }\n\n    void setNewDataFlag() {\n      smileMutexLock(dataFlagMtx);\n      dataFlag = 1;\n      lastDataCount=0;\n      smileMutexUnlock(dataFlagMtx);\n    }\n    int getNBPS() { return nBPS; }\n    int getNBits() { return nBits; }\n    int getChannels() { return channels; }\n    int getSelectedChannel() { return selectChannel; }\n    int getSampleRate() { return sampleRate; }\n    int isAbort() { return abort; }\n    int isMonoMixdown() { return monoMixdown; }\n    \n    virtual ~cPortaudioSource();\n};\n\n\n#endif // HAVE_PORTAUDIO\n\n\n#endif // __CPORTAUDIOSOURCE_HPP\n"
  },
  {
    "path": "src/include/portaudio/portaudioWavplayer.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nportAudio dataSink for live audio playback\n(?? known to work on windows, linux, and mac)\n\n*/\n\n\n#ifndef __CPORTAUDIOWAVPLAYER_HPP\n#define __CPORTAUDIOWAVPLAYER_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/smileComponent.hpp>\n\n#ifdef HAVE_PORTAUDIO\n\n#include <portaudio.h>\n\n#ifdef HAVE_JULIUSLIB\n#include <classifiers/julius/kwsjKresult.h>\n#endif \n\n#define COMPONENT_DESCRIPTION_CPORTAUDIOWAVPLAYER \"This component can play wavefiles directly to a portaudio output device. Multiple wave files can be specified as inputs and they can be played via smile messages containing the index of the sample to play. Concurrent play requests will be discarded (TODO: mix the output). All wave files must have the same sampling rate.\"\n#define COMPONENT_NAME_CPORTAUDIOWAVPLAYER \"cPortaudioWavplayer\"\n\n\n#define PA_STREAM_STOPPED 0\n#define PA_STREAM_STARTED 1\n\n#undef class\nclass DLLEXPORT cPortaudioWavplayer : public cSmileComponent {\n  private:\n    PaStream *stream;\n    long paFrames;\n    int deviceId;\n    int streamStatus;\n    int listDevices;\n    int numDevices;\n    int isPaInit;\n    \n    long audioBuffersize;\n    double audioBuffersize_sec;\n    \n    int monoMixdown;    // if set to 1, multi-channel files will be mixed down to 1 channel\n\n    int eof, abort; // NOTE : when setting abort, first lock the callbackMtx!!!\n    int inputChannels, channels, sampleRate, nBits, nBPS;\n    \n    const char *semaineCallbackRcpt;\n    int isFirst;\n\n    int numKw;\n    const char ** keywords;\n    int numInd;\n    int * indices;\n\n\n    int setupDevice();\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    virtual void fetchConfig();\n    virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n    //virtual int configureReader();\n\n    virtual int processComponentMessage( cComponentMessage *_msg );\n\n#ifdef HAVE_JULIUSLIB\n    int getPlayIdxFromKeyword(juliusResult *k);\n#endif\n    int getPlayIdxFromClassname(const char *cls);\n    int getPlayIdxFromClassidx(float idx);\n    int triggerPlayback(int idx);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    // variables for the callback method:\n    int wavsLoaded;\n    int nWavs;\n    float **wavedata;\n    long *wavelength;\n\n    int playback, playIndex;\n    long playPtr;\n\n    smileMutex dataFlagMtx;\n    smileMutex callbackMtx;\n    smileCond  callbackCond;\n    int dataFlag;\n        \n    cPortaudioWavplayer(const char *_name);\n\n    void printDeviceList();\n    \n    void sendEndMessage();\n\n\t  int startPlayback();\n    int stopPlayback();\n    int stopPlaybackWait();\n\n    int getNBPS() { return nBPS; }\n    int getNBits() { return nBits; }\n    int getChannels() { return channels; }\n    int getInputChannels() { return inputChannels; }\n    int getSampleRate() { return sampleRate; }\n\n    int isAbort() { return abort; }\n    int isMonoMixdown() { return monoMixdown; }\n\n    virtual ~cPortaudioWavplayer();\n};\n\n\n#endif // HAVE_PORTAUDIO\n\n\n#endif // __CPORTAUDIOWAVPLAYER_HPP\n"
  },
  {
    "path": "src/include/rapidjson/document.h",
    "content": "/******************************************\r\n * RapidJson\r\n * Copyright (C) 2011 Milo Yip\r\n * see COPYING in the top-level directory\r\n * for more information.\r\n *****************************************/\r\n\r\n#ifndef RAPIDJSON_DOCUMENT_H_\r\n#define RAPIDJSON_DOCUMENT_H_\r\n\r\n#include \"reader.h\"\r\n#include \"internal/strfunc.h\"\r\n#include <new>\t\t// placement new\r\n\r\n#ifdef _MSC_VER\r\n#pragma warning(push)\r\n#pragma warning(disable : 4127) // conditional expression is constant\r\n#endif\r\n\r\nnamespace rapidjson {\r\n\r\n///////////////////////////////////////////////////////////////////////////////\r\n// GenericValue\r\n\r\n//! Represents a JSON value. Use Value for UTF8 encoding and default allocator.\r\n/*!\r\n\tA JSON value can be one of 7 types. This class is a variant type supporting\r\n\tthese types.\r\n\r\n\tUse the Value if UTF8 and default allocator\r\n\r\n\t\\tparam Encoding\tEncoding of the value. (Even non-string values need to have the same encoding in a document)\r\n\t\\tparam Allocator\tAllocator type for allocating memory of object, array and string.\r\n*/\r\n#pragma pack (push, 4)\r\ntemplate <typename Encoding, typename Allocator = MemoryPoolAllocator<> > \r\nclass GenericValue {\r\npublic:\r\n\t//! Name-value pair in an object.\r\n\tstruct Member { \r\n\t\tGenericValue<Encoding, Allocator> name;\t\t//!< name of member (must be a string)\r\n\t\tGenericValue<Encoding, Allocator> value;\t//!< value of member.\r\n\t};\r\n\r\n\ttypedef Encoding EncodingType;\t\t\t\t\t//!< Encoding type from template parameter.\r\n\ttypedef Allocator AllocatorType;\t\t\t\t//!< Allocator type from template parameter.\r\n\ttypedef typename Encoding::Ch Ch;\t\t\t\t//!< Character type derived from Encoding.\r\n\ttypedef Member* MemberIterator;\t\t\t\t\t//!< Member iterator for iterating in object.\r\n\ttypedef const Member* ConstMemberIterator;\t\t//!< Constant member iterator for iterating in object.\r\n\ttypedef GenericValue* ValueIterator;\t\t\t//!< Value iterator for iterating in array.\r\n\ttypedef const GenericValue* ConstValueIterator;\t//!< Constant value iterator for iterating in array.\r\n\r\n\t//!@name Constructors and destructor.\r\n\t//@{\r\n\r\n\t//! Default constructor creates a null value.\r\n\tGenericValue() : flags_(kNullFlag) {}\r\n\r\n\t//! Copy constructor is not permitted.\r\nprivate:\r\n\tGenericValue(const GenericValue& rhs);\r\n\r\npublic:\r\n\r\n\t//! Constructor with JSON value type.\r\n\t/*! This creates a Value of specified type with default content.\r\n\t\t\\param type\tType of the value.\r\n\t\t\\note Default content for number is zero.\r\n\t*/\r\n\tGenericValue(Type type) {\r\n\t\tstatic const unsigned defaultFlags[7] = {\r\n\t\t\tkNullFlag, kFalseFlag, kTrueFlag, kObjectFlag, kArrayFlag, kConstStringFlag,\r\n\t\t\tkNumberFlag | kIntFlag | kUintFlag | kInt64Flag | kUint64Flag | kDoubleFlag\r\n\t\t};\r\n\t\tRAPIDJSON_ASSERT(type <= kNumberType);\r\n\t\tflags_ = defaultFlags[type];\r\n\t\tmemset(&data_, 0, sizeof(data_));\r\n\t}\r\n\r\n\t//! Constructor for boolean value.\r\n\tGenericValue(bool b) : flags_(b ? kTrueFlag : kFalseFlag) {}\r\n\r\n\t//! Constructor for int value.\r\n\tGenericValue(int i) : flags_(kNumberIntFlag) { \r\n\t\tdata_.n.i64 = i;\r\n\t\tif (i >= 0)\r\n\t\t\tflags_ |= kUintFlag | kUint64Flag;\r\n\t}\r\n\r\n\t//! Constructor for unsigned value.\r\n\tGenericValue(unsigned u) : flags_(kNumberUintFlag) {\r\n\t\tdata_.n.u64 = u; \r\n\t\tif (!(u & 0x80000000))\r\n\t\t\tflags_ |= kIntFlag | kInt64Flag;\r\n\t}\r\n\r\n\t//! Constructor for int64_t value.\r\n\tGenericValue(int64_t i64) : flags_(kNumberInt64Flag) {\r\n\t\tdata_.n.i64 = i64;\r\n\t\tif (i64 >= 0) {\r\n\t\t\tflags_ |= kNumberUint64Flag;\r\n\t\t\tif (!(i64 & 0xFFFFFFFF00000000LL))\r\n\t\t\t\tflags_ |= kUintFlag;\r\n\t\t\tif (!(i64 & 0xFFFFFFFF80000000LL))\r\n\t\t\t\tflags_ |= kIntFlag;\r\n\t\t}\r\n\t\telse if (i64 >= -2147483648LL)\r\n\t\t\tflags_ |= kIntFlag;\r\n\t}\r\n\r\n\t//! Constructor for uint64_t value.\r\n\tGenericValue(uint64_t u64) : flags_(kNumberUint64Flag) {\r\n\t\tdata_.n.u64 = u64;\r\n\t\tif (!(u64 & 0x8000000000000000ULL))\r\n\t\t\tflags_ |= kInt64Flag;\r\n\t\tif (!(u64 & 0xFFFFFFFF00000000ULL))\r\n\t\t\tflags_ |= kUintFlag;\r\n\t\tif (!(u64 & 0xFFFFFFFF80000000ULL))\r\n\t\t\tflags_ |= kIntFlag;\r\n\t}\r\n\r\n\t//! Constructor for double value.\r\n\tGenericValue(double d) : flags_(kNumberDoubleFlag) { data_.n.d = d; }\r\n\r\n\t//! Constructor for constant string (i.e. do not make a copy of string)\r\n\tGenericValue(const Ch* s, SizeType length) { \r\n\t\tRAPIDJSON_ASSERT(s != NULL);\r\n\t\tflags_ = kConstStringFlag;\r\n\t\tdata_.s.str = s;\r\n\t\tdata_.s.length = length;\r\n\t}\r\n\r\n\t//! Constructor for constant string (i.e. do not make a copy of string)\r\n\tGenericValue(const Ch* s) { SetStringRaw(s, internal::StrLen(s)); }\r\n\r\n\t//! Constructor for copy-string (i.e. do make a copy of string)\r\n\tGenericValue(const Ch* s, SizeType length, Allocator& allocator) { SetStringRaw(s, length, allocator); }\r\n\r\n\t//! Constructor for copy-string (i.e. do make a copy of string)\r\n\tGenericValue(const Ch*s, Allocator& allocator) { SetStringRaw(s, internal::StrLen(s), allocator); }\r\n\r\n\t//! Destructor.\r\n\t/*! Need to destruct elements of array, members of object, or copy-string.\r\n\t*/\r\n\t~GenericValue() {\r\n\t\tif (Allocator::kNeedFree) {\t// Shortcut by Allocator's trait\r\n\t\t\tswitch(flags_) {\r\n\t\t\tcase kArrayFlag:\r\n\t\t\t\tfor (GenericValue* v = data_.a.elements; v != data_.a.elements + data_.a.size; ++v)\r\n\t\t\t\t\tv->~GenericValue();\r\n\t\t\t\tAllocator::Free(data_.a.elements);\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase kObjectFlag:\r\n\t\t\t\tfor (Member* m = data_.o.members; m != data_.o.members + data_.o.size; ++m) {\r\n\t\t\t\t\tm->name.~GenericValue();\r\n\t\t\t\t\tm->value.~GenericValue();\r\n\t\t\t\t}\r\n\t\t\t\tAllocator::Free(data_.o.members);\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase kCopyStringFlag:\r\n\t\t\t\tAllocator::Free(const_cast<Ch*>(data_.s.str));\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t//@}\r\n\r\n\t//!@name Assignment operators\r\n\t//@{\r\n\r\n\t//! Assignment with move semantics.\r\n\t/*! \\param rhs Source of the assignment. It will become a null value after assignment.\r\n\t*/\r\n\tGenericValue& operator=(GenericValue& rhs) {\r\n\t\tRAPIDJSON_ASSERT(this != &rhs);\r\n\t\tthis->~GenericValue();\r\n\t\tmemcpy(this, &rhs, sizeof(GenericValue));\r\n\t\trhs.flags_ = kNullFlag;\r\n\t\treturn *this;\r\n\t}\r\n\r\n\t//! Assignment with primitive types.\r\n\t/*! \\tparam T Either Type, int, unsigned, int64_t, uint64_t, const Ch*\r\n\t\t\\param value The value to be assigned.\r\n\t*/\r\n\ttemplate <typename T>\r\n\tGenericValue& operator=(T value) {\r\n\t\tthis->~GenericValue();\r\n\t\tnew (this) GenericValue(value);\r\n\t\treturn *this;\r\n\t}\r\n\t//@}\r\n\r\n\t//!@name Type\r\n\t//@{\r\n\r\n\tType GetType()\tconst { return static_cast<Type>(flags_ & kTypeMask); }\r\n\tbool IsNull()\tconst { return flags_ == kNullFlag; }\r\n\tbool IsFalse()\tconst { return flags_ == kFalseFlag; }\r\n\tbool IsTrue()\tconst { return flags_ == kTrueFlag; }\r\n\tbool IsBool()\tconst { return (flags_ & kBoolFlag) != 0; }\r\n\tbool IsObject()\tconst { return flags_ == kObjectFlag; }\r\n\tbool IsArray()\tconst { return flags_ == kArrayFlag; }\r\n\tbool IsNumber() const { return (flags_ & kNumberFlag) != 0; }\r\n\tbool IsInt()\tconst { return (flags_ & kIntFlag) != 0; }\r\n\tbool IsUint()\tconst { return (flags_ & kUintFlag) != 0; }\r\n\tbool IsInt64()\tconst { return (flags_ & kInt64Flag) != 0; }\r\n\tbool IsUint64()\tconst { return (flags_ & kUint64Flag) != 0; }\r\n\tbool IsDouble() const { return (flags_ & kDoubleFlag) != 0; }\r\n\tbool IsString() const { return (flags_ & kStringFlag) != 0; }\r\n\r\n\t//@}\r\n\r\n\t//!@name Null\r\n\t//@{\r\n\r\n\tGenericValue& SetNull() { this->~GenericValue(); new (this) GenericValue(); return *this; }\r\n\r\n\t//@}\r\n\r\n\t//!@name Bool\r\n\t//@{\r\n\r\n\tbool GetBool() const { RAPIDJSON_ASSERT(IsBool()); return flags_ == kTrueFlag; }\r\n\tGenericValue& SetBool(bool b) { this->~GenericValue(); new (this) GenericValue(b); return *this; }\r\n\r\n\t//@}\r\n\r\n\t//!@name Object\r\n\t//@{\r\n\r\n\t//! Set this value as an empty object.\r\n\tGenericValue& SetObject() { this->~GenericValue(); new (this) GenericValue(kObjectType); return *this; }\r\n\r\n\t//! Get the value associated with the object's name.\r\n\tGenericValue& operator[](const Ch* name) {\r\n\t\tif (Member* member = FindMember(name))\r\n\t\t\treturn member->value;\r\n\t\telse {\r\n\t\t\tstatic GenericValue NullValue;\r\n\t\t\treturn NullValue;\r\n\t\t}\r\n\t}\r\n\tconst GenericValue& operator[](const Ch* name) const { return const_cast<GenericValue&>(*this)[name]; }\r\n\r\n\t//! Member iterators.\r\n\tConstMemberIterator MemberBegin() const\t{ RAPIDJSON_ASSERT(IsObject()); return data_.o.members; }\r\n\tConstMemberIterator MemberEnd()\tconst\t{ RAPIDJSON_ASSERT(IsObject()); return data_.o.members + data_.o.size; }\r\n\tMemberIterator MemberBegin()\t\t\t{ RAPIDJSON_ASSERT(IsObject()); return data_.o.members; }\r\n\tMemberIterator MemberEnd()\t\t\t\t{ RAPIDJSON_ASSERT(IsObject()); return data_.o.members + data_.o.size; }\r\n\r\n\t//! Check whether a member exists in the object.\r\n\tbool HasMember(const Ch* name) const { return FindMember(name) != 0; }\r\n\r\n\t//! Add a member (name-value pair) to the object.\r\n\t/*! \\param name A string value as name of member.\r\n\t\t\\param value Value of any type.\r\n\t    \\param allocator Allocator for reallocating memory.\r\n\t    \\return The value itself for fluent API.\r\n\t    \\note The ownership of name and value will be transfered to this object if success.\r\n\t*/\r\n\tGenericValue& AddMember(GenericValue& name, GenericValue& value, Allocator& allocator) {\r\n\t\tRAPIDJSON_ASSERT(IsObject());\r\n\t\tRAPIDJSON_ASSERT(name.IsString());\r\n\t\tObject& o = data_.o;\r\n\t\tif (o.size >= o.capacity) {\r\n\t\t\tif (o.capacity == 0) {\r\n\t\t\t\to.capacity = kDefaultObjectCapacity;\r\n\t\t\t\to.members = (Member*)allocator.Malloc(o.capacity * sizeof(Member));\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tSizeType oldCapacity = o.capacity;\r\n\t\t\t\to.capacity *= 2;\r\n\t\t\t\to.members = (Member*)allocator.Realloc(o.members, oldCapacity * sizeof(Member), o.capacity * sizeof(Member));\r\n\t\t\t}\r\n\t\t}\r\n\t\to.members[o.size].name.RawAssign(name);\r\n\t\to.members[o.size].value.RawAssign(value);\r\n\t\to.size++;\r\n\t\treturn *this;\r\n\t}\r\n\r\n\tGenericValue& AddMember(const Ch* name, Allocator& nameAllocator, GenericValue& value, Allocator& allocator) {\r\n\t\tGenericValue n(name, internal::StrLen(name), nameAllocator);\r\n\t\treturn AddMember(n, value, allocator);\r\n\t}\r\n\r\n\tGenericValue& AddMember(const Ch* name, GenericValue& value, Allocator& allocator) {\r\n\t\tGenericValue n(name, internal::StrLen(name));\r\n\t\treturn AddMember(n, value, allocator);\r\n\t}\r\n\r\n\ttemplate <typename T>\r\n\tGenericValue& AddMember(const Ch* name, T value, Allocator& allocator) {\r\n\t\tGenericValue n(name, internal::StrLen(name));\r\n\t\tGenericValue v(value);\r\n\t\treturn AddMember(n, v, allocator);\r\n\t}\r\n\r\n\t//! Remove a member in object by its name.\r\n\t/*! \\param name Name of member to be removed.\r\n\t    \\return Whether the member existed.\r\n\t    \\note Removing member is implemented by moving the last member. So the ordering of members is changed.\r\n\t*/\r\n\tbool RemoveMember(const Ch* name) {\r\n\t\tRAPIDJSON_ASSERT(IsObject());\r\n\t\tif (Member* m = FindMember(name)) {\r\n\t\t\tRAPIDJSON_ASSERT(data_.o.size > 0);\r\n\t\t\tRAPIDJSON_ASSERT(data_.o.members != 0);\r\n\r\n\t\t\tMember* last = data_.o.members + (data_.o.size - 1);\r\n\t\t\tif (data_.o.size > 1 && m != last) {\r\n\t\t\t\t// Move the last one to this place\r\n\t\t\t\tm->name = last->name;\r\n\t\t\t\tm->value = last->value;\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\t// Only one left, just destroy\r\n\t\t\t\tm->name.~GenericValue();\r\n\t\t\t\tm->value.~GenericValue();\r\n\t\t\t}\r\n\t\t\t--data_.o.size;\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\treturn false;\r\n\t}\r\n\r\n\t//@}\r\n\r\n\t//!@name Array\r\n\t//@{\r\n\r\n\t//! Set this value as an empty array.\r\n\tGenericValue& SetArray() {\tthis->~GenericValue(); new (this) GenericValue(kArrayType); return *this; }\r\n\r\n\t//! Get the number of elements in array.\r\n\tSizeType Size() const { RAPIDJSON_ASSERT(IsArray()); return data_.a.size; }\r\n\r\n\t//! Get the capacity of array.\r\n\tSizeType Capacity() const { RAPIDJSON_ASSERT(IsArray()); return data_.a.capacity; }\r\n\r\n\t//! Check whether the array is empty.\r\n\tbool Empty() const { RAPIDJSON_ASSERT(IsArray()); return data_.a.size == 0; }\r\n\r\n\t//! Remove all elements in the array.\r\n\t/*! This function do not deallocate memory in the array, i.e. the capacity is unchanged.\r\n\t*/\r\n\tvoid Clear() {\r\n\t\tRAPIDJSON_ASSERT(IsArray()); \r\n\t\tfor (SizeType i = 0; i < data_.a.size; ++i)\r\n\t\t\tdata_.a.elements[i].~GenericValue();\r\n\t\tdata_.a.size = 0;\r\n\t}\r\n\r\n\t//! Get an element from array by index.\r\n\t/*! \\param index Zero-based index of element.\r\n\t\t\\note\r\n\\code\r\nValue a(kArrayType);\r\na.PushBack(123);\r\nint x = a[0].GetInt();\t\t\t\t// Error: operator[ is ambiguous, as 0 also mean a null pointer of const char* type.\r\nint y = a[SizeType(0)].GetInt();\t// Cast to SizeType will work.\r\nint z = a[0u].GetInt();\t\t\t\t// This works too.\r\n\\endcode\r\n\t*/\r\n\tGenericValue& operator[](SizeType index) {\r\n\t\tRAPIDJSON_ASSERT(IsArray());\r\n\t\tRAPIDJSON_ASSERT(index < data_.a.size);\r\n\t\treturn data_.a.elements[index];\r\n\t}\r\n\tconst GenericValue& operator[](SizeType index) const { return const_cast<GenericValue&>(*this)[index]; }\r\n\r\n\t//! Element iterator\r\n\tValueIterator Begin() { RAPIDJSON_ASSERT(IsArray()); return data_.a.elements; }\r\n\tValueIterator End() { RAPIDJSON_ASSERT(IsArray()); return data_.a.elements + data_.a.size; }\r\n\tConstValueIterator Begin() const { return const_cast<GenericValue&>(*this).Begin(); }\r\n\tConstValueIterator End() const { return const_cast<GenericValue&>(*this).End(); }\r\n\r\n\t//! Request the array to have enough capacity to store elements.\r\n\t/*! \\param newCapacity\tThe capacity that the array at least need to have.\r\n\t\t\\param allocator\tThe allocator for allocating memory. It must be the same one use previously.\r\n\t\t\\return The value itself for fluent API.\r\n\t*/\r\n\tGenericValue& Reserve(SizeType newCapacity, Allocator &allocator) {\r\n\t\tRAPIDJSON_ASSERT(IsArray());\r\n\t\tif (newCapacity > data_.a.capacity) {\r\n\t\t\tdata_.a.elements = (GenericValue*)allocator.Realloc(data_.a.elements, data_.a.capacity * sizeof(GenericValue), newCapacity * sizeof(GenericValue));\r\n\t\t\tdata_.a.capacity = newCapacity;\r\n\t\t}\r\n\t\treturn *this;\r\n\t}\r\n\r\n\t//! Append a value at the end of the array.\r\n\t/*! \\param value\t\tThe value to be appended.\r\n\t    \\param allocator\tThe allocator for allocating memory. It must be the same one use previously.\r\n\t    \\return The value itself for fluent API.\r\n\t    \\note The ownership of the value will be transfered to this object if success.\r\n\t    \\note If the number of elements to be appended is known, calls Reserve() once first may be more efficient.\r\n\t*/\r\n\tGenericValue& PushBack(GenericValue& value, Allocator& allocator) {\r\n\t\tRAPIDJSON_ASSERT(IsArray());\r\n\t\tif (data_.a.size >= data_.a.capacity)\r\n\t\t\tReserve(data_.a.capacity == 0 ? kDefaultArrayCapacity : data_.a.capacity * 2, allocator);\r\n\t\tdata_.a.elements[data_.a.size++].RawAssign(value);\r\n\t\treturn *this;\r\n\t}\r\n\r\n\ttemplate <typename T>\r\n\tGenericValue& PushBack(T value, Allocator& allocator) {\r\n\t\tGenericValue v(value);\r\n\t\treturn PushBack(v, allocator);\r\n\t}\r\n\r\n\t//! Remove the last element in the array.\r\n\tGenericValue& PopBack() {\r\n\t\tRAPIDJSON_ASSERT(IsArray());\r\n\t\tRAPIDJSON_ASSERT(!Empty());\r\n\t\tdata_.a.elements[--data_.a.size].~GenericValue();\r\n\t\treturn *this;\r\n\t}\r\n\t//@}\r\n\r\n\t//!@name Number\r\n\t//@{\r\n\r\n\tint GetInt() const\t\t\t{ RAPIDJSON_ASSERT(flags_ & kIntFlag);   return data_.n.i.i;   }\r\n\tunsigned GetUint() const\t{ RAPIDJSON_ASSERT(flags_ & kUintFlag);  return data_.n.u.u;   }\r\n\tint64_t GetInt64() const\t{ RAPIDJSON_ASSERT(flags_ & kInt64Flag); return data_.n.i64; }\r\n\tuint64_t GetUint64() const\t{ RAPIDJSON_ASSERT(flags_ & kUint64Flag); return data_.n.u64; }\r\n\r\n\tdouble GetDouble() const {\r\n\t\tRAPIDJSON_ASSERT(IsNumber());\r\n\t\tif ((flags_ & kDoubleFlag) != 0)\t\t\t\treturn data_.n.d;\t// exact type, no conversion.\r\n\t\tif ((flags_ & kIntFlag) != 0)\t\t\t\t\treturn data_.n.i.i;\t// int -> double\r\n\t\tif ((flags_ & kUintFlag) != 0)\t\t\t\t\treturn data_.n.u.u;\t// unsigned -> double\r\n\t\tif ((flags_ & kInt64Flag) != 0)\t\t\t\t\treturn (double)data_.n.i64; // int64_t -> double (may lose precision)\r\n\t\tRAPIDJSON_ASSERT((flags_ & kUint64Flag) != 0);\treturn (double)data_.n.u64;\t// uint64_t -> double (may lose precision)\r\n\t}\r\n\r\n\tGenericValue& SetInt(int i)\t\t\t\t{ this->~GenericValue(); new (this) GenericValue(i);\treturn *this; }\r\n\tGenericValue& SetUint(unsigned u)\t\t{ this->~GenericValue(); new (this) GenericValue(u);\treturn *this; }\r\n\tGenericValue& SetInt64(int64_t i64)\t\t{ this->~GenericValue(); new (this) GenericValue(i64);\treturn *this; }\r\n\tGenericValue& SetUint64(uint64_t u64)\t{ this->~GenericValue(); new (this) GenericValue(u64);\treturn *this; }\r\n\tGenericValue& SetDouble(double d)\t\t{ this->~GenericValue(); new (this) GenericValue(d);\treturn *this; }\r\n\r\n\t//@}\r\n\r\n\t//!@name String\r\n\t//@{\r\n\r\n\tconst Ch* GetString() const { RAPIDJSON_ASSERT(IsString()); return data_.s.str; }\r\n\r\n\t//! Get the length of string.\r\n\t/*! Since rapidjson permits \"\\u0000\" in the json string, strlen(v.GetString()) may not equal to v.GetStringLength().\r\n\t*/\r\n\tSizeType GetStringLength() const { RAPIDJSON_ASSERT(IsString()); return data_.s.length; }\r\n\r\n\t//! Set this value as a string without copying source string.\r\n\t/*! This version has better performance with supplied length, and also support string containing null character.\r\n\t\t\\param s source string pointer. \r\n\t\t\\param length The length of source string, excluding the trailing null terminator.\r\n\t\t\\return The value itself for fluent API.\r\n\t*/\r\n\tGenericValue& SetString(const Ch* s, SizeType length) { this->~GenericValue(); SetStringRaw(s, length); return *this; }\r\n\r\n\t//! Set this value as a string without copying source string.\r\n\t/*! \\param s source string pointer. \r\n\t\t\\return The value itself for fluent API.\r\n\t*/\r\n\tGenericValue& SetString(const Ch* s) { return SetString(s, internal::StrLen(s)); }\r\n\r\n\t//! Set this value as a string by copying from source string.\r\n\t/*! This version has better performance with supplied length, and also support string containing null character.\r\n\t\t\\param s source string. \r\n\t\t\\param length The length of source string, excluding the trailing null terminator.\r\n\t\t\\param allocator Allocator for allocating copied buffer. Commonly use document.GetAllocator().\r\n\t\t\\return The value itself for fluent API.\r\n\t*/\r\n\tGenericValue& SetString(const Ch* s, SizeType length, Allocator& allocator) { this->~GenericValue(); SetStringRaw(s, length, allocator); return *this; }\r\n\r\n\t//! Set this value as a string by copying from source string.\r\n\t/*!\t\\param s source string. \r\n\t\t\\param allocator Allocator for allocating copied buffer. Commonly use document.GetAllocator().\r\n\t\t\\return The value itself for fluent API.\r\n\t*/\r\n\tGenericValue& SetString(const Ch* s, Allocator& allocator) {\tSetString(s, internal::StrLen(s), allocator); return *this; }\r\n\r\n\t//@}\r\n\r\n\t//! Generate events of this value to a Handler.\r\n\t/*! This function adopts the GoF visitor pattern.\r\n\t\tTypical usage is to output this JSON value as JSON text via Writer, which is a Handler.\r\n\t\tIt can also be used to deep clone this value via GenericDocument, which is also a Handler.\r\n\t\t\\tparam Handler type of handler.\r\n\t\t\\param handler An object implementing concept Handler.\r\n\t*/\r\n\ttemplate <typename Handler>\r\n\tconst GenericValue& Accept(Handler& handler) const {\r\n\t\tswitch(GetType()) {\r\n\t\tcase kNullType:\t\thandler.Null(); break;\r\n\t\tcase kFalseType:\thandler.Bool(false); break;\r\n\t\tcase kTrueType:\t\thandler.Bool(true); break;\r\n\r\n\t\tcase kObjectType:\r\n\t\t\thandler.StartObject();\r\n\t\t\tfor (Member* m = data_.o.members; m != data_.o.members + data_.o.size; ++m) {\r\n\t\t\t\thandler.String(m->name.data_.s.str, m->name.data_.s.length, false);\r\n\t\t\t\tm->value.Accept(handler);\r\n\t\t\t}\r\n\t\t\thandler.EndObject(data_.o.size);\r\n\t\t\tbreak;\r\n\r\n\t\tcase kArrayType:\r\n\t\t\thandler.StartArray();\r\n\t\t\tfor (GenericValue* v = data_.a.elements; v != data_.a.elements + data_.a.size; ++v)\r\n\t\t\t\tv->Accept(handler);\r\n\t\t\thandler.EndArray(data_.a.size);\r\n\t\t\tbreak;\r\n\r\n\t\tcase kStringType:\r\n\t\t\thandler.String(data_.s.str, data_.s.length, false);\r\n\t\t\tbreak;\r\n\r\n\t\tcase kNumberType:\r\n\t\t\tif (IsInt())\t\t\thandler.Int(data_.n.i.i);\r\n\t\t\telse if (IsUint())\t\thandler.Uint(data_.n.u.u);\r\n\t\t\telse if (IsInt64())\t\thandler.Int64(data_.n.i64);\r\n\t\t\telse if (IsUint64())\thandler.Uint64(data_.n.u64);\r\n\t\t\telse\t\t\t\t\thandler.Double(data_.n.d);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\treturn *this;\r\n\t}\r\n\r\nprivate:\r\n\ttemplate <typename, typename>\r\n\tfriend class GenericDocument;\r\n\r\n\tenum {\r\n\t\tkBoolFlag = 0x100,\r\n\t\tkNumberFlag = 0x200,\r\n\t\tkIntFlag = 0x400,\r\n\t\tkUintFlag = 0x800,\r\n\t\tkInt64Flag = 0x1000,\r\n\t\tkUint64Flag = 0x2000,\r\n\t\tkDoubleFlag = 0x4000,\r\n\t\tkStringFlag = 0x100000,\r\n\t\tkCopyFlag = 0x200000,\r\n\r\n\t\t// Initial flags of different types.\r\n\t\tkNullFlag = kNullType,\r\n\t\tkTrueFlag = kTrueType | kBoolFlag,\r\n\t\tkFalseFlag = kFalseType | kBoolFlag,\r\n\t\tkNumberIntFlag = kNumberType | kNumberFlag | kIntFlag | kInt64Flag,\r\n\t\tkNumberUintFlag = kNumberType | kNumberFlag | kUintFlag | kUint64Flag | kInt64Flag,\r\n\t\tkNumberInt64Flag = kNumberType | kNumberFlag | kInt64Flag,\r\n\t\tkNumberUint64Flag = kNumberType | kNumberFlag | kUint64Flag,\r\n\t\tkNumberDoubleFlag = kNumberType | kNumberFlag | kDoubleFlag,\r\n\t\tkConstStringFlag = kStringType | kStringFlag,\r\n\t\tkCopyStringFlag = kStringType | kStringFlag | kCopyFlag,\r\n\t\tkObjectFlag = kObjectType,\r\n\t\tkArrayFlag = kArrayType,\r\n\r\n\t\tkTypeMask = 0xFF\t// bitwise-and with mask of 0xFF can be optimized by compiler\r\n\t};\r\n\r\n\tstatic const SizeType kDefaultArrayCapacity = 16;\r\n\tstatic const SizeType kDefaultObjectCapacity = 16;\r\n\r\n\tstruct String {\r\n\t\tconst Ch* str;\r\n\t\tSizeType length;\r\n\t\tunsigned hashcode;\t//!< reserved\r\n\t};\t// 12 bytes in 32-bit mode, 16 bytes in 64-bit mode\r\n\r\n\t// By using proper binary layout, retrieval of different integer types do not need conversions.\r\n\tunion Number {\r\n#if RAPIDJSON_ENDIAN == RAPIDJSON_LITTLEENDIAN\r\n\t\tstruct I {\r\n\t\t\tint i;\r\n\t\t\tchar padding[4];\r\n\t\t}i;\r\n\t\tstruct U {\r\n\t\t\tunsigned u;\r\n\t\t\tchar padding2[4];\r\n\t\t}u;\r\n#else\r\n\t\tstruct I {\r\n\t\t\tchar padding[4];\r\n\t\t\tint i;\r\n\t\t}i;\r\n\t\tstruct U {\r\n\t\t\tchar padding2[4];\r\n\t\t\tunsigned u;\r\n\t\t}u;\r\n#endif\r\n\t\tint64_t i64;\r\n\t\tuint64_t u64;\r\n\t\tdouble d;\r\n\t};\t// 8 bytes\r\n\r\n\tstruct Object {\r\n\t\tMember* members;\r\n\t\tSizeType size;\r\n\t\tSizeType capacity;\r\n\t};\t// 12 bytes in 32-bit mode, 16 bytes in 64-bit mode\r\n\r\n\tstruct Array {\r\n\t\tGenericValue<Encoding, Allocator>* elements;\r\n\t\tSizeType size;\r\n\t\tSizeType capacity;\r\n\t};\t// 12 bytes in 32-bit mode, 16 bytes in 64-bit mode\r\n\r\n\tunion Data {\r\n\t\tString s;\r\n\t\tNumber n;\r\n\t\tObject o;\r\n\t\tArray a;\r\n\t};\t// 12 bytes in 32-bit mode, 16 bytes in 64-bit mode\r\n\r\n\t//! Find member by name.\r\n\tMember* FindMember(const Ch* name) {\r\n\t\tRAPIDJSON_ASSERT(name);\r\n\t\tRAPIDJSON_ASSERT(IsObject());\r\n\r\n\t\tSizeType length = internal::StrLen(name);\r\n\r\n\t\tObject& o = data_.o;\r\n\t\tfor (Member* member = o.members; member != data_.o.members + data_.o.size; ++member)\r\n\t\t\tif (length == member->name.data_.s.length && memcmp(member->name.data_.s.str, name, length * sizeof(Ch)) == 0)\r\n\t\t\t\treturn member;\r\n\r\n\t\treturn 0;\r\n\t}\r\n\tconst Member* FindMember(const Ch* name) const { return const_cast<GenericValue&>(*this).FindMember(name); }\r\n\r\n\t// Initialize this value as array with initial data, without calling destructor.\r\n\tvoid SetArrayRaw(GenericValue* values, SizeType count, Allocator& alloctaor) {\r\n\t\tflags_ = kArrayFlag;\r\n\t\tdata_.a.elements = (GenericValue*)alloctaor.Malloc(count * sizeof(GenericValue));\r\n\t\tmemcpy(data_.a.elements, values, count * sizeof(GenericValue));\r\n\t\tdata_.a.size = data_.a.capacity = count;\r\n\t}\r\n\r\n\t//! Initialize this value as object with initial data, without calling destructor.\r\n\tvoid SetObjectRaw(Member* members, SizeType count, Allocator& alloctaor) {\r\n\t\tflags_ = kObjectFlag;\r\n\t\tdata_.o.members = (Member*)alloctaor.Malloc(count * sizeof(Member));\r\n\t\tmemcpy(data_.o.members, members, count * sizeof(Member));\r\n\t\tdata_.o.size = data_.o.capacity = count;\r\n\t}\r\n\r\n\t//! Initialize this value as constant string, without calling destructor.\r\n\tvoid SetStringRaw(const Ch* s, SizeType length) {\r\n\t\tRAPIDJSON_ASSERT(s != NULL);\r\n\t\tflags_ = kConstStringFlag;\r\n\t\tdata_.s.str = s;\r\n\t\tdata_.s.length = length;\r\n\t}\r\n\r\n\t//! Initialize this value as copy string with initial data, without calling destructor.\r\n\tvoid SetStringRaw(const Ch* s, SizeType length, Allocator& allocator) {\r\n\t\tRAPIDJSON_ASSERT(s != NULL);\r\n\t\tflags_ = kCopyStringFlag;\r\n\t\tdata_.s.str = (Ch *)allocator.Malloc((length + 1) * sizeof(Ch));\r\n\t\tdata_.s.length = length;\r\n\t\tmemcpy(const_cast<Ch*>(data_.s.str), s, length * sizeof(Ch));\r\n\t\tconst_cast<Ch*>(data_.s.str)[length] = '\\0';\r\n\t}\r\n\r\n\t//! Assignment without calling destructor\r\n\tvoid RawAssign(GenericValue& rhs) {\r\n\t\tmemcpy(this, &rhs, sizeof(GenericValue));\r\n\t\trhs.flags_ = kNullFlag;\r\n\t}\r\n\r\n\tData data_;\r\n\tunsigned flags_;\r\n};\r\n#pragma pack (pop)\r\n\r\n//! Value with UTF8 encoding.\r\ntypedef GenericValue<UTF8<> > Value;\r\n\r\n///////////////////////////////////////////////////////////////////////////////\r\n// GenericDocument \r\n\r\n//! A document for parsing JSON text as DOM.\r\n/*!\r\n\t\\implements Handler\r\n\t\\tparam Encoding encoding for both parsing and string storage.\r\n\t\\tparam Alloactor allocator for allocating memory for the DOM, and the stack during parsing.\r\n*/\r\ntemplate <typename Encoding, typename Allocator = MemoryPoolAllocator<> >\r\nclass GenericDocument : public GenericValue<Encoding, Allocator> {\r\npublic:\r\n\ttypedef typename Encoding::Ch Ch;\t\t\t\t\t\t//!< Character type derived from Encoding.\r\n\ttypedef GenericValue<Encoding, Allocator> ValueType;\t//!< Value type of the document.\r\n\ttypedef Allocator AllocatorType;\t\t\t\t\t\t//!< Allocator type from template parameter.\r\n\r\n\t//! Constructor\r\n\t/*! \\param allocator\t\tOptional allocator for allocating stack memory.\r\n\t\t\\param stackCapacity\tInitial capacity of stack in bytes.\r\n\t*/\r\n\tGenericDocument(Allocator* allocator = 0, size_t stackCapacity = kDefaultStackCapacity) : stack_(allocator, stackCapacity), parseError_(0), errorOffset_(0) {}\r\n\r\n\t//! Parse JSON text from an input stream.\r\n\t/*! \\tparam parseFlags Combination of ParseFlag.\r\n\t\t\\param stream Input stream to be parsed.\r\n\t\t\\return The document itself for fluent API.\r\n\t*/\r\n\ttemplate <unsigned parseFlags, typename Stream>\r\n\tGenericDocument& ParseStream(Stream& stream) {\r\n\t\tValueType::SetNull(); // Remove existing root if exist\r\n\t\tGenericReader<Encoding, Allocator> reader;\r\n\t\tif (reader.template Parse<parseFlags>(stream, *this)) {\r\n\t\t\tRAPIDJSON_ASSERT(stack_.GetSize() == sizeof(ValueType)); // Got one and only one root object\r\n\t\t\tthis->RawAssign(*stack_.template Pop<ValueType>(1));\t// Add this-> to prevent issue 13.\r\n\t\t\tparseError_ = 0;\r\n\t\t\terrorOffset_ = 0;\r\n\t\t}\r\n\t\telse {\r\n\t\t\tparseError_ = reader.GetParseError();\r\n\t\t\terrorOffset_ = reader.GetErrorOffset();\r\n\t\t\tClearStack();\r\n\t\t}\r\n\t\treturn *this;\r\n\t}\r\n\r\n\t//! Parse JSON text from a mutable string.\r\n\t/*! \\tparam parseFlags Combination of ParseFlag.\r\n\t\t\\param str Mutable zero-terminated string to be parsed.\r\n\t\t\\return The document itself for fluent API.\r\n\t*/\r\n\ttemplate <unsigned parseFlags>\r\n\tGenericDocument& ParseInsitu(Ch* str) {\r\n\t\tGenericInsituStringStream<Encoding> s(str);\r\n\t\treturn ParseStream<parseFlags | kParseInsituFlag>(s);\r\n\t}\r\n\r\n\t//! Parse JSON text from a read-only string.\r\n\t/*! \\tparam parseFlags Combination of ParseFlag (must not contain kParseInsituFlag).\r\n\t\t\\param str Read-only zero-terminated string to be parsed.\r\n\t*/\r\n\ttemplate <unsigned parseFlags>\r\n\tGenericDocument& Parse(const Ch* str) {\r\n\t\tRAPIDJSON_ASSERT(!(parseFlags & kParseInsituFlag));\r\n\t\tGenericStringStream<Encoding> s(str);\r\n\t\treturn ParseStream<parseFlags>(s);\r\n\t}\r\n\r\n\t//! Whether a parse error was occured in the last parsing.\r\n\tbool HasParseError() const { return parseError_ != 0; }\r\n\r\n\t//! Get the message of parsing error.\r\n\tconst char* GetParseError() const { return parseError_; }\r\n\r\n\t//! Get the offset in character of the parsing error.\r\n\tsize_t GetErrorOffset() const { return errorOffset_; }\r\n\r\n\t//! Get the allocator of this document.\r\n\tAllocator& GetAllocator() {\treturn stack_.GetAllocator(); }\r\n\r\n\t//! Get the capacity of stack in bytes.\r\n\tsize_t GetStackCapacity() const { return stack_.GetCapacity(); }\r\n\r\nprivate:\r\n\t// Prohibit assignment\r\n\tGenericDocument& operator=(const GenericDocument&);\r\n\r\n\tfriend class GenericReader<Encoding, Allocator>;\t// for Reader to call the following private handler functions\r\n\r\n\t// Implementation of Handler\r\n\tvoid Null()\t{ new (stack_.template Push<ValueType>()) ValueType(); }\r\n\tvoid Bool(bool b) { new (stack_.template Push<ValueType>()) ValueType(b); }\r\n\tvoid Int(int i) { new (stack_.template Push<ValueType>()) ValueType(i); }\r\n\tvoid Uint(unsigned i) { new (stack_.template Push<ValueType>()) ValueType(i); }\r\n\tvoid Int64(int64_t i) { new (stack_.template Push<ValueType>()) ValueType(i); }\r\n\tvoid Uint64(uint64_t i) { new (stack_.template Push<ValueType>()) ValueType(i); }\r\n\tvoid Double(double d) { new (stack_.template Push<ValueType>()) ValueType(d); }\r\n\r\n\tvoid String(const Ch* str, SizeType length, bool copy) { \r\n\t\tif (copy) \r\n\t\t\tnew (stack_.template Push<ValueType>()) ValueType(str, length, GetAllocator());\r\n\t\telse\r\n\t\t\tnew (stack_.template Push<ValueType>()) ValueType(str, length);\r\n\t}\r\n\r\n\tvoid StartObject() { new (stack_.template Push<ValueType>()) ValueType(kObjectType); }\r\n\t\r\n\tvoid EndObject(SizeType memberCount) {\r\n\t\ttypename ValueType::Member* members = stack_.template Pop<typename ValueType::Member>(memberCount);\r\n\t\tstack_.template Top<ValueType>()->SetObjectRaw(members, (SizeType)memberCount, GetAllocator());\r\n\t}\r\n\r\n\tvoid StartArray() { new (stack_.template Push<ValueType>()) ValueType(kArrayType); }\r\n\t\r\n\tvoid EndArray(SizeType elementCount) {\r\n\t\tValueType* elements = stack_.template Pop<ValueType>(elementCount);\r\n\t\tstack_.template Top<ValueType>()->SetArrayRaw(elements, elementCount, GetAllocator());\r\n\t}\r\n\r\n\tvoid ClearStack() {\r\n\t\tif (Allocator::kNeedFree)\r\n\t\t\twhile (stack_.GetSize() > 0)\t// Here assumes all elements in stack array are GenericValue (Member is actually 2 GenericValue objects)\r\n\t\t\t\t(stack_.template Pop<ValueType>(1))->~ValueType();\r\n\t\telse\r\n\t\t\tstack_.Clear();\r\n\t}\r\n\r\n\tstatic const size_t kDefaultStackCapacity = 1024;\r\n\tinternal::Stack<Allocator> stack_;\r\n\tconst char* parseError_;\r\n\tsize_t errorOffset_;\r\n};\r\n\r\ntypedef GenericDocument<UTF8<> > Document;\r\n\r\n} // namespace rapidjson\r\n\r\n#ifdef _MSC_VER\r\n#pragma warning(pop)\r\n#endif\r\n\r\n#endif // RAPIDJSON_DOCUMENT_H_\r\n"
  },
  {
    "path": "src/include/rapidjson/filestream.h",
    "content": "/******************************************\r\n * RapidJson\r\n * Copyright (C) 2011 Milo Yip\r\n * see COPYING in the top-level directory\r\n * for more information.\r\n *****************************************/\r\n\r\n\r\n#ifndef RAPIDJSON_FILESTREAM_H_\r\n#define RAPIDJSON_FILESTREAM_H_\r\n\r\n#include <cstdio>\r\n\r\nnamespace rapidjson {\r\n\r\n//! Wrapper of C file stream for input or output.\r\n/*!\r\n\tThis simple wrapper does not check the validity of the stream.\r\n\t\\implements Stream\r\n*/\r\nclass FileStream {\r\npublic:\r\n\ttypedef char Ch;\t//!< Character type. Only support char.\r\n\r\n\tFileStream(FILE* fp) : fp_(fp), count_(0) { Read(); }\r\n\tchar Peek() const { return current_; }\r\n\tchar Take() { char c = current_; Read(); return c; }\r\n\tsize_t Tell() const { return count_; }\r\n\tvoid Put(char c) { fputc(c, fp_); }\r\n\r\n\t// Not implemented\r\n\tchar* PutBegin() { return 0; }\r\n\tsize_t PutEnd(char*) { return 0; }\r\n\r\nprivate:\r\n\tvoid Read() {\r\n\t\tRAPIDJSON_ASSERT(fp_ != 0);\r\n\t\tint c = fgetc(fp_);\r\n\t\tif (c != EOF) {\r\n\t\t\tcurrent_ = (char)c;\r\n\t\t\tcount_++;\r\n\t\t}\r\n\t\telse\r\n\t\t\tcurrent_ = '\\0';\r\n\t}\r\n\r\n\tFILE* fp_;\r\n\tchar current_;\r\n\tsize_t count_;\r\n};\r\n\r\n} // namespace rapidjson\r\n\r\n#endif // RAPIDJSON_FILESTREAM_H_\r\n"
  },
  {
    "path": "src/include/rapidjson/internal/pow10.h",
    "content": "/******************************************\r\n * RapidJson\r\n * Copyright (C) 2011 Milo Yip\r\n * see COPYING in the top-level directory\r\n * for more information.\r\n *****************************************/\r\n\r\n\r\n#ifndef RAPIDJSON_POW10_\r\n#define RAPIDJSON_POW10_\r\n\r\nnamespace rapidjson {\r\nnamespace internal {\r\n\r\n//! Computes integer powers of 10 in double (10.0^n).\r\n/*! This function uses lookup table for fast and accurate results.\r\n\t\\param n positive/negative exponent. Must <= 308.\r\n\t\\return 10.0^n\r\n*/\r\ninline double Pow10(int n) {\r\n\tstatic const double e[] = { // 1e-308...1e308: 617 * 8 bytes = 4936 bytes\r\n\t\t1e-308,1e-307,1e-306,1e-305,1e-304,1e-303,1e-302,1e-301,1e-300,\r\n\t\t1e-299,1e-298,1e-297,1e-296,1e-295,1e-294,1e-293,1e-292,1e-291,1e-290,1e-289,1e-288,1e-287,1e-286,1e-285,1e-284,1e-283,1e-282,1e-281,1e-280,\r\n\t\t1e-279,1e-278,1e-277,1e-276,1e-275,1e-274,1e-273,1e-272,1e-271,1e-270,1e-269,1e-268,1e-267,1e-266,1e-265,1e-264,1e-263,1e-262,1e-261,1e-260,\r\n\t\t1e-259,1e-258,1e-257,1e-256,1e-255,1e-254,1e-253,1e-252,1e-251,1e-250,1e-249,1e-248,1e-247,1e-246,1e-245,1e-244,1e-243,1e-242,1e-241,1e-240,\r\n\t\t1e-239,1e-238,1e-237,1e-236,1e-235,1e-234,1e-233,1e-232,1e-231,1e-230,1e-229,1e-228,1e-227,1e-226,1e-225,1e-224,1e-223,1e-222,1e-221,1e-220,\r\n\t\t1e-219,1e-218,1e-217,1e-216,1e-215,1e-214,1e-213,1e-212,1e-211,1e-210,1e-209,1e-208,1e-207,1e-206,1e-205,1e-204,1e-203,1e-202,1e-201,1e-200,\r\n\t\t1e-199,1e-198,1e-197,1e-196,1e-195,1e-194,1e-193,1e-192,1e-191,1e-190,1e-189,1e-188,1e-187,1e-186,1e-185,1e-184,1e-183,1e-182,1e-181,1e-180,\r\n\t\t1e-179,1e-178,1e-177,1e-176,1e-175,1e-174,1e-173,1e-172,1e-171,1e-170,1e-169,1e-168,1e-167,1e-166,1e-165,1e-164,1e-163,1e-162,1e-161,1e-160,\r\n\t\t1e-159,1e-158,1e-157,1e-156,1e-155,1e-154,1e-153,1e-152,1e-151,1e-150,1e-149,1e-148,1e-147,1e-146,1e-145,1e-144,1e-143,1e-142,1e-141,1e-140,\r\n\t\t1e-139,1e-138,1e-137,1e-136,1e-135,1e-134,1e-133,1e-132,1e-131,1e-130,1e-129,1e-128,1e-127,1e-126,1e-125,1e-124,1e-123,1e-122,1e-121,1e-120,\r\n\t\t1e-119,1e-118,1e-117,1e-116,1e-115,1e-114,1e-113,1e-112,1e-111,1e-110,1e-109,1e-108,1e-107,1e-106,1e-105,1e-104,1e-103,1e-102,1e-101,1e-100,\r\n\t\t1e-99, 1e-98, 1e-97, 1e-96, 1e-95, 1e-94, 1e-93, 1e-92, 1e-91, 1e-90, 1e-89, 1e-88, 1e-87, 1e-86, 1e-85, 1e-84, 1e-83, 1e-82, 1e-81, 1e-80, \r\n\t\t1e-79, 1e-78, 1e-77, 1e-76, 1e-75, 1e-74, 1e-73, 1e-72, 1e-71, 1e-70, 1e-69, 1e-68, 1e-67, 1e-66, 1e-65, 1e-64, 1e-63, 1e-62, 1e-61, 1e-60, \r\n\t\t1e-59, 1e-58, 1e-57, 1e-56, 1e-55, 1e-54, 1e-53, 1e-52, 1e-51, 1e-50, 1e-49, 1e-48, 1e-47, 1e-46, 1e-45, 1e-44, 1e-43, 1e-42, 1e-41, 1e-40, \r\n\t\t1e-39, 1e-38, 1e-37, 1e-36, 1e-35, 1e-34, 1e-33, 1e-32, 1e-31, 1e-30, 1e-29, 1e-28, 1e-27, 1e-26, 1e-25, 1e-24, 1e-23, 1e-22, 1e-21, 1e-20, \r\n\t\t1e-19, 1e-18, 1e-17, 1e-16, 1e-15, 1e-14, 1e-13, 1e-12, 1e-11, 1e-10, 1e-9,  1e-8,  1e-7,  1e-6,  1e-5,  1e-4,  1e-3,  1e-2,  1e-1,  1e+0,  \r\n\t\t1e+1,  1e+2,  1e+3,  1e+4,  1e+5,  1e+6,  1e+7,  1e+8,  1e+9,  1e+10, 1e+11, 1e+12, 1e+13, 1e+14, 1e+15, 1e+16, 1e+17, 1e+18, 1e+19, 1e+20, \r\n\t\t1e+21, 1e+22, 1e+23, 1e+24, 1e+25, 1e+26, 1e+27, 1e+28, 1e+29, 1e+30, 1e+31, 1e+32, 1e+33, 1e+34, 1e+35, 1e+36, 1e+37, 1e+38, 1e+39, 1e+40,\r\n\t\t1e+41, 1e+42, 1e+43, 1e+44, 1e+45, 1e+46, 1e+47, 1e+48, 1e+49, 1e+50, 1e+51, 1e+52, 1e+53, 1e+54, 1e+55, 1e+56, 1e+57, 1e+58, 1e+59, 1e+60,\r\n\t\t1e+61, 1e+62, 1e+63, 1e+64, 1e+65, 1e+66, 1e+67, 1e+68, 1e+69, 1e+70, 1e+71, 1e+72, 1e+73, 1e+74, 1e+75, 1e+76, 1e+77, 1e+78, 1e+79, 1e+80,\r\n\t\t1e+81, 1e+82, 1e+83, 1e+84, 1e+85, 1e+86, 1e+87, 1e+88, 1e+89, 1e+90, 1e+91, 1e+92, 1e+93, 1e+94, 1e+95, 1e+96, 1e+97, 1e+98, 1e+99, 1e+100,\r\n\t\t1e+101,1e+102,1e+103,1e+104,1e+105,1e+106,1e+107,1e+108,1e+109,1e+110,1e+111,1e+112,1e+113,1e+114,1e+115,1e+116,1e+117,1e+118,1e+119,1e+120,\r\n\t\t1e+121,1e+122,1e+123,1e+124,1e+125,1e+126,1e+127,1e+128,1e+129,1e+130,1e+131,1e+132,1e+133,1e+134,1e+135,1e+136,1e+137,1e+138,1e+139,1e+140,\r\n\t\t1e+141,1e+142,1e+143,1e+144,1e+145,1e+146,1e+147,1e+148,1e+149,1e+150,1e+151,1e+152,1e+153,1e+154,1e+155,1e+156,1e+157,1e+158,1e+159,1e+160,\r\n\t\t1e+161,1e+162,1e+163,1e+164,1e+165,1e+166,1e+167,1e+168,1e+169,1e+170,1e+171,1e+172,1e+173,1e+174,1e+175,1e+176,1e+177,1e+178,1e+179,1e+180,\r\n\t\t1e+181,1e+182,1e+183,1e+184,1e+185,1e+186,1e+187,1e+188,1e+189,1e+190,1e+191,1e+192,1e+193,1e+194,1e+195,1e+196,1e+197,1e+198,1e+199,1e+200,\r\n\t\t1e+201,1e+202,1e+203,1e+204,1e+205,1e+206,1e+207,1e+208,1e+209,1e+210,1e+211,1e+212,1e+213,1e+214,1e+215,1e+216,1e+217,1e+218,1e+219,1e+220,\r\n\t\t1e+221,1e+222,1e+223,1e+224,1e+225,1e+226,1e+227,1e+228,1e+229,1e+230,1e+231,1e+232,1e+233,1e+234,1e+235,1e+236,1e+237,1e+238,1e+239,1e+240,\r\n\t\t1e+241,1e+242,1e+243,1e+244,1e+245,1e+246,1e+247,1e+248,1e+249,1e+250,1e+251,1e+252,1e+253,1e+254,1e+255,1e+256,1e+257,1e+258,1e+259,1e+260,\r\n\t\t1e+261,1e+262,1e+263,1e+264,1e+265,1e+266,1e+267,1e+268,1e+269,1e+270,1e+271,1e+272,1e+273,1e+274,1e+275,1e+276,1e+277,1e+278,1e+279,1e+280,\r\n\t\t1e+281,1e+282,1e+283,1e+284,1e+285,1e+286,1e+287,1e+288,1e+289,1e+290,1e+291,1e+292,1e+293,1e+294,1e+295,1e+296,1e+297,1e+298,1e+299,1e+300,\r\n\t\t1e+301,1e+302,1e+303,1e+304,1e+305,1e+306,1e+307,1e+308\r\n\t};\r\n\tRAPIDJSON_ASSERT(n <= 308);\r\n\treturn n < -308 ? 0.0 : e[n + 308];\r\n}\r\n\r\n} // namespace internal\r\n} // namespace rapidjson\r\n\r\n#endif // RAPIDJSON_POW10_\r\n"
  },
  {
    "path": "src/include/rapidjson/internal/stack.h",
    "content": "/******************************************\r\n * RapidJson\r\n * Copyright (C) 2011 Milo Yip\r\n * see COPYING in the top-level directory\r\n * for more information.\r\n *****************************************/\r\n\r\n\r\n#ifndef RAPIDJSON_INTERNAL_STACK_H_\r\n#define RAPIDJSON_INTERNAL_STACK_H_\r\n\r\nnamespace rapidjson {\r\nnamespace internal {\r\n\r\n///////////////////////////////////////////////////////////////////////////////\r\n// Stack\r\n\r\n//! A type-unsafe stack for storing different types of data.\r\n/*! \\tparam Allocator Allocator for allocating stack memory.\r\n*/\r\ntemplate <typename Allocator>\r\nclass Stack {\r\npublic:\r\n\tStack(Allocator* allocator, size_t stack_capacity) : allocator_(allocator), own_allocator_(0), stack_(0), stack_top_(0), stack_end_(0), stack_capacity_(stack_capacity) {\r\n\t\tRAPIDJSON_ASSERT(stack_capacity_ > 0);\r\n\t\tif (!allocator_)\r\n\t\t\town_allocator_ = allocator_ = new Allocator();\r\n\t\tstack_top_ = stack_ = (char*)allocator_->Malloc(stack_capacity_);\r\n\t\tstack_end_ = stack_ + stack_capacity_;\r\n\t}\r\n\r\n\t~Stack() {\r\n\t\tAllocator::Free(stack_);\r\n\t\tdelete own_allocator_; // Only delete if it is owned by the stack\r\n\t}\r\n\r\n\tvoid Clear() { /*stack_top_ = 0;*/ stack_top_ = stack_; }\r\n\r\n\ttemplate<typename T>\r\n\tT* Push(size_t count = 1) {\r\n\t\t // Expand the stack if needed\r\n\t\tif (stack_top_ + sizeof(T) * count >= stack_end_) {\r\n\t\t\tsize_t new_capacity = stack_capacity_ * 2;\r\n\t\t\tsize_t size = GetSize();\r\n\t\t\tsize_t new_size = GetSize() + sizeof(T) * count;\r\n\t\t\tif (new_capacity < new_size)\r\n\t\t\t\tnew_capacity = new_size;\r\n\t\t\tstack_ = (char*)allocator_->Realloc(stack_, stack_capacity_, new_capacity);\r\n\t\t\tstack_capacity_ = new_capacity;\r\n\t\t\tstack_top_ = stack_ + size;\r\n\t\t\tstack_end_ = stack_ + stack_capacity_;\r\n\t\t}\r\n\t\tT* ret = (T*)stack_top_;\r\n\t\tstack_top_ += sizeof(T) * count;\r\n\t\treturn ret;\r\n\t}\r\n\r\n\ttemplate<typename T>\r\n\tT* Pop(size_t count) {\r\n\t\tRAPIDJSON_ASSERT(GetSize() >= count * sizeof(T));\r\n\t\tstack_top_ -= count * sizeof(T);\r\n\t\treturn (T*)stack_top_;\r\n\t}\r\n\r\n\ttemplate<typename T>\r\n\tT* Top() { \r\n\t\tRAPIDJSON_ASSERT(GetSize() >= sizeof(T));\r\n\t\treturn (T*)(stack_top_ - sizeof(T));\r\n\t}\r\n\r\n\ttemplate<typename T>\r\n\tT* Bottom() { return (T*)stack_; }\r\n\r\n\tAllocator& GetAllocator() { return *allocator_; }\r\n\tsize_t GetSize() const { return stack_top_ - stack_; }\r\n\tsize_t GetCapacity() const { return stack_capacity_; }\r\n\r\nprivate:\r\n\tAllocator* allocator_;\r\n\tAllocator* own_allocator_;\r\n\tchar *stack_;\r\n\tchar *stack_top_;\r\n\tchar *stack_end_;\r\n\tsize_t stack_capacity_;\r\n};\r\n\r\n} // namespace internal\r\n} // namespace rapidjson\r\n\r\n#endif // RAPIDJSON_STACK_H_\r\n"
  },
  {
    "path": "src/include/rapidjson/internal/strfunc.h",
    "content": "/******************************************\r\n * RapidJson\r\n * Copyright (C) 2011 Milo Yip\r\n * see COPYING in the top-level directory\r\n * for more information.\r\n *****************************************/\r\n\r\n\r\n#ifndef RAPIDJSON_INTERNAL_STRFUNC_H_\r\n#define RAPIDJSON_INTERNAL_STRFUNC_H_\r\n\r\nnamespace rapidjson {\r\nnamespace internal {\r\n\r\n//! Custom strlen() which works on different character types.\r\n/*!\t\\tparam Ch Character type (e.g. char, wchar_t, short)\r\n\t\\param s Null-terminated input string.\r\n\t\\return Number of characters in the string. \r\n\t\\note This has the same semantics as strlen(), the return value is not number of Unicode codepoints.\r\n*/\r\ntemplate <typename Ch>\r\ninline SizeType StrLen(const Ch* s) {\r\n\tconst Ch* p = s;\r\n\twhile (*p != '\\0')\r\n\t\t++p;\r\n\treturn SizeType(p - s);\r\n}\r\n\r\n} // namespace internal\r\n} // namespace rapidjson\r\n\r\n#endif // RAPIDJSON_INTERNAL_STRFUNC_H_\r\n"
  },
  {
    "path": "src/include/rapidjson/prettywriter.h",
    "content": "/******************************************\r\n * RapidJson\r\n * Copyright (C) 2011 Milo Yip\r\n * see COPYING in the top-level directory\r\n * for more information.\r\n *****************************************/\r\n\r\n\r\n#ifndef RAPIDJSON_PRETTYWRITER_H_\r\n#define RAPIDJSON_PRETTYWRITER_H_\r\n\r\n#include \"writer.h\"\r\n\r\nnamespace rapidjson {\r\n\r\n//! Writer with indentation and spacing.\r\n/*!\r\n\t\\tparam Stream Type of ouptut stream.\r\n\t\\tparam Encoding Encoding of both source strings and output.\r\n\t\\tparam Allocator Type of allocator for allocating memory of stack.\r\n*/\r\ntemplate<typename Stream, typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<> >\r\nclass PrettyWriter : public Writer<Stream, Encoding, Allocator> {\r\npublic:\r\n\ttypedef Writer<Stream, Encoding, Allocator> Base;\r\n\ttypedef typename Base::Ch Ch;\r\n\r\n\t//! Constructor\r\n\t/*! \\param stream Output stream.\r\n\t\t\\param allocator User supplied allocator. If it is null, it will create a private one.\r\n\t\t\\param levelDepth Initial capacity of \r\n\t*/\r\n\tPrettyWriter(Stream& stream, Allocator* allocator = 0, size_t levelDepth = Base::kDefaultLevelDepth) : \r\n\t\tBase(stream, allocator, levelDepth), indentChar_(' '), indentCharCount_(4) {}\r\n\r\n\t//! Set custom indentation.\r\n\t/*! \\param indentChar\t\tCharacter for indentation. Must be whitespace character (' ', '\\t', '\\n', '\\r').\r\n\t\t\\param indentCharCount\tNumber of indent characters for each indentation level.\r\n\t\t\\note The default indentation is 4 spaces.\r\n\t*/\r\n\tPrettyWriter& SetIndent(Ch indentChar, unsigned indentCharCount) {\r\n\t\tRAPIDJSON_ASSERT(indentChar == ' ' || indentChar == '\\t' || indentChar == '\\n' || indentChar == '\\r');\r\n\t\tindentChar_ = indentChar;\r\n\t\tindentCharCount_ = indentCharCount;\r\n\t\treturn *this;\r\n\t}\r\n\r\n\t//@name Implementation of Handler.\r\n\t//@{\r\n\r\n\tPrettyWriter& Null()\t\t\t\t{ PrettyPrefix(kNullType);   Base::WriteNull();\t\t\treturn *this; }\r\n\tPrettyWriter& Bool(bool b)\t\t\t{ PrettyPrefix(b ? kTrueType : kFalseType); Base::WriteBool(b); return *this; }\r\n\tPrettyWriter& Int(int i)\t\t\t{ PrettyPrefix(kNumberType); Base::WriteInt(i);\t\t\treturn *this; }\r\n\tPrettyWriter& Uint(unsigned u)\t\t{ PrettyPrefix(kNumberType); Base::WriteUint(u);\t\treturn *this; }\r\n\tPrettyWriter& Int64(int64_t i64)\t{ PrettyPrefix(kNumberType); Base::WriteInt64(i64);\t\treturn *this; }\r\n\tPrettyWriter& Uint64(uint64_t u64)\t{ PrettyPrefix(kNumberType); Base::WriteUint64(u64);\treturn *this; }\r\n\tPrettyWriter& Double(double d)\t\t{ PrettyPrefix(kNumberType); Base::WriteDouble(d);\t\treturn *this; }\r\n\r\n\tPrettyWriter& String(const Ch* str, SizeType length, bool copy = false) {\r\n\t\t(void)copy;\r\n\t\tPrettyPrefix(kStringType);\r\n\t\tBase::WriteString(str, length);\r\n\t\treturn *this;\r\n\t}\r\n\r\n\tPrettyWriter& StartObject() {\r\n\t\tPrettyPrefix(kObjectType);\r\n\t\tnew (Base::level_stack_.template Push<typename Base::Level>()) typename Base::Level(false);\r\n\t\tBase::WriteStartObject();\r\n\t\treturn *this;\r\n\t}\r\n\r\n\tPrettyWriter& EndObject(SizeType memberCount = 0) {\r\n\t\t(void)memberCount;\r\n\t\tRAPIDJSON_ASSERT(Base::level_stack_.GetSize() >= sizeof(typename Base::Level));\r\n\t\tRAPIDJSON_ASSERT(!Base::level_stack_.template Top<typename Base::Level>()->inArray);\r\n\t\tbool empty = Base::level_stack_.template Pop<typename Base::Level>(1)->valueCount == 0;\r\n\r\n\t\tif (!empty) {\r\n\t\t\tBase::stream_.Put('\\n');\r\n\t\t\tWriteIndent();\r\n\t\t}\r\n\t\tBase::WriteEndObject();\r\n\t\treturn *this;\r\n\t}\r\n\r\n\tPrettyWriter& StartArray() {\r\n\t\tPrettyPrefix(kArrayType);\r\n\t\tnew (Base::level_stack_.template Push<typename Base::Level>()) typename Base::Level(true);\r\n\t\tBase::WriteStartArray();\r\n\t\treturn *this;\r\n\t}\r\n\r\n\tPrettyWriter& EndArray(SizeType memberCount = 0) {\r\n\t\t(void)memberCount;\r\n\t\tRAPIDJSON_ASSERT(Base::level_stack_.GetSize() >= sizeof(typename Base::Level));\r\n\t\tRAPIDJSON_ASSERT(Base::level_stack_.template Top<typename Base::Level>()->inArray);\r\n\t\tbool empty = Base::level_stack_.template Pop<typename Base::Level>(1)->valueCount == 0;\r\n\r\n\t\tif (!empty) {\r\n\t\t\tBase::stream_.Put('\\n');\r\n\t\t\tWriteIndent();\r\n\t\t}\r\n\t\tBase::WriteEndArray();\r\n\t\treturn *this;\r\n\t}\r\n\r\n\t//@}\r\n\r\n\t//! Simpler but slower overload.\r\n\tPrettyWriter& String(const Ch* str) { return String(str, internal::StrLen(str)); }\r\n\r\nprotected:\r\n\tvoid PrettyPrefix(Type type) {\r\n\t\t(void)type;\r\n\t\tif (Base::level_stack_.GetSize() != 0) { // this value is not at root\r\n\t\t\ttypename Base::Level* level = Base::level_stack_.template Top<typename Base::Level>();\r\n\r\n\t\t\tif (level->inArray) {\r\n\t\t\t\tif (level->valueCount > 0) {\r\n\t\t\t\t\tBase::stream_.Put(','); // add comma if it is not the first element in array\r\n\t\t\t\t\tBase::stream_.Put('\\n');\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t\tBase::stream_.Put('\\n');\r\n\t\t\t\tWriteIndent();\r\n\t\t\t}\r\n\t\t\telse {\t// in object\r\n\t\t\t\tif (level->valueCount > 0) {\r\n\t\t\t\t\tif (level->valueCount % 2 == 0) {\r\n\t\t\t\t\t\tBase::stream_.Put(',');\r\n\t\t\t\t\t\tBase::stream_.Put('\\n');\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse {\r\n\t\t\t\t\t\tBase::stream_.Put(':');\r\n\t\t\t\t\t\tBase::stream_.Put(' ');\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t\tBase::stream_.Put('\\n');\r\n\r\n\t\t\t\tif (level->valueCount % 2 == 0)\r\n\t\t\t\t\tWriteIndent();\r\n\t\t\t}\r\n\t\t\tif (!level->inArray && level->valueCount % 2 == 0)\r\n\t\t\t\tRAPIDJSON_ASSERT(type == kStringType);  // if it's in object, then even number should be a name\r\n\t\t\tlevel->valueCount++;\r\n\t\t}\r\n\t\telse\r\n\t\t\tRAPIDJSON_ASSERT(type == kObjectType || type == kArrayType);\r\n\t}\r\n\r\n\tvoid WriteIndent()  {\r\n\t\tsize_t count = (Base::level_stack_.GetSize() / sizeof(typename Base::Level)) * indentCharCount_;\r\n\t\tPutN(Base::stream_, indentChar_, count);\r\n\t}\r\n\r\n\tCh indentChar_;\r\n\tunsigned indentCharCount_;\r\n};\r\n\r\n} // namespace rapidjson\r\n\r\n#endif // RAPIDJSON_RAPIDJSON_H_\r\n"
  },
  {
    "path": "src/include/rapidjson/rapidjson.h",
    "content": "/******************************************\r\n * RapidJson\r\n * Copyright (C) 2011 Milo Yip\r\n * see COPYING in the top-level directory\r\n * for more information.\r\n *****************************************/\r\n\r\n\r\n#ifndef RAPIDJSON_RAPIDJSON_H_\r\n#define RAPIDJSON_RAPIDJSON_H_\r\n\r\n// Copyright (c) 2011-2012 Milo Yip (miloyip@gmail.com)\r\n// Version 0.11\r\n\r\n#include <cstdlib>\t// malloc(), realloc(), free()\r\n#include <cstring>\t// memcpy()\r\n\r\n///////////////////////////////////////////////////////////////////////////////\r\n// RAPIDJSON_NO_INT64DEFINE\r\n\r\n// Here defines int64_t and uint64_t types in global namespace.\r\n// If user have their own definition, can define RAPIDJSON_NO_INT64DEFINE to disable this.\r\n#ifndef RAPIDJSON_NO_INT64DEFINE\r\n#ifdef _MSC_VER\r\ntypedef __int64 int64_t;\r\ntypedef unsigned __int64 uint64_t;\r\n#else\r\n#include <inttypes.h>\r\n#endif\r\n#endif // RAPIDJSON_NO_INT64TYPEDEF\r\n\r\n///////////////////////////////////////////////////////////////////////////////\r\n// RAPIDJSON_ENDIAN\r\n#define RAPIDJSON_LITTLEENDIAN\t0\t//!< Little endian machine\r\n#define RAPIDJSON_BIGENDIAN\t\t1\t//!< Big endian machine\r\n\r\n//! Endianness of the machine.\r\n/*!\tGCC provided macro for detecting endianness of the target machine. But other\r\n\tcompilers may not have this. User can define RAPIDJSON_ENDIAN to either\r\n\tRAPIDJSON_LITTLEENDIAN or RAPIDJSON_BIGENDIAN.\r\n*/\r\n#ifndef RAPIDJSON_ENDIAN\r\n#ifdef __BYTE_ORDER__\r\n#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__\r\n#define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN\r\n#else\r\n#define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN\r\n#endif // __BYTE_ORDER__\r\n#else\r\n#define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN\t// Assumes little endian otherwise.\r\n#endif\r\n#endif // RAPIDJSON_ENDIAN\r\n\r\n///////////////////////////////////////////////////////////////////////////////\r\n// RAPIDJSON_SSE2/RAPIDJSON_SSE42/RAPIDJSON_SIMD\r\n\r\n// Enable SSE2 optimization.\r\n//#define RAPIDJSON_SSE2\r\n\r\n// Enable SSE4.2 optimization.\r\n//#define RAPIDJSON_SSE42\r\n\r\n#if defined(RAPIDJSON_SSE2) || defined(RAPIDJSON_SSE42)\r\n#define RAPIDJSON_SIMD\r\n#endif\r\n\r\n///////////////////////////////////////////////////////////////////////////////\r\n// RAPIDJSON_NO_SIZETYPEDEFINE\r\n\r\n#ifndef RAPIDJSON_NO_SIZETYPEDEFINE\r\nnamespace rapidjson {\r\n//! Use 32-bit array/string indices even for 64-bit platform, instead of using size_t.\r\n/*! User may override the SizeType by defining RAPIDJSON_NO_SIZETYPEDEFINE.\r\n*/\r\ntypedef unsigned SizeType;\r\n} // namespace rapidjson\r\n#endif\r\n\r\n///////////////////////////////////////////////////////////////////////////////\r\n// RAPIDJSON_ASSERT\r\n\r\n//! Assertion.\r\n/*! By default, rapidjson uses C assert() for assertion.\r\n\tUser can override it by defining RAPIDJSON_ASSERT(x) macro.\r\n*/\r\n#ifndef RAPIDJSON_ASSERT\r\n#include <cassert>\r\n#define RAPIDJSON_ASSERT(x) assert(x)\r\n#endif // RAPIDJSON_ASSERT\r\n\r\n///////////////////////////////////////////////////////////////////////////////\r\n// Helpers\r\n\r\n#define RAPIDJSON_MULTILINEMACRO_BEGIN do {  \r\n#define RAPIDJSON_MULTILINEMACRO_END \\\r\n} while((void)0, 0)\r\n\r\nnamespace rapidjson {\r\n\r\n///////////////////////////////////////////////////////////////////////////////\r\n// Allocator\r\n\r\n/*! \\class rapidjson::Allocator\r\n\t\\brief Concept for allocating, resizing and freeing memory block.\r\n\t\r\n\tNote that Malloc() and Realloc() are non-static but Free() is static.\r\n\t\r\n\tSo if an allocator need to support Free(), it needs to put its pointer in \r\n\tthe header of memory block.\r\n\r\n\\code\r\nconcept Allocator {\r\n\tstatic const bool kNeedFree;\t//!< Whether this allocator needs to call Free().\r\n\r\n\t// Allocate a memory block.\r\n\t// \\param size of the memory block in bytes.\r\n\t// \\returns pointer to the memory block.\r\n\tvoid* Malloc(size_t size);\r\n\r\n\t// Resize a memory block.\r\n\t// \\param originalPtr The pointer to current memory block. Null pointer is permitted.\r\n\t// \\param originalSize The current size in bytes. (Design issue: since some allocator may not book-keep this, explicitly pass to it can save memory.)\r\n\t// \\param newSize the new size in bytes.\r\n\tvoid* Realloc(void* originalPtr, size_t originalSize, size_t newSize);\r\n\r\n\t// Free a memory block.\r\n\t// \\param pointer to the memory block. Null pointer is permitted.\r\n\tstatic void Free(void *ptr);\r\n};\r\n\\endcode\r\n*/\r\n\r\n///////////////////////////////////////////////////////////////////////////////\r\n// CrtAllocator\r\n\r\n//! C-runtime library allocator.\r\n/*! This class is just wrapper for standard C library memory routines.\r\n\t\\implements Allocator\r\n*/\r\nclass CrtAllocator {\r\npublic:\r\n\tstatic const bool kNeedFree = true;\r\n\tvoid* Malloc(size_t size) { return malloc(size); }\r\n\tvoid* Realloc(void* originalPtr, size_t originalSize, size_t newSize) { (void)originalSize; return realloc(originalPtr, newSize); }\r\n\tstatic void Free(void *ptr) { free(ptr); }\r\n};\r\n\r\n///////////////////////////////////////////////////////////////////////////////\r\n// MemoryPoolAllocator\r\n\r\n//! Default memory allocator used by the parser and DOM.\r\n/*! This allocator allocate memory blocks from pre-allocated memory chunks. \r\n\r\n    It does not free memory blocks. And Realloc() only allocate new memory.\r\n\r\n    The memory chunks are allocated by BaseAllocator, which is CrtAllocator by default.\r\n\r\n    User may also supply a buffer as the first chunk.\r\n\r\n    If the user-buffer is full then additional chunks are allocated by BaseAllocator.\r\n\r\n    The user-buffer is not deallocated by this allocator.\r\n\r\n    \\tparam BaseAllocator the allocator type for allocating memory chunks. Default is CrtAllocator.\r\n\t\\implements Allocator\r\n*/\r\ntemplate <typename BaseAllocator = CrtAllocator>\r\nclass MemoryPoolAllocator {\r\npublic:\r\n\tstatic const bool kNeedFree = false;\t//!< Tell users that no need to call Free() with this allocator. (concept Allocator)\r\n\r\n\t//! Constructor with chunkSize.\r\n\t/*! \\param chunkSize The size of memory chunk. The default is kDefaultChunkSize.\r\n\t\t\\param baseAllocator The allocator for allocating memory chunks.\r\n\t*/\r\n\tMemoryPoolAllocator(size_t chunkSize = kDefaultChunkCapacity, BaseAllocator* baseAllocator = 0) : \r\n\t\tchunkHead_(0), chunk_capacity_(chunkSize), userBuffer_(0), baseAllocator_(baseAllocator), ownBaseAllocator_(0)\r\n\t{\r\n\t\tif (!baseAllocator_)\r\n\t\t\townBaseAllocator_ = baseAllocator_ = new BaseAllocator();\r\n\t\tAddChunk(chunk_capacity_);\r\n\t}\r\n\r\n\t//! Constructor with user-supplied buffer.\r\n\t/*! The user buffer will be used firstly. When it is full, memory pool allocates new chunk with chunk size.\r\n\r\n\t\tThe user buffer will not be deallocated when this allocator is destructed.\r\n\r\n\t\t\\param buffer User supplied buffer.\r\n\t\t\\param size Size of the buffer in bytes. It must at least larger than sizeof(ChunkHeader).\r\n\t\t\\param chunkSize The size of memory chunk. The default is kDefaultChunkSize.\r\n\t\t\\param baseAllocator The allocator for allocating memory chunks.\r\n\t*/\r\n\tMemoryPoolAllocator(char *buffer, size_t size, size_t chunkSize = kDefaultChunkCapacity, BaseAllocator* baseAllocator = 0) :\r\n\t\tchunkHead_(0), chunk_capacity_(chunkSize), userBuffer_(buffer), baseAllocator_(baseAllocator), ownBaseAllocator_(0)\r\n\t{\r\n\t\tRAPIDJSON_ASSERT(buffer != 0);\r\n\t\tRAPIDJSON_ASSERT(size > sizeof(ChunkHeader));\r\n\t\tchunkHead_ = (ChunkHeader*)buffer;\r\n\t\tchunkHead_->capacity = size - sizeof(ChunkHeader);\r\n\t\tchunkHead_->size = 0;\r\n\t\tchunkHead_->next = 0;\r\n\t}\r\n\r\n\t//! Destructor.\r\n\t/*! This deallocates all memory chunks, excluding the user-supplied buffer.\r\n\t*/\r\n\t~MemoryPoolAllocator() {\r\n\t\tClear();\r\n\t\tdelete ownBaseAllocator_;\r\n\t}\r\n\r\n\t//! Deallocates all memory chunks, excluding the user-supplied buffer.\r\n\tvoid Clear() {\r\n\t\twhile(chunkHead_ != 0 && chunkHead_ != (ChunkHeader *)userBuffer_) {\r\n\t\t\tChunkHeader* next = chunkHead_->next;\r\n\t\t\tbaseAllocator_->Free(chunkHead_);\r\n\t\t\tchunkHead_ = next;\r\n\t\t}\r\n\t}\r\n\r\n\t//! Computes the total capacity of allocated memory chunks.\r\n\t/*! \\return total capacity in bytes.\r\n\t*/\r\n\tsize_t Capacity() {\r\n\t\tsize_t capacity = 0;\r\n\t\tfor (ChunkHeader* c = chunkHead_; c != 0; c = c->next)\r\n\t\t\tcapacity += c->capacity;\r\n\t\treturn capacity;\r\n\t}\r\n\r\n\t//! Computes the memory blocks allocated.\r\n\t/*! \\return total used bytes.\r\n\t*/\r\n\tsize_t Size() {\r\n\t\tsize_t size = 0;\r\n\t\tfor (ChunkHeader* c = chunkHead_; c != 0; c = c->next)\r\n\t\t\tsize += c->size;\r\n\t\treturn size;\r\n\t}\r\n\r\n\t//! Allocates a memory block. (concept Allocator)\r\n\tvoid* Malloc(size_t size) {\r\n\t\tsize = (size + 3) & ~3;\t// Force aligning size to 4\r\n\r\n\t\tif (chunkHead_->size + size > chunkHead_->capacity)\r\n\t\t\tAddChunk(chunk_capacity_ > size ? chunk_capacity_ : size);\r\n\r\n\t\tchar *buffer = (char *)(chunkHead_ + 1) + chunkHead_->size;\r\n\t\tRAPIDJSON_ASSERT(((uintptr_t)buffer & 3) == 0);\t// returned buffer is aligned to 4\r\n\t\tchunkHead_->size += size;\r\n\r\n\t\treturn buffer;\r\n\t}\r\n\r\n\t//! Resizes a memory block (concept Allocator)\r\n\tvoid* Realloc(void* originalPtr, size_t originalSize, size_t newSize) {\r\n\t\tif (originalPtr == 0)\r\n\t\t\treturn Malloc(newSize);\r\n\r\n\t\t// Do not shrink if new size is smaller than original\r\n\t\tif (originalSize >= newSize)\r\n\t\t\treturn originalPtr;\r\n\r\n\t\t// Simply expand it if it is the last allocation and there is sufficient space\r\n\t\tif (originalPtr == (char *)(chunkHead_ + 1) + chunkHead_->size - originalSize) {\r\n\t\t\tsize_t increment = newSize - originalSize;\r\n\t\t\tincrement = (increment + 3) & ~3;\t// Force aligning size to 4\r\n\t\t\tif (chunkHead_->size + increment <= chunkHead_->capacity) {\r\n\t\t\t\tchunkHead_->size += increment;\r\n\t\t\t\tRAPIDJSON_ASSERT(((uintptr_t)originalPtr & 3) == 0);\t// returned buffer is aligned to 4\r\n\t\t\t\treturn originalPtr;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Realloc process: allocate and copy memory, do not free original buffer.\r\n\t\tvoid* newBuffer = Malloc(newSize);\r\n\t\tRAPIDJSON_ASSERT(newBuffer != 0);\t// Do not handle out-of-memory explicitly.\r\n\t\treturn memcpy(newBuffer, originalPtr, originalSize);\r\n\t}\r\n\r\n\t//! Frees a memory block (concept Allocator)\r\n\tstatic void Free(void *) {} // Do nothing\r\n\r\nprivate:\r\n\t//! Creates a new chunk.\r\n\t/*! \\param capacity Capacity of the chunk in bytes.\r\n\t*/\r\n\tvoid AddChunk(size_t capacity) {\r\n\t\tChunkHeader* chunk = (ChunkHeader*)baseAllocator_->Malloc(sizeof(ChunkHeader) + capacity);\r\n\t\tchunk->capacity = capacity;\r\n\t\tchunk->size = 0;\r\n\t\tchunk->next = chunkHead_;\r\n\t\tchunkHead_ =  chunk;\r\n\t}\r\n\r\n\tstatic const int kDefaultChunkCapacity = 64 * 1024; //!< Default chunk capacity.\r\n\r\n\t//! Chunk header for perpending to each chunk.\r\n\t/*! Chunks are stored as a singly linked list.\r\n\t*/\r\n\tstruct ChunkHeader {\r\n\t\tsize_t capacity;\t//!< Capacity of the chunk in bytes (excluding the header itself).\r\n\t\tsize_t size;\t\t//!< Current size of allocated memory in bytes.\r\n\t\tChunkHeader *next;\t//!< Next chunk in the linked list.\r\n\t};\r\n\r\n\tChunkHeader *chunkHead_;\t//!< Head of the chunk linked-list. Only the head chunk serves allocation.\r\n\tsize_t chunk_capacity_;\t\t//!< The minimum capacity of chunk when they are allocated.\r\n\tchar *userBuffer_;\t\t\t//!< User supplied buffer.\r\n\tBaseAllocator* baseAllocator_;\t//!< base allocator for allocating memory chunks.\r\n\tBaseAllocator* ownBaseAllocator_;\t//!< base allocator created by this object.\r\n};\r\n\r\n///////////////////////////////////////////////////////////////////////////////\r\n// Encoding\r\n\r\n/*! \\class rapidjson::Encoding\r\n\t\\brief Concept for encoding of Unicode characters.\r\n\r\n\\code\r\nconcept Encoding {\r\n\ttypename Ch;\t//! Type of character.\r\n\r\n\t//! \\brief Encode a Unicode codepoint to a buffer.\r\n\t//! \\param buffer pointer to destination buffer to store the result. It should have sufficient size of encoding one character.\r\n\t//! \\param codepoint An unicode codepoint, ranging from 0x0 to 0x10FFFF inclusively.\r\n\t//! \\returns the pointer to the next character after the encoded data.\r\n\tstatic Ch* Encode(Ch *buffer, unsigned codepoint);\r\n};\r\n\\endcode\r\n*/\r\n\r\n///////////////////////////////////////////////////////////////////////////////\r\n// UTF8\r\n\r\n//! UTF-8 encoding.\r\n/*! http://en.wikipedia.org/wiki/UTF-8\r\n\t\\tparam CharType Type for storing 8-bit UTF-8 data. Default is char.\r\n\t\\implements Encoding\r\n*/\r\ntemplate<typename CharType = char>\r\nstruct UTF8 {\r\n\ttypedef CharType Ch;\r\n\r\n\tstatic Ch* Encode(Ch *buffer, unsigned codepoint) {\r\n\t\tif (codepoint <= 0x7F) \r\n\t\t\t*buffer++ = codepoint & 0xFF;\r\n\t\telse if (codepoint <= 0x7FF) {\r\n\t\t\t*buffer++ = 0xC0 | ((codepoint >> 6) & 0xFF);\r\n\t\t\t*buffer++ = 0x80 | ((codepoint & 0x3F));\r\n\t\t}\r\n\t\telse if (codepoint <= 0xFFFF) {\r\n\t\t\t*buffer++ = 0xE0 | ((codepoint >> 12) & 0xFF);\r\n\t\t\t*buffer++ = 0x80 | ((codepoint >> 6) & 0x3F);\r\n\t\t\t*buffer++ = 0x80 | (codepoint & 0x3F);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tRAPIDJSON_ASSERT(codepoint <= 0x10FFFF);\r\n\t\t\t*buffer++ = 0xF0 | ((codepoint >> 18) & 0xFF);\r\n\t\t\t*buffer++ = 0x80 | ((codepoint >> 12) & 0x3F);\r\n\t\t\t*buffer++ = 0x80 | ((codepoint >> 6) & 0x3F);\r\n\t\t\t*buffer++ = 0x80 | (codepoint & 0x3F);\r\n\t\t}\r\n\t\treturn buffer;\r\n\t}\r\n};\r\n\r\n///////////////////////////////////////////////////////////////////////////////\r\n// UTF16\r\n\r\n//! UTF-16 encoding.\r\n/*! http://en.wikipedia.org/wiki/UTF-16\r\n\t\\tparam CharType Type for storing 16-bit UTF-16 data. Default is wchar_t. C++11 may use char16_t instead.\r\n\t\\implements Encoding\r\n*/\r\ntemplate<typename CharType = wchar_t>\r\nstruct UTF16 {\r\n\ttypedef CharType Ch;\r\n\r\n\tstatic Ch* Encode(Ch* buffer, unsigned codepoint) {\r\n\t\tif (codepoint <= 0xFFFF) {\r\n\t\t\tRAPIDJSON_ASSERT(codepoint < 0xD800 || codepoint > 0xDFFF); // Code point itself cannot be surrogate pair \r\n\t\t\t*buffer++ = static_cast<Ch>(codepoint);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tRAPIDJSON_ASSERT(codepoint <= 0x10FFFF);\r\n\t\t\tunsigned v = codepoint - 0x10000;\r\n\t\t\t*buffer++ = static_cast<Ch>((v >> 10) + 0xD800);\r\n\t\t\t*buffer++ = (v & 0x3FF) + 0xDC00;\r\n\t\t}\r\n\t\treturn buffer;\r\n\t}\r\n};\r\n\r\n///////////////////////////////////////////////////////////////////////////////\r\n// UTF32\r\n\r\n//! UTF-32 encoding. \r\n/*! http://en.wikipedia.org/wiki/UTF-32\r\n\t\\tparam Ch Type for storing 32-bit UTF-32 data. Default is unsigned. C++11 may use char32_t instead.\r\n\t\\implements Encoding\r\n*/\r\ntemplate<typename CharType = unsigned>\r\nstruct UTF32 {\r\n\ttypedef CharType Ch;\r\n\r\n\tstatic Ch *Encode(Ch* buffer, unsigned codepoint) {\r\n\t\tRAPIDJSON_ASSERT(codepoint <= 0x10FFFF);\r\n\t\t*buffer++ = codepoint;\r\n\t\treturn buffer;\r\n\t}\r\n};\r\n\r\n///////////////////////////////////////////////////////////////////////////////\r\n//  Stream\r\n\r\n/*! \\class rapidjson::Stream\r\n\t\\brief Concept for reading and writing characters.\r\n\r\n\tFor read-only stream, no need to implement PutBegin(), Put() and PutEnd().\r\n\r\n\tFor write-only stream, only need to implement Put().\r\n\r\n\\code\r\nconcept Stream {\r\n\ttypename Ch;\t//!< Character type of the stream.\r\n\r\n\t//! Read the current character from stream without moving the read cursor.\r\n\tCh Peek() const;\r\n\r\n\t//! Read the current character from stream and moving the read cursor to next character.\r\n\tCh Take();\r\n\r\n\t//! Get the current read cursor.\r\n\t//! \\return Number of characters read from start.\r\n\tsize_t Tell();\r\n\r\n\t//! Begin writing operation at the current read pointer.\r\n\t//! \\return The begin writer pointer.\r\n\tCh* PutBegin();\r\n\r\n\t//! Write a character.\r\n\tvoid Put(Ch c);\r\n\r\n\t//! End the writing operation.\r\n\t//! \\param begin The begin write pointer returned by PutBegin().\r\n\t//! \\return Number of characters written.\r\n\tsize_t PutEnd(Ch* begin);\r\n}\r\n\\endcode\r\n*/\r\n\r\n//! Put N copies of a character to a stream.\r\ntemplate<typename Stream, typename Ch>\r\ninline void PutN(Stream& stream, Ch c, size_t n) {\r\n\tfor (size_t i = 0; i < n; i++)\r\n\t\tstream.Put(c);\r\n}\r\n\r\n///////////////////////////////////////////////////////////////////////////////\r\n// StringStream\r\n\r\n//! Read-only string stream.\r\n/*! \\implements Stream\r\n*/\r\ntemplate <typename Encoding>\r\nstruct GenericStringStream {\r\n\ttypedef typename Encoding::Ch Ch;\r\n\r\n\tGenericStringStream(const Ch *src) : src_(src), head_(src) {}\r\n\r\n\tCh Peek() const { return *src_; }\r\n\tCh Take() { return *src_++; }\r\n\tsize_t Tell() const { return src_ - head_; }\r\n\r\n\tCh* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }\r\n\tvoid Put(Ch) { RAPIDJSON_ASSERT(false); }\r\n\tsize_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }\r\n\r\n\tconst Ch* src_;\t\t//!< Current read position.\r\n\tconst Ch* head_;\t//!< Original head of the string.\r\n};\r\n\r\ntypedef GenericStringStream<UTF8<> > StringStream;\r\n\r\n///////////////////////////////////////////////////////////////////////////////\r\n// InsituStringStream\r\n\r\n//! A read-write string stream.\r\n/*! This string stream is particularly designed for in-situ parsing.\r\n\t\\implements Stream\r\n*/\r\ntemplate <typename Encoding>\r\nstruct GenericInsituStringStream {\r\n\ttypedef typename Encoding::Ch Ch;\r\n\r\n\tGenericInsituStringStream(Ch *src) : src_(src), dst_(0), head_(src) {}\r\n\r\n\t// Read\r\n\tCh Peek() { return *src_; }\r\n\tCh Take() { return *src_++; }\r\n\tsize_t Tell() { return src_ - head_; }\r\n\r\n\t// Write\r\n\tCh* PutBegin() { return dst_ = src_; }\r\n\tvoid Put(Ch c) { RAPIDJSON_ASSERT(dst_ != 0); *dst_++ = c; }\r\n\tsize_t PutEnd(Ch* begin) { return dst_ - begin; }\r\n\r\n\tCh* src_;\r\n\tCh* dst_;\r\n\tCh* head_;\r\n};\r\n\r\ntypedef GenericInsituStringStream<UTF8<> > InsituStringStream;\r\n\r\n///////////////////////////////////////////////////////////////////////////////\r\n// Type\r\n\r\n//! Type of JSON value\r\nenum Type {\r\n\tkNullType = 0,\t\t//!< null\r\n\tkFalseType = 1,\t\t//!< false\r\n\tkTrueType = 2,\t\t//!< true\r\n\tkObjectType = 3,\t//!< object\r\n\tkArrayType = 4,\t\t//!< array \r\n\tkStringType = 5,\t//!< string\r\n\tkNumberType = 6,\t//!< number\r\n};\r\n\r\n} // namespace rapidjson\r\n\r\n#endif // RAPIDJSON_RAPIDJSON_H_\r\n"
  },
  {
    "path": "src/include/rapidjson/reader.h",
    "content": "/******************************************\r\n * RapidJson\r\n * Copyright (C) 2011 Milo Yip\r\n * see COPYING in the top-level directory\r\n * for more information.\r\n *****************************************/\r\n\r\n\r\n#ifndef RAPIDJSON_READER_H_\r\n#define RAPIDJSON_READER_H_\r\n\r\n// Copyright (c) 2011 Milo Yip (miloyip@gmail.com)\r\n// Version 0.1\r\n\r\n#include \"rapidjson.h\"\r\n#include \"internal/pow10.h\"\r\n#include \"internal/stack.h\"\r\n#include <csetjmp>\r\n\r\n#ifdef RAPIDJSON_SSE42\r\n#include <nmmintrin.h>\r\n#elif defined(RAPIDJSON_SSE2)\r\n#include <emmintrin.h>\r\n#endif\r\n\r\n#ifdef _MSC_VER\r\n#pragma warning(push)\r\n#pragma warning(disable : 4127) // conditional expression is constant\r\n#endif\r\n\r\n#ifndef RAPIDJSON_PARSE_ERROR\r\n#define RAPIDJSON_PARSE_ERROR(msg, offset) \\\r\n\tRAPIDJSON_MULTILINEMACRO_BEGIN \\\r\n\tparseError_ = msg; \\\r\n\terrorOffset_ = offset; \\\r\n\tlongjmp(jmpbuf_, 1); \\\r\n\tRAPIDJSON_MULTILINEMACRO_END\r\n#endif\r\n\r\nnamespace rapidjson {\r\n\r\n///////////////////////////////////////////////////////////////////////////////\r\n// ParseFlag\r\n\r\n//! Combination of parseFlags\r\nenum ParseFlag {\r\n\tkParseDefaultFlags = 0,\t\t\t//!< Default parse flags. Non-destructive parsing. Text strings are decoded into allocated buffer.\r\n\tkParseInsituFlag = 1\t\t\t//!< In-situ(destructive) parsing.\r\n};\r\n\r\n///////////////////////////////////////////////////////////////////////////////\r\n// Handler\r\n\r\n/*!\t\\class rapidjson::Handler\r\n\t\\brief Concept for receiving events from GenericReader upon parsing.\r\n\\code\r\nconcept Handler {\r\n\ttypename Ch;\r\n\r\n\tvoid Null();\r\n\tvoid Bool(bool b);\r\n\tvoid Int(int i);\r\n\tvoid Uint(unsigned i);\r\n\tvoid Int64(int64_t i);\r\n\tvoid Uint64(uint64_t i);\r\n\tvoid Double(double d);\r\n\tvoid String(const Ch* str, SizeType length, bool copy);\r\n\tvoid StartObject();\r\n\tvoid EndObject(SizeType memberCount);\r\n\tvoid StartArray();\r\n\tvoid EndArray(SizeType elementCount);\r\n};\r\n\\endcode\r\n*/\r\n///////////////////////////////////////////////////////////////////////////////\r\n// BaseReaderHandler\r\n\r\n//! Default implementation of Handler.\r\n/*! This can be used as base class of any reader handler.\r\n\t\\implements Handler\r\n*/\r\ntemplate<typename Encoding = UTF8<> >\r\nstruct BaseReaderHandler {\r\n\ttypedef typename Encoding::Ch Ch;\r\n\r\n\tvoid Default() {}\r\n\tvoid Null() { Default(); }\r\n\tvoid Bool(bool) { Default(); }\r\n\tvoid Int(int) { Default(); }\r\n\tvoid Uint(unsigned) { Default(); }\r\n\tvoid Int64(int64_t) { Default(); }\r\n\tvoid Uint64(uint64_t) { Default(); }\r\n\tvoid Double(double) { Default(); }\r\n\tvoid String(const Ch*, SizeType, bool) { Default(); }\r\n\tvoid StartObject() { Default(); }\r\n\tvoid EndObject(SizeType) { Default(); }\r\n\tvoid StartArray() { Default(); }\r\n\tvoid EndArray(SizeType) { Default(); }\r\n};\r\n\r\n///////////////////////////////////////////////////////////////////////////////\r\n// SkipWhitespace\r\n\r\n//! Skip the JSON white spaces in a stream.\r\n/*! \\param stream A input stream for skipping white spaces.\r\n\t\\note This function has SSE2/SSE4.2 specialization.\r\n*/\r\ntemplate<typename Stream>\r\nvoid SkipWhitespace(Stream& stream) {\r\n\tStream s = stream;\t// Use a local copy for optimization\r\n\twhile (s.Peek() == ' ' || s.Peek() == '\\n' || s.Peek() == '\\r' || s.Peek() == '\\t')\r\n\t\ts.Take();\r\n\tstream = s;\r\n}\r\n\r\n#ifdef RAPIDJSON_SSE42\r\n//! Skip whitespace with SSE 4.2 pcmpistrm instruction, testing 16 8-byte characters at once.\r\ninline const char *SkipWhitespace_SIMD(const char* p) {\r\n\tstatic const char whitespace[16] = \" \\n\\r\\t\";\r\n\t__m128i w = _mm_loadu_si128((const __m128i *)&whitespace[0]);\r\n\r\n\tfor (;;) {\r\n\t\t__m128i s = _mm_loadu_si128((const __m128i *)p);\r\n\t\tunsigned r = _mm_cvtsi128_si32(_mm_cmpistrm(w, s, _SIDD_UBYTE_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK | _SIDD_NEGATIVE_POLARITY));\r\n\t\tif (r == 0)\t// all 16 characters are whitespace\r\n\t\t\tp += 16;\r\n\t\telse {\t\t// some of characters may be non-whitespace\r\n#ifdef _MSC_VER\t\t// Find the index of first non-whitespace\r\n\t\t\tunsigned long offset;\r\n\t\t\tif (_BitScanForward(&offset, r))\r\n\t\t\t\treturn p + offset;\r\n#else\r\n\t\t\tif (r != 0)\r\n\t\t\t\treturn p + __builtin_ffs(r) - 1;\r\n#endif\r\n\t\t}\r\n\t}\r\n}\r\n\r\n#elif defined(RAPIDJSON_SSE2)\r\n\r\n//! Skip whitespace with SSE2 instructions, testing 16 8-byte characters at once.\r\ninline const char *SkipWhitespace_SIMD(const char* p) {\r\n\tstatic const char whitespaces[4][17] = {\r\n\t\t\"                \",\r\n\t\t\"\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\",\r\n\t\t\"\\r\\r\\r\\r\\r\\r\\r\\r\\r\\r\\r\\r\\r\\r\\r\\r\",\r\n\t\t\"\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\"};\r\n\r\n\t__m128i w0 = _mm_loadu_si128((const __m128i *)&whitespaces[0][0]);\r\n\t__m128i w1 = _mm_loadu_si128((const __m128i *)&whitespaces[1][0]);\r\n\t__m128i w2 = _mm_loadu_si128((const __m128i *)&whitespaces[2][0]);\r\n\t__m128i w3 = _mm_loadu_si128((const __m128i *)&whitespaces[3][0]);\r\n\r\n\tfor (;;) {\r\n\t\t__m128i s = _mm_loadu_si128((const __m128i *)p);\r\n\t\t__m128i x = _mm_cmpeq_epi8(s, w0);\r\n\t\tx = _mm_or_si128(x, _mm_cmpeq_epi8(s, w1));\r\n\t\tx = _mm_or_si128(x, _mm_cmpeq_epi8(s, w2));\r\n\t\tx = _mm_or_si128(x, _mm_cmpeq_epi8(s, w3));\r\n\t\tunsigned short r = ~_mm_movemask_epi8(x);\r\n\t\tif (r == 0)\t// all 16 characters are whitespace\r\n\t\t\tp += 16;\r\n\t\telse {\t\t// some of characters may be non-whitespace\r\n#ifdef _MSC_VER\t\t// Find the index of first non-whitespace\r\n\t\t\tunsigned long offset;\r\n\t\t\tif (_BitScanForward(&offset, r))\r\n\t\t\t\treturn p + offset;\r\n#else\r\n\t\t\tif (r != 0)\r\n\t\t\t\treturn p + __builtin_ffs(r) - 1;\r\n#endif\r\n\t\t}\r\n\t}\r\n}\r\n\r\n#endif // RAPIDJSON_SSE2\r\n\r\n#ifdef RAPIDJSON_SIMD\r\n//! Template function specialization for InsituStringStream\r\ntemplate<> inline void SkipWhitespace(InsituStringStream& stream) { \r\n\tstream.src_ = const_cast<char*>(SkipWhitespace_SIMD(stream.src_));\r\n}\r\n\r\n//! Template function specialization for StringStream\r\ntemplate<> inline void SkipWhitespace(StringStream& stream) {\r\n\tstream.src_ = SkipWhitespace_SIMD(stream.src_);\r\n}\r\n#endif // RAPIDJSON_SIMD\r\n\r\n///////////////////////////////////////////////////////////////////////////////\r\n// GenericReader\r\n\r\n//! SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator.\r\n/*! GenericReader parses JSON text from a stream, and send events synchronously to an \r\n    object implementing Handler concept.\r\n\r\n    It needs to allocate a stack for storing a single decoded string during \r\n    non-destructive parsing.\r\n\r\n    For in-situ parsing, the decoded string is directly written to the source \r\n    text string, no temporary buffer is required.\r\n\r\n    A GenericReader object can be reused for parsing multiple JSON text.\r\n    \r\n    \\tparam Encoding Encoding of both the stream and the parse output.\r\n    \\tparam Allocator Allocator type for stack.\r\n*/\r\ntemplate <typename Encoding, typename Allocator = MemoryPoolAllocator<> >\r\nclass GenericReader {\r\npublic:\r\n\ttypedef typename Encoding::Ch Ch;\r\n\r\n\t//! Constructor.\r\n\t/*! \\param allocator Optional allocator for allocating stack memory. (Only use for non-destructive parsing)\r\n\t\t\\param stackCapacity stack capacity in bytes for storing a single decoded string.  (Only use for non-destructive parsing)\r\n\t*/\r\n\tGenericReader(Allocator* allocator = 0, size_t stackCapacity = kDefaultStackCapacity) : stack_(allocator, stackCapacity), parseError_(0), errorOffset_(0) {}\r\n\r\n\t//! Parse JSON text.\r\n\t/*! \\tparam parseFlags Combination of ParseFlag. \r\n\t\t \\tparam Stream Type of input stream.\r\n\t\t \\tparam Handler Type of handler which must implement Handler concept.\r\n\t\t \\param stream Input stream to be parsed.\r\n\t\t \\param handler The handler to receive events.\r\n\t\t \\return Whether the parsing is successful.\r\n\t*/\r\n\ttemplate <unsigned parseFlags, typename Stream, typename Handler>\r\n\tbool Parse(Stream& stream, Handler& handler) {\r\n\t\tparseError_ = 0;\r\n\t\terrorOffset_ = 0;\r\n\r\n#ifdef _MSC_VER\r\n#pragma warning(push)\r\n#pragma warning(disable : 4611) // interaction between '_setjmp' and C++ object destruction is non-portable\r\n#endif\r\n\t\tif (setjmp(jmpbuf_)) {\r\n#ifdef _MSC_VER\r\n#pragma warning(pop)\r\n#endif\r\n\t\t\tstack_.Clear();\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tSkipWhitespace(stream);\r\n\r\n\t\tif (stream.Peek() == '\\0')\r\n\t\t\tRAPIDJSON_PARSE_ERROR(\"Text only contains white space(s)\", stream.Tell());\r\n\t\telse {\r\n\t\t\tswitch (stream.Peek()) {\r\n\t\t\t\tcase '{': ParseObject<parseFlags>(stream, handler); break;\r\n\t\t\t\tcase '[': ParseArray<parseFlags>(stream, handler); break;\r\n\t\t\t\tdefault: RAPIDJSON_PARSE_ERROR(\"Expect either an object or array at root\", stream.Tell());\r\n\t\t\t}\r\n\t\t\tSkipWhitespace(stream);\r\n\r\n\t\t\tif (stream.Peek() != '\\0')\r\n\t\t\t\tRAPIDJSON_PARSE_ERROR(\"Nothing should follow the root object or array.\", stream.Tell());\r\n\t\t}\r\n\r\n\t\treturn true;\r\n\t}\r\n\r\n\tbool HasParseError() const { return parseError_ != 0; }\r\n\tconst char* GetParseError() const { return parseError_; }\r\n\tsize_t GetErrorOffset() const { return errorOffset_; }\r\n\r\nprivate:\r\n\t// Parse object: { string : value, ... }\r\n\ttemplate<unsigned parseFlags, typename Stream, typename Handler>\r\n\tvoid ParseObject(Stream& stream, Handler& handler) {\r\n\t\tRAPIDJSON_ASSERT(stream.Peek() == '{');\r\n\t\tstream.Take();\t// Skip '{'\r\n\t\thandler.StartObject();\r\n\t\tSkipWhitespace(stream);\r\n\r\n\t\tif (stream.Peek() == '}') {\r\n\t\t\tstream.Take();\r\n\t\t\thandler.EndObject(0);\t// empty object\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tfor (SizeType memberCount = 0;;) {\r\n\t\t\tif (stream.Peek() != '\"') {\r\n\t\t\t\tRAPIDJSON_PARSE_ERROR(\"Name of an object member must be a string\", stream.Tell());\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tParseString<parseFlags>(stream, handler);\r\n\t\t\tSkipWhitespace(stream);\r\n\r\n\t\t\tif (stream.Take() != ':') {\r\n\t\t\t\tRAPIDJSON_PARSE_ERROR(\"There must be a colon after the name of object member\", stream.Tell());\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tSkipWhitespace(stream);\r\n\r\n\t\t\tParseValue<parseFlags>(stream, handler);\r\n\t\t\tSkipWhitespace(stream);\r\n\r\n\t\t\t++memberCount;\r\n\r\n\t\t\tswitch(stream.Take()) {\r\n\t\t\t\tcase ',': SkipWhitespace(stream); break;\r\n\t\t\t\tcase '}': handler.EndObject(memberCount); return;\r\n\t\t\t\tdefault:  RAPIDJSON_PARSE_ERROR(\"Must be a comma or '}' after an object member\", stream.Tell());\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// Parse array: [ value, ... ]\r\n\ttemplate<unsigned parseFlags, typename Stream, typename Handler>\r\n\tvoid ParseArray(Stream& stream, Handler& handler) {\r\n\t\tRAPIDJSON_ASSERT(stream.Peek() == '[');\r\n\t\tstream.Take();\t// Skip '['\r\n\t\thandler.StartArray();\r\n\t\tSkipWhitespace(stream);\r\n\r\n\t\tif (stream.Peek() == ']') {\r\n\t\t\tstream.Take();\r\n\t\t\thandler.EndArray(0); // empty array\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tfor (SizeType elementCount = 0;;) {\r\n\t\t\tParseValue<parseFlags>(stream, handler);\r\n\t\t\t++elementCount;\r\n\t\t\tSkipWhitespace(stream);\r\n\r\n\t\t\tswitch (stream.Take()) {\r\n\t\t\t\tcase ',': SkipWhitespace(stream); break;\r\n\t\t\t\tcase ']': handler.EndArray(elementCount); return;\r\n\t\t\t\tdefault:  RAPIDJSON_PARSE_ERROR(\"Must be a comma or ']' after an array element.\", stream.Tell());\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\ttemplate<unsigned parseFlags, typename Stream, typename Handler>\r\n\tvoid ParseNull(Stream& stream, Handler& handler) {\r\n\t\tRAPIDJSON_ASSERT(stream.Peek() == 'n');\r\n\t\tstream.Take();\r\n\r\n\t\tif (stream.Take() == 'u' && stream.Take() == 'l' && stream.Take() == 'l')\r\n\t\t\thandler.Null();\r\n\t\telse\r\n\t\t\tRAPIDJSON_PARSE_ERROR(\"Invalid value\", stream.Tell() - 1);\r\n\t}\r\n\r\n\ttemplate<unsigned parseFlags, typename Stream, typename Handler>\r\n\tvoid ParseTrue(Stream& stream, Handler& handler) {\r\n\t\tRAPIDJSON_ASSERT(stream.Peek() == 't');\r\n\t\tstream.Take();\r\n\r\n\t\tif (stream.Take() == 'r' && stream.Take() == 'u' && stream.Take() == 'e')\r\n\t\t\thandler.Bool(true);\r\n\t\telse\r\n\t\t\tRAPIDJSON_PARSE_ERROR(\"Invalid value\", stream.Tell());\r\n\t}\r\n\r\n\ttemplate<unsigned parseFlags, typename Stream, typename Handler>\r\n\tvoid ParseFalse(Stream& stream, Handler& handler) {\r\n\t\tRAPIDJSON_ASSERT(stream.Peek() == 'f');\r\n\t\tstream.Take();\r\n\r\n\t\tif (stream.Take() == 'a' && stream.Take() == 'l' && stream.Take() == 's' && stream.Take() == 'e')\r\n\t\t\thandler.Bool(false);\r\n\t\telse\r\n\t\t\tRAPIDJSON_PARSE_ERROR(\"Invalid value\", stream.Tell() - 1);\r\n\t}\r\n\r\n\t// Helper function to parse four hexidecimal digits in \\uXXXX in ParseString().\r\n\ttemplate<typename Stream>\r\n\tunsigned ParseHex4(Stream& stream) {\r\n\t\tStream s = stream;\t// Use a local copy for optimization\r\n\t\tunsigned codepoint = 0;\r\n\t\tfor (int i = 0; i < 4; i++) {\r\n\t\t\tCh c = s.Take();\r\n\t\t\tcodepoint <<= 4;\r\n\t\t\tcodepoint += c;\r\n\t\t\tif (c >= '0' && c <= '9')\r\n\t\t\t\tcodepoint -= '0';\r\n\t\t\telse if (c >= 'A' && c <= 'F')\r\n\t\t\t\tcodepoint -= 'A' - 10;\r\n\t\t\telse if (c >= 'a' && c <= 'f')\r\n\t\t\t\tcodepoint -= 'a' - 10;\r\n\t\t\telse \r\n\t\t\t\tRAPIDJSON_PARSE_ERROR(\"Incorrect hex digit after \\\\u escape\", s.Tell() - 1);\r\n\t\t}\r\n\t\tstream = s; // Restore stream\r\n\t\treturn codepoint;\r\n\t}\r\n\r\n\t// Parse string, handling the prefix and suffix double quotes and escaping.\r\n\ttemplate<unsigned parseFlags, typename Stream, typename Handler>\r\n\tvoid ParseString(Stream& stream, Handler& handler) {\r\n#define Z16 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r\n\t\tstatic const Ch escape[256] = {\r\n\t\t\tZ16, Z16, 0, 0,'\\\"', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,'/', \r\n\t\t\tZ16, Z16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,'\\\\', 0, 0, 0, \r\n\t\t\t0, 0,'\\b', 0, 0, 0,'\\f', 0, 0, 0, 0, 0, 0, 0,'\\n', 0, \r\n\t\t\t0, 0,'\\r', 0,'\\t', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \r\n\t\t\tZ16, Z16, Z16, Z16, Z16, Z16, Z16, Z16\r\n\t\t};\r\n#undef Z16\r\n\r\n\t\tStream s = stream;\t// Use a local copy for optimization\r\n\t\tRAPIDJSON_ASSERT(s.Peek() == '\\\"');\r\n\t\ts.Take();\t// Skip '\\\"'\r\n\t\tCh *head;\r\n\t\tSizeType len;\r\n\t\tif (parseFlags & kParseInsituFlag)\r\n\t\t\thead = s.PutBegin();\r\n\t\telse\r\n\t\t\tlen = 0;\r\n\r\n#define RAPIDJSON_PUT(x) \\\r\n\tdo { \\\r\n\t\tif (parseFlags & kParseInsituFlag) \\\r\n\t\t\ts.Put(x); \\\r\n\t\telse { \\\r\n\t\t\t*stack_.template Push<Ch>() = x; \\\r\n\t\t\t++len; \\\r\n\t\t} \\\r\n\t} while(false)\r\n\r\n\t\tfor (;;) {\r\n\t\t\tCh c = s.Take();\r\n\t\t\tif (c == '\\\\') {\t// Escape\r\n\t\t\t\tCh e = s.Take();\r\n\t\t\t\tif ((sizeof(Ch) == 1 || e < 256) && escape[(unsigned char)e])\r\n\t\t\t\t\tRAPIDJSON_PUT(escape[(unsigned char)e]);\r\n\t\t\t\telse if (e == 'u') {\t// Unicode\r\n\t\t\t\t\tunsigned codepoint = ParseHex4(s);\r\n\t\t\t\t\tif (codepoint >= 0xD800 && codepoint <= 0xDBFF) { // Handle UTF-16 surrogate pair\r\n\t\t\t\t\t\tif (s.Take() != '\\\\' || s.Take() != 'u') {\r\n\t\t\t\t\t\t\tRAPIDJSON_PARSE_ERROR(\"Missing the second \\\\u in surrogate pair\", s.Tell() - 2);\r\n\t\t\t\t\t\t\treturn;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tunsigned codepoint2 = ParseHex4(s);\r\n\t\t\t\t\t\tif (codepoint2 < 0xDC00 || codepoint2 > 0xDFFF) {\r\n\t\t\t\t\t\t\tRAPIDJSON_PARSE_ERROR(\"The second \\\\u in surrogate pair is invalid\", s.Tell() - 2);\r\n\t\t\t\t\t\t\treturn;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tcodepoint = (((codepoint - 0xD800) << 10) | (codepoint2 - 0xDC00)) + 0x10000;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tCh buffer[4];\r\n\t\t\t\t\tSizeType count = SizeType(Encoding::Encode(buffer, codepoint) - &buffer[0]);\r\n\r\n\t\t\t\t\tif (parseFlags & kParseInsituFlag) \r\n\t\t\t\t\t\tfor (SizeType i = 0; i < count; i++)\r\n\t\t\t\t\t\t\ts.Put(buffer[i]);\r\n\t\t\t\t\telse {\r\n\t\t\t\t\t\tmemcpy(stack_.template Push<Ch>(count), buffer, count * sizeof(Ch));\r\n\t\t\t\t\t\tlen += count;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse {\r\n\t\t\t\t\tRAPIDJSON_PARSE_ERROR(\"Unknown escape character\", stream.Tell() - 1);\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse if (c == '\"') {\t// Closing double quote\r\n\t\t\t\tif (parseFlags & kParseInsituFlag) {\r\n\t\t\t\t\tsize_t length = s.PutEnd(head);\r\n\t\t\t\t\tRAPIDJSON_ASSERT(length <= 0xFFFFFFFF);\r\n\t\t\t\t\tRAPIDJSON_PUT('\\0');\t// null-terminate the string\r\n\t\t\t\t\thandler.String(head, SizeType(length), false);\r\n\t\t\t\t}\r\n\t\t\t\telse {\r\n\t\t\t\t\tRAPIDJSON_PUT('\\0');\r\n\t\t\t\t\thandler.String(stack_.template Pop<Ch>(len), len - 1, true);\r\n\t\t\t\t}\r\n\t\t\t\tstream = s;\t// restore stream\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\telse if (c == '\\0') {\r\n\t\t\t\tRAPIDJSON_PARSE_ERROR(\"lacks ending quotation before the end of string\", stream.Tell() - 1);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\telse if ((unsigned)c < 0x20) {\t// RFC 4627: unescaped = %x20-21 / %x23-5B / %x5D-10FFFF\r\n\t\t\t\tRAPIDJSON_PARSE_ERROR(\"Incorrect unescaped character in string\", stream.Tell() - 1);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\tRAPIDJSON_PUT(c);\t// Normal character, just copy\r\n\t\t}\r\n#undef RAPIDJSON_PUT\r\n\t}\r\n\r\n\ttemplate<unsigned parseFlags, typename Stream, typename Handler>\r\n\tvoid ParseNumber(Stream& stream, Handler& handler) {\r\n\t\tStream s = stream; // Local copy for optimization\r\n\t\t// Parse minus\r\n\t\tbool minus = false;\r\n\t\tif (s.Peek() == '-') {\r\n\t\t\tminus = true;\r\n\t\t\ts.Take();\r\n\t\t}\r\n\r\n\t\t// Parse int: zero / ( digit1-9 *DIGIT )\r\n\t\tunsigned i;\r\n\t\tbool try64bit = false;\r\n\t\tif (s.Peek() == '0') {\r\n\t\t\ti = 0;\r\n\t\t\ts.Take();\r\n\t\t}\r\n\t\telse if (s.Peek() >= '1' && s.Peek() <= '9') {\r\n\t\t\ti = s.Take() - '0';\r\n\r\n\t\t\tif (minus)\r\n\t\t\t\twhile (s.Peek() >= '0' && s.Peek() <= '9') {\r\n\t\t\t\t\tif (i >= 214748364) { // 2^31 = 2147483648\r\n\t\t\t\t\t\tif (i != 214748364 || s.Peek() > '8') {\r\n\t\t\t\t\t\t\ttry64bit = true;\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\ti = i * 10 + (s.Take() - '0');\r\n\t\t\t\t}\r\n\t\t\telse\r\n\t\t\t\twhile (s.Peek() >= '0' && s.Peek() <= '9') {\r\n\t\t\t\t\tif (i >= 429496729) { // 2^32 - 1 = 4294967295\r\n\t\t\t\t\t\tif (i != 429496729 || s.Peek() > '5') {\r\n\t\t\t\t\t\t\ttry64bit = true;\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\ti = i * 10 + (s.Take() - '0');\r\n\t\t\t\t}\r\n\t\t}\r\n\t\telse {\r\n\t\t\tRAPIDJSON_PARSE_ERROR(\"Expect a value here.\", stream.Tell());\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Parse 64bit int\r\n\t\tuint64_t i64 = 0;\r\n\t\tbool useDouble = false;\r\n\t\tif (try64bit) {\r\n\t\t\ti64 = i;\r\n\t\t\tif (minus) \r\n\t\t\t\twhile (s.Peek() >= '0' && s.Peek() <= '9') {\t\t\t\t\t\r\n\t\t\t\t\tif (i64 >= 922337203685477580uLL) // 2^63 = 9223372036854775808\r\n\t\t\t\t\t\tif (i64 != 922337203685477580uLL || s.Peek() > '8') {\r\n\t\t\t\t\t\t\tuseDouble = true;\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\ti64 = i64 * 10 + (s.Take() - '0');\r\n\t\t\t\t}\r\n\t\t\telse\r\n\t\t\t\twhile (s.Peek() >= '0' && s.Peek() <= '9') {\t\t\t\t\t\r\n\t\t\t\t\tif (i64 >= 1844674407370955161uLL) // 2^64 - 1 = 18446744073709551615\r\n\t\t\t\t\t\tif (i64 != 1844674407370955161uLL || s.Peek() > '5') {\r\n\t\t\t\t\t\t\tuseDouble = true;\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\ti64 = i64 * 10 + (s.Take() - '0');\r\n\t\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Force double for big integer\r\n\t\tdouble d = 0.0;\r\n\t\tif (useDouble) {\r\n\t\t\td = (double)i64;\r\n\t\t\twhile (s.Peek() >= '0' && s.Peek() <= '9') {\r\n\t\t\t\tif (d >= 1E307) {\r\n\t\t\t\t\tRAPIDJSON_PARSE_ERROR(\"Number too big to store in double\", stream.Tell());\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\t\t\t\td = d * 10 + (s.Take() - '0');\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Parse frac = decimal-point 1*DIGIT\r\n\t\tint expFrac = 0;\r\n\t\tif (s.Peek() == '.') {\r\n\t\t\tif (!useDouble) {\r\n\t\t\t\td = try64bit ? (double)i64 : (double)i;\r\n\t\t\t\tuseDouble = true;\r\n\t\t\t}\r\n\t\t\ts.Take();\r\n\r\n\t\t\tif (s.Peek() >= '0' && s.Peek() <= '9') {\r\n\t\t\t\td = d * 10 + (s.Take() - '0');\r\n\t\t\t\t--expFrac;\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tRAPIDJSON_PARSE_ERROR(\"At least one digit in fraction part\", stream.Tell());\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\twhile (s.Peek() >= '0' && s.Peek() <= '9') {\r\n\t\t\t\tif (expFrac > -16) {\r\n\t\t\t\t\td = d * 10 + (s.Peek() - '0');\r\n\t\t\t\t\t--expFrac;\r\n\t\t\t\t}\r\n\t\t\t\ts.Take();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Parse exp = e [ minus / plus ] 1*DIGIT\r\n\t\tint exp = 0;\r\n\t\tif (s.Peek() == 'e' || s.Peek() == 'E') {\r\n\t\t\tif (!useDouble) {\r\n\t\t\t\td = try64bit ? (double)i64 : (double)i;\r\n\t\t\t\tuseDouble = true;\r\n\t\t\t}\r\n\t\t\ts.Take();\r\n\r\n\t\t\tbool expMinus = false;\r\n\t\t\tif (s.Peek() == '+')\r\n\t\t\t\ts.Take();\r\n\t\t\telse if (s.Peek() == '-') {\r\n\t\t\t\ts.Take();\r\n\t\t\t\texpMinus = true;\r\n\t\t\t}\r\n\r\n\t\t\tif (s.Peek() >= '0' && s.Peek() <= '9') {\r\n\t\t\t\texp = s.Take() - '0';\r\n\t\t\t\twhile (s.Peek() >= '0' && s.Peek() <= '9') {\r\n\t\t\t\t\texp = exp * 10 + (s.Take() - '0');\r\n\t\t\t\t\tif (exp > 308) {\r\n\t\t\t\t\t\tRAPIDJSON_PARSE_ERROR(\"Number too big to store in double\", stream.Tell());\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tRAPIDJSON_PARSE_ERROR(\"At least one digit in exponent\", s.Tell());\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tif (expMinus)\r\n\t\t\t\texp = -exp;\r\n\t\t}\r\n\r\n\t\t// Finish parsing, call event according to the type of number.\r\n\t\tif (useDouble) {\r\n\t\t\td *= internal::Pow10(exp + expFrac);\r\n\t\t\thandler.Double(minus ? -d : d);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tif (try64bit) {\r\n\t\t\t\tif (minus)\r\n\t\t\t\t\thandler.Int64(-(int64_t)i64);\r\n\t\t\t\telse\r\n\t\t\t\t\thandler.Uint64(i64);\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tif (minus)\r\n\t\t\t\t\thandler.Int(-(int)i);\r\n\t\t\t\telse\r\n\t\t\t\t\thandler.Uint(i);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tstream = s; // restore stream\r\n\t}\r\n\r\n\t// Parse any JSON value\r\n\ttemplate<unsigned parseFlags, typename Stream, typename Handler>\r\n\tvoid ParseValue(Stream& stream, Handler& handler) {\r\n\t\tswitch (stream.Peek()) {\r\n\t\t\tcase 'n': ParseNull  <parseFlags>(stream, handler); break;\r\n\t\t\tcase 't': ParseTrue  <parseFlags>(stream, handler); break;\r\n\t\t\tcase 'f': ParseFalse <parseFlags>(stream, handler); break;\r\n\t\t\tcase '\"': ParseString<parseFlags>(stream, handler); break;\r\n\t\t\tcase '{': ParseObject<parseFlags>(stream, handler); break;\r\n\t\t\tcase '[': ParseArray <parseFlags>(stream, handler); break;\r\n\t\t\tdefault : ParseNumber<parseFlags>(stream, handler);\r\n\t\t}\r\n\t}\r\n\r\n\tstatic const size_t kDefaultStackCapacity = 256;\t//!< Default stack capacity in bytes for storing a single decoded string. \r\n\tinternal::Stack<Allocator> stack_;\t//!< A stack for storing decoded string temporarily during non-destructive parsing.\r\n\tjmp_buf jmpbuf_;\t\t\t\t\t//!< setjmp buffer for fast exit from nested parsing function calls.\r\n\tconst char* parseError_;\r\n\tsize_t errorOffset_;\r\n}; // class GenericReader\r\n\r\n//! Reader with UTF8 encoding and default allocator.\r\ntypedef GenericReader<UTF8<> > Reader;\r\n\r\n} // namespace rapidjson\r\n\r\n#ifdef _MSC_VER\r\n#pragma warning(pop)\r\n#endif\r\n\r\n#endif // RAPIDJSON_READER_H_\r\n"
  },
  {
    "path": "src/include/rapidjson/stringbuffer.h",
    "content": "/******************************************\r\n * RapidJson\r\n * Copyright (C) 2011 Milo Yip\r\n * see COPYING in the top-level directory\r\n * for more information.\r\n *****************************************/\r\n\r\n\r\n#ifndef RAPIDJSON_STRINGBUFFER_H_\r\n#define RAPIDJSON_STRINGBUFFER_H_\r\n\r\n#include \"rapidjson.h\"\r\n#include \"internal/stack.h\"\r\n\r\nnamespace rapidjson {\r\n\r\n//! Represents an in-memory output stream.\r\n/*!\r\n\t\\tparam Encoding Encoding of the stream.\r\n\t\\tparam Allocator type for allocating memory buffer.\r\n\t\\implements Stream\r\n*/\r\ntemplate <typename Encoding, typename Allocator = CrtAllocator>\r\nstruct GenericStringBuffer {\r\n\ttypedef typename Encoding::Ch Ch;\r\n\r\n\tGenericStringBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {}\r\n\r\n\tvoid Put(Ch c) { *stack_.template Push<Ch>() = c; }\r\n\r\n\tvoid Clear() { stack_.Clear(); }\r\n\r\n\tconst char* GetString() const {\r\n\t\t// Push and pop a null terminator. This is safe.\r\n\t\t*stack_.template Push<Ch>() = '\\0';\r\n\t\tstack_.template Pop<Ch>(1);\r\n\r\n\t\treturn stack_.template Bottom<Ch>();\r\n\t}\r\n\r\n\tsize_t Size() const { return stack_.GetSize(); }\r\n\r\n\tstatic const size_t kDefaultCapacity = 256;\r\n\tmutable internal::Stack<Allocator> stack_;\r\n};\r\n\r\ntypedef GenericStringBuffer<UTF8<> > StringBuffer;\r\n\r\n//! Implement specialized version of PutN() with memset() for better performance.\r\ntemplate<>\r\ninline void PutN(GenericStringBuffer<UTF8<> >& stream, char c, size_t n) {\r\n\tmemset(stream.stack_.Push<char>(n), c, n * sizeof(c));\r\n}\r\n\r\n} // namespace rapidjson\r\n\r\n#endif // RAPIDJSON_STRINGBUFFER_H_\r\n"
  },
  {
    "path": "src/include/rapidjson/writer.h",
    "content": "/******************************************\r\n * RapidJson\r\n * Copyright (C) 2011 Milo Yip\r\n * see COPYING in the top-level directory\r\n * for more information.\r\n *****************************************/\r\n\r\n\r\n#ifndef RAPIDJSON_WRITER_H_\r\n#define RAPIDJSON_WRITER_H_\r\n\r\n#include \"rapidjson.h\"\r\n#include \"internal/stack.h\"\r\n#include \"internal/strfunc.h\"\r\n#include <cstdio>\t// snprintf() or _sprintf_s()\r\n#include <new>\t\t// placement new\r\n\r\n#ifdef _MSC_VER\r\n#pragma warning(push)\r\n#pragma warning(disable : 4127) // conditional expression is constant\r\n#endif\r\n\r\nnamespace rapidjson {\r\n\r\n//! JSON writer\r\n/*! Writer implements the concept Handler.\r\n\tIt generates JSON text by events to an output stream.\r\n\r\n\tUser may programmatically calls the functions of a writer to generate JSON text.\r\n\r\n\tOn the other side, a writer can also be passed to objects that generates events, \r\n\r\n\tfor example Reader::Parse() and Document::Accept().\r\n\r\n\t\\tparam Stream Type of ouptut stream.\r\n\t\\tparam Encoding Encoding of both source strings and output.\r\n\t\\implements Handler\r\n*/\r\ntemplate<typename Stream, typename Encoding = UTF8<>, typename Allocator = MemoryPoolAllocator<> >\r\nclass Writer {\r\npublic:\r\n\ttypedef typename Encoding::Ch Ch;\r\n\r\n\tWriter(Stream& stream, Allocator* allocator = 0, size_t levelDepth = kDefaultLevelDepth) : \r\n\t\tstream_(stream), level_stack_(allocator, levelDepth * sizeof(Level)) {}\r\n\r\n\t//@name Implementation of Handler\r\n\t//@{\r\n\tWriter& Null()\t\t\t\t\t{ Prefix(kNullType);   WriteNull();\t\t\treturn *this; }\r\n\tWriter& Bool(bool b)\t\t\t{ Prefix(b ? kTrueType : kFalseType); WriteBool(b); return *this; }\r\n\tWriter& Int(int i)\t\t\t\t{ Prefix(kNumberType); WriteInt(i);\t\t\treturn *this; }\r\n\tWriter& Uint(unsigned u)\t\t{ Prefix(kNumberType); WriteUint(u);\t\treturn *this; }\r\n\tWriter& Int64(int64_t i64)\t\t{ Prefix(kNumberType); WriteInt64(i64);\t\treturn *this; }\r\n\tWriter& Uint64(uint64_t u64)\t{ Prefix(kNumberType); WriteUint64(u64);\treturn *this; }\r\n\tWriter& Double(double d)\t\t{ Prefix(kNumberType); WriteDouble(d);\t\treturn *this; }\r\n\r\n\tWriter& String(const Ch* str, SizeType length, bool copy = false) {\r\n\t\t(void)copy;\r\n\t\tPrefix(kStringType);\r\n\t\tWriteString(str, length);\r\n\t\treturn *this;\r\n\t}\r\n\r\n\tWriter& StartObject() {\r\n\t\tPrefix(kObjectType);\r\n\t\tnew (level_stack_.template Push<Level>()) Level(false);\r\n\t\tWriteStartObject();\r\n\t\treturn *this;\r\n\t}\r\n\r\n\tWriter& EndObject(SizeType memberCount = 0) {\r\n\t\t(void)memberCount;\r\n\t\tRAPIDJSON_ASSERT(level_stack_.GetSize() >= sizeof(Level));\r\n\t\tRAPIDJSON_ASSERT(!level_stack_.template Top<Level>()->inArray);\r\n\t\tlevel_stack_.template Pop<Level>(1);\r\n\t\tWriteEndObject();\r\n\t\treturn *this;\r\n\t}\r\n\r\n\tWriter& StartArray() {\r\n\t\tPrefix(kArrayType);\r\n\t\tnew (level_stack_.template Push<Level>()) Level(true);\r\n\t\tWriteStartArray();\r\n\t\treturn *this;\r\n\t}\r\n\r\n\tWriter& EndArray(SizeType elementCount = 0) {\r\n\t\t(void)elementCount;\r\n\t\tRAPIDJSON_ASSERT(level_stack_.GetSize() >= sizeof(Level));\r\n\t\tRAPIDJSON_ASSERT(level_stack_.template Top<Level>()->inArray);\r\n\t\tlevel_stack_.template Pop<Level>(1);\r\n\t\tWriteEndArray();\r\n\t\treturn *this;\r\n\t}\r\n\t//@}\r\n\r\n\t//! Simpler but slower overload.\r\n\tWriter& String(const Ch* str) { return String(str, internal::StrLen(str)); }\r\n\r\nprotected:\r\n\t//! Information for each nested level\r\n\tstruct Level {\r\n\t\tLevel(bool inArray_) : inArray(inArray_), valueCount(0) {}\r\n\t\tbool inArray;\t\t//!< true if in array, otherwise in object\r\n\t\tsize_t valueCount;\t//!< number of values in this level\r\n\t};\r\n\r\n\tstatic const size_t kDefaultLevelDepth = 32;\r\n\r\n\tvoid WriteNull()  {\r\n\t\tstream_.Put('n'); stream_.Put('u'); stream_.Put('l'); stream_.Put('l');\r\n\t}\r\n\r\n\tvoid WriteBool(bool b)  {\r\n\t\tif (b) {\r\n\t\t\tstream_.Put('t'); stream_.Put('r'); stream_.Put('u'); stream_.Put('e');\r\n\t\t}\r\n\t\telse {\r\n\t\t\tstream_.Put('f'); stream_.Put('a'); stream_.Put('l'); stream_.Put('s'); stream_.Put('e');\r\n\t\t}\r\n\t}\r\n\r\n\tvoid WriteInt(int i) {\r\n\t\tif (i < 0) {\r\n\t\t\tstream_.Put('-');\r\n\t\t\ti = -i;\r\n\t\t}\r\n\t\tWriteUint((unsigned)i);\r\n\t}\r\n\r\n\tvoid WriteUint(unsigned u) {\r\n\t\tchar buffer[10];\r\n\t\tchar *p = buffer;\r\n\t\tdo {\r\n\t\t\t*p++ = (u % 10) + '0';\r\n\t\t\tu /= 10;\r\n\t\t} while (u > 0);\r\n\r\n\t\tdo {\r\n\t\t\t--p;\r\n\t\t\tstream_.Put(*p);\r\n\t\t} while (p != buffer);\r\n\t}\r\n\r\n\tvoid WriteInt64(int64_t i64) {\r\n\t\tif (i64 < 0) {\r\n\t\t\tstream_.Put('-');\r\n\t\t\ti64 = -i64;\r\n\t\t}\r\n\t\tWriteUint64((uint64_t)i64);\r\n\t}\r\n\r\n\tvoid WriteUint64(uint64_t u64) {\r\n\t\tchar buffer[20];\r\n\t\tchar *p = buffer;\r\n\t\tdo {\r\n\t\t\t*p++ = char(u64 % 10) + '0';\r\n\t\t\tu64 /= 10;\r\n\t\t} while (u64 > 0);\r\n\r\n\t\tdo {\r\n\t\t\t--p;\r\n\t\t\tstream_.Put(*p);\r\n\t\t} while (p != buffer);\r\n\t}\r\n\r\n\t//! \\todo Optimization with custom double-to-string converter.\r\n\tvoid WriteDouble(double d) {\r\n\t\tchar buffer[100];\r\n#if _MSC_VER\r\n\t\tint ret = sprintf_s(buffer, sizeof(buffer), \"%g\", d);\r\n#else\r\n\t\tint ret = snprintf(buffer, sizeof(buffer), \"%g\", d);\r\n#endif\r\n\t\tRAPIDJSON_ASSERT(ret >= 1);\r\n\t\tfor (int i = 0; i < ret; i++)\r\n\t\t\tstream_.Put(buffer[i]);\r\n\t}\r\n\r\n\tvoid WriteString(const Ch* str, SizeType length)  {\r\n\t\tstatic const char hexDigits[] = \"0123456789ABCDEF\";\r\n\t\tstatic const char escape[256] = {\r\n#define Z16 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\r\n\t\t\t//0    1    2    3    4    5    6    7    8    9    A    B    C    D    E    F\r\n\t\t\t'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'b', 't', 'n', 'u', 'f', 'r', 'u', 'u', // 00\r\n\t\t\t'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', // 10\r\n\t\t\t  0,   0, '\"',   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, // 20\r\n\t\t\tZ16, Z16,\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// 30~4F\r\n\t\t\t  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,'\\\\',   0,   0,   0, // 50\r\n\t\t\tZ16, Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16\t\t\t\t\t\t\t\t// 60~FF\r\n#undef Z16\r\n\t\t};\r\n\r\n\t\tstream_.Put('\\\"');\r\n\t\tfor (const Ch* p = str; p != str + length; ++p) {\r\n\t\t\tif ((sizeof(Ch) == 1 || *p < 256) && escape[(unsigned char)*p])  {\r\n\t\t\t\tstream_.Put('\\\\');\r\n\t\t\t\tstream_.Put(escape[(unsigned char)*p]);\r\n\t\t\t\tif (escape[(unsigned char)*p] == 'u') {\r\n\t\t\t\t\tstream_.Put('0');\r\n\t\t\t\t\tstream_.Put('0');\r\n\t\t\t\t\tstream_.Put(hexDigits[(*p) >> 4]);\r\n\t\t\t\t\tstream_.Put(hexDigits[(*p) & 0xF]);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\tstream_.Put(*p);\r\n\t\t}\r\n\t\tstream_.Put('\\\"');\r\n\t}\r\n\r\n\tvoid WriteStartObject()\t{ stream_.Put('{'); }\r\n\tvoid WriteEndObject()\t{ stream_.Put('}'); }\r\n\tvoid WriteStartArray()\t{ stream_.Put('['); }\r\n\tvoid WriteEndArray()\t{ stream_.Put(']'); }\r\n\r\n\tvoid Prefix(Type type) {\r\n\t\t(void)type;\r\n\t\tif (level_stack_.GetSize() != 0) { // this value is not at root\r\n\t\t\tLevel* level = level_stack_.template Top<Level>();\r\n\t\t\tif (level->valueCount > 0) {\r\n\t\t\t\tif (level->inArray) \r\n\t\t\t\t\tstream_.Put(','); // add comma if it is not the first element in array\r\n\t\t\t\telse  // in object\r\n\t\t\t\t\tstream_.Put((level->valueCount % 2 == 0) ? ',' : ':');\r\n\t\t\t}\r\n\t\t\tif (!level->inArray && level->valueCount % 2 == 0)\r\n\t\t\t\tRAPIDJSON_ASSERT(type == kStringType);  // if it's in object, then even number should be a name\r\n\t\t\tlevel->valueCount++;\r\n\t\t}\r\n\t\telse\r\n\t\t\tRAPIDJSON_ASSERT(type == kObjectType || type == kArrayType);\r\n\t}\r\n\r\n\tStream& stream_;\r\n\tinternal::Stack<Allocator> level_stack_;\r\n\r\nprivate:\r\n\t// Prohibit assignment for VC C4512 warning\r\n\tWriter& operator=(const Writer& w);\r\n};\r\n\r\n} // namespace rapidjson\r\n\r\n#ifdef _MSC_VER\r\n#pragma warning(pop)\r\n#endif\r\n\r\n#endif // RAPIDJSON_RAPIDJSON_H_\r\n"
  },
  {
    "path": "src/include/rnn/rnn.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n#ifndef __RNN_HPP\n#define __RNN_HPP\n\n#include <core/smileCommon.hpp>\n\n#ifdef BUILD_RNN\n#include <float.h>\n\n#define MAX_LAYERS 100 // this is used during loading of net config...\n\n#define NNLAYERTYPE_NN 0\n#define NNLAYERTYPE_RNN 1\n#define NNLAYERTYPE_LSTM 2\n\n#define NNLSTMACT_TANHTANHLOGI 11\n#define NNLSTMACT_TANHIDENLOGI 12\n#define NNACT_TANH              1\n#define NNACT_IDEN              2\n#define NNACT_LOGI              3\n\n#define NNTASK_REGRESSION 1\n#define NNTASK_CLASSIFICATION 2\n#define NNTASK_TRANSCRIPTION 3\n\n#define FLOAT_NN float\n\n#define RNN_ERR(level, ...) { fprintf(stderr, \"RNN ERROR: \"); fprintf(stderr, __VA_ARGS__); fprintf(stderr,\"\\n\"); }\n\n\n\nFLOAT_NN nnTf_logistic(FLOAT_NN x);\n\nclass cNnTf {\n  // transfer function class\npublic:\n  // return the value of f(x), where f is the transfer (squashing) function\n  virtual FLOAT_NN f(FLOAT_NN x)=0;\n  virtual ~cNnTf() {}\n};\n\nclass cNnTfTanh : public cNnTf {\n  // transfer function class for tanh transfer function\npublic:\n  // return the value of f(x), where f is the transfer function\n  virtual FLOAT_NN f(FLOAT_NN x) {\n    // tanh transfer function:\n    return (FLOAT_NN)(2.0) * nnTf_logistic((FLOAT_NN)2.0 * x) - (FLOAT_NN)1.0;\n  }\n};\n\nclass cNnTfIdentity : public cNnTf {\n  // transfer function class for tanh transfer function\npublic:\n  // return the value of f(x), where f is the transfer function\n  virtual FLOAT_NN f(FLOAT_NN x) {\n    // tanh transfer function:\n    return x;\n  }\n};\n\nclass cNnTfLogistic : public cNnTf {\n  // transfer function class for logistic transfer function\npublic:\n  // return the value of f(x), where f is the transfer function\n  virtual FLOAT_NN f(FLOAT_NN x) {\n    // logistic transfer function:\n    return nnTf_logistic(x);\n  }\n};\n\n\n\nclass cNnCell {\nprotected:\n  // each cell can have multiple inputs to different units\n  // a standard NN cell will only have one input which is the weighted sum of all the cell inputs\n  // the weighted sum is computed by the cConnection object\n\n  long nInputs;\n\n  // each cell has only one output... except for LSTM blocks with multiple internal cells\n  long nOutputs;\n  FLOAT_NN *cellOutputs;\n  FLOAT_NN cellOutput;\n\n  // the transfer (squashing) function object of this cell\n  cNnTf *transfer;\n  // this is relevant only for debug output messages\n  long layerIndex, cellIndex;  \n\npublic:\n  // if transfer == NULL, then no squashing functions will be applied to the cell/unit output(s)\n  cNnCell(cNnTf *_transfer=NULL, long _cIdx=0, long _lIdx=0) :\n      cellIndex(_cIdx), layerIndex(_lIdx), transfer(_transfer), nOutputs(1), nInputs(1),\n        cellOutputs(NULL), cellOutput(0.0)\n  {\n    // create a cell with nInputs number of units\n  }\n\n  // return the number of inputs (units) in this cell\n  virtual long getInputSize() {\n    return nInputs;\n  }\n  // return the number of outputs of this cell\n  virtual long getOutputSize() {\n    return nOutputs;\n  }\n  \n  virtual void reset() \n  {\n    cellOutput = 0.0;\n  }\n\n\n  // feed data through the cell and compute the cell output(s) (return value)\n  // note: N and the size of *x must match the value returned by getInputSize()\n  virtual const FLOAT_NN *forward(const FLOAT_NN *x, long *N=NULL)=0;\n\n  // get the current output activation\n  virtual const FLOAT_NN *getOutput(long *N=NULL) { if(N!=NULL) *N=1; return &cellOutput; }\n\n  // destroy the cell\n  virtual ~cNnCell() {}\n};\n\n\n// standard feed-forward or recurrent unit, 1 input, 1 output\nclass cNnNNcell : public cNnCell \n{\nprivate:\n\npublic:\n  cNnNNcell(cNnTf *_transfer=NULL, long _cIdx=0, long _lIdx=0) :\n    cNnCell(_transfer, _cIdx, _lIdx)\n  {}\n\n  // feed data through the cell and compute the cell output (return value)\n  // note: N and the size of *x must match the value returned by getInputSize()\n  virtual const FLOAT_NN *forward(const FLOAT_NN *x, long *N=NULL) \n  {\n    // the input should only be 1 value (weighted sum of inputs, handled by the connection)\n    // thus we apply the transfer function and have the output value :)\n    if (transfer != NULL) {\n      cellOutput = transfer->f(*x);\n    } else {\n      cellOutput = *x;\n    }\n    // set the number of outputs..\n    if (N!=NULL) *N = 1;\n\n    return (const FLOAT_NN*)&cellOutput;\n  }\n\n};\n\n\n// LSTM block or cell\nclass cNnLSTMcell : public cNnNNcell {\nprivate:\n  // LSTM cells require the cell state to be saved:\n  long nCells;\n  FLOAT_NN *sc;  // cell state(s)\n\n\n  // weights array for LSTM cells:\n  // we have 4 weights for each input connection, 4*N total weights (N=nInput)\n                                                   //NO!! 1...N inGate , 1...N forget Gate,  1..N outGate, 1...N cell input\n  // in1, fg1, cellIn1, outgate1, in2, ..\n   // for multiple cells per block: in1C1, in1C2, ..., fg1C1, fg1C2, ..., in2C1, in2C2, ...\n\n  // the peep weights are in the following order:\n  // inp1, forget1, out1, inp2, ...\n  // for multiple cells per block, see above...\n\n  // transfer functions for cell state output and gate ouputs:\n  cNnTf * transferOut;\n  cNnTf * transferGate;\n\n  // peephole weights:\n  long nPeeps; \n  FLOAT_NN *peep;\n\npublic:\n  cNnLSTMcell(cNnTf *_transferIn, cNnTf *_transferOut, cNnTf *_transferGate, long _cellsPerBlock=1, long _cIdx=0, long _lIdx=0) :\n      cNnNNcell(_transferIn, _cIdx, _lIdx), nCells(_cellsPerBlock), \n      peep(NULL),\n      transferOut(_transferOut), transferGate(_transferGate)\n  {\n    // create a cell with nInputs to each unit\n    nInputs = nCells+3;\n    nOutputs = nCells;\n    // create cell states...\n    sc = (FLOAT_NN*)calloc(1,sizeof(FLOAT_NN)*nCells);\n    // create cell outputs...\n    cellOutputs = (FLOAT_NN*)calloc(1,sizeof(FLOAT_NN)*nCells);\n  }\n\n  void setPeepWeights(FLOAT_NN *x, long N, int copy);\n\n  // reset the cell\n  virtual void reset();\n\n  // feed data through the cell and compute the cell output (return value)\n  // note: for an lstm block with nCells > 1, the number of output values will be > 1... how to handle this??\n  virtual const FLOAT_NN * forward(const FLOAT_NN *x, long *N=NULL);\n\n  ~cNnLSTMcell() {\n    //if (transferOut != NULL) delete transferOut;\n    //if (transferGate != NULL) delete transferGate;\n    if (sc != NULL) free(sc);\n    if (cellOutputs != NULL) free(cellOutputs);\n    if (peep != NULL) free(peep);\n  }\n};\n\n\n\n/* a layer in the net */\nclass cNnLayer {\nprotected:\n  int direction; // 0 == forward, 1 == reverse\n  // a layer contains a set of cells or blocks which again contain cells\n  long layerIdx; \n  long nCells; // nInputsTotal, nUnitsPerCell;\n  long nContext;\n  char *name;\n\n  long nCellOutputs, nCellInputs;\n  long nOutputs, nInputs;\n  cNnCell **cell;\n  // TODO. for on-line BRNN we require output to be 2D, buffering X past states..\n  FLOAT_NN *output; // <-- cyclic buffer\n  long curPtr;  // <- the current frame pointer (to the next uninitialised frame...)\n  long nDelayed; // <- number of delayed output frames currently in buffer (0 if only the current frame is available)\n\n  // this function creates the output buffers and does some initialisation, \n  //  after the cell objects have been created and we know the layer dimensions\n  void afterCreateCells() \n  {\n    if ((cell!=NULL) && (cell[0] != NULL)) {\n      nCellInputs = cell[0]->getInputSize();\n      nCellOutputs = cell[0]->getOutputSize();\n    }\n    if (nCells > 0) {\n      nInputs = nCells * nCellInputs;\n      nOutputs = nCells * nCellOutputs;\n    }\n    if (nOutputs > 0)\n      output = (FLOAT_NN*)calloc(1,sizeof(FLOAT_NN)*nOutputs*(nContext+1));\n    curPtr = 0;\n    nDelayed = 0; // we init with 0 because always the first frame (all 0) is available\n  }\n\npublic:\n  // create a layer which has nInput connections for each cell\n  cNnLayer(long _nCells, int _layerIdx=0, int _direction=0, long _nContext=0) : \n      nCells(_nCells), layerIdx(_layerIdx), cell(NULL), output(NULL), direction(_direction), nContext(_nContext), name(NULL)\n  {\n    if (_nCells > 0) \n      cell = (cNnCell**)calloc(1,sizeof(cNnCell*)*nCells);\n    if (nContext < 0) nContext = 0;\n  }\n\n  int isReverse() { return direction; }\n  \n  // set the human readable name of this layer (required only for debug output)\n  void setName(const char *_name ) \n  { \n    if (name != NULL) free(name);\n    if (_name != NULL) name = strdup(_name); \n  }\n  \n  // get the human readable name of this layer\n  const char *getName() { return (const char *)name; }\n\n  // return the layer index assigned by the rnn net class when this layer was created\n  long getLayerIdx() { return layerIdx; }\n\n  // feed data forward, N must match the layer's input size (nInputs)\n  virtual void forward(FLOAT_NN *x, long N);\n\n  // get the output activations\n  const FLOAT_NN * getOutput(long *N, long delay=0) \n  {\n    if (N!=NULL) *N = nOutputs;\n    if (delay == 0) {\n      return (const FLOAT_NN*)output;\n    } else {\n      if (delay > nContext) delay = nContext;\n      long idx = (nContext+curPtr-delay)%nContext;\n      return ((const FLOAT_NN*)output)+idx;\n    }\n  }\n\n  virtual void resetLayer();\n\n  // check whether output is available\n  // for forward layers this always returns 1 (true)\n  // for reverse layers this only returns 1 (true) if the output (ring-)buffer is full\n  int outputAvailable() {\n    if (direction) {\n//      printf(\"nD:%i nC:%i \",nDelayed,nContext);\n      if (nDelayed >= nContext) return 1;\n    } else {\n      return 1;\n    }\n    return 0;\n  }\n  //TODO: we also require   a function to query the current context buffer state\n  //long getNdelayed() { return nDelayed; }\n\n  virtual long getOutputSize() { return nOutputs; }\n  virtual long getInputSize() { return nInputs; }\n  long getNContext() { return nContext; }\n\n  virtual ~cNnLayer() {\n    long i;\n    if (cell != NULL) {\n      for (i=0; i<nCells; i++) {\n        if (cell[i] != NULL) delete(cell[i]);\n      }\n      free(cell);\n    }\n    if (output != NULL) free(output);\n    if (name != NULL) free(name);\n  }\n\n};\n\n/**************************** cNnNNlayer *******************************************/\n\nclass cNnNNlayer : public cNnLayer {\nprotected: \n  cNnTf *_tf;\n\npublic:\n  cNnNNlayer(long _nCells, int _layerIdx=0, int _direction=0, long _nContext=0) : cNnLayer(_nCells, _layerIdx, _direction, _nContext), _tf(NULL) {}\n\n  // create the cells for this layer\n  void createCells(cNnTf *_transfer) {\n    long i;\n    for (i=0; i<nCells; i++) {\n      cell[i] = new cNnNNcell(_transfer,i,layerIdx);\n    }\n    _tf = _transfer; // NOTE: the transfer function object will be freed by the layer, since it is allocated only once and the same pointer is passed to all cells...\n    afterCreateCells();\n  }\n\n  ~cNnNNlayer() {\n    if (_tf != NULL) delete _tf;\n  }\n};\n\n/**************************** cNnSoftmaxLayer *******************************************/\n\nclass cNnSoftmaxLayer : public cNnLayer {\nprotected: \n  double expLim;\n\npublic:\n  cNnSoftmaxLayer(int _nOutputs, int _layerIdx=0, int _direction=0, long _nContext=0) : cNnLayer(0, _layerIdx, _direction, _nContext), expLim(log(DBL_MAX)) \n  {\n    nInputs = _nOutputs;\n    nOutputs = _nOutputs; \n    afterCreateCells();\n  }\n\n  // create the cells for this layer, dummy function here...\n  void createCells() {\n    \n  }\n\n  virtual void forward(FLOAT_NN *x, long N);\n\n  ~cNnSoftmaxLayer() {\n  }\n};\n\n/**************************** cNnLSTMlayer *******************************************/\n\nclass cNnLSTMlayer : public cNnLayer {\nprotected: \n  cNnTf  *_tf, *_tfO, *_tfG;\n\npublic:\n  cNnLSTMlayer(long _nCells, int _layerIdx=0, int _direction=0, long _nContext=0) : cNnLayer(_nCells, _layerIdx, _direction, _nContext), _tf(NULL), _tfO(NULL), _tfG(NULL) {}\n\n  // create the cells for this layer\n  void createCells(cNnTf *_transferIn, cNnTf *_transferOut, cNnTf *_transferGate, long _cellsPerBlock=1) {\n    int i;\n    for (i=0; i<nCells; i++) {\n      cell[i] = new cNnLSTMcell(_transferIn, _transferOut, _transferGate, _cellsPerBlock, i, layerIdx);\n    }\n    _tf = _transferIn;\n    _tfO = _transferOut;\n    _tfG = _transferGate;\n    afterCreateCells();\n  }\n\n  // set the LSTM cells' peephole weights: input is a vector with all weights for all cells in this layer\n  virtual void setPeepWeights(FLOAT_NN *_peep, long N, int copy=1) \n  { \n    long i;\n    for (i=0; i<nCells; i++) {\n      ((cNnLSTMcell*)(cell[i]))->setPeepWeights(_peep+i*3,3,copy);\n    }\n  }\n\n  ~cNnLSTMlayer() {\n    if (_tf != NULL) delete _tf;\n    if (_tfO != NULL) delete _tfO;\n    if (_tfG != NULL) delete _tfG;\n  }\n};\n\n/**************************************************************************************/\n/**************************** cNnConnection *******************************************/\n/**************************************************************************************/\n\nclass cNnConnection {\nprotected:\n  int bidirectional;\n  // a connection requires memory for recurrent connections , and connects output with inputs\n  int nInputs; int inpCnt;\n  cNnLayer **input;\n  cNnLayer *output;\n  // vector sizes:\n  long inputSize;\n  long *inputStart;\n  long outputSize;\n\n  // connection weights\n  long nWeights;\n  FLOAT_NN *weight;\n  // bias weights\n  long nBias;\n  FLOAT_NN *bias;\n\n  // current output vector:\n  FLOAT_NN *outputs;\n\npublic:\n  // create the connection, which forwards to the output layer _output, and which has _nInputs input layers\n  cNnConnection(cNnLayer *_output, int _nInputs, int _bidirectional=0) :\n      output(_output), nInputs(_nInputs), inpCnt(0), bias(NULL), weight(NULL), outputs(NULL), bidirectional(_bidirectional)\n  {\n    input = (cNnLayer**)calloc(1,sizeof(cNnLayer*)*nInputs);\n    inputStart = (long*)malloc(sizeof(long*)*nInputs);\n  }\n\n  // connect an input layer to the connection, return layer index\n  int connectLayer(cNnLayer *_input)\n  {\n    input[inpCnt] = _input;\n    return inpCnt++;\n  }\n\n  // initialise connection parameters after all input layers have been added...\n  void initialise(long _bidir_bufsize=0);\n\n  // set the connection weights from one large array (which has been loaded from the net config file) for one input layer..\n  // call only after initialise()\n  void setWeights(FLOAT_NN *_weights, long N, int _layerIdx) {\n    if (N!=input[_layerIdx]->getOutputSize()*outputSize) {\n      RNN_ERR(1,\"number of weights mismatch for layer %i in connection->setWeights: number weights = %i, expected %i\",_layerIdx,N,input[_layerIdx]->getOutputSize()*outputSize);\n    }\n    //XX//fprintf(stderr,\"setWW %i %i N=%i\\n\",(inputStart[_layerIdx]*outputSize),_layerIdx,N);\n    memcpy(weight+(inputStart[_layerIdx]*outputSize), _weights, N*sizeof(FLOAT_NN));\n  }\n\n  virtual void setBias(FLOAT_NN *_bias, long N) \n  { \n    //XX//printf(\"outputSize:%i, nBias:%i, _N:%i  bias:%i  _bias:%i \\n\",output->getInputSize(),nBias,N,bias,_bias);\n    memcpy(bias, _bias, N*sizeof(FLOAT_NN));\n  }\n\n\n  // forward data (one timestep) from the input layers to the output layer\n  virtual void forward();\n\n  // print human readable connection information \n  void printInfo();\n\n  virtual ~cNnConnection()\n  {\n    if (inputStart!=NULL) free(inputStart);\n    if (outputs != NULL) free(outputs);\n    if (bias != NULL) free(bias);\n    if (weight != NULL) free(weight);\n    //if (output != NULL) delete output;\n    if (input != NULL) {\n      /*  // We do NOT free the input layers here, since an input layer may be connected to multiple connections and thus it may get freed multiple times\n      int i;\n      for (i=0; i<nInputs; i++) {\n        if (input[i] != NULL) delete input[i];\n      }*/\n      free(input);\n    }\n  }\n};\n\n\n\n/**************************************************************************************/\n/**************************** cNnRnn **************************************************/\n/**************************************************************************************/\n\n\n/* the RNN class */\nclass DLLEXPORT cNnRnn  {\nprotected:\n  // a net consists of layers and connections\n  int nLayers; \n  int curLidx;\n  int nConnections;\n  cNnLayer **layer;\n  cNnConnection **connection;\n\npublic:\n  cNnRnn(int _nLayers, int _nConnections=-1) : nLayers(_nLayers), nConnections(_nConnections), curLidx(0)\n  {\n    if (nConnections == -1) nConnections = nLayers-1;\n    layer = (cNnLayer**)calloc(1,sizeof(cNnLayer*)*nLayers);\n    connection = (cNnConnection**)calloc(1,sizeof(cNnConnection*)*(nConnections+1));\n  }\n\n  // add layers to the net....\n  // idx == -1 : add as next layer, else add as layer with index 'idx' (0..nLayers-1)\n  void addLayer(cNnLayer *_l, int idx=-1) \n  {\n    if (idx < 0) idx = curLidx++;\n    layer[idx] = _l;\n  }\n\n  //// create the connections *after* adding *all* layers!\n  // create a connection to the inputs of a layer with index >1\n  void connectTo(int toLayer, int lN) \n  {\n    if (toLayer > 0) {\n      connection[toLayer] = new cNnConnection(layer[toLayer], lN);\n    }\n  }\n\n  // after calling connectTo (which creates the connection), call connectFrom '_N' times to connect the input layers\n  // the return value is the input index (idxF_local), which must be used when setting weights for this connection!\n  int connectFrom(int fromLayer, int toLayer) \n  {\n    if (connection[toLayer] != NULL) {\n      return connection[toLayer]->connectLayer(layer[fromLayer]);\n    }\n    return -1;\n  }\n\n  void initialise(int idx=-1) {\n    if (idx < 0) {\n      int i;\n      for (i=0; i<nConnections; i++) connection[i]->initialise();\n    } else {\n      connection[idx]->initialise();\n    }\n  }\n\n  void setWeights(int idxF_local, int idxT, FLOAT_NN *x, long N)\n  {\n    if ((idxT >= 0)&&(idxT<=nConnections)&&(idxF_local >= 0)&&(connection[idxT] != NULL))\n      connection[idxT]->setWeights(x,N,idxF_local);\n  }\n\n  void setBias(int idxT, FLOAT_NN *x, long N)\n  {\n    if ((idxT >= 0)&&(idxT<=nConnections)&&(connection[idxT] != NULL))\n      connection[idxT]->setBias(x,N);\n  }\n\n  // feed data forward through the net and compute the next output activations vector\n  void forward(FLOAT_NN *x, long N);\n\n  // read the output activations vector\n  const FLOAT_NN * getOutput(long *N)\n  {\n    return layer[nLayers-1]->getOutput(N);\n  }\n\n  // print the connections in human readable format to the log\n  void printConnections();\n\n  virtual ~cNnRnn() {\n    // delete the layers and the connections\n    long i;\n    if (layer != NULL) {\n      for (i=0; i<nLayers; i++) {\n        if (layer[i] != NULL) delete layer[i];\n      }\n      free(layer);\n    }\n    if (connection != NULL) {\n      for (i=0; i<= nConnections; i++) {\n        if (connection[i] != NULL) {\n          delete connection[i];\n        }\n      }\n      free(connection);\n    }\n  }\n};\n\n\n\n/***************************************************************************************/\n\n// variables for layer type must be 32 bit unsigned long!\n// lower bits < 1024 : layer number (0 for bias, etc.)\n#define LAYER_BIAS    1024\n#define LAYER_HIDDEN  2048\n#define LAYER_DIR_FWD 4096\n#define LAYER_DIR_RWD 8192\n#define LAYER_INPUT   8192*2\n#define LAYER_OUTPUT  8192*4\n#define LAYER_PEEPHOLES 8192*8\n#define LAYER_HIDDEN_GATHER  8192*16\n#define LAYER_SUBSAMPLE  8192*32\n\nclass DLLEXPORT cRnnWeightVector {\npublic:\n  long nWeights;\n  FLOAT_NN *weights;\n  char from[102];\n  char to[102];\n  long F,T; // From, To as int constants (or'ed)\n\n  cRnnWeightVector(long N) : nWeights(N) {\n    weights = (FLOAT_NN*)calloc(1,sizeof(FLOAT_NN)*N);\n    from[0] = 0; to[0] = 0;\n  }\n  ~cRnnWeightVector() {\n    free(weights);\n  }\n};\n\n// data of parsed rnn net file\nclass DLLEXPORT cRnnNetFile {\npublic:\n  int loaded;\n  int nHiddenLayers; // the number of hidden layers!!\n  long inputSize, outputSize;\n  long hiddenSize[MAX_LAYERS];\n  int hiddenType[MAX_LAYERS];\n  int hiddenActType[MAX_LAYERS];\n  int cellsPerBlock;\n  int bidirectional;\n  long nContext; // -1 : whole sequence (TODO...), 0 : no context (unidirectional only), >0 : number of future frames to buffer before output is generated\n  int task;\n  int nWeightVectors;\n  cRnnWeightVector * wv[4*MAX_LAYERS];\n\n  cRnnNetFile() : nWeightVectors(0), nHiddenLayers(0), loaded(0) {\n    int i;\n    for (i=0; i<4*MAX_LAYERS; i++) { wv[i] = NULL; }\n  }\n  ~cRnnNetFile() {\n    int i;\n    for (i=0; i<4*MAX_LAYERS; i++) { if (wv[i] != NULL) delete wv[i]; }\n  }\n};\n\n// load and parse a saved network file\nDLLEXPORT int smileRnn_loadNetJson(const char *filename, cRnnNetFile &net);\n\n// load and parse a saved network file\nDLLEXPORT int smileRnn_loadNet(const char *filename, cRnnNetFile &net);\n\n//creat a cNnRnn class instance from a loaded network file\nDLLEXPORT int smileRnn_createNet(cRnnNetFile &net, cNnRnn *&rnn, int printConnections=1);\n\n// get the input weight statistics\nDLLEXPORT int smileRnn_getInputSelection(cRnnNetFile &net, FLOAT_NN **weights);\n\n#endif // BUILD_RNN\n#endif // __RNN_HPP\n"
  },
  {
    "path": "src/include/rnn/rnnProcessor.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nBLSTM RNN processor\n\n*/\n\n\n#ifndef __CRNNPROCESSOR_HPP\n#define __CRNNPROCESSOR_HPP\n\n#include <core/smileCommon.hpp>\n\n#ifdef BUILD_RNN\n#include <core/dataProcessor.hpp>\n#include <rnn/rnn.hpp>\n\n#define COMPONENT_DESCRIPTION_CRNNPROCESSOR \"BLSTM RNN processor.\"\n#define COMPONENT_NAME_CRNNPROCESSOR \"cRnnProcessor\"\n\n#undef class\nclass DLLEXPORT cRnnProcessor : public cDataProcessor {\n  private:\n    const char *netfile;\n    char *classlabels_;\n    const char **classlabelArr_;\n    long nClasses;\n    cNnRnn *rnn;\n    cRnnNetFile net;\n    FLOAT_NN *in;\n    FLOAT_DMEM *out;\n    int printConnections;\n    cVector *frameO;\n    int jsonNet;\n    int net_created_;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n    virtual int setupNewNames(long nEl);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cRnnProcessor(const char *_name);\n\n    virtual ~cRnnProcessor();\n};\n\n\n#endif // BUILD_RNN\n\n#endif // __CRNNPROCESSOR_HPP\n"
  },
  {
    "path": "src/include/rnn/rnnSink.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample dataSink:\nreads data from data memory and outputs it to console/logfile (via smileLogger)\nthis component is also useful for debugging\n\n*/\n\n\n#ifndef __CRNNSINK_HPP\n#define __CRNNSINK_HPP\n\n#include <core/smileCommon.hpp>\n\n#ifdef BUILD_RNN\n#include <core/dataSink.hpp>\n#include <rnn/rnn.hpp>\n\n#define COMPONENT_DESCRIPTION_CRNNSINK \"This is an example of a cDataSink descendant. It reads data from the data memory and prints it to the console. This component is intended as a template for developers.\"\n#define COMPONENT_NAME_CRNNSINK \"cRnnSink\"\n\n#undef class\n\n\n\n\nclass DLLEXPORT cRnnSink : public cDataSink {\n  private:\n    FILE *outfile;\n    FILE *outfileC;\n    const char *netfile;\n    const char *actoutput;\n    const char *classoutput;\n    char *classlabels;\n    const char **classlabelArr;\n    long nClasses;\n    int ctcDecode;\n    cNnRnn *rnn;\n    cRnnNetFile net;\n    FLOAT_NN *in;\n    FLOAT_DMEM *out;\n    int lasti;\n    int printConnections;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    //cRnnWeightVector *createWeightVectorFromLine(char *line);\n    //int loadNet(const char *filename);\n    \n//    int findPeepWeights(unsigned long id);\n    //int findWeights(unsigned long idFrom, unsigned long idTo);\n    //cNnLSTMlayer *createLstmLayer(int i, int idx, int dir=LAYER_DIR_FWD);\n    // create a network from a successfully loaded net config file (loadNet function)\n    //int createNet();\n    \n    virtual void fetchConfig();\n    virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cRnnSink(const char *_name);\n\n    virtual ~cRnnSink();\n};\n\n\n#endif // BUILD_RNN\n\n#endif // __CRNNSINK_HPP\n"
  },
  {
    "path": "src/include/rnn/rnnVad2.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nBLSTM RNN processor\n\n*/\n\n\n#ifndef __CRNNVAD2_HPP\n#define __CRNNVAD2_HPP\n\n#include <core/smileCommon.hpp>\n#include <core/dataProcessor.hpp>\n#include <rnn/rnn.hpp>\n\n#define COMPONENT_DESCRIPTION_CRNNVAD2 \"BLSTM RNN processor.\"\n#define COMPONENT_NAME_CRNNVAD2 \"cRnnVad2\"\n\n#undef class\n\n\n/* ring buffer average computation over holdTime + decayTime segments */\n/* hold of max over holdTime, decay over decayTime */\nclass cEavgHold \n{\nprivate:\n  /* moving average */\n  FLOAT_DMEM *Ebuf;\n  long EbufSize, nAvg;\n  long EbufPtr, EbufPtrOld;\n  double EavgSumCur;\n  FLOAT_DMEM EmaxRiseAlpha; /* alpha for exponential rise smoothing of max energy: 1= rise immediately, 0=do not follow input */\n\n  /* envelope */\n  FLOAT_DMEM Emax;\n  long EmaxAge;\n  FLOAT_DMEM EmaxDecayStep;\n\n  int holdTime;\n  int decayTime;\n\npublic:\n  /* holdTime and decayTime in frames/samples */\n  cEavgHold(int _holdTime, int _decayTime, int _decayFunct=0, FLOAT_DMEM _EmaxRiseAlpha=0.2) :\n      holdTime(_holdTime),\n      decayTime(_decayTime),\n      EmaxRiseAlpha(_EmaxRiseAlpha)\n  {\n    if (decayTime <= 0) decayTime = 1;\n    if (holdTime <= 0) holdTime = 1;\n\n    EbufSize = holdTime + decayTime;\n    EbufPtr = 0;\n    EbufPtrOld = 0;\n    Ebuf = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*EbufSize);\n    EavgSumCur = 0.0; nAvg = 0;\n    Emax = 0.0;\n    EmaxAge = 0;\n    EmaxDecayStep = 0.0;\n  }\n\n  /* add next input to buffer */\n  void nextE(FLOAT_DMEM E)\n  {\n    /* average: */\n    EavgSumCur -= Ebuf[EbufPtrOld];\n    Ebuf[EbufPtr] = E;\n    EbufPtrOld = EbufPtr++;\n    EavgSumCur += E;\n    if (EbufPtr >= EbufSize) EbufPtr %= EbufSize;\n    if (nAvg < EbufSize) nAvg++;\n    /* envelope: */\n    if (E > Emax) {\n      Emax = Emax*((FLOAT_DMEM)1.0-EmaxRiseAlpha) + E*EmaxRiseAlpha;\n      EmaxDecayStep = Emax/(FLOAT_DMEM)decayTime;\n      EmaxAge = 0;\n    } else {\n      EmaxAge++;\n      if (EmaxAge > holdTime && EmaxAge < holdTime+decayTime && Emax > EmaxDecayStep) {\n        Emax -= EmaxDecayStep;\n      }\n    }\n  }\n\n  /* get the current short-term average */\n  FLOAT_DMEM getAvg() \n  {\n    if (nAvg > 100 || nAvg >= EbufSize) {\n      return (FLOAT_DMEM) ( EavgSumCur / (double)nAvg ) ;\n    } else { return 0.0; }\n  }\n\n  /* get the current envelope (max. hold) */\n  FLOAT_DMEM getEnv() \n  {\n    if (nAvg > 100  || nAvg >= EbufSize) return Emax;\n    else return 0.0;\n  }\n\n  ~cEavgHold()\n  {\n    if (Ebuf != NULL) free(Ebuf);\n  }\n};\n\n\nclass DLLEXPORT cRnnVad2 : public cDataProcessor {\n  private:\n    cEavgHold * eUser;\n    cEavgHold * eCurrent;\n    cEavgHold * eAgent;\n    cEavgHold * eBg;\n    \n    long voiceIdx, agentIdx, energyIdx, f0Idx;\n\n    long cnt; \n    int isV;\n    int vadDebug, allowEoverride;\n    cVector *frameO;\n    \n    FLOAT_DMEM voiceThresh, agentThresh;\n    \n    //long agentBlockTime;\n    long agentTurnCntdn;\n    long agentTurnPastBlock;\n    int alwaysRejectAgent, smartRejectAgent;\n    int doReset, agentTurn, userPresence;\n    long userCnt, agentCntdn;\n\n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n\n    virtual void fetchConfig();\n    //virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n    virtual int processComponentMessage( cComponentMessage *_msg );\n\n    virtual int setupNewNames(long nEl);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cRnnVad2(const char *_name);\n\n    virtual ~cRnnVad2();\n};\n\n\n\n\n#endif // __CRNNVAD2_HPP\n"
  },
  {
    "path": "src/include/smileutil/JsonClasses.hpp",
    "content": "/*F***************************************************************************\r\n * \r\n * openSMILE - the Munich open source Multimedia Interpretation by \r\n * Large-scale Extraction toolkit\r\n * \r\n * This file is part of openSMILE.\r\n * \r\n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\r\n * \r\n * See file \"COPYING\" for details on usage rights and licensing terms.\r\n * By using, copying, editing, compiling, modifying, reading, etc. this\r\n * file, you agree to the licensing terms in the file COPYING.\r\n * If you do not agree to the licensing terms,\r\n * you must immediately destroy all copies of this file.\r\n * \r\n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\r\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\r\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\r\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\r\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\r\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\r\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\r\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\r\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\r\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\r\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\r\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\r\n * THE SOFTWARE OR DERIVATIVE WORKS.\r\n * \r\n * Main authors: Florian Eyben, Felix Weninger, \r\n *            Martin Woellmer, Bjoern Schuller\r\n * \r\n * Copyright (c) 2008-2013, \r\n *   Institute for Human-Machine Communication,\r\n *   Technische Universitaet Muenchen, Germany\r\n * \r\n * Copyright (c) 2013-2015, \r\n *   audEERING UG (haftungsbeschraenkt),\r\n *   Gilching, Germany\r\n * \r\n * Copyright (c) 2016,   \r\n *   audEERING GmbH,\r\n *   Gilching Germany\r\n ***************************************************************************E*/\r\n\r\n#ifndef SMILEUTIL_JSONCLASSES_HPP\r\n#define SMILEUTIL_JSONCLASSES_HPP\r\n\r\n#include <smileutil/JsonClassesForward.hpp>\r\n#include <rapidjson/document.h>\r\n#include <rapidjson/writer.h>\r\n#include <rapidjson/stringbuffer.h>\r\n#include <rapidjson/reader.h>\r\n\r\nnamespace smileutil {\r\nnamespace json {\r\n    class JsonValue\r\n    {\r\n    private:\r\n        mutable rapidjson::Value *_p;\r\n\r\n    public:\r\n        JsonValue()\r\n            : _p(NULL)\r\n        {\r\n        }\r\n\r\n        JsonValue(rapidjson::Value *p)\r\n            : _p(p)\r\n        {\r\n        }\r\n\r\n        bool isValid() const\r\n        {\r\n            return (_p != NULL);\r\n        }\r\n\r\n        rapidjson::Value* operator-> () const\r\n        {\r\n            return _p;\r\n        }\r\n\r\n        rapidjson::Value& operator* () const\r\n        {\r\n            return *_p;\r\n        }\r\n    };\r\n\r\n    class JsonAllocator\r\n    {\r\n    private:\r\n        mutable rapidjson::MemoryPoolAllocator<> *_p;\r\n\r\n    public:\r\n        JsonAllocator(rapidjson::MemoryPoolAllocator<> *p)\r\n            : _p(p)\r\n        {\r\n        }\r\n\r\n        rapidjson::MemoryPoolAllocator<>* operator-> () const\r\n        {\r\n            return _p;\r\n        }\r\n\r\n        operator rapidjson::MemoryPoolAllocator<>& () const\r\n        {\r\n            return *_p;\r\n        }\r\n    };\r\n\r\n    class JsonDocument\r\n    {\r\n    private:\r\n        mutable rapidjson::Document *_p;\r\n\r\n    public:\r\n        JsonDocument(rapidjson::Document *p)\r\n            : _p(p)\r\n        {\r\n        }\r\n\r\n        JsonDocument(rapidjson::Document &p)\r\n            : _p(&p)\r\n        {\r\n        }\r\n\r\n        rapidjson::Document* operator-> () const\r\n        {\r\n            return _p;\r\n        }\r\n\r\n        rapidjson::Document& operator* () const\r\n        {\r\n            return *_p;\r\n        }\r\n\r\n        operator rapidjson::Document& () const\r\n        {\r\n            return *_p;\r\n        }\r\n    };\r\n\r\n}  // namespace json\r\n}  // namespace smileutil\r\n\r\n\r\n#endif // SMILEUTIL_JSONCLASSES_HPP\r\n"
  },
  {
    "path": "src/include/smileutil/JsonClassesForward.hpp",
    "content": "/*F***************************************************************************\r\n * \r\n * openSMILE - the Munich open source Multimedia Interpretation by \r\n * Large-scale Extraction toolkit\r\n * \r\n * This file is part of openSMILE.\r\n * \r\n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\r\n * \r\n * See file \"COPYING\" for details on usage rights and licensing terms.\r\n * By using, copying, editing, compiling, modifying, reading, etc. this\r\n * file, you agree to the licensing terms in the file COPYING.\r\n * If you do not agree to the licensing terms,\r\n * you must immediately destroy all copies of this file.\r\n * \r\n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\r\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\r\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\r\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\r\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\r\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\r\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\r\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\r\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\r\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\r\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\r\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\r\n * THE SOFTWARE OR DERIVATIVE WORKS.\r\n * \r\n * Main authors: Florian Eyben, Felix Weninger, \r\n *            Martin Woellmer, Bjoern Schuller\r\n * \r\n * Copyright (c) 2008-2013, \r\n *   Institute for Human-Machine Communication,\r\n *   Technische Universitaet Muenchen, Germany\r\n * \r\n * Copyright (c) 2013-2015, \r\n *   audEERING UG (haftungsbeschraenkt),\r\n *   Gilching, Germany\r\n * \r\n * Copyright (c) 2016,   \r\n *   audEERING GmbH,\r\n *   Gilching Germany\r\n ***************************************************************************E*/\r\n\r\n#ifndef SMILEUTIL_JSONCLASSESFORWARD_HPP\r\n#define SMILEUTIL_JSONCLASSESFORWARD_HPP\r\n\r\nnamespace smileutil {\r\nnamespace json {\r\n\r\n    class JsonValue;\r\n    class JsonAllocator;\r\n    class JsonDocument;\r\n\r\n    int safeJsonGetInt(const JsonValue &val, const char *name);\r\n    \r\n    template <typename T>\r\n    T checkedJsonGet(const JsonDocument &jsonDoc, const char *varName);\r\n\r\n}  // namespace json\r\n}  // namespace smileutil\r\n\r\n\r\n#endif // SMILEUTIL_JSONCLASSESFORWARD_HPP\r\n"
  },
  {
    "path": "src/include/smileutil/smileUtil.h",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  SmileUtil\n    =========\n\ncontains modular DSP functions\nand other utility functions\n\n*/\n\n\n#ifndef __SMILE_UTIL_H\n#define __SMILE_UTIL_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* you may remove this include if you are using smileUtil outside of openSMILE */\n//#include <smileCommon.hpp>\n/* --------------------------------------------------------------------------- */\n#ifndef __SMILE_COMMON_H\n#define __SMILE_COMMON_H\n\n// this is a minimal set of defines if we are using smileUtil outside of openSMILE\n// on linux you should consider compiling with -DHAVE_INTTYPES_H option (see smileTypes.h)\n\n#ifdef HAVE_CONFIG_H\n#include <config.h>\n#endif\n\n#ifdef _MSC_VER // Visual Studio specific macro\n  #ifdef BUILDING_DLL\n    #define DLLEXPORT __declspec(dllexport)\n//    #define class class __declspec(dllexport)\n  #else\n    #define DLLEXPORT __declspec(dllimport)\n//    #define class class __declspec(dllimport)\n  #endif\n  #define DLLLOCAL \n#else \n    #define DLLEXPORT \n    #define DLLLOCAL  \n#endif\n\n#include <stdlib.h>\n#include <stdio.h>\n\n#endif  // __SMILE_COMMON_H\n\n\n#ifndef __SMILE_LOGGER_HPP\n#define __SMILE_LOGGER_HPP\n#define LOGLEVEL 2\n#define SMILE_PRINT(...) fprintf(stderr,__VA_ARGS__)\n#define SMILE_PRINTL(level, ...) { if (level <= LOGLEVEL) fprintf(stderr,__VA_ARGS__); }\n\n#define SMILE_MSG(level, ...) { if (level <= LOGLEVEL) { fprintf(stderr,\"MSG(%i): \",level) ; fprintf(stderr,__VA_ARGS__); } }\n#define SMILE_IMSG(level, ...) { if (level <= LOGLEVEL) { fprintf(stderr,\"MSG(%i): \",level) ; fprintf(stderr,__VA_ARGS__); } }\n\n#define SMILE_ERR(level, ...) { if (level <= LOGLEVEL) { fprintf(stderr,\"ERR(%i): \",level) ; fprintf(stderr,__VA_ARGS__); } }\n#define SMILE_IERR(level, ...) { if (level <= LOGLEVEL) { fprintf(stderr,\"ERR(%i): \",level) ; fprintf(stderr,__VA_ARGS__); } }\n\n#define SMILE_WRN(level, ...) { if (level <= LOGLEVEL) { fprintf(stderr,\"WRN(%i): \",level) ; fprintf(stderr,__VA_ARGS__); } }\n#define SMILE_IWRN(level, ...) { if (level <= LOGLEVEL) { fprintf(stderr,\"WRN(%i): \",level) ; fprintf(stderr,__VA_ARGS__); } }\n\n\n#ifdef DEBUG\n#define SMILE_DBG(level, ...) { if (level <= LOGLEVEL) { fprintf(stderr,\"DBG(%i): \",level) ; fprintf(stderr,__VA_ARGS__); } }\n#define SMILE_IDBG(level, ...) { if (level <= LOGLEVEL) { fprintf(stderr,\"DBG(%i): \",level) ; fprintf(stderr,__VA_ARGS__); } }\n#endif\n#endif  // __SMILE_LOGGER_HPP\n\n// TODO: use android logprint on android! -> platform independent fprintf!\n\n#include <core/smileTypes.h>\n#include <smileutil/smileUtilSpline.h>\n#ifdef BUILD_WITH_AUDEERING_LIBS\n#include <smileutil/smileUtilDspaudeering.h>\n#endif\n\n#ifndef __cplusplus\ntypedef enum {false, true} bool;\n#endif\n\n// --- mathematics ----::\n\n#define MIN( a, b ) ((a < b) ? a : b)\n#define MAX( a, b ) ((a > b) ? a : b)\n\n\n/*******************************************************************************************\n ***********************=====   Misc functions   ===== **************************************\n *******************************************************************************************/\n\nDLLEXPORT int smileUtil_stripline(char ** _line);\n\n/*******************************************************************************************\n ***********************=====   Sort functions   ===== **************************************\n *******************************************************************************************/\n\n  /* NOTE: the quicksort functions sort in ASCENDING order */\n\n/* QuickSort algorithm for a double array with nEl elements */\nDLLEXPORT void smileUtil_quickSort_double(double *arr, long nEl);\n\n/* QuickSort algorithm for a float array with nEl elements */\nDLLEXPORT void smileUtil_quickSort_float(float *arr, long nEl);\n\n/* QuickSort algorithm for a FLOAT_DMEM array with nEl elements */\nDLLEXPORT void smileUtil_quickSort_FLOATDMEM(FLOAT_DMEM *arr, long nEl);\n\n/* Reverse the order in an array of elements, i.e. swap first and last element, etc. */\nDLLEXPORT void smileUtil_reverseOrder_FLOATDMEM(FLOAT_DMEM *arr, long nEl);\n\n\n/*******************************************************************************************\n ***********************=====   Filter functions   ===== **************************************\n *******************************************************************************************/\n\n\n/* allocate workspace (history matrix) for a temporal median filter */\nDLLEXPORT FLOAT_DMEM * smileUtil_temporalMedianFilterInit(long N, long T);\nDLLEXPORT FLOAT_DMEM * smileUtil_temporalMedianFilterInitSl(long N, long Ns, long T);\n\n/* free the temporal median filter workspace and return NULL */\nDLLEXPORT FLOAT_DMEM * smileUtil_temporalMedianFilterFree(FLOAT_DMEM *workspace);\n\n/*\n  Perform median filter of each element in frame x (over time) using a history matrix given in *workspace\n  The workspace must be created with smileUtil_temporalMedianFilterInit\n*/\nDLLEXPORT void smileUtil_temporalMedianFilter(FLOAT_DMEM *x, long N, FLOAT_DMEM *workspace);\n\n/*\n  Perform median filter of each element in frame x (over time) using a history matrix given in *workspace\n  The workspace must be created with smileUtil_temporalMedianFilterInit.\n  workspace : ptr el0 el0 el0(t-1)... el0(t) ; ptr el1 el1 el1(t-1) ... el1(t)\n  **> Filter with slave data (Ns is number of slave elements for each element in x (total size of x thus is N*Ns))\n*/\nDLLEXPORT void smileUtil_temporalMedianFilterWslave(FLOAT_DMEM *x, long N, long Ns, FLOAT_DMEM *workspace);\n\n/*******************************************************************************************\n ***********************=====   FIR filters   ===== ****************************************\n *******************************************************************************************/\n\ntypedef struct {\n  int offset;   // location of t=0 in impulse response, for non-causal filters\n                // actually all implemented filters are causal, but offset will be the delay of the output..\n  int N;  // impulse response length\n  FLOAT_DMEM * h;  // impulse response\n} sSmileDspImpulseResponse;\n\ntypedef struct {\n  sSmileDspImpulseResponse ir;\n  int blocksize;  // processing blocksize (minimum)\n  int bufsize;  // input sample buffer size\n  FLOAT_DMEM * x_buf;  // input sample buffer\n  int x_buf_ptr;\n} sSmileDspConvolverState;\n\n// FIR impulse responses are clipped to a finite length N\n// This function fades out the impulse response linearly in the\n// left and right border regions (10% of the full length at each side)\nvoid smileDsp_impulse_response_linearFadeout(sSmileDspImpulseResponse *ir);\n\n// FIR impulse responses are clipped to a finite length N\n// This function fades out the impulse response linearly in the\n// left and right border regions (10% of the full length at each side)\n// NOTE: the fadeout function breaks normalisation!\n// Use normalise = true to normalise the output.\nvoid smileDsp_impulse_response_gaussFadeout(sSmileDspImpulseResponse *ir,\n    float sigma, bool normalise);\n\n// Initialises an impulse response structure for N taps\nsSmileDspImpulseResponse *smileDsp_impulse_response_init(int N, sSmileDspImpulseResponse *s);\n\n// Normalises an impulse response, so that the convolution of a signal\n// with the impulse response has the same gain/amplitude as the input signal\nvoid smileDsp_normalise_impulse_response(sSmileDspImpulseResponse *ir);\n\n// Sinc impulse response for a low-pass filter\n// with Gaussian fadeout (default sigma 0.5) (preferred!).\n// Standard deviation (sigma) of Gaussian fadeout is relative to\n// window length of filter (0.5 spans half the window).\n// If highpass is set to true, the filter is \"inverted\"\n// in the frequency domain, i.e. it becomes a high-pass filter.\n// Defaults for optional parameters: bool highpass=false, bool fadeout=true\nvoid smileDsp_sincGauss_impulse_response(sSmileDspImpulseResponse *ir,\n    float cutoffHz, float Ts, float sigma, bool highpass, bool fadeout);\n\n// Creates a gammatone bandpass impulse response of length ir->N\n// with center frequency fc and bandwidth bw for a sampling period of Ts\n// set N in ir before calling this function!\nvoid smileDsp_gammatone_impulse_response(sSmileDspImpulseResponse *ir,\n    float fc, float bw, float Ts, float a, int order, bool fadeout);\n\n// Creates a gabor bandpass impulse response of length ir->N\n// with center frequency fc and bandwidth bw for a sampling period of Ts\n// set N in ir before calling this function!\nvoid smileDsp_gabor_impulse_response(sSmileDspImpulseResponse *ir, float fc, float bw, float Ts, bool fadeout);\n\n// Initializes a block convolver work area\nsSmileDspConvolverState *smileDsp_block_convolve_init(int blocksize, sSmileDspImpulseResponse *ir,\n    sSmileDspConvolverState *s);\n\n// Frees a block convolver work area (if noFreeIr is true, then the impulse\n// response ir.h is not freed - use if IRs are shared across multiple filter states)\n// if noFreePtr = true, then free(s) won't be called. Only the internal data will be freed.\nvoid smileDsp_block_convolve_destroy(sSmileDspConvolverState * s, bool noFreeIr, bool noFreePtr);\n\n// Performs a discrete convolution on a block of N input samples in *x.\n// The output will be saved in *y.\n// Using a larger blocksize will reduce the overhead in\n//   a) calling this function\n//   b) rotating the buffer of past samples\n// N must be >= s->blocksize\n// outputStep: the distance (in samples between two output samples (for matrix output))\n// outputOffset: the index of the first output\nvoid smileDsp_block_convolve(sSmileDspConvolverState *s, FLOAT_DMEM *x,\n    FLOAT_DMEM *y, int N, int outputStep, int outputOffset);\n\n\n/*******************************************************************************************\n ***********************=====   Math functions   ===== **************************************\n *******************************************************************************************/\n\n#include <math.h>\n\n#ifndef M_PI\n#define M_PI 3.14159265358979323846264338327950288\n#endif\n\n/* computes logisitic sigmoid */\nFLOAT_DMEM smileMath_logistic(FLOAT_DMEM x);\n\n/* tanh function */\nFLOAT_DMEM smileMath_tanh(FLOAT_DMEM x);\n\n/* computes a modified tanh, which is linear in [-limit1;limit1]\n * and then contains a modified sigmoid, which is slope fitted\n * at limit1, and which scales to max value +-(limit1 + excessToLimit2),\n * i.e. converges to +- that max value */\nFLOAT_DMEM smileMath_ratioLimit(FLOAT_DMEM x,\n    FLOAT_DMEM limit1, FLOAT_DMEM excessToLimit2);\n\n/*\n  median of vector x\n  (workspace can be a pointer to an array of N FLOAT_DMEMs which is used to sort the data in x without changing x)\n  (if workspace is NULL , the function will allocate and free the workspace internally)\n*/\nDLLEXPORT FLOAT_DMEM smileMath_median(const FLOAT_DMEM *x, long N, FLOAT_DMEM *workspace);\n\n/*\n  median of vector x\n  (workspace can be a pointer to an array of 2*N (!) FLOAT_DMEMs which is used to sort the data in x without changing x)\n  (if workspace is NULL , the function will allocate and free the workspace internally)\n  THIS function should return the original vector index of the median in workspace[0] (and workspace[1] if N is even), to use this functionality you must provide a workspace pointer!\n*/\nDLLEXPORT FLOAT_DMEM smileMath_medianOrdered(const FLOAT_DMEM *x, long N, FLOAT_DMEM *workspace);\n\n/* check if number x is power of 2 (positive or negative) */\nDLLEXPORT long smileMath_isPowerOf2(long x);\n\n/* round x to nearest power of two */\nDLLEXPORT long smileMath_roundToNextPowOf2(long x);\n\n/* round up x to next power of 2 */\nDLLEXPORT long smileMath_ceilToNextPowOf2(long x);\n\n/* round down x to next power of two */\nDLLEXPORT long smileMath_floorToNextPowOf2(long x);\n\n/* compute log to base 2 */\ndouble smileMath_log2(double x);\n\n/* Computes Pearson cross correlation between two vectors */\nFLOAT_DMEM smileMath_crossCorrelation(const FLOAT_DMEM * x, long Nx, const FLOAT_DMEM * y, long Ny);\n\n/***** vector math *******/\n\n\n/* compute euclidean norm of given vector x */\nDLLEXPORT FLOAT_DMEM smileMath_vectorLengthEuc(FLOAT_DMEM *x, long N);\n\n/* compute L1 norm (sum of absoulte values) of given vector x */\nDLLEXPORT FLOAT_DMEM smileMath_vectorLengthL1(FLOAT_DMEM *x, long N);\n\n/* normalise euclidean length of x to 1 */\nDLLEXPORT FLOAT_DMEM smileMath_vectorNormEuc(FLOAT_DMEM *x, long N);\n\n/* normalise vector sum to 1 */\nDLLEXPORT FLOAT_DMEM smileMath_vectorNormL1(FLOAT_DMEM *x, long N);\n\n/* normalise values of vector x to range [min - max] */\nDLLEXPORT void smileMath_vectorNormMax(FLOAT_DMEM *x, long N, FLOAT_DMEM min, FLOAT_DMEM max);\n\n/* compute the arithmetic mean of vector x */\nDLLEXPORT FLOAT_DMEM smileMath_vectorAMean(FLOAT_DMEM *x, long N);\n\n/* root of each element in a vector */\nDLLEXPORT void smileMath_vectorRoot(FLOAT_DMEM *x, long N);\n/* root of each element in a vector */\nDLLEXPORT void smileMath_vectorRootD(double *x, long N);\n\n/****** complex number math ****/\n\n/* compute A/B , store in C */\nDLLEXPORT void smileMath_complexDiv(double ReA, double ImA, double ReB, double ImB, double *ReC, double *ImC);\n\n/* absolute value of a complex number */\ndouble smileMath_complexAbs(double Re, double Im);\n\n/* fix roots to inside the unit circle */\n// ensure all roots are within the unit circle\n// if abs(root) > 1  (outside circle)\n// then root = 1 / root*\n//\n// *roots is an array of n complex numbers (2*n doubles)\nDLLEXPORT void smileMath_complexIntoUnitCircle(double *roots, int n);\n\n\n/***** interpolation ****/\n\n// constructs a parabola from three points\n// returns: peak x of parabola, and optional (if not NULL) the y value of the peak in *y and the steepness in *_a\nDLLEXPORT double smileMath_quadFrom3pts(double x1, double y1, double x2, double y2, double x3, double y3, double *y, double *_a);\n\n\n/*******************************************************************************************\n ***********************=====   DSP functions   ===== **************************************\n *******************************************************************************************/\n\n/* compute the equal loudness curve weight, which can be applied to a log-power spectrum\n   See Hermansky's 1990 JASA-Article on PLP for details and equations.\n*/\ndouble smileDsp_equalLoudnessWeight(double frequency);\ndouble smileDsp_equalLoudnessWeight_htk(double frequency);\n\n/* frequency weighting for computing the psychoacoustic measure of spectral sharpness */\ndouble smileDsp_getSharpnessWeightG(double frq, int frqScale, double param);\n\n/* convert LP coefficients to cepstral representation \n   lpGain is used returned by the Durbin recursion function (smileDsp_calcLpcAcf) \n     for computing LP coefficients and is used herein for computation\n     of the \"0th\" cepstral coefficient, which is the return value of this function\n   Details: HTKbook 3.4, equation 5.11\n*/\nFLOAT_DMEM smileDsp_lpToCeps(const FLOAT_DMEM *lp, int nLp, FLOAT_DMEM lpGain, FLOAT_DMEM *ceps, int firstCC, int lastCC);\n\n  /***** spectral scales (Mel/Bark/etc.) *****/\n\n#define SPECTSCALE_LINEAR   0\n#define SPECTSCALE_LOG      1\n#define SPECTSCALE_BARK     2\n#define SPECTSCALE_BARK_OLD     7\n#define SPECTSCALE_MEL      3\n#define SPECTSCALE_SEMITONE 4\n#define SPECTSCALE_BARK_SCHROED     5\n#define SPECTSCALE_BARK_SPEEX       6\n\n// equivalent rectangular bandwidth (in linear frequency)\n// of critical band filter at a given linear centre frequency\ndouble smileDsp_ERB(double x);\n\n// +++ forward scale transformation function (source (linear) -> target) +++\n// 'x' : is the (linear) source frequency in Hertz\n// 'scale' : is one of the following:\n//   SPECTSCALE_LOG, SPECTSCALE_SEMITONE, SPECTSCALE_BARK, \n//   SPECTSCALE_BARK_SCHROED, SPECTSCALE_BARK_SPEEX, SPECTSCALE_MEL\n// 'param' is either:\n//   logScaleBase if scale == SPECTSCALE_LOG\n//   firstNote    if scale == SPECTSCALE_SEMITONE\ndouble smileDsp_specScaleTransfFwd(double x, int scale, double param);\n\n// +++ inverse scale transformation function (linear -> target) +++\n// 'x' : is the (non-linear) source frequency in Bark/Mel/etc. scale ...\n// 'scale' : is one of the following:\n//   SPECTSCALE_LOG, SPECTSCALE_SEMITONE, SPECTSCALE_BARK, \n//   SPECTSCALE_BARK_SCHROED, SPECTSCALE_BARK_SPEEX, SPECTSCALE_MEL\n// 'param' is either:\n//   logScaleBase if scale == SPECTSCALE_LOG\n//   firstNote    if scale == SPECTSCALE_SEMITONE\n// return value: linear frequency in Hertz\ndouble smileDsp_specScaleTransfInv(double x, int scale, double param);\n\n  /***** window functions *****/\n\n/* definition of window function types */\n#define WINF_HANNING    0\n#define WINF_HAMMING    1\n#define WINF_RECTANGLE  2\n#define WINF_RECTANGULAR 2\n#define WINF_SINE       3\n#define WINF_COSINE     3\n#define WINF_GAUSS      4\n#define WINF_TRIANGULAR 5\n#define WINF_TRIANGLE   5\n#define WINF_BARTLETT   6\n#define WINF_LANCZOS    7\n#define WINF_BARTHANN   8\n#define WINF_BLACKMAN   9\n#define WINF_BLACKHARR  10\n#define WINF_TRIANGULAR_POWERED 11\n#define WINF_TRIANGLE_POWERED   11\n#define WINF_UNKNOWN  9999\n\n\n#ifdef _MSC_VER // Visual Studio specific macro\n#define inline __inline\n#endif\n\n/* sinc function (modified) : (sin 2pi*x) / x */\ndouble smileDsp_lcSinc(double x);\n\n/* sinc function : (sin x) / x  */\ndouble smileDsp_sinc(double x);\n\n#ifdef _MSC_VER // Visual Studio specific macro\n#undef inline\n#endif\n\n/* Rectangular window */\nDLLEXPORT double * smileDsp_winRec(long N_);\n\n/* Triangular window (non-zero endpoint) */\nDLLEXPORT double * smileDsp_winTri(long N_);\n\n/* Powered triangular window (non-zero endpoint) */\nDLLEXPORT double * smileDsp_winTrP(long N_);\n\n/* Bartlett window (triangular, zero endpoint) */\nDLLEXPORT double * smileDsp_winBar(long N_);\n\n/* Hann window */\nDLLEXPORT double * smileDsp_winHan(long N_);\n\n/* Hamming window */\nDLLEXPORT double * smileDsp_winHam(long N_);\n\n/* Sine window */\nDLLEXPORT double * smileDsp_winSin(long N_);\n\n/* Gauss window */\nDLLEXPORT double * smileDsp_winGau(long N_, double sigma);\n\n/* Lanczos window */\nDLLEXPORT double * smileDsp_winLac(long N_);\n\n/* Blackman window */\nDLLEXPORT double * smileDsp_winBla(long N_, double alpha0, double alpha1, double alpha2);\n\n/* Bartlett-Hann window */\nDLLEXPORT double * smileDsp_winBaH(long N_, double alpha0, double alpha1, double alpha2);\n\n/* Blackman-Harris window */\nDLLEXPORT double * smileDsp_winBlH(long N_, double alpha0, double alpha1, double alpha2, double alpha3);\n\n/* convert string window function name (from config file) to integer constant */\nDLLEXPORT int winFuncToInt(const char * winF);\n\n/****** FFT related dsp functions *****/\n\n/* Unwraps a phase by adding +- 2pi in case of phase jumps greater -+ pi\n * N: number of phase values\n * Function operates in-place on phaseRadians array.\n */\nvoid smileDsp_fftPhaseUnwrap(FLOAT_DMEM * phaseRadians, long N);\n\n/* Computes magnitude and phase from a complex spectrum (of a real dft) input of total length N.\n * The input is expected to be in the rdft output format of fft4g.\n * Stores magnitudes in pre-allocated *mag array (size N/2 + 1)\n * Stores phases in pre-allocated *phases array (size N/2 + 1)\n * *mag and *phases can be NULL, to disable computation of either.\n * normaliseFft: all input values are divided by 2.0/N before magnitudes are computed\n * return value: number of elements in *mag / *phases (= N/2 + 1)\n */\nlong smileDsp_fftComputeMagPhase(const FLOAT_DMEM *complex, long N,\n    FLOAT_DMEM *mag, FLOAT_DMEM *phase, int normaliseFft);\n\n/***** other dsp functions ****/\n\n/* compute harmonic product spectrum from a magnitude spectrum, use up to maxMul down-scaled spectra */\nDLLEXPORT long smileDsp_harmonicProductLin(const FLOAT_DMEM *src, long Nsrc, FLOAT_DMEM *dst, long Ndst, int maxMul);\n\n/* compute harmonic sum spectrum from a magnitude spectrum, use up to maxMul down-scaled spectra */\nDLLEXPORT long smileDsp_harmonicSumLin(const FLOAT_DMEM *src, long Nsrc, FLOAT_DMEM *dst, long Ndst, int maxMul);\n\n/* LPC analysis via ACF (=implementation of Durbin recursion) */\nDLLEXPORT int smileDsp_calcLpcAcf(FLOAT_DMEM * acf, FLOAT_DMEM *lpc, int _p, FLOAT_DMEM *gain, FLOAT_DMEM *refl);\n\n/* smileDsp_calcLpcBurg:\n * Computes LPC coefficients with Burg's method (N. Anderson (1978)):\n     N. Anderson (1978), \"On the calculation of filter coefficients for maximum entropy spectral analysis\", in Childers, Modern Spectrum Analysis, IEEE Press, 252-255.\n Parameters:\n   *samples : wave samples,\n   N : number of samples\n   *coeffs : array which will hold the LPC coefficients\n   M : (maximum) number of coefficients to compute\n   lpcgain : optional pointer to a FLOAT_DMEM variable, which will be filled with the computed LPC gain\n   gbb, gb2, gaa : work area memory,\n     pointers will be automatically initialised on the first use,\n     they must be freed by the calling code on exit ;\n     if these pointers are NULL, smileDsp_calcLpcBurg will allocate\n     the work area at the beginning of the function and\n     free it at the end of the function\n     (the latter is inefficient if memory allocation is slow)\n */\nDLLEXPORT int smileDsp_calcLpcBurg (const FLOAT_DMEM *samples, long N,\n    FLOAT_DMEM *coeffs, int M, FLOAT_DMEM *lpcgain,\n    FLOAT_DMEM **gbb, FLOAT_DMEM **gb2, FLOAT_DMEM **gaa);\n\n\n/* Autocorrelation in the time domain (for ACF LPC method) */\n/* x is signal to correlate, n is number of samples in input buffer, \n   *outp is array to hold #lag output coefficients, lag is # of output coefficients (= max. lag) */\nDLLEXPORT void smileDsp_autoCorr(const FLOAT_DMEM *x, const int n, FLOAT_DMEM *outp, int lag);\n\n/* computes formant frequencies and bandwidths from lpc polynomial roots \n   return value: number of valid formants detected from given lpc polynomial roots\nr is n complex roots (2*n 'doubles'), nR is number of roots (=n),\n*fc is array that will hold formant frequencies (non valid formant entries (index > return value) will be zero),\n*bc is array that will hold formant bandwidths (non valid formant entries (index > return value) will be zero),\nnF is max. # of formants wanted (must match size of fc and bc array),\nsamplePeriod is 1.0 / sampleFrequency,\nfLow is min. formant frequency (upper and lower margin for valid formant frequency range),\nfHigh is max. formant frequency  (if  -1 (or < fLow), \"samplingFrequency / 2 - fLow\" will be used)\n */\nDLLEXPORT int smileDsp_lpcrootsToFormants(double *r, int nR, double *fc, double *bc, int nF, double samplePeriod, double fLow, double fHigh);\n\n\n/* Implementation of a lattice filter, processes a single value per call */\n/* k is filter coefficients, *b is work area (initialise with 0 when calling! (size: sizeof(FLOAT_DMEM)*M )),\n   M is filter order (number of coefficients),  *in is input samples array (will contain in-place filtered outputs),\n   *bM is an optional b(M) result\n   returns: f(M), and filtered data in *in\n */\nDLLEXPORT FLOAT_DMEM smileDsp_lattice(FLOAT_DMEM *k, FLOAT_DMEM *b, int M, FLOAT_DMEM in, FLOAT_DMEM *bM);\n\n/* Implementation of an inverse lattice filter, processes a single value per call */\n/* k is filter coefficients, *b is work area (initialise with 0 when calling! (size: sizeof(FLOAT_DMEM)*M )),\n   M is filter order (number of coefficients),  *out is input samples array (will contain in-place filtered outputs),\n   returns: f(M), and filtered data in *out\n */\nDLLEXPORT FLOAT_DMEM smileDsp_invLattice(FLOAT_DMEM *k, FLOAT_DMEM *b, int M, FLOAT_DMEM out);\n\n/* peak enhancement in a linear magnitude spectrum */\nDLLEXPORT int smileDsp_specEnhanceSHS(double *a, long n);\n\n/* smooth a magnitude spectrum (linear) */\nDLLEXPORT void smileDsp_specSmoothSHS(double *a, long n);\n\n\n/****** simple, slow & full inverse DFT ******/\n\ntypedef struct {\n  FLOAT_DMEM *costable;  // K*I matrix\n  FLOAT_DMEM *sintable;\n  long K; // Nsrc\n  long kMax; // MIN(Nsrc,Ndst) \n  long I; // Ndst\n  int antiAlias;\n} sDftWork;\n\n// initialise a inverse RDFT work area\n// K is number of frequency bins (input)\n// I is the number of actual output samples to compute\n// nI is the denominator of the sin/cos functions (usually =I) \nDLLEXPORT sDftWork * smileDsp_initIrdft(long K, long I, double nI, int antialias);\n\n// free a DFT work area\nDLLEXPORT sDftWork * smileDsp_freeDftwork(sDftWork * w);\n\n// perform an arbitrary inverse RDFT (slow version)\nDLLEXPORT void smileDsp_irdft(const FLOAT_DMEM * inData, FLOAT_DMEM *out, sDftWork *w);\n\n#include <dspcore/fftXg.h>\n\ntypedef struct {\n  double *winF, *winFo;\n  FLOAT_DMEM *x;\n  FLOAT_TYPE_FFT * _w;\n  int *_ip;\n  sDftWork *irdftWork;\n} sResampleWork;\n\nDLLEXPORT sResampleWork * smileDsp_resampleWorkFree(sResampleWork * work);\nDLLEXPORT sResampleWork * smileDsp_resampleWorkInit(long Nin);\nDLLEXPORT int smileDsp_doResample(FLOAT_TYPE_FFT *x, long Nin, FLOAT_DMEM *y, long Nout, double nd, sResampleWork ** _work);\n\n// converts an amplitude ratio a to decibel (dB) \n//     using the equation: 20*log(a)\n// a must be > 0\nDLLEXPORT double smileDsp_amplitudeRatioToDB(double a);\n\n\n/*******************************************************************************************\n ***********************=====   Statistics functions   ===== *******************************\n *******************************************************************************************/\n\n/* compute entropy of a \"pmf\" (the given pmf (in _vals) will be normalised by this function internally) */\nDLLEXPORT FLOAT_DMEM smileStat_entropy(const FLOAT_DMEM *vals, long N);\n\n/* compute relative entropy of a \"pmf\" (may also be unnormalised) */\nDLLEXPORT FLOAT_DMEM smileStat_relativeEntropy(const FLOAT_DMEM *vals, long N);\n\ntypedef struct {\n  long Nbins;\n  FLOAT_DMEM min, max;\n  FLOAT_DMEM stepsize;\n  FLOAT_DMEM *bins;\n  FLOAT_DMEM weight; // = number of samples from which the current histogram was built\n} sHistogram;\n\ntypedef struct {\n  uint32_t Nbins;\n  float min, max;\n  float stepsize;\n} sHistogram_file;\n\n#define PROBFLOOR       0.0000000000000000000000001   // 1.0e-25\n#define PROBFLOOR_LOG   -1000.0\n\n/* computes a PMF from a sample sequence using a histogram sampling method.\nif a valid pointer is given in *_pmf, then the histogram will be added to the existing data,\nthe resulting histogram will then be unnormalised, you will have to call smileMath_vectorNormEuc in the end.. \nthe memory pointed to by *h must be initialised with 0s! (at least h->bins must be NULL...)\n*/\nDLLEXPORT void smileStat_getPMF(FLOAT_DMEM *_vals, long N, sHistogram *h);\n\n/* Estimate the probability of a vector x with a given pmf (the pmf must be normalised to sum 1!) */\nDLLEXPORT FLOAT_DMEM smileStat_probEstim(FLOAT_DMEM x, sHistogram *h, FLOAT_DMEM probFloor);\n\n/* get a PMF vector from a data matrix (result is a pmf histogram for each row of the matrix) */\n/* N: number of colums in matrix  , R: number of rows in the matrix (must match the size of *h) */\n/* matrix in _vals is read rowwise.. cMatrix in openSMILE is read columnwise, so you must transpose here!\nthe memory pointed to by *h must be initialised with 0s! (at least h->bins must be NULL...)\n*/\nvoid smileStat_getPMFvec(FLOAT_DMEM *_vals, long N, long R, sHistogram *h);\n\n/* get a PMF vector from a data matrix (result is a pmf histogram for each row of the matrix) */\n/* *h must point to an allocated array of R x sHistogram \nthe memory pointed to by *h must be initialised with 0s! (at least h->bins must be NULL...)\n*/\n/* N: number of colums in matrix  , R: number of rows in the matrix (must match the size of *h) */\n/* matrix in _vals is read columnwise.. use this for compatiblity with openSMILE cMatrix!*/\nvoid smileStat_getPMFvecT(FLOAT_DMEM *_vals, long N, long R, sHistogram *h);\n\n/* estimate probability of a vector belonging to a pmf array */\nvoid smileStat_probEstimVec(FLOAT_DMEM *x, sHistogram *h, FLOAT_DMEM **p, long R, FLOAT_DMEM probFloor);\n\n/* estimate probability of a vector belonging to a pmf array (linear multiplication) */\nFLOAT_DMEM smileStat_probEstimVecLin(FLOAT_DMEM *x, sHistogram *h, long R, FLOAT_DMEM probFloor);\n\n/* estimate probability of a vector belonging to a pmf array (log prob addition)*/\nFLOAT_DMEM smileStat_probEstimVecLog(FLOAT_DMEM *x, sHistogram *h, long R, FLOAT_DMEM probFloorLog);\n\n/*******************************************************************************************\n ***********************=====   WAVE file I/O   ===== **************************************\n *******************************************************************************************/\n\n#define BYTEORDER_LE    0\n#define BYTEORDER_BE    1\n#define MEMORGA_INTERLV 0\n#define MEMORGA_SEPCH   1\n\n\ntypedef struct {\n  long sampleRate;\n  int sampleType;\n  int nChan;\n  int blockSize;\n  int nBPS;       // actual bytes per sample\n  int nBits;       // bits per sample (precision)\n  int byteOrder;  // BYTEORDER_LE or BYTEORDER_BE\n  int memOrga;    // MEMORGA_INTERLV  or MEMORGA_SEPCH\n  long nBlocks;  // nBlocks in buffer\n  int headerOffset;  // NEW: byte length of wave header(s)\n} sWaveParameters;\n\n/* \n  read the wave file header from fileHandle, store parameters in struct pointed to by pcmParam \n  the file must be opened via fopen()\n */\nDLLEXPORT int smilePcm_readWaveHeader(FILE *filehandle, sWaveParameters *pcmParam, const char *filename);\n\n/* parse a wave header from a wave file in memory */\nDLLEXPORT int smilePcm_parseWaveHeader(void *raw, long long N, sWaveParameters *pcmParam);\n\n// Convert samples from binary buffer to float array, given the wave parameters\n//  *buf : the raw PCM data buffer\n//  *pcmParam : parameter struct specifying the sample format\n//      Requires nBits, nBPS, and nChan in pcmParam. pcmParam->nChan is the number of channels in *buf\n//  *a : The array where the converted buffer will be stored in. It must be pre-allocated to the right size! [nChan * nSamples * sizeof(float)]\n//  nChan : number of audio channels allocated in *a (if smaller then pcmParam->nChan, only the smaller number will be copied. If larger, behaviour undefined!!!),\n//  nSamples : number of audio samples to copy from *buf to *a\n//  monoMixdown : 1 = convert from multi-channel recording to mono (1 channel)\n//  Return value: number of samples processed (= nSamples)\nDLLEXPORT int smilePcm_convertSamples(uint8_t *buf, sWaveParameters *pcmParam, float *a, int nChan, int nSamples, int monoMixdown);\n\n/*read samples from wave file (after reading header). \n  *a  is a pointer to a float array which will receive the data as:  c1s1 c2s1 .. c1s2 c2s2 .... (c1 : channel1, s1 sample1, ...)\n  *pcmParam points to the struct filled by smilePcm_readWaveHeader(...)\n  nChan and nSamples specify the size of the memory pointed to by *a  (which is sizeof(float)*nChan*nSamples)\n     nChan should match the value in pcmParam! (except when monoMixdown = 1, then nChan must always be 1)\n  return value : -1 eof (or filehandle==NULL), 0 error, > 0 , num samples read\n  the filehandle will automatically be closed and set to NULL at the end of file\n*/\nDLLEXPORT int smilePcm_readSamples(FILE **filehandle, sWaveParameters *pcmParam, float *a, int nChan, int nSamples, int monoMixdown);\n\n\n/*******************************************************************************************\n *******************=====   Vector save/load debug helpers   ===== *************************\n *******************************************************************************************/\n\n/* these functions are not safe and should only be used for data output during debugging ! */\n\nDLLEXPORT void saveDoubleVector_csv(const char * filename, double * vec, long N, int append);\nDLLEXPORT void saveFloatVector_csv(const char * filename, float * vec, long N, int append);\nDLLEXPORT void saveFloatDmemVector_csv(const char * filename, FLOAT_DMEM * vec, long N, int append);\nDLLEXPORT void saveDoubleVector_bin(const char * filename, double * vec, long N, int append);\nDLLEXPORT void saveFloatVector_bin(const char * filename, float * vec, long N, int append);\nDLLEXPORT void saveFloatDmemVector_bin(const char * filename, FLOAT_DMEM * vec, long N, int append);\nDLLEXPORT void saveFloatDmemVectorWlen_bin(const char * filename, FLOAT_DMEM * vec, long N, int append);\n\n\n/** HTK functions **/\n\ntypedef struct {\n  uint32_t nSamples;\n  uint32_t samplePeriod;\n  uint16_t sampleSize;\n  uint16_t parmKind;\n} sHTKheader;\n\nvoid smileHtk_prepareHeader( sHTKheader *h );\nint smileHtk_readHeader(FILE *filehandle, sHTKheader *head);\nint smileHtk_writeHeader(FILE *filehandle, sHTKheader *_head);\nint smileHtk_IsVAXOrder ();\nvoid smileHtk_SwapFloat( float *p );\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif  // __SMILE_UTIL_H\n"
  },
  {
    "path": "src/include/smileutil/smileUtilSpline.h",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n#ifndef __SMILE_UTIL_SPLINE_H\n#define __SMILE_UTIL_SPLINE_H\n\n/* you may remove this include if you are using smileUtil outside of openSMILE */\n//#include <smileCommon.hpp>\n/* --------------------------------------------------------------------------- */\n#ifndef __SMILE_COMMON_H\n#define __SMILE_COMMON_H\n\n// this is a minimal set of defines if we are using smileUtil outside of openSMILE\n// on linux you should consider compiling with -DHAVE_INTTYPES_H option (see smileTypes.h)\n\n#ifdef HAVE_CONFIG_H\n#include <config.h>\n#endif\n\n#ifdef _MSC_VER // Visual Studio specific macro\n  #ifdef BUILDING_DLL\n    #define DLLEXPORT __declspec(dllexport)\n//    #define class class __declspec(dllexport)\n  #else\n    #define DLLEXPORT __declspec(dllimport)\n//    #define class class __declspec(dllimport)\n  #endif\n  #define DLLLOCAL\n#else\n    #define DLLEXPORT\n    #define DLLLOCAL\n#endif\n\n#include <stdlib.h>\n#include <stdio.h>\n\n#endif  // __SMILE_COMMON_H\n\n\n#ifndef __SMILE_LOGGER_HPP\n#define __SMILE_LOGGER_HPP\n#define LOGLEVEL 2\n#define SMILE_PRINT(...) fprintf(stderr,__VA_ARGS__)\n#define SMILE_PRINTL(level, ...) { if (level <= LOGLEVEL) fprintf(stderr,__VA_ARGS__); }\n\n#define SMILE_MSG(level, ...) { if (level <= LOGLEVEL) { fprintf(stderr,\"MSG(%i): \",level) ; fprintf(stderr,__VA_ARGS__); } }\n#define SMILE_IMSG(level, ...) { if (level <= LOGLEVEL) { fprintf(stderr,\"MSG(%i): \",level) ; fprintf(stderr,__VA_ARGS__); } }\n\n#define SMILE_ERR(level, ...) { if (level <= LOGLEVEL) { fprintf(stderr,\"ERR(%i): \",level) ; fprintf(stderr,__VA_ARGS__); } }\n#define SMILE_IERR(level, ...) { if (level <= LOGLEVEL) { fprintf(stderr,\"ERR(%i): \",level) ; fprintf(stderr,__VA_ARGS__); } }\n\n#define SMILE_WRN(level, ...) { if (level <= LOGLEVEL) { fprintf(stderr,\"WRN(%i): \",level) ; fprintf(stderr,__VA_ARGS__); } }\n#define SMILE_IWRN(level, ...) { if (level <= LOGLEVEL) { fprintf(stderr,\"WRN(%i): \",level) ; fprintf(stderr,__VA_ARGS__); } }\n\n\n#ifdef DEBUG\n#define SMILE_DBG(level, ...) { if (level <= LOGLEVEL) { fprintf(stderr,\"DBG(%i): \",level) ; fprintf(stderr,__VA_ARGS__); } }\n#define SMILE_IDBG(level, ...) { if (level <= LOGLEVEL) { fprintf(stderr,\"DBG(%i): \",level) ; fprintf(stderr,__VA_ARGS__); } }\n#endif\n#endif  // __SMILE_LOGGER_HPP\n\n#include <core/smileTypes.h>\n\n\n/****** spline functions ******/\n\n/*\n        smileMath_spline: evalutes a spline function:\n\n        Given two arrays x[1..n] and y[1..n] containing a tabulated function, that is\n        y[i] = f(x[i]), with x[1] < x[2] < ... < x[n], and the values yp1 and\n        ypn for the first derivative of the interpolating function at points\n        1 and n, respectively, this function returns an array y2[1..n] which\n        contains the second derivative of the interpolating function at the\n        point x.\n        If yp1 and / or ypn are greater or equal than 10^30,\n        the corresponding boundary condition for a natuarl spline is set, with\n        a zero second derivative on that boundary.\n        u is an optional pointer to a workspace area (smileMath_spline will\n        allocate a vector there if the pointer pointed to is NULL).\n        The calling code is responsible of freeing this memory with free() at any\n        later time which seems convenient (i.e. at the end of all calculations).\n*/\nDLLEXPORT int smileMath_spline(const double *x, const double *y,\n    long n, double yp1, double ypn, double *y2, double **workspace);\n\nDLLEXPORT int smileMath_spline_FLOAT_DMEM(const FLOAT_DMEM *x, const FLOAT_DMEM *y,\n    long n, FLOAT_DMEM yp1, FLOAT_DMEM ypn, FLOAT_DMEM *y2, FLOAT_DMEM **workspace);\n\n/* smileMath_splint:\n    Does spline interpolation of y for a given x value of function ya=f(xa).\n\n    Xa[1..n] and ya[1..n] contain the function to be interpolated,\n    i.e., ya[i] = f(xa[i]), with xa[1] < xa[2] < ... < xa[n].\n    y2a[1..n] is the output of smileMath_spline(...) above,\n    containing the second derivatives.\n    n contains the length of xa and ya\n    x holds the position at which to interpolate *y = f(x).\n*/\nDLLEXPORT int smileMath_splint(const double *xa, const double *ya,\n    const double *y2a, long n, double x, double *y);\n\nDLLEXPORT int smileMath_splint_FLOAT_DMEM(const FLOAT_DMEM *xa, const FLOAT_DMEM *ya,\n    const FLOAT_DMEM *y2a, long n, FLOAT_DMEM x, FLOAT_DMEM *y);\n\n#endif // __SMILE_UTIL_SPLINE_H\n\n"
  },
  {
    "path": "src/include/smileutil/zerosolve.h",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n#ifndef __SMILEUTIL_ZEROSOLVER_H\n#define __SMILEUTIL_ZEROSOLVER_H\n\n#include <stdlib.h>\n\ntypedef struct {\n  long double val[2];\n} tZerosolverComplexlDouble;\n\ntypedef struct {\n  double val[2];\n} tZerosolverComplex;\n\ntypedef struct {\n  float val[2];\n} tZerosolverComplexFloat;\n\ntypedef double *  tZerosolverComplexNumber;\ntypedef float * tZerosolverComplexNumberFloat;\ntypedef long double * tZerosolverComplexNumberlDouble;\n\ntypedef const double * tZerosolverConstComplexNumber;\ntypedef const float * tZerosolverConstComplexNumberFloat;\ntypedef const long double * tZerosolverConstComplexNumberlDouble;\n\ntypedef tZerosolverComplexNumber tZerosolverComplexNumberArray;\ntypedef tZerosolverComplexNumberFloat tZerosolverComplexNumberFloatArray;\ntypedef tZerosolverComplexNumberlDouble  tZerosolverComplexNumberlDoubleArray;\n\ntypedef const double * tZerosolverConstComplexNumberArray;\ntypedef const float * tZerosolverConstComplexNumberArrayFloat;\ntypedef const long double * tZerosolverConstComplexNumberArraylDouble;\n\ntypedef tZerosolverComplexNumber tZerosolverComplexNumberPointer;\ntypedef tZerosolverComplexNumberFloat tZerosolverComplexNumberFloatPointer;\ntypedef tZerosolverComplexNumberlDouble tZerosolverComplexNumberlDoublePointer;\n\ntypedef const double * tZerosolverConstComplexNumberPointer;\ntypedef const float * tZerosolverConstComplexNumberFloatPointer;\ntypedef const long double * tZerosolverConstComplexNumberlDoublePointer;\n\n\ntypedef struct {\n  long nCol;\n  double * mat;\n} sZerosolverPolynomialComplexWs;\n\n#define ZEROSOLVER_REAL(z)     ((z).val[0])\n#define ZEROSOLVER_IMAG(z)     ((z).val[1])\n#define ZEROSOLVER_COMPLEX_POINTER(zp) ((zp)->val)\n#define ZEROSOLVER_COMPLEX_POINTER_REAL(zp)  ((zp)->val[0])\n#define ZEROSOLVER_COMPLEX_POINTER_IMAG(zp)  ((zp)->val[1])\n#define ZEROSOLVER_COMPLEX_EQUAL(z1,z2) (((z1).val[0] == (z2).val[0]) && ((z1).val[1] == (z2).val[1]))\n#define ZEROSOLVER_SET_COMPLEX(zptr,x,y) {(zptr)->val[0] = (x); (zptr)->val[1] = (y); }\n#define ZEROSOLVER_SET_REAL(zptr,x)      {(zptr)->val[0] = (x); }\n#define ZEROSOLVER_SET_IMAG(zptr,y)      {(zptr)->val[1] = (y); }\n#define ZEROSOLVER_SET_COMPLEX_NUMBER(zptr,n,x,y)   { *((zptr) + 2 * (n)) = (x); *((zptr) + (2 * (n) + 1)) = (y); }\n\n#define ZEROSOLVER_DBL_EPSILON 2.2204460492503131e-16\n\n// Evaluates the polynomial\n// a[0] + a[1] * x + a[2] * x^2 + ... + a[N - 1] * x^(N-1)\n__inline double zerosolverEvaluatePolynomial(const double a[], const int N, const double x)\n{\n  double res = a[N-1];\n  int i = N - 1;\n  for (; i > 0; i--)\n    res = a[i-1] + x * res;\n  return res;\n}\n\n__inline tZerosolverComplex zerosolverEvaluateComplexPolynomialComplex(const tZerosolverComplex a[],\n    const int N, const tZerosolverComplex x)\n{\n  tZerosolverComplex res = a[N-1];\n  int i = N - 1;\n  for (; i > 0; i--) {\n    double tmp = ZEROSOLVER_REAL(a[i-1]) + ZEROSOLVER_REAL(x) * ZEROSOLVER_REAL(res)\n        - ZEROSOLVER_IMAG(x) * ZEROSOLVER_IMAG(res);\n    ZEROSOLVER_SET_IMAG(&res, ZEROSOLVER_IMAG(a[i - 1]) + ZEROSOLVER_IMAG(x) * ZEROSOLVER_REAL(res)\n        + ZEROSOLVER_REAL(x) * ZEROSOLVER_IMAG(res));\n    ZEROSOLVER_SET_REAL(&res, tmp);\n  }\n  return res;\n}\n\n__inline tZerosolverComplex zerosolverEvaluatePolynomialComplex(const double a[],\n    const int N, const tZerosolverComplex x)\n{\n  tZerosolverComplex res;\n  ZEROSOLVER_SET_COMPLEX (&res, a[N-1], 0.0);\n  int i = N - 1;\n  for(; i > 0; i--) {\n    double tmp = a[i - 1] + ZEROSOLVER_REAL(x) * ZEROSOLVER_REAL(res)\n        - ZEROSOLVER_IMAG(x) * ZEROSOLVER_IMAG(res);\n    ZEROSOLVER_SET_IMAG(&res, ZEROSOLVER_IMAG(x) * ZEROSOLVER_REAL(res)\n        + ZEROSOLVER_REAL(x) * ZEROSOLVER_IMAG(res));\n    ZEROSOLVER_SET_REAL(&res, tmp);\n  }\n  return res;\n}\n\n// Allocates the workspace\nsZerosolverPolynomialComplexWs * zerosolverPolynomialComplexWorkspaceAllocate(long N);\n// Frees the workspace\nvoid zerosolverPolynomialComplexWorkspaceFree(sZerosolverPolynomialComplexWs * w);\n\n// Solves for the complex roots of a real polynomial given by *a\nint zerosolverPolynomialComplexSolve (const double * a, long N,\n    sZerosolverPolynomialComplexWs * w, tZerosolverComplexNumberPointer x);\n\n\n#endif  // __SMILEUTIL_ZEROSOLVER_H\n"
  },
  {
    "path": "src/include/video/openCVSource.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nOpenCVSource\nCaptures frames from either webcam or file stream and extracts a square region containing the face(s).\nAuthor: Florian Gross\n\n*/\n\n\n#ifndef __OPENCV_SOURCE_HPP\n#define __OPENCV_SOURCE_HPP\n\n\n#include <core/smileCommon.hpp>\n#include <core/dataSource.hpp>\n\n#ifdef HAVE_OPENCV\n\n#define BUILD_COMPONENT_OpenCVSource\n\n#include \"opencv2/objdetect/objdetect.hpp\"\n#include \"opencv2/highgui/highgui.hpp\"\n#include \"opencv2/imgproc/imgproc.hpp\"\n#include \"opencv2/video/video.hpp\"\n\n#include <video/openCV_LBPHistogram.hpp>\n#include <video/openCV_HSVHistogram.hpp>\n#include <video/openCV_OpticalFlow.hpp>\n\n#include <iostream>\n#include <stdio.h>\n\nusing namespace cv;\n\nclass ExtractedFace {\npublic:\n\tbool faceFound, eyesFound;\n\tcv::Rect faceRect;\n\tcv::Point leftEye, rightEye;\n\tcv::Mat faceGray, faceColor;\n};\n\n#define COMPONENT_DESCRIPTION_COPENCVSOURCE \"Captures frames from either webcam or file stream, extracts a square region containing the face and creates a LBP, HSV and optical flow histogram.\"\n#define COMPONENT_NAME_COPENCVSOURCE \"cOpenCVSource\"\n\n#undef class\nclass DLLEXPORT cOpenCVSource : public cDataSource {\n  private:\n    int cfgDisplay; // Display video output\n\tString cfgVideoSource; // WEBCAM or FILE\n\tString cfgFilename;\n\tString cfgFace_cascade_name;\n\tString cfgEyes_cascade_name;\n\n\tint cfgExtractFace;\n\tint cfgExtractHSVHist;\n\tint cfgExtractLBPHist;\n\tint cfgExtractOpticalFlow;\n\t\n\tint cfgIncludeFaceFeatures;\n\t\n\tint cfgIgnoreInvalid;\n\tint cfgFaceWidth;\n\tint cfgLBPUniformPatterns;\n\t\n\tint cfgHueBins, cfgSatBins, cfgValBins;\n\tint cfgFlowBins;\n\tint cfgNormalizeHistograms;\n\tFLOAT_DMEM cfgMaxFlow;\n\tFLOAT_DMEM cfgFlowDownsample;\n\tint cfgUseLBPC;\n\tint cfgLBPCRadius, cfgLBPCPoints;\n\n\tdouble cfgFps;\n\n\tcv::Mat mCurrentFrame_bgr, mCurrentFrame_gray, mPrevFrame_gray_resized, mCurrentFrameDisplay_bgr;\n\tVideoCapture mVideoCapture;\n\tCascadeClassifier mFace_cascade;\n\tCascadeClassifier mEyes_cascade;\n\n\tint mVectorSize;\n\n\tstd::map<unsigned char, unsigned char> mIdentityMap;\n\tstd::map<unsigned char, unsigned char> mUniformMap;\n\tint mLBPSize;\n\n\tdouble avgVal[7], avgNum[7];\n    \n  protected:\n    SMILECOMPONENT_STATIC_DECL_PR\n    \n    virtual void fetchConfig();\n    virtual int myConfigureInstance();\n    virtual int myFinaliseInstance();\n    virtual int myTick(long long t);\n\n\n    virtual int configureWriter(sDmLevelConfig &c);\n    virtual int setupNewNames(long nEl);\n    \n\tvirtual ExtractedFace extractFace(cv::Mat& frame, cv::Mat& frame_gray);\n\n  public:\n    SMILECOMPONENT_STATIC_DECL\n    \n    cOpenCVSource(const char *_name);\n\n    virtual ~cOpenCVSource();\n};\n\n\n#endif // HAVE_OPENCV\n\n#endif // __LBPHIST_SOURCE_HPP\n"
  },
  {
    "path": "src/include/video/openCV_HSVHistogram.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n/*\nopenCV_LBPHistogram\nVarious helper functions for computing the LBP representation and histogram of an image.\nAuthor: Florian Gross\n\n*/\n\n#ifndef OPENCV_HSVHISTOGRAM_HPP_\n#define OPENCV_HSVHISTOGRAM_HPP_\n\n#ifdef HAVE_OPENCV\n\n#include <core/smileCommon.hpp>\n#include <core/dataSource.hpp>\n\n#include \"opencv2/objdetect/objdetect.hpp\"\n#include \"opencv2/highgui/highgui.hpp\"\n#include \"opencv2/imgproc/imgproc.hpp\"\n\n#include <iostream>\n#include <stdio.h>\n\nnamespace HSVHistogram {\n\n/**\n * @function euclideanDistance\n * @brief Computes the euclidean distance of two points ( \\f$ d = \\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}\\f$ ).\n */\ninline float euclideanDistance(cv::Point& p1, cv::Point& p2)\n{\n  float dx = p1.x - p2.x;\n  float dy = p1.y - p2.y;\n  return std::sqrt(dx * dx + dy * dy);\n};\n\n/**\n * @function computeSingleHistogram\n * @brief Computes a single histogram for a given single channel image (cv::Mat).\n * @param image Matrix representation of image, single channel\n * @return Histogram (cv::Mat)\n */\ninline cv::Mat computeSingleHistogram(cv::Mat& input, int& histSize, const float range[], int normalize)\n{\n\tcv::Mat retHist;\n\tcv::calcHist(&input, 1, 0, cv::Mat(), retHist, 1, &histSize, &range, true, false);\n\n\tif(normalize == 1)\n\t{\n\t\tcv::normalize(retHist, retHist, 1, 0, cv::NORM_L1, -1, cv::Mat()); // L1-norm\n\t}\n\n\treturn retHist;\n}\n\n/**\n * @function computeHSVHistogram\n * @brief Computes the HSV histogram for a given image (cv::Mat).\n * @param image Matrix representation of image, BGR format\n * @return Array of histograms, ([0] => H, [1] => S, [2] => V)\n */\ninline std::vector<cv::Mat> computeHSVHistogram(cv::Mat& image, int cfgHueSize, int cfgSatSize, int cfgValSize, int normalize)\n{\n\tcv::Mat hsvImage;\n\tcv::cvtColor(image, hsvImage, CV_BGR2HSV);\n\n\tstd::vector<cv::Mat> hsvPlanes;\n\tcv::split(hsvImage, hsvPlanes);\n\n\tconst float hranges[] = { 0, 180 };\n\tconst float sranges[] = { 0, 256 };\n\tconst float vranges[] = { 0, 256 };\n\n\tcv::Mat h_hist = computeSingleHistogram(hsvPlanes[0], cfgHueSize, hranges, normalize);\n\tcv::Mat s_hist = computeSingleHistogram(hsvPlanes[1], cfgSatSize, sranges, normalize);\n\tcv::Mat v_hist = computeSingleHistogram(hsvPlanes[2], cfgValSize, vranges, normalize);\n\n\tstd::vector<cv::Mat> hists_splitted;\n\thists_splitted.push_back(h_hist);\n\thists_splitted.push_back(s_hist);\n\thists_splitted.push_back(v_hist);\n\n\treturn hists_splitted;\n}\n\n\n} // End namespace LBPHistogram\n\n#endif // HAVE_OPENCV\n\n#endif /* OPENCV_HSVHISTOGRAM_HPP_ */\n"
  },
  {
    "path": "src/include/video/openCV_LBPHistogram.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n/*\nopenCV_LBPHistogram\nVarious helper functions for computing the LBP representation and histogram of an image.\nAuthor: Florian Gross\n\n*/\n\n#ifndef OPENCV_LBPHISTOGRAM_HPP_\n#define OPENCV_LBPHISTOGRAM_HPP_\n\n#ifdef HAVE_OPENCV\n\n#include <core/smileCommon.hpp>\n#include <core/dataSource.hpp>\n\n#include \"opencv2/objdetect/objdetect.hpp\"\n#include \"opencv2/highgui/highgui.hpp\"\n#include \"opencv2/imgproc/imgproc.hpp\"\n\n#include <iostream>\n#include <stdio.h>\n\nnamespace LBPHistogram {\n\n/**\n * @function euclideanDistance\n * @brief Computes the euclidean distance of two points ( \\f$ d = \\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}\\f$ ).\n */\ninline float euclideanDistance(cv::Point& p1, cv::Point& p2)\n{\n  float dx = p1.x - p2.x;\n  float dy = p1.y - p2.y;\n  return std::sqrt(dx * dx + dy * dy);\n};\n\n/**\n * @function computeLBPImage_\n * @brief Creates an image representation of the LBP value for each pixel. (by binarizing...)\n * @param src Source Image (@link cv::Mat @endlink)\n */\ntemplate<class Elem, class Word>\ninline cv::Mat computeLBPImage_(cv::Mat& src)\n{\n\tcv::Mat dst = cv::Mat::zeros(src.size(), CV_8UC1);\n\tfor (int i = 1; i < src.rows - 1; ++i)\n    {\n        for (int j = 1; j < src.cols - 1; ++j)\n        {\n            std::vector<Elem> neighbors(8);\n            neighbors[0] = src.at<Elem>(i,     j + 1);\n            neighbors[1] = src.at<Elem>(i + 1, j + 1);\n            neighbors[2] = src.at<Elem>(i + 1, j);\n            neighbors[3] = src.at<Elem>(i + 1, j - 1);\n            neighbors[4] = src.at<Elem>(i,     j - 1);\n            neighbors[5] = src.at<Elem>(i - 1, j - 1);\n            neighbors[6] = src.at<Elem>(i - 1, j);\n            neighbors[7] = src.at<Elem>(i - 1, j + 1);\n            Elem c = src.at<Elem>(i, j);\n            Word word = 0;\n            for (size_t k = 0; k < neighbors.size(); ++k)\n            {\n                if (k > 0)\n                    word = word << 1;\n                unsigned char bit = neighbors[k] > c;\n                //cout << bit - 0;\n                //cout << \"val = \" << neighbors[k] - 0 << \"; thr = \" << bit - 0 << endl;\n                word |= bit;\n                //cout << \"word = \" << word  - 0 << endl;\n            }\n            //cout << endl << \"(\" << i << \",\" << j << \"): \" << \"word = \" << word - 0 << endl;\n            /*if (ntrans > 2)\n                cout << \"non-uniform!\" << endl;*/\n            // 85 is word representation of 01010101 (non-uniform pattern)\n            dst.at<Word>(i, j) = word;\n//            dstUnif.at<Word>(i, j) = ntrans > 2 ? 85 : word;\n        }\n    }\n    return dst;\n};\n\n/**\n * @function computeLBPImage\n * @brief Wrapper for computeLBPImage_ with standard types <unsigned char, unsigned char>\n */\ninline cv::Mat computeLBPImage(cv::Mat& src)\n{\n\treturn computeLBPImage_<unsigned char, unsigned char>(src);\n};\n\n/**\n * @function lbp_hist\n * @brief Creates an LBP Histogram.\n * @param src LBP image representation (see computeLBPImage)\n * @param dst Destination histogram\n * @param wordMap Mapping to uniform or identity patterns\n */\ntemplate<class Word, class Cnt>\ninline void lbp_hist_(cv::Mat& src, std::map<Word, Cnt>& dst, const std::map<Word, Word> &wordMap)\n{\n    dst.clear();\n    for (typename std::map<Word, Word>::const_iterator itr = wordMap.begin();\n         itr != wordMap.end(); ++itr)\n    {\n\t//printf(\"ITR->second: %i\\n\", itr->second);\n        dst[itr->second] = 0;\n    }\n    printf(\"Fertig!\\n\");\n    for (int i = 0; i < src.rows; ++i)\n    {\n        for (int j = 0; j < src.cols; ++j)\n        {\n            Word word = src.at<Word>(i, j);\n            typename std::map<Word, Word>::const_iterator itr = wordMap.find(word);\n            if (itr != wordMap.end())\n            {\n                //std::cout << \"converting \" << itr->first - 0 << \" to \" << itr->second - 0 << std::endl;\n                ++dst[itr->second];\n            }\n            else\n            {\n                ++dst[word];\n            }\n        }\n    }\n};\n\n/**\n * @function lbp_hist_add\n * @brief Add values of histogram bins of op1 in op2 to op1\n * @param op1 First histogram\n * @param op2 Second histogram\n */\n// add values of histogram bins of op1 in op2 to op1\ntemplate<class Word, class Cnt>\ninline void lbp_hist_add_(std::map<Word, Cnt>& op1, const std::map<Word, Cnt>& op2)\n{\n    for (typename std::map<Word, Cnt>::const_iterator itr = op2.begin();\n         itr != op2.end(); ++itr)\n    {\n        /*typename map<Word, Cnt>::const_iterator\n        itrF = op2.find(itr->first);\n        if (itrF != op2.end())\n          op1[itr->first] += itrF->second;\n        else\n        {\n          cerr << \"WARNING: histogram bin \" << itr->first\n               << \" not found in addition!\" << endl;\n        }*/\n        op1[itr->first] += itr->second;\n    }\n};\n\n/**\n * @function lbp_hist_normalize\n * @brief Normalizes the LBP Histogram.\n * @param op LBP histogram\n */\ntemplate<class Word, class Cnt>\ninline void lbp_hist_normalize_(std::map<Word, Cnt>& op)\n{\n    Cnt total = 0;\n    for (typename std::map<Word, Cnt>::const_iterator itr = op.begin();\n         itr != op.end(); ++itr)\n    {\n        total += itr->second;\n    }\n    for (typename std::map<Word, Cnt>::iterator itr = op.begin();\n         itr != op.end(); ++itr)\n    {\n        itr->second /= total;\n    }\n};\n\n/**\n * @function computeLBPHistogram_\n * @brief Template function for complete computation of LBP histograms, either with uniform patterns mapping or without\n * @param src LBP image representation (see computeLBPImage)\n * @param wordMap Mapping to uniform or identity patterns\n */\ntemplate<class Word, class Cnt>\ninline std::map<Word, Cnt> computeLBPHistogram_(cv::Mat& src, std::map<unsigned char, unsigned char>& wordMap, int normalize)\n{\n\tstd::map<Word, Cnt> lbpHist;\n\t\n\tlbp_hist_<Word, Cnt>(src, lbpHist, wordMap); // Create the histogram\n\t\n\t//lbp_hist_add_<Word, Cnt>(lbpHistAll, lbpHist); // Add to overall histogram, perhaps for averaging over time?\n\t\n\tif(normalize == 1)\n\t{\n\t\tlbp_hist_normalize_<Word, Cnt>(lbpHist); // Normalize the histogram\n\t}\n\t\n\treturn lbpHist;\n};\n\n/**\n * @function computeLBPHistogram\n * @brief Wrapper for computeLBPHistogram_ with standard types <unsigned char,float>\n */\ninline std::map<unsigned char, FLOAT_DMEM> computeLBPHistogram(cv::Mat& src, std::map<unsigned char, unsigned char>& wordMap, int normalize)\n{\n\treturn computeLBPHistogram_<unsigned char, FLOAT_DMEM>(src, wordMap, normalize);\n};\n\n/**\n * @function compute_uniform_map_\n * @brief ???\n * @return Map with uniform pattern words\n */\ntemplate<class Word>\ninline std::map<Word, Word> compute_uniform_map_()\n{\n\tstd::map<Word, Word> m;\n    m.clear();\n    int maxWord = (1 << (sizeof(Word) * 8)) - 1;\n    int nextIdx = 0;\n    std::vector<Word> nonunif;\n    for (int word = 0; word <= maxWord; ++word)\n    {\n        //std::cout << \"word \" << word - 0 << std::endl;\n        int wordTmp = word;\n        int ntrans = 0;\n        unsigned char lastBit;\n        for (int bit = 0; bit < sizeof(Word) * 8; ++bit)\n        {\n            // get LSB\n            unsigned char bitValue = wordTmp & 1;\n            //std::cout << bitValue - 0;\n            // shift right\n            wordTmp = wordTmp >> 1;\n            if (bit > 0 && bitValue != lastBit)\n            {\n                ++ntrans;\n            }\n            lastBit = bitValue;\n        }\n        //std::cout << std::endl;\n        if (ntrans > 2)\n        {\n            nonunif.push_back(word);\n            //std::cout << \"non-uniform word: \" << word << \" (ntrans = \" << ntrans << \")\" << std::endl;\n        }\n        else if (m.find(word) == m.end())\n        {\n            m[word] = nextIdx;\n            //std::cout << \"map word \" << word << \" to \" << nextIdx << std::endl;\n            ++nextIdx;\n        }\n    }\n    for (size_t k = 0; k < nonunif.size(); ++k)\n    {\n        m[nonunif[k]] = nextIdx;\n        //std::cout << \"map non-uniform word \" << nonunif[k] - 0 << \" to \" << nextIdx << std::endl;\n    }\n    return m;\n};\n\n/**\n * @function compute_identity_map_\n * @brief ???\n * @return Map with identity pattern words\n */\ntemplate<class Word>\ninline std::map<Word, Word> compute_identity_map_()\n{\n\tstd::map<Word, Word> m;\n    m.clear();\n    int maxWord = (1 << (sizeof(Word) * 8)) - 1;\n    for (int word = 0; word <= maxWord; ++word)\n    {\n        m[word] = word;\n    }\n    return m;\n};\n\n/**\n * @function cropFace\n * @brief Scales and rotates image, so that a image of the upright head of the size dstSize is returned.\n */\ninline void cropFace(const cv::Mat& src, cv::Mat& dst, cv::Point& leftEye, cv::Point& rightEye, float offsetXPct, float offsetYPct, cv::Size& dstSize)\n{\n  float offsetX = std::floor(offsetXPct * dstSize.width);\n  float offsetY = std::floor(offsetYPct * dstSize.height);\n  //float eyeDirX = rightEye.x - leftEye.x;\n  //float eyeDirY = rightEye.y - leftEye.y;\n  float rotation = std::atan2(float(rightEye.y - leftEye.y), float(rightEye.x - leftEye.x));\n  float rotationDeg = rotation * 180.0 / M_PI;\n  float dist = euclideanDistance(leftEye, rightEye);\n  float refDist = float(dstSize.width) - 2.0 * offsetX;\n  float scale = dist / refDist;\n  // cout << \"dist = \" << dist << endl;\n  //float scale = dist / (0.8 * float(dstSize.width));\n  /*float cosine = std::cos(rotation);\n  float sine = std::sin(rotation);*/\n  /*float rotMatData[] = {\n    cosine,\n    sine,\n    leftEye.x - leftEye.x * cosine - leftEye.y * sine,\n    -sine,\n    cosine,\n    leftEye.y + leftEye.x * sine - leftEye.y * cosine\n  };\n  cv::Mat rotMat(2, 3, CV_32F, rotMatData);*/\n  // std::cout << \"rotation = \" << rotation << \"; scale = \" << scale << std::endl;\n  //std::cout << rotMat << std::endl;\n  cv::Mat rotMat = cv::getRotationMatrix2D(leftEye, rotationDeg, 1.0);\n  //std::cout << rotMat << std::endl;\n  cv::Mat dst2 = cv::Mat::zeros(src.rows, src.cols, src.type());\n  cv::warpAffine(src, dst2, rotMat, dst2.size());\n  float cropX = leftEye.x - scale * offsetX;\n  float cropY = leftEye.y - scale * offsetY;\n  float cropSizeWidth = float(dstSize.width) * scale;\n  float cropSizeHeight = float(dstSize.height) * scale;\n  /*cout << \"ROI: (\" << cropX << \", \" << cropY << \") -> (\"\n     << (cropX + cropSizeWidth) << \", \" << (cropY + cropSizeHeight) << \")\" << endl;*/\n  cv::Rect roi(cropX, cropY, cropSizeWidth, cropSizeHeight);\n//  Rect roi(10, 10, 100, 100);\n  if (roi.x + roi.width >= dst2.cols)\n    roi.width = dst2.cols - roi.x - 1; // XXX: -1 ???\n  if (roi.y + roi.height >= dst2.rows)\n    roi.height = dst2.rows - roi.y - 1;\n  if (roi.x < 0)\n    roi.x = 0;\n  if (roi.y < 0)\n    roi.y = 0;\n  //std::cout << \"ROI: (\" << roi.x << \", \" << roi.y << \", \"\n  //   << roi.width << \", \" << roi.height << \")\" << std::endl;\n  //std::cout << \"Face size: \" << dst2.rows << \" x \" << dst2.cols << std::endl;\n  cv::Rect insideROI = roi & cv::Rect(0, 0, dst2.cols, dst2.rows);\n  if(insideROI.area() > 0)\n  {\n  \tcv::Mat cropped = dst2(insideROI);\n  \tcv::resize(cropped, dst, dstSize);\n  }\n  else\n  {\n  \tcv::resize(dst2, dst, dstSize);\n  }\n  //imshow( \"src\", src );\n  //imshow( \"rot\", dst2 );\n  //imshow( \"cropped\", cropped );\n  //imshow( \"dst\", dst );\n};\n\ntemplate<class Key, class Value>\ninline void print_map(const std::map<Key, Value>& m, std::ostream& os)\n{\n    os << \"[\" << std::endl;\n    for (typename std::map<Key, Value>::const_iterator itr = m.begin();\n         itr != m.end(); ++itr)\n    {\n        os << itr->first - 0 << \" => \" << itr->second - 0 << \",\" << std::endl;\n    }\n    os << \"]\" << std::endl;\n};\n\n\ntemplate<class Key, class Value>\ninline void print_map_values(const std::map<Key, Value>& m, std::ostream& os, char sep, char eol)\n{\n    for (typename std::map<Key, Value>::const_iterator itr = m.begin();\n         itr != m.end(); )\n    {\n        os << itr->second - 0;\n        if (++itr == m.end())\n            break;\n        os << sep;\n    }\n    os << eol;\n};\n\n/**\n * @function computeCircularLBPImage_\n * @brief Creates an image representation of the LBP value for each pixel. Instead of the surrounding pixels, bilinearly interpolated points on a circle around the center pixel are used.\n * @param src Source Image (@link cv::Mat @endlink)\n */\n\ntemplate<class Elem, class Word>\ninline cv::Mat computeCircularLBPImage_(cv::Mat& src, int radius, int points)\n{\n\tcv::Mat dst = cv::Mat::zeros(src.size(), CV_8UC1);\n\tunsigned char min, max;\n\tmin = 255;\n\tmax = 0;\n\tfor (int i = radius; i < src.rows - radius; ++i)\n    {\n        for (int j = radius; j < src.cols - radius; ++j)\n        {\n            std::vector<Elem> neighbors(8);\n            Word word = 0;\n            \n            for(int p = 0; p < points; ++p)\n            {\n                // Unit circle, start at the point below the center (x, y+1)\n                double x = static_cast<FLOAT_DMEM>(radius * sin(static_cast<FLOAT_DMEM>(2.0 * CV_PI * p / points)));\n                double y = static_cast<FLOAT_DMEM>(radius * cos(static_cast<FLOAT_DMEM>(2.0 * CV_PI * p / points)));\n                \n                // Discrete pixels, previous & next pixels for x and y -> 4 points\n                int x1 = static_cast<int>(floor(x));\n                int x2 = static_cast<int>(ceil(x));\n                int y1 = static_cast<int>(floor(y));\n                int y2 = static_cast<int>(ceil(y));\n                \n                // R1, R2\n                double R1 = static_cast<FLOAT_DMEM>((x2 - x) / (x2 - x1))*src.at<Elem>(x1, y1) + static_cast<FLOAT_DMEM>((x - x1) / (x2 - x1))*src.at<Elem>(x2, y1);\n                double R2 = static_cast<FLOAT_DMEM>((x2 - x) / (x2 - x1))*src.at<Elem>(x1, y2) + static_cast<FLOAT_DMEM>((x - x1) / (x2 - x1))*src.at<Elem>(x2, y2);\n                \n                // Interpolate between R1 and R2 -> desired value\n                Elem P = static_cast<Elem>(static_cast<FLOAT_DMEM>((y2 - y) / (y2 - y1))*R1 + static_cast<FLOAT_DMEM>((y - y1) / (y2 - y1))*R2);\n                \n                if (p > 0)\n                    word = word << 1;\n                    \n                unsigned char bit = P > src.at<Elem>(i, j);\n                word |= bit;\n                \n            }\n            dst.at<Word>(i, j) = word;\n\t    if(word < min)\n\t\tmin = word;\n\t    if(word > max)\n\t\tmax = word;\n\n        }\n    }\n    printf(\"Min: %i, Max: %i\\n\", min, max);\n\n    return dst;\n};\n\n/**\n * @function computeCircularLBPImage\n * @brief Wrapper for computeCircularLBPImage_ with standard types <unsigned char, unsigned char>\n * @param src Source Image (@link cv::Mat @endlink)\n * @param radius Radius of the circle, on which the points lie\n * @param points Number of neighbouring points (only 8 supported for now)\n */\ninline cv::Mat computeCircularLBPImage(cv::Mat& src, int radius, int points)\n{\n        // At the moment, only 8 points are supported. To support more points, choose the right data type\n\treturn computeCircularLBPImage_<unsigned char, unsigned char>(src, radius, 8);\n};\n\n} // End namespace LBPHistogram\n\n#endif // HAVE_OPENCV\n\n#endif /* OPENCV_LBPHISTOGRAM_HPP_ */\n"
  },
  {
    "path": "src/include/video/openCV_OpticalFlow.hpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n/*\nopenCV_OpticalFlow\nAuthor: Florian Gross\n\n*/\n\n#ifndef OPENCV_OPTICALFLOW_HPP_\n#define OPENCV_OPTICALFLOW_HPP_\n\n#ifdef HAVE_OPENCV\n\n#include \"opencv2/objdetect/objdetect.hpp\"\n#include \"opencv2/highgui/highgui.hpp\"\n#include \"opencv2/imgproc/imgproc.hpp\"\n#include \"opencv2/video/video.hpp\"\n\n\nnamespace OpticalFlow {\n\nclass FrameFtExtrParams{\npublic:\n\t//number of histogram bins for optical flow analysis\n\tint flo_bins;\n\tFLOAT_DMEM max_flow; //percentual maximum flow for histogram analysis (relative to image width)\n\tFLOAT_DMEM flow_downsample; //downsampling ratio for flow anaylsis (0.5 is half image size)\n};\n\n/**\n * @function computeOpticalFlowHistogram\n * @brief Computes the optical flow histogram.\n */\ninline std::vector<FLOAT_DMEM> computeOpticalFlowHistogram(cv::Mat& frame_gray_resized, cv::Mat& prevFrame_gray_resized, FrameFtExtrParams& params, int display, int normalize)\n{\n\tstd::vector<FLOAT_DMEM> ft_vec;\n\tft_vec.clear();\n\n\n\t// ### OPTICAL FLOW ANALYSIS ##########################################################################\n\n\t//calculate optical flow histogram using current frame and previous frame. If no previous frame found, output empty histogram of suitable size.\n\t//TODO: How to distinguish between pan/zoom and character movement?\n\tcv::MatND flo_hist;\n\tcv::Scalar mean_flow(0, 0);\n\tcv::Scalar stddev_flow(0, 0);\n\n\tFLOAT_DMEM px_nrm_fact_x = 1.0f / static_cast<FLOAT_DMEM>(frame_gray_resized.cols);\n\tFLOAT_DMEM px_nrm_fact_y = 1.0f / static_cast<FLOAT_DMEM>(frame_gray_resized.rows);\n\tint fhist_size[] = {params.flo_bins};\n\tFLOAT_DMEM f_ranges[] = {0.0, params.max_flow};\n\tconst FLOAT_DMEM *fhist_ranges[] = {f_ranges};\n\tint fhist_channels[] = {0};\n\tif (!prevFrame_gray_resized.empty()){\n\t\t//std::cout << \"Perform optical flow analysis\\n\";\n\t\tcv::Mat flow_img, flo_abs;\n\t\tcalcOpticalFlowFarneback(frame_gray_resized, prevFrame_gray_resized, flow_img, 0.5, 5, 10, 10, 5, 1.0, cv::OPTFLOW_FARNEBACK_GAUSSIAN);\n\n\t\t//convert into an image of screen-relative displacements\n\t\tfor (int cidx = 0; cidx < flow_img.cols; cidx++){\n\t\t\tfor (int ridx = 0; ridx < flow_img.rows; ridx++){\n\t\t\t\tcv::Point2f pixgrad = flow_img.at<cv::Point2f>(ridx, cidx);\n\t\t\t\tpixgrad.x *= px_nrm_fact_x;\n\t\t\t\tpixgrad.y *= px_nrm_fact_y;\n\t\t\t\tflow_img.at<cv::Point2f>(ridx, cidx) = pixgrad;\n\t\t\t}\n\t\t}\n\n\t\tcv::meanStdDev(flow_img, mean_flow, stddev_flow);\n\t\t//std::cout << mean_flow << \", \" << stddev_flow << \"\\n\";\n\t\tflo_abs.create(flow_img.rows, flow_img.cols, CV_32FC1);\n\t\tFLOAT_DMEM max_x = 0;\n\t\tFLOAT_DMEM max_y = 0;\n\t\t//get amount of flow for each pixel\n\t\tfor (int cidx = 0; cidx < flow_img.cols; cidx++){\n\t\t\tfor (int ridx = 0; ridx < flow_img.rows; ridx++){\n\t\t\t\tcv::Point2f pixgrad = flow_img.at<cv::Point2f>(ridx, cidx);\n\t\t\t\t//pixgrad.x -= mean_flow.at<FLOAT_DMEM>(0);\n\t\t\t\t//pixgrad.y -= mean_flow.at<FLOAT_DMEM>(1);\n\t\t\t\tflo_abs.at<FLOAT_DMEM>(ridx, cidx) = sqrt(pixgrad.x*pixgrad.x + pixgrad.y*pixgrad.y);\n\t\t\t\tmax_x = std::max(max_x, std::abs(pixgrad.x));\n\t\t\t\tmax_y = std::max(max_y, std::abs(pixgrad.y));\n\t\t\t}\n\t\t}\n\t\t//std::cout << \"Maximum gradients \" << max_x << \", \" << max_y << \"\\n\";\n\t\t//TODO: Find absolute normalization scheme\n\t\tcv::Mat flo_nrm;\n\t\tcv::normalize(flo_abs, flo_nrm, 0, 255, cv::NORM_MINMAX, CV_8UC1);\n\t\tcv::Mat tmp_disp_img = flo_nrm.clone();\n\n\t\tif(display)\n\t\t{\n\t\t\tcv::imshow(\"DenseOpticalFlow\", tmp_disp_img);\n\t\t}\n\n\t\t//get optical flow amount histogram\n\t\tcv::calcHist(&flo_abs, 1, fhist_channels, cv::Mat(), flo_hist, 1, fhist_size, fhist_ranges, true);\n\t\t\n\t\tif(normalize == 1)\n\t\t{\n\t\t\tcv::normalize(flo_hist, flo_hist, 1, 0, cv::NORM_L1, -1, cv::Mat()); // L1-norm\n\t\t}\n\n\t\t//std::vector<FLOAT_DMEM> flo_zero_hist(par.flo_bins, 0);\n\t\t//flo_hist = cv::Mat(flo_zero_hist);\n\t} else {\n\t\tstd::cout << \"Skip optical flow analysis, no previous frame stored\\n\";\n\t\tstd::vector<FLOAT_DMEM> flo_zero_hist(params.flo_bins, 0);\n\t\tflo_hist = cv::Mat(flo_zero_hist);\n\t}\n\tft_vec.push_back(mean_flow[0]);\n\tft_vec.push_back(mean_flow[1]);\n\tft_vec.push_back(stddev_flow[0]);\n\tft_vec.push_back(stddev_flow[1]);\n\n\tfor (int i = 0; i < params.flo_bins; i++){\n\t\tft_vec.push_back(flo_hist.at<FLOAT_DMEM>(i));\n\t}\n\n\treturn ft_vec;\n}\n\n} // End namespace OpticalFlow\n\n#endif // HAVE_OPENCV\n\n#endif /* OPENCV_OPTICALFLOW_HPP_ */\n"
  },
  {
    "path": "src/io/libsvmSink.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nLibSVM feature file output\n\n*/\n\n\n#include <io/libsvmSink.hpp>\n\n#define MODULE \"cLibsvmSink\"\n\n\nSMILECOMPONENT_STATICS(cLibsvmSink)\n\nSMILECOMPONENT_REGCOMP(cLibsvmSink)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CLIBSVMSINK;\n  sdescription = COMPONENT_DESCRIPTION_CLIBSVMSINK;\n\n  // we inherit cDataSink configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSink\")\n\n  SMILECOMPONENT_IFNOTREGAGAIN_BEGIN\n    ct->setField(\"filename\",\"Output filename of libsvm formant file\",\"smileoutput.lsvm\");\n    ct->setField(\"lag\",\"output data <lag> frames behind\",0,0,0);\n    ct->setField(\"append\",\"Whether to append to existing file or not (1/0 = yes/no)\",0);\n    ct->setField(\"timestamp\",\"1 = print timestamp attribute (0 = no)\",1);\n    ct->setField(\"instanceBase\",\"If not empty, print instance name attribute <instanceBase_Nr>\",\"\",0,0);\n    ct->setField(\"instanceName\",\"If not empty, print instance name attribute <instanceName>\",\"\",0,0);\n//    ct->setField(\"number\",\"print instance number (= frameIndex) attribute (1/0 = yes/no)\",1);\n\n    ct->setField(\"class\",\"Optional definition of class-name strings (each element is the name of one class, i.e. if you have 7 classes, the array should have seven entries; the names will be mapped to class numbers internally, since the libsvm format requires numbers as class labels). This feature allows for passing ground-truth information by class name (using the targetStrAll or targetStr options) directly on the command-line and makes post-editing of feature files obsolete.\", \"classX\", ARRAY_TYPE);\n    ct->setField(\"targetNum\",\"Targets/Ground truths (as numbers/indicies) for each instance\",0,ARRAY_TYPE);\n    ct->setField(\"targetStr\",\"Targets/Ground truths (as strings) for each instance\",\"classX\",ARRAY_TYPE);\n    ct->setField(\"targetNumAll\",\"Target/Ground truth (as numbers/indicies) for all instances\",0);\n    ct->setField(\"targetStrAll\",\"Target/Ground truth (as strings) for all instances\",\"classX\");\n\n  SMILECOMPONENT_IFNOTREGAGAIN_END\n\n  SMILECOMPONENT_MAKEINFO(cLibsvmSink);\n}\n\nSMILECOMPONENT_CREATE(cLibsvmSink)\n\n//-----\n\ncLibsvmSink::cLibsvmSink(const char *_name) :\n  cDataSink(_name),\n  filehandle(NULL),\n  filename(NULL),\n  nInst(0),\n  nClasses(0),\n  inr(0),\n  targetNumAll(0),\n  classname(NULL), target(NULL)\n{\n}\n\nvoid cLibsvmSink::fetchConfig()\n{\n  cDataSink::fetchConfig();\n  \n  filename = getStr(\"filename\");\n  SMILE_DBG(3,\"filename = '%s'\",filename);\n\n  lag = getInt(\"lag\");\n  SMILE_DBG(3,\"lag = %i\",lag);\n\n  append = getInt(\"append\");\n  if (append) { SMILE_DBG(3,\"append to file is enabled\"); }\n\n  timestamp = getInt(\"timestamp\");\n  if (append) { SMILE_DBG(3,\"printing timestamp attribute (index 1) enabled\"); }\n\n  instanceBase = getStr(\"instanceBase\");\n  SMILE_DBG(3,\"instanceBase = '%s'\",instanceBase);\n\n  instanceName = getStr(\"instanceName\");\n  SMILE_DBG(3,\"instanceName = '%s'\",instanceName);\n  \n  int i;\n  nClasses = getArraySize(\"class\");\n  classname = (char**)calloc(1,sizeof(char*)*nClasses);\n  for (i=0; i<nClasses; i++) {\n    const char *tmp = getStr_f(myvprint(\"class[%i]\",i));\n    if (tmp!=NULL) classname[i] = strdup(tmp);\n  }\n\n  if (isSet(\"targetNumAll\")) {\n    targetNumAll = getInt(\"targetNumAll\");\n  }\n  if (isSet(\"targetStrAll\")) {\n    if (nClasses <=0) COMP_ERR(\"cannt have 'targetStrAll' option if no class names have been defined using the 'class' option! (inst '%s')\",getInstName());\n    targetNumAll = getClassIndex(getStr(\"targetStrAll\"));\n  }\n  nInst = getArraySize(\"targetNum\");\n  if (nInst > 0) {\n    target = (int *)calloc(1,sizeof(int)*nInst);\n    for (i=0; i<nInst; i++) {\n      target[i] = getInt_f(myvprint(\"targetNum[%i]\",i));\n      if (target[i] < 0) COMP_ERR(\"invalid class index %i for instance %i (in 'targetNum' option of instance '%s')\",target[i],i,getInstName());\n    }\n  } else {\n    nInst = getArraySize(\"targetStr\");\n    if (nInst > 0) {\n      if (nClasses <=0) COMP_ERR(\"cannt have 'targetStr' option if no class names have been defined using the 'class' option! (inst '%s')\",getInstName());\n      target = (int *)calloc(1,sizeof(int)*nInst);\n      for (i=0; i<nInst; i++) {\n        target[i] = getClassIndex(getStr_f(myvprint(\"targetStr[%i]\",i)));\n        if (target[i] < 0) COMP_ERR(\"invalid class index %i for instance %i (from class '%s' in 'targetStr' option of instance '%s')\",target[i],i,getStr_f(myvprint(\"targetStr[%i]\",i)),getInstName());\n      }\n    } else { nInst = 0; }\n  }\n\n}\n\n/*\nint cLibsvmSink::myConfigureInstance()\n{\n  int ret=1;\n  ret *= cDataSink::myConfigureInstance();\n  // ....\n  //return ret;\n}\n*/\n\n\nint cLibsvmSink::myFinaliseInstance()\n{\n  int ap=0;\n\n  int ret = cDataSink::myFinaliseInstance();\n  if (ret==0) return 0;\n  \n  if (append) {\n    // check if file exists:\n    filehandle = fopen(filename, \"r\");\n    if (filehandle != NULL) {\n      fclose(filehandle);\n      filehandle = fopen(filename, \"a\");\n      ap=1;\n    } else {\n      filehandle = fopen(filename, \"w\");\n    }\n  } else {\n    filehandle = fopen(filename, \"w\");\n  }\n  if (filehandle == NULL) {\n    COMP_ERR(\"Error opening file '%s' for writing (component instance '%s', type '%s')\",filename, getInstName(), getTypeName());\n  }\n  \n//  if (!ap) {\n  // write header ....\n//  if (timestamp) {\n//    fprintf(filehandle, \"@attribute frameTime numeric%s\",NEWLINE);\n//  }\n/*\n  long _N = reader->getLevelN();\n  long i;\n  for(i=0; i<_N; i++) {\n    char *tmp = reader->getElementName(i);\n    fprintf(filehandle, \"@attribute %s numeric%s\",tmp,NEWLINE);\n    free(tmp);\n  }\n*/\n//  }\n  \n  return ret;\n}\n\n\nint cLibsvmSink::myTick(long long t)\n{\n  if (filehandle == NULL) return 0;\n\n  SMILE_DBG(4,\"tick # %i, writing to lsvm file (lag=%i):\",t,lag);\n  cVector *vec= reader_->getFrameRel(lag);  //new cVector(nValues+1);\n  if (vec == NULL) return 0;\n  //else reader->nextFrame();\n\n  long vi = vec->tmeta->vIdx;\n  double tm = vec->tmeta->time;\n  long idx = 1;\n  \n/*\n  if (prname==1) {\n    fprintf(filehandle,\"'%s',\",instanceName);\n  } else if (prname==2) {\n    fprintf(filehandle,\"'%s_%i',\",instanceBase,vi);\n  }\n  */\n  // classes: TODO:::\n  if ((nClasses > 0)&&(nInst>0)) {  // per instance classes\n    if (inr >= nInst) {\n      SMILE_WRN(3,\"more instances written to LibSVM file (%i), then there are targets available for (%i)!\",inr,nInst);\n      fprintf(filehandle,\"%i \",targetNumAll);\n    } else {\n      fprintf(filehandle,\"%i \",target[inr++]);\n    }\n  } else {\n    fprintf(filehandle,\"%i \",targetNumAll);\n  }\n\n//  if (number) fprintf(filehandle,\"%i:%i \",idx++,vi);\n  if (timestamp) fprintf(filehandle,\"%i:%f \",idx++,tm);\n\n  \n  // now print the vector:\n  int i;\n  fprintf(filehandle,\"%i:%e \",idx++,vec->dataF[0]);\n  for (i=1; i<vec->N; i++) {\n    fprintf(filehandle,\"%i:%e \",idx++,vec->dataF[i]);\n  }\n\n  fprintf(filehandle,\"%s\",NEWLINE);\n\n  // tick success\n  return 1;\n}\n\n\ncLibsvmSink::~cLibsvmSink()\n{\n  fclose(filehandle);\n  int i;\n  if (classname!=NULL) {\n    for (i=0; i<nClasses; i++) if (classname[i] != NULL) free(classname[i]);\n    free(classname);\n  }\n  if (target!=NULL) free(target);\n}\n\n"
  },
  {
    "path": "src/iocore/arffSink.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\narffSink\nARFF file output (for WEKA)\n\n*/\n\n\n#include <iocore/arffSink.hpp>\n\n#define MODULE \"cArffSink\"\n\n/*Library:\nsComponentInfo * registerMe(cConfigManager *_confman) {\n  cDataSink::registerComponent(_confman);\n}\n*/\n\nSMILECOMPONENT_STATICS(cArffSink)\n\n//sComponentInfo * cArffSink::registerComponent(cConfigManager *_confman)\nSMILECOMPONENT_REGCOMP(cArffSink)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CARFFSINK;\n  sdescription = COMPONENT_DESCRIPTION_CARFFSINK;\n\n  // we inherit cDataSink configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSink\")\n\n  SMILECOMPONENT_IFNOTREGAGAIN_BEGIN\n    ct->setField(\"filename\",\"The filename of the ARFF file to write to. An empty filename disables this sink component.\",\"smileoutput.arff\");\n    ct->setField(\"lag\",\"output data <lag> frames behind\",0,0,0);\n    ct->setField(\"append\",\"1 = append to an existing file, or create a new file; 0 = overwrite an existing file, or create a new file\",0);\n    ct->setField(\"relation\",\"The name of the ARFF relation (@relation tag)\",\"smile\");\n    ct->setField(\"instanceBase\",\"If this string is not empty and not equal to '-', cArffSink prints an instance name attribute <instanceBase_Nr>, where Nr is the number (continuous index) of current instance\",\"\");\n    ct->setField(\"instanceName\",\"If this string is not empty and not equal to '-', cArffSink prints an instance name attribute <instanceName> for all instances. instanceName overwrites instanceBase.\",\"\");\n    ct->setField(\"instanceNameFromMetadata\",\"1/0 = yes/no. Use instanceName from metadata, if available. If this is not available, printing of an instance name depends on 'instanceName' and 'instanceBase' attributes.\",0);\n    ct->setField(\"useTargetsFromMetadata\",\"1/0 = yes/no. Use string of target values/classes from vector metadata instead of building it from the 'target' array. If no metadata is present the target string will be built from the 'target' array\",0);\n    ct->setField(\"number\",\"'Synonym' for the 'frameIndex' option: 1 = print an instance number (= frameIndex) attribute (continuous index) (1/0 = yes/no)\",1);\n    ct->setField(\"timestamp\",\"'Synonym' for the 'frameTime' option: 1 = print a timestamp (=frameTime) attribute (1/0 = yes/no)\",1);\n    ct->setField(\"frameIndex\",\"1 = print an instance number (= frameIndex) attribute (continuous index) (1/0 = yes/no) (same as 'number' option)\",1);\n    ct->setField(\"frameTime\",\"1 = print a timestamp (=frameTime) attribute (1/0 = yes/no) (same as 'timestamp' option)\",1);\n    ct->setField(\"frameTimeAdd\",\"Add this value to the framTime values (unit: seconds)\",0);\n    ct->setField(\"frameLength\",\"1 = print a frame length attribute (1/0 = yes/no).\",0);\n\n    ConfigType * classType = new ConfigType(\"arffClass\");\n    classType->setField(\"name\", \"The name of the target attribute\", \"class\");\n    classType->setField(\"type\", \"The type of the target attribute: 'numeric', 'string', or nominal (= list of classes, enclosed in {} )\", \"numeric\");\n    ct->setField(\"class\",\"This is an array defining the optional class target attributes (grund-truths that you want to have included in your arff file along with your features). It is an array for multiple targets/classes. See also the 'target' array.\", classType, ARRAY_TYPE);\n    ct->setField(\"printDefaultClassDummyAttribute\", \"1/0 = yes/no, print default class dummy attribute if no class attributes are given in the class[] array. Default is 1 for backward compatibility. Set to 0 to remove default class attribute.\", 1);\n\n    ConfigType * targetType = new ConfigType(\"arffTarget\");\n    targetType->setField(\"instance\", \"An array containing a target for each instance \", \"\",ARRAY_TYPE);\n    targetType->setField(\"all\", \"Assign this one target to all processed instances. You can use this option if you pass only one instance to cArffSink when openSMILE is run. (This option is used by a lot batch feature extraction scripts)\", \"\");\n    \n    ct->setField(\"target\",\"The ground truth targets (classes) for each target (class) attribute\",targetType,ARRAY_TYPE);\n \n    // overwrite default for this option inherited from the parent class\n    ct->setField(\"errorOnNoOutput\",(const char*)NULL,1);\n\n    // TODO: custom fields, import from file, merge arff streams...\n    \n  SMILECOMPONENT_IFNOTREGAGAIN_END\n\n  SMILECOMPONENT_MAKEINFO(cArffSink);\n}\n\nSMILECOMPONENT_CREATE(cArffSink)\n\n//-----\n\ncArffSink::cArffSink(const char *_name) :\n  cDataSink(_name),\n  prname(0),\n  filehandle(NULL),\n  filename(NULL),\n  nInst(0),\n  nClasses(0),\n  inr(0),\n  classname(NULL), classtype(NULL),\n  targetall(NULL), targetinst(NULL),\n  disabledSink_(false)\n{\n}\n\nvoid cArffSink::fetchConfig()\n{\n  cDataSink::fetchConfig();\n  \n  filename = getStr(\"filename\");\n  if (filename == NULL || *filename == 0 || (*filename == '?' && *(filename+1) == 0)) {\n    SMILE_IMSG(2, \"No filename given, disabling this sink component.\");\n    disabledSink_ = true;\n    errorOnNoOutput_ = 0;\n  }\n\n  lag = getInt(\"lag\");\n  SMILE_IDBG(3,\"lag = %i\",lag);\n\n  append = getInt(\"append\");\n  if (append) { SMILE_IDBG(3,\"append to file is enabled\"); }\n\n  printDefaultClassDummyAttribute = getInt(\"printDefaultClassDummyAttribute\");\n  \n  if (isSet(\"frameTime\")) timestamp = getInt(\"frameTime\");\n  else timestamp = getInt(\"timestamp\");\n  if (timestamp) { SMILE_IDBG(3,\"printing timestamp attribute enabled\"); }\n\n  if (isSet(\"frameIndex\")) number = getInt(\"frameIndex\");\n  else number = getInt(\"number\");\n  if (number) { SMILE_IDBG(3,\"printing instance number (=frame number) attribute enabled\"); }\n\n  frameLength = getInt(\"frameLength\");\n\n  relation = getStr(\"relation\");\n  SMILE_IDBG(3,\"ARFF relation = '%s'\",relation);\n\n  instanceBase = getStr(\"instanceBase\");\n  SMILE_IDBG(3,\"instanceBase = '%s'\",instanceBase);\n\n  instanceName = getStr(\"instanceName\");\n  SMILE_IDBG(3,\"instanceName = '%s'\",instanceName);\n  \n  int i;\n  nClasses = getArraySize(\"class\");\n  //printf(\"nclasses: %i\\n\", nClasses);\n  classname = (char**)calloc(1,sizeof(char*)*nClasses);\n  classtype = (char**)calloc(1,sizeof(char*)*nClasses);\n  for (i=0; i<nClasses; i++) {\n    const char *tmp = getStr_f(myvprint(\"class[%i].name\",i));\n    if (tmp!=NULL) classname[i] = strdup(tmp);\n    tmp = getStr_f(myvprint(\"class[%i].type\",i));\n    if (tmp!=NULL) classtype[i] = strdup(tmp);\n  }\n/*\n    ConfigType * classType = new ConfigType(\"arffClass\");\n    classType->setField(\"name\", \"name of target\", \"class\");\n    classType->setField(\"type\", \"numeric, or nominal (= list of classes)\", \"numeric\");\n    ct->setField(\"class\",\"definition of class target attributes (array for multiple targets/classes)\", classType, ARRAY_TYPE);\n\n    ConfigType * targetType = new ConfigType(\"arffTarget\");\n    targetType->setField(\"instance\", \"array containing targets for each instance\", 0,ARRAY_TYPE);\n    targetType->setField(\"all\", \"one common target for all processed instances\", 0);\n*/\n\n  if (getArraySize(\"target\") != nClasses) {\n    SMILE_ERR(1,\"number of targets (%i) is != number of class attributes (%i)!\",getArraySize(\"target\"),nClasses);\n  } else {\n    targetall = (char**)calloc(1,sizeof(char*)*nClasses);\n    targetinst = (char***)calloc(1,sizeof(char**)*nClasses);\n    nInst = -2;\n    for (i=0; i<nClasses; i++) {\n      char *tmp = myvprint(\"target[%i].instance\",i);\n      const char *t = getStr_f(myvprint(\"target[%i].all\",i));\n      if (t!=NULL) targetall[i] = strdup(t);\n      long ni = getArraySize(tmp);\n      if (nInst==-2) nInst = ni; // -1 if no array\n      else {\n        if (nInst != ni) COMP_ERR(\"number of instances in target[].instance array is not constant among all targets! %i <> %i\",nInst,ni);\n      }\n      int j;\n      if (nInst > 0) {\n        targetinst[i] = (char**)calloc(1,sizeof(char*)*nInst);\n        for (j=0; j<nInst; j++) {\n          t = getStr_f(myvprint(\"%s[%i]\",tmp,j));\n          if (t!=NULL) targetinst[i][j] = strdup(t);\n        }\n      }\n      free(tmp);\n    }\n  }\n\n  instanceNameFromMetadata = getInt(\"instanceNameFromMetadata\");\n  SMILE_IDBG(2,\"instanceNameFromMetadata = %i\",instanceNameFromMetadata);\n  useTargetsFromMetadata = getInt(\"useTargetsFromMetadata\");\n  SMILE_IDBG(2,\"useTargetsFromMetadata = %i\",useTargetsFromMetadata);\n  frameTimeAdd= getDouble(\"frameTimeAdd\");\n//    ct->setField(\"target\",\"targets (classes) for each target (class) attribute\",targetType,ARRAY_TYPE);\n}\n\nint cArffSink::myFinaliseInstance()\n{\n  int ap=0;\n  if (disabledSink_) {\n    filehandle = NULL;\n    return 1;\n  }\n  int ret = cDataSink::myFinaliseInstance();\n  if (ret==0) return 0;\n\n  if (append) {\n    // check if file exists:\n    filehandle = fopen(filename, \"r\");\n    if (filehandle != NULL) {\n      fclose(filehandle);\n      filehandle = fopen(filename, \"a\");\n      ap=1;\n    } else {\n      filehandle = fopen(filename, \"w\");\n    }\n  } else {\n    filehandle = fopen(filename, \"w\");\n  }\n  if (filehandle == NULL) {\n    COMP_ERR(\"Error opening file '%s' for writing (component instance '%s', type '%s')\",filename, getInstName(), getTypeName());\n  }\n\n  if (instanceNameFromMetadata) {\n    prname = 1;\n  } else {\n    if ((instanceBase!=NULL)&&(strlen(instanceBase)>0)&&\n        (instanceBase[0] != '-' || strlen(instanceBase) > 1)\n       ) prname = 2;\n    if ((instanceName!=NULL)&&(strlen(instanceName)>0)&&\n        (instanceName[0] != '-' || strlen(instanceName) > 1)\n       ) prname = 1;\n  }\n  long _N = reader_->getLevelN();\n\n  if (!ap) {\n    // write arff header ....\n    fprintf(filehandle, \"@relation %s%s%s\",relation,NEWLINE,NEWLINE);\n    if (prname) {\n      fprintf(filehandle, \"@attribute name string%s\",NEWLINE);\n    }\n    if (number) {\n      fprintf(filehandle, \"@attribute frameIndex numeric%s\",NEWLINE);\n    }\n    if (timestamp) {\n      fprintf(filehandle, \"@attribute frameTime numeric%s\",NEWLINE);\n    }\n    if (frameLength) {\n      fprintf(filehandle, \"@attribute frameLength numeric%s\",NEWLINE);\n    }\n\n    long i;\n    if (_N > 10000) {\n      SMILE_IMSG(2,\"writing ARFF header (%i features), this may take a while (it is a lot of data and heavy weight string formatting) ...\",_N);\n    } else {\n      SMILE_IMSG(2,\"writing ARFF header (%i features)...\",_N);\n    }\n    for(i=0; i<_N; i++) {\n      char *tmp = reader_->getElementName(i);\n      fprintf(filehandle, \"@attribute %s numeric%s\",tmp,NEWLINE);\n      free(tmp);\n      if ((i>0)&&(i%20000==0)) {\n        SMILE_IMSG(2,\"Status: %i feature names written.\",i);\n      }\n    }\n    if (_N > 6000) {\n      SMILE_IMSG(2,\"finished writing ARFF header.\");\n    }\n\n    // TODO: classes..... as config file options...\n    if (nClasses > 0) {\n      for (i=0; i<nClasses; i++) {\n        if (classtype[i] == NULL) fprintf(filehandle, \"@attribute %s numeric%s\",classname[i],NEWLINE);\n        else fprintf(filehandle, \"@attribute %s %s%s\",classname[i],classtype[i],NEWLINE);\n      }\n    } else {\n      // default dummy class attribute...\n      if (printDefaultClassDummyAttribute) {\n        fprintf(filehandle, \"@attribute class {0,1,2,3}%s\",NEWLINE);\n      }\n    }\n    fprintf(filehandle, \"%s@data%s%s\",NEWLINE,NEWLINE,NEWLINE);\n    fflush(filehandle);\n  }\n  return ret;\n}\n\n\nint cArffSink::myTick(long long t)\n{\n  if (filehandle == NULL) return 0;\n\n  SMILE_DBG(4,\"tick # %i, reading value vector (lag=%i):\",t,lag);\n  cVector *vec= reader_->getFrameRel(lag);  //new cVector(nValues+1);\n  if (vec == NULL) return 0;\n  //else reader->nextFrame();\n\n  long vi = vec->tmeta->vIdx;\n  double tm = vec->tmeta->time;\n  double len = vec->tmeta->lengthSec;\n\n  if (vec->tmeta->metadata.iData[1] == 1234) {\n    instanceName = vec->tmeta->metadata.text;\n    if (prname==1) {\n      fprintf(filehandle,\"%s,\",instanceName);\n    }\n  } else {\n    if (prname==1) {\n      fprintf(filehandle,\"'%s',\",instanceName);\n    } else if (prname==2) {\n      fprintf(filehandle,\"'%s_%i',\",instanceBase,vi);\n    }\n  }\n\n  if (number) fprintf(filehandle,\"%i,\",vi);\n  if (timestamp) fprintf(filehandle,\"%f,\",tm+frameTimeAdd);\n  if (frameLength) fprintf(filehandle,\"%f,\",len);\n  \n  // now print the vector:\n  int i;\n  fprintf(filehandle,\"%e\",vec->dataF[0]);\n  for (i=1; i<vec->N; i++) {\n    fprintf(filehandle,\",%e\",vec->dataF[i]);\n    //printf(\"  (a=%i vi=%i, tm=%fs) %s.%s = %f\\n\",reader->getCurR(),vi,tm,reader->getLevelName(),vec->name(i),vec->dataF[i]);\n  }\n\n  // classes: \n  if ((vec->tmeta->metadata.iData[1] == 1234)&&(vec->tmeta->metadata.custom != NULL)&&(vec->tmeta->metadata.customLength > 0)&&(useTargetsFromMetadata)) {\n    // TODO: check the order of the fields....\n    fprintf(filehandle, \",%s\", (const char *)(vec->tmeta->metadata.custom));\n  } else {\n    if (nClasses > 0) {\n      if (nInst>0) {\n        if (inr >= nInst) {\n          SMILE_WRN(3,\"more instances writte to ARFF file, then there are targets available for (%i)!\",nInst);\n          if (targetall != NULL) {\n            for (i=0; i<nClasses; i++) {\n              if (targetall[i] != NULL)\n                fprintf(filehandle,\",%s\",targetall[i]);\n              else\n                fprintf(filehandle,\",NULL\");\n            }\n          } else {\n            for (i=0; i<nClasses; i++) {\n              fprintf(filehandle,\",NULL\");\n            }\n          }\n          //inr++;\n        } else {\n          for (i=0; i<nClasses; i++) {\n            fprintf(filehandle,\",%s\",targetinst[i][inr]);\n          }\n          inr++;\n        }\n      } else {\n        if (targetall != NULL) {\n          for (i=0; i<nClasses; i++) {\n            if (targetall[i] != NULL)\n              fprintf(filehandle,\",%s\",targetall[i]);\n            else\n              fprintf(filehandle,\",NULL\");\n          }\n        } else {\n          for (i=0; i<nClasses; i++) {\n            fprintf(filehandle,\",NULL\");\n          }\n        }\n      }\n    } else {\n      // dummy class attribute, always 0\n      if (printDefaultClassDummyAttribute) {\n        fprintf(filehandle,\",0\");\n      }\n    }\n  }\n\n  fprintf(filehandle,\"%s\",NEWLINE);\n\n  int err = fflush(filehandle);\n  if (err == EOF) {\n    SMILE_IERR(1,\"error writing to file '%s' (code: %i)\",filename,errno);\n    COMP_ERR(\"aborting\");\n    return 0;\n  }\n\n  nWritten_++;\n\n  // tick success\n  return 1;\n}\n\n\ncArffSink::~cArffSink()\n{\n  if (filehandle != NULL) {\n    fclose(filehandle);\n    filehandle = NULL;\n  }\n  int i;\n  if (classname!=NULL) {\n    for (i=0; i<nClasses; i++) if (classname[i] != NULL) free(classname[i]);\n    free(classname);\n  }\n  if (classtype!=NULL) {\n    for (i=0; i<nClasses; i++) if (classtype[i] != NULL) free(classtype[i]);\n    free(classtype);\n  }\n  if (targetall!=NULL) {\n    for (i=0; i<nClasses; i++) if (targetall[i] != NULL) free(targetall[i]);\n    free(targetall);\n  }\n  if (targetinst!=NULL) {\n    int j;\n    for (i=0; i<nClasses; i++) {\n      if (targetinst[i] != NULL) {\n        for (j=0; j<nInst; j++) {\n          if (targetinst[i][j] != NULL) free(targetinst[i][j]);\n        }\n        free(targetinst[i]);\n      }\n    }\n    free(targetinst);\n  }\n}\n\n"
  },
  {
    "path": "src/iocore/arffSource.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample dataSource\nwrites data to data memory...\n\n*/\n\n\n#include <iocore/arffSource.hpp>\n\n\n\n#define MODULE \"cArffSource\"\n\n/*Library:\nsComponentInfo * registerMe(cConfigManager *_confman) {\n  cDataSource::registerComponent(_confman);\n}\n*/\n#define N_ALLOC_BLOCK 50\n\nSMILECOMPONENT_STATICS(cArffSource)\n\n//sComponentInfo * cArffSource::registerComponent(cConfigManager *_confman)\nSMILECOMPONENT_REGCOMP(cArffSource)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n/*  if (_confman == NULL) return NULL;\n  int rA = 0;\n  sconfman = _confman;\n*/\n  scname = COMPONENT_NAME_CARFFSOURCE;\n  sdescription = COMPONENT_DESCRIPTION_CARFFSOURCE;\n\n  // we inherit cDataSource configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSource\")\n/*\n  ConfigType *ct = new ConfigType( *(sconfman->getTypeObj(\"cDataSource\")) , scname );\n  if (ct == NULL) {\n    SMILE_WRN(4,\"cDataSource config Type not found!\");\n    rA=1;\n  }*/\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"filename\",\"The filename of the ARFF file to read\",\"input.arff\");\n    // TODO: support reading a frame time field from the arff file...\n    ct->setField(\"skipFirst\",\"the number of numeric(!) attributes to skip at the beginning\",0);\n    ct->setField(\"skipClasses\",\"The number of numeric(!) (or real) attributes (values) at end of each instance to skip (Note: nominal and string attributes are ignored anyway, this option only applies to the last numeric attributes, even if they are followd by string or nominal aatributes). To have more fine grained control over selecting attributes, please use the component cDataSelector!\",0);\n    ct->setField(\"saveInstanceIdAsMetadata\",\"1/0 = on/off : save the first string attribute of the arff file as instance ID string the vector meta data (e.g. for use by the winToVecProcessor component in the frameMode=meta mode).\",0);\n    ct->setField(\"saveTargetsAsMetadata\",\"1/0 = on/off : save everything after the last numeric attribute as meta-data string. This can be read by arffSink and appended to the instances instead of reading individual targets from the config.\",0);\n    // TODO: add classes as custom meta data...?\n\n    //ct->setField(\"selection\",\"indicies of attributes to read (separate indicies by , and specify ranges with a-b e.g. 1-5,7,8). Default ('all') is to read all numeric/real attributes.\",\"all\");\n  )\n\n/*\n    ConfigInstance *Tdflt = new ConfigInstance( scname, ct, 1 );\n    sconfman->registerType(Tdflt);\n  } else {\n    if (ct!=NULL) delete ct;\n  }\n*/\n  SMILECOMPONENT_MAKEINFO(cArffSource);\n}\n\nSMILECOMPONENT_CREATE(cArffSource)\n\n//-----\n\ncArffSource::cArffSource(const char *_name) :\n  cDataSource(_name),\n  field(NULL),\n  fieldNalloc(0),\n  lineNr(0),\n  eof(0),\n  lastNumeric(-1),\n  strField(-1),\n  origline(NULL), lineLen(0)\n{\n}\n\nvoid cArffSource::fetchConfig()\n{\n  cDataSource::fetchConfig();\n  \n  filename = getStr(\"filename\");\n  SMILE_IDBG(2,\"filename = '%s'\",filename);\n  skipClasses = getInt(\"skipClasses\");\n  SMILE_IDBG(2,\"skipClasses = %i\",skipClasses);\n  skipFirst = getInt(\"skipFirst\");\n  SMILE_IDBG(2,\"skipFirst = %i\",skipFirst);\n\n  useInstanceID = getInt(\"saveInstanceIdAsMetadata\");\n  SMILE_IDBG(2,\"saveInstanceIdAsMetadata = %i\",useInstanceID);\n  saveClassesAsMetadata = getInt(\"saveTargetsAsMetadata\");\n  SMILE_IDBG(2,\"saveTargetsAsMetadata = %i\",saveClassesAsMetadata);\n}\n\n/*\nint cArffSource::myConfigureInstance()\n{\n    // call writer->setConfig here to set the dataMemory level configuration and override config file and defaults...\n//  double T = 1.0 / (double)(pcmParam.sampleRate);\n//  writer->setConfig(1,2*buffersize,T, 0.0, 0.0 , 0, DMEM_FLOAT);  // lenSec = (double)(2*buffersize)*T\n\n  int ret = 1;\n  ret *= cDataSource::myConfigureInstance();\n  // ...\n  return ret;\n}\n*/\n\nint cArffSource::setupNewNames(long nEl)\n{\n  // read header lines...\n  int ret=1;\n  long read;\n  char *line;\n  int head=1;\n  int fnr = 0;\n  int nnr = 0;\n  // count attributes\n  int nAttributes = 0;\n  if (filehandle != NULL) {\n    fclose(filehandle);\n  }\n  filehandle = fopen(filename, \"r\");\n  if (filehandle == NULL) {\n    COMP_ERR(\"Error opening file '%s' for reading (component instance '%s', type '%s')\",filename, getInstName(), getTypeName());\n  }\n  do {\n    read = smile_getline(&origline, &lineLen, filehandle);\n    line = origline;\n    if ((read > 0)&&(line!=NULL)) {\n      lineNr++;\n      if ( (!strncasecmp(line, \"@attribute \", 11)) ) {\n        char *name = line+11;\n        while (*name == ' ') name++;\n        char *type = strchr(name,' ');\n        if (type != NULL) {\n          *(type++) = 0;\n          while (*type == ' ') type++; // skip spaces here too\n          if ((!strncasecmp(type,\"real\",4))||(!strncasecmp(type,\"numeric\",7))) { // add numeric attribute:\n            nAttributes++;\n          }\n        }\n      } else if ( (!strncasecmp(line, \"@data\", 5)) ) {\n        head = 0;\n      }\n    } else {\n      // ERROR: EOF in header!!!\n      head = 0;\n      eof = 1;\n      SMILE_ERR(1,\"incomplete arff file '%s', could not find '@data' line!\",filename);\n      ret = 0;\n    }\n  } while (head);\n  if (ret == 0) {\n    return 0;\n  }\n  SMILE_IMSG(3, \"Arff file '%s' has %i numeric attributes.\", filename, nAttributes);\n  head = 1;\n  fclose(filehandle);\n  filehandle = fopen(filename, \"r\");\n  if (filehandle == NULL) {\n    COMP_ERR(\"Error opening file '%s' for reading (component instance '%s', type '%s')\",filename, getInstName(), getTypeName());\n  }\n  do {\n    // TODO: specify index based selection of attributes!\n    read = smile_getline(&origline, &lineLen, filehandle);\n    line = origline;\n    if ((read > 0)&&(line!=NULL)) {\n      lineNr++;\n      if ( (!strncasecmp(line,\"@attribute \",11)) ) {\n        char *name = line+11;\n        /* bugfix thanks to Ina: skip spaces between @attribute and name! */\n        while (*name == ' ') name++;\n\n        char *type = strchr(name,' ');\n        if (type != NULL) {\n          *(type++) = 0;\n          while (*type == ' ') type++; // skip spaces here too\n          if ((!strncasecmp(type,\"real\",4))||(!strncasecmp(type,\"numeric\",7))) { // add numeric attribute:\n            // TODO: correct skip classes option! it currently specifies the number of numeric attributes (from first one) to include!\n            if (nnr < nAttributes - skipClasses) {\n              if (nnr >= skipFirst) {\n              writer_->addField(name,1);\n              // TODO: check for [] at end of name and accumulate names to add as array field??\n              if (fnr >= fieldNalloc) {\n                field = (int*)crealloc( field, sizeof(int)*(fieldNalloc+N_ALLOC_BLOCK), sizeof(int)*(fieldNalloc) );\n                fieldNalloc += N_ALLOC_BLOCK;\n              }\n              field[fnr] = 1;\n              lastNumeric = fnr;\n              }\n              nnr++;\n            }\n            // TODO: detect array fields [X]\n          } else if (!strncasecmp(type,\"string\",6)) {\n            if ((strField == -1)&&(useInstanceID)) strField = fnr; // set strField to point to the FIRST string attribute in the arff file\n          }\n          fnr++;\n\n        } else { // ERROR:...\n          ret=0;\n        }\n      } else if ( (!strncasecmp(line,\"@data\",5)) ) {\n        head = 0;\n      }\n    } else {\n      head = 0; eof=1;\n      SMILE_ERR(1,\"incomplete arff file '%s', could not find '@data' line!\",filename);\n      ret=0;\n    } // ERROR: EOF in header!!!\n  } while (head);\n  //if (line!=NULL) free(line);\n\n  // skip 'skipClasses' numeric classes from end\n  /*\n  if (skipClasses) {\n    int i;\n    int s=skipClasses;\n    for (i=fnr-1; i>=0; i++) {\n      if (field[i]) { field[i]=0; s--; nnr--; }\n      if (s<=0) break;\n    }\n  }*/\n \n  nFields = fnr;\n  nNumericFields = nnr-skipFirst;\n\n  allocVec(nnr-skipFirst);\n\n  namesAreSet_=1;\n  return 1;\n}\n\nint cArffSource::myFinaliseInstance()\n{\n/*  filehandle = fopen(filename, \"r\");\n  if (filehandle == NULL) {\n    COMP_ERR(\"Error opening file '%s' for reading (component instance '%s', type '%s')\",filename, getInstName(), getTypeName());\n  }*/\n\n  int ret = cDataSource::myFinaliseInstance();\n\n  if (ret == 0) {\n    fclose(filehandle); filehandle = NULL;\n  }\n  return ret;\n  \n}\n\n\nint cArffSource::myTick(long long t)\n{\n  if (isEOI()) return 0;\n  \n  SMILE_DBG(4,\"tick # %i, reading value vector from arff file\",t);\n  if (eof) {\n    SMILE_DBG(4,\"(inst '%s') EOF, no more data to read\",getInstName());\n    return 0;\n  }\n\n  if (!(writer_->checkWrite(1))) return 0;\n  \n  size_t n=0,read;\n  char *line=NULL;\n  int l=1;\n  int len=0;\n  int i=0, ncnt=0;\n  // get next non-empty line\n  do {\n    \n    read = smile_getline(&origline, &lineLen, filehandle);\n    //origline = line;\n    line = origline;\n\n    if ((read != -1)&&(line!=NULL)) {\n      lineNr++;\n      len=(int)strlen(line);\n      if (len>0) { if (line[len-1] == '\\n') { line[len-1] = 0; len--; } }\n      if (len>0) { if (line[len-1] == '\\r') { line[len-1] = 0; len--; } }\n      while (((line[0] == ' ')||(line[0] == '\\t'))&&(len>=0)) { line[0] = 0; line++; len--; }\n      if (len > 0) {\n        l=0;\n        char *x, *x0=line;\n        do {\n          x = strchr(x0,',');\n          if (x!=NULL) {\n            *(x++)=0;\n          }\n          if (field[i]) { // if this field is numeric/selected\n            // convert value in x0\n            char *ep=NULL;\n            double val = strtod( x0, &ep );\n            if ((val==0.0)&&(ep==x0)) { SMILE_ERR(1,\"error parsing value in arff file '%s' (line %i), expected double value (element %i).\",filename,lineNr,i); }\n            if (ncnt < vec_->N) vec_->dataF[ncnt++] = (FLOAT_DMEM)val;\n            else { SMILE_IERR(1,\"more elements in field selection (%i) than allocated in vector (%i)!\",ncnt,vec_->N); } // <- should never happen?\n          }\n          if (i==strField) { // if instance label string field .. add name to vector meta data\n            if (vec_->tmeta->metadata.text != NULL) {\n              free( vec_->tmeta->metadata.text);\n            } \n            vec_->tmeta->metadata.text = strdup(x0);\n          }\n          if (x!=NULL) {\n            // TODO: check for end of numeric attributes.... and add rest as \"tmeta->metadata.custom pointer!\"\n            if ((saveClassesAsMetadata)&&(i>=lastNumeric)&&(lastNumeric>=1)) {\n              // add the remaining string to the custom info\n              vec_->tmeta->metadata.iData[1] = 1234;\n              long ll = (long)(strlen(x)+1);\n              if (ll > vec_->tmeta->metadata.customLength) {\n                if (vec_->tmeta->metadata.custom != NULL) free(vec_->tmeta->metadata.custom);\n                vec_->tmeta->metadata.custom = strdup(x);\n                vec_->tmeta->metadata.customLength = ll;\n              } else {\n                memcpy(vec_->tmeta->metadata.custom, x, ll);\n              }\n              x = NULL;\n            } else {\n              i++;\n              x0=x;\n            }\n          }\n        } while (x!=NULL);\n      }\n      //free(line); line = NULL;\n    } else {\n      l=0; // EOF....  signal EOF...???\n      eof=1;\n    }\n  } while (l);\n\n  if (!eof) {\n//    SMILE_IMSG(1,\"metadata.text = '%s'\",vec->tmeta->metadata.text);\n    writer_->setNextFrame(vec_);\n    return 1;\n  }\n  \n  return 0;\n}\n\n\ncArffSource::~cArffSource()\n{\n  if (filehandle!=NULL) fclose(filehandle);\n  if (field != NULL) free(field);\n  if (origline != NULL) free(origline);\n}\n"
  },
  {
    "path": "src/iocore/csvSink.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nComma Separated Value file output (CSV)\n\n*/\n\n\n\n#include <iocore/csvSink.hpp>\n\n#define MODULE \"cCsvSink\"\n\n/*Library:\nsComponentInfo * registerMe(cConfigManager *_confman) {\n  cDataSink::registerComponent(_confman);\n}\n*/\n\nSMILECOMPONENT_STATICS(cCsvSink)\n\n//sComponentInfo * cCsvSink::registerComponent(cConfigManager *_confman)\nSMILECOMPONENT_REGCOMP(cCsvSink)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CCSVSINK;\n  sdescription = COMPONENT_DESCRIPTION_CCSVSINK;\n\n  // we inherit cDataSink configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSink\")\n\n  SMILECOMPONENT_IFNOTREGAGAIN_BEGIN\n    ct->setField(\"filename\",\"The CSV file to write to. An empty filename (or '?' as the filename) disables this sink component.\",\"smileoutput.csv\");\n    ct->setField(\"delimChar\",\"The column delimiter character to use (usually ',' or ';') (NOTE: use '<space>' or '<tab>' for these special characters respectively)\",';');\n    ct->setField(\"lag\",\"output data <lag> frames behind\",0,0,0);\n    ct->setField(\"append\",\"1 = append to an existing file, or create a new file; 0 = overwrite an existing file, or create a new file\",0);\n    ct->setField(\"timestamp\",\"1 = print a timestamp attribute for each output frame (1/0 = yes/no)\", 1);\n    // for compatibility with arffSink\n    ct->setField(\"frameTime\",\"(same as 'timestamp') 1 = print a timestamp attribute for each output frame (1/0 = yes/no)\", 1);\n    ct->setField(\"number\", \"1 = print an instance number (= frameIndex) attribute for each output frame (1/0 = yes/no)\", 1);\n    // for compatibility with arffSink\n    ct->setField(\"frameIndex\", \"(same as 'number') 1 = print an instance number (= frameIndex) attribute for each output frame (1/0 = yes/no)\", 1);\n    ct->setField(\"printHeader\",\"1 = print a header line as the first line in the CSV file. This line contains the attribute names separated by the delimiter character.\",1);\n    ct->setField(\"flush\", \"1 = flush data to file after every line written (might give low performance for small lines!).\", 0);\n    ct->setField(\"instanceBase\", \"if not empty, print instance name attribute <instanceBase_Nr>\", (const char*)NULL);\n    ct->setField(\"instanceName\", \"if not empty, print instance name attribute <instanceName>\", (const char*)NULL);\n\n  SMILECOMPONENT_IFNOTREGAGAIN_END\n\n  SMILECOMPONENT_MAKEINFO(cCsvSink);\n}\n\nSMILECOMPONENT_CREATE(cCsvSink)\n\n//-----\n\ncCsvSink::cCsvSink(const char *_name) :\n  cDataSink(_name),\n  filehandle(NULL),\n  filename(NULL),\n  printHeader(0),\n  delimChar(';'),\n  instanceName(NULL),\n  instanceBase(NULL),\n  prname(0),\n  disabledSink_(false)\n{\n}\n\nvoid cCsvSink::fetchConfig()\n{\n  cDataSink::fetchConfig();\n  \n  filename = getStr(\"filename\");\n  if (filename == NULL || *filename == 0 || (*filename == '?' && *(filename+1) == 0)) {\n    SMILE_IMSG(2, \"No filename given, disabling this sink component.\");\n    disabledSink_ = true;\n    errorOnNoOutput_ = 0;\n  }\n  delimChar = getChar(\"delimChar\");\n  lag = getInt(\"lag\");\n  append = getInt(\"append\");\n  if (append) { SMILE_IDBG(3,\"append to file is enabled\"); }\n  printHeader = getInt(\"printHeader\");\n  if (printHeader) { SMILE_IDBG(3,\"printing header with feature names\"); }\n\n  number = getInt(\"number\");\n  if (isSet(\"frameIndex\")) {\n    number = getInt(\"frameIndex\");\n  }\n  if (number) { SMILE_IDBG(3,\"printing of frameIndex (number) to file is enabled\"); }\n\n  timestamp = getInt(\"timestamp\");\n  if (isSet(\"frameTime\")) {\n    timestamp = getInt(\"frameTime\");\n  }\n  if (timestamp) { SMILE_IDBG(3,\"printing timestamp attribute (index 1) enabled\"); }\n\n  flush = getInt(\"flush\");\n\n  if (isSet(\"instanceBase\")) {\n    instanceBase = getStr(\"instanceBase\");\n    prname = 2;\n  }\n  if (isSet(\"instanceName\")) {  // instance name overrides instance base\n    instanceName = getStr(\"instanceName\");\n    prname = 1;\n  }\n}\n\n/*\nint cCsvSink::myConfigureInstance()\n{\n  int ret=1;\n  ret *= cDataSink::myConfigureInstance();\n  // ....\n  //return ret;\n}\n*/\n\n\nint cCsvSink::myFinaliseInstance()\n{\n  int ap=0;\n  if (disabledSink_) {\n    filehandle = NULL;\n    return 1;\n  }\n  int ret = cDataSink::myFinaliseInstance();\n  if (ret==0) return 0;\n  \n  if (append) {\n    // check if file exists:\n    filehandle = fopen(filename, \"r\");\n    if (filehandle != NULL) {\n      fclose(filehandle);\n      filehandle = fopen(filename, \"a\");\n      ap=1;\n    } else {\n      filehandle = fopen(filename, \"w\");\n    }\n  } else {\n    filehandle = fopen(filename, \"w\");\n  }\n  if (filehandle == NULL) {\n    COMP_ERR(\"Error opening file '%s' for writing (component instance '%s', type '%s')\",filename, getInstName(), getTypeName());\n  }\n  \n  if ((!ap)&&(printHeader)) {\n    // write header ....\n    if (prname) {\n      fprintf(filehandle, \"name%c\", delimChar);\n    }\n    if (number) {\n      fprintf(filehandle, \"frameIndex%c\", delimChar);\n    }\n    if (timestamp) {\n      fprintf(filehandle, \"frameTime%c\", delimChar);\n    }\n\n    long _N = reader_->getLevelN();\n    long i;\n    for(i=0; i<_N-1; i++) {\n      char *tmp = reader_->getElementName(i);\n      fprintf(filehandle, \"%s%c\",tmp,delimChar);\n      free(tmp);\n    }\n    char *tmp = reader_->getElementName(i);\n    fprintf(filehandle, \"%s%s\",tmp,NEWLINE);\n    free(tmp);\n  }\n  \n  return ret;\n}\n\n\nint cCsvSink::myTick(long long t)\n{\n  if (filehandle == NULL) {\n    return 0;\n  }\n  cVector *vec= reader_->getFrameRel(lag);\n  SMILE_IDBG(4, \"tick # %i, writing to CSV file (lag=%i) (vec = %ld):\", \n    t, lag, long(vec));\n  if (vec == NULL) {\n    return 0;\n  }\n  long vi = vec->tmeta->vIdx;\n  double tm = vec->tmeta->time;\n  if (prname == 1) {\n    fprintf(filehandle, \"'%s'%c\", instanceName, delimChar);\n  } else if (prname == 2) {\n    fprintf(filehandle, \"'%s_%i'%c\", instanceBase, vi, delimChar);\n  }\n\n  if (number) \n    fprintf(filehandle,\"%i%c\",vi,delimChar);\n  if (timestamp) \n    fprintf(filehandle,\"%f%c\",tm,delimChar);\n\n  // now print the vector:\n  int i;\n  for (i=0; i<vec->N-1; i++) {\n    // print float as integer if its decimals are zero\n    if (vec->dataF[i] == floor(vec->dataF[i])) {\n      fprintf(filehandle,\"%.0f%c\",vec->dataF[i],delimChar);\n    } else {\n      fprintf(filehandle,\"%e%c\",vec->dataF[i],delimChar);\n    }\n  }\n  if (vec->dataF[i] == floor(vec->dataF[i])) {\n    fprintf(filehandle,\"%0.f%s\",vec->dataF[i],NEWLINE);\n  } else {\n    fprintf(filehandle,\"%e%s\",vec->dataF[i],NEWLINE);\n  }\n  if (flush) {\n    fflush(filehandle);\n  }\n  nWritten_++;\n\n  // tick success\n  return 1;\n}\n\n\ncCsvSink::~cCsvSink()\n{\n  if (filehandle != NULL) {\n    fclose(filehandle);\n    filehandle = NULL;\n  }\n}\n\n"
  },
  {
    "path": "src/iocore/csvSource.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nCSV (Comma seperated value) file reader. \nThis component reads all columns as attributes into the data memory. One line thereby represents one frame or sample. The first line may contain a header with the feature names (see header=yes/no/auto option).\n\n*/\n\n\n#include <iocore/csvSource.hpp>\n\n\n\n#define MODULE \"cCsvSource\"\n\n/*Library:\nsComponentInfo * registerMe(cConfigManager *_confman) {\n  cDataSource::registerComponent(_confman);\n}\n*/\n#define N_ALLOC_BLOCK 50\n\nSMILECOMPONENT_STATICS(cCsvSource)\n\nSMILECOMPONENT_REGCOMP(cCsvSource)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CCSVSOURCE;\n  sdescription = COMPONENT_DESCRIPTION_CCSVSOURCE;\n\n  // we inherit cDataSource configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSource\")\n\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"filename\",\"The CSV file to read\",\"input.csv\");\n    // TODO: support reading a frame time field from the arff file...\n    ct->setField(\"delimChar\",\"The CSV delimiter character to use. Usually ',' or ';'.\", ';');\n    ct->setField(\"header\",\"yes/no/auto : wether to read the first line of the CSV file as header (yes), or treat it as numeric data (no), or automatically determine from the first field in the first line whether to read the header or not (auto).\",\"auto\");\n    ct->setField(\"start\", \"Start at line 'start', not counting the header line. The first line after the (optional) header line is line 0 (also the default).\", 0);\n    ct->setField(\"end\", \"Read up to line 'end'. The number of the line given here is the last line that will be read. 0 is the first line in the file (excluding header). The default '-1' refers to the last line in the file (this is also the default).\", -1);\n    //ct->setField(\"selection\",\"indicies of attributes to read (separate indicies by , and specify ranges with a-b e.g. 1-5,7,8). Default ('all') is to read all numeric/real attributes.\",\"all\");\n  )\n\n  SMILECOMPONENT_MAKEINFO(cCsvSource);\n}\n\nSMILECOMPONENT_CREATE(cCsvSource)\n\n//-----\n\ncCsvSource::cCsvSource(const char *_name) :\n  cDataSource(_name),\n  field(NULL),\n  lineNr(0),\n  eof(0),\n  header(0),\n  delimChar(',')\n{\n}\n\n#define HEADER_AUTO  0\n#define HEADER_FORCE 1\n#define HEADER_OMIT  2\n\nvoid cCsvSource::fetchConfig()\n{\n  cDataSource::fetchConfig();\n  \n  start = getInt(\"start\");\n  end = getInt(\"end\");\n\n  filename = getStr(\"filename\");\n  SMILE_IDBG(2,\"filename = '%s'\",filename);\n  \n  delimChar = getChar(\"delimChar\");\n  SMILE_IDBG(2,\"delimChar = %c\",delimChar);\n\n  const char *_header = getStr(\"header\");\n  if (!strncasecmp(_header,\"auto\",4)) {\n    header = HEADER_AUTO;\n  } else if(!strncasecmp(_header,\"yes\",3)) {\n    header = HEADER_FORCE;\n  } else if (!strncasecmp(_header,\"no\",2)) {\n    header = HEADER_OMIT;\n  } else {\n    header = HEADER_AUTO;\n    SMILE_IWRN(1,\"unknon value for 'header' parameter: '%s'. Allowed values are: yes / no / auto .\",_header);\n  }\n  \n\n}\n\nvoid cCsvSource::setGenericNames(int nDelim) \n{\n  writer_->addField(\"csvdata\", nDelim + 1);\n}\n\nvoid cCsvSource::setNamesFromCSVheader(char *line, int nDelim) \n{\n  int i;\n  int len = (int)strlen(line);\n  const char * start = line;\n  for (i=0; i<len; i++) {\n    if ((line[i] == delimChar)||(line[i]==0)||(line[i]=='\\n')||(line[i]=='\\r')) {\n      line[i] = 0;\n      if (start != NULL && start != line+i)\n        writer_->addField(start,1);\n      start = line+i+1;\n    }\n  }\n}\n\n\nint cCsvSource::setupNewNames(long nEl)\n{\n  // read header line and split names\n  int quote1=0, quote2=0;\n  char *line=NULL;\n  size_t n,read;\n  int nDelim = 0;\n  read = smile_getline(&line, &n, filehandle);\n  if ((read > 0)&&(line!=NULL)) {\n    lineNr++;\n    // count number of unquoted delim chars  (quoting via ' or \")\n    int len = (int)strlen(line);\n    char * firstEl = NULL;\n    \n    int i;\n    for (i=0; i<len; i++) {\n      if ((!quote2)&&(line[i] == '\\'')) { quote1 = !quote1; }\n      else if ((!quote1)&&(line[i] == '\"')) { quote2 = !quote2; }\n      if ((quote1+quote2 == 0)&&(line[i] == delimChar)) { \n        if (nDelim == 0) { line[i] = 0; firstEl = strdup(line); line[i] = delimChar; }\n        nDelim++;\n      }\n    }\n\n    // allocate field selection map:\n    field = (int*)malloc(sizeof(int)*(nDelim+1));\n    // select all by default:\n    for (i=0; i<=nDelim; i++) field[i] = 1;\n\n    // set names, either generic or from csv \"pseudo\" header (first line)\n    if (header == HEADER_AUTO) {\n      // check first Element\n      int head = 1;\n      char *eptr=NULL;\n      if (firstEl == NULL) {\n        SMILE_IWRN(2, \"Only one element on first line of CSV file '%s'. Did you configure the right delimiter character!? delimChar = '%c'\", filename, delimChar);\n        strtol(line, &eptr, 10);\n        // if the first field is not a pure numeric field, assume it is a header\n        if ((line[0] != 0) && ((eptr == NULL) || (eptr[0] == 0))) {\n          head = 0;\n        }\n      } else {\n        strtol(firstEl, &eptr, 10);\n        // if the first field is not a pure numeric field, assume it is a header\n        if ((firstEl[0] != 0) && ((eptr == NULL) || (eptr[0] == 0))) {\n          head = 0;\n        }\n      }\n\n      if (head) { \n        SMILE_IMSG(3,\"automatically detected first line of CSV input as HEADER!\");\n        setNamesFromCSVheader(line,nDelim); \n      } else { \n        SMILE_IMSG(3,\"automatically detected first line of CSV input as NUMERIC DATA! (No header is present, generic element names will be used).\");\n        setGenericNames(nDelim); rewind(filehandle); lineNr=0; \n      }\n\n    } else if (header == HEADER_FORCE) {\n      setNamesFromCSVheader(line, nDelim);\n    } else {\n      setGenericNames(nDelim);\n      rewind(filehandle);\n      lineNr=0;\n    }\n    if (firstEl != NULL) free(firstEl);\n    //return nDelim+1;\n    if (nDelim == 0) {\n        // this should only be a warning, not an error (only 1 feature in CSV --> no delimiters)\n        SMILE_IWRN(1,\"no delimiter chars ('%c') found in first line of the CSV file: \\n  %s\\n    Have you selected the correct delimiter character?\",delimChar,line);\n    }\n  }\n  \n  // TODO: nFields will actually reflect the true number of selected fields, nCols will reflect the number of columns in the first line of the csv file\n  nCols = nDelim + 1;\n  nFields = nDelim + 1;\n  if (line != NULL)\n    free(line);\n  allocVec(nFields);\n  namesAreSet_=1;\n  return nDelim + 1;\n}\n\nint cCsvSource::myFinaliseInstance()\n{\n  filehandle = fopen(filename, \"r\");\n  if (filehandle == NULL) {\n    COMP_ERR(\"Error opening file '%s' for reading (component instance '%s', type '%s')\",filename, getInstName(), getTypeName());\n  }\n\n  int ret = cDataSource::myFinaliseInstance();\n\n  if (ret == 0) {\n    fclose(filehandle); filehandle = NULL;\n  }\n  return ret;\n  \n}\n\n\nint cCsvSource::myTick(long long t)\n{\n  if (isEOI()) return 0;\n\n  SMILE_DBG(4,\"tick # %i, reading value vector from CSV file\",t);\n  if (eof) {\n    SMILE_DBG(4,\"(inst '%s') EOF, no more data to read\",getInstName());\n    return 0;\n  }\n\n  int ret = 0;\n\n  // read # blocksizeW lines from file\n  int b;\n  for (b=0; b<blocksizeW_; b++) {\n\n    if (!(writer_->checkWrite(1))) return ret;\n\n    size_t n,read;\n    char *line=NULL;\n    int l=1;\n    int len=0;\n    int i=0, ncnt=0;\n    // get next non-empty line in range [start; end]\n    do {\n      read = smile_getline(&line, &n, filehandle);\n      if ((read != -1)&&(line!=NULL)) {\n        lineNr++;\n        if (lineNr > start && (lineNr - 1 <= end || (end == -1))) {\n          len=(int)strlen(line);\n          if (len>0) { if (line[len-1] == '\\n') { line[len-1] = 0; len--; } }\n          if (len>0) { if (line[len-1] == '\\r') { line[len-1] = 0; len--; } }\n          while (((line[0] == ' ')||(line[0] == '\\t'))&&(len>=0)) { line[0] = 0; line++; len--; }\n          if (len > 0) {\n            l=0; // <- termination of while loop, when a non-empty line was found\n            char *x, *x0=line;\n            int nDel=0;\n            do {\n              x = strchr(x0,delimChar);\n              if (x!=NULL) {\n                *(x++)=0;\n                nDel++;\n              }\n              if (field[i]) { // if this field is selected for import\n                // convert value in x0\n                if (ncnt < nFields) {\n                  char *ep=NULL;\n                  double val = strtod( x0, &ep );\n                  if ((val==0.0)&&(ep==x0)) { SMILE_ERR(1,\"error parsing numeric value in CSV file '%s' (line %i), expected float/int value (element %i).\",filename,lineNr,i); }\n                  vec_->dataF[ncnt++] = (FLOAT_DMEM)val;\n                } else {\n                  SMILE_IWRN(2,\"trying to import more fields than selected (%i>%i) on line %i of CSV file '%s'. Ignoring the excess fields!\",ncnt,nFields,lineNr,filename);\n                }\n              }\n              if (x!=NULL) {\n                i++;\n                x0=x;\n              }\n            } while (x!=NULL);\n            if (nDel != nCols-1) {\n              SMILE_IWRN(2,\"numer of columns (%i) on line %i of CSV file '%s' does not match the number of excpected columns (%i) (read from first line or file header)\",nDel+1,lineNr,filename,nCols);\n            }\n          }\n        }\n      } else {\n        l=0; // EOF....  signal EOF...???\n        eof=1;\n      }\n    } while (l);\n    if (line != NULL)\n      free(line);\n    if (!eof) {\n      if (ncnt < nFields) {\n        SMILE_IWRN(1,\"less elements than expected (%i < %i) on line %i of CSV file '%s'\",ncnt,nFields,lineNr,filename);\n      }\n      writer_->setNextFrame(vec_);\n      ret = 1;\n    } else { break; }\n\n  }\n\n  return ret;\n}\n\n\ncCsvSource::~cCsvSource()\n{\n  if (filehandle!=NULL) fclose(filehandle);\n  if (field != NULL) free(field);\n}\n"
  },
  {
    "path": "src/iocore/datadumpSink.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: datadumpSink\n\ndump data in raw binary format (float)\nthe data can easily be loaded into matlab\n\nThe first float value will contain the vecsize\nThe second float value will contain the number of vectors\nThen the matrix data follows float by float\n\n*/\n\n\n\n#include <iocore/datadumpSink.hpp>\n\n#define MODULE \"cDatadumpSink\"\n\n/*Library:\nsComponentInfo * registerMe(cConfigManager *_confman) {\n  cDataSink::registerComponent(_confman);\n}\n*/\n\nSMILECOMPONENT_STATICS(cDatadumpSink)\n\n//sComponentInfo * cDatadumpSink::registerComponent(cConfigManager *_confman)\nSMILECOMPONENT_REGCOMP(cDatadumpSink)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CDATADUMPSINK;\n  sdescription = COMPONENT_DESCRIPTION_CDATADUMPSINK;\n\n  // we inherit cDataSink configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSink\")\n\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"filename\",\"The filename of the output file (if it doesn't exist it will be created).\",\"datadump.dat\");\n    ct->setField(\"lag\",\"output data <lag> frames behind\",0,0,0);\n    ct->setField(\"append\",\"1 = append to an existing file, or create a new file; 0 = overwrite an existing file, or create a new file\",0);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cDatadumpSink);\n}\n\nSMILECOMPONENT_CREATE(cDatadumpSink)\n\n//-----\n\ncDatadumpSink::cDatadumpSink(const char *_name) :\n  cDataSink(_name),\n  filehandle(NULL),\n  filename(NULL),\n  nVec(0),\n  vecSize(0)\n{\n}\n\nvoid cDatadumpSink::fetchConfig()\n{\n  cDataSink::fetchConfig();\n  \n  filename = getStr(\"filename\");\n  SMILE_IDBG(3,\"filename = '%s'\",filename);\n\n  lag = getInt(\"lag\");\n  SMILE_IDBG(3,\"lag = %i\",lag);\n\n  append = getInt(\"append\");\n  if (append) { SMILE_IDBG(3,\"append to file is enabled\"); }\n}\n\n/*\nint cDatadumpSink::myConfigureInstance()\n{\n  int ret=1;\n  ret *= cDataSink::myConfigureInstance();\n  // ....\n  //return ret;\n}\n*/\n\n\nint cDatadumpSink::myFinaliseInstance()\n{\n  int ap=0;\n  float tmp=0;\n  \n  int ret = cDataSink::myFinaliseInstance();\n  if (ret==0) return 0;\n  \n  if (append) {\n    // check if file exists:\n    filehandle = fopen(filename, \"rb\");\n    if (filehandle != NULL) {\n      // load vecsize, to see if it matches!\n      if (fread(&tmp,sizeof(float),1,filehandle)) vecSize=(long)tmp;\n      else vecSize = 0;\n      // load initial nVec\n      if (fread(&tmp,sizeof(float),1,filehandle)) nVec=(long)tmp;\n      else nVec = 0;\n      fclose(filehandle);\n      filehandle = fopen(filename, \"ab\");\n      ap=1;\n    } else {\n      filehandle = fopen(filename, \"wb\");\n    }\n  } else {\n    filehandle = fopen(filename, \"wb\");\n  }\n  if (filehandle == NULL) {\n    COMP_ERR(\"Error opening binary file '%s' for writing (component instance '%s', type '%s')\",filename, getInstName(), getTypeName());\n  }\n  \n  if (vecSize == 0) vecSize = reader_->getLevelN();\n\n  if (!ap) {\n    // write mini dummy header ....\n    writeHeader();\n  }\n  \n  return ret;\n}\n\n\nint cDatadumpSink::myTick(long long t)\n{\n  if (filehandle == NULL) return 0;\n  \n  SMILE_DBG(4,\"tick # %i, writing value vector (lag=%i):\",t,lag);\n  cVector *vec= reader_->getFrameRel(lag);  //new cVector(nValues+1);\n  if (vec == NULL) return 0;\n\n  // now print the vector:\n  int i; float *tmp = (float*)malloc(sizeof(float)*vec->N);\n  if (tmp==NULL) OUT_OF_MEMORY;\n  \n  if (vec->type == DMEM_FLOAT) {\n    for (i=0; i<vec->N; i++) {\n      tmp[i] = (float)(vec->dataF[i]);\n    }\n  } else if (vec->type == DMEM_INT) {\n    for (i=0; i<vec->N; i++) {\n      tmp[i] = (float)(vec->dataI[i]);\n    }\n  } else {\n    SMILE_ERR(1,\"unknown data type %i\",vec->type);\n    return 0;\n  }\n\n  int ret=1;\n  if (!fwrite(tmp,sizeof(float),vec->N,filehandle)) {\n    SMILE_ERR(1,\"Error writing to raw feature file '%s'!\",filename);\n    ret = 0;\n  } else {\n    //reader->nextFrame();\n    nVec++;\n  }\n\n  free(tmp);\n\n  // tick success\n  return ret;\n}\n\n// WARNING: write header changes file write pointer to beginning of file (after header)\nvoid cDatadumpSink::writeHeader()\n{\n  // seek to beginning of file:\n  fseek( filehandle, 0, SEEK_SET );\n  // write header:\n  float tmp;\n  tmp = (float)vecSize;\n  fwrite(&tmp, sizeof(float), 1, filehandle);\n  tmp = (float)nVec;\n  fwrite(&tmp, sizeof(float), 1, filehandle);\n}\n\ncDatadumpSink::~cDatadumpSink()\n{\n  // write final header \n  writeHeader();\n  // close output file\n  fclose(filehandle);\n}\n\n"
  },
  {
    "path": "src/iocore/htkSink.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: htkSink\n\nHTK binary feature file output\n\n*/\n\n\n#include <iocore/htkSink.hpp>\n\n#define MODULE \"cHtkSink\"\n\n\nSMILECOMPONENT_STATICS(cHtkSink)\n\nSMILECOMPONENT_REGCOMP(cHtkSink)\n{\n  SMILECOMPONENT_REGCOMP_INIT;\n  scname = COMPONENT_NAME_CHTKSINK;\n  sdescription = COMPONENT_DESCRIPTION_CHTKSINK;\n\n  // we inherit cDataSink configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSink\");\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"filename\",\"HTK parameter file to write to (and create)\",\"smileoutput.htk\");\n    ct->setField(\"lag\",\"If > 0, enable output of data <lag> frames behind\",0,0,0);\n    ct->setField(\"append\",\"1 = append to existing file (0 = don't append)\",0);\n    ct->setField(\"parmKind\",\"HTK parmKind header field (0=WAVEFORM, 1=LPC, 2=LPREFC, 3=LPCEPSTRA, 4=LPDELCEP, 5=IREFC, 6=MFCC, 7=FBANK (log), 8=MELSPEC (linear), 9=USER, 10=DISCRETE, 11=PLPCC ;\\n   Qualifiers (added): 64=_E, 128=_N, 256=_D, 512=_A, 1024=_C, 2048=_Z, 4096=_K, 8192=_0)\",9);\n    ct->setField(\"forcePeriod\", \"Set a value here to force the output period to a fixed value (usually 0.01) to avoid broken HTK files for periods > 0.06s\", 0.01);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cHtkSink);\n}\n\nSMILECOMPONENT_CREATE(cHtkSink)\n\n//-----\n\ncHtkSink::cHtkSink(const char *_name) :\n  cDataSink(_name), filehandle(NULL), filename(NULL),\n  nVec(0), vecSize(0), period(0.0), disabledSink_(false),\n  forcePeriod_(0.0)\n{\n  bzero(&header, sizeof(sHTKheader));\n  if ( smileHtk_IsVAXOrder() ) vax = 1;\n  else vax = 0;\n}\n\nvoid cHtkSink::fetchConfig()\n{\n  cDataSink::fetchConfig();\n  \n  filename = getStr(\"filename\");\n  if (filename == NULL || *filename == 0 || (*filename == '?' && *(filename+1) == 0)) {\n    SMILE_IMSG(2, \"No filename given, disabling this sink component.\");\n    disabledSink_ = true;\n    errorOnNoOutput_ = 0;\n  }\n\n  lag = getInt(\"lag\");\n  SMILE_IDBG(2,\"lag = %i\",lag);\n\n  append = getInt(\"append\");\n  if (append) { SMILE_IDBG(2,\"append to file is enabled\"); }\n\n  parmKind = (uint16_t)getInt(\"parmKind\");\n  SMILE_IDBG(2,\"parmKind = %i\",parmKind);\n  if (isSet(\"forcePeriod\"))\n    forcePeriod_ = getDouble(\"forcePeriod\");\n}\n\n/*\nint cHtkSink::myConfigureInstance()\n{\n  int ret=1;\n  ret *= cDataSink::myConfigureInstance();\n  // ....\n  //return ret;\n}\n*/\n\nint cHtkSink::writeHeader()\n{\n  if (filehandle==NULL) return 0;\n  header.nSamples = nVec;\n  if (period <= 0.0) {\n    SMILE_IWRN(1, \"Sample period on input level is 0. HTK will not be able to read these files. Setting dummy frame period of 0.01!. Use the 'period' option in the source component to change the frame period.\");\n    header.samplePeriod = (uint32_t)(100000);\n  } else {\n    header.samplePeriod = (uint32_t)round(period*10000000.0);\n  }\n  if ((uint32_t)sizeof(float) * vecSize >= (uint32_t)2<<16) {\n    SMILE_IERR(1,\"vecSize overflow for HTK output: vecSize (%i) > max. HTK vecSize (%i)! limiting vecSize\",(uint32_t)sizeof(float) * (uint32_t)vecSize,(uint32_t)2<<16);\n    vecSize = (2<<16) - 1;\n  }\n  header.sampleSize = (uint16_t)(sizeof(float) * vecSize);\n  header.parmKind = parmKind;  \n  return smileHtk_writeHeader(filehandle,&header);\n}\n\n/*\nint cHtkSink::readHeader()\n{\n  if (filehandle==NULL) return 0;\n  if (!fread(&header, sizeof(sHTKheader), 1, filehandle)) {\n    SMILE_IERR(1,\"error reading header from file '%s'\",filename);\n    return 0;\n  }\n  prepareHeader(&header); // convert to host byte order\n  return 1;\n}\n*/\n\nint cHtkSink::myFinaliseInstance()\n{\n  int ap=0;\n  if (disabledSink_) {\n    filehandle = NULL;\n    return 1;\n  }\n  int ret = cDataSink::myFinaliseInstance();\n  if (ret==0) return 0;\n\n  period = reader_->getLevelT();\n  vecSize = reader_->getLevelN();\n  \n  if (forcePeriod_ > 0.0)\n    period = forcePeriod_;\n\n  if (append) {\n    // check if file exists:\n    filehandle = fopen(filename, \"rb\");\n    if (filehandle != NULL) {\n      if (!readHeader()) {\n        SMILE_ERR(1,\"error reading header from file '%s' (which seems to exist)! we cannot append to that file!\");\n        // TODO: force overwrite via config file option in this case...\n        ret = 0;\n      }\n      if (ret) {\n        if (header.samplePeriod != (uint32_t)round(period*10000000.0)) {\n          SMILE_ERR(1,\"cannot append to '%s': samplePeriod mismatch (should be: %i, in file on disk: %i)\",filename,(uint32_t)round(period*10000000.0),header.samplePeriod);\n          ret = 0;\n        }\n        if (header.sampleSize != (uint16_t)(sizeof(float) * vecSize)) {\n          SMILE_ERR(1,\"cannot append to '%s': sampleSize mismatch (should be: %i, in file on disk: %i)\",filename,(uint16_t)(sizeof(float) * vecSize),header.sampleSize);\n          ret = 0;\n        }\n      }\n      nVec = header.nSamples;\n      fclose(filehandle); filehandle = NULL;\n      if (ret==0) return 0;\n      filehandle = fopen(filename, \"ab\");\n      ap=1;\n    } else {\n      filehandle = fopen(filename, \"wb\");\n    }\n  } else {\n    filehandle = fopen(filename, \"wb\");\n  }\n  if (filehandle == NULL) {\n    COMP_ERR(\"Error opening binary file '%s' for writing (component instance '%s', type '%s')\",filename, getInstName(), getTypeName());\n  }\n  \n  if (!ap) {\n    // write dummy htk header ....\n    writeHeader();\n  }\n  \n  return ret;\n}\n\n\nint cHtkSink::myTick(long long t)\n{\n  if (filehandle == NULL) return 0;\n\n  SMILE_DBG(4,\"tick # %i, reading value vector (lag=%i):\",t,lag);\n  cVector *vec= reader_->getFrameRel(lag);  //new cVector(nValues+1);\n  if (vec == NULL) return 0;\n\n  // now print the vector:\n  int i; float *tmp = (float *)malloc(sizeof(float)*vec->N);\n  if (tmp==NULL) OUT_OF_MEMORY;\n\n  if (vec->type == DMEM_FLOAT) {\n    for (i=0; i<vec->N; i++) {\n      tmp[i] = (float)(vec->dataF[i]);\n      if (vax) smileHtk_SwapFloat(tmp+i);\n    }\n  } else if (vec->type == DMEM_INT) {\n    for (i=0; i<vec->N; i++) {\n      tmp[i] = (float)(vec->dataI[i]);\n      if (vax) smileHtk_SwapFloat(tmp+i);\n    }\n  } else {\n    SMILE_ERR(1,\"unknown data type %i\",vec->type);\n    return 0;\n  }\n\n  int ret = 1;\n  \n  if (!fwrite(tmp,sizeof(float),vec->N,filehandle)) {\n    SMILE_ERR(1,\"Error writing to raw feature file '%s'!\",filename);\n    ret = 0;\n  } else {\n    //reader->nextFrame();\n    nVec++;\n  }\n\n  free(tmp);\n\n  // tick success\n  return ret;\n}\n\n\ncHtkSink::~cHtkSink()\n{\n  if (filehandle != NULL) {\n    writeHeader();\n    fclose(filehandle);\n  }\n}\n\n"
  },
  {
    "path": "src/iocore/htkSource.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: cHtkSource\n-----------------------------------\n\nHTK Source:\n\nReads data from an HTK parameter file.\n\n-----------------------------------\n\n11/2009 - Written by Florian Eyben\n*/\n\n#include <iocore/htkSource.hpp>\n#define MODULE \"cHtkSource\"\n\n/*Library:\nsComponentInfo * registerMe(cConfigManager *_confman) {\n  cDataSource::registerComponent(_confman);\n}\n*/\n#define N_ALLOC_BLOCK 50\n\nSMILECOMPONENT_STATICS(cHtkSource)\n\nSMILECOMPONENT_REGCOMP(cHtkSource)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CHTKSOURCE;\n  sdescription = COMPONENT_DESCRIPTION_CHTKSOURCE;\n\n  // we inherit cDataSource configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSource\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"filename\",\"HTK parameter file to read\",\"input.htk\");\n    ct->setField(\"featureName\",\"The name of the array-field which is to be created in the data memory output level for the data array read from the HTK file\",\"htkpara\");\n    ct->setField(\"featureFrameSize\",\"The size of the feature frames in seconds.\",0.0);\n    ct->setField(\"forceSampleRate\",\"Set a given sample rate for the output level. Typically the base period of the input level will be used for this purpose, but when reading frame-based data from feature files, for example, this information is not available. This option overwrites the input level base period, if it is set.\",16000.0);\n    ct->setField(\"blocksize\", \"The size of data blocks to write at once (to data memory) in frames\", 10);\n//    ct->setField(\"featureNames\",\"array of feature names to apply (must match the vector size in the HTK parameter file!)\",\"htkpara\",ARRAY_TYPE);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cHtkSource);\n}\n\nSMILECOMPONENT_CREATE(cHtkSource)\n\n//-----\n\ncHtkSource::cHtkSource(const char *_name) :\n  cDataSource(_name),\n  eof(0),\n  featureName(NULL),\n  tmpvec(NULL)\n{\n  vax = smileHtk_IsVAXOrder();\n}\n\nvoid cHtkSource::fetchConfig()\n{\n  cDataSource::fetchConfig();\n  \n  filename = getStr(\"filename\");\n  SMILE_IDBG(2,\"filename = '%s'\",filename);\n  featureName = getStr(\"featureName\");\n  SMILE_IDBG(2,\"featureName = '%s'\",featureName);\n}\n\n\nint cHtkSource::myConfigureInstance()\n{\n  int ret = 1;\n  filehandle = fopen(filename, \"rb\");\n  if (filehandle == NULL) {\n    COMP_ERR(\"Error opening file '%s' for reading (component instance '%s', type '%s')\",filename, getInstName(), getTypeName());\n  }\n\n  if (!readHeader()) {\n    ret = 0;\n  } else {\n    ret *= cDataSource::myConfigureInstance();\n  }\n\n  if (ret == 0) {\n    fclose(filehandle); filehandle = NULL;\n  }\n  return ret;\n}\n\n/*\nint cHtkSource::readHeader()\n{\n  if (filehandle==NULL) return 0;\n  if (!fread(&head, sizeof(sHTKheader), 1, filehandle)) {\n    SMILE_IERR(1,\"error reading header from file '%s'\",filename);\n    return 0;\n  }\n  prepareHeader(&head); // convert to host byte order\n  return 1;\n}\n*/\n\nint cHtkSource::configureWriter(sDmLevelConfig &c)\n{\n  c.T = ( (double)head.samplePeriod ) * 0.000000100;  // convert HTK 100ns units..\n\n  if (isSet(\"forceSampleRate\")) {\n    double sr = getDouble(\"forceSampleRate\");\n    if (sr > 0.0) {\n      c.basePeriod = 1.0/sr;\n    } else {\n      c.basePeriod = 1.0;\n      SMILE_IERR(1,\"sample rate (forceSampleRate) must be > 0! (it is: %f)\",sr);\n    }\n  }\n  \n  if (isSet(\"featureFrameSize\")) {\n    c.frameSizeSec = getDouble(\"featureFrameSize\");\n    c.lastFrameSizeSec = c.frameSizeSec;\n  } \n\n  \n\n  return 1;\n}\n\nint cHtkSource::setupNewNames(long nEl)\n{\n  N = head.sampleSize/sizeof(float);\n  writer_->addField(featureName,N);\n\n  allocVec(N);\n  tmpvec = (float *)malloc(sizeof(float)*N);\n\n  namesAreSet_=1;\n  return 1;\n}\n\nint cHtkSource::myFinaliseInstance()\n{\n  int ret = cDataSource::myFinaliseInstance();\n  return ret;\n}\n\n\nint cHtkSource::myTick(long long t)\n{\n  if (isEOI()) return 0;\n\n  SMILE_IDBG(4,\"tick # %i, reading value vector from HTK parameter file\",t);\n  if (eof) {\n    SMILE_IDBG(4,\"EOF, no more data to read\");\n    return 0;\n  }\n\n  long n;\n  for (n=0; n<blocksizeW_; n++) {\n\n    // check if there is enough space in the data memory\n    if (!(writer_->checkWrite(1))) return 0;\n\n\n    if (fread(tmpvec, head.sampleSize, 1, filehandle)) {\n      long i;\n      if (vax) {\n        for (i=0; i<vec_->N; i++) {\n          smileHtk_SwapFloat ( (tmpvec+i) );\n          vec_->dataF[i] = (FLOAT_DMEM)tmpvec[i];\n        }\n      } else {\n        for (i=0; i<vec_->N; i++) {\n          vec_->dataF[i] = (FLOAT_DMEM)tmpvec[i];\n        }\n      }\n    } else {\n      // EOF ??\n      eof = 1;\n    } \n\n\n    if (!eof) {\n      writer_->setNextFrame(vec_);\n      return 1;\n    } else {\n      return 0;\n    }\n  }\n  return 0;\n}\n\n\ncHtkSource::~cHtkSource()\n{\n  if (filehandle!=NULL) fclose(filehandle);\n  if (tmpvec != NULL) free(tmpvec);\n}\n"
  },
  {
    "path": "src/iocore/waveSink.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nwaveSink: writes data to an uncompressed PCM WAVE file\n\n*/\n\n\n#include <iocore/waveSink.hpp>\n\n#define MODULE \"cWaveSink\"\n\n\n#define SMILE_SFSTR_8BIT        \"8bit\"     // 8-bit signed\n#define SMILE_SFSTR_16BIT       \"16bit\"    // 16-bit signed\n#define SMILE_SFSTR_24BIT       \"24bit\"    // 24-bit signed sample in 4byte dword\n#define SMILE_SFSTR_24BITp      \"24bitp\"   // 3-byte packed 24-bit signed value\n#define SMILE_SFSTR_32BIT       \"32bit\"    // 32-bit signed integer\n#define SMILE_SFSTR_32BIT_FLOAT \"float\"    // 32-bit float\n\n#define SMILE_SF_8BIT        0    // 8-bit signed\n#define SMILE_SF_16BIT       1    // 16-bit signed\n#define SMILE_SF_24BIT       2    // 24-bit signed sample in 4byte dword\n#define SMILE_SF_24BITp      3    // 3-byte packed 24-bit signed value\n#define SMILE_SF_32BIT       4    // 32-bit signed integer\n#define SMILE_SF_32BIT_FLOAT 5    // 32-bit float\n\nSMILECOMPONENT_STATICS(cWaveSink)\n\nSMILECOMPONENT_REGCOMP(cWaveSink)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CWAVESINK;\n  sdescription = COMPONENT_DESCRIPTION_CWAVESINK;\n\n  // we inherit cDataSink configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSink\")\n\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->makeMandatory(ct->setField(\"filename\",\"The filename of the PCM wave file to write data to\",\"output.wav\"));\n    //ct->setField(\"buffersize\",\"size of data to write at once\",2048);\n    char * sfdesc = myvprint(\"openSMILE uses float for all data internally. Thus you must specify your desired sample format for the wave files here. Available formats:\\n   '%s' : 8-bit signed \\n   '%s' : 16-bit signed\\n   '%s' : 24-bit signed\\n   '%s' : 24-bit signed packed in 3 bytes\\n   '%s' : 32-bit signed integer\\n   '%s' : 32-bit float\",SMILE_SFSTR_8BIT,SMILE_SFSTR_16BIT,SMILE_SFSTR_24BIT,SMILE_SFSTR_24BITp,SMILE_SFSTR_32BIT,SMILE_SFSTR_32BIT_FLOAT);\n    ct->setField(\"sampleFormat\",sfdesc,SMILE_SFSTR_16BIT);\n    //ct->setField(\"sampleFormat\",\"openSMILE uses float for all data internally. Thus you must specify your desired sample format for the wave files here. Available formats:\\n   '8bit' : 8-bit signed \\n   '16bit' : 16-bit signed\\n   '24bit' : 24-bit signed\\n   '24bitp' : 24-bit signed packed in 3 bytes\\n   '32bit' : 32-bit signed integer\\n   'float' : 32-bit float\",SMILE_SFSTR_16BIT);\n    free(sfdesc);\n\n    ct->setField(\"flushData\",\"1/0 (on/off) : flush data to disk and update wave header after writing a frame to the output file (default behaviour is to flush only when the file is closed and openSMILE is being terminated via Ctrl+C or at the end-of-input in offline mode)\",0);\n\n    // overwrite cDataSink's default blocksize, enabling faster disk access:\n    ct->setField(\"blocksize_sec\", NULL , 1.0);\n  )\n\n    SMILECOMPONENT_MAKEINFO(cWaveSink);\n}\n\nSMILECOMPONENT_CREATE(cWaveSink)\n\n//-----\n\ncWaveSink::cWaveSink(const char *_name) :\n  cDataSink(_name),\n  fHandle(NULL),\n  sampleBuffer(NULL),\n  sampleBufferLen(NULL)\n{\n  // ...\n}\n\nvoid cWaveSink::fetchConfig()\n{\n  cDataSink::fetchConfig();\n\n  filename = getStr(\"filename\");\n  SMILE_DBG(2,\"filename = '%s'\",filename);\n  if (filename == NULL) COMP_ERR(\"fetchConfig: getStr(filename) returned NULL! missing option in config file?\");\n\n  /*\n  lag = getInt(\"lag\");\n  SMILE_DBG(2,\"lag = %i\",lag);\n*/\n  //frameRead = getInt(\"frameRead\");\n  //SMILE_DBG(2,\"frameRead = %i\",frameRead);\n/*\n  buffersize = getInt(\"buffersize\");\n  SMILE_DBG(2,\"buffersize = %i\",buffersize);\n*/\n\n  const char * sampleFormatStr = getStr(\"sampleFormat\");\n  if (sampleFormatStr != NULL) {\n    SMILE_DBG(2,\"sampleFormat = '%s'\",sampleFormatStr);\n    if (!strcasecmp(sampleFormatStr,SMILE_SFSTR_8BIT)) {\n      nBitsPerSample = 8;\n      nBytesPerSample = 1;\n      sampleFormat = SMILE_SF_8BIT;\n    }\n    else if (!strcasecmp(sampleFormatStr,SMILE_SFSTR_16BIT)) {\n      nBitsPerSample = 16;\n      nBytesPerSample = 2;\n      sampleFormat = SMILE_SF_16BIT;\n    }\n    else if (!strcasecmp(sampleFormatStr,SMILE_SFSTR_24BIT)) {\n      nBitsPerSample = 24;\n      nBytesPerSample = 4;\n      sampleFormat = SMILE_SF_24BIT;\n    }\n    else if (!strcasecmp(sampleFormatStr,SMILE_SFSTR_24BITp)) {\n      nBitsPerSample = 24;\n      nBytesPerSample = 3;\n      sampleFormat = SMILE_SF_24BITp;\n    }\n    else if (!strcasecmp(sampleFormatStr,SMILE_SFSTR_32BIT)) {\n      nBitsPerSample = 32;\n      nBytesPerSample = 4;\n      sampleFormat = SMILE_SF_32BIT;\n    }\n    else if (!strcasecmp(sampleFormatStr,SMILE_SFSTR_32BIT_FLOAT)) {\n      nBitsPerSample = 32;\n      nBytesPerSample = 4;\n      sampleFormat = SMILE_SF_32BIT_FLOAT;\n    }\n    else\n    {\n      SMILE_IERR(1,\"unknown sampleFormat '%s'!\",sampleFormatStr);\n      COMP_ERR(\"aborting\");\n    }\n  }\n\n  flushData = getInt(\"flushData\");\n\n}\n\nint cWaveSink::configureReader()\n{\n  if (blocksizeR_ < 10) blocksizeR_ = 10;\n  reader_->setupSequentialMatrixReading( blocksizeR_, blocksizeR_, 0 );\n  return 1;\n}\n\nint cWaveSink::myFinaliseInstance()\n{\n  int ret = cDataSink::myFinaliseInstance();\n  if (!ret) return 0;\n\n  // open wave file for writing\n  if (fHandle == NULL) {\n    fHandle = fopen(filename, \"wb\");  // TODO: support append mode\n    if (fHandle == NULL) COMP_ERR(\"failed to open output file '%s'\",filename);\n  }\n\n  nBlocks = 0;\n\n  // write dummy header...\n  nChannels = reader_->getLevelN();\n  curWritePos = writeWaveHeader();\n  if (curWritePos == 0) COMP_ERR(\"failed writing initial wave header to file '%s'! Disk full or read-only filesystem?\",filename);\n  return ret;\n}\n\nint cWaveSink::myTick(long long t)\n{\n  SMILE_DBG(4,\"tick # %i, reading value vector:\",t);\n\n  // read next buffer from memory:\n  cMatrix *mat = reader_->getNextMatrix(0, 0, DMEM_PAD_NONE);\n  int ret = writeData(mat);\n  if (mat != NULL && flushData) {\n    // NOTE: if the application is killed during this flush procedure the wave file might be corrput!\n    writeWaveHeader();\n    // set file pointer back to end of file for appending the next frame\n    fseek(fHandle,0,SEEK_END);\n    // flush data to disk\n    fflush(fHandle);\n  }\n  return ret;\n}\n\n\ncWaveSink::~cWaveSink()\n{\n  if (sampleBuffer!=NULL) free(sampleBuffer);\n  if (fHandle != NULL) {\n    // write final wave header\n    writeWaveHeader();\n    fclose(fHandle);\n  }\n}\n\n//----------------------------------------------------------------------------------\n\n#ifdef HAVE_UNISTD_H\n#include <unistd.h>\n#endif\n\n/* WAVE Header struct, valid only for PCM Files */\ntypedef struct {\n  uint32_t\tRiff;    /* Must be little endian 0x46464952 (RIFF) */\n  uint32_t\tFileSize;\n  uint32_t\tFormat;  /* Must be little endian 0x45564157 (WAVE) */\n\n  uint32_t\tSubchunk1ID;  /* Must be little endian 0x20746D66 (fmt ) */\n  uint32_t\tSubchunk1Size;\n  uint16_t\tAudioFormat;\n  uint16_t\tNumChannels;\n  uint32_t\tSampleRate;\n  uint32_t\tByteRate;\n  uint16_t\tBlockAlign;\n  uint16_t\tBitsPerSample;\n\n  uint32_t\tSubchunk2ID;  /* Must be little endian 0x61746164 (data) */\n  uint32_t  Subchunk2Size;\n} sRiffPcmWaveHeader;\n\ntypedef struct {\n  uint32_t SubchunkID;\n  uint32_t SubchunkSize;\n} sRiffChunkHeader;\n\nint cWaveSink::writeWaveHeader()\n{\n  if (fHandle == NULL) return 0;\n\n  // use reader parameters to determine\n  //   nChannels\n  //   sampleRate\n  long sampleRate;\n  sampleRate = (long)( 1.0 / (reader_->getLevelT()) );\n  // get sample format from config options\n\n  sRiffPcmWaveHeader head; \n  head.Riff = 0x46464952;  // RIFF\n  head.Format = 0x45564157; // WAVE\n  head.Subchunk1ID = 0x20746D66; // fmt\n  head.Subchunk1Size = 4*4; // size of format chunk\n  head.SampleRate = sampleRate;\n  head.BitsPerSample = nBitsPerSample;\n  head.ByteRate = sampleRate * nChannels * nBytesPerSample;\n  head.AudioFormat = 1; // !!! ??\n  head.NumChannels = nChannels;\n  head.BlockAlign = nChannels * nBytesPerSample;\n  head.Subchunk2ID = 0x61746164; // data\n  head.Subchunk2Size = nBlocks * nChannels * nBytesPerSample;  // size of wave data chunk\n  head.FileSize = sizeof(sRiffPcmWaveHeader)  + head.Subchunk2Size;\n  fseek(fHandle, 0, SEEK_SET);\n  return (fwrite(&head, sizeof(sRiffPcmWaveHeader), 1, fHandle) == 1 ? sizeof(sRiffPcmWaveHeader) : 0 );\n}\n\nint cWaveSink::writeData(cMatrix *m) \n{\n  if (m!=NULL) {\n    if (m->N != nChannels) { SMILE_IERR(1,\"number of chanels is inconsistent! %i <-> %i\",m->fmeta->N,nChannels); return 0; }\n    else {\n      // convert data\n      long i;\n      if ((m->nT > sampleBufferLen)&&(sampleBuffer!=NULL)) free(sampleBuffer);\n      sampleBufferLen = m->nT;\n      if (sampleBuffer == NULL) sampleBuffer = malloc(nBytesPerSample*nChannels*m->nT);\n\n      int8_t *b8;\n      int16_t *b16;\n      int32_t *b32;\n      float *b32f;\n\n      switch(sampleFormat) {\n      case SMILE_SF_8BIT:\n        b8 = (int8_t*)sampleBuffer;\n        for (i=0; i<m->nT*nChannels; i++) { b8[i] = (int8_t)round(m->dataF[i] * 127.0); }\n        break;\n      case SMILE_SF_16BIT:\n        b16 = (int16_t*)sampleBuffer;\n        for (i=0; i<m->nT*nChannels; i++) { b16[i] = (int16_t)round(m->dataF[i] * 32767.0); }\n        break;\n      case SMILE_SF_24BIT:\n        b32 = (int32_t*)sampleBuffer;\n        for (i=0; i<m->nT*nChannels; i++) { b32[i] = (int32_t)round(m->dataF[i] * 32767.0 * 256.0); }\n        break;\n      case SMILE_SF_24BITp:\n        COMP_ERR(\"24-bit wave file with 3 bytes per sample encoding not yet supported!\");\n        //int16_t *b16 = buf;\n        //for (i=0; i<m->nT*nChannels; i++) { b16[i] = (int16_t)round(m->dataF[i] * 32767.0); }\n        //break;\n      case SMILE_SF_32BIT:\n        b32 = (int32_t*)sampleBuffer;\n        for (i=0; i<m->nT*nChannels; i++) { b32[i] = (int32_t)round(m->dataF[i] * 32767.0 * 32767.0 * 2.0); }\n        break;\n      case SMILE_SF_32BIT_FLOAT:\n        b32f = (float*)sampleBuffer;\n        for (i=0; i<m->nT*nChannels; i++) { b32f[i] = (float)(m->dataF[i]); }\n        break;\n      default:\n        SMILE_IERR(1,\"unknown sampleFormat encountered in writeData(): %i\",sampleFormat);\n      }\n\n      long written = (long)fwrite(sampleBuffer, nBytesPerSample*nChannels, m->nT, fHandle);\n      if (written != m->nT) {\n        SMILE_IERR(2, \"Data lost during write to output file (%ld of %ld records written)\\n \", written, m->nT);\n        // TODO: try to repeat write??\n      }\n      if (written > 0) {\n        nBlocks += written;\n        curWritePos += nBytesPerSample*nChannels * written;\n        return written;\n      }\n\n    }\n  }\n  return 0;\n}\n"
  },
  {
    "path": "src/iocore/waveSinkCut.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nwaveSink: writes data to an uncompressed PCM WAVE file, thereby being able to split the output to multiple files, based on messages\n\n*/\n\n/*\n read wave frame by frame\n get turnStart / turnEnd messages (pre/post normalised)\n read from initial pcm frames level\n if isTurn: write data to current file frame by frame\n @turnEnd: close file\n @turnStart: open new file, increase file number counter\n*/\n\n\n\n\n#include <iocore/waveSinkCut.hpp>\n\n#define MODULE \"cWaveSinkCut\"\n\n\n#define SMILE_SFSTR_8BIT        \"8bit\"     // 8-bit signed\n#define SMILE_SFSTR_16BIT       \"16bit\"    // 16-bit signed\n#define SMILE_SFSTR_24BIT       \"24bit\"    // 24-bit signed sample in 4byte dword\n#define SMILE_SFSTR_24BITp      \"24bitp\"   // 3-byte packed 24-bit signed value\n#define SMILE_SFSTR_32BIT       \"32bit\"    // 32-bit signed integer\n#define SMILE_SFSTR_32BIT_FLOAT \"float\"    // 32-bit float\n\n#define SMILE_SF_8BIT        0    // 8-bit signed\n#define SMILE_SF_16BIT       1    // 16-bit signed\n#define SMILE_SF_24BIT       2    // 24-bit signed sample in 4byte dword\n#define SMILE_SF_24BITp      3    // 3-byte packed 24-bit signed value\n#define SMILE_SF_32BIT       4    // 32-bit signed integer\n#define SMILE_SF_32BIT_FLOAT 5    // 32-bit float\n\nSMILECOMPONENT_STATICS(cWaveSinkCut)\n\nSMILECOMPONENT_REGCOMP(cWaveSinkCut)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CWAVESINKCUT;\n  sdescription = COMPONENT_DESCRIPTION_CWAVESINKCUT;\n\n  // we inherit cDataSink configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSink\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"fileBase\",\"The base of the wave file name, if writing multiple output files (multiOut=1), or else the filename of the wave file to write to\",\"output_segment_\");\n    ct->setField(\"fileExtension\",\"The file extension to use when writing multiple output files (multiOut=1), else this option is ignored (the extension is set via 'fileBase' then which specifies the full file name)\",\".wav\");\n    ct->setField(\"fileNameFormatString\",\"Specifies how the filename will be formatted (printf compatible syntax, three parameters are available in the given order: fileBase (string), current index (integer), fileExtension (string)), the default should be reasonable, it generates filenames such as 'output_segment_XXXX.wav'.\",\"%s%04d%s\");\n    ct->setField(\"startIndex\",\"The index of the first file for consecutive numbering of output files (if multiOut=1)\",1);\n    ct->setField(\"preSil\",\"Specifies the amount of silence at the turn beginning in seconds, i.e. the lag of the turn detector. This is the length of the data that will be added to the current segment prior to the turn start time received in the message from the turn detector component.\",0.2);\n    ct->setField(\"postSil\",\"Specifies the amount of silence at the turn end in seconds. This is the length of the data that will be added to the current segment after to the turn end time received in the message from the turn detector component.\",0.3);\n    ct->setField(\"multiOut\",\"1 = enable multiple file mode, i.e. multiple files segmented by turnStart/turnEnd messages ; 0 = write all frames (only between turnStart/turnEnd messages) concatenated to one file, i.e. effectively filtering out non-turn audio.\",1);\n    ct->setField(\"forceSampleRate\",\"force sample rate to given value (if not set, it is determined from the reader's frame size in bytes, which may be inaccurate)\",16000);\n    char * sfdesc = myvprint(\"openSMILE uses float for all data internally. Thus you must specify your desired sample format for the wave files here. Available formats:\\n   '%s' : 8-bit signed \\n   '%s' : 16-bit signed\\n   '%s' : 24-bit signed\\n   '%s' : 24-bit signed packed in 3 bytes\\n   '%s' : 32-bit signed integer\\n   '%s' : 32-bit float\",SMILE_SFSTR_8BIT,SMILE_SFSTR_16BIT,SMILE_SFSTR_24BIT,SMILE_SFSTR_24BITp,SMILE_SFSTR_32BIT,SMILE_SFSTR_32BIT_FLOAT);\n    ct->setField(\"sampleFormat\",sfdesc,SMILE_SFSTR_16BIT);\n    ct->setField(\"showSegmentTimes\", \"1 = show start and end times relative to input of segments that are saved by this sink.\", 0);\n    ct->setField(\"saveSegmentTimes\", \"1 = save turn times (start, end, and filename) to text file.\", (const char*)NULL);\n    //ct->setField(\"sampleFormat\",\"openSMILE uses float for all data internally. Thus you must specify your desired sample format for the wave files here. Available formats:\\n   '8bit' : 8-bit signed \\n   '16bit' : 16-bit signed\\n   '24bit' : 24-bit signed\\n   '24bitp' : 24-bit signed packed in 3 bytes\\n   '32bit' : 32-bit signed integer\\n   'float' : 32-bit float\",SMILE_SFSTR_16BIT);\n\t  free(sfdesc);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cWaveSinkCut);\n}\n\nSMILECOMPONENT_CREATE(cWaveSinkCut)\n\n//-----\n\ncWaveSinkCut::cWaveSinkCut(const char *_name) :\n  cDataSink(_name),\n  fHandle(NULL),\n  filebase(NULL),\n  fileExtension(NULL),\n  multiOut(0),\n  isTurn(0), curStart(0), curEnd(0),\n  turnEnd(0), turnStart(0),\n  curFileNr(0), fieldSize(0),\n  curVidx(0), vIdxStart(0), vIdxEnd(0), endWait(-1),\n  sampleBuffer(NULL), sampleBufferLen(0),\n  nOvl(0), preSil(0), postSil(0),\n  forceSampleRate(0),\n  showSegmentTimes_(0)\n{\n  // ...\n}\n\nvoid cWaveSinkCut::fetchConfig()\n{\n  cDataSink::fetchConfig();\n\n  filebase = getStr(\"fileBase\");\n  SMILE_IDBG(2,\"fileBase = '%s'\",filebase);\n  if (filebase == NULL) COMP_ERR(\"fetchConfig: getStr(filebase) returned NULL! missing option in config file?\");\n\n  fileExtension = getStr(\"fileExtension\");\n  SMILE_IDBG(2,\"fileExtension = '%s'\",fileExtension);\n\n  fileNameFormatString = getStr(\"fileNameFormatString\");\n  SMILE_IDBG(2,\"fileNameFormatString = '%s'\",fileNameFormatString);\n\n  multiOut = getInt(\"multiOut\");\n  if (multiOut) { SMILE_IDBG(2,\"outputting multiple files\"); }\n\n  curFileNr = getInt(\"startIndex\");\n  SMILE_IDBG(2,\"startIndex = %i\",curFileNr);\n\n  const char * sampleFormatStr = getStr(\"sampleFormat\");\n  if (sampleFormatStr != NULL) {\n    SMILE_DBG(2,\"sampleFormat = '%s'\",sampleFormatStr);\n    if (!strcasecmp(sampleFormatStr,SMILE_SFSTR_8BIT)) {\n      nBitsPerSample = 8;\n      nBytesPerSample = 1;\n      sampleFormat = SMILE_SF_8BIT;\n    }\n    else if (!strcasecmp(sampleFormatStr,SMILE_SFSTR_16BIT)) {\n      nBitsPerSample = 16;\n      nBytesPerSample = 2;\n      sampleFormat = SMILE_SF_16BIT;\n    }\n    else if (!strcasecmp(sampleFormatStr,SMILE_SFSTR_24BIT)) {\n      nBitsPerSample = 24;\n      nBytesPerSample = 4;\n      sampleFormat = SMILE_SF_24BIT;\n    }\n    else if (!strcasecmp(sampleFormatStr,SMILE_SFSTR_24BITp)) {\n      nBitsPerSample = 24;\n      nBytesPerSample = 3;\n      sampleFormat = SMILE_SF_24BITp;\n    }\n    else if (!strcasecmp(sampleFormatStr,SMILE_SFSTR_32BIT)) {\n      nBitsPerSample = 32;\n      nBytesPerSample = 4;\n      sampleFormat = SMILE_SF_32BIT;\n    }\n    else if (!strcasecmp(sampleFormatStr,SMILE_SFSTR_32BIT_FLOAT)) {\n      nBitsPerSample = 32;\n      nBytesPerSample = 4;\n      sampleFormat = SMILE_SF_32BIT_FLOAT;\n    }\n    else\n    {\n      SMILE_IERR(1,\"unknown sampleFormat '%s'!\",sampleFormatStr);\n      COMP_ERR(\"aborting\");\n    }\n  }\n\n  if (isSet(\"forceSampleRate\")) {\n    forceSampleRate = getInt(\"forceSampleRate\");\n  } else {\n    forceSampleRate = 0;\n  }\n\n  showSegmentTimes_ = getInt(\"showSegmentTimes\");\n  saveSegmentTimes_ = getStr(\"saveSegmentTimes\");\n}\n\n// get the current filename , caller must free the string!\nchar * cWaveSinkCut::getCurFileName() \n{\n  if (multiOut) {\n    return myvprint(fileNameFormatString, filebase, curFileNr, fileExtension);\n  } else {\n    return strdup(filebase);\n  }\n}\n\nint cWaveSinkCut::myConfigureInstance()\n{\n  int ret = cDataSink::myConfigureInstance();\n  if (!ret) return 0;\n  return ret;\n}\n\n\nint cWaveSinkCut::myFinaliseInstance()\n{\n  int ret = cDataSink::myFinaliseInstance();\n  if (!ret) return 0;\n\n // setup pre/post silence config:\n  float _preSil = (float)getDouble(\"preSil\");\n  float _postSil = (float)getDouble(\"postSil\");\n  double _T = reader_->getLevelT();\n  if (_T!=0.0) preSil = (int)ceil(_preSil/_T);\n  else preSil = (int)(_preSil);\n  if (_T!=0.0) postSil = (int)ceil(_postSil/_T);\n  else postSil = (int)(_postSil);\n\n  nChannels = reader_->getLevelNf();\n  fieldSize = reader_->getLevelN() / nChannels;\n\n  // open wave file for writing\n  if (multiOut == 0) {\n    if (fHandle == NULL) {\n      fHandle = fopen(getCurFileName(), \"wb\");  // TODO: support append mode\n      if (fHandle == NULL) COMP_ERR(\"failed to open output file '%s'\",getCurFileName());\n    }\n  }\n\n  nBlocks = 0;\n  if (fHandle != NULL) {\n    // write dummy header...\n    curWritePos = writeWaveHeader();\n    if (curWritePos == 0) COMP_ERR(\"failed writing initial wave header to file '%s'! Disk full or read-only filesystem?\",getCurFileName());\n  }\n\n  return ret;\n}\n\nvoid cWaveSinkCut::saveAndPrintSegmentData(long n)\n{\n  if (saveSegmentTimes_ != NULL && saveSegmentTimes_[0] != '?') {\n    FILE *f = fopen(saveSegmentTimes_, \"a\");\n    // each line: filename;startsec;endsec;numberOfFrames(Vidxes)\n    fprintf(f, \"%s;%f,%f;%ld\\n\", getCurFileName(), startSec_, endSec_, n);\n    fclose(f);\n  }\n  if (showSegmentTimes_) {\n    printf(\"Segment '%s' : %f sec. - %f sec. (%ld frames)\\n\", getCurFileName(), startSec_, endSec_, n);\n  }\n}\n\nint cWaveSinkCut::processComponentMessage( cComponentMessage *msg )\n{\n  if (multiOut==1) {\n    if (isMessageType(msg,\"turnStart\")) {\n      // if previous message was not yet processed we update the data\n      nPre = (long)(msg->floatData[0]);\n      vIdxStart = (long)(msg->floatData[1]) - preSil;\n      turnStart=1;\n      startSec0_ = (float)(msg->floatData[2] * (double)vIdxStart);\n      if (showSegmentTimes_) {\n        printf(\"  (Start of segment received: %.2f seconds)\\n\", startSec0_);\n      }\n      return 1;\n    }\n    if (isMessageType(msg,\"turnEnd\")) {\n      if (!turnEnd) { // if previous message was not yet processed we discard this message\n        nPost = (long)(msg->floatData[0]);\n        vIdxEnd = (long)(msg->floatData[1]) + postSil;\n        turnEnd = 1;\n        endSec_ = (float)(msg->floatData[2] * (double)vIdxEnd);\n        startSec_ = startSec0_;\n        if (showSegmentTimes_) {\n          printf(\"  (End of segment received: %.2f seconds)\\n\", endSec_);\n        }\n        //SMILE_IDBG(2,\"received turn end at vIdx %i!\",vIdxEnd); \n        return 1;\n      }\n    }\n    // TODO: message queque??\n  }\n  return 0;\n}\n\nint cWaveSinkCut::myTick(long long t)\n{\n  //if (fieldSize == 0) fieldSize = reader->getLevelN() / reader->getLevelNf(); //vec->fmeta->field[0].N;\n  if (multiOut == 1) {\n    lockMessageMemory();\n    // handle pre/post silence and turn detector interface\n    if ((turnStart)&&(!turnEnd)) { \n      turnStart = 0; \n      curVidx = vIdxStart;\n      if (curVidx < 0) {\n        curVidx = 0;\n      }\n      isTurn = 1;\n      SMILE_IDBG(2,\"received turn start at vIdx %i!\",vIdxStart); \n\n      // just to be sure...\n      if (fHandle != NULL) fclose(fHandle);\n      fHandle = fopen(getCurFileName(), \"wb\");  // TODO: support append mode\n      if (fHandle == NULL) SMILE_IERR(1,\"failed to open output file '%s', no wave output will be written\",getCurFileName());\n\n      nBlocks=0;\n      curWritePos = writeWaveHeader();\n      if (curWritePos == 0) {\n        SMILE_IERR(1,\"failed writing initial wave header to file '%s'! Disk full or read-only filesystem?\",getCurFileName());\n        fclose(fHandle); fHandle=NULL;\n      }\n    }\n    if (turnEnd) { \n      if (curVidx >= vIdxEnd) { turnEnd = 0; isTurn = 0; }\n      // if no frames have been written...\n      if (curVidx == vIdxStart && isTurn) { \n        SMILE_IERR(1,\"no frames were written for turn #%i\",curFileNr);\n        turnEnd=0; isTurn=0;\n      }\n      if (!turnEnd) {\n        if (fHandle != NULL) {\n          saveAndPrintSegmentData(curVidx - vIdxStart);\n          SMILE_IDBG(2,\"processed turn end, file '%s' was closed!\", getCurFileName());\n          writeWaveHeader();\n          fclose(fHandle); \n          nBlocks=0;\n          fHandle=NULL;\n          curFileNr++;\n        }\n      }\n    }\n    //if (!isTurn) { ret=-3; isTurn = 1; }\n    unlockMessageMemory();\n  }\n\n  // read next buffer from memory:\n  if ((fHandle != NULL)&&(isTurn)) {\n    // TODO: if vIdxstart == -1 , then call reader_->getNextFrame to get latest frame...\n    cVector *vec = reader_->getFrame(curVidx);\n    if (vec == NULL) return 0;\n    curVidx++;\n    // write data buffer to file:\n    return writeDataFrame(vec);\n  } else {\n    reader_->catchupCurR();\n  }\n  return isTurn;\n}\n\n\ncWaveSinkCut::~cWaveSinkCut()\n{\n  if (sampleBuffer!=NULL) free(sampleBuffer);\n  if (fHandle != NULL) {\n    // write final wave header\n    writeWaveHeader();\n    fclose(fHandle);\n  }\n}\n\n//----------------------------------------------------------------------------------\n\n#ifdef HAVE_UNISTD_H\n#include <unistd.h>\n#endif\n\n/* WAVE Header struct, valid only for PCM Files */\ntypedef struct {\n  uint32_t\tRiff;    /* Must be little endian 0x46464952 (RIFF) */\n  uint32_t\tFileSize;\n  uint32_t\tFormat;  /* Must be little endian 0x45564157 (WAVE) */\n\n  uint32_t\tSubchunk1ID;  /* Must be little endian 0x20746D66 (fmt ) */\n  uint32_t\tSubchunk1Size;\n  uint16_t\tAudioFormat;\n  uint16_t\tNumChannels;\n  uint32_t\tSampleRate;\n  uint32_t\tByteRate;\n  uint16_t\tBlockAlign;\n  uint16_t\tBitsPerSample;\n\n  uint32_t\tSubchunk2ID;  /* Must be little endian 0x61746164 (data) */\n  uint32_t  Subchunk2Size;\n} sRiffPcmWaveHeader;\n\ntypedef struct {\n  uint32_t SubchunkID;\n  uint32_t SubchunkSize;\n} sRiffChunkHeader;\n\nint cWaveSinkCut::writeWaveHeader()\n{\n  if (fHandle == NULL) return 0;\n\n  // use reader parameters to determine\n  //   nChannels\n  //   sampleRate\n  long sampleRate;\n  // TODO: detect overlap!!\n  double fss = reader_->getFrameSizeSec();\n  double ft  = reader_->getLevelT();\n\n  nOvl = (long)ceil( (double)fieldSize * (1.0 - (ft/fss)) );\n\n  // get sample format from config options\n  if (forceSampleRate != 0) {\n    sampleRate = forceSampleRate;\n  } else {\n    sampleRate = (long)( 1.0 / (fss / (double)fieldSize) );\n  }\n\n  sRiffPcmWaveHeader head; \n  head.Riff = 0x46464952;  // RIFF\n  head.Format = 0x45564157; // WAVE\n  head.Subchunk1ID = 0x20746D66; // fmt\n  head.Subchunk1Size = 4*4; // size of format chunk\n  head.SampleRate = sampleRate;\n  head.BitsPerSample = nBitsPerSample;\n  head.ByteRate = sampleRate * nChannels * nBytesPerSample;\n  head.AudioFormat = 1; // !!! ??\n  head.NumChannels = nChannels;\n  head.BlockAlign = nChannels * nBytesPerSample;\n  head.Subchunk2ID = 0x61746164; // data\n  head.Subchunk2Size = nBlocks * nChannels * nBytesPerSample;  // size of wave data chunk\n  head.FileSize = sizeof(sRiffPcmWaveHeader)  + head.Subchunk2Size;\n\n  fseek(fHandle, 0, SEEK_SET);\n  return (fwrite(&head, sizeof(sRiffPcmWaveHeader), 1, fHandle) == 1 ? sizeof(sRiffPcmWaveHeader) : 0 );\n}\n\nint cWaveSinkCut::writeDataFrame(cVector *m) \n{\n  if (m!=NULL) {\n    if (m->fmeta->N != nChannels) { SMILE_IERR(1,\"number of chanels is inconsistent! %i <-> %i\",m->fmeta->N,nChannels); return 0; }\n    else {\n      // convert data\n      long i,j;\n      if (( (m->fmeta->field[0].N - nOvl) > sampleBufferLen)&&(sampleBuffer!=NULL)) { free(sampleBuffer); sampleBuffer = NULL; }\n      sampleBufferLen = m->fmeta->field[0].N - nOvl;\n      if (sampleBufferLen<=0) {\n        SMILE_IERR(1,\"sampleBufferLen<=0! (%i), something went wrong with computing frame size and overlap!\",sampleBufferLen);\n        return 0;\n      }\n\n      if (sampleBuffer == NULL) sampleBuffer = malloc(nBytesPerSample*nChannels*sampleBufferLen);\n\n      int8_t *b8;\n      int16_t *b16;\n      int32_t *b32;\n      float *b32f;\n\n      switch(sampleFormat) {\n        case SMILE_SF_8BIT: \n          b8 = (int8_t*)sampleBuffer;\n          for (i=0; i<sampleBufferLen; i++) { \n            for (j=0; j<nChannels; j++) { // conversion from separate channels to interleaved channels\n              b8[i*nChannels+j] = (int8_t)round(m->dataF[i+sampleBufferLen*j] * 127.0);\n            }\n          }\n          break;\n        case SMILE_SF_16BIT: \n          b16 = (int16_t*)sampleBuffer;\n          for (i=0; i<sampleBufferLen; i++) { \n            for (j=0; j<nChannels; j++) { // conversion from separate channels to interleaved channels\n              b16[i*nChannels+j] = (int16_t)round(m->dataF[i+sampleBufferLen*j] * 32767.0); \n            }\n          }\n          break;\n        case SMILE_SF_24BIT: \n          b32 = (int32_t*)sampleBuffer;\n          for (i=0; i<sampleBufferLen; i++) { \n            for (j=0; j<nChannels; j++) { // conversion from separate channels to interleaved channels\n              b32[i*nChannels+j] = (int32_t)round(m->dataF[i+sampleBufferLen*j] * 32767.0 * 256.0);\n            }\n          }\n          break;\n        case SMILE_SF_24BITp: \n          COMP_ERR(\"24-bit wave file with 3 bytes per sample encoding not yet supported!\");\n          //int16_t *b16 = buf;\n          //for (i=0; i<m->nT*nChannels; i++) { b16[i] = (int16_t)round(m->dataF[i] * 32767.0); }\n          //break;\n        case SMILE_SF_32BIT: \n          b32 = (int32_t*)sampleBuffer;\n          for (i=0; i<sampleBufferLen; i++) { \n            for (j=0; j<nChannels; j++) { // conversion from separate channels to interleaved channels\n              b32[i*nChannels+j] = (int32_t)round(m->dataF[i+sampleBufferLen*j] * 32767.0 * 32767.0 * 2.0); \n            }\n          }\n          break;\n        case SMILE_SF_32BIT_FLOAT: \n          b32f = (float*)sampleBuffer;\n          for (i=0; i<sampleBufferLen; i++) { \n            for (j=0; j<nChannels; j++) { // conversion from separate channels to interleaved channels\n              b32f[i*nChannels+j] = (float)(m->dataF[i+sampleBufferLen*j]); \n            }\n          }\n          break;\n        default:\n          SMILE_IERR(1,\"unknown sampleFormat encountered in writeData(): %i\",sampleFormat);\n      }\n\n      long written = (long)fwrite(sampleBuffer, nBytesPerSample*nChannels, sampleBufferLen, fHandle);\n      //printf(\"written: %i of %i\\n\",written,m->nT);\n      if (written > 0) {\n        nBlocks += written;\n        curWritePos += nBytesPerSample*nChannels * written;\n        return written;\n      }\n\n    }\n  }\n  return 0;\n}\n"
  },
  {
    "path": "src/iocore/waveSource.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nwaveSource : reads PCM WAVE files (RIFF format)\n\nSupport for a negative start index was added by Benedikt Gollan (TUM).\n\n\nTODO:\nmulti filename support (EOI signalling after every filename? Or turnFrameTimeMessage? make it configurable!)\nsegmentList support ()  (EOI signalling or frametime message after each segment? make it configurable!)\n*/\n\n\n#include <iocore/waveSource.hpp>\n#define MODULE \"cWaveSource\"\n\nSMILECOMPONENT_STATICS(cWaveSource)\n\nSMILECOMPONENT_REGCOMP(cWaveSource)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CWAVESOURCE;\n  sdescription = COMPONENT_DESCRIPTION_CWAVESOURCE;\n\n  // we inherit cDataSource configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSource\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->makeMandatory(ct->setField(\"filename\",\"The filename of the PCM wave file to load. Only uncompressed RIFF files are supported. Use a suitable converter (mplayer, for example) to convert other formats to wave.\",\"input.wav\"));\n    ct->setField(\"properTimestamps\", \"1 = set smileTime for every input sample based on sample time (a bit inefficient); otherwise the default is to use the current system time at which the samples are read from the file.\", 0);\n    ct->setField(\"monoMixdown\",\"Mix down all channels to 1 mono channel (1=on, 0=off)\",1);\n    ct->setField(\"segmentList\", \"List of segments with start end times. (NOT IMPLEMENTED YET).\", (const char*)NULL, ARRAY_TYPE);\n    ct->setField(\"start\",\"The read start point in seconds from the beginning of the file\",0.0);\n    ct->setField(\"end\",\"The read end point in seconds from the beginning of file (-1 = read to EoF)\",-1.0);\n    ct->setField(\"endrel\",\"The read end point in seconds from the END of file (only if 'end' = -1, or not set)\",0.0);\n    ct->setField(\"startSamples\",\"The read start in samples from the beginning of the file (this overwrites 'start')\",0,0,0);\n    ct->setField(\"endSamples\",\"The read end in samples from the beginning of the file (this overwrites 'end' and 'endrelSamples')\",-1,0,0);\n    ct->setField(\"endrelSamples\",\"The read end in samples from the END of file (this overwrites 'endrel')\",0,0,0);\n    ct->setField(\"noHeader\",\"1 = treat the input file as 'raw' format, i.e. don't read the RIFF header. You must specify the parameters 'sampleRate', 'channels', and possibly 'sampleSize' if the defaults don't match your file format\",0);\n    ct->setField(\"sampleRate\",\"Set/force the sampling rate that is assigned to the input data (required for reading raw files)\",16000,0,0);\n    ct->setField(\"sampleSize\",\"Set/force the samplesize (in bytes) (required for reading raw files)\",2,0,0);\n    ct->setField(\"channels\",\"Set/force the number of channels (required for reading raw files)\",1,0,0);\n    ct->setField(\"outFieldName\", \"Set the name of the output field, containing the pcm data\", \"pcm\");\n    // overwrite cDataSource's default:\n    ct->setField(\"blocksize_sec\", NULL , 1.0);\n    // TODO: check if this default will be used....!!\n  )\n\n  SMILECOMPONENT_MAKEINFO(cWaveSource);\n}\n\nSMILECOMPONENT_CREATE(cWaveSource)\n\n//-----\n\ncWaveSource::cWaveSource(const char *_name) :\n  cDataSource(_name),\n  filehandle(NULL),\n  filename(NULL),\n  //buffersize(2000),\n  pcmDataBegin(0),\n  curReadPos(0),\n  eof(0),\n  monoMixdown(0),\n  properTimestamps_(0)\n{\n  // ...\n}\n\nvoid cWaveSource::fetchConfig()\n{\n  cDataSource::fetchConfig();\n  \n  filename = getStr(\"filename\");\n  SMILE_IDBG(2,\"filename = '%s'\",filename);\n  if (filename == NULL) COMP_ERR(\"fetchConfig: getStr(filename) returned NULL! missing option in config file?\");\n\n  /*\n  buffersize = getInt(\"buffersize\");\n  if (buffersize < 1) buffersize=1;\n  SMILE_DBG(2,\"buffersize = %i\",buffersize);\n*/\n\n  monoMixdown = getInt(\"monoMixdown\");\n  if (monoMixdown) { SMILE_IDBG(2,\"monoMixdown enabled!\"); }\n\n  start = getDouble(\"start\");\n  endrel = getDouble(\"endrel\");\n  end = getDouble(\"end\");\n\n  outFieldName = getStr(\"outFieldName\");\n\n  if(outFieldName == NULL) COMP_ERR(\"fetchConfig: getStr(outFieldName) returned NULL! missing option in config file?\");\n\n  properTimestamps_ = getInt(\"properTimestamps\");\n}\n\nint cWaveSource::configureWriter(sDmLevelConfig &c)\n{\n  negativestart = 0;\n  int ret = 0;\n\n  int noHeader = getInt(\"noHeader\");\n\n  if (!noHeader) { \n    ret = readWaveHeader();\n    if (ret == 0) COMP_ERR(\"failed reading wave header from file '%s'! Maybe this is not a WAVE file?\",filename);\n  } else { \n    fseek( filehandle, 0, SEEK_END );\n    size_t filesize = ftell(filehandle);\n    rewind(filehandle);\n\n    pcmParam.sampleRate = getInt(\"sampleRate\");\n    pcmParam.nChan = getInt(\"channels\");\n    pcmParam.nBPS = getInt(\"sampleSize\");\n    pcmParam.nBits = pcmParam.nBPS*8;\n    pcmParam.blockSize = pcmParam.nChan * pcmParam.nBPS;\n    pcmParam.nBlocks = (long)(filesize / pcmParam.blockSize);\n    curReadPos = 0;\n    ret = 1;\n  }\n\n  double srate = (double)(pcmParam.sampleRate);\n  if (srate==0.0) srate = 1.0;\n  long flen  = (long)(pcmParam.nBlocks); // file length in samples ///XXXX TODO!\n\n  if (isSet(\"startSamples\")) {\n    startSamples = getInt(\"startSamples\");\n  } else {\n    SMILE_DBG(2,\"start = %f\",start);\n    startSamples = (long)floor(start * srate);\n  }\n  if (startSamples < 0)\n  {\n\t  negativestart = 1;\n\t  negstartoffset = -startSamples;\n  }\n  if (startSamples > flen) startSamples = flen;///XXXX TODO!\n  SMILE_DBG(2,\"startSamples = %i\",startSamples);\n\n  if (isSet(\"endSamples\")) {\n    endSamples = getInt(\"endSamples\");\n  } else {\n    if (end < 0.0) endSamples = -1; ///XXXX TODO!\n    else endSamples = (long)ceil(end * srate); ///XXXX TODO!\n  }\n\n  if (endSamples < 0) {\n    if (isSet(\"endrelSamples\")) {\n      endrelSamples = getInt(\"endrelSamples\");\n      if (endrelSamples < 0) endrelSamples = 0;\n      SMILE_DBG(2,\"endrelSamples = %i\",endrelSamples);\n      endSamples = flen-endrelSamples; ///XXXX TODO!\n      if (endSamples < 0) endSamples = 0;\n    } else {\n      if (isSet(\"endrel\")) {\n        endSamples = flen - (long)floor(endrel * srate); ///XXXX TODO!\n        if (endSamples < 0) endSamples = 0;\n      } else {\n        endSamples = flen; ///XXXX TODO!\n      }\n    }\n  }\n  if (endSamples > flen) endSamples = flen; ///XXXX TODO!\n  SMILE_DBG(2,\"endSamples = %i\",endSamples);\n\n  if (startSamples > 0) { // seek to start pos!\n    curReadPos = startSamples;\n    fseek( filehandle, curReadPos*pcmParam.blockSize, SEEK_CUR ); /* must be: SEEK_CUR ! */\n  }\n\n  // more segments\n  //if (getArraySize(\"start\")) {\n\n\n  //}\n\n\n    // TODO:: AUTO buffersize.. maximum length of wave data to store (depends on config of windower components)\n    // so.. we CAN configure windower components first, which then set a config option in the wave source config..?\n    //    OR central config unit apart from the configManager? (only for internal config?)\n    // the windower comps. must set the buffersize info during their fetchCOnfig phase (i.e. BEFORE configure instance phase)\n  c.T = 1.0 / (double)(pcmParam.sampleRate);\n  //writer->setConfig(1,2*buffersize,T, 0.0, 0.0 , 0, DMEM_FLOAT);  // lenSec = (double)(2*buffersize)*T\n  //c.basePeriod = c.T; // <- this is handled by dataSource already\n  // TODO : blocksize...\n\n  return 1;\n}\n\nint cWaveSource::myConfigureInstance()\n{\n  // open wave file.... etc. get header, etc.\n  if (filehandle == NULL) {\n    filehandle = fopen(filename, \"rb\");\n    if (filehandle == NULL) COMP_ERR(\"failed to open input file '%s'\",filename);\n  }\n\n  int ret = cDataSource::myConfigureInstance();\n  \n  if (!ret) {\n    fclose(filehandle); filehandle = NULL;\n  }\n  return ret;\n}\n\nint cWaveSource::setupNewNames(long nEl) \n{\n  // configure dataMemory level, names, etc.\n  if (monoMixdown) {\n    writer_->addField(outFieldName,1);\n    //allocMat(1, blocksizeW_);\n  } else {\n    writer_->addField(outFieldName,pcmParam.nChan);\n    //allocMat(pcmParam.nChan, blocksizeW_);\n  }\n\n  namesAreSet_ = 1;\n  return 1;\n}\n\n/*\nint cWaveSource::myFinaliseInstance()\n{\n \n  return cDataSource::myFinaliseInstance();\n}\n*/\n\nint cWaveSource::myTick(long long t)\n{\n  if (isEOI()) {\n    // Check if we successfully reached the end of the current segment,\n    // or if processing got interrupted at a different point.\n    // If so, give an error:\n    if (!eof) {\n      SMILE_IERR(1, \"Processing aborted before all data was read from the input wave file! There must be something wrong with your config, e.g. a dataReader blocking a dataMemory level. Look for level full error messages in the debug mode output!\");\n    }\n    return 0;\n  }\n  if (mat_ == NULL) {\n    if (monoMixdown) allocMat(1, blocksizeW_);\n    else allocMat(pcmParam.nChan, blocksizeW_);\n  }\n  while (negativestart == 1) {\n    if (negstartoffset >= blocksizeW_) {\n      if (writer_->checkWrite(negstartoffset)) {\n        writer_->setNextMatrix(mat_);\n      }\n      negstartoffset = negstartoffset - blocksizeW_;\n      SMILE_IMSG(1, \"Negative Start Offset: = %f\", negstartoffset);\n    }\n    if (negstartoffset > 0 && negstartoffset < blocksizeW_) {\n      cMatrix *matout = new cMatrix(mat_->N, negstartoffset, mat_->type);\n      if (writer_->checkWrite(negstartoffset)) {\n        writer_->setNextMatrix(matout);\n      }\n      negstartoffset = negstartoffset - blocksizeW_;\n      SMILE_IMSG(1, \"Negative Start Offset: = %f\", negstartoffset);\n      negativestart = 0;\n    }\n    if (negstartoffset == 0) negativestart = 0;\n  }\n  // TODO: check if there is space in dmLevel for this write...!\n  if (writer_->checkWrite(blocksizeW_)) {\n    if (readData()) { // read new data from wave file!\n      /**/\n      if (properTimestamps_) {\n        // NOTE: this is experimental, seems to work, but is inefficient.\n        // This has to be replaced by the new \"simple\" layers.\n        for (long i = 0; i < mat_->nT; i++) { // <<-- new timestamp assignment, untested!!\n          mat_->tmeta[i].smileTime = (double)(curReadPos - mat_->nT + i) \n                                     / (double)pcmParam.sampleRate;\n        }/**/\n      }\n      if (!writer_->setNextMatrix(mat_)) { // save data in dataMemory buffers\n        SMILE_IERR(1, \"can't write, level full... (strange, level space was checked using checkWrite(bs=%i))\", blocksizeW_);\n      } else {\n        return 1;\n      }\n    }\n  }\n  return 0;\n}\n\n\ncWaveSource::~cWaveSource()\n{\n  if (filehandle != NULL) fclose(filehandle);\n}\n\n//--------------------------------------------------  wave specific\n\n#ifdef HAVE_UNISTD_H\n#include <unistd.h>\n#endif\n\n\n// reads data into matrix m, size is determined by m, also performs format conversion to float samples and matrix format\nint cWaveSource::readData(cMatrix *m)\n{\n  if (eof) {\n    SMILE_WRN(6,\"not reading from file, already EOF\");\n    return 0;\n  }\n  \n  if (m==NULL) {\n    if (mat_ == NULL) {\n      if (monoMixdown) allocMat(1, blocksizeW_);\n      else allocMat(pcmParam.nChan, blocksizeW_);\n    }\n    m=mat_;\n  }\n  if ( (m->N != pcmParam.nChan)&&((!monoMixdown) && (m->N == 1)) ) {\n    SMILE_ERR(1,\"readData: incompatible read! nChan=%i <-> matrix N=%i (these numbers must match!)\\n\",pcmParam.nChan,m->N);\n    return 0;\n  }\n\n  long samplesToRead = m->nT;\n  if (endSamples - curReadPos < blocksizeW_) {\n    samplesToRead = (endSamples - curReadPos);\n  }\n\n  long nChan = 1;\n  if (!monoMixdown) {\n    nChan = pcmParam.nChan;\n  }\n  // check for float data type\n  // if they match, convert with smilePcm_readSamples();\n  long nRead = 0;\n#if FLOAT_DMEM_NUM == FLOAT_DMEM_FLOAT\n  nRead = smilePcm_readSamples(&filehandle, &pcmParam, m->dataF, nChan, samplesToRead, monoMixdown);\n#else\n  // TODO: allocate only once, put variable in class object\n  float * a = (float *)malloc(sizeof(float) * m->nT);\n  nRead = smilePcm_readSamples(&filehandle, &pcmParam, a, nChan, samplesToRead, monoMixdown);\n  // convert to matrix\n  for (long i = 0; i < nRead && i < m->nT; i++) {\n    m->dataF[i] = (FLOAT_DMEM)a[i];\n  }\n  free(a);\n#endif\n  if (nRead != blocksizeW_ || nRead < 0) {\n    SMILE_IWRN(5,\"nRead (%i) < size to read (%i) ==> assuming EOF!\", nRead, blocksizeW_);\n    eof = 1;\n    if (nRead >= 0) {\n      m->nT = nRead;\n    } else {\n      m->nT = 0;\n    }\n  }\n  if (nRead > 0) {\n    curReadPos += nRead;\n  }\n  return (nRead > 0);\n}\n\nint cWaveSource::readWaveHeader()\n{\n  return smilePcm_readWaveHeader(filehandle, &pcmParam, filename);\n}\n\n"
  },
  {
    "path": "src/lld/cens.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: cCens\n\nComputes CENS features from Chroma features.\n\n*/\n\n\n#include <lld/cens.hpp>\n\n#define MODULE \"cCens\"\n\n/*Library:\nsComponentInfo * registerMe(cConfigManager *_confman) {\n  cDataProcessor::registerComponent(_confman);\n}\n*/\n\nSMILECOMPONENT_STATICS(cCens)\n\nSMILECOMPONENT_REGCOMP(cCens)\n{\n  if (_confman == NULL) return NULL;\n  int rA = 0;\n\n  sconfman = _confman;\n  scname = COMPONENT_NAME_CCENS;\n  sdescription = COMPONENT_DESCRIPTION_CCENS;\n\n\n  // we inherit cDataSource configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"nameAppend\",NULL,\"CENS\");\n    ct->setField(\"copyInputName\",NULL,0);\n    ct->setField(\"window\",\"The window function to use for temporal CENS smoothing; one of these: han (Hanning), ham (Hamming), bar (Bartlett)\",\"han\");\n    ct->setField(\"downsampleRatio\",\"The integer ratio at which to downsample the resulting sequence of vectors. I.e. a value of 4 will average 4 frames and output 1 CENS frame.\",10);\n    ct->setField(\"winlength\",\"The length of the CENS smoothing window, in frames.\",41);\n    ct->setField(\"winlength_sec\",\"The length of the CENS smoothing window, in seconds. This will be rounded upwards (ceil) to the closest length in frames. It overrides winlength, if set.\",0.41,0,0);\n    ct->setField(\"l2norm\",\"1/0 = enable/disable normalisation of CENS vectors by their L2-norm.\",1);\n   ) \n\n  SMILECOMPONENT_MAKEINFO(cCens);\n}\n\nSMILECOMPONENT_CREATE(cCens)\n\n//-----\n\ncCens::cCens(const char *_name) :\n  cVectorProcessor(_name),\n    winf(NULL), buffer(NULL), bptr(NULL), dsidx(NULL)\n{\n\n}\n\nvoid cCens::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n  \n  const char *wstr = getStr(\"window\");\n  if (wstr != NULL) {\n    if (!strncmp(wstr,\"han\",3)) {\n      window = WINF_HANNING;\n    } else if (!strncmp(wstr,\"ham\",3)) {\n      window = WINF_HAMMING;\n    } else if (!strncmp(wstr,\"bar\",3)) {\n      window = WINF_BARTLETT;\n    } else  {\n      SMILE_IERR(1,\"invalid window function '%s', see help for valid strings! (case sensitive!); defaulting to Hanning window\",wstr);\n      window = WINF_HANNING;\n    }\n  }\n\n \n  SMILE_IDBG(2,\"window shape = %i\",window);\n\n  l2norm = getInt(\"l2norm\");\n  winlength = getInt(\"winlength\");\n\n  downsampleRatio = getInt(\"downsampleRatio\");\n  SMILE_IDBG(2,\"downsampleRatio = %i\",downsampleRatio);\n\n  if (isSet(\"winlength_sec\")) {\n    double winlength_sec = getDouble(\"winlength_sec\");\n\n    double period = reader_->getLevelT();\n    if (period > 0) {\n      winlength = (long)ceil(winlength_sec / period);\n    } else {\n      winlength = (long)ceil(winlength_sec);\n    }\n  }\n\n  if (downsampleRatio < 1) downsampleRatio=1;\n  if (winlength < 1) winlength=1;\n\n}\n\nint cCens::configureWriter(sDmLevelConfig &c)\n{\n  // adjust output period and effective frame length (downsampling)\n  c.T = c.T * (double)downsampleRatio;\n  c.lastFrameSizeSec = c.frameSizeSec;\n  c.frameSizeSec = c.frameSizeSec * (double)downsampleRatio;\n  return 1;\n}\n\nint cCens::setupNamesForField(int i, const char*name, long nEl)\n{\n  if (winf == NULL) winf = (double**)multiConfAlloc();\n  if (buffer == NULL) buffer = (FLOAT_DMEM**)multiConfAlloc();\n  if (bptr == NULL) bptr = multiConfAllocLong();\n  if (dsidx == NULL) dsidx = multiConfAllocLong();\n\n  if (window == WINF_HANNING) {\n    winf[i] = smileDsp_winHan(winlength);\n  } else if (window == WINF_HAMMING) {\n    winf[i] = smileDsp_winHam(winlength);\n  } else if (window == WINF_BARTLETT) {\n    winf[i] = smileDsp_winBar(winlength);\n  } else { // .... should not happen...\n    COMP_ERR(\"invalid window function... (%i) !\",window);\n  }\n\n  buffer[i] = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*(winlength+1)*nEl);\n  bptr[i] = 1; dsidx[i] = 0;\n\n  return cVectorProcessor::setupNamesForField(i,name,nEl);\n}\n\nvoid cCens::chromaDiscretise(const FLOAT_DMEM *in, FLOAT_DMEM *out, long N)\n{\n  int i;\n  for (i = 0;i < N; i++) {\n    if (in[i] >= 0.4) out[i] = 4.0;\n    else if ( (in[i] >= 0.2)&&(in[i]<0.4) ) out[i] = 3.0;\n    else if ( (in[i] >= 0.1)&&(in[i]<0.2) ) out[i] = 2.0;\n    else if ( (in[i] >= 0.05)&&(in[i]<0.1) ) out[i] = 1.0;\n    else out[i] = 0.0;\n  }\n}\n\n// a derived class should override this method, in order to implement the actual processing\nint cCens::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  // manage internal history for reasons of simplicity (we could get it from the dataMemory too, but then we would have to take care of multiple fields (i.e. this class must be a dataProcessor), and of the correct input level buffersize!\n  FLOAT_DMEM *_buf = buffer[idxi];  \n  double *_win = winf[idxi];  \n  long bp = bptr[idxi];\n  // A note on the buffer: the first frame  (index 0) is reserved for the temporary frame\n  // thus, the ring buffer indicies start at frame index 1 to winlength (not winlength-1)\n\n  int i,j;\n  double sum = 0.0;\n  \n  // quantise chroma vector:\n  chromaDiscretise(src,dst,MIN(Nsrc,Ndst));\n\n  // store in buffer at pointer position\n  for (i=0; i<MIN(Nsrc,Ndst); i++) {\n    _buf[bp*Nsrc+i] = dst[i];\n  }\n  \n  // manage ring-buffer index\n  bptr[idxi]++;\n  if (bptr[idxi] > winlength) bptr[idxi] = 1;\n  //bptr[idxi] = (bptr[idxi]+1)%winlength;\n  \n  // downsample\n  if ((dsidx[idxi]%downsampleRatio)==0) {\n    // convole with window ...\n    for (i = 0; i < MIN(Nsrc,Ndst); i++) {\r\n      _buf[i] = 0.0;\r\n      for (j = 0; j < winlength; j++) {\r\n        long bpj = bp-j;\r\n        if (bpj < 1) bpj+=winlength;\r\n        _buf[i] += _buf[bpj*Nsrc+i] * (FLOAT_DMEM)_win[j];\r\n      }\r\n    }\r\n\n    // normalise with L2 norm\n    if (l2norm) {\n      // compute norm\n      double n = 0.0;\n      for (i = 0; i < MIN(Nsrc,Ndst); i++) {\n        n += (double)_buf[i] * (double)_buf[i];\n      }\n      // normalise or assign normalised unit vector in case the norm is 0\n      if (n > 0.0) {\n        n = sqrt(n);\n        for (i = 0; i < MIN(Nsrc,Ndst); i++) {\n          dst[i] = _buf[i] / (FLOAT_DMEM)n;\n        }\n      } else {\n        FLOAT_DMEM uv = (FLOAT_DMEM)(1.0 / sqrt((FLOAT_DMEM)(MIN(Nsrc,Ndst))));\n        for (i = 0; i < MIN(Nsrc,Ndst); i++) {\n          dst[i] = uv;\n        }\n      }\n\n    } else {\n\n      // save as output:\n      for (i = 0; i < MIN(Nsrc,Ndst); i++) {\n        dst[i] = _buf[i];\n      }\n\n    }\n\n    return 1; // write output data\n  } \n  \n  return 0; // do not write output data!\n}\n\ncCens::~cCens()\n{\n  multiConfFree1D(bptr);\n  multiConfFree1D(dsidx);\n  multiConfFree(buffer);\n  multiConfFree(winf);\n}\n"
  },
  {
    "path": "src/lld/chroma.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: cChroma\n\nComponent to compute chroma features from a semi-tone spectrum. \n\nThis component is based on original code from Moritz Dausinger (wave2chroma). \nThe openSMILE chroma component was implemented by Christoph Kozielski.\n\n*/\n\n\n#include <lld/chroma.hpp>\n\n#define MODULE \"cChroma\"\n\n/*Library:\nsComponentInfo * registerMe(cConfigManager *_confman) {\n  cDataProcessor::registerComponent(_confman);\n}\n*/\n\nSMILECOMPONENT_STATICS(cChroma)\n\nSMILECOMPONENT_REGCOMP(cChroma)\n{\n  if (_confman == NULL) return NULL;\n  int rA = 0;\n\n  sconfman = _confman;\n  scname = COMPONENT_NAME_CCHROMA;\n  sdescription = COMPONENT_DESCRIPTION_CCHROMA;\n\n  // we inherit cVectorProcessor configType and extend it:\n  ConfigType *ct = new ConfigType( *(sconfman->getTypeObj(\"cVectorProcessor\")) , scname );\n  if (ct == NULL) {\n    SMILE_WRN(4,\"cVectorProcessor config Type not found!\");\n    rA=1;\n  }\n  if (rA==0) {\n    ct->setField(\"nameAppend\",NULL,\"chroma\");\n    ct->setField(\"copyInputName\",NULL,0);\n    ct->setField(\"octaveSize\",\"The size of an octave, i.e. the number of output bins, or the interval to which the input bins are mapped via warping.\",12);\n    ct->setField(\"silThresh\",\"Chroma 'floor', i.e. silence threshold. If at least on element of the (unnormalised) chroma vector falls below the threshold, the vector will not be normalised, and a 0 vector will be output instead.\",0.001); // chroma toolbox uses 0.001 ?\n    ConfigInstance *Tdflt = new ConfigInstance( scname, ct, 1 );\n    sconfman->registerType(Tdflt);\n  } \n\n  SMILECOMPONENT_MAKEINFO(cChroma);\n}\n\nSMILECOMPONENT_CREATE(cChroma)\n\n//-----\n\ncChroma::cChroma(const char *_name) :\n  cVectorProcessor(_name), silThresh(0.0)\n{\n\n}\n\nvoid cChroma::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n  \n  silThresh = (FLOAT_DMEM)getDouble(\"silThresh\");\n\n  octaveSize = getInt(\"octaveSize\");\n  SMILE_IDBG(2,\"octaveSize = %i\",octaveSize);\n}\n\n\nint cChroma::setupNamesForField(int i, const char*name, long nEl)\n{\n  return cVectorProcessor::setupNamesForField(i,name,octaveSize);\n}\n\n\n\n// a derived class should override this method, in order to implement the actual processing\nint cChroma::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n// input: power of tonespec...!\n\n  int i,j;\n  double sum = 0.0;\n  int silFlag = 0;\n  \n  nOctaves = Nsrc / octaveSize;\n  if (Nsrc % octaveSize == 0) {\n    for (i = 0;i < octaveSize; i++) {\n      dst[i] = 0.0;\n      for (j = 0;j < nOctaves; j++) {\n        dst[i] += src[j * octaveSize + i];\n      }\n      //sum += (dst[i]*dst[i]); // <- old pre 1.0.0 code\n      if (dst[i] < silThresh) silFlag = 1;\n      sum += (double)dst[i];\n    }\n    if ((sum != 0.0)&&(!silFlag)) {\n      //double power = sqrt(sum);  // <- old pre 1.0.0 code\n      for (i = 0;i < octaveSize; i++)\n        dst[i] = dst[i] / (FLOAT_DMEM)sum;\n        //dst[i] = dst[i] / (FLOAT_DMEM)power;  // <- old pre 1.0.0 code\n    } else {\n      for (i = 0;i < octaveSize; i++) dst[i] = 0.0;\n    }\n  } else {\n    SMILE_IERR(1,\"cannot compute Chroma features from an input frame with a size (%i) no an integer multiple of 'octaveSize' (%i)! Check your tonespec configuration!\",Nsrc,octaveSize);\n  }\n\n  return 1;\n}\n\ncChroma::~cChroma()\n{\n}\n"
  },
  {
    "path": "src/lld/formantLpc.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nThis component computes Formant canditates and their bandwidths from LPC coefficients\n\nNote: you must downsample the signal to max formant frequency prior to LPC for best results\n      use Burg's LPC method (? is the result different from autocorr method ?)\n\n      use 50ms frames with gaussian window and 0.97 pre/de (?) emphasis\n\n*/\n\n\n#include <lld/formantLpc.hpp>\n#include <math.h>\n#include <smileutil/zerosolve.h>\n\n#define MODULE \"cFormantLpc\"\n\nSMILECOMPONENT_STATICS(cFormantLpc)\n\nSMILECOMPONENT_REGCOMP(cFormantLpc)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CFORMANTLPC;\n  sdescription = COMPONENT_DESCRIPTION_CFORMANTLPC;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"nFormants\",\"The maximum number of formants to detect (set to < 0 to automatically detect the maximum number of possible formants (nLpcCoeff - 1)\",-1);  \n    ct->setField(\"saveFormants\",\"If set to 1, output formant frequencies [field name: formantFreqLpc]\",1);  \n    ct->setField(\"saveIntensity\",\"If set to 1, output formant frame intensity [field name: formantFrameIntensity]\",0);  \n    ct->setField(\"saveNumberOfValidFormants\",\"If set to 1, output the number of valid formants [field name: nFormants]\",0);  \n    ct->setField(\"saveBandwidths\",\"If set to 1, output formant bandwidths [field name: formantBandwidthLpc]\",0);\n    ct->setField(\"minF\",\"The minimum of the formant frequency search range\",50.0);\n    ct->setField(\"maxF\",\"The maximum detectable formant frequency\",5500.0);\n    ct->setField(\"useLpSpec\",\"Experimental option: If set to 1, computes the formants from peaks found in the 'lpSpectrum' field instead of root solving the lpc coefficient polynomial\",0);\n    ct->setField(\"medianFilter\",\"1 = enable formant post processing by a median filter of length 'medianFilter' (recommended: 5) (will be rounded up to the next odd number); 0 to disable median filter.\",0);\n    ct->setField(\"octaveCorrection\",\"Experimental option: 1 = prevent formant octave jumps (esp. when medianFilter is enabled) by employing simple 'octave' correction. 0 = no correction.\",0);\n\n    //ct->setField(\"margin\",\"minimum formant frequency\",50.0);\n    ct->setField(\"processArrayFields\",NULL,0);\n  )\n  SMILECOMPONENT_MAKEINFO(cFormantLpc);\n}\n\nSMILECOMPONENT_CREATE(cFormantLpc)\n\n//-----\n\ncFormantLpc::cFormantLpc(const char *_name) :\n  cVectorProcessor(_name),\n    roots(NULL), lpc(NULL),\n    formant(NULL), bandwidth(NULL),\n    nSmooth(5)\n{\n\n}\n\nvoid cFormantLpc::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n\n  maxF=getDouble(\"maxF\");\n  SMILE_IDBG(2,\"maxF = %f\",maxF); \n\n  minF=getDouble(\"minF\");\n  SMILE_IDBG(2,\"minF = %f\",minF); \n\n  nFormants=getInt(\"nFormants\");\n  SMILE_IDBG(2,\"nFormants = %i\",nFormants); \n\n  saveNumberOfValidFormants=getInt(\"saveNumberOfValidFormants\");\n  SMILE_IDBG(2,\"saveNumberOfValidFormants = %i\",saveNumberOfValidFormants); \n\n  saveFormants=getInt(\"saveFormants\");\n  SMILE_IDBG(2,\"saveFormants = %i\",saveFormants); \n\n  saveBandwidths=getInt(\"saveBandwidths\");\n  SMILE_IDBG(2,\"saveBandwidths = %i\",saveBandwidths); \n\n  saveIntensity=getInt(\"saveIntensity\");\n  SMILE_IDBG(2,\"saveIntensity = %i\",saveIntensity); \n\n  useLpSpec=getInt(\"useLpSpec\");\n  SMILE_IDBG(2,\"useLpSpec = %i\",useLpSpec); \n\n  medianFilter=getInt(\"medianFilter\");\n\n  octaveCorrection=getInt(\"octaveCorrection\");\n  SMILE_IDBG(2,\"octaveCorrection = %i\",octaveCorrection); \n\n  if (medianFilter > 1) {\n    nSmooth = medianFilter;\n    if ((nSmooth & 1) == 0) nSmooth++;\n    SMILE_IDBG(2,\"medianFilter = %i\",nSmooth); \n  }\n  \n\n}\n\n/* setup output vector */\n//int cFormantLpc::setupNamesForField(int i, const char*name, long nEl)\nint cFormantLpc::setupNewNames(long nEl)\n{\n  int n=0;\n\n  findInputFields();\n\n  if (saveIntensity) {\n    writer_->addField(\"formantFrameIntensity\", 1);\n    n+=1;\n  }\n  if (saveNumberOfValidFormants) {\n    writer_->addField( \"nFormants\", 1 );\n    n += 1;\n  }\n  if (saveFormants) {\n    writer_->addField( \"formantFreqLpc\", nFormants, 1);\n    n += nFormants;\n  }\n  if (saveBandwidths) {\n    writer_->addField( \"formantBandwidthLpc\", nFormants, 1);\n    n += nFormants;\n  }\n\n  const sDmLevelConfig *c = reader_->getLevelConfig();\n  T = (double)(c->basePeriod);\n\n  namesAreSet_=1;\n  return n;\n}\n\nvoid cFormantLpc::findInputFields()\n{\n  const FrameMetaInfo * fmeta = reader_->getFrameMetaInfo();\n\n  lpcCoeffIdx = fmeta->findFieldByPartialName( \"lpcCoeff\" ); \n  if (lpcCoeffIdx < 0) { \n    lpcCoeffIdx = 0; // default : fallbak to 0th field\n    SMILE_IWRN(1,\"no 'lpcCoeff' field found in input (this is required!). Using 0th field by default!!\");\n  } \n  nLpc = fmeta->field[lpcCoeffIdx].N;\n  // convert field index to element index (as found in vector later..)\n  lpcCoeffIdx = fmeta->fieldToElementIdx( lpcCoeffIdx );\n\n  if (lpcCoeffIdx < 0) {\n    SMILE_IERR(1,\"unknown error while converting field index (lpcCoeff) to element index (return value: %i)\",lpcCoeffIdx); \n    lpcCoeffIdx = 0;\n  }\n\n  if (nFormants > nLpc-1) {\n    SMILE_IERR(1,\"nFormants > nLpcCoeffs-1 , this is not feasible! Setting nFormants = nLpc-1 (%i).\",nLpc-1);\n    nFormants = nLpc-1;\n  }\n\n  if (nFormants <= 0) {  // auto determine nFormants from number of input lpc coefficients\n    nFormants = nLpc-1;\n  }\n\n  lpcGainIdx = fmeta->findFieldByPartialName( \"lpGain\" );\n  if (lpcGainIdx < 0) {\n    if (saveIntensity) SMILE_IERR(1,\"lpGain not found as input field, cannot compute formant frame intensity, disabling it now!\");\n    saveIntensity = 0;\n  }\n  lpcGainIdx = fmeta->fieldToElementIdx( lpcGainIdx );\n\n  if (useLpSpec) {\n    lpSpecIdx = findField(\"lpSpectrum\", 0, &lpSpecN);\n  }\n}\n\n\nint cFormantLpc::processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi)\n{\n  // not yet implemented\n  return 0;\n}\n\n\nint cFormantLpc::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  long i,j;\n  if (lpc == NULL) lpc = (double*)malloc(sizeof(double)*(nLpc+1));\n  if (roots == NULL) roots = (double*)malloc(sizeof(double)*(nLpc)*2);\n  if (formant == NULL) {\n    formant = (double*)calloc(1, sizeof(double)*(nFormants)*(nSmooth+1));\n  }\n  if (saveBandwidths && (bandwidth == NULL)) {\n    bandwidth = (double*)calloc(1, sizeof(double)*(nFormants)*(nSmooth+1));\n  }\n\n  if (lpcCoeffIdx + nLpc > Nsrc) {\n    SMILE_IERR(1,\"lpcCoeffIdx (%i) + #lpc (%i) > Nsrc (%i) ! \",lpcCoeffIdx,nLpc,Nsrc);\n    nLpc = Nsrc - lpcCoeffIdx;\n  }\n  // get lpc gain, if present:\n  double gain = -1.0;\n  if (lpcGainIdx >= 0) {\n    gain = src[lpcGainIdx];\n    //printf(\"gain : %f idx %i %i\\n\",gain,lpcGainIdx,lpcCoeffIdx);\n  }\n\n  int nValidF=0;\n\n  if (useLpSpec) { /* formant computation by peak picking in lp spectrum and interpolation */\n    if (lpSpecIdx >= 0) {\n      const FLOAT_DMEM *ls = src+lpSpecIdx;\n      int f = 0;\n      //double lastMin = -1.0;\n      for (i=0; i<nFormants; i++) {\n        formant[i] = 0.0;\n        if (bandwidth != NULL) bandwidth[i] = 0.0;\n      }\n\n      double deltaIf;\n      if (T > 0.0) deltaIf = 1.0/(T*lpSpecN*2.0);\n      else {\n        SMILE_IERR(1,\"T <= 0.0 ! cannot compute lpSpectrum frequencies, formant frequencies will be incorrect!\");\n        deltaIf = 1.0;\n      }\n      for (i=2; i<lpSpecN-2; i++) { // find lp spectrum peaks\n        if ( (ls[i-1] < ls[i])&&(ls[i]>ls[i+1]) ) { // max:\n          // interpolate peak (quadratic):\n          double x1 = deltaIf*(double)(i-1); \n          double x2 = deltaIf*(double)(i);\n          double x3 = deltaIf*(double)(i+1);\n          double yE=0.0; double aQ=0.0;\n          double pk = smileMath_quadFrom3pts(x1, ls[i-1], x2, ls[i], x3, ls[i+1], &yE, &aQ);\n          if ( (pk >= minF) && (pk <= maxF) && (aQ < 0) && (f<nFormants) ) {\n            formant[f] = pk;\n            if (bandwidth != NULL) {\n              // compute bandwidth from parameter a:\n              bandwidth[f] = 2.0 * ( pk + sqrt((yE/sqrt(2.0) - yE)/aQ) );\n            }\n            f++;\n          }\n        } \n      }\n      nValidF = f;\n    } else { \n      SMILE_IERR(1,\"lpSpecIdx < 0 ! no input defined!\");\n      return 0; \n    }\n\n  \n  } else { /*  formant computation from roots of lpc polynomial  */\n\n\n    // copy lpc coefficients (inverse order) : lpc coefficients -> polynomial coefficients\n    for (i=0; i<nLpc; i++) {\n      lpc[i] = -src[lpcCoeffIdx+nLpc-i-1]; // lpcCoeffIdx+i\n      //printf(\"lpcpoly[%i]=%f\\n\",i,lpc[i]);\n    }\n    lpc[nLpc] = 1.0; // first coefficient is always one\n\n    // get roots (0s) of lpc polynomial\n    sZerosolverPolynomialComplexWs * ws = zerosolverPolynomialComplexWorkspaceAllocate(nLpc+1);\n    zerosolverPolynomialComplexSolve(lpc, nLpc+1, ws, roots);\n    zerosolverPolynomialComplexWorkspaceFree(ws);\n\n    // fix roots to inside the unit circle\n    smileMath_complexIntoUnitCircle(roots,nLpc);\n\n    // compute formants and bandwidths from roots\n    //for (i=0; i<(nLpc)*2; i+=2) {\n      //printf(\"T %f root[%i]=%f + i * %f\\n\",T,i/2,roots[i],roots[i+1]);\n    //}\n    nValidF = smileDsp_lpcrootsToFormants(roots, nLpc, formant, bandwidth, nFormants, T, minF, maxF);\n\n    // sort formants and bandwidths in formant frequency ascending order:\n    int nFnon0 = 0;\n    for (i=0; i<nFormants; i++) {\n      if (formant[i] == 0.0) break;\n    }\n    nFnon0 = i;\n    for (i=0; i<nFnon0; i++) {\n      for (j=i+1; j<nFnon0; j++) {\n        if (formant[j] < formant[i]) { // swap\n          double f = formant[j];\n          formant[j] = formant[i];\n          formant[i] = f;\n          if (bandwidth != NULL) {\n            double b = bandwidth[j];\n            bandwidth[j] = bandwidth[i];\n            bandwidth[i] = b;\n          }\n        }\n      }\n    }\n\n  }\n\n\n  if (saveFormants) {\n\n    // TODO: correct consideration of bandwidths when sorting for median and when swapping!!\n\n    if (octaveCorrection) {\n      // formant octave correction:\n      for (i=0; i<nFormants-1; i++) {\n        // formant[nFormants+i]; formant[2*nFormants+i];\n        if ( fabs((formant[nFormants+i+1] / formant[2*nFormants+i])-1.0) < 0.2 ) {\n          formant[i+1] = formant[nFormants+i+1] = formant[2*nFormants+i+1]; // use previous value\n        }\n        if ( fabs((formant[nFormants+i] / formant[2*nFormants+i+1])-1.0) < 0.2 ) {\n          formant[i] = formant[nFormants+i] = formant[2*nFormants+i]; // use previous value\n        }\n      }\n    }\n\n    if (medianFilter) {\n      // formant median smoothing:\n      double * tmp = new double[nSmooth];\n      for (i = 0; i < nSmooth; i++) {\n        tmp[i] = 0.0;\n      }\n      for (i=0; i<nFormants; i++) {\n        double min=formant[i+nFormants];\n        double max=formant[i+nFormants]; \n        tmp[0] = formant[i+nFormants];\n        for (j=2; j<nSmooth; j++) {\n          if (formant[j*nFormants+i] > max) max = formant[j*nFormants+i];\n          else if (formant[j*nFormants+i] < min) min = formant[j*nFormants+i];\n          tmp[j-1] = formant[j*nFormants+i];\n        }\n        if ((min>0.0)) { // octave jump -> median smoothing\n          smileUtil_quickSort_double(tmp,nSmooth);\n          formant[i] = tmp[nSmooth/2];\n        }\n      }\n      delete[] tmp;\n    }\n\n    if (octaveCorrection || medianFilter) {\n      // copy current formant/bandwidth to last\n      for (i=0; i<nFormants; i++) {\n        for (j=nSmooth-1; j>0; j--) {\n          formant[j*nFormants+i] = formant[(j-1)*nFormants+i];\n          if (bandwidth != NULL) bandwidth[j*nFormants+i] = bandwidth[(j-1)*nFormants+i];\n        }\n      }\n    }\n\n\n\n  }\n\n  // copy the result to the output vector:\n  int n = 0;\n\n  if (saveIntensity) {\n    dst[n++] = (FLOAT_DMEM)gain;\n  }\n\n  if (saveNumberOfValidFormants) {\n    dst[n++] = (FLOAT_DMEM)nValidF;\n  }\n  if (saveFormants) {\n    for (i=0; i<nFormants; i++) {\n      dst[n++] = (FLOAT_DMEM)(formant[i]);\n      //if (bandwidth != NULL) printf(\"formant[%i]=%f  (bw %f)\\n\",i,(FLOAT_DMEM)(formant[i]),bandwidth[i]);\n      //else printf(\"formant[%i]=%f \\n\",i,(FLOAT_DMEM)(formant[i]));\n    }\n  }\n  if (saveBandwidths) {\n    for (i=0; i<nFormants; i++) {\n      dst[n++] = (FLOAT_DMEM)(bandwidth[i]);\n    }\n  }\n\n  return n;\n}\n\n\ncFormantLpc::~cFormantLpc()\n{\n  if (lpc != NULL) free(lpc);\n  if (roots != NULL) free(roots);\n  if (formant != NULL) free(formant);\n  if (bandwidth != NULL) free(bandwidth);\n}\n\n\n/* NEXT: an integrated formant component... */\n\n"
  },
  {
    "path": "src/lld/formantSmoother.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\n\n*/\n\n\n\n#include <lld/formantSmoother.hpp>\n\n#define MODULE \"cFormantSmoother\"\n\n\nSMILECOMPONENT_STATICS(cFormantSmoother)\n\nSMILECOMPONENT_REGCOMP(cFormantSmoother)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CFORMANTSMOOTHER;\n  sdescription = COMPONENT_DESCRIPTION_CFORMANTSMOOTHER;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n\n  // if the inherited config type was found, we register our configuration variables\n  SMILECOMPONENT_IFNOTREGAGAIN( {} // <- this is only to avoid compiler warnings...\n    // name append has a special role: it is defined in cDataProcessor, and can be overwritten here:\n\t  // if you set description to NULL, the existing description will be used, thus the following call can\n  \t// be used to update the default value:\n    //ct->setField(\"nameAppend\",NULL,\"processed\");\n\n    ct->setField(\"medianFilter0\",\"If > 0, applies median filtering of candidates as the FIRST processing step; the filter length is the value of 'medianFilter0' if > 0\",0);\n    ct->setField(\"postSmoothing\",\"If > 0, applies post processing (median and spike remover) over 'postSmoothing' frames (0=no smoothing or use default set by postSmoothingMethod)\",0);\n    ct->setField(\"postSmoothingMethod\",\"The post processing method to use. One of the following:\\n   'none' disable post smoothing\\n   'simple' simple post smoothing using only 1 frame delay (will smooth out 1 frame octave spikes)\\n   'median' will apply a median filter to the output values (length = value of 'postProcessing')\",\"simple\");\n    //ct->setField(\"octaveCorrection\",\"enable intelligent cross candidate octave correction\",1);\n    \n    ct->setField(\"F0field\",\"The input field containing either F0final or voicingFinalClipped (i.e. a field who's value is 0 for unvoiced frames and != 0 otherwise), (the name you give here is a partial name, i.e. the actual field names will be matched against *'F0field'*). Note: do not use the *Env (envelope) fields here, they are != 0 for unvoiced frames!\",\"F0final\");\n    ct->setField(\"formantBandwidthField\",\"The input field containing formant bandwidths (the name you give here is a partial name, i.e. the actual field names will be matched against *formantBandwidthField*)\",\"formantBand\");\n    ct->setField(\"formantFreqField\",\"The input field containing formant frequencies (the name you give here is a partial name, i.e. the actual field names will be matched against *formantFreqField*)\",\"formantFreq\");\n    ct->setField(\"formantFrameIntensField\",\"The input field containing formant frame intensity (the name you give here is a partial name, i.e. the actual field names will be matched against *formantFrameIntensField*)\",\"formantFrameIntens\");\n\n    // new data\n    ct->setField(\"intensity\",\"If set to 1, output formant intensity\",0);\n    ct->setField(\"nFormants\",\"This sets the maximum number of smoothed formants to output (set to 0 to disable the output of formants and bandwidths)\",5);\n    ct->setField(\"formants\",\"If set to 1, output formant frequencies (also see 'nFormants' option)\",1);\n    ct->setField(\"bandwidths\",\"If set to 1, output formant bandwidths (also see 'nFormants' option)\",0);\n    ct->setField(\"saveEnvs\",\"If set to 1, output formant frequency and bandwidth envelopes instead(!) of the actual data (i.e. the last value of a voiced frame is used for the following unvoiced frames).\",0);\n    ct->setField(\"no0f0\",\"'no zero F0': if set to 1, output data only when F0>0, i.e. a voiced frame is detected. This may cause problem with some functionals and framer components, which don't support this variable length data yet...\",0);\n\n    \n    ct->setField(\"processArrayFields\",NULL,0);\n  )\n\n  // The configType gets automatically registered with the config manger by the SMILECOMPONENT_IFNOTREGAGAIN macro\n  \n  // we now create out sComponentInfo, including name, description, success status, etc. and return that\n  SMILECOMPONENT_MAKEINFO(cFormantSmoother);\n}\n\nSMILECOMPONENT_CREATE(cFormantSmoother)\n\n//-----\n\ncFormantSmoother::cFormantSmoother(const char *_name) :\n  cVectorProcessor(_name),\n    median0WorkspaceF0cand(NULL), lastFinal(NULL), nFormantsIn(-1),\n    fbin(NULL), fbinLastVoiced(NULL)\n{\n\n}\n\nvoid cFormantSmoother::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n\n  medianFilter0 = getInt(\"medianFilter0\");\n  SMILE_IDBG(2,\"medianFilter0 = %i\",medianFilter0);\n\n  postSmoothing = getInt(\"postSmoothing\");\n  const char * postSmoothingMethodStr = getStr(\"postSmoothingMethod\");\n  if (!strncasecmp(postSmoothingMethodStr,\"none\",4)) {\n    postSmoothingMethod = FPOSTSMOOTHING_NONE;\n    postSmoothing = 0;\n  } else if (!strncasecmp(postSmoothingMethodStr,\"simp\",4)) {\n    postSmoothingMethod = FPOSTSMOOTHING_SIMPLE;\n    postSmoothing = 1;\n  } else if (!strncasecmp(postSmoothingMethodStr,\"medi\",4)) {\n    postSmoothingMethod = FPOSTSMOOTHING_MEDIAN;\n    if (postSmoothing < 2) postSmoothing = 2; \n  } else {\n    SMILE_IERR(1,\"unknown post smoothing method '%s'\",postSmoothingMethodStr);\n    postSmoothingMethod = FPOSTSMOOTHING_NONE;\n  }\n  SMILE_IDBG(2,\"postSmoothing = %i\",postSmoothing);\n  \n  //octaveCorrection = getInt(\"octaveCorrection\");\n  //SMILE_IDBG(2,\"octaveCorrection = %i\",octaveCorrection);\n\n  formants = getInt(\"formants\");\n  SMILE_IDBG(2,\"formants = %i\",formants);\n\n  nFormants = getInt(\"nFormants\");\n  SMILE_IDBG(2,\"nFormants = %i\",nFormants);\n  bandwidths = getInt(\"bandwidths\");\n  SMILE_IDBG(2,\"bandwidths = %i\",bandwidths);\n  intensity = getInt(\"intensity\");\n  SMILE_IDBG(2,\"intensity = %i\",intensity);\n  saveEnvs = getInt(\"saveEnvs\");\n  SMILE_IDBG(2,\"saveEnvs = %i\",saveEnvs);\n\n  no0f0 = getInt(\"no0f0\");\n  SMILE_IDBG(2,\"no0f0 = %i (not yet well supported)\",no0f0);\n\n  if ((postSmoothing>0)&&(nFormants>0)) {\n   lastFinal = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*postSmoothing*nFormants);\n  }\n\n}\n\n\nint cFormantSmoother::setupNewNames(long nEl)\n{\n  int n=0;\n    //TODO: usw addNameAppendField to preserve base name\n  // final (smoothed) output\n  if (intensity) { writer_->addField(\"formantFrameIntensity\", 1); n++; } \n  if (nFormants > 0) {\n    if (saveEnvs) {\n      if (formants) { writer_->addField(\"formantFinFreqEnv\", nFormants); n += nFormants; } \n      if (bandwidths) { writer_->addField(\"formantFinBWEnv\", nFormants); n += nFormants; } \n    } else {\n      if (formants) { writer_->addField(\"formantFinalFreq\", nFormants); n += nFormants; } \n      if (bandwidths) { writer_->addField(\"formantFinalBW\", nFormants); n += nFormants; } \n    }\n  }\n\n\n  const char *field = getStr(\"F0field\");\n  long idx = findField(field, 0);\n  if (idx >= 0) { F0fieldIdx = idx; }\n  else { \n    SMILE_IERR(1,\"input field F0field '%s' not found! Usign 0th field...\",field);\n    F0fieldIdx = 0; \n  }\n\n  if (intensity) {\n    field = getStr(\"formantFrameIntensField\");\n    idx = findField(field, 0);\n    if (idx >= 0) { formantFrameIntensField = idx; }\n    else { \n      SMILE_IERR(1,\"input field formantFrameIntensField '%s' not found! Usign 0th field...\",field);\n      formantFrameIntensField = 0; \n    }\n  }\n\n  long N=0;\n  if (formants) {\n    field = getStr(\"formantFreqField\");\n    idx = findField(field, 0, &N, NULL, nEl);\n    if (idx >= 0) { \n      formantFreqFieldIdx = idx; \n      nFormantsIn = N;\n    }\n    else { \n      SMILE_IERR(1,\"input field formantFreqField '%s' not found! Usign 0th field...\",field);\n      formantFreqFieldIdx = 0; \n    }\n  }\n\n  if (bandwidths) {\n    field = getStr(\"formantBandwidthField\");\n    idx = findField(field, 0, &N, NULL, nEl);\n    if (idx >= 0) { formantBandwidthFieldIdx = idx; }\n    else { \n      SMILE_IERR(1,\"input field formantBandwidthField '%s' not found! Usign 0th field...\",field);\n      formantBandwidthFieldIdx = 0; \n      if (nFormantsIn == -1) nFormantsIn = N;\n      else { \n        if (nFormantsIn != N) { \n          SMILE_IERR(1,\"size of formantBandwidthField (%i) differs from size of formantFreqField (%i)! Either your config is incorrect or this is a bug!\",N,nFormantsIn);\n          COMP_ERR(\"aborting\");\n        }\n      }\n    }\n  }\n\n\n  if (medianFilter0 > 0) {\n    median0WorkspaceF0cand = smileUtil_temporalMedianFilterInitSl(nFormantsIn, 1, medianFilter0);\n  }\n\n  if (nFormantsIn > 0) {\n    long bw=0;\n    if (formants) bw++;\n    if (bandwidths) bw++;\n    if (bw > 0) {\n      fbin=(FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*nFormantsIn*bw);\n      fbinLastVoiced=(FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*nFormantsIn*bw);\n    }\n  }\n\n  if (nFormants > nFormantsIn) {\n    SMILE_IWRN(1,\"more output formants requested in config (%i) than there are input formants available (%i)! Limiting number of output formants.\",nFormants,nFormantsIn);\n    nFormants = nFormantsIn;\n  }\n\n  namesAreSet_ = 1;\n  return n;\n}\n\n// a derived class should override this method, in order to implement the actual processing\nint cFormantSmoother::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  long i;\n  long n=0;\n\n  \n  // collect all input candidates\n  int c = 0;\n  if (fbin != NULL) {\n    for (i=0; i<nFormantsIn; i++) {\n      int offs = 0;\n      if (formants) { fbin[i] = src[formantFreqFieldIdx+i]; offs = nFormantsIn; }\n      if (bandwidths) fbin[i+offs] = src[formantBandwidthFieldIdx+i];\n      if (fbin[i] != 0.0) c++;\n    }\n  }\n\n  \n  // median filter:\n  if (medianFilter0 > 0) {\n    smileUtil_temporalMedianFilterWslave(fbin, c, 1, median0WorkspaceF0cand);\n  }\n  \n  //apply voiced/unvoiced filter:\n  long bw=0;\n  if (formants) bw++;\n  if (bandwidths) bw++;\n\n  FLOAT_DMEM voice = src[F0fieldIdx];\n  if (voice > 0.0) {\n    for (i=0; i<nFormantsIn*bw; i++) {\n      fbinLastVoiced[i] = fbin[i];\n    }\n  } else {\n    for (i=0; i<nFormantsIn*bw; i++) {\n      if (saveEnvs) {\n        fbin[i] = fbinLastVoiced[i];\n      } else {\n        fbin[i] = 0.0;\n      }\n    }\n  }\n\n  \n  //output:\n  if (intensity) { \n    if (formantFrameIntensField>=0) {\n      dst[n++] = src[formantFrameIntensField];\n    } else {\n      dst[n++] = 0.0; \n    }\n  }\n\n  if (nFormants > 0) {\n    //if (saveEnvs) {\n      int offs = 0;\n      if (formants) { \n        for (i=0; i<nFormants; i++) {\n          dst[n++] = fbin[i];\n        }\n        offs = nFormantsIn;\n      } \n      if (bandwidths) { \n        for (i=0; i<nFormants; i++) {\n          dst[n++] = fbin[i+offs];\n        }\n      } \n    /*} else {\n      int offs = 0;\n      if (formants) { \n        for (i=0; i<nFormants; i++) {\n          dst[n++] = fbin[i]; \n        }\n        offs = nFormantsIn;\n      } \n      if (bandwidths) { \n        for (i=0; i<nFormants; i++) {\n          dst[n++] = fbin[i+offs];\n        }\n      } \n    }*/\n  }\n\n\n  return n;\n}\n\ncFormantSmoother::~cFormantSmoother()\n{\n  if (median0WorkspaceF0cand != NULL) smileUtil_temporalMedianFilterFree(median0WorkspaceF0cand);\n  if (lastFinal != NULL) free(lastFinal);\n  if (fbin != NULL) free(fbin);\n  if (fbinLastVoiced != NULL) free(fbinLastVoiced);\n}\n\n"
  },
  {
    "path": "src/lld/harmonics.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n#include <lld/harmonics.hpp>\n#include <math.h>\n\n#define MODULE \"cHarmonics\"\n\n// TODO: harmonics energy ratios (magnitudes squared)\n\nSMILECOMPONENT_STATICS(cHarmonics)\n\nSMILECOMPONENT_REGCOMP(cHarmonics)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CHARMONICS;\n  sdescription = COMPONENT_DESCRIPTION_CHARMONICS;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    // overwrite some defaults from cVectorProcessor\n    ct->setField(\"processArrayFields\", NULL, 0);\n    ct->setField(\"includeSingleElementFields\", NULL, 1);\n    // define our own new options:\n    ct->setField(\"f0ElementName\", \"Name of F0 element in input vector to use.\", \"F0final\");\n    ct->setField(\"f0ElementNameIsFull\", \"1/0= f0ElementName is a partial name (glob with *x*) or the exact full name.\", 1);\n    ct->setField(\"magSpecFieldName\", \"Name of magnitude spectrum field in input vector to use.\", \"pcm_fftMag\");\n    ct->setField(\"magSpecFieldNameIsFull\", \"1/0= magSpecFieldName is a partial name (glob with *x*) or the exact full name.\", 0);\n    ct->setField(\"formantFrequencyFieldName\", \"Name of formant frequency field. Typcially formantFreqLpc\", (const char*)NULL);\n    ct->setField(\"formantFrequencyFieldNameIsFull\", \"1/0= formantFrequencyFieldName is a partial name (glob with *x*) or the exact full name.\", 1);\n    ct->setField(\"formantBandwidthFieldName\", \"Name of formant bandwidth field. Typically formantBandwidthLpc\", (const char*)NULL);\n    ct->setField(\"formantBandwidthFieldNameIsFull\", \"1/0= formantBandwidthFieldName is a partial name (glob with *x*) or the exact full name.\", 1);\n\n    ct->setField(\"nHarmonics\", \"Maximum number of harmonics to search for (including F0) (approximately Fmax / F_lowest_f0).\", 100);\n    ct->setField(\"firstHarmonicMagnitude\", \"Index of first harmonic magnitude to output (0 is magnitude of F0).\", 1);\n    ct->setField(\"nHarmonicMagnitudes\", \"Number of harmonic magnitudes to output. 0 to disable.\", 0);\n    ct->setField(\"outputLogRelMagnitudes\", \"1 = output logarithmic magnitudes (dB) normalised by the magnitude of F0 (0dB), if nHarmonicMagnitudes > 0.\", 1);\n    ct->setField(\"outputLinearMagnitudes\", \"1 = output the linear magnitudes as obtained from the FFT for the nHarmonicMagnitudes harmonics (if nHarmonicMagnitudes > 0).\", 0);\n    ct->setField(\"harmonicDifferences\", \"Array that specifies harmonic differences (ratios in linear scale) to compute. Syntax for one element: H1-H2 (ratio of H1 to H2), H0 is fundamental frequency. A1,A2,...,AN is the amplitude (highest peak in the formant range) of the N-th formant, if formant frequency AND bandwidth information is given in the input (see formantFrequencyFieldName and formantBandwidthFieldName options).\", (const char*)NULL, ARRAY_TYPE);\n    ct->setField(\"harmonicDifferencesLog\", \"1 = Harmonic differences in log magnitude scale (actually differences of the log values then).\", 1);\n    ct->setField(\"harmonicDifferencesRatioLinear\", \"1 = Harmonic differences in linear magnitude scale (actually ratios of the linear values then).\", 0);\n    ct->setField(\"formantAmplitudes\", \"1 = Enable output of formant amplitudes (amplitude of highest peak in the formant range, half bandwidth left and right of formant frequency).\", 0);\n    ct->setField(\"formantAmplitudesLinear\", \"1 = Linear formant amplitude output, requires formantAmplitudes=1 .\", 0);\n    ct->setField(\"formantAmplitudesLogRel\", \"1 = Logarithmic relative to F0 formant amplitude output in dB, requires formantAmplitudes=1 .\", 1);\n    ct->setField(\"formantAmplitudesStart\", \"First formant to compute amplitudes for, 0 is F0, 1 is first formant, etc.\", 1);\n    ct->setField(\"formantAmplitudesEnd\", \"Last formant to compute amplitudes for. Default '-1' is last formant found in the input.\", -1);\n\n    ct->setField(\"computeAcfHnrLogdB\", \"1 = enable HNR (logarithmic in dB) from ACF at F0 position (vs. total energy). Will be zero for unvoiced frames (where F0 = 0).\", 0);\n    ct->setField(\"computeAcfHnrLinear\", \"1 = enable HNR (linear ACF amplitude ratio) from ACF at F0 position (vs. total energy).  Will be zero for unvoiced frames (where F0 = 0).\", 0);\n    ct->setField(\"logRelValueFloorUnvoiced\", \"Sets the value that is returned for LogRel (relative to F0) type features when F0==0 (unvoiced). Logical default is the general floor of -201.0, however if unvoiced regions should always be zero, in order to be discarded/ignored e.g. by a functionals component, then this should be set to 0.0\", -201.0);\n    // TODO: acf refined F0\n    //       harmonic flux\n    //       fft refined formants (and optionally bandwidths for ease of use)\n\n    /*    ct->setField(\"harmonicsSlope\", \"    \", 0);\n    ct->setField(\"harmonicsMeanMagnitude\", \"\", 0);\n    ct->setField(\"harmonicsStddevMagnitude\", \"\", 0);*/\n    // harmonics flux: deviation of harmonics from expected positions  (could be due to poor spectral res also.. so use a min threshold and subtract that (0.5 - 1 bin width)\n  )\n\n  SMILECOMPONENT_MAKEINFO(cHarmonics);\n}\n\nSMILECOMPONENT_CREATE(cHarmonics)\n\n\ncHarmonics::cHarmonics(const char *_name) :\n  cVectorProcessor(_name),\n  f0ElementName_(NULL), magSpecFieldName_(NULL), idxF0(-1), fsSec(-1.0),\n  frq_(NULL), nFrq_(0), harmonics_(NULL),\n  w_(NULL), ip_(NULL), acfdata_(NULL), acf_(NULL), cnt_(0),\n  harmonicDifferences_(NULL), haveFormantDifference_(false),\n  logRelValueFloorUnvoiced_(-201.0),\n  formantAmplitudes_(0)\n{}\n\nsHarmonicDifferences * cHarmonics::parseHarmonicDifferences(int * Ndiff, bool *haveFormant, int * maxHarmonic)\n{\n  int N = getArraySize(\"harmonicDifferences\");\n  if (N > 0) {\n    int err = 0;\n    sHarmonicDifferences *hd = (sHarmonicDifferences *)calloc(1, sizeof(sHarmonicDifferences) * N);\n    for (int i = 0; i < N; i++) {\n      const char *tmp = getStr_f(myvprint(\"harmonicDifferences[%i]\", i));\n      if (tmp != NULL) {\n        char *h1 = strdup(tmp);\n        char *h2 = strchr(h1, '-');\n        if (h2 != NULL && h2 > h1) {\n          *h2 = 0;\n          h2++;\n          if (h1[0] == 'H') {\n            char *ep = NULL;\n            int r = strtol(h1 + 1, &ep, 10);\n            if ((r == 0) && (ep == h1 + 1)) {\n              SMILE_IERR(1, \"Error parsing %i. harmonic difference (part 1): %s\", i, h1);\n              err = 1;\n            } else {\n              hd[i].h1formant = -1;\n              hd[i].h1idx = r;\n              if (maxHarmonic != NULL && *maxHarmonic < r) {\n                *maxHarmonic = r;\n              }\n            }\n          } else if (h1[0] == 'A') {\n            if (haveFormant != NULL) {\n              *haveFormant = true;\n            }\n            char *ep = NULL;\n            int r = strtol(h1 + 1, &ep, 10);\n            if ((r == 0) && (ep == h1 + 1)) {\n              SMILE_IERR(1, \"Error parsing %i. harmonic difference (part 1): %s\", i, h1);\n              err = 1;\n            } else {\n              hd[i].h1formant = r;\n              hd[i].h1idx = -1;\n            }\n          } else {\n            SMILE_IERR(1, \"Invalid identifier in %i. harmonic difference (part 1): %c. Allowed are 'A' for Formant, and 'H' for harmonic.\", i, h1[0]);\n            err = 1;\n          }\n          if (h2[0] == 'H') {\n             char *ep = NULL;\n             int r = strtol(h2 + 1, &ep, 10);\n             if ((r == 0) && (ep == h2 + 1)) {\n               SMILE_IERR(1, \"Error parsing %i. harmonic difference (part 2): %s\", i, h2);\n               err = 1;\n             } else {\n               hd[i].h2formant = -1;\n               hd[i].h2idx = r;\n               if (maxHarmonic != NULL && *maxHarmonic < r) {\n                 *maxHarmonic = r;\n               }\n             }\n           } else if (h2[0] == 'A') {\n             if (haveFormant != NULL) {\n               *haveFormant = true;\n             }\n             char *ep = NULL;\n             int r = strtol(h2 + 1, &ep, 10);\n             if ((r == 0) && (ep == h2 + 1)) {\n               SMILE_IERR(1, \"Error parsing %i. harmonic difference (part 2): %s\", i, h2);\n               err = 1;\n             } else {\n               hd[i].h2formant = r;\n               hd[i].h2idx = -1;\n             }\n           } else {\n             SMILE_IERR(1, \"Invalid identifier in %i. harmonic difference (part 2): %c. Allowed are 'A' for Formant, and 'H' for harmonic.\", i, h2[0]);\n             err = 1;\n           }\n        } else {\n          SMILE_IERR(1, \"Invalid range specified for %i. harmonic difference: '%s'\", i, h1);\n          err = 1;\n        }\n        if (err == 0) {\n          hd[i].text = tmp;\n        }\n        free(h1);\n      }\n    }\n    if (err == 1) {\n      free(hd);\n      return NULL;\n    } else {\n      if (Ndiff != NULL) {\n        *Ndiff = N;\n      }\n      return hd;\n    }\n  } else {\n    if (Ndiff != NULL) {\n      *Ndiff = 0;\n    }\n  }\n  return NULL;\n}\n\nvoid cHarmonics::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n  nHarmonics_ = getInt(\"nHarmonics\");\n  nHarmonicMagnitudes_ = getInt(\"nHarmonicMagnitudes\");\n  firstHarmonicMagnitude_ = getInt(\"firstHarmonicMagnitude\");\n  outputLogRelMagnitudes_ = getInt(\"outputLogRelMagnitudes\");\n  outputLinearMagnitudes_ = getInt(\"outputLinearMagnitudes\");\n  int maxHarmonic = 0;\n  harmonicDifferences_ = parseHarmonicDifferences(&nHarmonicDifferences_,\n      &haveFormantDifference_, &maxHarmonic);\n  harmonicDifferencesLog_ = getInt(\"harmonicDifferencesLog\");\n  harmonicDifferencesLinear_ = getInt(\"harmonicDifferencesRatioLinear\");\n  formantAmplitudes_ = getInt(\"formantAmplitudes\");\n  formantAmplitudesLogRel_ = getInt(\"formantAmplitudesLogRel\");\n  formantAmplitudesLinear_ = getInt(\"formantAmplitudesLinear\");\n  formantAmplitudesStart_ = getInt(\"formantAmplitudesStart\");\n  formantAmplitudesEnd_ = getInt(\"formantAmplitudesEnd\");\n  f0ElementName_ = getStr(\"f0ElementName\");\n  f0ElementNameIsFull_ = getInt(\"f0ElementNameIsFull\");\n  magSpecFieldName_ = getStr(\"magSpecFieldName\");\n  magSpecFieldNameIsFull_ = getInt(\"magSpecFieldNameIsFull\");\n  formantFrequencyFieldName_ = getStr(\"formantFrequencyFieldName\");\n  formantFrequencyFieldNameIsFull_ = getInt(\"formantFrequencyFieldNameIsFull\");\n  formantBandwidthFieldName_ = getStr(\"formantBandwidthFieldName\");\n  formantBandwidthFieldNameIsFull_ = getInt(\"formantBandwidthFieldNameIsFull\");\n  computeAcfHnrLogdB_ = getInt(\"computeAcfHnrLogdB\");\n  computeAcfHnrLinear_ = getInt(\"computeAcfHnrLinear\");\n  if (nHarmonics_ < nHarmonicMagnitudes_ + firstHarmonicMagnitude_ + 1) {\n    nHarmonics_ = nHarmonicMagnitudes_ + firstHarmonicMagnitude_ + 1;\n  }\n  if (nHarmonics_ < maxHarmonic + 1) {\n    nHarmonics_ = maxHarmonic + 1;\n  }\n  if (formantAmplitudesLogRel_ == 0 && formantAmplitudesLinear_ == 0) {\n    formantAmplitudes_ = 0;\n    SMILE_IWRN(1, \"Disabling formant amplitude output, because neither formantAmplitudesLogRel nor formantAmplitudesLinear is enabled.\");\n  }\n  logRelValueFloorUnvoiced_ = (FLOAT_DMEM)getDouble(\"logRelValueFloorUnvoiced\");\n}\n\n\nint cHarmonics::setupNewNames(long nEl)\n{\n  namesAreSet_ = 1;\n  int newNEl = 0;\n  if (fsSec == -1.0) {\n    const sDmLevelConfig *c = reader_->getLevelConfig();\n    fsSec = c->frameSizeSec;  // WHAT about this value if we use pitch from 60ms win and spectrum from 25ms win???\n    // We should rather use the meta data info on the spectral field...! However this will not be passed properly.\n  }\n  // setup output fields\n  if (computeAcfHnrLogdB_) {\n    writer_->addField(\"HarmonicsToNoiseRatioACFLogdB\", 1);\n    newNEl++;\n  }\n  if (computeAcfHnrLinear_) {\n    writer_->addField(\"HarmonicsToNoiseRatioACFLinear\", 1);\n    newNEl++;\n  }\n  if (outputLogRelMagnitudes_) {\n    if (nHarmonicMagnitudes_ > 0) {\n      writer_->addField(\"HarmonicMagnitudeRelativeF0dB\", nHarmonicMagnitudes_, firstHarmonicMagnitude_);\n      newNEl += nHarmonicMagnitudes_;\n    }\n  }\n  if (outputLinearMagnitudes_) {\n    if (nHarmonicMagnitudes_ > 0) {\n      writer_->addField(\"HarmonicMagnitudeLinear\", nHarmonicMagnitudes_, firstHarmonicMagnitude_);\n      newNEl += nHarmonicMagnitudes_;\n    }\n  }\n  // find input fields\n  if (f0ElementName_ == NULL) {\n    SMILE_IERR(1, \"F0ElementName not specified! This is required! Aborting.\");\n    return 0;\n  }\n  if (magSpecFieldName_ == NULL) {\n    SMILE_IERR(1, \"Magnitude spectrum field name not specified! This is required! Aborting.\");\n    return 0;\n  }\n  idxF0 = findElement(f0ElementName_, f0ElementNameIsFull_, NULL, NULL, NULL);\n  idxSpec = findField(magSpecFieldName_, magSpecFieldNameIsFull_, &nSpecBins, NULL, -1, NULL, &idxSpecField_);\n  if (idxF0 == idxSpec) {\n    SMILE_IERR(1, \"Index found for f0Element and magSpecField are the same (%i)! There is an error somewhere, correct your config! Maybe one of the two fields (or both) does not exist in the input level!?\", idxF0);\n    return 0;\n  }\n  nFFreq_ = 0;\n  nFBandw_ = 0;\n  idxFFreq_ = -1;\n  idxFBandw_ = -1;\n  if (formantFrequencyFieldName_ != NULL) {\n    if (formantBandwidthFieldName_ == NULL) {\n      if (formantAmplitudes_) {\n        SMILE_IERR(2, \"Formant bandwidth field name is missing. Both frequency and bandwidth of formants are required! Disabling formant based harmonics features!!!\");\n        if (haveFormantDifference_) {\n          SMILE_IWRN(2, \"Also disabling harmonic difference features, because they contain some formant amplitude differences!\");\n          nHarmonicDifferences_ = 0;\n        }\n        formantAmplitudes_ = 0;\n      }\n      formantAmplitudes_ = 0;\n    }\n    idxFFreq_ = findField(formantFrequencyFieldName_, formantFrequencyFieldNameIsFull_, &nFFreq_, NULL, -1, NULL);\n    idxFBandw_ = findField(formantBandwidthFieldName_, formantBandwidthFieldNameIsFull_, &nFBandw_, NULL, -1, NULL);\n    // some sanity checks...\n    if (idxFFreq_ == idxFBandw_) {\n      SMILE_IERR(1, \"Index for formant frequency field and formant bandwidth field are the same!\");\n      return 0;\n    }\n    if (nFFreq_ != nFBandw_) {\n      SMILE_IERR(1, \"Number of formant frequencies and bandwidth does not match! (%i != %i)\", nFFreq_, nFBandw_);\n      return 0;\n    }\n  } else {\n    if (formantAmplitudes_) {\n      SMILE_IERR(2, \"Formant amplitudes cannot be computed, formantFrequencyFieldName_ and formantBandwidthFieldName_ are not set! Disabling formant amplitudes.\");\n      if (haveFormantDifference_) {\n        SMILE_IWRN(2, \"Also disabling harmonic difference features, because they contain some formant amplitude differences!\");\n        nHarmonicDifferences_ = 0;\n      }\n      formantAmplitudes_ = 0;\n    }\n  }\n  // add harmonic difference field\n  if (nHarmonicDifferences_ > 0 && (harmonicDifferencesLog_ || harmonicDifferencesLinear_)) {\n    for (int i = 0; i < nHarmonicDifferences_; i++) {\n      if (harmonicDifferences_[i].text != NULL) {\n        char *tmp = strdup(harmonicDifferences_[i].text);\n        // remove spaces before and after\n        char *x = tmp;\n        int l = strlen(x);\n        while (*x == ' ' && l > 0) {\n          x++; l--;\n        }\n        while (*(x+l) == ' ' && l > 0) {\n          *(x+l) = 0; l--;\n        }\n        if (harmonicDifferencesLinear_) {\n          char *y = myvprint(\"HarmonicDifferenceRatioLinear%s\", x);\n          writer_->addField(y, 1);\n          newNEl++;\n          free(y);\n        }\n        if (harmonicDifferencesLog_) {\n          char *y = myvprint(\"HarmonicDifferenceLogRel%s\", x);\n          writer_->addField(y, 1);\n          newNEl++;\n          free(y);\n        }\n        free(x);\n      } else {\n        SMILE_IERR(1, \"Inconsistency in harmonic differences! Element %i has NULL text. Seems like a bug somewhere. Aborting config.\", i);\n        return 0;\n      }\n    }\n  }\n  // add formant amplitudes field\n  if (formantAmplitudes_) {\n    if (formantAmplitudesEnd_ == -1) {\n      formantAmplitudesEnd_ = nFFreq_;\n    }\n    if (formantAmplitudesStart_ < 0) {\n      formantAmplitudesStart_ = 0;\n    }\n    if (formantAmplitudesEnd_ > nFFreq_) {\n      formantAmplitudesEnd_ = nFFreq_;\n    }\n    if (formantAmplitudesEnd_ < formantAmplitudesStart_) {\n      SMILE_IERR(1, \"Inconsistency in the formant amplitudes range configuration found (end (%i) < start (%i)). Disabling formant amplitude output.\", formantAmplitudesEnd_, formantAmplitudesStart_);\n      formantAmplitudes_ = 0;\n    } else {\n      if (formantAmplitudesLinear_) {\n        writer_->addField(\"FormantAmplitudeByMaxHarmonicLinear\", formantAmplitudesEnd_ - formantAmplitudesStart_ + 1, formantAmplitudesStart_);\n        newNEl += formantAmplitudesEnd_ - formantAmplitudesStart_ + 1;\n      }\n      if (formantAmplitudesLogRel_) {\n        writer_->addField(\"FormantAmplitudeByMaxHarmonicLogRelF0\", formantAmplitudesEnd_ - formantAmplitudesStart_ + 1, formantAmplitudesStart_);\n        newNEl += formantAmplitudesEnd_ - formantAmplitudesStart_ + 1;\n      }\n    }\n  }\n  return newNEl;\n}\n\nint cHarmonics::isPeak(const FLOAT_DMEM * x, long N, long n)\n{\n  if (n >= N || n < 0) { return 0; }\n  if (n + 1 < N) {\n    if (n > 0) {\n      if (x[n] > x[n - 1] && x[n] > x[n + 1]) {\n        return 1;\n      }\n    } else {\n      if (x[0] > x[1]) { \n        return 1; \n      }\n    }\n  } else {\n    if (n > 0) {\n      if (x[n] > x[n - 1]) {\n        return 1;\n      }\n    }\n  }\n  return 0;\n}\n\n// this method only works for linear frequency scales!\nint cHarmonics::freqToAcfBinLin(float freq)\n{\n  double fs = frq_[nFrq_-1] * 2.0;\n  if (freq > 0.0) {\n    return (int)floor(fs / freq);\n  } else {\n    return 0;\n  }\n}\n\nint cHarmonics::freqToBin(float freq, int startBin)\n{\n  for (; startBin < nFrq_; startBin++) {\n    if (frq_[startBin] > freq) {\n      if (frq_[startBin] - freq > freq - frq_[startBin - 1]) {\n        return startBin - 1;\n      } else {\n        return startBin;\n      }\n    }\n  }\n  return 0;\n}\n\nint cHarmonics::findHarmonicPeaks(float pitchFreq,\n    const FLOAT_DMEM * magSpec, long nBins, sF0Harmonic * harmonics,\n    int nHarmonics, const double * frq, float F0)\n{\n  if (nHarmonics <= 0) {\n    return 0;\n  }\n  if (harmonics == NULL) {\n    //harmonics = (sF0Harmonic *)calloc(1, sizeof(sF0Harmonic));\n    return 0;\n  }\n  int nHarmonicsFound = 0;\n  if (frq_ == NULL) {  // linear fft spectrum\n    // loop over candidates and find closest peak\n    int firstBin = (int)floor((float)(1.5) * pitchFreq / F0);\n    for (int i = 0; i < nHarmonics; i++) {\n      // map pitchFreq to bins\n      int candBin = (int)floor((float)(i + 2) * pitchFreq / F0);\n      int peakBin = -1;\n      if (isPeak(magSpec, nBins, candBin)) {\n        peakBin = candBin;\n      } else {\n        int candBinL = candBin - 1;\n        int candBinR = candBin + 1;\n        int lowerLimit = (int)floor(((float)i + 1.5) * pitchFreq / F0);\n        int upperLimit = (int)floor(((float)i + 2.5) * pitchFreq / F0);\n        // search left and right\n        while (candBinL > lowerLimit && candBinR < upperLimit && peakBin == -1) {\n          if (isPeak(magSpec, nBins, candBinL)) {\n            peakBin = candBinL; break;\n          }\n          if (isPeak(magSpec, nBins, candBinR)) {\n            peakBin = candBinR; break;\n          }\n          candBinR++;\n          candBinL--;\n        }\n      }\n      // found a valid peak for harmonic i?\n      if (peakBin >= firstBin && peakBin < nBins - 1) {\n        harmonics[i].bin = peakBin;\n        harmonics[i].freqExpected = (float)(i + 2) * pitchFreq;\n        harmonics[i].freqFromBin = (float)peakBin * F0;\n        harmonics[i].magnitude = magSpec[peakBin];\n        double magnitudeInterpolated = 0.0;\n        float binInterpolated = (float)smileMath_quadFrom3pts(\n            (double)(peakBin - 1), (double)magSpec[peakBin - 1],\n            (double)peakBin, (double)magSpec[peakBin],\n            (double)(peakBin + 1), (double)magSpec[peakBin + 1],\n            &magnitudeInterpolated, NULL);\n        harmonics[i].freqInterpolated = binInterpolated * F0;\n        harmonics[i].magnitudeInterpolated = (float)magnitudeInterpolated;\n        nHarmonicsFound++;\n      } else {\n        harmonics[i].bin = -1;\n        harmonics[i].freqExpected = 0.0;\n        harmonics[i].freqFromBin = 0.0;\n        harmonics[i].magnitude = 0.0;\n        harmonics[i].magnitudeInterpolated = 0.0;\n      }\n    }\n  } else {  // possibly something else, nonlinear...\n    // loop over candidates and find closest peak\n    int lastBin = freqToBin(0.5f * pitchFreq, 1);\n    int firstBin = freqToBin(0.5f * pitchFreq, lastBin);\n    for (int i = 0; i < nHarmonics; i++) {\n      // map pitchFreq to bins\n      int candBin = freqToBin((float)(i + 1) * pitchFreq, lastBin);\n      int peakBin = -1;\n      if (candBin >= nBins) {\n        harmonics[i].freqExpected = 0.0;\n        harmonics[i].magnitudeLogRelF0 = -201.0;\n        harmonics[i].bin = -1;\n        harmonics[i].freqFromBin = 0.0;\n        harmonics[i].freqInterpolated = 0.0;\n        harmonics[i].magnitude = 0.0;\n        harmonics[i].magnitudeInterpolated = 0.0;\n        continue;\n      }\n      if (isPeak(magSpec, nBins, candBin)) {\n        peakBin = candBin;\n      } else {\n        int candBinL = candBin - 1;\n        int candBinR = candBin + 1;\n        int lowerLimit = freqToBin(((float)i + 0.5f) * pitchFreq, lastBin);\n        int upperLimit = freqToBin(((float)i + 1.5f) * pitchFreq, candBin);\n        // search left and right\n        while ((candBinL >= lowerLimit || candBinR <= upperLimit) && peakBin == -1) {\n          if (candBinR <= upperLimit) {\n            if (isPeak(magSpec, nBins, candBinR)) {\n              peakBin = candBinR;\n              break;\n            }\n            candBinR++;\n          }\n          if (candBinL >= lowerLimit) {\n            if (isPeak(magSpec, nBins, candBinL)) {\n              peakBin = candBinL;\n              break;\n            }\n            candBinL--;\n          }\n        }\n        // TODO: remove duplicate harmonics?\n      }\n      harmonics[i].freqExpected = (float)(i + 1) * pitchFreq;\n      harmonics[i].magnitudeLogRelF0 = -201.0;\n      // found a valid peak for harmonic i?\n      if (peakBin >= firstBin && peakBin < nBins - 1) {\n        harmonics[i].bin = peakBin;\n        harmonics[i].freqFromBin = (float)frq_[peakBin];\n        harmonics[i].magnitude = magSpec[peakBin];\n        double magnitudeInterpolated = 0.0;\n        harmonics[i].freqInterpolated = (float)smileMath_quadFrom3pts(\n            frq_[peakBin - 1], (double)magSpec[peakBin - 1],\n            frq_[peakBin], (double)magSpec[peakBin],\n            frq_[peakBin + 1], (double)magSpec[peakBin + 1],\n            &magnitudeInterpolated, NULL);\n        harmonics[i].magnitudeInterpolated = (float)magnitudeInterpolated;\n        nHarmonicsFound++;\n      } else {\n        harmonics[i].bin = candBin;\n        harmonics[i].freqFromBin = 0.0;\n        harmonics[i].freqInterpolated = 0.0;\n        harmonics[i].magnitude = 0.0;\n        harmonics[i].magnitudeInterpolated = 0.0;\n      }\n      lastBin = candBin;\n    }\n  }\n  return nHarmonicsFound;\n}\n\nvoid cHarmonics::postProcessHarmonics(sF0Harmonic * harmonics, int nHarmonics, bool logRelMagnitude)\n{\n  float magnitudeF0 = 0.0;\n  if (logRelMagnitude) {\n    magnitudeF0 = harmonics[0].magnitude;\n    if (magnitudeF0 == 0.0) {\n      logRelMagnitude = false;\n    } else {\n      magnitudeF0 = log10(magnitudeF0);\n    }\n    harmonics[0].magnitudeLogRelF0 = 0.0;\n  }\n  for (int i = 1; i < nHarmonics; i++) {\n    if (logRelMagnitude) {\n      double tmp = 0.0;\n      if (harmonics[i].magnitudeInterpolated > 0.0) {\n        tmp = log10(harmonics[i].magnitudeInterpolated);\n        harmonics[i].magnitudeLogRelF0 = (float)(20.0 * (tmp - magnitudeF0));\n        if (harmonics[i].magnitudeLogRelF0 < -200.0) {\n          harmonics[i].magnitudeLogRelF0 = -200.0;\n        }\n      } else {\n        harmonics[i].magnitudeLogRelF0 = -200.0;\n      }\n    } else {\n      harmonics[i].magnitudeLogRelF0 = -201.0;\n    }\n    // remove (set to zero) duplicates:\n    if (harmonics[i].bin == harmonics[i-1].bin) {\n      harmonics[i].bin = 0;\n      harmonics[i].freqFromBin = 0.0;\n      harmonics[i].freqInterpolated = 0.0;\n      harmonics[i].freqExpected = 0.0;\n      harmonics[i].magnitude = 0.0;\n      harmonics[i].magnitudeInterpolated = 0.0;\n      harmonics[i].magnitudeLogRelF0 = -201.0;\n    }\n  }\n}\n\nint cHarmonics::computeAcf(const FLOAT_DMEM *magSpec, FLOAT_DMEM *acf, long nBins, bool squareInput)\n{\n  long N = (nBins-1)*2;\n  // check for power of 2!!\n  if (!smileMath_isPowerOf2(N)) {\n    SMILE_IERR(1,\"(Nsrc-1)*2 = %i is not a power of 2, this is required for acf!! make sure the input data really is fft magnitude data!\",N);\n    return 0;\n  }\n  // data preparation for inverse fft:\n  if (acfdata_ == NULL) {\n    acfdata_ = (FLOAT_TYPE_FFT*)malloc(sizeof(FLOAT_TYPE_FFT)*N);\n  }\n  if (ip_ == NULL) {\n    ip_ = (int *)calloc(1,sizeof(int)*(N+2));\n  }\n  if (w_ == NULL) {\n    w_ = (FLOAT_TYPE_FFT *)calloc(1,sizeof(FLOAT_TYPE_FFT)*(N*5)/4+2);\n  }\n  if (squareInput) {\n    acfdata_[0] = (FLOAT_TYPE_FFT)(magSpec[0] * magSpec[0]);\n    acfdata_[1] = (FLOAT_TYPE_FFT)(magSpec[nBins-1] * magSpec[nBins-1]);\n    for (int i = 2; i < N-1; i += 2) {\n      acfdata_[i] = (FLOAT_TYPE_FFT)(magSpec[i>>1] * magSpec[i>>1]);\n      acfdata_[i+1] = 0.0;\n    }\n  } else {\n    acfdata_[0] = (FLOAT_TYPE_FFT)(magSpec[0]);\n    acfdata_[1] = (FLOAT_TYPE_FFT)(magSpec[nBins-1]);\n    for (int i = 2; i < N-1; i += 2) {\n      acfdata_[i] = (FLOAT_TYPE_FFT)(magSpec[i>>1]);\n      acfdata_[i+1] = 0.0;\n    }\n  }\n  // inverse fft\n  rdft(N, -1, acfdata_, ip_, w_);\n  // data output\n  for (int i = 0; (i < N) && (i < nBins); i++) {\n    acf[i] = (FLOAT_DMEM)fabs(acfdata_[i]) / (FLOAT_DMEM)nBins;\n  }\n  return 1;\n}\n\nlong cHarmonics::getClosestPeak(const FLOAT_DMEM *x, long N, long idx)\n{\n  if (isPeak(x, N, idx)) {\n    return idx;\n  }\n  long o = 1;\n  while (idx - o > 0 || idx + o < N - 1) {\n    if (idx - o > 0) {\n      if (isPeak(x, N, idx - o)) {\n        return idx - o;\n      }\n    }\n    if (idx + o < N - 1) {\n      if (isPeak(x, N, idx + o)) {\n        return idx + o;\n      }\n    }\n    o++;\n  }\n  if (x[0] > x[idx] && x[N-1] <= x[idx]) {\n    return 0;\n  } else if (x[0] <= x[idx] && x[N-1] > x[idx]) {\n    return N-1;\n  } else if (x[0] > x[idx] && x[N-1] > x[idx]) {\n    if (idx < N/2) {\n      return 0;\n    } else {\n      return N-1;\n    }\n  }\n  // if all values are the same, we return idx,\n  // otherwise we should already have returned an index above\n  return idx;\n}\n\n/* computes HNR from ACF in dB for a range -100 to +100 dB */\nFLOAT_DMEM cHarmonics::computeAcfHnr_linear(const FLOAT_DMEM *a, long N, long F0bin)\n{\n  if (F0bin <= 0) {\n    // find first peak of ACF?\n    return 0.0;\n  } else {\n\n    double hnr = a[0] - a[F0bin];\n    if (hnr == 0.0) {\n      hnr = 10e10;\n    } else {\n      hnr = a[F0bin] / hnr;\n    }\n    if (hnr > 10e10) {\n      hnr = 10e10;\n    } else if (hnr < 10e-10) {\n      hnr = 10e-10;\n    }\n    return (FLOAT_DMEM)hnr;\n  }\n}\n\nFLOAT_DMEM cHarmonics::computeAcfHnr_dB(const FLOAT_DMEM *a, long N, long F0bin)\n{\n  if (F0bin <= 0) {\n    // find first peak of ACF?\n    return 0.0;\n  } else {\n    double hnr = a[0] - a[F0bin];\n    double ret;\n    if (hnr == 0.0) {\n      hnr = 10e10;\n    } else {\n      hnr = a[F0bin] / hnr;\n    }\n    if (hnr > 10e10) {\n      ret = 10.0 * log10(10e10);\n    } else if (hnr < 10e-10) {\n      ret = 10.0 * log10(10e-10);\n    } else {\n      ret = 10.0 * log10(hnr);\n    }\n    return (FLOAT_DMEM)ret;\n  }\n}\n\nint * cHarmonics::getFormantAmplitudeIndices(const FLOAT_DMEM * centreFreq,\n    const FLOAT_DMEM *bandw, int N)\n{\n  int * ampl = NULL;\n  if (N > 0) {\n    ampl = (int *)calloc(1, sizeof(int) * N);\n  }\n  for (int f = 0; f < N; f++) {\n    // TODO: we don't seem to require the bandwidths... remove them or make an option to use them optionally!\n    //float fLeft = (float)centreFreq[f] - 0.38f * (float)bandw[f];\n    //float fRight = (float)centreFreq[f] + 0.38f * (float)bandw[f];\n    float fLeft = 0.8f * (float)centreFreq[f];\n    float fRight = 1.2f * (float)centreFreq[f];\n    int maxIdx = -1;\n    float maxMag = 0.0;\n    for (int h = 0; h < nHarmonics_; h++) {\n      if (harmonics_[h].freqInterpolated >= fLeft && harmonics_[h].freqInterpolated <= fRight) {\n        if (harmonics_[h].magnitude > maxMag) {\n          maxIdx = h;\n          maxMag = harmonics_[h].magnitude;\n        }\n      }\n    }\n    ampl[f] = maxIdx;\n  }\n  return ampl;\n}\n\n// a derived class should override this method, in order to implement the actual processing\nint cHarmonics::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  //printf(\"Nsrc = %i, Ndst = %i\\n\", Nsrc, Ndst);\n  if (idxi > 0) {\n    SMILE_IERR(1, \"Field index > 0 in processVectorFloat. This should not happen, please use processArrayFields = 1!\");\n    return 0;\n  }\n  if (Nsrc <= 0) {\n    return 0;\n  }\n  if (frq_ == NULL) { // input block's frequency axis\n    const FrameMetaInfo * fmeta = reader_->getFrameMetaInfo();\n    if ((fmeta != NULL)&&(idxSpecField_ < fmeta->N)) {\n      // TODO: check input block's type (in fmeta)\n      // fmeta->field[idxi].dataType & SPECTRAL == 1 ?\n      frq_ = (double *)(fmeta->field[idxSpecField_].info);\n      nFrq_ = fmeta->field[idxSpecField_].infoSize / sizeof(double);\n      if (nFrq_ != nSpecBins) {\n        SMILE_IWRN(2,\"number of frequency axis points (from info struct) [%i] is not equal to Nsrc [%i] ! Field index: %i (check the processArrayFields option).\",nFrq_, nSpecBins, idxi);\n        nFrq_ = MIN(nFrq_, nSpecBins);\n      }\n      // TODO: spectrum scale is stored in level meta-data!\n      // should not be, should be in field meta data! or datatype...?\n      //reader_->getLevelMetaDataPtr();\n      //fmeta->field[idxSpec].dataType\n      // FOR NOW: assumes linear scale...\n    } else {\n      if (fmeta != NULL) {\n        SMILE_IERR(1, \"Unable to get frequency axis meta information from input level spectral magnitude field (field # %i of %i).\", idxSpecField_, fmeta->N);\n      } else {\n        SMILE_IERR(1, \"No frame meta information available from input level. This is required for spectral axis information!\");\n      }\n      return 0;\n    }\n  }\n  //printf(\"nFrq %i , idxi %i, Nsrc %i, Ndst %i, idxF0 %i, idxSpec %i \\n\", nFrq_, idxi, Nsrc, Ndst, idxF0, idxSpec);\n\n  long dstPtr = 0;\n\n  // get F0 input field....\n  FLOAT_DMEM F0 = src[idxF0];\n  // convert F0 (frequency) to T0 (acf bin) and FF0 (fft bin)\n  long F0bin = freqToBin(F0, 1);\n  long F0acfBin = freqToAcfBinLin(F0);\n  // get magnitude spectrum pointer\n  const FLOAT_DMEM *magSpec = src + idxSpec;\n\n  if (computeAcfHnrLogdB_ || computeAcfHnrLinear_) {\n    // do acf\n    if (acf_ == NULL) {\n      acf_ = (FLOAT_DMEM *)malloc(sizeof(FLOAT_DMEM) * nFrq_);\n    }\n    if (computeAcf(magSpec, acf_, nFrq_, 1 /* squareInput = true */)) {\n      // compute ACF HNR\n      long F0acfBinRefined = 0;\n      if (F0acfBin > 0) {\n        F0acfBinRefined = getClosestPeak(acf_, nFrq_, F0acfBin);\n      }\n      if (computeAcfHnrLogdB_) {\n        dst[dstPtr++] = computeAcfHnr_dB(acf_, nFrq_, F0acfBinRefined);\n      }\n      if (computeAcfHnrLinear_) {\n        dst[dstPtr++] = computeAcfHnr_linear(acf_, nFrq_, F0acfBinRefined);\n      }\n    } else {\n      return 0;\n    }\n  }\n\n  bool needHarmonics =\n      ((nHarmonicMagnitudes_ > 0 && (outputLogRelMagnitudes_ || outputLinearMagnitudes_))\n          || (nHarmonicDifferences_ > 0 && (harmonicDifferencesLog_ || harmonicDifferencesLinear_))\n          || formantAmplitudes_);\n  if (needHarmonics) {\n    // F0 based harmonic features\n    if (F0 > 0.0) {\n      if (harmonics_ == NULL) {\n        harmonics_ = (sF0Harmonic *)calloc(1, sizeof(sF0Harmonic) * nHarmonics_);\n      }\n      int nH = findHarmonicPeaks(F0, magSpec, nFrq_, harmonics_, nHarmonics_, frq_, 0.0);\n      postProcessHarmonics(harmonics_, nHarmonics_, true);\n      //printf(\"n harmonics found (frame %i): %i of %i\\n\", cnt_, nH,  nHarmonics_);\n      //for (int i = 0; i < nHarmonics_; i++) {\n//        printf(\"[%.1f %i %.1f; %.1f]  \", harmonics_[i].freqExpected, harmonics_[i].bin, harmonics_[i].freqInterpolated, harmonics_[i].magnitudeLogRelF0);\n  //    }\n      //printf(\"\\n\");\n      if (outputLogRelMagnitudes_) {\n        for (int i = firstHarmonicMagnitude_; i < nHarmonicMagnitudes_; i++) {\n          dst[dstPtr++] = harmonics_[i].magnitudeLogRelF0;\n        }\n      }\n      if (outputLinearMagnitudes_) {\n        for (int i = firstHarmonicMagnitude_; i < nHarmonicMagnitudes_; i++) {\n          dst[dstPtr++] = harmonics_[i].magnitude;\n        }\n      }\n      int * faidxs = NULL;\n      if (haveFormantDifference_ || formantAmplitudes_) {\n        // get formant ranges\n        const FLOAT_DMEM *Ff = src + idxFFreq_;\n        const FLOAT_DMEM *Fb = src + idxFBandw_;\n        // get formant amplitudes\n        faidxs = getFormantAmplitudeIndices(Ff, Fb, nFFreq_);\n        /*for (int i = 0; i < nFFreq_; i++) {\n          printf(\"cnt[%i]: faidxs[%i] = %i\\n\", cnt_, i, faidxs[i]);\n        }*/\n        if (haveFormantDifference_ && nHarmonicDifferences_ > 0\n            && (harmonicDifferencesLog_ || harmonicDifferencesLinear_)) {\n          // get corresponding harmonic indices\n          for (int i = 0; i < nHarmonicDifferences_; i++) {\n            if (harmonicDifferences_[i].h1formant > 0) {\n              if (harmonicDifferences_[i].h1formant <= nFFreq_) {\n                harmonicDifferences_[i].h1idx = faidxs[harmonicDifferences_[i].h1formant - 1];\n              } else {\n                SMILE_IWRN(1, \"Formant index %i in difference %s is higher than number of input formants (%i)!\",\n                    harmonicDifferences_[i].h1formant, harmonicDifferences_[i].text, nFFreq_);\n              }\n            } else if (harmonicDifferences_[i].h1formant == 0) {\n              harmonicDifferences_[i].h1idx = 0;\n            }\n            if (harmonicDifferences_[i].h2formant > 0) {\n              if (harmonicDifferences_[i].h2formant <= nFFreq_) {\n                harmonicDifferences_[i].h2idx = faidxs[harmonicDifferences_[i].h2formant - 1];\n              } else {\n                SMILE_IWRN(1, \"Formant index %i in difference %s is higher than number of input formants (%i)!\",\n                    harmonicDifferences_[i].h2formant, harmonicDifferences_[i].text, nFFreq_);\n              }\n            } else if (harmonicDifferences_[i].h2formant == 0) {\n              harmonicDifferences_[i].h2idx = 0;\n            }\n          }\n        }\n      }\n      if (nHarmonicDifferences_ > 0 && (harmonicDifferencesLog_ || harmonicDifferencesLinear_)) {\n        for (int i = 0; i < nHarmonicDifferences_; i++) {\n          if (harmonicDifferences_[i].h1idx >= 0 && harmonicDifferences_[i].h2idx >= 0\n              && harmonicDifferences_[i].h1idx < nHarmonics_\n              && harmonicDifferences_[i].h2idx < nHarmonics_) {\n            // both valid\n            if (harmonicDifferencesLinear_) {\n              if (harmonics_[harmonicDifferences_[i].h2idx].magnitude > 10e-10) {\n                dst[dstPtr++] = harmonics_[harmonicDifferences_[i].h1idx].magnitude\n                                 / harmonics_[harmonicDifferences_[i].h2idx].magnitude;\n              } else {\n                dst[dstPtr++] = (FLOAT_DMEM)(harmonics_[harmonicDifferences_[i].h1idx].magnitude\n                                 / 10e-10f);\n              }\n            }\n            if (harmonicDifferencesLog_) {\n              dst[dstPtr] = harmonics_[harmonicDifferences_[i].h1idx].magnitudeLogRelF0\n                              - harmonics_[harmonicDifferences_[i].h2idx].magnitudeLogRelF0;\n              if (dst[dstPtr] < -201.0) {\n                dst[dstPtr] = -201.0;\n              }\n              if (dst[dstPtr] > 201.0) {\n                dst[dstPtr] = 201.0;\n              }\n              dstPtr++;\n            }\n          } else {\n            if (harmonicDifferences_[i].h1idx >= 0 && harmonicDifferences_[i].h1idx < nHarmonics_) {\n              // h1 valid, assign h1\n              if (harmonicDifferencesLinear_) {\n                dst[dstPtr++] = (FLOAT_DMEM)(harmonics_[harmonicDifferences_[i].h1idx].magnitudeLogRelF0 / 10e-10f);\n              }\n              if (harmonicDifferencesLog_) {\n                dst[dstPtr] = (FLOAT_DMEM)(harmonics_[harmonicDifferences_[i].h1idx].magnitudeLogRelF0 - 201.0f);\n                if (dst[dstPtr] < (FLOAT_DMEM)-201.0) {\n                  dst[dstPtr] = (FLOAT_DMEM)-201.0;\n                }\n                if (dst[dstPtr] > (FLOAT_DMEM)201.0) {\n                  dst[dstPtr] = (FLOAT_DMEM)201.0;\n                }\n                dstPtr++;\n              }\n              if (harmonicDifferences_[i].h2idx >= 0) {\n                SMILE_IWRN(2, \"%i. harmonic index %i (b) is out of range (check nHarmonics (=%i)!)\",\n                    i, harmonicDifferences_[i].h2idx, nHarmonics_);\n              }\n            } else if (harmonicDifferences_[i].h2idx >= 0 && harmonicDifferences_[i].h2idx < nHarmonics_) {\n              // h2 valid, assign h2\n              if (harmonicDifferencesLinear_) {\n                dst[dstPtr++] = 0.0;\n              }\n              if (harmonicDifferencesLog_) {\n                dst[dstPtr] = (FLOAT_DMEM)(-201.0 - harmonics_[harmonicDifferences_[i].h2idx].magnitudeLogRelF0);\n                if (dst[dstPtr] < (FLOAT_DMEM)-201.0) {\n                  dst[dstPtr] = (FLOAT_DMEM)-201.0;\n                }\n                if (dst[dstPtr] > (FLOAT_DMEM)201.0) {\n                  dst[dstPtr] = (FLOAT_DMEM)201.0;\n                }\n                dstPtr++;\n              }\n              if (harmonicDifferences_[i].h1idx >= 0) {\n                SMILE_IWRN(2, \"%i. harmonic index %i (a) is out of range (check nHarmonics (=%i)!)\",\n                    i, harmonicDifferences_[i].h1idx, nHarmonics_);\n              }\n            } else {\n              // none valid\n              if (harmonicDifferencesLinear_) {\n                dst[dstPtr++] = (FLOAT_DMEM)1.0;\n              }\n              if (harmonicDifferencesLog_) {\n                dst[dstPtr++] = (FLOAT_DMEM)0.0;\n              }\n              SMILE_IWRN(3, \"%i. harmonic index %i (a) is out of range (check nHarmonics (=%i)!)\",\n                  i, harmonicDifferences_[i].h1idx, nHarmonics_);\n              SMILE_IWRN(3, \"%i. harmonic index %i (b) is out of range (check nHarmonics (=%i)!)\",\n                  i, harmonicDifferences_[i].h2idx, nHarmonics_);\n            }\n          }\n        }\n      }\n      if (formantAmplitudes_) {\n        for (int i = formantAmplitudesStart_; i <= formantAmplitudesEnd_; i++) {\n          if (i > 0 && i <= nFFreq_ && faidxs != NULL) {\n            if (formantAmplitudesLinear_) {\n              if (faidxs[i - 1] >= 0) {\n                dst[dstPtr++] = harmonics_[faidxs[i - 1]].magnitude;\n              } else {\n                dst[dstPtr++] = (FLOAT_DMEM)0.0;\n              }\n            }\n            if (formantAmplitudesLogRel_) {\n              if (faidxs[i - 1] >= 0) {\n                dst[dstPtr++] = harmonics_[faidxs[i - 1]].magnitudeLogRelF0;\n              } else {\n                dst[dstPtr++] = (FLOAT_DMEM)0.0; // -201.0;\n              }\n            }\n          } else if (i == 0) {\n            if (formantAmplitudesLinear_) {\n              dst[dstPtr++] = harmonics_[0].magnitude;\n            }\n            if (formantAmplitudesLogRel_) {\n              dst[dstPtr++] = harmonics_[0].magnitudeLogRelF0;\n            }\n          } else {\n            if (formantAmplitudesLinear_) {\n              dst[dstPtr++] = (FLOAT_DMEM)0.0;\n            }\n            if (formantAmplitudesLogRel_) {\n              dst[dstPtr++] = (FLOAT_DMEM)-201.0;\n            }\n          }\n        }\n      }\n      if (faidxs != NULL) {\n        free(faidxs);\n      }\n    } else {\n      if (outputLogRelMagnitudes_) {\n        for (int i = 0; i < nHarmonicMagnitudes_; i++) {\n          dst[dstPtr++] = logRelValueFloorUnvoiced_;\n        }\n      }\n      if (outputLinearMagnitudes_) {\n        for (int i = 0; i < nHarmonicMagnitudes_; i++) {\n          dst[dstPtr++] = (FLOAT_DMEM)0.0;\n        }\n      }\n      if (nHarmonicDifferences_ > 0 && (harmonicDifferencesLog_ || harmonicDifferencesLinear_)) {\n        for (int i = 0; i < nHarmonicDifferences_; i++) {\n          if (harmonicDifferencesLinear_) {\n            dst[dstPtr++] = (FLOAT_DMEM)1.0;\n          }\n          if (harmonicDifferencesLog_) {\n            dst[dstPtr++] = (FLOAT_DMEM)0.0;\n          }\n        }\n      }\n      if (formantAmplitudes_) {\n        if (formantAmplitudesLinear_) {\n          for (int i = formantAmplitudesStart_; i <= formantAmplitudesEnd_; i++) {\n            dst[dstPtr++] = (FLOAT_DMEM)0.0;\n          }\n        }\n        if (formantAmplitudesLogRel_) {\n          for (int i = formantAmplitudesStart_; i <= formantAmplitudesEnd_; i++) {\n            dst[dstPtr++] = logRelValueFloorUnvoiced_;\n          }\n        }\n      }\n    }\n  }\n  cnt_++;\n  return 1;\n}\n\n/*\n * F0 based harmonic detection\n *\n * ACF HNRs\n *\n * Get formant region peaks and formant amplitudes (add extra format frequency fields)\n *\n * Harmonic features (computed from harmonic peaks)\n *\n * General spectral peaks (non-harmonic)\n *\n * Features from these...\n *\n */\n\ncHarmonics::~cHarmonics()\n{\n  if (harmonics_ != NULL) {\n    free(harmonics_);\n  }\n  if (w_ != NULL) {\n    free(w_);\n  }\n  if (ip_ != NULL) {\n    free(ip_);\n  }\n  if (acfdata_ != NULL) {\n    free(acfdata_);\n  }\n  if (acf_ != NULL) {\n    free(acf_);\n  }\n  if (harmonicDifferences_ != NULL) {\n    free(harmonicDifferences_);\n  }\n}\n\n"
  },
  {
    "path": "src/lld/lpc.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nLPC, compute LPC coefficients from wave data (PCM) frames \n\n*/\n\n\n#include <lld/lpc.hpp>\n#include <math.h>\n\n#define MODULE \"cLpc\"\n\nSMILECOMPONENT_STATICS(cLpc)\n\nSMILECOMPONENT_REGCOMP(cLpc)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CLPC;\n  sdescription = COMPONENT_DESCRIPTION_CLPC;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"method\",\"This option sets the lpc method to use. Choose between: 'acf' acf (autocorrelation) method with Levinson-Durbin algorithm , 'burg' Burg method (N. Anderson (1978)) \",\"acf\");  \n    ct->setField(\"p\",\"Predictor order (= number of lpc coefficients)\",8);\n    ct->setField(\"saveLPCoeff\",\"1 = save LP coefficients to output\",1);\n    ct->setField(\"lpGain\",\"1 = save lpc gain (error) in output vector\",0);\n    ct->setField(\"saveRefCoeff\",\"1 = save reflection coefficients to output\",0);\n    ct->setField(\"residual\",\"1 = compute lpc residual signal and store in output frame\",0);\n    ct->setField(\"residualGainScale\",\"1 = scale lpc residual signal by lpc gain (divides each frame by gain)\",0);\n    ct->setField(\"forwardFilter\",\"1 = apply forward instead of inverse filter when computing residual\",0);\n    ct->setField(\"lpSpectrum\",\"1 = compute lp spectrum using 'lpSpecDeltaF' as frequency resolution or 'lpSpecBins' bins\",0);\n    ct->setField(\"forwardLPspec\",\"1 = compute forward filter transfer function as LP spectrum, instead of old default behaviour of computing spectrum of inverse filter.\", 1);\n    ct->setField(\"forwardLPspecFloor\",\"Floor value to add to all spectral bins of inverse LP spectrum when inverting the spectrum (1/x) to avoid division by 0. Default: 10^-13.\", 0.0000000000001);\n    ct->setField(\"lpSpecDeltaF\",\"frequency resolution of lp spectrum (only applicable if 'lpSpectrum=1')\",10.0);\n    ct->setField(\"lpSpecBins\",\"number of bins to compute lp spectrum for (overrides lpSpecDeltaF) (only applicable if 'lpSpectrum=1')\",100,0,0);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cLpc);\n}\n\nSMILECOMPONENT_CREATE(cLpc)\n\n//-----\n\ncLpc::cLpc(const char *_name) :\n  cVectorProcessor(_name),\n  p(0),\n  saveRefCoeff(0), acf(NULL),\n  lpCoeff(NULL), lastLpCoeff(NULL), refCoeff(NULL),\n  gbb(NULL), gb2(NULL), gaa(NULL),\n  lSpec(NULL), _ip(NULL), _w(NULL), latB(NULL)\n{\n\n}\n\nvoid cLpc::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n\n  const char *met = getStr(\"method\");\n  method = 0;\n  if (met != NULL) {\n    if (!strncasecmp(met,\"acf\",3)) {\n      method = LPC_METHOD_ACF;\n    } else if (!strncasecmp(met,\"burg\",4)) {\n      method = LPC_METHOD_BURG; \n    }\n  }\n\n  p=getInt(\"p\");\n  if (p<1) p=1;\n  SMILE_IDBG(2,\"predictor order p = %i\",p); \n\n  saveLPCoeff=getInt(\"saveLPCoeff\");\n  SMILE_IDBG(2,\"saveLPCoeff = %i\",saveLPCoeff); \n\n  lpGain=getInt(\"lpGain\");\n  SMILE_IDBG(2,\"lpGain = %i\",lpGain); \n\n  saveRefCoeff=getInt(\"saveRefCoeff\");\n  SMILE_IDBG(2,\"saveRefCoeff = %i\",saveRefCoeff); \n\n  residual=getInt(\"residual\");\n  residualGainScale=getInt(\"residualGainScale\");\n  SMILE_IDBG(2,\"residual = %i\",residual); \n\n  forwardRes=getInt(\"forwardFilter\");\n  SMILE_IDBG(2,\"forwardRes = %i\",forwardRes); \n\n  lpSpectrum = getInt(\"lpSpectrum\");\n  SMILE_IDBG(2,\"lpSpectrum = %i\",lpSpectrum); \n\n  forwardLPspec = getInt(\"forwardLPspec\");\n  forwardLPspecFloor = (FLOAT_DMEM)getDouble(\"forwardLPspecFloor\");\n\n  lpSpecDeltaF = getDouble(\"lpSpecDeltaF\");\n  SMILE_IDBG(2,\"lpSpecDeltaF = %f\",lpSpecDeltaF); \n  lpSpecBins = getInt(\"lpSpecBins\");\n  SMILE_IDBG(2,\"lpSpecBins = %i\",lpSpecBins); \n\n  latB = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*p);\n  lpCoeff = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*(p+1));\n  lastLpCoeff = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*(p));\n  refCoeff = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*p);\n  lastGain = 0.0;\n}\n\n// setup size of output vector (= predictor order p)\nint cLpc::setupNamesForField(int i, const char*name, long nEl)\n{\n  int n=0;\n\n  nInput_ = nEl;\n  inputStart_ = 0;\n\n  if (saveLPCoeff) {\n    writer_->addField( \"lpcCoeff\", p ); n += p;\n  }\n\n  if (saveRefCoeff) {\n    writer_->addField( \"reflectionCoeff\", p ); n += p;\n  }\n\n  if (lpGain) {\n    writer_->addField( \"lpGain\", 1 ); n += 1;\n  }\n\n  if (lpSpectrum) {\n    writer_->addField( \"lpSpectrum\", lpSpecBins ); n += lpSpecBins;\n    //TODO: set the spectral info struct of the lp spec and debug output the bin F0\n  }\n\n  if (residual) {\n    writer_->addField( \"lpcResidual\", nEl ); n += nEl;\n  }\n\n  return n;\n\n  // TODO: add reflection coeffs..\n // return cDataProcessor::setupNamesForField(i,name,p);\n}\n\n\n\n// return value: gain\nFLOAT_DMEM cLpc::calcLpc(const FLOAT_DMEM *x, long Nsrc, FLOAT_DMEM * lpc, long nCoeff, FLOAT_DMEM *refl)\n{\n  FLOAT_DMEM gain = 0.0;\n  if (method == LPC_METHOD_ACF) {\n    if (acf == NULL) acf = (FLOAT_DMEM *)malloc(sizeof(FLOAT_DMEM)*(nCoeff+1));\n    smileDsp_autoCorr(x, Nsrc, acf, nCoeff+1);\n    smileDsp_calcLpcAcf(acf, lpc, nCoeff, &gain, refl);\n  } \n  else if (method == LPC_METHOD_BURG) {\n    smileDsp_calcLpcBurg(x, Nsrc, lpc, nCoeff, &gain, &gbb, &gb2, &gaa);\n    if (refl != NULL) SMILE_IWRN(1,\"computation of reflection coefficients with Burg's LPC method is not yet implemented!\");\n  }\n  return gain;\n}\n\nint cLpc::processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi)\n{\n  // not yet implemented\n  return 0;\n}\n\nint cLpc::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  long myN = Ndst;\n  if (residual) myN = Ndst - Nsrc;\n\n  long expectedN = 0;\n  if (saveRefCoeff) expectedN += p;\n  if (saveLPCoeff) expectedN += p;\n  if (lpGain) expectedN += 1;\n  if (lpSpectrum) expectedN += lpSpecBins;\n  if (myN != expectedN) {\n    SMILE_IWRN(1,\"Ndst(-Nsrc) (=%i) <> expected value (%i) ! something is wrong.. the program might crash!\",myN,expectedN);\n  }\n\n  if (p<0) {\n    SMILE_IWRN(1,\"p<0! something is wrong...\");\n    p=0;\n  }\n\n  long i;\n  FLOAT_DMEM *dst0 = dst;\n  FLOAT_DMEM gain = 0.0;\n\n  if (saveRefCoeff) {\n    //calcLpc(const FLOAT_DMEM *x, long Nsrc, FLOAT_DMEM * lpc, long nCoeff, FLOAT_DMEM *refl) \n    gain = calcLpc(src, Nsrc, lpCoeff, p, refCoeff);\n    if (saveLPCoeff) {\n      for (i=0; i<p; i++) {\n        dst[i] = lpCoeff[i];\n        dst[i+p] = refCoeff[i];\n      }\n      dst += 2*p;\n    } else {\n      for (i=0; i<p; i++) {\n        dst[i] = refCoeff[i];\n      }\n      dst += p;\n    }    \n  } else {\n    if (saveLPCoeff || residual || lpSpectrum || lpGain) {\n      gain = calcLpc(src, Nsrc, lpCoeff, p, refCoeff);\n    }\n    if (saveLPCoeff) {\n      for (i=0; i<p; i++) {\n        dst[i] = lpCoeff[i];\n      }\n      dst += p;\n    }\n  }\n\n  if (lpGain) {\n    dst[0] = gain;\n    dst++;\n  }\n\n  if (lpSpectrum) {\n    /*\n      we compute the lp spectrum by zero padding and fft of the lp coefficients\n      the number of 0's we pad with determines our frequency resolution\n    */\n     // config parameters: lpSpecDeltaF & lpSpecBins (N or -1 for = nLpc)\n    //double fftN = (1.0/T) / lpSpecDeltaF;\n    if (lSpec == NULL) lSpec = (FLOAT_TYPE_FFT*)malloc(sizeof(FLOAT_TYPE_FFT) * lpSpecBins * 2);\n\n    // create padded vector\n    for (i=0; i<lpSpecBins*2; i++) {\n      lSpec[i] = 0.0;\n    }\n    lSpec[0] = 1.0;\n    for (i=1; i<=p; i++) {\n      lSpec[i] = (FLOAT_TYPE_FFT)lpCoeff[i-1];\n    }\n\n    // transform\n    if (_ip==NULL) _ip = (int *)calloc(1,sizeof(int)*(lpSpecBins*2+2));\n    if (_w==NULL) _w = (FLOAT_TYPE_FFT *)calloc(1,sizeof(FLOAT_TYPE_FFT)*(lpSpecBins*2*5)/4+2);\n    //perform FFT\n    rdft(lpSpecBins*2, 1, lSpec, _ip, _w);\n\n    // compute magnitude\n    int n=0;\n    if (forwardLPspec) {\n      // in order to obtain the forward filter, we need to invert the amplitudes\n      *(dst++) = (FLOAT_DMEM)fabs((FLOAT_DMEM)1.0 / (lSpec[0] + forwardLPspecFloor)); /* DC part */\n      for (i=2; i<(lpSpecBins-1)*2; i += 2) {\n        // save in output vector\n        *(dst++) = (FLOAT_DMEM)1.0 / ((FLOAT_DMEM)sqrt(lSpec[i]*lSpec[i] + lSpec[i+1]*lSpec[i+1]) + forwardLPspecFloor);\n      }\n      *(dst++) = (FLOAT_DMEM)fabs((FLOAT_DMEM)1.0 / (lSpec[1] + forwardLPspecFloor));; /* Nyquist freq. */\n    } else {\n      *(dst++) = (FLOAT_DMEM)fabs( lSpec[0] ); /* DC part */\n      for (i=2; i<(lpSpecBins-1)*2; i += 2) {\n        // save in output vector\n        *(dst++) = (FLOAT_DMEM)sqrt( lSpec[i]*lSpec[i] + lSpec[i+1]*lSpec[i+1] );\n      }\n      *(dst++) = (FLOAT_DMEM)fabs( lSpec[1] ); /* Nyquist freq. */\n    }\n  }\n\n  if (residual) {\n    if (forwardRes) { // apply forward LPC filter (recursive)\n      for (i=0; i<Nsrc; i++) {\n       dst[i] = smileDsp_invLattice(refCoeff, latB, p, src[i]);\n      }\n    } else { // apply inverse LPC filter (this yields the actual residual)\n      // alternative: lattice filter with reflection coefficients:\n      for (i=0; i<Nsrc; i++) {\n        FLOAT_DMEM tmp = smileDsp_lattice(refCoeff, latB, p, src[i], NULL);\n        if (residualGainScale) {\n          if (gain > 0.0) {\n            dst[i] = tmp / gain;\n          } else {\n            dst[i] = 0.0;\n          }\n        } else {\n          dst[i] = tmp;\n        }\n      }\n    }\n    lastGain = gain;\n  }\n\n  return 1;\n}\n\n\ncLpc::~cLpc()\n{\n  if (acf != NULL) free(acf);\n  if (lpCoeff != NULL) free(lpCoeff);\n  if (lastLpCoeff != NULL) free(lastLpCoeff);\n  if (refCoeff != NULL) free(refCoeff);\n  if (lSpec != NULL) free(lSpec);\n  if (latB != NULL) free(latB);\n  if (gbb != NULL) free(gbb);\n  if (gb2 != NULL) free(gb2);\n  if (gaa != NULL) free(gaa);\n  if (_ip!=NULL) free(_ip);\n  if (_w!=NULL) free(_w);\n}\n\n"
  },
  {
    "path": "src/lld/lsp.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n/*****************************************************************\n  This code uses functions from the Speex codec library,\n  which are distributed under the following license terms:\n\nCopyright 2002-2008     Xiph.org Foundation\nCopyright 2002-2008     Jean-Marc Valin\nCopyright 2005-2007     Analog Devices Inc.\nCopyright 2005-2008     Commonwealth Scientific and Industrial Research\n                        Organisation (CSIRO)\nCopyright 1993, 2002, 2006 David Rowe\nCopyright 2003          EpicGames\nCopyright 1992-1994     Jutta Degener, Carsten Bormann\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n\n- Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n\n- Redistributions in binary form must reproduce the above copyright\nnotice, this list of conditions and the following disclaimer in the\ndocumentation and/or other materials provided with the distribution.\n\n- Neither the name of the Xiph.org Foundation nor the names of its\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR\nCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\nEXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\nPROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\nPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n****************************/\n\n/*  openSMILE component: cLsp\nComputes LSP (line spectral pairs) from LPC coefficients\n*/\n\n\n#include <lld/lsp.hpp>\n#include <math.h>\n\n#define MODULE \"cLsp\"\n\nSMILECOMPONENT_STATICS(cLsp)\n\nSMILECOMPONENT_REGCOMP(cLsp)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CLSP;\n  sdescription = COMPONENT_DESCRIPTION_CLSP;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    //ct->setField(\"p\",\"order of predictor (= number of lpc coefficients)\",8);\n    ct->setField(\"processArrayFields\",NULL,0);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cLsp);\n}\n\nSMILECOMPONENT_CREATE(cLsp)\n\n//-----\n\ncLsp::cLsp(const char *_name) :\n  cVectorProcessor(_name),\n  nLpc(0),\n  lpcIdx(-1)\n{\n}\n\nvoid cLsp::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n\n  //p=getInt(\"p\");\n  //SMILE_IDBG(2,\"predictor order p = %i\",p); \n}\n\n/*\nint cLsp::setupNamesForField(int i, const char*name, long nEl)\n{\n  return cDataProcessor::setupNamesForField(i,name,nEl);\n}\n*/\n\n/*\nint cLsp::myFinaliseInstance()\n{\n//  frameSizeFrames = reader->getLevelN();\n  return cVectorProcessor::myFinaliseInstance();\n}\n*/\n\nint cLsp::processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi)\n{\n  // not yet implemented\n  return 0;\n}\n\nFLOAT_DMEM cLsp::cheb_poly_eva(FLOAT_DMEM *coef, FLOAT_DMEM x, int m)\n{\n   int k;\n   FLOAT_DMEM b0, b1, tmp;\n\n   /* Initial conditions */\n   b0=0; /* b_(m+1) */\n   b1=0; /* b_(m+2) */\n   x*=2;\n   /* Calculate the b_(k) */\n   for (k=m;k>0;k--) {\n      tmp=b0;                           /* tmp holds the previous value of b0 */\n      b0=x*b0-b1+coef[m-k];    /* b0 holds its new value based on b0 and b1 */\n      b1=tmp;                           /* b1 holds the previous value of b0 */\n   }\n   return(-b1+(FLOAT_DMEM)0.5*x*b0+coef[m]);\n}\n\n#define SIGN_CHANGE(a,b) (((a)*(b))<0.0)\n#define LPC_SCALING  1.f\n#define FREQ_SCALE 1.0\n#define X2ANGLE(x) (acos(x))\n\n#define LSP_DELTA1 .2\n#define LSP_DELTA2 .05\n\n/*  float *a                    lpc coefficients                        */\n/*  int lpcrdr                  order of LPC coefficients (10)          */\n/*  float *freq                 LSP frequencies in the x domain         */\n/*  int nb                      number of sub-intervals (4)             */\n/*  float delta                 grid spacing interval (0.02)            */\nint cLsp::lpc_to_lsp (const FLOAT_DMEM *a, int lpcrdr, FLOAT_DMEM *freq, int nb, FLOAT_DMEM delta)\n{\n    FLOAT_DMEM temp_xr,xl,xr,xm=0;\n    FLOAT_DMEM psuml,psumr,psumm,temp_psumr /*,temp_qsumr*/;\n    int i,j,m,flag,k;\n    FLOAT_DMEM *Q = NULL;                   /* ptrs for memory allocation           */\n    FLOAT_DMEM *P = NULL;\n    FLOAT_DMEM *Q16 = NULL;         /* ptrs for memory allocation           */\n    FLOAT_DMEM *P16 = NULL;\n    FLOAT_DMEM *px;                   /* ptrs of respective P'(z) & Q'(z)     */\n    FLOAT_DMEM *qx;\n    FLOAT_DMEM *p;\n    FLOAT_DMEM *q;\n    FLOAT_DMEM *pt;                   /* ptr used for cheb_poly_eval()\n                                whether P' or Q'                        */\n    int roots=0;                /* DR 8/2/94: number of roots found     */\n    flag = 1;                   /*  program is searching for a root when,\n                                1 else has found one                    */\n    m = lpcrdr/2;               /* order of P'(z) & Q'(z) polynomials   */\n\n    /* Allocate memory space for polynomials */\n    Q = (FLOAT_DMEM*) calloc(1,sizeof(FLOAT_DMEM)*(m+1));\n    P = (FLOAT_DMEM*) calloc(1,sizeof(FLOAT_DMEM)*(m+1));\n\n    /* determine P'(z)'s and Q'(z)'s coefficients where\n      P'(z) = P(z)/(1 + z^(-1)) and Q'(z) = Q(z)/(1-z^(-1)) */\n\n    px = P;                      /* initialise ptrs                     */\n    qx = Q;\n    p = px;\n    q = qx;\n\n    *px++ = LPC_SCALING;\n    *qx++ = LPC_SCALING;\n    for(i=0;i<m;i++) {\n       *px++ = (a[i]+a[lpcrdr-1-i]) - *p++;\n       *qx++ = (a[i]-a[lpcrdr-1-i]) + *q++;\n    }\n    px = P;\n    qx = Q;\n    for(i=0;i<m;i++) {\n       *px = 2**px;\n       *qx = 2**qx;\n       px++;\n       qx++;\n    }\n\n    px = P;                     /* re-initialise ptrs                   */\n    qx = Q;\n    /* now that we have computed P and Q convert to 16 bits to\n       speed up cheb_poly_eval */\n    P16 = P;\n    Q16 = Q;\n\n    /* Search for a zero in P'(z) polynomial first and then alternate to Q'(z).\n    Keep alternating between the two polynomials as each zero is found  */\n\n    xr = 0;                     /* initialise xr to zero                */\n    xl = FREQ_SCALE;                    /* start at point xl = 1                */\n\n    for(j=0;j<lpcrdr;j++){\n        if(j&1)                 /* determines whether P' or Q' is eval. */\n            pt = Q16;\n        else\n            pt = P16;\n\n        psuml = cheb_poly_eva(pt,xl,m);   /* evals poly. at xl    */\n        flag = 1;\n        while(flag && (xr >= -FREQ_SCALE)){\n           FLOAT_DMEM dd;\n           /* Modified by JMV to provide smaller steps around x=+-1 */\n\n           dd=delta*((FLOAT_DMEM)1.0-(FLOAT_DMEM)0.9*xl*xl);\n           if (fabs(psuml)<.2)\n              dd *= (FLOAT_DMEM)0.5;\n\n           xr = xl - dd;                          /* interval spacing     */\n            psumr = cheb_poly_eva(pt,xr,m);/* poly(xl-delta_x)    */\n            temp_psumr = psumr;\n            temp_xr = xr;\n\n   /* if no sign change increment xr and re-evaluate poly(xr). Repeat til\n    sign change.\n    if a sign change has occurred the interval is bisected and then\n    checked again for a sign change which determines in which\n    interval the zero lies in.\n    If there is no sign change between poly(xm) and poly(xl) set interval\n    between xm and xr else set interval between xl and xr and repeat till\n    root is located within the specified limits                         */\n\n            if(SIGN_CHANGE(psumr,psuml))\n            {\n                roots++;\n\n                psumm=psuml;\n                for(k=0;k<=nb;k++){\n                    xm = (FLOAT_DMEM)0.5*(xl+xr);            /* bisect the interval  */\n                    psumm=cheb_poly_eva(pt,xm,m);\n                    /*if(psumm*psuml>0.)*/\n                    if(!SIGN_CHANGE(psumm,psuml))\n                    {\n                        psuml=psumm;\n                        xl=xm;\n                    } else {\n                        psumr=psumm;\n                        xr=xm;\n                    }\n                }\n\n               /* once zero is found, reset initial interval to xr      */\n               if (xm>1.0) { xm = 1.0; } /* <- fixed a possible NAN issue here...? */\n               else if (xm<-1.0) { xm = -1.0; }\n               freq[j] = X2ANGLE(xm);\n               xl = xm;\n               flag = 0;                /* reset flag for next search   */\n            }\n            else{\n                psuml=temp_psumr;\n                xl=temp_xr;\n            }\n        }\n    }\n    if (P!=NULL) free(P);\n    if (Q!=NULL) free(Q);\n    return(roots);\n}\n\nint cLsp::setupNewNames(long nEl)\n{\n  nLpc = 0;\n  const FrameMetaInfo *fmeta = reader_->getFrameMetaInfo();\n  if (fmeta != NULL) {\n    long field = fmeta->findFieldByPartialName( \"lpcCoeff\" );\n    if (field >= 0) {\n      lpcIdx = fmeta->fieldToElementIdx( field );\n      nLpc = fmeta->field[field].N;\n      writer_->addField( \"lspFreq\", nLpc );\n      namesAreSet_=1;\n      return nLpc;\n    }\n  }\n  SMILE_IERR(1,\"could not find required field 'lpcCoeff' in input data!\");\n  return nLpc;\n}\n\nint cLsp::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  // (TODO:) check if Ndst >= Nsrc!\n  if (Ndst < Nsrc ) return 0;\n\n  if ((lpcIdx == -1)||(nLpc <= 0)) {\n    //if (!warned) SMILE_IWRN(1,\"field 'lpcCoeff' not found in input (is the read level an lpc level ??)\");\n    // warned = 1;\n    return 0;\n  }\n\n  /* LPC to LSPs (x-domain) transform */\n  int roots;\n  roots = lpc_to_lsp (src+lpcIdx, nLpc, dst, 10, (FLOAT_DMEM)LSP_DELTA1);\n  if (roots!=nLpc) {\n    roots = lpc_to_lsp (src+lpcIdx, nLpc, dst, 10, (FLOAT_DMEM)LSP_DELTA2);  // nLpc was Nsrc\n    if (roots!=nLpc) {\n      int i;\n      for (i=roots;i<nLpc;i++) {\n        dst[i]=0.0;\n      }\n    }\n  }\n\n  return 1;\n}\n\n\ncLsp::~cLsp()\n{\n}\n\n\n"
  },
  {
    "path": "src/lld/pitchDirection.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nread pitch data and compute pitch direction estimates\ninput fields: F0 or F0env\n\n\nThis component detects:\n\npseudo-syllables, pseudo-syllable rate\n\npitch contour per pseudo syllable:\nrise/fall\nfall/rise\nrise\nfall\nflat\n\ngenral pitch contour per syllable\nrise\nfall\nflat\n\nsyllable length, mean syllable length (TODO: use energy here and adjacent syllables for more accurate results..?)\n\n*/\n\n\n#include <lld/pitchDirection.hpp>\n\n#define MODULE \"cPitchDirection\"\n\nSMILECOMPONENT_STATICS(cPitchDirection)\n\nSMILECOMPONENT_REGCOMP(cPitchDirection)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n    scname = COMPONENT_NAME_CPITCHDIRECTION;\n  sdescription = COMPONENT_DESCRIPTION_CPITCHDIRECTION;\n\n  // we inherit cDataProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataProcessor\")\n\n    SMILECOMPONENT_IFNOTREGAGAIN( {}\n  //ct->setField(\"offset\",\"offset that this dummy component adds to the values\",1.0);\n  ct->setField(\"ltbs\",\"The size of the long-term average buffer in seconds\",0.20);\n  ct->setField(\"stbs\",\"The size of the short-term average buffer in seconds\",0.05);\n  ct->setField(\"directionMsgRecp\",\"Recipient component(s) for per syllable event-based pitch direction message (rise/fall/rise-fall/fall-rise message are sent only if and as ofter as a such event occurs on a syllable)\",(const char *)NULL);\n  ct->setField(\"speakingRateBsize\",\"The buffer size for computation of speaking rate (in input frames, typical frame rate 100 fps)\",100);\n  ct->setField(\"F0direction\",\"1 = enable output of F0 direction as numeric value (fall: -1.0 / flat: 0.0 / rise: 1.0)\",1);\n  ct->setField(\"directionScore\",\"1 = enable output of F0 direction score (short term mean - long term mean)\",1);\n  ct->setField(\"speakingRate\",\"1 = enable output of current speaking rate in Hz (is is output for every frame, thus, a lot of redundancy here)\",0);\n  ct->setField(\"F0avg\",\"1 = enable output of long term average F0\",0);\n  ct->setField(\"F0smooth\",\"1 = enable output of exponentially smoothed F0\",0);\n  ct->setField(\"onlyTurn\",\"1 = send pitch direction messages (directionMsgRecp) only during speech turns (voice activity) (according to turnStart/turnEnd messages received from cTurnDetector)\",0);\n  ct->setField(\"turnStartMessage\",\"Use this option to define a custom message name for turn start messages, i.e. if you want to use voice activity start/end messages instead\",\"turnStart\");\n  ct->setField(\"turnEndMessage\",\"Use this option to define a custom message name for turn end messages, i.e. if you want to use voice activity start/end messages instead\",\"turnEnd\");\n  ct->setField(\"F0fieldname\",\"The name of the F0 data field to use for syllable detection and pitch direction analysis\",\"F0\");\n  ct->setField(\"F0envFieldname\",\"The name of the F0 envelope data field to use for syllable detection and pitch direction analysis\",\"F0env\");\n  ct->setField(\"LoudnessFieldname\",\"The name of the 'Loudness' data field (see cIntensity component) to use for syllable nuclei detection\",\"loudness\");\n  ct->setField(\"RMSenergyFieldname\",\"The name of the RMS energy data field to use for syllable detection\",\"pcm_RMSenergy\");\n\n  //TODO: add invertTurn option\n  )\n\n    SMILECOMPONENT_MAKEINFO(cPitchDirection);\n}\n\n\nSMILECOMPONENT_CREATE(cPitchDirection)\n\n//-----\n\ncPitchDirection::cPitchDirection(const char *_name) :\ncDataProcessor(_name), myVec(NULL), F0field(-1), F0envField(0), \nstbuf(NULL), ltbuf(NULL), F0non0(0.0), lastF0non0(0.0),\nltbsFrames(2),stbsFrames(1),\nstbufPtr(0), ltbufPtr(0),\nbufInit(0),\ninsyl(0),\nf0cnt(0), lastE(0.0),\nstartE(0.0), maxE(0.0), minE(0.0), endE(0.0),\nsylen(0), maxPos(0), minPos(0), sylenLast(0),\ninpPeriod(0.0),\ntimeCnt(0.0), sylCnt(0), lastSyl(100.0),\nstartF0(0.0), lastF0(0.0), maxF0(0.0), minF0(0.0),\nmaxF0Pos(0), minF0Pos(0),\nlongF0Avg(0.0),\ndirectionMsgRecp(NULL),\nspeakingRateBsize(20),\nF0directionOutp(0),\ndirectionScoreOutp(0),\nspeakingRateOutp(0),\nF0avgOutp(0), F0smoothOutp(0),\nnEnabled(0), \nisTurn(0), onlyTurn(0), resetTurnData(0),\nturnStartMessage(NULL), turnEndMessage(NULL), invertTurn(0),\ncurSpkRate(0), nBuf0(0), nBuf1(0), nSyl0(0), nSyl1(0)\n{\n}\n\nvoid cPitchDirection::fetchConfig()\n{\n  cDataProcessor::fetchConfig();\n\n  stbs = (FLOAT_DMEM)getDouble(\"stbs\");\n  ltbs = (FLOAT_DMEM)getDouble(\"ltbs\");\n  if (ltbs < stbs) {\n    ltbs = stbs;\n    SMILE_IWRN(2,\"long term buffer cannot be smaller than short term buffer! please check the config! (I will set ltbs=stbs)\");\n  }\n  SMILE_IDBG(2,\"stbs = %f\",stbs);\n  SMILE_IDBG(2,\"ltbs = %f\",ltbs);\n\n  directionMsgRecp = getStr(\"directionMsgRecp\");\n  speakingRateBsize = getInt(\"speakingRateBsize\");\n\n  F0directionOutp = getInt(\"F0direction\");\n  directionScoreOutp = getInt(\"directionScore\");\n  speakingRateOutp = getInt(\"speakingRate\");\n  F0avgOutp = getInt(\"F0avg\");\n  F0smoothOutp = getInt(\"F0smooth\");\n\n  onlyTurn = getInt(\"onlyTurn\");\n\n  turnStartMessage = getStr(\"turnStartMessage\");\n  turnEndMessage = getStr(\"turnEndMessage\");\n\n  //TODO: add invertTurn option\n\n  // load all configuration parameters you will later require fast and easy access to here:\n\n  //offset = getDouble(\"offset\");\n  // note, that it is \"polite\" to output the loaded parameters at debug level 2:\n  //SMILE_DBG(2,\"offset = %f\",offset);\n}\n\n/*  This method is rarely used. It is only there to improve readability of component code.\nIt is called from cDataProcessor::myFinaliseInstance just before the call to configureWriter.\nI.e. you can do everything that you would do here, also in configureWriter()\nHowever, if you implement the method, it must return 1 in order for the configure process to continue!\n*/\n/*\nint cPitchDirection::configureReader() \n{\nreturn 1;\n}\n*/\n\nint cPitchDirection::configureWriter(sDmLevelConfig &c) \n{\n  // if you would like to change the write level parameters... do so HERE:\n\n  //c.T = 0.01; /* don't forget to set the write level sample/frame period */\n  //c.nT = 100; /* e.g. 100 frames buffersize for ringbuffer */\n\n  if (c.T != 0.0) {\n    stbsFrames = (long)ceil(stbs / c.T);\n    ltbsFrames = (long)ceil(ltbs / c.T);\n  } else {\n    stbsFrames = (long)round(stbs);\n    ltbsFrames = (long)round(ltbs);\n  }\n  inpPeriod = c.T;\n\n  return 1; /* success */\n}\n\n/* You shouldn't need to touch this....\nint cPitchDirection::myConfigureInstance()\n{\nint ret = cDataProcessor::myConfigureInstance();\nreturn ret;\n}\n*/\n\n/*\nDo what you like here... this is called after the input names and number of input elements have become available, \nso you may use them here.\n*/\n/*\nint cPitchDirection::dataProcessorCustomFinalise()\n{\n\nreturn 1;\n}\n*/\n\n\n/* \nUse setupNewNames() to freely set the data elements and their names in the output level\nThe input names are available at this point, you can get them via reader->getFrameMeta()\nPlease set \"namesAreSet\" to 1, when you do set names\n*/\n\nint cPitchDirection::setupNewNames(long nEl) \n{\n  // find required input fields\n  const FrameMetaInfo * fmeta = reader_->getFrameMetaInfo();\n  F0field = fmeta->findField( getStr(\"F0fieldname\") ); // ByPartialName\n  F0envField = fmeta->findField( getStr(\"F0envFieldname\") ); // ByPartialName\n  LoudnessField = fmeta->findFieldByPartialName( getStr(\"LoudnessFieldname\") ); // ByPartialName\n  RMSField = fmeta->findFieldByPartialName( getStr(\"RMSenergyFieldname\") ); // ByPartialName\n\n  if (F0field < 0) { SMILE_IERR(1,\"no input field '%s' found, this is required! Use a pitch component as input and check the name, see the 'F0fieldname' option.\",getStr(\"F0fieldname\")); F0field=0; }\n  if (F0envField < 0) { SMILE_IERR(1,\"no input field '%s' found, this is required! Use a pitch component as input and check the name, see the 'F0envFieldname' option.\", getStr(\"F0envFieldname\")); F0envField = 0; }\n  if ((LoudnessField < 0)&&(RMSField<0)) { SMILE_IERR(1,\"no input field 'RMSenergy' or 'loudness' found, one of these is required! Use an energy or intensity component as second input.\"); }\n\n  int n=0;\n\n  if (F0directionOutp) {\n    writer_->addField(\"F0direction\"); n++;\n  }\n  if (directionScoreOutp) { // smean-lmean\n    writer_->addField(\"directionScore\"); n++;\n  }\n  if (speakingRateOutp) {\n    writer_->addField(\"speakingRate\"); n++;\n  }\n  if (F0avgOutp) {\n    writer_->addField(\"F0avg\"); n++;\n  }\n  if (F0smoothOutp) {\n    writer_->addField(\"F0smooth\"); n++;\n  }\n\n  if (n==0) { // force at least one field\n    F0directionOutp=1;\n    writer_->addField(\"F0direction\"); n++;\n    SMILE_IWRN(1,\"no output enabled, at least one output field is required though. Enabling F0directionOutp !\");\n  }\n\n  nEnabled = n;\n\n  namesAreSet_ = 1;\n  return n;\n}\n\n\n/*\nIf you don't use setupNewNames() you may set the names for each input field by overwriting the following method:\n*/\n/*\nint cPitchDirection::setupNamesForField( TODO )\n{\n// DOC TODO...\n}\n*/\n\nint cPitchDirection::myFinaliseInstance()\n{\n  int ret = cDataProcessor::myFinaliseInstance();\n  if (ret) {\n    // do all custom init stuff here... \n    // e.g. allocating and initialising memory (which is not used before, e.g. in setupNames, etc.),\n    // loading external data, \n    // etc.\n\n    // allocate memory for long/short term average buffers\n    if (stbs > 0) {\n      stbuf = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*stbsFrames);\n    }\n    if (ltbs > 0) {\n      ltbuf = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*ltbsFrames);\n    }\n\n  }\n  return ret;\n}\n\n\nint cPitchDirection::processComponentMessage( cComponentMessage *_msg )\n{\n  const char * endM = NULL;\n  if (turnEndMessage == NULL) endM = \"turnEnd\";\n  else endM = turnEndMessage;\n\n  if (isMessageType(_msg,endM)) {\n    if (invertTurn) {\n      isTurn = 1; resetTurnData = 1;\n    } else {\n      isTurn = 0;\n    }\n    SMILE_IDBG(3,\"received turnEnd (%s)\",endM);\n    return 1;\n  }\n\n  const char * startM = NULL;\n  if (turnStartMessage == NULL) startM = \"turnStart\";\n  else startM = turnStartMessage;\n\n  if (isMessageType(_msg,startM)) {\n    if (invertTurn) {\n      isTurn = 0;\n    } else {\n      isTurn = 1;\n      resetTurnData = 1;\n    }\n    SMILE_IDBG(3,\"received turnStart (%s)\",startM);\n    return 1;\n  }\n  return 0;\n}\n\n\nvoid cPitchDirection::sendPitchDirectionResult(int _result, double _smileTime, const char * _directionMsgRecp) \n{\n  if (_directionMsgRecp != NULL) {\n    int _isTurn;\n    lockMessageMemory();\n    _isTurn = isTurn;\n    unlockMessageMemory();\n\n    if (isTurn||(!onlyTurn)) {\n\n      cComponentMessage _msg(\"pitchDirection\");\n      _msg.userTime1 = _smileTime;\n      _msg.intData[0] = _result;\n     // printf(\"XXXXX send pitch %i\\n\\n\",_result);\n      sendComponentMessage(_directionMsgRecp, &_msg);\n\n    }\n  }\n}\n\n//TODO: sync with turn status...\n// receive turn messages\n// send only if turn=1\n//\n\nint cPitchDirection::myTick(long long t)\n{\n  /* actually process data... */\n  SMILE_IDBG(4,\"tick # %i, processing value vector\",t);\n\n  // get next frame from dataMemory\n  cVector *vec = reader_->getNextFrame();\n\n  if (vec == NULL) return 0;\n\n  // ALGO:\n  // Rising/Falling pitch is determined at end of vowels (end of pitch regions)\n  // using two moving window averages (long term and short term)\n  // We use intensity/loudness, (F0env,) and F0 to determine vowel/syllable positions\n\n  FLOAT_DMEM f0eNow=0.0;\n  FLOAT_DMEM f0now =0.0;\n  FLOAT_DMEM loudn =0.0;\n  if (F0envField >= 0) f0eNow = vec->dataF[F0envField];\n  if (F0field >= 0) f0now = vec->dataF[F0field];\n  if (LoudnessField >= 0) loudn = vec->dataF[LoudnessField];\n  else if (RMSField >= 0) loudn = vec->dataF[RMSField];\n  /*\n  #ifdef DEBUG\n  float dbg[3];\n  dbg[0] = (float)f0eNow;\n  dbg[1] = (float)f0s;\n  if (!insyl) dbg[1] = 0.0;\n  dbg[2] = (float)loudn;\n  //saveFloatVector_csv(\"pitchdir.dat\",dbg,3,1);\n  #endif\n  */\n  // f0now == 0 ==> unvoiced\n\n  if (f0now != 0.0) {\n    lastF0non0 = F0non0;\n    F0non0 = f0now;\n  }\n\n  /* -- speaking rate buffer cycling -- */\n  if (nBuf0 < speakingRateBsize) {\n    nBuf0++; \n    if (nBuf0 == speakingRateBsize) {\n      curSpkRate = (double)nSyl0 / ( (double)nBuf0 * reader_->getLevelT());\n    }\n  }\n  if (nBuf1 < speakingRateBsize*2) nBuf1++;\n  else {\n    curSpkRate = (double)nSyl1 / ( (double)nBuf1 * reader_->getLevelT());\n    nBuf1 -= nBuf0;\n    nSyl1 -= nSyl0;\n    nSyl0 = 0;\n    nBuf0 = 0;\n  }\n  /* ---------*/\n\n  // only if first syllable encountered and last syllable encountered not longer than X sec. ago\n  lastSyl += inpPeriod;\n  if (lastSyl < 0.8 ) { \n    timeCnt += inpPeriod;\n  } else {\n    timeCnt = 0.0;\n  }\n\n  long i; \n  // fill buffer:\n  if (!bufInit) {\n    stbuf[stbufPtr] = f0eNow;\n    ltbuf[ltbufPtr] = f0eNow;\n    if (++stbufPtr >= stbsFrames) stbufPtr = 0;\n\n    if (++ltbufPtr >= ltbsFrames) {\n      ltbufPtr = 0;\n      bufInit = 1;\n      // compute initial sums!\n      ltSum=0.0; stSum=0.0;\n      for (i=0; i<ltbsFrames; i++) {\n        ltSum+=ltbuf[i];\n      }\n      for (i=0; i<stbsFrames; i++) {\n        stSum+=stbuf[i];\n      }\n    }\n  } else {\n    // find pseudo-syllables (energetic voiced segments)\n    if (!insyl) { // in unvoiced part\n      if (f0now > 0.0) { // detect beginning\n        if (f0cnt >= 1) {\n          /* syl. start */\n\n          if (nBuf0 < speakingRateBsize) nSyl0++;  /* syllable rate counters */\n          nSyl1++;  /* syllable rate counters */\n\n          insyl = 1; sylen = f0cnt;\n          f0cnt=0; lastSyl = 0.0;\n          startF0 = (lastF0+f0now)*(FLOAT_DMEM)0.5;\n          f0s = startF0;\n          maxF0 = MAX(lastF0,f0now);\n          minF0 = MIN(lastF0,f0now);\n          maxF0Pos = 0;\n          minF0Pos = 0;\n          nFall=0; nRise=0; nFlat=0;\n        }\n        f0cnt++; \n        if (startE == 0.0) { \n          minE = maxE = startE = lastE;\n        }\n      } else { f0cnt = 0; startE = 0.0; maxE = 0.0; minE = 0.0; }\n    } else { // in syllable part\n      if (f0now <= 0.0) { // detect end\n        if (f0cnt >= 1) {\n\n          /* syl. end */\n          // syllable energy verification:\n\n          /*\n          if (( 0.5*(startE+endE) < 0.975*maxE )&&( MIN(startE,endE) < 1.05*minE )) {\n          printf(\"E-verify OK\\n\");\n          }\n          */\n\n          // other stuff:\n          insyl = 0;\n\n          if (sylen > 3) {\n            endE = lastE;\n            sylenLast = sylen-f0cnt;\n            f0cnt=0; \n            sylCnt++; lastSyl=0.0;\n            /* //syllable rate computed with each new syllable\n            if (timeCnt > 0.0) {\n              printf(\"pseudo-syllable nucleus end (sylen=%i): syl rate = %f Hz\\n\",sylen,(double)sylCnt / timeCnt);\n            }\n            */\n\n            // pitch contour classification:\n            FLOAT_DMEM endF0 = f0s; //0.5*(F0non0+lastF0non0);\n            //lastF0 : end\n            //startF0 : start\n            // maxF0 / minF0 : start/end\n            FLOAT_DMEM conf = (FLOAT_DMEM)sylen;\n            if (conf > 10.0) conf = 10.0;\n            conf *= 30.0;\n            int score=0; int rf=0; int result = -1;\n\n            // determine type of pitch rise/fall\n\n            if (endF0 > (FLOAT_DMEM)pow(startF0,(FLOAT_DMEM)1.01)) {\n              if (startF0 != 0.0) \n                score = (int)((endF0-startF0)/startF0*conf);\n              if (score >= 1) {\n//                printf(\"Syl: Rise %i\\n\",score);\n                rf=1;\n                result = 0;\n              }\n            }\n            else if (endF0 < (FLOAT_DMEM)pow(startF0,(FLOAT_DMEM)(1.0/1.01))) {\n              if (startF0 != 0.0) \n                score = (int)((startF0-endF0)/startF0*conf);\n              if (score >= 1) {\n//                printf(\"Syl: Fall %i\\n\",score);\n                rf=1;\n                result = 1;\n              }\n              //printf(\"Syl: Fall %i\\n\",(int)((startF0-endF0)/startF0*conf));\n            }\n\n            if ((!rf)&&(maxF0 > (FLOAT_DMEM)pow(endF0,(FLOAT_DMEM)1.01))&&(maxF0 > (FLOAT_DMEM)pow(startF0,(FLOAT_DMEM)1.01))) {\n              if (startF0 != 0.0) \n//                printf(\"Syl: Rise->Fall %i , %i\\n\",(int)((maxF0-startF0)/startF0*conf),(int)((maxF0-endF0)/startF0*conf));\n                if (result >= 0) {\n                  if (score < 15) result = 2;\n                } else { result = 2; }\n            }\n            if ((!rf)&&(minF0 < (FLOAT_DMEM)pow(endF0,(FLOAT_DMEM)(1.0/1.01)))&&(minF0 < (FLOAT_DMEM)pow(startF0,(FLOAT_DMEM)(1.0/1.01)))) {\n              if (startF0 != 0.0) \n                //printf(\"Syl: Fall->Rise %i , %i\\n\",(int)((startF0-minF0)/startF0*conf),(int)((endF0-minF0)/startF0*conf));\n                if (result >= 0) {\n                  if (score < 15) result = 3;\n                } else { result = 3; }\n            }\n\n            // check if result is in line with majority vote over syllable\n            if ((result == 0)||(result==1)) {\n\n              if ((nFall>nRise)&&(nFall>nFlat)) {\n                //printf(\"MajVote: Falling\\n\");\n                if (result == 0) result = -1;\n              } else\n                if ((nRise>nFall)&&(nRise>nFlat)) {\n                  //printf(\"MajVote: Rising\\n\");\n                  if (result == 1) result = -1;\n                } else { \n                  //printf(\"MajVote: Flat\\n\"); \n                  result = -1; \n                }\n\n            }\n\n            // send result:\n            if (result >= 0)  {\n              if (result == 0) printf(\"  __^^__ pitch UP\\n\");\n              else if (result == 1) printf(\"  __vv__ pitch DOWN\\n\");\n              sendPitchDirectionResult(result,vec->tmeta->smileTime,directionMsgRecp);\n            }\n\n          }\n        }\n        f0cnt++;\n      } else { f0cnt = 0; }\n\n      if (insyl) { // check if status has changed..\n        //monitor energy levels: loudness must be low at beginning and end, and higher in the middle\n        if (loudn > maxE) { maxE = loudn; maxPos = sylen; }\n        if (loudn < minE) { minE = loudn; minPos = sylen; }\n        f0s = (FLOAT_DMEM)(0.5)*f0s + (FLOAT_DMEM)(0.5) * F0non0; /* smoothed F0 */\n        if (f0s > maxF0) { maxF0 = f0s; maxF0Pos = sylen; }\n        if (f0s < minF0) { minF0 = f0s; minF0Pos = sylen; }\n        sylen++; lastSyl=0.0;\n        if (longF0Avg == 0.0) longF0Avg = F0non0;\n        longF0Avg = (FLOAT_DMEM)(0.02)*F0non0 + (FLOAT_DMEM)(0.98)*longF0Avg;\n\n        double lmean = ltSum/(double)ltbsFrames;\n        double smean = stSum/(double)stbsFrames;\n        if (smean > pow(lmean,1.02)) {\n          nRise++;\n          //dir = 1.0;\n        } else \n          if (smean < pow(lmean,1.0/1.02)) {\n            nFall++;\n            //dir = -1.0;\n          } else {\n            nFlat++;\n            //dir = 0.0;\n          }\n      }\n    }\n    lastF0 = f0now;\n    lastE = loudn;\n\n\n  }\n\n  FLOAT_DMEM dir = 0.0;\n  double smean = 0.0, lmean = 0.0;\n\n  if (insyl) { //(f0now > 0.0) {\n    //// cycle buffer and evaluate data\n    // mean of ltbuf:\n    ltSum -= (double)ltbuf[ltbufPtr];\n    ltbuf[ltbufPtr] = f0s;\n    ltSum += (double)f0s;\n    if (++ltbufPtr >= ltbsFrames) ltbufPtr = 0;\n\n    // mean of stbuf:\n    stSum -= (double)stbuf[stbufPtr];\n    stbuf[stbufPtr] = f0s;\n    stSum += (double)f0s;\n    if (++stbufPtr >= stbsFrames) stbufPtr = 0;\n\n    // detect rising/falling pitch continuously\n    lmean = ltSum/(double)ltbsFrames;\n    smean = stSum/(double)stbsFrames;\n    if (smean > pow(lmean,1.01)) {\n      //printf(\"PITCH : rising\\n\"); \n      dir = 1.0;\n    } else \n      if (smean < pow(lmean,1.0/1.01)) {\n        //printf(\"PITCH : falling\\n\"); \n        dir = -1.0;\n      } else {\n        //printf(\"PITCH : flat\\n\"); \n        dir = 0.0;\n      }\n  }\n\n  if (myVec == NULL) myVec = new cVector(nEnabled,vec->type);\n\n  // if you create a new vector here and pass it to setNextFrame(),\n  // then be sure to assign a valid tmeta info for correct timing info:\n  // e.g.:\n  myVec->tmetaReplace(vec->tmeta);\n\n  int n=0;\n  if (F0directionOutp) {\n    myVec->dataF[n] = dir; n++;\n  }\n  if (directionScoreOutp) { // smean-lmean\n    myVec->dataF[n] = (FLOAT_DMEM)(smean-lmean); n++;\n  }\n  if (speakingRateOutp) {\n    myVec->dataF[n] = (FLOAT_DMEM)(curSpkRate); n++; // TODO!!\n  }\n  if (F0avgOutp) {\n    myVec->dataF[n] = (FLOAT_DMEM)( ltSum/(double)ltbsFrames ); n++;\n  }\n  if (F0smoothOutp) {\n    myVec->dataF[n] = (float)f0s; n++;\n    if (!insyl) { myVec->dataF[n] = (FLOAT_DMEM)(0.0); }\n  }\n  \n  // save to dataMemory\n  writer_->setNextFrame(myVec);\n\n  return 1;\n}\n\n\ncPitchDirection::~cPitchDirection()\n{\n  // cleanup...\n  if (myVec != NULL) delete myVec;\n  if (stbuf != NULL) free(stbuf);\n  if (ltbuf != NULL) free(ltbuf);\n}\n\n"
  },
  {
    "path": "src/lld/pitchJitter.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n// TODO: some pitch periods in opensmile.wav are twice, others are missing! FIX!\n\n/*  openSMILE component:\n\ncompute jitter from waveform and F0 estimate\n\nThis component has 2 readers (!)\n\n*/\n\n\n#include <lld/pitchJitter.hpp>\n\n#define MODULE \"cPitchJitter\"\n\nSMILECOMPONENT_STATICS(cPitchJitter)\n\nSMILECOMPONENT_REGCOMP(cPitchJitter)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CPITCHJITTER;\n  sdescription = COMPONENT_DESCRIPTION_CPITCHJITTER;\n\n  // we inherit cDataProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataProcessor\")\n  if (ct->setField(\"F0reader\", \"Configuration of the dataMemory reader sub-component which is used to read the F0 estimate from a pitch component output (e.g. cPitchShs).\",\n                  sconfman->getTypeObj(\"cDataReader\"), NO_ARRAY, DONT_FREE) == -1) {\n     rA=1; // if subtype not yet found, request , re-register in the next iteration\n  }\n/*\nif (ct->setField(\"exWriter\", \"dataMemory writer for pcm voice excitation signal\",\n                  sconfman->getTypeObj(\"cDataReader\"), NO_ARRAY, DONT_FREE) == -1) {\n     rA=1; // if subtype not yet found, request , re-register in the next iteration\n  }\n  */\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    //ct->setField(\"F0dmLevel\",\"data memory level to read f0 estimate from\",\"pitch\");\n    ct->setField(\"F0field\",\"The name of the field in 'F0reader.dmLevel' containing the F0 estimate (in Hz) (usually F0final or F0raw) - full name, exact match!\",\"F0final\");\n    ct->setField(\"searchRangeRel\",\"The relative search range for period deviations (Jitter): maxT0, minT0 = (1.0 +/- searchRangeRel)*T0\",0.10);\n    ct->setField(\"minNumPeriods\", \"Minimum number of F0 periods to compute jitter/shimmer over. The frame size must be large enough to hold that number of periods for the extraction to be stable!\", 2);\n    ct->setField(\"minCC\", \"Cross correlation threshold below which the periods will be rejected.\", 0.5);\n    ct->setField(\"jitterLocal\",\"1 = enable computation of F0 jitter (period length variations). jitterLocal = the average absolute difference between consecutive periods, divided by the average period length of all periods in the frame\",0);\n    ct->setField(\"jitterDDP\",\"1 = enable computation of F0 jitter (period length variations). jitterDDP = the average absolute difference between consecutive differences between consecutive periods, divided by the average period length of all periods in the frame\",0);\n    ct->setField(\"jitterLocalEnv\",\"1 = compute envelope of jitterLocal (i.e. fill jitter values in unvoiced frames with value of last voiced segment). Use this in conjunction with statistical functionals such as means.\",0);\n    ct->setField(\"jitterDDPEnv\",\"1 = compute envelope of jitterDDP (i.e. fill jitter values in unvoiced frames with value of last voiced segment). Use this in conjunction with statistical functionals such as means.\",0);\n    \n    ct->setField(\"shimmerLocal\",\"1 = enable computation of F0 shimmer (amplitude variations). shimmerLocal = the average absolute difference between the interpolated peak amplitudes of consecutive periods, divided by the average peak amplitude of all periods in the frame\", 0);\n    ct->setField(\"shimmerLocalDB\",\"1 = enable computation of F0 shimmer (amplitude variations) in decibel (dB). shimmerLocal = the average absolute difference between the interpolated peak amplitudes of consecutive periods, divided by the average peak amplitude of all periods in the frame\", 0);\n    ct->setField(\"shimmerLocalEnv\",\"1 = compute envelope of shimmerLocal (i.e. fill shimmer values in unvoiced frames with value of last voiced segment). Use this in conjunction with statistical functionals such as means.\", 0);\n    ct->setField(\"shimmerLocalDBEnv\",\"1 = compute envelope of shimmerLocalDB (i.e. fill shimmer values in unvoiced frames with value of last voiced segment). Use this in conjunction with statistical functionals such as means.\", 0);\n    ct->setField(\"shimmerUseRmsAmplitude\", \"1 = use average rms amplitude instead of peak amplitude.\", 0);\n\n    ct->setField(\"harmonicERMS\",\"1 = output of harmonic component RMS energy (energy average period waveform).\",0);\n    ct->setField(\"noiseERMS\",\"1 = output of noise component RMS energy (energy of difference signal between repeated average period waveform and actual signal).\",0);\n    ct->setField(\"linearHNR\",\"1 = output of harmonics to noise ratio computed from waveform signal (= harmonicERMS/noiseERMS)\",0);\n    ct->setField(\"logHNR\",\"1 = output of logarithmic harmonics to noise ratio computed from waveform signal, using natural logarithm (base e) (logHNR = log(harmonicERMS/noiseERMS) )\",0);\n    ct->setField(\"lgHNRfloor\",\"minimal value logHNR can be, to avoid very large negative numbers for small harmonic energies.\",-100.0);\n    // TODO: this option is not fully supported by the functionals component, for example.\n    // winToVecProcessor cannot deal with variable frame rate, i.e. does not yet support collecting frames by looking at tmeta fields...\n    ct->setField(\"onlyVoiced\",\"1 = produce output only for voiced frames. I.e. do not output 0 jitter/shimmer values for unvoiced frames. WARNING: this option is not fully supported by the functionals component, yet.\",0);\n    ct->setField(\"refinedF0\", \"1 = output refined F0 in a field named after the 'F0field' option.\", 0);\n    ct->setField(\"sourceQualityMean\", \"1 = compute larynx source quality mean per frame (similarity of pitch periods)\", 0);\n    ct->setField(\"sourceQualityRange\", \"1 = compute larynx source quality range per frame (max - min similarity of pitch periods)\", 0);\n    ct->setField(\"usePeakToPeakPeriodLength\", \"1 = use peak to peak period length instead of correlation peak position (should roughly be the same - the old version used the correlation peak pos., which is the default)\", 0);\n    ct->setField(\"periodOutputFile\", \"Dump period start/end/amplitude/length to file if this option is set to a filename.\", (const char*)NULL);\n    //ct->setField(\"periodLengths\",\"1 = enable output of individual period lengths\",0);\n    //ct->setField(\"periodStarts\",\"1 = enable output of individual period start times\",0);\n    ct->makeMandatory(ct->setField(\"inputMaxDelaySec\", \"The maximum possible delay of the F0 input wrt. to the waveform in seconds. This occurs mainly for viterbi smoothing, for example. IT IS IMPORTANT that you set this parameter with care (summing up all delays like bufferLength of the viterbi smoother, etc.), otherwise the processing will hang or abort before the actual end of the input!\", 2.0));\n    ct->setField(\"useBrokenJitterThresh\", \"1 = enable compatibility with 2.2 and earlier versions with broken Jitter computation. Please specify this manually in all new configs (and update old configs to use value 0), as the default might change from 1 to 0 in future builds.\", 1);\n  )\n  \n  SMILECOMPONENT_MAKEINFO(cPitchJitter);\n}\n\n\nSMILECOMPONENT_CREATE(cPitchJitter)\n\n//-----\n\ncPitchJitter::cPitchJitter(const char *_name) :\n  cDataProcessor(_name), minF0(25.0), // <- TODO: read this from pitch field metadata\n    lastIdx(0), lastMis(0), out(NULL), F0reader(NULL), lastT0(0.0), lastDiff(0.0),\n    Nout(0), lastJitterLocal(0.0), lastJitterDDP(0.0), lastShimmerLocal(0.0),\n    lastJitterLocal_b(0.0), lastJitterDDP_b(0.0), lastShimmerLocal_b(0.0),\n    filehandle(NULL), threshCC_(0.5), minNumPeriods(2),\n    useBrokenJitterThresh_(1)\n{\n  char *tmp = myvprint(\"%s.F0reader\",getInstName());\n  F0reader = (cDataReader *)(cDataReader::create(tmp));\n  if (F0reader == NULL) {\n    COMP_ERR(\"Error creating dataReader '%s'\",tmp);\n  }\n  if (tmp!=NULL) free(tmp);\n}\n\nvoid cPitchJitter::fetchConfig()\n{\n  cDataProcessor::fetchConfig();\n\n  // load all configuration parameters you will later require fast and easy access to here:\n\n  F0field = getStr(\"F0field\");\n  SMILE_IDBG(2,\"F0field = '%s'\",F0field);\n  \n  searchRangeRel = getDouble(\"searchRangeRel\");\n  SMILE_IDBG(2,\"searchRangeRel = %f\",searchRangeRel);\n\n  onlyVoiced = getInt(\"onlyVoiced\");\n  SMILE_IDBG(2,\"onlyVoiced = %i\",onlyVoiced);\n\n  jitterLocal = getInt(\"jitterLocal\");\n  SMILE_IDBG(2,\"jitterLocal = %i\",jitterLocal);\n  jitterDDP = getInt(\"jitterDDP\");\n  SMILE_IDBG(2,\"jitterDDP = %i\",jitterDDP);\n\n  jitterLocalEnv = getInt(\"jitterLocalEnv\");\n  SMILE_IDBG(2,\"jitterLocalEnv = %i\",jitterLocalEnv);\n  jitterDDPEnv = getInt(\"jitterDDPEnv\");\n  SMILE_IDBG(2,\"jitterDDPEnv = %i\",jitterDDPEnv);\n\n  shimmerLocalDB = getInt(\"shimmerLocalDB\");\n  shimmerLocal = getInt(\"shimmerLocal\");\n  SMILE_IDBG(2,\"shimmerLocal = %i\",shimmerLocal);\n  shimmerLocalDBEnv = getInt(\"shimmerLocalDBEnv\");\n  shimmerLocalEnv = getInt(\"shimmerLocalEnv\");\n  SMILE_IDBG(2,\"shimmerLocalEnv = %i\",shimmerLocalEnv);\n\n  harmonicERMS = getInt(\"harmonicERMS\");\n  noiseERMS = getInt(\"noiseERMS\");\n  linearHNR = getInt(\"linearHNR\");\n  logHNR = getInt(\"logHNR\");\n  lgHNRfloor = (FLOAT_DMEM)getDouble(\"lgHNRfloor\");\n  input_max_delay_ = getInt(\"inputMaxDelaySec\");\n  shimmerUseRmsAmplitude = getInt(\"shimmerUseRmsAmplitude\");\n\n  minNumPeriods = getInt(\"minNumPeriods\");\n  if (minNumPeriods < 2) {\n    SMILE_IWRN(2, \"minNumPeriods must be >= 2. Setting to 2.\");\n    minNumPeriods = 2;\n  }\n  threshCC_ = (FLOAT_DMEM)getDouble(\"minCC\");\n  if (threshCC_ < (FLOAT_DMEM)0.01) {\n    SMILE_IWRN(2, \"minCC must be > 0.01 and < 0.99! Setting to 0.01.\");\n    threshCC_ = (FLOAT_DMEM)0.01;\n  }\n  if (threshCC_ > (FLOAT_DMEM)0.99) {\n    SMILE_IWRN(2, \"minCC must be > 0.01 and < 0.99! Setting to 0.99.\");\n    threshCC_ = (FLOAT_DMEM)0.99;\n  }\n  refinedF0 = getInt(\"refinedF0\");\n  sourceQualityRange = getInt(\"sourceQualityRange\");\n  sourceQualityMean = getInt(\"sourceQualityMean\");\n  usePeakToPeakPeriodLength_ = getInt(\"usePeakToPeakPeriodLength\");\n  useBrokenJitterThresh_ = getInt(\"useBrokenJitterThresh\");\n}\n\n\n\n\nint cPitchJitter::configureReader(const sDmLevelConfig &c)\n{\n  // check if F0 level period and pcm input period match\n  double Tf0 = F0reader->getLevelT();\n  //double T = reader_->getLevelT();\n  if (c.T == Tf0) {\n    SMILE_IERR(1,\"pcm level frame period must be << F0 level frame period! pcm data should be stream data and not frame data!\");\n  }\n\n  // set blocksize of wave reader to 5*max pitch period (2.0/minF0)\n  blocksizeR_sec_ = (long)ceil((3.0 + (double)minNumPeriods)/(minF0)) + input_max_delay_;\n  if (c.T > 0.0) {\n    blocksizeR_ = (long) ceil (blocksizeR_sec_ / c.T);\n  } else {\n    SMILE_IERR(1, \"Cannot properly set the reader blocksize in frames from blocksize in seconds, as the input level is not periodic (lcfg.T==0!). Non-periodic waveform input levels are not supported for pitchJitter!\");\n    return 0;\n  }\n  // FIXME: when the F0 is delayed due to post-smoothing (viterbi, etc.)\n  //        then data in the wave level might have expired, or reading\n  //        will block the processing.\n  //        Thus, we must signal the wave reader the max possible delay\n  //        so that the wave buffersize can be set correctly.\n  //        We don't know the delay, as there is no standard mechanism\n  //        we can use to read it from the pitch components.\n  //        Therefore we provide a mandatory config option and let the user\n  //        set it correctly!\n  int ret = cDataProcessor::configureReader(c);\n  F0reader->setBlocksize(1);\n  return ret;\n}\n\nvoid cPitchJitter::mySetEnvironment()\n{\n  cDataProcessor::mySetEnvironment();\n  F0reader->setComponentEnvironment(getCompMan(), -1, this);\n}\n\nint cPitchJitter::myRegisterInstance(int *runMe)\n{\n  int ret = cDataProcessor::myRegisterInstance(runMe);\n  ret *= F0reader->registerInstance();\n  return ret;\n}\n\nint cPitchJitter::myConfigureInstance()\n{\n  if (!(F0reader->configureInstance())) return 0;\n  if (!(F0reader->finaliseInstance())) return 0;\n\n  int ret = cDataProcessor::myConfigureInstance();\n  return ret;\n}\n\nint cPitchJitter::configureWriter(sDmLevelConfig &c) \n{\n  // check that we have mono input!!\n  if (c.fmeta->Ne > 1) {\n    SMILE_IERR(1,\"this component must read mono (1 channel) wave input (your input currently has %i channels)! Use the monomixdown option in the wave-source!\",c.fmeta->Ne);\n    return 0;\n  }\n\n  const sDmLevelConfig *cfg = F0reader->getLevelConfig();\n  c.T = cfg->T;\n  c.frameSizeSec = cfg->frameSizeSec;\n  c.basePeriod = cfg->basePeriod;\n  c.growDyn = cfg->growDyn;\n  c.isRb = cfg->isRb;\n  c.lastFrameSizeSec = cfg->frameSizeSec;\n  c.lenSec = cfg->lenSec;\n  return 1; /* success */\n}\n\n/* You shouldn't need to touch this....\nint cPitchJitter::myConfigureInstance()\n{\n  int ret = cDataProcessor::myConfigureInstance();\n  return ret;\n}\n*/\n\n/*\n  Do what you like here... this is called after the input names and number of input elements have become available, \n  so you may use them here.\n*/\n/*\nint cPitchJitter::dataProcessorCustomFinalise()\n{\n  \n  return 1;\n}\n*/\n\n\n/* \n  Use setupNewNames() to freely set the data elements and their names in the output level\n  The input names are available at this point, you can get them via reader->getFrameMeta()\n  Please set \"namesAreSet\" to 1, when you do set names\n*/\n\nint cPitchJitter::setupNewNames(long nEl) \n{\n  // find pitch input field:\n  const FrameMetaInfo * fmeta = F0reader->getFrameMetaInfo();\n  int ri=0;\n  long idx = fmeta->findField( F0field , &ri );\n  if (nEl <= 0) nEl = reader_->getLevelN();\n  if (idx < 0) {\n    F0fieldIdx = 0;\n    SMILE_IWRN(2,\"Requested input field '*%s*' not found, defaulting to use 0th field! Available field names are listed below:\", F0field);\n    fmeta->printFieldNames();\n  } else {\n    F0fieldIdx = fmeta->fieldToElementIdx( idx ) + ri;\n  }\n  \n  int n=0;\n  if (jitterLocal) { writer_->addField(\"jitterLocal\",1); n++; }\n  if (jitterDDP) { writer_->addField(\"jitterDDP\",1); n++; }\n  if (jitterLocalEnv) { writer_->addField(\"jitterLocEnv\",1); n++; }\n  if (jitterDDPEnv) { writer_->addField(\"jitterDEnv\",1); n++; }\n  if (shimmerLocal) { writer_->addField(\"shimmerLocal\",1); n++; }\n  if (shimmerLocalDB) { writer_->addField(\"shimmerLocalDB\",1); n++; }\n  if (shimmerLocalEnv) { writer_->addField(\"shimmerLocEnv\",1); n++; }\n  if (shimmerLocalDBEnv) { writer_->addField(\"shimmerLocDBEnv\",1); n++; }\n  if (harmonicERMS) { writer_->addField(\"harmonicERMS\",1); n++; }\n  if (noiseERMS) { writer_->addField(\"noiseERMS\",1); n++; }\n  if (linearHNR) { writer_->addField(\"linearHNR\",1); n++; }\n  if (logHNR) { writer_->addField(\"logHNR\",1); n++; }\n  if (refinedF0) {\n    if (F0field != NULL) {\n      writer_->addField(F0field, 1);\n    } else {\n      writer_->addField(\"F0final\", 1);\n    }\n    n++;\n  }\n  if (sourceQualityMean) {\n    writer_->addField(\"sourceQualityMean\", 1);\n    n++;\n  }\n  if (sourceQualityRange) {\n    writer_->addField(\"sourceQualityRange\", 1);\n    n++;\n  }\n  namesAreSet_ = 1;\n  Nout = n;\n  return n;\n}\n\n/*\n  If you don't use setupNewNames() you may set the names for each input field by overwriting the following method:\n*/\n/*\nint cPitchJitter::setupNamesForField( TODO )\n{\n  // DOC TODO...\n}\n*/\n\nint cPitchJitter::myFinaliseInstance()\n{\n  int ret = cDataProcessor::myFinaliseInstance();\n  if (ret) {\n    const char *periodOutputFile = getStr(\"periodOutputFile\");\n    if (periodOutputFile != NULL) {\n      filehandle = fopen(periodOutputFile, \"w\");\n    }\n  }\n  savedMaxDebugPeriod = 0;\n  return ret;\n}\n\ndouble cPitchJitter::crossCorr(FLOAT_DMEM * x, long Nx, FLOAT_DMEM * y, long Ny)\n{\n  long N = MIN(Nx,Ny);\n  long i;\n  double cc = 0.0;\n  double mx = 0.0;\n  double my = 0.0;\n  double nx = 0;\n  double ny = 0;\n  for (i=0; i<N; i++) {\n    mx += x[i];\n    my += y[i];\n  }\n  mx /= (double)N;\n  my /= (double)N;\n  for (i=0; i<N; i++) {\n/*\n// TODO: low-pass filter in here...\n// x[i] is symm moving avg of +- 5 samples?\ndouble x_avg = 0.0;\ndouble x_n = 0;\ndouble y_avg = 0.0;\nfor (int j = 0; j < 6; j++) {\n  if (i - j > 0) {\n    x_avg += x[i - j];\n    y_avg += y[i - j];\n    x_n += 1.0;\n  }\n  if (i + j < N && j != 0) {\n    x_avg += x[i - j];\n    y_avg += y[i - j];\n    x_n += 1.0;\n  }\n}\nif (x_n > 0.0) {\n  x_avg /= x_n;\n  y_avg /= x_n;\n}\n    cc += (x_avg-mx)*(y_avg-my);\n    nx += (x_avg-mx)*(x_avg-mx);\n    ny += (y_avg-my)*(y_avg-my);*/\n    cc += (x[i]-mx)*(y[i]-my);\n    nx += (x[i]-mx)*(x[i]-mx);\n    ny += (y[i]-my)*(y[i]-my);\n  }\n  /*\n  FLOAT_DMEM tmpX[4];\n  FLOAT_DMEM tmpY[4];\n  FLOAT_DMEM tmp2[4];\n  int j;\n  for (i=0; i<N; i+=4) {\n    tmpX[0] = x[i+0]-mx;\n    tmpX[1] = x[i+1]-mx;\n    tmpX[2] = x[i+2]-mx;\n    tmpX[3] = x[i+3]-mx;\n    tmpY[0] = y[i+0]-my;\n    tmpY[1] = y[i+1]-my;\n    tmpY[2] = y[i+2]-my;\n    tmpY[3] = y[i+3]-my;\n    tmp2[0] = tmpX[0]*tmpY[0];\n    tmp2[1] = tmpX[1]*tmpY[1];\n    tmp2[2] = tmpX[2]*tmpY[2];\n    tmp2[3] = tmpX[3]*tmpY[3];\n    cc += tmp2[0] + tmp2[1] + tmp2[2] + tmp2[3];\n    tmp2[0] = (x[i+0]-mx) * tmpX[0];\n    tmp2[1] = (x[i+1]-mx) * tmpX[1];\n    tmp2[2] = (x[i+2]-mx) * tmpX[2];\n    tmp2[3] = (x[i+3]-mx) * tmpX[3];\n    nx += tmp2[0] + tmp2[1] + tmp2[2] + tmp2[3];\n    tmp2[0] = (y[i+0]-mx) * tmpY[0];\n    tmp2[1] = (y[i+1]-mx) * tmpY[1];\n    tmp2[2] = (y[i+2]-mx) * tmpY[2];\n    tmp2[3] = (y[i+3]-mx) * tmpY[3];\n    ny += tmp2[0] + tmp2[1] + tmp2[2] + tmp2[3];\n  }*/\n  cc /= sqrt(nx)*sqrt(ny);\n  return cc;\n}\n\n// get difference of peak amplitude in the two given frames\n// save interpolated index of max peak in first frame in *maxI0 if != NULL\n// save interpolated index of max peak in second frame in *maxI1 if != NULL\nFLOAT_DMEM cPitchJitter::amplitudeDiff(FLOAT_DMEM *x, long Nx, FLOAT_DMEM *y, long Ny, double *maxI0, double *maxI1, FLOAT_DMEM *_A0, FLOAT_DMEM *_A1)\n{\n  long i;\n  long N = MIN(Nx,Ny);\n  double A0=1.0, A1=1.0;\n  // analyse first frame:\n  long mI=1;\n  FLOAT_DMEM max0=x[1];\n  FLOAT_DMEM min0=x[1];\n  for (i=1; i<Nx-1; i++) {\n    if (x[i] > max0) { max0=x[i]; mI = i; }\n    if (x[i] < min0) { min0=x[i]; }\n  }\n  double mi = smileMath_quadFrom3pts((double)(mI-1),x[mI-1],(double)(mI),x[mI],(double)(mI+1),x[mI+1],&A0,NULL);\n  //printf(\"A0 %f  x[%i] %f  Nx=%i\\n\",A0,mI,x[mI],Nx);\n  if (maxI0 != NULL) *maxI0 = mi;\n  // analyse second frame:\n  mI = 1;\n  FLOAT_DMEM max1 = y[1];\n  FLOAT_DMEM min1 = y[1];\n  for (i=1; i<Ny-1; i++) {\n    if (y[i] > max1) { max1=y[i]; mI = i; }\n    if (y[i] < min1) { min1=y[i]; }\n  }\n  mi = smileMath_quadFrom3pts((double)(mI-1),y[mI-1],(double)(mI),y[mI],(double)(mI+1),y[mI+1],&A1,NULL);\n  if (maxI1 != NULL) *maxI1 = mi;\n  //printf(\"A1 %f  x[%i] %f  Ny=%i\\n\",A1,mI,y[mI],Ny);\n  \n  // save min to max amplitudes\n  //if (_A0 != NULL) *_A0 = (FLOAT_DMEM)A0;\n  //if (_A1 != NULL) *_A1 = (FLOAT_DMEM)A1;\n  if (_A0 != NULL) *_A0 = max0 - min0;\n  if (_A1 != NULL) *_A1 = max1 - min1;\n\n  // compute relative min to max amplitude difference:\n  return (FLOAT_DMEM)fabs((max0 - min0) - (max1 - min1));\n}\n\n// get difference of low-pass smoothed rms amplitudes in the two given frames\n// save interpolated index of max peak in first frame in *maxI0 if != NULL  (rms amplitudes in A0, A1..! NOT peak)\n// save interpolated index of max peak in second frame in *maxI1 if != NULL\nFLOAT_DMEM cPitchJitter::rmsAmplitudeDiff(FLOAT_DMEM *x, long Nx, FLOAT_DMEM *y, long Ny, double *maxI0, double *maxI1, FLOAT_DMEM *_A0, FLOAT_DMEM *_A1)\n{\n  long i;\n  long N = MIN(Nx,Ny);\n  double A0 = 1.0;\n  double A1 = 1.0;\n  // analyse first frame:\n  long mI = 1;\n  FLOAT_DMEM max = x[1];\n  FLOAT_DMEM rmsX = x[0] * x[0];\n  for (i=1; i < Nx - 1; i++) {\n    if (x[i] > max) {\n      max=x[i];\n      mI = i;\n    }\n    rmsX += x[i] * x[i];\n  }\n  rmsX = sqrt((rmsX + x[i] * x[i]) / (FLOAT_DMEM)Nx);\n  double mi = smileMath_quadFrom3pts((double)(mI-1),x[mI-1],(double)(mI),x[mI],(double)(mI+1),x[mI+1],&A0,NULL);\n  if (maxI0 != NULL) {\n    *maxI0 = mi;\n  }\n  // analyse second frame:\n  mI = 1;\n  max = y[1];\n  FLOAT_DMEM rmsY = y[0] * y[0];\n  for (i = 1; i < Ny - 1; i++) {\n    if (y[i] > max) {\n      max=y[i];\n      mI = i;\n    }\n    rmsY += y[i] * y[i];\n  }\n  rmsY = sqrt((rmsY + y[i] * y[i]) / (FLOAT_DMEM)Ny);\n  //rmsY = (rmsY + y[i]) / (FLOAT_DMEM)Ny;\n  mi = smileMath_quadFrom3pts((double)(mI-1),y[mI-1],(double)(mI),y[mI],(double)(mI+1),y[mI+1],&A1,NULL);\n  if (maxI1 != NULL) {\n    *maxI1 = mi;\n  }\n  // save rms amplitudes\n  if (_A0 != NULL) {\n    *_A0 = (FLOAT_DMEM)rmsX;\n  }\n  if (_A1 != NULL) {\n    *_A1 = (FLOAT_DMEM)rmsY;\n  }\n  // compute relative rms amplitude difference:\n  return (FLOAT_DMEM)fabs(rmsX - rmsY);\n}\n\nvoid cPitchJitter::saveDebugPeriod(long sample, double sampleInterp)\n{\n  if (filehandle != NULL) {\n    if (sample > savedMaxDebugPeriod + 1) {\n      savedMaxDebugPeriod = sample;\n      fprintf(filehandle, \"%i,%f\\n\", sample, sampleInterp);\n    }\n  }\n}\n\n\n#if 0\nint cPitchJitter::myTick2(long long t)\n{\n  if (isEOI()) return 0; // TODO: check if we need to flush jitter data OR we can still read from input....?\n\n  // get next F0 frame:\n  cVector *fvec = F0reader->getNextFrame();\n  if (fvec == NULL) {\n    return 0;\n  }\n  FLOAT_DMEM F0 = 0.0;\n  if (F0fieldIdx < fvec->N) {\n    F0 = fvec->dataF[F0fieldIdx];\n  }\n\n  // get wave data belonging to this F0 frame..\n  double T = reader_->getLevelT();  // wave sample period\n  long startVidxS = (long)round(fvec->tmeta->time / T);  // start of F0 frame in samples\n  long lenF0frameS = fvec->tmeta->lengthFrames;  // the length of the F0 frame in wavesamples\n  double F0period = fvec->tmeta->period;  // pitch frame period\n  long stepF0frameS = (long)ceil(F0period/T);      // step size in samples of F0 frame\n  long ovlF0frameS = lenF0frameS - stepF0frameS;  // pitch frame overlap (in samples)\n\n  long toRead = stepF0frameS;\n  if (firstF0frame) {\n    toRead = lenF0frameS;\n    firstF0frame = false;\n  }\n  cMatrix *mat = reader_->getMatrix(startVidxS, toRead /* = pitch frame length/step */);\n  // save in ringbuffer\n  waveBuffer->setNext(mat->dataF, mat->nT);\n  if (F0 > 0.0) {\n    // figure out which data to process from wave buffer wrPtr_ backwards\n    long wp = waveBuffer->getWritePointer();\n    wp -= lenF0frameS;\n    // at least 2 periods...\n\n    // not smaller than 0...\n\n    FLOAT_DMEM *buf = waveBuffer->get(wp, lenF0frameS);\n\n    // do wave period matching\n\n  // get data from ringbuffer...:\n  /* from lastIndex to end of buffer (only full periods)\n   * at least 2 estimated periods,\n   * cc match to refine period lengths\n   * save last buffer index\n   */\n  } else {\n    // reset some pointers\n\n  }\n}\n#endif\n\n/*\n * Ideas for NEW jitter component:\n *\n * read wave data sync. to pitch without delay\n * store in internal ringbuffer of sufficient size\n * - cross correlation computation\n * - analyse amplitudes and correlations in double and half the pitch period\n * - fix octave errors?\n * - compute jitter / shimmer / hnr\n * - compute other features from pitch region... make available to dataMemory?\n */\nint cPitchJitter::myTick(long long t)\n{\n  if (isEOI()) return 0; // TODO: check if we need to flush jitter data OR we can still read from input....?\n\n  long i;\n\n  // get next pitch frame:\n  cVector *fvec = F0reader->getNextFrame();\n  if (fvec != NULL) {\n    FLOAT_DMEM F0 = 0.0;\n    if (F0fieldIdx < fvec->N) {\n      F0 = fvec->dataF[F0fieldIdx];  // F0 estimate\n    }\n    long lenF = fvec->tmeta->lengthFrames;\n\n    double T = reader_->getLevelT(); // sample period\n    long startVidx = (long)round(fvec->tmeta->time / T);  // start in samples\n    double pitchT = fvec->tmeta->period; // pitch frame period\n\n\n    long ppLen = (long)ceil(pitchT/T);  // step size in samples of pitch frames\n    long ovl = lenF - ppLen;  // pitch frame overlap (in samples)\n\n\n    // New method to determine toRead samples:\n    //  We need to read at least ppLen+lastMix, otherwise we fall behind the frame rate\n    //  We need at least two pitch periods + serach range tolerance\n    //  We must read at max. lenF+lastMis\n    long toRead0 = ppLen+lastMis;  // number of samples we should read?\n    long toRead = toRead0;\n    double T0 = 0.0; // f0 period (seconds)\n    double Tf = 0.0; // f0 period in samples, floating point\n    long T0f = 0; // f0 period in samples as integer\n    // upper / lower T0 bounds:\n    double T0min = 0.0;  // lower bound of f0 period search range\n    double T0max = 0.0;  // upper bound of f0 period search range\n    long T0minF = 0;  // bounds as integer (samples)\n    long T0maxF = 0;   // bounds as integer (samples)\n    long two_pp = 0;\n    if (F0 > 0.0) {\n      T0 = 1.0/F0;\n      Tf = T0/T;\n      T0f = (long)round(Tf);\n      T0min = (1.0-searchRangeRel)*Tf;\n      T0max = (1.0+searchRangeRel)*Tf;\n      T0minF = (long)floor(T0min);\n      T0maxF = (long)ceil(T0max);\n      two_pp = minNumPeriods * T0maxF + minNumPeriods;\n      if (toRead < two_pp) {\n        toRead = two_pp;\n      }\n    }\n    long maxRead = lastMis+lenF;  // maxmimum number of samples we may read...\n    //SMILE_IMSG(2,\"Input indices (F0 = %f) (startV-lm = %i) != (last idx = %i)  (startv: %i, lastm: %i, tord %i, maxrd %i ; ppLen %i, 2pp %i).\", F0, startVidx - lastMis, lastIdx, startVidx, lastMis, toRead, maxRead, ppLen, two_pp);\n\n    if (toRead > maxRead) {\n      SMILE_IWRN(2, \"It appears that we need to read more wave samples than the length of the input F0 frame to read two full pitch periods at F0=%f with tolerance (searchRangeRel = %f) : toRead = %i, maxRead = %i. Limiting toRead=maxRead. Reduce the value of the minNumPeriods (=%i) option or increase the F0 framesize!\\n\", F0, searchRangeRel, toRead, maxRead, minNumPeriods);\n      toRead = maxRead;\n    }\n\n    // check start idx:\n    if (startVidx - lastMis != lastIdx) {\n      SMILE_IWRN(3,\"Discontinuity in input indices... %i != %i  (v: %i, lastm: %i, tr %i, mr %i - ppLen %i). This warning is ok, if you encounter it at the beginning and a pitchSmoother component is causing a delay of the pitch frames.\", startVidx - lastMis, lastIdx, startVidx, lastMis, toRead, maxRead, ppLen);\n      lastIdx = startVidx;\n      if (toRead > lenF) { toRead = lenF; } \n      if (maxRead > lenF) { maxRead = lenF; } \n    }\n    \n    // read wave data for the current pitch frame\n    cMatrix *mat = reader_->getMatrix(lastIdx, toRead /* = pitch frame length */);\n\n    if (mat == NULL && !isEOI()) {\n      // TODO: print this error message only if lastIdx is well behind the current F0 frame vIdx equivalent!\n      SMILE_IERR(2, \"no pcm data read!  lastIdx %ld  toRead %ld. Check inpuMaxDelaySec option! It needs to be increased (unless you get this error message close to the end of processing, current tick = %lld).\", lastIdx, toRead, t);\n      lastIdx += toRead0;\n      return 0;\n    }\n    if (maxRead < 1 || mat->dataF==NULL) {\n      SMILE_IERR(1,\"maxRead < 1 or mat->dataF==NULL, something is wrong (probably tmeta info on the pitch input level is not set correctly, thus the pitch frame length is read as 0; please debug the component that produces the pitch data this component reads!)\");\n      return 0;\n    }\n\n    // jitter computation variables:\n    FLOAT_DMEM nPeriodsLocal = 0;\n    FLOAT_DMEM nPeriodsDDP = 0;\n    FLOAT_DMEM nPeriods = 0;\n    FLOAT_DMEM avgPeriod = 0.0;\n    FLOAT_DMEM JitterDDP=0.0;  // Praat: ddp\n    FLOAT_DMEM JitterLocal=0.0;\n    FLOAT_DMEM JitterPPQ=0.0;\n    // shimmer computation variables:\n    FLOAT_DMEM avgAmp=0.0;\n    FLOAT_DMEM avgAmpDiff=0.0;\n    // HNR computation variables:\n    FLOAT_DMEM eH = 0.0;\n    FLOAT_DMEM eN = 0.0;\n    FLOAT_DMEM HNR = 0.0;\n    FLOAT_DMEM lgHNR = 0.0;\n    FLOAT_DMEM sumCC = 0.0;\n    FLOAT_DMEM maxCC = -2.0;\n    FLOAT_DMEM minCC = -2.0;\n    int nCC = 0;\n    \n    // start the waveform matching for voiced segments\n    long start = 0;\n    long lastPeriod = 0;\n    if (F0 > 0.0) { // voiced frame\n\n      // create a buffer for storing pitch period boundaries (required for second pass HNR computation)\n      int numPeriods = 0;\n      long * periodBuffer;\n      if (T0f > 0) periodBuffer = (long *)calloc(1,sizeof(long)*(maxRead/T0minF+3));\n      else periodBuffer = (long *)calloc(1,sizeof(long)*(maxRead+2));\n\n      // buffer for computing average period waveform\n      FLOAT_DMEM * avgPeriodWf = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM) * (T0f+1));\n\n      //// waveform matching  (TODO: sync to amplitude max.)\n      double *cc = (double*)calloc(1,sizeof(double)*((int)(T0maxF-T0minF)+1));\n\n      long os = start;\n      long pp = 0;\n      // TODO: check what happens, if the while loop below does not run at all!\n      //       if pp is uninitialised, then valgrind will complain in the line:\n      // for (j=periodBuffer[i]; j<MIN(periodBuffer[i+1],periodBuffer[i]+T0f); j++) {\n      //printf(\"read N %i  2*T0maxF %i\\n\",mat->nT,2*T0maxF);\n      // TODO: multi-channel (mat->N > 1) support!\n      //printf(\"  start %i  toRead %i  T0maxF %i  mat-nt %i\\n\",start, toRead, 2*T0maxF, mat->nT);\n      //while (( start< mat->nT - 2*T0maxF ) && (start < toRead)) {\n      //while (( start < toRead0 - T0maxF - 1 ) && (start < toRead - 2 * T0maxF - 1)) {\n      while ((start < mat->nT - 2 * T0maxF - 1)) {\n        long _Tf;\n        for (_Tf = T0minF; _Tf <= T0maxF; _Tf++) {\n          long mid = start+_Tf;\n          cc[_Tf-T0minF] = crossCorr(mat->dataF+start,_Tf,mat->dataF+mid,_Tf);\n// FIXME: cross correlation with previous and next period, then average to get better estimate for current period length?\n// FIXME: re-evaluate period length and position after band-pass comb filtering (phase shift??) and peak detection for boundaries!\n// FIXME: sync correlation to max amplitude boundaries once found  (via lastMis variable..)\n        }\n\n        // peak picking\n        double max=cc[T0f-T0minF];\n        long maxI=-1;\n        //printf(\"T0maxF %i T0minF %i T0 %f, F0 %f, T0min %f , T0max %f T %f\\n\",T0maxF,T0minF,T0,F0,T0min,T0max,T);\n        for (i=1; i<T0maxF-T0minF-1; i++) {\n          //printf(\"cc[%i] = %f\\n\",i,cc[i]);\n          if ( (cc[i-1] < cc[i]) && (cc[i] > cc[i+1]) ) { // peak\n            if (maxI == -1) {\n              maxI = i; max = cc[i];\n            } else {\n              if (cc[i] > max) {\n                maxI = i; max = cc[i];\n              }\n            }\n          }\n        }\n        if (maxI == -1) {\n          // no peak found, we assign the expected period length, for HNR computation\n          pp = T0f;\n        } else {\n          pp = T0minF + maxI;\n        }\n\n        // assign new start\n        os = start;\n\n        // compute Jitter and Shimmer\n        //printf(\"  jitter: %i  pp=%i (maxI: %i)\\n\",pp-T0f,pp,maxI);\n        if (maxI >= 0) {\n          start += pp;\n          // get amplitude differences  for shimmer computation:\n          double max0 = 0.0;\n          double max1 = 0.0;\n          FLOAT_DMEM _a0=0.0;\n          FLOAT_DMEM _a1=0.0;\n          FLOAT_DMEM ad=0.0;\n // FIXME: compute shimmer with a lag of one period... only if we know the end position of the next period, compute shimmer! \n // FIXME: smooth the period waveforms with a narrow band-pass (comb!?) before computing amplitude to improve noise robustness!\n //        --> better:  generate a sine (not dirac pulse... because f0 alone is sinusoidal) and correlate that with a single period to obtain period phase and magnitude...?\n          if (shimmerUseRmsAmplitude) {\n            ad = rmsAmplitudeDiff(mat->dataF+os, pp, mat->dataF+start, pp, &max0, &max1, &_a0, &_a1);\n          } else {\n            ad = amplitudeDiff(mat->dataF+os, pp, mat->dataF+start, pp, &max0, &max1, &_a0, &_a1);\n          }\n          periodBuffer[numPeriods++] = os;\n          // compute averaged pitch period waveform for HNR\n          for (i=0; i<T0f; i++) {\n            avgPeriodWf[i] += *(mat->dataF+(os+i));\n          }\n\n          // parabolic interpolation of maxI\n          double conf = 0.0;\n          double ccI = 0.0;\n          double maxId = fabs(((double)T0minF + smileMath_quadFrom3pts((double)(maxI-1),cc[maxI-1],(double)(maxI),cc[maxI],(double)(maxI+1),cc[maxI+1],&ccI,&conf) ) ) * T;\n          // TODO: save instantaneous periods to extra file... with proper timestamps (e.g. for sonic visualiser).\n\n          // store CC stats for laryngalisation\n          sumCC += (FLOAT_DMEM)ccI;\n          if (minCC == (FLOAT_DMEM)-2.0 || minCC > (FLOAT_DMEM)ccI) {\n            minCC = (FLOAT_DMEM)ccI;\n          }\n          if (maxCC == (FLOAT_DMEM)-2.0 || maxCC < (FLOAT_DMEM)ccI) {\n            maxCC = (FLOAT_DMEM)ccI;\n          }\n\n          FLOAT_DMEM thresh = threshCC_;\n          if (useBrokenJitterThresh_) {\n            // due to an earlier variable clash when introducing CC stats\n            // we have to support the broken version in order to be compatible\n            // to all models trained before 09.06.2016 which include Jitter!\n            threshCC_ = minCC;\n          }\n          //printf(\"%f - %f\\n\", ccI, threshCC_);\n          if (ccI > threshCC_) { \n// TODO: what happens the the lastPeriod, average etc. when a pitch period is discarded!? DEBUG THIS IN DETAIL!\n            FLOAT_DMEM period = 0.0;\n            if (usePeakToPeakPeriodLength_) {\n              period = (FLOAT_DMEM)(((double)start + max1 - (double)os - max0) * T);\n            } else {\n              period = (FLOAT_DMEM)maxId;\n            }\n            avgPeriod += period;\n            nPeriods += 1.0;\n            if (lastT0 > 0.0) {\n              FLOAT_DMEM diff = (FLOAT_DMEM)fabs(lastT0 - period);\n              JitterLocal += diff;\n              nPeriodsLocal += 1.0;\n              if (lastDiff > 0.0) {\n                JitterDDP += fabs(lastDiff - diff);\n                nPeriodsDDP += 1.0;\n              }\n              lastDiff = diff;\n            }\n            lastT0 = period;\n            // debug output\n            // (TODO: save wave data properly to a pcm level, and save period start/end times..\n            // TODO: save average waveform to output level...\n            //saveFloatDmemVectorWlen_bin(\"dataJ.dat\",mat->dataF+os,start-os,1);\n            //saveDebugPeriod(lastIdx + start, (double)lastIdx + maxId);\n            saveDebugPeriod(lastIdx + os + (int)round(max0), (double)lastIdx + os + max0);\n            // Shimmer:\n            avgAmp += (_a0 + _a1) / (FLOAT_DMEM)2.0;\n            avgAmpDiff += ad;\n          }\n// TODO: send messages with pitch periods for pitch sync features!\n\n          //SMILE_IMSG(2, \"old start = %i ; new start = %i  (EV: %i - cc@max %f [%i %f] [T0f = %i])\", os, start, lastIdx + start, cc[maxI-1], T0minF + maxI, maxId / T, T0f);\n        } else {\n          start += T0f;\n        }\n        if (start < toRead0 - 1) {\n          lastPeriod = start;\n        }\n      }\n      // The last period\n      periodBuffer[numPeriods++] = start;\n\n      //HNR, for last period not yet processed: compute averaged pitch period waveform for HNR\n      // AND energy of averaged pitch period waveform (harmonic energy: H)\n      FLOAT_DMEM Eh = 0.0;\n      for (i=0; i<T0f && start+i < mat->nT; i++) {\n        avgPeriodWf[i] += *(mat->dataF+(start+i));\n        avgPeriodWf[i] /= (FLOAT_DMEM)numPeriods;\n        if (i>2 && i<T0f-2) /* skip possibly unreliable beginning and end frames */\n          Eh += avgPeriodWf[i]*avgPeriodWf[i];\n      }\n      if (T0f-4 > 0) {\n        Eh /= (FLOAT_DMEM)(T0f - 4);\n      }\n      Eh = sqrt(Eh);\n\n      //HNR, 2nd pass: compute energy of diff between each period and averaged waveform (noise energy N)\n      long j;\n      FLOAT_DMEM En = 0.0; long nEn = 0;\n      if (pp > 0) {\n        periodBuffer[numPeriods] = start+pp;\n      }\n      for (i=0; i<numPeriods; i++) {\n        long n = 2;\n        for (j=periodBuffer[i]+2; j<MIN(periodBuffer[i+1],periodBuffer[i]+T0f)-2; j++) {\n          FLOAT_DMEM delta = mat->dataF[j] - avgPeriodWf[n++];\n          En += delta*delta;\n          nEn++;\n        }\n      }\n      if (nEn > 0) En /= (FLOAT_DMEM)nEn;\n      En = sqrt(En);\n\n      // export variables\n      eH = Eh;\n      eN = En;\n      if (En > 0.0) {\n        HNR = Eh/En;\n        if (HNR > 0.0) {\n          lgHNR = (FLOAT_DMEM)(20.0 * log((double)HNR) / log(10.0));\n        } else {\n          lgHNR = lgHNRfloor;\n        }\n      }\n\n      // laryngalisation\n      if (numPeriods > 0) {\n        sumCC /= (FLOAT_DMEM)numPeriods;\n\n      }\n\n      // update end pointer\n      lastMis = toRead0 - lastPeriod; // - start;\n\n      free(cc);\n      free(periodBuffer);\n      free(avgPeriodWf);\n\n    } else { // for unvoiced frames:\n      start = toRead0;\n      lastPeriod = toRead0;\n      lastMis = 0;\n      // reset memory:\n      lastT0 = 0.0; lastDiff=0.0;\n      lastJitterDDP = 0.0; lastJitterLocal = 0.0;\n      lastShimmerLocal = 0.0;\n\n      //saveFloatDmemVectorWlen_bin(\"dataJ.dat\",mat->dataF,toRead,1);  \n\n      // HNR:\n      // noise energy is now signal RMS energy.. TODO!\n      if (noiseERMS || linearHNR || logHNR) {\n        long i; double E=0.0;\n        for (i=0; i<mat->nT; i++) {\n          E += mat->dataF[i]*mat->dataF[i];\n        }\n        E /= (double)mat->nT;\n\n        // export variables\n        eH = 0.0;\n        HNR = 0.0;\n        eN = (FLOAT_DMEM)sqrt(E);\n        lgHNR = lgHNRfloor;\n      }\n    }\n\n    //lastIdx += start;\n    lastIdx += lastPeriod;\n\n    // build output vector:\n    if (Nout == 0) return 0;\n\n    if (onlyVoiced && (F0==0.0)) { return 0; }\n\n    long n=0;\n    if (out == NULL) out = new cVector(Nout,DMEM_FLOAT);\n    if (out == NULL) OUT_OF_MEMORY;\n\n    \n    if ((nPeriods>0.0)&&(nPeriodsLocal > 0.0)&&(F0>0.0)) {\n      JitterLocal /= nPeriodsLocal;\n      lastJitterLocal_b = lastJitterLocal = JitterLocal / (avgPeriod/nPeriods);\n    }\n    if (jitterLocal) {\n      //printf(\"avgperiod = %f (over %f)  (F0=%f)\\n\", 1.0/(avgPeriod/nPeriods), nPeriods, F0);\n      if ((nPeriods>0.0)&&(nPeriodsLocal > 0.0)&&(F0>0.0)) {\n        //JitterLocal /= nPeriodsLocal;\n        if (lastJitterLocal > 1.0) lastJitterLocal = 1.0;\n        out->dataF[n] = lastJitterLocal; // = JitterLocal / (avgPeriod/nPeriods);\n      } else {\n        if ((nPeriods == 0.0)&&(F0>0.0)) {\n          if (lastJitterLocal > 1.0) lastJitterLocal = 1.0;\n          out->dataF[n] = lastJitterLocal;\n        } else {\n          out->dataF[n] = 0.0;\n        }\n      }\n      n++;\n    }\n    if (jitterLocalEnv) {\n      if (lastJitterLocal_b > 1.0) lastJitterLocal_b = 1.0;\n      out->dataF[n] = lastJitterLocal_b;\n      n++;\n    }\n\n    if ((nPeriods>0.0)&&(nPeriodsDDP > 0.0)&&(F0>0.0)) {\n      JitterDDP /= nPeriodsDDP;\n      lastJitterDDP_b = lastJitterDDP = JitterDDP / (avgPeriod/nPeriods);\n    }\n    if (jitterDDP) {\n      if ((nPeriods>0.0)&&(nPeriodsDDP > 0.0)&&(F0>0.0)) {\n        //JitterDDP /= nPeriodsDDP;\n        if (lastJitterDDP > 1.0) lastJitterDDP = 1.0;\n        out->dataF[n] = lastJitterDDP;\n      } else {\n        if ((nPeriods == 0.0)&&(F0>0.0)) {\n          if (lastJitterDDP > 1.0) lastJitterDDP = 1.0;\n          out->dataF[n] = lastJitterDDP;\n        } else {\n          out->dataF[n] = 0.0;\n        }\n      }\n      n++;\n    }\n\n    if (jitterDDPEnv) {\n      if (lastJitterDDP_b > 1.0) lastJitterDDP_b = 1.0;\n      out->dataF[n] = lastJitterDDP_b;\n      n++;\n    }\n    \n    if ((nPeriods>0.0)&&(F0>0.0)) {\n      if (avgAmp > 0.0) {\n        lastShimmerLocal_b = lastShimmerLocal = (avgAmpDiff/avgAmp);\n      } else {\n        lastShimmerLocal=0.0;\n      }\n    }\n    if (shimmerLocal || shimmerLocalDB) { // shimmer local\n      if ((nPeriods>0.0)&&(F0>0.0)) {\n        if (lastShimmerLocal > 1.0) lastShimmerLocal = 1.0;\n        if (shimmerLocal) {\n          out->dataF[n] = lastShimmerLocal;\n          n++;\n        } \n        if (shimmerLocalDB) {\n          out->dataF[n] = (FLOAT_DMEM)smileDsp_amplitudeRatioToDB(lastShimmerLocal + 1.0);\n          n++;\n        }\n      } else {\n        if ((nPeriods == 0.0)&&(F0>0.0)) {\n          if (lastShimmerLocal > 1.0) lastShimmerLocal = 1.0;\n          if (shimmerLocal) {\n            out->dataF[n] = lastShimmerLocal;\n            n++;\n          }\n          if (shimmerLocalDB) {\n            out->dataF[n] = (FLOAT_DMEM)smileDsp_amplitudeRatioToDB(lastShimmerLocal + 1.0);\n            n++;\n          }\n        } else {\n          if (shimmerLocal) {\n            out->dataF[n] = 0.0;\n            n++;\n          }\n          if (shimmerLocalDB) {\n            out->dataF[n] = 0.0;\n            n++;\n          }\n        }\n      }\n    }\n    if (shimmerLocalEnv) {\n      if (lastShimmerLocal_b > 1.0) lastShimmerLocal_b = 1.0;\n      out->dataF[n] = lastShimmerLocal_b;\n      n++;\n    }\n\n    if (harmonicERMS) {\n//      printf(\"XX   Eh %f\\n\", eH);\n      out->dataF[n++] = eH;\n    }\n    if (noiseERMS) {\n      out->dataF[n++] = eN;\n    }\n    if (linearHNR) {\n      out->dataF[n++] = HNR;\n    }\n    if (logHNR) {\n      if (lgHNR < lgHNRfloor) lgHNR = lgHNRfloor;\n      out->dataF[n++] = lgHNR;\n    }\n    if (refinedF0) {\n      // TODO: refined F0 only for step size, i.e. only until toRead0\n      if (nPeriods > 0.0 && F0 > 0.0) {\n        out->dataF[n++] = (FLOAT_DMEM)1.0 / (avgPeriod / nPeriods);\n      } else {\n        out->dataF[n++] = 0.0;\n      }\n    }\n\n    // larynx\n    if (sourceQualityMean) {\n      out->dataF[n++] = sumCC;\n    }\n    if (sourceQualityRange) {\n      out->dataF[n++] = fabs(maxCC-minCC);\n    }\n\n    out->tmetaReplace(fvec->tmeta);\n    writer_->setNextFrame(out);\n\n    return 1;\n  }\n\n\n////////////////////////////////////\n\n#if 0\n    double startVidx = fvec->tmeta->time / fvec->tmeta->period;\n    \n    double pitchT = fvec->tmeta->period; // pitch frame period\n    double T = reader_->getLevelT(); // sample period\n\n    double T0 = 1.0/F0; // pitch period\n\n    long toRead = (long)ceil((pitchT+T0)/T)+lastMis;\n    //double len = fvec->tmeta->lengthSec;\n\n    double Tf = T0/T; // f0 period in frames (samples)\n    long T0f = (long)round(Tf);\n\n    // upper / lower T0 bounds:\n    double T0min = (1.0-searchRangeRel)*T0;\n    double T0max = (1.0+searchRangeRel)*T0;\n    long T0minF = (long)floor(T0min/T);\n    long T0maxF = (long)ceil(T0max/T);\n\n    // maxmimum number of frames we may read...\n    long maxAvail = lenF+lastMis;\n\n    // get pcm data\n    long nRead = maxAvail; // MIN(maxAvail,toRead);\n    cMatrix *mat = reader_->getMatrix(lastIdx,nRead);\n\n    lastIdx += nRead;\n    if (mat == NULL) { \n      // frame not available..? If F0 frame was available this can only mean we have to catch up...\n      \n      // TODO : write NULL jitter/shimmer frame for proper sync?\n      //...\n      printf(\"Not avail\\n\");\n      return 0; \n    }\n\n    if (F0 > 0.0) {\n      // waveform matching  (TODO: sync to amplitude max.)\n      double *cc = (double*)calloc(1,sizeof(double)*(T0maxF-T0minF+1));\n\n      long start = 0;\n      //printf(\"read N %i  2*T0maxF %i\\n\",mat->nT,2*T0maxF);\n      // TODO: multi-channel (mat->N > 1) support!\n      while (start<mat->nT - 2*T0maxF) {\n        long _Tf;\n        for (_Tf = T0minF; _Tf <= T0maxF; _Tf++) {\n          long mid = start+_Tf;\n          long end = start+2*_Tf;\n          //if (end < vec->nT) {\n          cc[_Tf-T0minF] = crossCorr(mat->dataF+start,_Tf,mat->dataF+mid,_Tf);\n          //} \n        }\n\n        // peak picking and (TODO: parabolic interpolation)\n        double max=cc[T0f-T0minF]; long maxI=-1;\n        //printf(\"T0maxF %i T0minF %i T0 %f, F0 %f, T0min %f , T0max %f T %f\\n\",T0maxF,T0minF,T0,F0,T0min,T0max,T);\n        for (i=1; i<T0maxF-T0minF-1; i++) {\n          printf(\"cc[%i] = %f\\n\",i,cc[i]);\n          if ( (cc[i-1] < cc[i]) && (cc[i] > cc[i+1]) ) { // peak\n            if (maxI == -1) {\n              maxI = i; max = cc[i];\n            } else {\n              if (cc[i] > max) {\n                maxI = i; max = cc[i];\n              }\n            }\n          }\n        }\n        // TODO: parabolic interpolation of maxI for jitter comp. ??\n\n        // assign new start\n        long os = start;\n        long pp = T0minF+maxI;\n        if (maxI >= 0) {\n          printf(\"jitter: %i  (maxI: %i)\\n\",pp-T0f,maxI);\n          start += pp;\n        } else {\n          start += T0f;\n          printf(\"no match\\n\");\n        }\n        saveFloatDmemVectorWlen_bin(\"dataJ.dat\",mat->dataF+os,start-os,1);  \n\n\n        // save period start...\n      }\n\n\n\n      free(cc);\n\n      lastMis = nRead - start;\n\n    } else {\n      // compute lastMis (i.e.: maxAvail - lastPeriodEnd)\n      lastMis = 0;\n      //lastIdx += start;\n    }\n    \n     // zero jitter/shimmer for unvoiced frames ?\n  // lastIdx += lenF;\n  // printf(\"unvoiced \\n\");\n  //}\n    \n  // build output vector\n\n  // save output\n    //writer->setNextFrame(vecO);\n    return 1;  \n  } \n#endif\n  return 0;\n\n}\n\n\ncPitchJitter::~cPitchJitter()\n{\n  // cleanup...\n  if (out != NULL) {\n    delete out;\n  }\n  if (F0reader != NULL) {\n    delete F0reader;\n  }\n  if (filehandle != NULL) {\n    fclose(filehandle);\n  }\n}\n\n"
  },
  {
    "path": "src/lld/pitchShs.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nInput log2 scale spectrum\n\n*/\n\n\n\n#include <lld/pitchShs.hpp>\n\n#define MODULE \"cPitchShs\"\n\n\nSMILECOMPONENT_STATICS(cPitchShs)\n\nSMILECOMPONENT_REGCOMP(cPitchShs)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CPITCHSHS;\n  sdescription = COMPONENT_DESCRIPTION_CPITCHSHS;\n\n  // we inherit cPitchBase configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cPitchBase\")\n\n  const ConfigType *r2 = sconfman->getTypeObj(\"cDataWriter\");\n  if (r2 == NULL) {\n    SMILE_WRN(4,\"%s config Type not found!\",\"configtype\");\n    rA=1;\n  } else {\n    ConfigType * ct2 = new ConfigType( *(r2) , \"cDataWriterShs\" );\n    ct2->setField(\"dmLevel\", NULL, \"___shs__dummy__\");\n    if (ct->setField(\"shsWriter\", \"Configuration of the dataMemory writer sub-component which is used to dump the SHS spectrum.\",\n                      ct2, NO_ARRAY) == -1) {\n       rA = 1; // if subtype not yet found, request , re-register in the next iteration\n    }\n  }\n\n  // if the inherited config type was found, we register our configuration variables\n  SMILECOMPONENT_IFNOTREGAGAIN( {} // <- this is only to avoid compiler warnings...\n    // name append has a special role: it is defined in cDataProcessor, and can be overwritten here:\n\t  // if you set description to NULL, the existing description will be used, thus the following call can\n  \t// be used to update the default value:\n    //ct->setField(\"nameAppend\",NULL,\"processed\");\n\n    // add custom config here...\n    ct->setField(\"inputFieldSearch\",NULL,\"Mag_logScale\");\n    ct->setField(\"nHarmonics\",\"Number of harmonics to consider for subharmonic sampling (feasible values: 5-15)\",15);\n    ct->setField(\"compressionFactor\",\"The factor for successive compression of sub-harmonics\",0.85);\n    ct->setField(\"voicingCutoff\",NULL,0.70);\n    ct->setField(\"octaveCorrection\",\"1 = enable low-level octave correction tuned for the SHS algorithm (will affect F0C1, voicingC1 and F0raw output fields) [EXPERIMENTAL! MAY BREAK CORRECT PITCH DETECTION!]\",0);\n    ct->setField(\"greedyPeakAlgo\",\"1 = use new algorithm to return all maximum score candidates regardless of their order. The old algorithm added new candidates only if they were higher scored as the first one. Enabling this seems to require different viterbi parameters for smoothing though, so use with caution! Default behaviour is 'off' so we remain backwards compatibility.\",0);\n    ct->setField(\"shsSpectrumOutput\", \"If set to 1, then the sub-harmonic summation spectra frames will be written to the level specified by shsWriter.dmLevel.\", 0);\n    ct->setField(\"lfCut\", \"> 0 = remove low frequency information up to given frequency from input spectrum by zeroing all bins below.\", 0);\n  )\n\n  // The configType gets automatically registered with the config manger by the SMILECOMPONENT_IFNOTREGAGAIN macro\n  \n  // we now create out sComponentInfo, including name, description, success status, etc. and return that\n  SMILECOMPONENT_MAKEINFO(cPitchShs);\n}\n\nSMILECOMPONENT_CREATE(cPitchShs)\n\n//-----\n\ncPitchShs::cPitchShs(const char *_name) :\n  cPitchBase(_name),\n    SS(NULL), Fmap(NULL), shsWriter_(NULL), shsVector_(NULL)\n{\n  char *tmp = myvprint(\"%s.shsWriter\", getInstName());\n  shsWriter_ = (cDataWriter *)(cDataWriter::create(tmp));\n  if (shsWriter_ == NULL)\n    COMP_ERR(\"Error creating dataWriter '%s'\",tmp);\n  if (tmp != NULL)\n    free(tmp);\n}\n\nvoid cPitchShs::fetchConfig()\n{\n  cPitchBase::fetchConfig();\n\n  // fetch custom config here...\n  nHarmonics = getInt(\"nHarmonics\");\n  SMILE_IDBG(2,\"nHarmonics = %i\\n\",nHarmonics);\n\n  compressionFactor = (FLOAT_DMEM)getDouble(\"compressionFactor\");\n  SMILE_IDBG(2,\"compressionFactor = %f\\n\",compressionFactor);\n\n  greedyPeakAlgo = getInt(\"greedyPeakAlgo\");\n\n  shsSpectrumOutput = getInt(\"shsSpectrumOutput\");\n  lfCut_ = getDouble(\"lfCut\");\n}\n\nvoid cPitchShs::mySetEnvironment()\n{\n  cPitchBase::mySetEnvironment();\n  if (shsSpectrumOutput != 0) {\n    shsWriter_->setComponentEnvironment(getCompMan(), -1, this);\n  }\n}\n\nint cPitchShs::myRegisterInstance(int *runMe)\n{\n  int ret = cPitchBase::myRegisterInstance(runMe);\n  if (shsSpectrumOutput != 0) {\n    ret *= shsWriter_->registerInstance();\n  }\n  return ret;\n}\n\nint cPitchShs::myConfigureInstance()\n{\n  int ret = cPitchBase::myConfigureInstance();\n  if (ret != 0 && shsSpectrumOutput != 0) {\n    const sDmLevelConfig * c = reader_->getConfig();\n    sDmLevelConfig c2(*c);\n    shsWriter_->setConfig(c2, 0);\n    if (!(shsWriter_->configureInstance())) return 0;\n  }\n  return ret;\n}\n\nint cPitchShs::myFinaliseInstance()\n{\n  int ret = cPitchBase::myFinaliseInstance();\n  if (ret != NULL && shsSpectrumOutput != 0) {\n    if (!(shsWriter_->finaliseInstance())) return 0;\n  }\n  return ret;\n}\n\nint cPitchShs::cloneInputFieldInfoShs(int sourceFidx, int targetFidx, int force)\n{\n  const FrameMetaInfo * fmeta = reader_->getFrameMetaInfo();\n  if ((fmeta != NULL) && (sourceFidx < fmeta->N)) {\n    const FrameMetaInfo * fmetaW = shsWriter_->getFrameMetaInfo();\n    int isset = 0;\n    if (fmetaW != NULL) {\n      if ((fmetaW->N > 0) && (fmetaW->field[fmetaW->N-1].infoSet)) isset = 1;\n      if (!isset || force) {\n        if (fmeta->field[sourceFidx].infoSize > 0) { // TODO: check why we had infoSize==0 here!! (valgrind leak check revealed this...)\n          void * _info = malloc(fmeta->field[sourceFidx].infoSize);\n          memcpy(_info, fmeta->field[sourceFidx].info, fmeta->field[sourceFidx].infoSize);\n          shsWriter_->setFieldInfo(targetFidx, fmeta->field[sourceFidx].dataType, _info , fmeta->field[sourceFidx].infoSize );\n        }\n      }\n      return 1;\n    }\n  }\n  return 0;\n}\n\nint cPitchShs::setupNewNames(long nEl)\n{\n  int n = cPitchBase::setupNewNames(nEl);\n  // set up custom names here:\n\n  cVectorMeta *mdata = reader_->getLevelMetaDataPtr();\n  FLOAT_DMEM _fmint, _fmaxt, _fmin;\n  if (mdata != NULL) {\n    _fmin = mdata->fData[0];\n    //_fmax = mdata->fData[1];\n    nOctaves = mdata->fData[2];\n    nPointsPerOctave = mdata->fData[3];\n    _fmint = mdata->fData[4];\n    _fmaxt = mdata->fData[5];\n    if (nOctaves == 0.0) {\n      SMILE_IERR(1,\"cannot read valid 'nOctaves' from input level meta data, please check if the input is a log(2) scale spectrum from a cSpecScale component!\");\n      COMP_ERR(\"aborting!\");\n    }\n  }\n\n  // check for octave scaling:\n  base = exp( log((double)_fmin)/(double)_fmint );\n  if (fabs(base-2.0) < 0.00001) {\n   // oct scale ok\n    base = 2.0;\n  } else {\n   // warn: not oct scale, adjust base internally... untested!\n    SMILE_IWRN(1,\"log base is not 2.0 (no octave scale spectrum)! Untested behaviour! (base = %f, _fmin %f, _fmint %f)\",base,_fmin,_fmint);\n  }\n\n  Fmint = _fmint;\n  Fstept = (_fmaxt-_fmint)/(FLOAT_DMEM)(nInput_-1);\n\n/*  // build frequency mapping for log spectral axis: (obsolete!?)\n  Fmap = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*nInput);\n  long i; \n  for (i=0; i<nInput; i++) {\n    Fmap[i] = exp(f*log(base)); // we assume octave scaling here!!\n    f += fstep;\n  }*/\n\n  // allocate array for sum spectrum\n  SS = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*nInput_);\n\n  if (shsSpectrumOutput != 0) {\n    int _N = reader_->getLevelNf();\n    int i;\n    for (i=0; i<_N; i++) {\n      int __N=0;\n      int arrNameOffset=0;\n      const char *tmp = reader_->getFieldName(i, &__N, &arrNameOffset);\n      shsWriter_->addField( tmp, __N, arrNameOffset );\n      cloneInputFieldInfo(i, -1, 0); // last parameter = 0 => no overwrite of info data\n    }\n  }\n  return n;\n}\n\nint cPitchShs::pitchDetect(FLOAT_DMEM * _inData, long _N, double _fsSec, double _baseT, FLOAT_DMEM *_f0cand, FLOAT_DMEM *_candVoice, FLOAT_DMEM *_candScore, long _nCandidates)\n{\n  int nCand = 0;\n  long i,j;\n  if (nOctaves == 0.0) return -1;\n  \n\n\t/* remove lower frequencies */\n  if (lfCut_ > 0.0) {\n    int bin = (int)((ceil(log(lfCut_)/log(base)) - Fmint)/Fstept);\n    SMILE_IMSG(2, \"lfCut: <= bin %i from %i\", bin, _N);\n    for (i = 0; i <= bin; i++) {\n      _inData[i] = 0.0;\n    }\n  }\n\n  for (j=0; j < _N; j++) {\n    SS[j] = _inData[j];\n  }\n\n  /* subharmonic summation; shift spectra by octaves and add */\n\n\n\n  FLOAT_DMEM _scale = compressionFactor;\n  \n  for (i=2; i < nHarmonics+1; i++) {\n    long shift = (long)floor ((double)nPointsPerOctave * smileMath_log2(i));\n    for (j=shift; j < _N; j++) {\n      SS[j-shift] += _inData[j] * _scale;\n    }\n    _scale *= compressionFactor;\n  }\n  for (j=0; j < _N; j++) {\n    SS[j] /= (FLOAT_DMEM)nHarmonics;  // Is this needed?\n    if (SS[j] < 0) SS[j] = 0.0;\n  }\n  // TODO : support output of SHS spectrum here for vis and debug\n  if (shsSpectrumOutput != 0) {\n    if (shsVector_ == NULL) {\n      shsVector_ = new cVector(_N, DMEM_FLOAT);\n    }\n    memcpy(shsVector_->dataF, SS, _N * sizeof(FLOAT_DMEM));\n    // TODO: properly set timestamps\n    shsWriter_->setNextFrame(shsVector_);\n  }\n\n  // peak candidate picking & computation of SS vector mean\n  _candScore[0] = 0.0;\n  double ssMean = (double)SS[0];\n  for (i=1; i<_N-1; i++) {\n    if (greedyPeakAlgo) { // use new (correct?) max. score peak detector\n\n\n    if ( (SS[i-1] < SS[i]) && (SS[i] > SS[i+1]) ) { // <- peak detection\n        //    && ((SS[i] > _candScore[0])||(_candScore[0]==0.0)) ) { // is max. peak or first peak?\n\n      // add candidate at first free spot or behind another higher scored one...\n      for (j=0; j<_nCandidates; j++) {\n        if (_candScore[j]==0.0 || _candScore[j]<SS[i]) {\n          // move remaining candidates downwards..\n          int jj;\n          for (jj=_nCandidates-1; jj>j; jj--) {\n            _candScore[jj] = _candScore[jj-1];\n            _f0cand[jj] = _f0cand[jj-1];\n          }\n          // add this one...\n          _f0cand[j] = (FLOAT_DMEM)i;\n          _candScore[j] = SS[i];\n          if (nCand<_nCandidates) nCand++;\n          break; // leave the for loop after adding candidate to array\n        }\n      }\n\n    }\n    } else {\n\n      if ( (SS[i-1] < SS[i]) && (SS[i] > SS[i+1])\n              && ((SS[i] > _candScore[0])||(_candScore[0]==0.0)) ) { // is max. peak or first peak?\n\n\n  // TODO:!! this algorithm might only add one candidate, if the first one added is the maximum score candidate. This will degarde performance of following viterbi smoothing!\n  // CLEAN SOLUTION: find all peaks, then sort by score, and output to \"nCandidates\"\n  // old algo:\n        // shift candScores and f0cand (=indicies)\n        for (j=_nCandidates-1; j>0; j--) {\n          _candScore[j] = _candScore[j-1];\n          _f0cand[j] = _f0cand[j-1];\n        }\n        _f0cand[0] = (FLOAT_DMEM)i;\n        _candScore[0] = SS[i];\n        if (nCand<_nCandidates) nCand++;\n      }\n\n    }\n    ssMean += (double)SS[i];\n  }\n  ssMean = (ssMean+(double)SS[i])/(double)_N;\n\n  // convert peak candidate frequencies and compute voicing prob.\n  for (i=0; i<nCand; i++) {\n    long j = (long)_f0cand[i];\n    // parabolic peak interpolation:\n    FLOAT_DMEM f1 = _f0cand[i]*Fstept + Fmint;\n    FLOAT_DMEM f2 = (_f0cand[i]+(FLOAT_DMEM)1.0)*Fstept + Fmint;\n    FLOAT_DMEM f0 = (_f0cand[i]-(FLOAT_DMEM)1.0)*Fstept + Fmint;\n    double sc=0;\n    double fx = smileMath_quadFrom3pts((double)f0, (double)SS[j-1], (double)f1, (double)SS[j], (double)f2, (double)SS[j+1], &sc, NULL);\n    // convert log(2) frequency scale to lin frequency scale (Hz):\n    _f0cand[i] = (FLOAT_DMEM)exp(fx*log(base));\n    _candScore[i] = (FLOAT_DMEM)sc;\n    if ((sc > 0.0)&&(sc>ssMean)) {\n      _candVoice[i] = (FLOAT_DMEM)( 1.0 - ssMean/sc );\n    } else {\n      _candVoice[i] = 0.0;\n    }\n  }\n\n  // octave correction of first candidate:\n  if (octaveCorrection) {\n    /*\n     algo: prefer lower candidate, if voicing prob of lower candidate approx. voicing prob of first candidate (or > voicing cutoff)\n     and if score of lower candidate > ( 1/((nHarmonics-1)*compressionFactor) )*score of cand[0]\n     */\n    for (i=0; i<nCand; i++) {\n      if ( (_f0cand[i] < _f0cand[0])&&(_f0cand[i] > 0) && ((_candVoice[i] > voicingCutoff)||(_candVoice[i]>=0.9*voicingCutoff)) && (_candScore[i] > ((1.0/(FLOAT_DMEM)(nHarmonics-1)*compressionFactor))*_candScore[0]) ) {\n        // then swap:\n        FLOAT_DMEM tmp;\n        tmp = _f0cand[0];\n        _f0cand[0] = _f0cand[i]; \n        _f0cand[i] = tmp;\n        tmp = _candVoice[0];\n        _candVoice[0] = _candVoice[i]; \n        _candVoice[i] = tmp;\n        tmp = _candScore[0];\n        _candScore[0] = _candScore[i]; \n        _candScore[i] = tmp;\n      }\n    }\n  }\n\n  // return actual number of candidates on success (-1 on failure...)\n  return nCand;\n}\n\nint cPitchShs::addCustomOutputs(FLOAT_DMEM *dstCur, long NdstLeft)\n{\n  // to be implemented by child class\n\n  // return the number of custom outputs that were added..\n  return 0;\n}\n\n\ncPitchShs::~cPitchShs()\n{\n  if (SS != NULL) free(SS);\n  if (Fmap != NULL) free(Fmap);\n  if (shsVector_ != NULL) delete(shsVector_);\n  if (shsWriter_ != NULL) delete(shsWriter_);\n}\n\n"
  },
  {
    "path": "src/lld/pitchSmootherViterbi.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n// TODO: discard pitch < 80 Hz, if 2 or less frames only (i.e. set to 0, unvoiced)\n// TODO: discard pitch < 60 Hz, if 5 or less frames only (i.e. set to 0, unvoiced)\n\n/*  openSMILE component:\n\nviterbi pitch smoothing. \nLoosely based on:\nI. Luengo (Basque Univ., Bilbao), \"Evaluation of Pitch Detection Algorithms Under Real Conditions\", Proc. ICASSP 2007\n\n*/\n\n\n#include <lld/pitchSmootherViterbi.hpp>\n\n#define MODULE \"cPitchSmootherViterbi\"\n\nSMILECOMPONENT_STATICS(cPitchSmootherViterbi)\n\nSMILECOMPONENT_REGCOMP(cPitchSmootherViterbi)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CPITCHSMOOTHERVITERBI;\n  sdescription = COMPONENT_DESCRIPTION_CPITCHSMOOTHERVITERBI;\n\n  // we inherit cDataProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataProcessor\")\n  \n  if (ct->setField(\"reader2\", \"Configuration of the dataMemory reader sub-component which is used to read input frames with a certain lag (max. bufferLength!).\",\n                    sconfman->getTypeObj(\"cDataReader\"), NO_ARRAY, DONT_FREE) == -1) {\n       rA=1; // if subtype not yet found, request , re-register in the next iteration\n  }\n\n  SMILECOMPONENT_IFNOTREGAGAIN(\n   ct->setField(\"bufferLength\",\"The length of the delay buffer in (input) frames. This is the amount of data that will be used for the Viterbi smoothing, and it is also the lag which the output is behind the input. The input level buffer must be at least bufferLength+1 in size!.\",30);\n\n   // new data\n   ct->setField(\"F0final\",\"1 = Enable output of final (corrected and smoothed) F0 -- linear scale\", 1);\n   ct->setField(\"F0finalLog\",\"1 = Enable output of final (corrected and smoothed) F0 in logarithmic representation (semitone scale with base note 27.5 Hz - a linear F0 equal to and below 29.136 Hz (= 1 on the semitone scale) will be clipped to an output value of 1, since 0 is reserved for unvoiced).\", 0);\n   ct->setField(\"F0finalEnv\",\"1 = Enable output of envelope of final smoothed F0 (i.e. there will be no 0 values (except for the beginning). Envelope method is to hold the last valid sample, no interpolation is performed. [EXPERIMENTAL!]\",0);\n   ct->setField(\"F0finalEnvLog\",\"1 = Enable output of envelope of final smoothed F0 (i.e. there will be no 0 values (except for end and beginning)) in a logarithmic (semitone, base note 27.5 Hz - a linear F0 equal to and below 29.136 Hz (= 1 on the semitone scale) will be clipped to an output value of 1, since 0 is reserved for unvoiced) frequency scale. Envelope method is sample and hold, no interpolation is performed. [EXPERIMENTAL!]\",0);\n\n   ct->setField(\"no0f0\",\"1 = enable 'no zero F0', output data only when F0>0, i.e. a voiced frame is detected. This may cause problem with some functionals and framer components, which don't support this variable length data yet...\",0);\n\n   ct->setField(\"voicingFinalClipped\",\"1 = Enable output of final smoothed and clipped voicing (pseudo) probability. 'Clipped' means that the voicing probability is set to 0 for unvoiced regions, i.e. where the probability lies below the voicing threshold.\",0);\n   ct->setField(\"voicingFinalUnclipped\",\"1 = Enable output of final smoothed, raw voicing (pseudo) probability (UNclipped: not set to 0 during unvoiced regions).\",0);\n\n   // data forwarded from pitch detector\n   ct->setField(\"F0raw\",\"1 = Enable output of 'F0raw' copied from input\",0);\n   ct->setField(\"voicingC1\",\"1 = Enable output of 'voicingC1' copied from input\",0);\n   ct->setField(\"voicingClip\",\"1 = Enable output of 'voicingClip' copied from input\",0);\n\n   //viterbi parameters\n   ct->setField(\"wLocal\",\"Viterbi weight for local log. voice probs. A higher weight here will favour candidates with a high voicing probability.\",2.0);\n   ct->setField(\"wTvv\",\"Viterbi weight for voiced-voiced transition. A higher weight here will favour a flatter pitch curve (less jumps)\",10.0);\n   ct->setField(\"wTvvd\",\"Viterbi weight for smoothness of voiced-voiced transition. A higher weight here will favour a flatter pitch curve (less jumps)\",5.0);\n   ct->setField(\"wTvuv\",\"Viterbi cost for voiced-unvoiced transitions. A higher value will reduce the number of voiced-unvoiced transitions.\",10.0);\n   ct->setField(\"wThr\",\"Viterbi cost bias for voice prob. crossing the voicing threshold. A higher value here will force voiced/unvoiced decisions by the Viterbi algorithm to be more close to the threshold based decision. A lower value, e.g. 0, will ignore the voicing threshold completely (not recommended).\",4.0);\n   ct->setField(\"wRange\",\"Viterbi weight for frequency range constraint. A higher value will enforce the given frequency weighting more strictly, i.e. favour pitch frequencies between 100 Hz and 300 Hz.\",1.0);\n   ct->setField(\"wTuu\",\"Viterbi cost for unvoiced-unvoiced transitions. There should be no need to change the default value of 0.\",0);\n\n  )\n  \n  SMILECOMPONENT_MAKEINFO(cPitchSmootherViterbi);\n}\n\n\nSMILECOMPONENT_CREATE(cPitchSmootherViterbi)\n\n//-----\n\nlong cSmileViterbi::addFrame(FLOAT_DMEM *frame)\n{\n  int i,j;\n\n  /* check for free space in the buffer, if no free space, return -1, the user needs to call getNextOutput first */\n  if (wrIdx-rdIdx < buflen) {\n    /* add the frame to the buffer */\n    FLOAT_DMEM * b = buf+((wrIdx%buflen)*frameSize);\n    memcpy(b,frame,sizeof(FLOAT_DMEM)*frameSize);\n    wrIdx++;\n    FLOAT_DMEM * a = prev; prev = b;\n\n    /* perform one step viterbi */\n\n    if (pathIdx == 0 || prev == NULL) {\n      pathIdx = 0; convIdx = -1;\n      /* trellis initialisation (no transp from previous states) */\n      for (i=0; i<nStates; i++) {\n        pathCosts[i] = localCost(i,frame);\n        paths[pathBuf][i*buflen] = i;\n      }\n    } else {\n      /* trellis updates */\n      int pathBufNew = (pathBuf+1)%2;\n//printf(\"XX Cost: \");\n      for (i=0; i<nStates; i++) {\n        /*  update all the state probabilities for the current timestep */\n\n        /* find best path into current state */\n        int minState = 0;\n        double minCost;\n        minCost = pathCostsTemp[0] = transitionCost(i, 0, a, b) + pathCosts[0];\n        for (j=1; j<nStates; j++) {\n          pathCostsTemp[j] = transitionCost(i, j, a, b) + pathCosts[j];\n          if (pathCostsTemp[j] < minCost) {\n            minState = j;\n            minCost = pathCostsTemp[j];\n          }\n        }\n\n        /* update new cost */\n        pathCostsNew[i] = minCost + localCost(i,frame);\n//printf(\"%f \",pathCostsNew[i]);\n        /* copy and update path */\n        memcpy(paths[pathBufNew] + i*buflen, paths[pathBuf] + minState*buflen, buflen*sizeof(int));\n        paths[pathBufNew][i*buflen + pathIdx%buflen] = i;\n      }\n//printf(\"\\n\");\n\n      /* copy new costs to pathCosts */\n      double * tmp = pathCosts;\n      pathCosts = pathCostsNew;\n      pathCostsNew = tmp;\n\n      /* swap path buffers */\n      pathBuf = pathBufNew;\n    }\n\n    pathIdx++;\n    if (pathIdx-convIdx > buflen) { /* > ok here, since convIdx starts at -1 */\n      /*\n       *  forced decision for the first (oldest) element in the path, based upon best final path\n       *\n       */\n      SMILE_MSG(4,\"cSmileViterbi: Forced viterbi trellis flush. If you get this message often, increase the 'bufferLength' option.\\n\");\n\n      /* find current path with minimal cost */\n      int minState = 0;\n      for (i=1; i<nStates; i++) {\n        if (pathCosts[i] < pathCosts[minState]) {\n          minState = i;\n        }\n      }\n\n      convIdx++;\n      int x = paths[pathBuf][minState*buflen + (convIdx)%buflen];\n      bestPath[convIdx%buflen] = x;\n\n    } else {\n      /* find point where all paths merge */\n      long n;\n      for (n=convIdx+1; n<pathIdx; n++) {\n        int x = paths[pathBuf][n%buflen];\n        int match = 1;\n        for (i=1; i<nStates; i++) {\n          if (x != paths[pathBuf][i*buflen+n%buflen]) {\n            match = 0;\n            break;\n          }\n        }\n        if (!match) { break; }\n        else {\n          convIdx++;\n          bestPath[convIdx%buflen] = x;\n        }\n        // TODO: shouldn't we choose the best path here and not the first??\n      }\n\n    }\n\n    return getNAvail();\n\n  } else {\n    return -1;\n  }\n\n\n}\n\n/* return next output value, optionally returns a pointer to the full input frame\n * !this pointer is only valid until the next call to any function in this class!\n */\nFLOAT_DMEM cSmileViterbi::getNextOutputFrame(FLOAT_DMEM ** frame=NULL, int *avail=NULL, int *state=NULL)\n{\n  FLOAT_DMEM result=0.0;\n\n  long av = getNAvail();\n  if (avail != 0) *avail = av;\n\n  if (av > 0) {\n    /* find best path state */\n    int s = bestPath[rdIdx%buflen];\n    if (state != NULL) *state = s;\n\n    FLOAT_DMEM * b =  buf+((rdIdx%buflen)*frameSize);\n    result = getStateValueFromFrame(s,b);\n\n    /* return full frame */\n    if (frame != NULL) {\n      *frame = b;\n    }\n\n    rdIdx++;\n  }\n\n  return result;\n}\n\n/* TODO!!!!\n *\n * some pitch candidates may no be valid, so we don't want the viterbi algo's paths to go through them...\n *  a) we fill them with 0's and ensure these will be penalised enough in the trans&local probs.\n *  b) if a candidate is missing for a few frames? interpolate it or not? right now: no... later on, maybe find an intelligent way to determine which one is missing and use the previous value for it...\n */\n\n//-------\n\ncPitchSmootherViterbi::cPitchSmootherViterbi(const char *_name) :\n  cDataProcessor(_name), viterbi(NULL), framePtr(NULL), vecO(NULL), buflen(0), outpVecSize(0),\n  nInputLevels(1), lastValidf0(0.0)\n{\n  char *tmp = myvprint(\"%s.reader2\",getInstName());\n  reader2 = (cDataReader *)(cDataReader::create(tmp));\n  if (reader2 == NULL) {\n    COMP_ERR(\"Error creating dataReader '%s'\",tmp);\n  }\n  if (tmp!=NULL) free(tmp);\n}\n\nvoid cPitchSmootherViterbi::fetchConfig() {\n  cDataProcessor::fetchConfig();\n\n  // load all configuration parameters you will later require for fast and easy access to here:\n\n  buflen = getInt(\"bufferLength\");\n  // note, that it is \"polite\" to output the loaded parameters at debug level 2:\n  SMILE_DBG(2,\"bufferLength = %f\",buflen);\n\n  F0final = getInt(\"F0final\");\n  SMILE_IDBG(2,\"F0final = %i\",F0final);\n  F0finalLog = getInt(\"F0finalLog\");\n  F0finalEnv = getInt(\"F0finalEnv\");\n  SMILE_IDBG(2,\"F0finalEnv = %i\",F0finalEnv);\n  F0finalEnvLog = getInt(\"F0finalEnvLog\");\n  //no0f0 = getInt(\"no0f0\");\n  //SMILE_IDBG(2,\"no0f0 = %i (not yet well supported)\",no0f0);\n\n  voicingFinalClipped = getInt(\"voicingFinalClipped\");\n  SMILE_IDBG(2,\"voicingFinalClipped = %i\",voicingFinalClipped);\n  voicingFinalUnclipped = getInt(\"voicingFinalUnclipped\");\n  SMILE_IDBG(2,\"voicingFinalUnclipped = %i\",voicingFinalUnclipped);\n\n  F0raw = getInt(\"F0raw\");\n  SMILE_IDBG(2,\"F0raw = %i\",F0raw);\n  voicingC1 = getInt(\"voicingC1\");\n  SMILE_IDBG(2,\"voicingC1 = %i\",voicingC1);\n  voicingClip = getInt(\"voicingClip\");\n  SMILE_IDBG(2,\"voicingClip = %i\",voicingClip);\n\n  wLocal = getDouble(\"wLocal\");\n  wTvv = getDouble(\"wTvv\");\n  wTvvd = getDouble(\"wTvvd\");\n  wTvuv = getDouble(\"wTvuv\");\n  wThr = getDouble(\"wThr\");\n  wRange = getDouble(\"wRange\");\n  wTuu = getDouble(\"wTuu\");\n\n}\n\n/*  This method is rarely used. It is only there to improve readability of component code.\n    It is called from cDataProcessor::myFinaliseInstance just before the call to configureWriter.\n    I.e. you can do everything that you would do here, also in configureWriter()\n    However, if you implement the method, it must return 1 in order for the configure process to continue!\n*/\n\nint cPitchSmootherViterbi::configureReader(const sDmLevelConfig &c)\n{\n  int ret = cDataProcessor::configureReader(c);\n  reader2->setBlocksize(buflen); /* this will ensure enough frames in the input level buffer */\n  return ret;\n}\n\nvoid cPitchSmootherViterbi::mySetEnvironment()\n{\n  cDataProcessor::mySetEnvironment();\n  reader2->setComponentEnvironment(getCompMan(), -1, this);\n}\n\nint cPitchSmootherViterbi::myRegisterInstance(int *runMe)\n{\n  int ret = cDataProcessor::myRegisterInstance(runMe);\n  ret *= reader2->registerInstance();\n  return ret;\n}\n\nint cPitchSmootherViterbi::myConfigureInstance()\n{\n  if (!(reader2->configureInstance())) return 0;\n  if (!(reader2->finaliseInstance())) return 0;\n\n  int ret = cDataProcessor::myConfigureInstance();\n  return ret;\n}\n\n\nint cPitchSmootherViterbi::configureWriter(sDmLevelConfig &c) \n{\n  c.blocksizeWriter = buflen;\n  c.blocksizeIsSet = 1;\n  return 1;\n}\n\n\n/* \n  Use setupNewNames() to freely set the data elements and their names in the output level\n  The input names are available at this point, you can get them via reader->getFrameMeta()\n  Please set \"namesAreSet\" to 1, when you do set names\n*/\n\nint cPitchSmootherViterbi::setupNewNames(long nEl) \n{\n  ///// set-up the output fields\n\n  // final (smoothed) output\n\n  if (F0final) {\n    writer_->addField(\"F0final\", 1); outpVecSize++;\n  }\n  if (F0finalLog) {\n    writer_->addField(\"F0finalLog\", 1); outpVecSize++;\n  }\n\n  if (F0finalEnv) {\n    writer_->addField(\"F0finEnv\", 1); outpVecSize++;\n  }\n  if (F0finalEnvLog) {\n    writer_->addField(\"F0finEnvLog\", 1); outpVecSize++;\n  }\n\n  if (voicingFinalClipped) { writer_->addField(\"voicingFinalClipped\", 1); outpVecSize++; }\n  if (voicingFinalUnclipped) { writer_->addField(\"voicingFinalUnclipped\", 1); outpVecSize++; }\n\n  // copied from input:\n  if (F0raw) { writer_->addField( \"F0raw\", 1 ); outpVecSize++; }\n  if (voicingC1) { writer_->addField( \"voicingC1\", 1 ); outpVecSize++;}\n  if (voicingClip) { writer_->addField( \"voicingClip\", 1 ); outpVecSize++; }\n\n   long i,idx;\n   nInputLevels = reader_->getNLevels();\n   if (nInputLevels<1) nInputLevels=1;\n   voicingCutoff = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*nInputLevels);\n   nCandidates = (long*)calloc(1,sizeof(long)*nInputLevels);\n   //nCands = (int*)calloc(1,sizeof(int)*nInputLevels);\n   f0candI = (int*)calloc(1,sizeof(int)*nInputLevels);\n   candVoiceI = (int*)calloc(1,sizeof(int)*nInputLevels);\n   candScoreI = (int*)calloc(1,sizeof(int)*nInputLevels);\n   F0rawI = (int*)calloc(1,sizeof(int)*nInputLevels);\n   voicingClipI = (int*)calloc(1,sizeof(int)*nInputLevels);\n   voicingC1I = (int*)calloc(1,sizeof(int)*nInputLevels);\n\n  // totalCands = 0;\n   int more=0; int moreV=0; int moreS=0;\n   int moreC1=0; int moreRa=0; int moreVc=0;\n\n   ////// find the input fields by their names...\n   for (i=0; i<nInputLevels; i++) {\n\n     cVectorMeta *mdata = reader_->getLevelMetaDataPtr(i);\n     if (mdata != NULL) {\n       // TODO : check mdata ID\n       voicingCutoff[i] = mdata->fData[0];\n       SMILE_IMSG(3,\"voicing cutoff read from input level %i = %f\",i,voicingCutoff[i]);\n     }\n\n     if (F0raw) {\n       int idxRa = findField(\"F0raw\",0,NULL,NULL,-1,&moreRa); // TODO: check if nC == 1 here\n       //printf(\"idxRa %i moreRa %i  i %i\\n\",idxRa,moreRa,i);\n       F0rawI[i] = idxRa;\n       if (moreRa>0) { moreRa = idxRa+1; }\n     }\n     if (voicingClip) {\n       int idxVc = findField(\"voicingClip\",0,NULL,NULL,-1,&moreVc); // TODO: check if nC == 1 here\n       voicingClipI[i] = idxVc;\n       if (moreVc>0) { moreVc = idxVc+1; }\n     }\n     if (voicingC1) {\n       int idxC1 = findField(\"voicingC1\",0,NULL,NULL,-1,&moreC1); // TODO: check if nC == 1 here\n       voicingC1I[i] = idxC1;\n       if (moreC1>0) { moreC1 = idxC1+1; }\n     }\n\n     idx = findField(\"F0Cand\",0,nCandidates+i,NULL,-1,&more);\n     f0candI[i] = idx;\n//printf(\"XXX idx %i  ncand[%i]=%i\\n\",idx,i,nCandidates[i]);\n     if (idx >= 0) {\n       int idxV = findField(\"candVoicing\",0,NULL,NULL,-1,&moreV);\n       candVoiceI[i] = idxV;\n       if (moreV>0) { moreV = idxV+1; }\n       int idxS = findField(\"candScore\",0,NULL,NULL,-1,&moreS); // TODO: check if nC == N here\n       candScoreI[i] = idxS;\n       if (moreS>0) { moreS = idxS+1; }\n       //nCandidates[i] = nC;\n       if (more>0) { more = idx+1; }\n       else {\n         //totalCands += nC;\n         nInputLevels = i+1;\n         break;\n       }\n     } else {\n       nCandidates[i] = 0;\n       nInputLevels = i;\n       break;\n     }\n     //totalCands += nC;\n\n     //if (nCandidates[0] > 0 && nCandidates[0] < 1000 /* upper limit to prevent out of memory when invalid values for nCandidates are received*/ ) {\n// ???\n    // }\n   }\n\n//printf(\"XXXX ncand0 = %i , nInputLevels = %i\\n\",nCandidates[0],reader->getNLevels());\n\n   namesAreSet_ = 1;\n   return outpVecSize;\n}\n\n\nint cPitchSmootherViterbi::myFinaliseInstance()\n{\n  int ret = cDataProcessor::myFinaliseInstance();\n  if (ret) {\n    /* create viterbi object */\n    voiceThresh = voicingCutoff[0];\n    viterbi = new cSmileViterbiPitchSmooth(nCandidates[0], buflen, nCandidates[0]*2 + 4, voiceThresh);\n    viterbi->setWeights(wLocal, wTvv, wTvvd, wTvuv, wThr, wRange, wTuu);\n    framePtr = (FLOAT_DMEM *)malloc(sizeof(FLOAT_DMEM) * (nCandidates[0] * 2 + 4) );\n  }\n  return ret;\n}\n\n\nint cPitchSmootherViterbi::myTick(long long t)\n{\n  /*\n   * TODO: pitch range weighting (either on the fly, message based data, or pre-loaded, or standard range (built-in))\n   */\n\n  long avail=0;\n  long i;\n\n  if (isEOI()) {\n    /* flush trellis on EOI */\n    viterbi->flushTrellis();\n    avail = viterbi->getNAvail();\n  } else {\n    // get next frame from dataMemory\n    cVector *vec = reader_->getNextFrame();\n    if (vec == NULL) return 0;\n\n    // fill framePtr: candidates first, then 3 values from input..\n    for (i=0; i<nCandidates[0]; i++) {\n      // TODO : add candidates from other input levels...\n      framePtr[i*2] = vec->dataF[f0candI[0]+i];\n      framePtr[i*2+1] = vec->dataF[candVoiceI[0]+i];\n    }\n    if (F0rawI[0] >= 0) framePtr[nCandidates[0]*2] = vec->dataF[F0rawI[0]];\n    else framePtr[nCandidates[0]*2] = 0.0;\n\n    if (voicingClipI[0] > 0) framePtr[nCandidates[0]*2+1] = vec->dataF[voicingClipI[0]];\n    else framePtr[nCandidates[0]*2+1] = 0.0;\n\n    if (voicingC1I[0] > 0) framePtr[nCandidates[0]*2+2] = vec->dataF[voicingC1I[0]];\n    else framePtr[nCandidates[0]*2+2] = 0.0;\n\n    /* TODO: store vIdx as long in framePtr... */\n    *(framePtr + (nCandidates[0]*2+3)) = (FLOAT_DMEM)vec->tmeta->vIdx;\n\n    avail = viterbi->addFrame(framePtr);\n  }\n\n  if (avail > 0) {\n\n    if (vecO == NULL) {\n      vecO = new cVector(outpVecSize);\n    }\n\n    /* read all available output frames and send them to the writer */\n    for (i=0; i<avail; i++) {\n      int av, state;\n      FLOAT_DMEM *frameOptr=NULL;\n      FLOAT_DMEM f0 = viterbi->getNextOutputFrame(&frameOptr, &av, &state);\n      long n=0;\n      if (F0final) {\n        vecO->dataF[n++] = f0;\n      }\n      if (F0finalLog) {\n        FLOAT_DMEM f0scaled = 0.0;\n        if (f0 > 29.136) {\n          // semi-tone scale, base tone 27.5 Hz\n          f0scaled = (FLOAT_DMEM)12.0 * log(f0 / (FLOAT_DMEM)27.5) / log((FLOAT_DMEM)2.0);\n        } else if (f0 > 0.0) {\n          f0scaled = 1.0;\n        }\n        vecO->dataF[n++] = f0scaled;\n      }\n      if (F0finalEnv || F0finalEnvLog) {\n        if (f0 <= 0.0) {\n          f0 = lastValidf0;\n        } else {\n          lastValidf0 = f0;\n        }\n        if (F0finalEnv) {\n          vecO->dataF[n++] = f0;\n        }\n        if (F0finalEnvLog) {\n          FLOAT_DMEM f0scaled = 0.0;\n          if (f0 > 29.136) {\n            // semi-tone scale, base tone 27.5 Hz\n            f0scaled = (FLOAT_DMEM)12.0 * log(f0 / (FLOAT_DMEM)27.5) / log((FLOAT_DMEM)2.0);\n          } else if (f0 > 0.0) {\n            f0scaled = 1.0;\n          }\n          vecO->dataF[n++] = f0scaled;\n        }\n      }\n      FLOAT_DMEM vp = 0.0;\n      if (state < nCandidates[0]) { vp = frameOptr[state*2+1]; }\n      else { vp = frameOptr[1]; }\n      if (voicingFinalClipped) {\n        if (vp >= voiceThresh) vecO->dataF[n++] = vp;\n        else vecO->dataF[n++] = 0.0;\n      }\n\n      if (voicingFinalUnclipped) vecO->dataF[n++] = vp;\n\n      if (F0raw) vecO->dataF[n++] = frameOptr[nCandidates[0]*2];\n      if (voicingC1) vecO->dataF[n++] = frameOptr[nCandidates[0]*2+1];\n      if (voicingClip) vecO->dataF[n++] = frameOptr[nCandidates[0]*2+2];\n\n      /* read frames from second reader to obtain correct tmeta object */\n      long vid = (long)(frameOptr[nCandidates[0]*2+3]);\n      cVector *vecIn = reader2->getFrame(vid);\n//      printf(\"XX vid %i\\n\",vid);\n\n      vecO->tmetaReplace(vecIn->tmeta);\n      writer_->setNextFrame(vecO);\n    }\n    return 1;\n  }\n\n  return 0;\n}\n\n\ncPitchSmootherViterbi::~cPitchSmootherViterbi()\n{\n  // cleanup...\n  if (framePtr != NULL) free(framePtr);\n  if (viterbi != NULL) delete viterbi;\n  if (vecO != NULL) delete vecO;\n\n  if (voicingCutoff != NULL) free(voicingCutoff);\n  if (nCandidates != NULL) free(nCandidates);\n  if (f0candI != NULL) free(f0candI);\n  if (candVoiceI != NULL) free(candVoiceI);\n  if (candScoreI != NULL) free(candScoreI);\n  if (F0rawI != NULL) free(F0rawI);\n  if (voicingClipI != NULL) free(voicingClipI);\n  if (voicingC1I != NULL) free(voicingC1I);\n\n  if (reader2 != NULL) delete reader2;\n}\n\n"
  },
  {
    "path": "src/lld/tonefilt.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\non-line semi-tone filter bank\n\n*/\n\n// TODO: this should be a WinToVecProcessor and NOT a DataProcessor !\n\n\n#include <lld/tonefilt.hpp>\n//#include <math.h>\n\n#define MODULE \"cTonefilt\"\n\n\nSMILECOMPONENT_STATICS(cTonefilt)\n\nSMILECOMPONENT_REGCOMP(cTonefilt)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CTONEFILT;\n  sdescription = COMPONENT_DESCRIPTION_CTONEFILT;\n\n  // we inherit cDataProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataProcessor\")\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"nameAppend\", NULL, \"tonefilt\");\n    ct->setField(\"nNotes\",\"The number of semi-tone filters in the bank\",48);\n    ct->setField(\"firstNote\",\"The frequency of the first note in Hz\",55.0);\n    ct->setField(\"decayF0\",\"The gliding average decay coefficient for the first note (lowest frequency)\",0.9995);\n    ct->setField(\"decayFN\",\"The gliding average decay coefficient for the last note (highest frequency) (must be < decayF0!); decay coefficents for intermediate frequencies will be interpolated linearly from the start and end coefficients.\",0.998);\n    ct->setField(\"outputPeriod\",\"Specifies the period at which to produce output frames in seconds\",0.1);\n    //ct->setField(\"outputBuffersize\",\"size of output buffer in frames (0=determine automatically)\",0);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cTonefilt);\n}\n\nSMILECOMPONENT_CREATE(cTonefilt)\n\n//-----\n\ncTonefilt::cTonefilt(const char *_name) :\n  cDataProcessor(_name),\n  outputPeriod(0.0),\n  //outputBuffersize(0),\n  tmpFrame(NULL),\n  tmpVec(NULL),\n  freq(NULL),\n  pos(NULL),\n  corrC(NULL), corrS(NULL),\n  decayF(NULL)\n{\n\n}\n\nvoid cTonefilt::fetchConfig()\n{\n  cDataProcessor::fetchConfig();\n  \n  outputPeriod = getDouble(\"outputPeriod\");\n  if (outputPeriod <= 0.0) outputPeriod = 0.1;\n  SMILE_DBG(2,\"outputPeriod = %f s\",outputPeriod);\n\n  decayFN = getDouble(\"decayFN\");\n  if (decayFN < 0.0) decayFN = 0.0;\n  if (decayFN > 1.0) decayFN = 1.0;\n  SMILE_DBG(2,\"decayFN = %f\",decayFN);\n\n  decayF0 = getDouble(\"decayF0\");\n  if (decayF0 < decayFN) decayF0 = decayFN;\n  if (decayF0 < 0.0) decayF0 = 0.0;\n  if (decayF0 > 1.0) decayF0 = 1.0;\n  SMILE_DBG(2,\"decayF0 = %f\",decayF0);\n\n  firstNote = getDouble(\"firstNote\");\n  if (firstNote <= 0.0) firstNote = 1.0;\n  SMILE_DBG(2,\"firstNote = %f Hz\",firstNote);\n\n  nNotes = getInt(\"nNotes\");\n  if (nNotes < 1) nNotes = 1;\n  SMILE_DBG(2,\"nNotes = %i\",nNotes);\n\n  /*\n  if (isSet(\"outputBuffersize\")) {\n    outputBuffersize = getInt(\"outputBuffersize\");\n    SMILE_DBG(2,\"outputBuffersize = %i frames\",outputBuffersize);\n  }\n  */\n}\n\n\nint cTonefilt::configureWriter(sDmLevelConfig &c)\n{\n  SMILE_DBG(3,\"reader period = %f\",c.T);\n\n  // c.T is input period here...\n  if (c.T != 0.0) {\n    outputPeriodFrames = (long)round(outputPeriod / c.T);\n  } else {\n    outputPeriodFrames = (long)round(outputPeriod);\n  }\n\n/*\n  if (!fsfGiven) frameSizeFrames = (long)round(frameSize / c->T);\n  else frameSize = ((double)frameSizeFrames) * c->T;\n  if (!fstfGiven) frameStepFrames = (long)round(frameStep / c->T);\n  else frameStep = ((double)frameStepFrames) * c->T;\n  SMILE_DBG(4,\"computed frameSizeFrames = %i\",frameSizeFrames);\n  SMILE_DBG(4,\"computed frameStepFrames = %i\",frameStepFrames);\n*/\n\n  if (outputPeriod < c.T) {\n    outputPeriod = c.T;\n    outputPeriodFrames = 1;\n  }\n  if (outputPeriodFrames < 0) outputPeriodFrames = 0;\n\n  c.T = outputPeriod;\n  c.frameSizeSec = outputPeriod;\n  \n  reader_->setupSequentialMatrixReading(outputPeriodFrames, outputPeriodFrames);\n\n  // you must return 1, in order to indicate configure success (0 indicated failure)\n  return 1;\n}\n\n\nint cTonefilt::setupNewNames(long nEl)\n{\n  // get reader names, append tonefilt to them, and set writer names\n  N = reader_->getLevelN();\n  Nf = reader_->getLevelNf();\n  inputPeriod = reader_->getLevelT();\n  int i,n;\n  char *xx;\n\n  corrC = (double**)calloc(1,sizeof(double*)*N);\n  corrS = (double**)calloc(1,sizeof(double*)*N);\n\n  for (i=0; i<Nf; i++) {\n    int __N=0;\n    const char *tmp = reader_->getFieldName(i,&__N);\n    if (tmp == NULL) { SMILE_ERR(1,\"reader->getFieldName(%i) failed (return value = NULL)!\",i); return 0; }\n    if (__N > 1) {\n      for (n=0; n<__N; n++) {\n        if ((nameAppend_!=NULL)&&(strlen(nameAppend_)>0))\n          xx = myvprint(\"%s%i_%s\",tmp,n,nameAppend_);\n        else\n          xx = myvprint(\"%s%i\",tmp,n);\n//        char *xx = myvprint(\"%s%i_frame\",tmp,n);  // TODO: append name of winFunc, if option in config file is set\n        writer_->addField( xx, nNotes );\n        free(xx);\n      }\n    } else {\n      if ((nameAppend_!=NULL)&&(strlen(nameAppend_)>0))\n        xx = myvprint(\"%s_%s\",tmp,nameAppend_);\n      else\n        xx = myvprint(\"%s\",tmp);\n//      char *xx = myvprint(\"%s_frame\",tmp);  // TODO: append name of winFunc, if option in config file is set\n      writer_->addField( xx, nNotes );\n      free(xx);\n    }\n  }\n  \n  for (i=0; i<N; i++) {\n    // initialize buffers for each element we process...\n    corrC[i] = (double*)calloc(1,sizeof(double)*nNotes);\n    corrS[i] = (double*)calloc(1,sizeof(double)*nNotes);\n  }\n  // initialize global buffers:\n  freq = (double*)malloc(sizeof(double)*nNotes);\n  decayF = (double*)malloc(sizeof(double)*nNotes);  // decay coefficient for each note\n  for (n=0; n<nNotes; n++) {\n    freq[n] = firstNote * pow(2.0,(double)n / 12.0); // freq. for each note\n  }\n  for (n=0; n<nNotes; n++) {\n    // TODO!!!!!!!!!!\n    //decayF[n] = decayFN + (decayF0-decayFN) * ((double)nNotes/12.0) / pow(2.0, (double)n/12.0); // TODO\n    decayF[n] = decayFN + (decayF0-decayFN) * (freq[n]-freq[0])/(freq[nNotes-1]);\n  }\n  pos = (long *)calloc(1,sizeof(long)*N);\n  \n  namesAreSet_ = 1;\n  if (tmpFrame==NULL) tmpFrame=(FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*nNotes);\n  return 1;\n}\n\n/*\nint cTonefilt::myFinaliseInstance()\n{\n  return cDataProcessor::myFinaliseInstance();\n}\n*/\n\nvoid cTonefilt::doFilter(int i, cMatrix *row, FLOAT_DMEM*y)\n{\n  long n,t;\n  double *s = corrS[i]; // sine\n  double *c = corrC[i]; // cosine\n  // TOOD: check for type dataF\n  for (t=0; t<nNotes; t++) {\n    double f= freq[t];\n    FLOAT_DMEM *x = row->dataF;\n    long idx = pos[i];\n    for (n=0; n<row->nT; n++) {\n      // compute correlation with sin+cos\n      double time = (double)(idx+n) * inputPeriod;\n      //      s[t] += sin(2.0*M_PI*f*t) * x[n];\n      //      c[t] += cos(2.0*M_PI*f*t) * x[n];\n      s[t] = decayF[t] * s[t] + (1.0 - decayF[t]) * sin(2.0*M_PI*f*time) * (double)x[n];\n      c[t] = decayF[t] * c[t] + (1.0 - decayF[t]) * cos(2.0*M_PI*f*time) * (double)x[n];\n    }\n    y[t] = (FLOAT_DMEM)sqrt(c[t]*c[t] + s[t]*s[t]);  // sqrt(re^2 + im^2)\n    y[t] *= 10.0;\n  }\n  pos[i] += row->nT;\n}\n\nint cTonefilt::myTick(long long t)\n{\n  SMILE_DBG(5,\"tick # %i, cTonefilt ....\",t);\n\n  if (!(writer_->checkWrite(1))) return 0;\n\n  // get next frame from dataMemory\n  cMatrix *mat = reader_->getNextMatrix();\n  if (mat == NULL) { return 0; } // currently no data available\n\n  if (tmpVec==NULL) tmpVec = new cVector(nNotes*N,mat->type);\n//  printf(\"vs=%i Nf=%i nn=%i\\n\",tmpVec->N,Nf,nNotes);\n  \n  int i;\n  for (i=0; i<N; i++) {\n    cMatrix *r = mat->getRow(i);\n\n    doFilter(i,r,tmpFrame); \n    \n    // copy data into main vector\n    memcpy( tmpVec->dataF+i*nNotes, tmpFrame, sizeof(FLOAT_DMEM)*nNotes );\n  }\n\n  // generate new tmeta from first and last tmeta\n  mat->tmetaSquash();\n  tmpVec->tmetaReplace(mat->tmeta);\n  \n  // save to dataMemory\n  writer_->setNextFrame(tmpVec);\n\n  return 1;\n}\n\n\ncTonefilt::~cTonefilt()\n{\n  if (tmpFrame!=NULL) free(tmpFrame);\n  if (tmpVec!=NULL) delete tmpVec;\n  if (freq!=NULL) free(freq);\n  if (pos!=NULL) free(pos);\n  if (decayF !=NULL) free(decayF);\n  int i;\n  if (corrS !=NULL) {\n    for (i=0; i<N; i++) { if (corrS[i] != NULL) free(corrS[i]); }\n    free(corrS);\n  }\n  if (corrC !=NULL) {\n    for (i=0; i<N; i++) { if (corrC[i] != NULL) free(corrC[i]); }\n    free(corrC);\n  }\n}\n\n"
  },
  {
    "path": "src/lld/tonespec.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\ncomputes (or rather estimates) semi-tone spectrum from fft spectrum\n\n*/\n\n\n/*\nTODO: \n *remove normalisation with 1/binsize (or provide option...)\n *no sqrt option by usePower\n *max and rect filter type\n\n (*tuning correction)\n*/\n\n#include <lld/tonespec.hpp>\n#include <dsp/dbA.hpp>\n\n#define MODULE \"cTonespec\"\n\nSMILECOMPONENT_STATICS(cTonespec)\n\nSMILECOMPONENT_REGCOMP(cTonespec)\n{\n  if (_confman == NULL) return NULL;\n  int rA = 0;\n\n  sconfman = _confman;\n  scname = COMPONENT_NAME_CTONESPEC;\n  sdescription = COMPONENT_DESCRIPTION_CTONESPEC;\n\n  // we inherit cVectorProcessor configType and extend it:\n  ConfigType *ct = new ConfigType( *(sconfman->getTypeObj(\"cVectorProcessor\")) , scname );\n  if (ct == NULL) {\n    SMILE_WRN(4,\"cVectorProcessor config Type not found!\");\n    rA=1;\n  }\n  if (rA==0) {\n    ct->setField(\"nameAppend\", NULL, \"note\");\n    ct->setField(\"nOctaves\",\"The number of octaves the spectrum should span\",6);\n    ct->setField(\"firstNote\",\"The frequency of the first note (in Hz)\",55.0);\n    ct->setField(\"filterType\",\"The shape of the semitone filter:\\n   tri (triangular)\\n   trp (triangular-powered)\\n   gau (gaussian)\",\"gau\");\n    ct->setField(\"usePower\",\"Compute the semi-tone spectrum from the power spectrum instead of the magnitudes (= square input values)\",0);\n    ct->setField(\"dbA\",\"apply built-in dbA weighting to (power) spectrum (1/0 = yes/no)\",1);\n  #ifdef DEBUG\n    ct->setField(\"printBinMap\",\"1 = print mapping of fft bins to semi-tone intervals\",0);\n    ct->setField(\"printFilterMap\",\"1 = print filter map\",0);\n  #endif\n    ConfigInstance *Tdflt = new ConfigInstance( scname, ct, 1 );\n    sconfman->registerType(Tdflt);\n  } \n\n  SMILECOMPONENT_MAKEINFO(cTonespec);\n}\n\nSMILECOMPONENT_CREATE(cTonespec)\n\n//-----\n\ncTonespec::cTonespec(const char *_name) :\n  cVectorProcessor(_name),\n  pitchClassFreq(NULL),\n  binKey(NULL),\n  distance2key(NULL),\n  pitchClassNbins(NULL),\n  filterMap(NULL),\n  flBin(NULL),\n  db(NULL),\n  nOctaves(1),\n  nNotes(8),\n  usePower(0),\n#ifdef DEBUG\n  printBinMap(0),\n#endif\n  filterType(WINF_GAUSS),\n  dbA(0)\n{\n\n}\n\nvoid cTonespec::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n  \n  nOctaves = getInt(\"nOctaves\");\n  SMILE_DBG(2,\"nOctaves = %i\",nOctaves);\n  nNotes = nOctaves * 12;\n  firstNote = (FLOAT_DMEM)getDouble(\"firstNote\");\n  SMILE_DBG(2,\"firstNote = %f\",firstNote);\n\n  lastNote = firstNote * (FLOAT_DMEM)pow(2.0, (double)nNotes/12.0);\n\n  usePower = getInt(\"usePower\");\n  if (usePower) { SMILE_DBG(2,\"using power spectrum\"); }\n  \n  dbA = getInt(\"dbA\");\n  if (dbA) { SMILE_DBG(2,\"dbA weighting for tonespec enabled\"); }\n\n  const char *f = getStr(\"filterType\");\n  if ( (!strcmp(f,\"gau\"))||(!strcmp(f,\"Gau\"))||(!strcmp(f,\"gauss\"))||(!strcmp(f,\"Gauss\"))||(!strcmp(f,\"gaussian\"))||(!strcmp(f,\"Gaussian\")) ) filterType = WINF_GAUSS;\n  else if ( (!strcmp(f,\"tri\"))||(!strcmp(f,\"Tri\"))||(!strcmp(f,\"triangular\"))||(!strcmp(f,\"Triangular\")) ) filterType = WINF_TRIANGULAR;\n  else if ( (!strcmp(f,\"trp\"))||(!strcmp(f,\"TrP\"))||(!strcmp(f,\"Trp\"))||(!strcmp(f,\"triangular-powered\"))||(!strcmp(f,\"Triangular-Powered\")) ) filterType = WINF_TRIANGULAR_POWERED;\n  else if ( (!strcmp(f,\"rec\"))||(!strcmp(f,\"Rec\"))||(!strcmp(f,\"rectangular\"))||(!strcmp(f,\"Rectangular\")) ) filterType = WINF_RECTANGULAR;\n  \n  #ifdef DEBUG\n  printBinMap = getInt(\"printBinMap\");\n  printFilterMap = getInt(\"printFilterMap\");\n  #endif\n}\n\n\nint cTonespec::dataProcessorCustomFinalise()\n{\n  if (namesAreSet_) return 1;\n  //Nfi = reader->getLevelNf();\n\n  // allocate for multiple configurations..\n  if (pitchClassFreq == NULL) pitchClassFreq = (FLOAT_DMEM**)multiConfAlloc();\n  if (distance2key == NULL) distance2key = (FLOAT_DMEM**)multiConfAlloc();\n  if (filterMap == NULL) filterMap = (FLOAT_DMEM**)multiConfAlloc();\n  if (binKey == NULL) binKey = (int**)multiConfAlloc();\n  if (pitchClassNbins == NULL) pitchClassNbins = (int**)multiConfAlloc();\n  if (flBin == NULL) flBin = (int**)multiConfAlloc();\n  if ((dbA)&&(db==NULL)) db = (FLOAT_DMEM**)multiConfAlloc();\n\n  return cVectorProcessor::dataProcessorCustomFinalise();\n}\n\n/*\nint cTonespec::configureWriter(const sDmLevelConfig *c)\n{\n  if (c==NULL) return 0;\n  \n  // you must return 1, in order to indicate configure success (0 indicated failure)\n  return 1;\n}\n*/\n\nvoid cTonespec::setPitchclassFreq(int idxc)\n{\n  FLOAT_DMEM *_pitchClassFreq = pitchClassFreq[idxc];\n\n  double n = 0.0;\n  int i;\n\n  if (_pitchClassFreq != NULL) free(_pitchClassFreq);\n  _pitchClassFreq = (FLOAT_DMEM *)malloc(sizeof(FLOAT_DMEM) * (nNotes+2));\n\n  // \"firstNote - 1\"\n  FLOAT_DMEM firstNote0 = firstNote / (FLOAT_DMEM)pow (2.0,1.0/12.0);\n  _pitchClassFreq[0] = firstNote0;\n  // standard pitch frequencies\n  for (i = 1; i < nNotes+2; i++) {\n    n += 1.0;\n    _pitchClassFreq[i] = firstNote0 * (FLOAT_DMEM)pow (2.0,n/12.0);\n  }\n  \n  pitchClassFreq[idxc] = _pitchClassFreq;\n}\n\n\n\nvoid cTonespec::computeFilters(long blocksize, double frameSizeSec, int idxc)\n{\n  FLOAT_DMEM *_distance2key = distance2key[idxc];\n  FLOAT_DMEM *_filterMap = filterMap[idxc];\n  FLOAT_DMEM *_pitchClassFreq = pitchClassFreq[idxc];\n\n  int * _binKey = binKey[idxc];\n  int * _pitchClassNbins = pitchClassNbins[idxc];\n\n  if (_distance2key != NULL) free(_distance2key);\n  _distance2key = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM) * blocksize);\n  if (_binKey != NULL) free(_binKey);\n  _binKey = (int *)malloc(sizeof(int) * blocksize);\n  if (_pitchClassNbins != NULL) free(_pitchClassNbins);\n  _pitchClassNbins = (int *)calloc(1,sizeof(int) * (nNotes+2));\n  if (_filterMap != NULL) free(_filterMap);\n  _filterMap = (FLOAT_DMEM *)malloc(sizeof(FLOAT_DMEM) * blocksize);\n\n  if (flBin[idxc] != NULL) free(flBin[idxc]);\n  flBin[idxc] = (int*)calloc(1,sizeof(FLOAT_DMEM)*2);\n  int firstBin = *(flBin[idxc]);\n  int lastBin = *(flBin[idxc]+1);\n\n  int i,b;\n\n  FLOAT_DMEM F0 = (FLOAT_DMEM)(1.0/frameSizeSec);\n  if (dbA) {\n    if (db[idxc] != NULL) free(db[idxc]);\n    db[idxc] = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*blocksize);\n    computeDBA( db[idxc], blocksize, F0 );\n  }\n\n  firstBin = (int)ceil((_pitchClassFreq[0]+_pitchClassFreq[1]) / (2.0*F0));\n  lastBin = (int)floor((_pitchClassFreq[nNotes]+_pitchClassFreq[nNotes+1]) / (2.0*F0));\n  //lastBin = (int)round(lastNote / F0);\n  if (firstBin < 1) firstBin = 1;\n  if (lastBin >= blocksize) lastBin = blocksize-1;\n  SMILE_DBG(2,\"\\tOne bin represents: %f Hz\\n\\t\\t\\t\\tUsing FFT bin %i to %i\\n\\t\\t\\t\\tFor freq %f Hz to %f Hz\",F0,firstBin,lastBin,firstNote,lastNote);\n\n  int curNote = 0;\n  FLOAT_DMEM distance0 = 0.0;\n  FLOAT_DMEM distance1 = 0.0;\n  for (i = 0 ; i < blocksize; i++)  // checks the frequency of every FFT bin and maps it to a key frequency\n  {\n    if (curNote > nNotes) curNote=nNotes; // ???\n    distance0 = fabs(_pitchClassFreq[curNote] - ((FLOAT_DMEM)i * F0));   //*get the distance\n    int note1 = curNote;\n    distance1 = fabs(_pitchClassFreq[++note1] - ((FLOAT_DMEM)i * F0));   //*get the distance\n    while (distance0 > distance1) {\n      //fprintf(stderr,\"curN: %i  n1 %i - di0 %f  di1 %f\\n\",curNote,note1,distance0,distance1); fflush(stderr);\n      if (note1 > nNotes) break;\n      distance0 = distance1;\n      distance1 = fabs(_pitchClassFreq[++note1] - ((FLOAT_DMEM)i * F0));   //*get the distance\n    }\n    curNote = note1-1;\n    _binKey[i] = curNote;\n  }\n/*\n    _distance2key[i] = 999999.0;\n    _binKey[i] = -1;\n    for (b=0; b < nNotes; b++) // foreach bin\n    {\n        //SMILE_PRINT(\"   note %i (f=%f)\",b,_pitchClassFreq[b]);\n      distance = _pitchClassFreq[b] - ((FLOAT_DMEM)i * F0);   //*get the distance\n      if (distance < 0.0) distance = (-1.0) * distance;\n      if (distance < _distance2key[i])\n      {\n        _binKey[i] = b;   //maps bin to a note (b)\n        _distance2key[i] = distance; \n      }\n    }\n  }\n*/\n  #ifdef DEBUG\n  if (printBinMap) {\n    for(i=0; i<blocksize;i++) {\n      SMILE_PRINT(\"   xbin %i (f=%f) -> note %i (f=%f) \",i,(FLOAT_DMEM)i*F0,_binKey[i], _pitchClassFreq[_binKey[i]]);\n    }\n  }\n  #endif\n\n  //Checks how many FFT bins belong to a certain pitchclass\n  //used to get the mean power\n  for (i=firstBin; i <= lastBin; i++) {\n    if (_binKey[i] >= 0) {\n      _pitchClassNbins[_binKey[i]]++;\n    }\n  }\n  #ifdef DEBUG\n  if (printBinMap) {\n    for(i=0; i<nNotes; i++) {\n      SMILE_PRINT(\"   _pitchClassNbins[%i]=%i \",i, _pitchClassNbins[i]);\n    }\n  }\n  #endif\n\n  //set up the filter map\n  for (i=0; i < blocksize; i++) _filterMap[i] = 0.0;\n\n\n  float start_bin, end_bin, middle_bin;\n  int i_start_bin, i_end_bin, i_middle_bin;\n  float start_freq, end_freq;\n\n  if (filterType != WINF_RECTANGULAR) {\n    for (b = 1; b < nNotes - 1; b++) {\n      start_freq = (_pitchClassFreq[b - 1] + _pitchClassFreq[b]) / (FLOAT_DMEM)2.0;\n      end_freq = (_pitchClassFreq[b] + _pitchClassFreq[b+1]) / (FLOAT_DMEM)2.0;\n\n      start_bin  = start_freq / F0;\n      end_bin  = end_freq / F0;\n\n      if ((int)(floor(end_bin) - floor(start_bin)) != _pitchClassNbins[b]) { SMILE_WRN(1,\"pitchClassN mismatch %i <> %i (note %i)\", (int)round(end_bin - start_bin), _pitchClassNbins[b], b); }\n\n      middle_bin = (_pitchClassFreq[b]/F0);\n\n      i_start_bin  = (int)(ceil(start_bin));  //??????\n      i_end_bin  = (int)(floor(end_bin));             //??????\n      i_middle_bin = (int)round(_pitchClassFreq[b]/F0);  //??????\n\n      if (i_start_bin > i_end_bin) continue;\n\n//      printf(\"n=%i -- sF %.3f, eF %.3f, sb=%.2f, eb=%.2f mb=%.2f\\n\",b,start_freq,end_freq,start_bin,end_bin,middle_bin);\n\n//      if (i_start_bin\n      if (i_end_bin >= blocksize) i_end_bin = blocksize-1;\n      if (i_start_bin >= blocksize) i_start_bin = blocksize-1;\n      if (i_start_bin < 1) i_start_bin = 1;\n\n      if ((filterType == WINF_TRIANGULAR)||(filterType == WINF_TRIANGULAR_POWERED)) {\n        for (i=i_start_bin; i < i_middle_bin; i++) {\n          _filterMap[i] = ((FLOAT_DMEM)1.0 - ((middle_bin - FLOAT_DMEM(i))/(middle_bin - start_bin)) );\n          if (_filterMap[i] > (FLOAT_DMEM)1.0) _filterMap[i] = (FLOAT_DMEM)2.0 - _filterMap[i];\n        }\n        for (i=i_middle_bin; i <= i_end_bin; i++) {\n          _filterMap[i] = ((FLOAT_DMEM)1.0 - ((FLOAT_DMEM(i) - middle_bin)/(end_bin - middle_bin)) );\n          if (_filterMap[i] > (FLOAT_DMEM)1.0) _filterMap[i] = (FLOAT_DMEM)2.0 - _filterMap[i];\n        }\n      }\n\n      if (filterType == WINF_GAUSS) {\n        double x_val;\n        double delta;\n        double dist_val;\n        for (i=i_start_bin; i <= i_end_bin; i++) {\n          dist_val = (double) (end_bin - start_bin);\n          if (dist_val > 0.0) {\n            x_val = (double)((double)i - middle_bin);\n            delta = dist_val / 15.0;   // M_PI  // ?????\n            _filterMap[i] = (FLOAT_DMEM)( (10.0 / 4.0) * (1.0 / sqrt(2.0*M_PI)) * exp( -0.5 * (1.0/delta) * (1.0/delta) * pow(x_val,2.0)) );\n          }\n        }\n      }\n\n    }\n  }\n\n  if (filterType == WINF_TRIANGULAR_POWERED) {\n    for (i = 0; i < blocksize; i++) {\n      _filterMap[i] *= _filterMap[i];\n    }\n  }\n\n#ifdef DEBUG\n  if (printFilterMap) {\n    printf(\"\\nfirstBin: %i  -- lastBin: %i\\n\",firstBin,lastBin);\n    printf(\"\\nfilterMap:\\n\");\n    for (i=0; i < blocksize; i++) {\n      printf(\"%.4f\",_filterMap[i]);\n      if (i<blocksize-1) printf(\",\");\n    }\n    printf(\"\\n\\n\");\n  }\n#endif\n\n  //Reduce bins to \"first_bin <-> last_bin\"\n  for (i = 0; i < firstBin; i++) {\n    _filterMap[i] = 0;\n  }\n  for (i = lastBin+1; i < blocksize; i++) {\n    _filterMap[i] = 0;\n  }\n\n  if (dbA) {  // optional dbA\n    FLOAT_DMEM *d = db[idxc];\n    for (i = firstBin; i <= lastBin; i++) {\n      _filterMap[i] *= *(d++);\n    }\n  }\n\n  *(flBin[idxc]) = firstBin;\n  *(flBin[idxc]+1) = lastBin;\n  distance2key[idxc] = _distance2key;\n  filterMap[idxc] = _filterMap;\n  binKey[idxc] = _binKey;\n  pitchClassNbins[idxc] = _pitchClassNbins;\n}\n\n\nint cTonespec::setupNamesForField(int i, const char*name, long nEl)\n{\n  const sDmLevelConfig *c = reader_->getLevelConfig();\n  setPitchclassFreq(getFconf(i));\n  computeFilters(nEl, c->frameSizeSec, getFconf(i));\n\n  return cVectorProcessor::setupNamesForField(i,\"tone\",nNotes);\n}\n\n\n/*\nint cTonespec::myFinaliseInstance()\n{\n  int ret;\n  ret = cVectorProcessor::myFinaliseInstance();\n  return ret;\n}\n*/\n\n// a derived class should override this method, in order to implement the actual processing\n/*\nint cTonespec::processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  // do domething to data in *src, save result to *dst\n  // NOTE: *src and *dst may be the same...\n  \n  return 1;\n}\n*/\n\n// a derived class should override this method, in order to implement the actual processing\nint cTonespec::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  int i;\n\n  idxi=getFconf(idxi);\n  FLOAT_DMEM *_distance2key = distance2key[idxi];\n  FLOAT_DMEM *_filterMap = filterMap[idxi];\n  int * _binKey = binKey[idxi];\n  int * _pitchClassNbins = pitchClassNbins[idxi];\n  int firstBin = *(flBin[idxi]);\n  int lastBin = *(flBin[idxi]+1);\n\n\n  // copy & square the fft magnitude\n  FLOAT_DMEM *_src;\n  if (usePower) {\n    _src = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*Nsrc);\n    if (src==NULL) OUT_OF_MEMORY;\n    for (i=0; i<Nsrc; i++) {\n      _src[i] = src[i]*src[i];\n    }\n    src = _src;\n  }\n\n  // do the tone filtering by multiplying with the filters and summing up\n  bzero(dst, Ndst*sizeof(FLOAT_DMEM));\n\n  // Sum the FFT bins for each pitch class and compute mean value\n  for (i=firstBin; i <= lastBin; i++) {\n    if ((_binKey[i] > 0) && (_binKey[i] <= nNotes)) {\n      dst[_binKey[i]-1] += src[i] * _filterMap[i];\n    }\n  }\n\n  for (i = 0; i < nNotes; i++) {\n    if (_pitchClassNbins[i+1] > 0) {\n      dst[i] /= (FLOAT_DMEM)(_pitchClassNbins[i+1]);\n      if (usePower) if (dst[i]>=0.0) dst[i] = sqrt(dst[i]); else dst[i] = 0.0; // FIXME ????\n    } else dst[i] = 0.0;\n  }\n\n  if ((usePower)&&(_src!=NULL)) free((void *)_src);\n\n  // TODO: semi-tone normalisation per octave!?  (here or in CHROMA?)\n  // TODO: check Gaussian filter function... also: filter overlap?\n  return 1;\n}\n\ncTonespec::~cTonespec()\n{\n  multiConfFree(pitchClassFreq);\n  multiConfFree(pitchClassNbins);\n  multiConfFree(binKey);\n  multiConfFree(distance2key);\n  multiConfFree(flBin);\n  multiConfFree(filterMap);\n  if (dbA) multiConfFree(db);\n}\n\n"
  },
  {
    "path": "src/lldcore/energy.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\ncompute RMS and log frame energy\n\n*/\n\n\n#include <lldcore/energy.hpp>\n\n#define MODULE \"cEnergy\"\ndouble minE = 8.674676e-019;\n\nSMILECOMPONENT_STATICS(cEnergy)\n\nSMILECOMPONENT_REGCOMP(cEnergy)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CENERGY;\n  sdescription = COMPONENT_DESCRIPTION_CENERGY;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"nameAppend\",NULL,\"energy\");\n    ct->setField(\"processArrayFields\",NULL,0);\n    ct->setField(\"htkcompatible\",\"If set to 1, enable htk compatible log-energy output (this will output log-energy ONLY! no rms energy...)\",0);\n    ct->setField(\"rms\",\"1/0 = on/off   output of root-mean-square (RMS) energy ( = square root of ( the sum over all input values n=0...N of (x[n]*x[n]) divided by N)\",1);\n    ct->setField(\"energy2\", \"1/0 = on/off   output of quadratic energy (sum of all x[n]^2  divided by N)\", 0);\n    ct->setField(\"log\",\"1/0 = on/off   output logarithmis energy (log-energy). E = log( sum (x[n]*x[n]/N ) ; The argument of the log() function is floored to 8.674676e-019. The output unit has the unit of 'neper' (which is simlar to decibel, with the only difference that the natural logarithm (base e) is used instead of the base-10 logarithm) \",1);\n    ct->setField(\"escaleLog\",\"scale factor to multiply log energy by\",1.0);\n    ct->setField(\"escaleRms\",\"scale factor to multiply rms energy by\",1.0);\n    ct->setField(\"escaleSquare\",\"scale factor to multiply quadratic energy by\",1.0);\n    ct->setField(\"ebiasLog\",\"bias to add to log energy\",0.0);\n    ct->setField(\"ebiasRms\",\"bias to add to rms energy\",0.0);\n    ct->setField(\"ebiasSquare\",\"bias to add to quadratic energy\",0.0);\n  )\n  SMILECOMPONENT_MAKEINFO(cEnergy);\n}\n\nSMILECOMPONENT_CREATE(cEnergy)\n\n//-----\n\ncEnergy::cEnergy(const char *_name) :\n  cVectorProcessor(_name)\n{\n\n}\n\nvoid cEnergy::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n  \n  htkcompatible = getInt(\"htkcompatible\");\n  if (htkcompatible) { SMILE_DBG(2,\"htkcompatible log-energy is enabled\"); }\n\n  erms = getInt(\"rms\");\n  energy2 = getInt(\"energy2\");\n  elog = getInt(\"log\");\n\n  if (htkcompatible) { elog=1; erms=0;  }\n\n  if (erms) { SMILE_DBG(2,\"rms-energy output enabled\"); }\n  if (elog) { SMILE_DBG(2,\"log-energy output enabled\"); }\n\n  ebiasLog = (FLOAT_DMEM)getDouble(\"ebiasLog\");\n  ebiasRms = (FLOAT_DMEM)getDouble(\"ebiasRms\");\n  ebiasSquare = (FLOAT_DMEM)getDouble(\"ebiasSquare\");\n  escaleRms = (FLOAT_DMEM)getDouble(\"escaleRms\");\n  escaleSquare = (FLOAT_DMEM)getDouble(\"escaleSquare\");\n  escaleLog = (FLOAT_DMEM)getDouble(\"escaleLog\");\n}\n\n/*\nint cEnergy::myConfigureInstance()\n{\n  int ret=1;\n  ret *= cVectorProcessor::myConfigureInstance();\n  if (ret == 0) return 0;\n\n//...\n\n\n  return ret;\n}\n*/\n\n/*\nint cEnergy::configureWriter(const sDmLevelConfig *c)\n{\n\n  // you must return 1, in order to indicate configure success (0 indicated failure)\n  return 1;\n}\n\n*/\n\nint cEnergy::setupNamesForField(int i, const char*name, long nEl)\n{\n  int n=0;\n\n  if (erms) {\n    addNameAppendFieldAuto(name, \"RMS\", 1); n++;\n  }\n  if (energy2) {\n    addNameAppendFieldAuto(name, \"SQUARED\", 1); n++;\n  }\n/* \n    if ((nameAppend!=NULL)&&(strlen(nameAppend)>0)) {\n    xx = myvprint(\"%s_RMS%s\",name,nameAppend);\n  } else { xx = myvprint(\"%s_RMS\",name); }\n  writer->addField( xx, 1 ); n++;\n  free(xx);\n  }\n  */\n  \n\n  if (elog) {\n    addNameAppendFieldAuto(name, \"LOG\", 1); n++;\n  }\n/*  if ((nameAppend!=NULL)&&(strlen(nameAppend)>0)) {\n    xx = myvprint(\"%s_LOG%s\",name,nameAppend);\n  } else { xx = myvprint(\"%s_LOG\",name); }\n  writer->addField( xx, 1 ); n++;\n  free(xx);\n  }  */\n  \n  return n;\n}\n\n\n/*\nint cEnergy::myFinaliseInstance()\n{\n  int ret=1;\n  ret *= cVectorProcessor::myFinaliseInstance();\n//.....\n  return ret;\n}\n*/\n\n/*\n// a derived class should override this method, in order to implement the actual processing\nint cEnergy::processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  // do domething to data in *src, save result to *dst\n  // NOTE: *src and *dst may be the same...\n  \n  return 0;\n}\n*/\n\n// a derived class should override this method, in order to implement the actual processing\nint cEnergy::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  // do domething to data in *src, save result to *dst\n  // NOTE: *src and *dst may be the same...\n  if (Nsrc == 0) return 0;\n  \n  long i;\n  double d=0.0;\n  for (i=0; i<Nsrc; i++) {\n    FLOAT_DMEM tmp=*(src++);\n    d += tmp*tmp;\n  }\n\n  int n=0;\n  if (erms) {\n    dst[n++] = (FLOAT_DMEM)sqrt(d/(FLOAT_DMEM)Nsrc) * escaleRms + ebiasRms;\n  }\n  if (energy2) {\n    dst[n++] = (FLOAT_DMEM)(d/(double)Nsrc) * escaleSquare + ebiasSquare;\n  }\n\n  //double minE = 8.674676e-019;\n\n  if (elog) {\n    if (!htkcompatible) {\n      d /= (FLOAT_DMEM)Nsrc;\n      if (d<minE) d = minE;\n      dst[n++] = (FLOAT_DMEM)log(d) * escaleLog + ebiasLog;\n    } else {\n      d *= 32767.0*32767.0;\n      if (d<=1.0) d = 1.0;\n      dst[n++] = (FLOAT_DMEM)log(d) * escaleLog + ebiasLog;\n    }\n  }\n\n  return n;\n}\n\ncEnergy::~cEnergy()\n{\n}\n\n"
  },
  {
    "path": "src/lldcore/intensity.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: cIntensity\n\ncompute simplified intensity according to :\n Andreas Kieling - Extraktion und Klassifikation prosodischer Merkmale in der automatischen Sprachverarbeitung\n Pg. 156-157\n\n(08/2009) Written by Florian Eyben\n\n*/\n\n\n#include <lldcore/intensity.hpp>\n\n#define MODULE \"cIntensity\"\n\nSMILECOMPONENT_STATICS(cIntensity)\n\nSMILECOMPONENT_REGCOMP(cIntensity)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CINTENSITY;\n  sdescription = COMPONENT_DESCRIPTION_CINTENSITY;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"nameAppend\",NULL,(const char *)NULL);\n    ct->setField(\"intensity\",\"1 = enable the output of intensity I (mean of squared input values multiplied by a Hamming window)\",1);\n    ct->setField(\"loudness\",\"1 = enable the output of loudness L : L = (I/I0)^0.3 ; I0 = 0.000001 (for sample values normalised to the range -1..1)\",0);\n  )\n  SMILECOMPONENT_MAKEINFO(cIntensity);\n}\n\nSMILECOMPONENT_CREATE(cIntensity)\n\n//-----\n\ncIntensity::cIntensity(const char *_name) :\n  cVectorProcessor(_name),\n  hamWin(NULL),\n  I0(1.0),\n  nWin(0), winSum(0.0)\n{\n\n}\n\nvoid cIntensity::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n\n  intensity = getInt(\"intensity\");\n  SMILE_IDBG(2,\"intensity = %i\\n\",intensity);\n  loudness = getInt(\"loudness\");\n  SMILE_IDBG(2,\"loudness = %i\\n\",loudness);\n\n}\n\n/*\nint cIntensity::myConfigureInstance()\n{\n  int ret=1;\n  ret *= cVectorProcessor::myConfigureInstance();\n  if (ret == 0) return 0;\n\n//...\n\n\n  return ret;\n}\n*/\n\n/*\nint cIntensity::configureWriter(const sDmLevelConfig *c)\n{\n\n  // you must return 1, in order to indicate configure success (0 indicated failure)\n  return 1;\n}\n\n*/\n\nint cIntensity::setupNamesForField(int i, const char*name, long nEl)\n{\n  int n=0;\n  long j;\n\n  if (intensity) { addNameAppendField(name, \"intensity\", 1); n++; }\n  if (loudness) { addNameAppendField(name, \"loudness\", 1); n++; }\n\n  // Create hamming window:\n  hamWin = smileDsp_winHam( nEl );\n  if (hamWin != NULL) nWin = nEl;\n  for (j=0; j<nEl; j++) {\n    winSum += hamWin[j];\n  }\n  if (winSum <= 0.0) winSum = 1.0;\n\n  // I0 constant for 60 dB and max. amplitude = 1.0:  I0 = 10^-6\n  I0 = (double)0.000001;\n\n  return n;\n}\n\n\n/*\nint cIntensity::myFinaliseInstance()\n{\n  int ret=1;\n  ret *= cVectorProcessor::myFinaliseInstance();\n//.....\n  return ret;\n}\n*/\n\n/*\n// a derived class should override this method, in order to implement the actual processing\nint cIntensity::processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  // do domething to data in *src, save result to *dst\n  // NOTE: *src and *dst may be the same...\n  \n  return 0;\n}\n*/\n\n// a derived class should override this method, in order to implement the actual processing\nint cIntensity::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  // do domething to data in *src, save result to *dst\n  // NOTE: *src and *dst may be the same...\n  if (Nsrc == 0) return 0;\n  if ((hamWin == NULL)||(nWin<=0)) return 0;\n\n  long i;\n  double Im=0.0;\n\n  long safeN = MIN(Nsrc,MIN(nWin,Ndst));\n  for (i=0; i<safeN; i++) {\n    Im += hamWin[i] * (double)src[i]*(double)src[i];       \n  }\n  Im /= winSum;\n\n  long n=0;\n  if (intensity) { dst[n++] = (FLOAT_DMEM)Im; }\n  if (loudness) { dst[n++] = (FLOAT_DMEM)pow( Im/I0 , 0.3 ); }\n  \n  return n;\n}\n\ncIntensity::~cIntensity()\n{\n  if (hamWin != NULL) free(hamWin);\n}\n\n"
  },
  {
    "path": "src/lldcore/melspec.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n/*  openSMILE component:\n\ncompute mel spectrum from fft magnitude\n\n*/\n\n\n#include <lldcore/melspec.hpp>\n\n#define MODULE \"cMelspec\"\n\nSMILECOMPONENT_STATICS(cMelspec)\n\nSMILECOMPONENT_REGCOMP(cMelspec)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  \n  scname = COMPONENT_NAME_CMELSPEC;\n  sdescription = COMPONENT_DESCRIPTION_CMELSPEC;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    //ct->setField(\"nameAppend\", NULL, \"FrqBand\");\n    ct->setField(\"nBands\",\"The number of Mel/Bark/Semitone band filters the filterbank from 'lofreq'-'hifreq' contains.\",26);\n    ct->setField(\"lofreq\",\"The lower cut-off frequency of the filterbank (Hz)\",20.0);\n    ct->setField(\"hifreq\",\"The upper cut-off frequency of the filterbank (Hz)\",8000.0);\n    ct->setField(\"usePower\",\"Set this to 1, to use the power spectrum instead of magnitude spectrum, i.e. if set this squares the input data\",0);\n    ct->setField(\"showFbank\",\"If this is set to 1, the bandwidths and centre frequencies of the filters in the filterbank are printed to openSMILE log output (console and/or file)\",0,0,0);\n    ct->setField(\"htkcompatible\",\"1 = enable htk compatible output (audio sample scaling -32767..+32767 instead of openSMILE's -1.0..1.0)\",1);\n    ct->setField(\"inverse\",\"[NOT YET FULLY TESTED] 1 = compute fft magnitude spectrum from mel spectrum; Note that if this option is set, 'nBands' specifies the number of fft bands to create!\",0,0,0);\n    ct->setField(\"specScale\",\"The frequency scale to design the critical band filterbank in (this is the scale in which the filter centre frequencies are placed equi-distant): \\n  mel = Mel-frequency scale (m = 1127 ln (1+f/700))\\n   bark = Bark scale approximation (Critical band rate z): z = [26.81 / (1.0 + 1960/f)] - 0.53\\n   bark_schroed = Bark scale approximation due to Schroeder (1977): 6*ln( f/600 + [(f/600)^2+1]^0.5 )\\n   bark_speex = Bark scale approximation as used in Speex codec package\\n   semi = semi-tone scale with first note (0) = 'firstNote' (default 27.5Hz)  (s=12*log(f/firstNote)/log(2)) [experimental]\\n   log = logarithmic scale with base 'logScaleBase' (default = 2)\\n   lin(ear) = linear Hz scale.\", \"mel\");\n    ct->setField(\"bwMethod\",\"The method to use to compute filter bandwidth:\\n  lr  : use centre frequencies of left and right neighbours (standard way for mel-spectra and mfcc)\\n  erb : bandwidth based on critical bandwidth approximation (ERB), choose this option for computing HFCC instead of MFCC.\\n  custom: use the 'halfBwTarg' option to specify a custom effective rectangular bandwidth of the triangular filters - this bandwidth is constant for all filters and independent of the center frequency.\", \"lr\");\n    ct->setField(\"halfBwTarg\", \"If bwMethod=='custom' then this options gives the effective rectangular bandwidth of the triangular filters in the target frequency scale (default mel). If showFbank=1 the actual bandwidth in Hz for each center frequency will be printed at startup.\", 1.0);\n    ct->setField(\"logScaleBase\",\"The base for log scales (a log base of 2.0 - the default - corresponds to an octave target scale)\", 2.0,0,0);  \n    ct->setField(\"firstNote\",\"The first note (in Hz) for a semi-tone scale\", 27.5,0,0);\n    ct->setField(\"overrideFrameSizeSec\", \"In case that the original FFT frame size in seconds cannot automatically be read from the input level meta data (i.e. for average spectra in a multi-frame-size setting), use this to manually override it and force the filters to be created based on the given frame size assumption.\", 0.0);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cMelspec);\n}\n\nSMILECOMPONENT_CREATE(cMelspec)\n\n//-----\n\ncMelspec::cMelspec(const char *_name) :\n  cVectorProcessor(_name),\n  filterCoeffs(NULL),  filterCfs(NULL),\n  chanMap(NULL), nLoF(NULL), nHiF(NULL),\n  nBands(26),\n  usePower(0),\n  htkcompatible(1), inverse(0),\n  specScale(SPECTSCALE_MEL)\n{\n\n}\n\nvoid cMelspec::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n  \n  nBands = getInt(\"nBands\");\n  SMILE_DBG(2,\"nBands = %i\",nBands);\n  lofreq = (FLOAT_DMEM)getDouble(\"lofreq\");\n  SMILE_DBG(2,\"lofreq = %f\",lofreq);\n  hifreq = (FLOAT_DMEM)getDouble(\"hifreq\");\n  SMILE_DBG(2,\"hifreq = %f\",hifreq);\n\n  usePower = getInt(\"usePower\");\n  if (usePower) { SMILE_DBG(2,\"using power spectrum\"); }\n\n  inverse = getInt(\"inverse\");\n  if (inverse) { SMILE_DBG(2,\"inverse mode\"); }\n\n  const char * bwMethod = getStr(\"bwMethod\");\n  hfcc = 0;\n  customBandwidth = 0;\n  if (!strncasecmp(bwMethod, \"erb\", 3)) {\n    hfcc=1;\n  } else if (!strncasecmp(bwMethod, \"lr\", 2)) {\n    //hfcc=0;\n  } else if (!strncasecmp(bwMethod, \"cus\", 3)) {\n    customBandwidth = 1;\n  } else {\n    SMILE_IWRN(2,\"unknown 'bwMethod' : %s (see help for possible values). Reverting to use 'lr' method, which is the MFCC standard method.\",bwMethod);\n  }\n  halfBwTarg = getDouble(\"halfBwTarg\");\n\n  htkcompatible = getInt(\"htkcompatible\");\n  if (htkcompatible) { SMILE_DBG(2,\"HTK compatible output is enabled\"); }\n\n  if (!htkcompatible) {\n    const char * specScaleStr = getStr(\"specScale\");\n    if (!strcasecmp(specScaleStr,\"mel\")) {\n      specScale = SPECTSCALE_MEL;\n    } else if (!strcasecmp(specScaleStr,\"bark\")) {\n      specScale = SPECTSCALE_BARK;\n    } else if (!strcasecmp(specScaleStr,\"bark_speex\")) {\n      specScale = SPECTSCALE_BARK_SPEEX;\n    } else if (!strcasecmp(specScaleStr,\"bark_schroed\")) {\n      specScale = SPECTSCALE_BARK_SCHROED;\n    } else if (!strncasecmp(specScaleStr, \"semi\", 4)) {\n      specScale = SPECTSCALE_SEMITONE;\n      firstNote = getDouble(\"firstNote\");\n    } else if (!strncasecmp(specScaleStr, \"lin\", 3)) {\n      specScale = SPECTSCALE_LINEAR;\n    } else if (!strncasecmp(specScaleStr, \"log\", 3)) {\n      specScale = SPECTSCALE_LOG;\n      logScaleBase = getDouble(\"logScaleBase\");\n      if ((logScaleBase <= 0.0)||(logScaleBase==1.0)) {\n        SMILE_IERR(1,\"logScaleBase must be > 0.0 and != 1.0 ! You have set it to: %f (I will set it to 2.0 now, but you are advised to correct your configuration!)\",logScaleBase);\n        logScaleBase = 2.0;\n      }\n    } else {\n      SMILE_IERR(1,\"unknown frequency scale '%s' (see -H for possible values), assuming 'htkmel'!\",specScaleStr);\n      specScale = SPECTSCALE_MEL;;\n    }\n    SMILE_IDBG(2,\"specScale = '%s'\",specScaleStr);\n  } else {\n    specScale = SPECTSCALE_MEL;\n    customBandwidth = 0;\n    halfBwTarg = 1.0;\n  }\n\n  if (specScale == SPECTSCALE_LOG) param = logScaleBase;\n  else if (specScale == SPECTSCALE_SEMITONE) param = firstNote;\n  else param = 0.0;\n}\n\nint cMelspec::dataProcessorCustomFinalise()\n{\n  // allocate for multiple configurations..\n  if (filterCoeffs == NULL) filterCoeffs = (FLOAT_DMEM**)multiConfAlloc();\n  if (filterCfs == NULL) filterCfs = (FLOAT_DMEM**)multiConfAlloc();\n  if (chanMap == NULL) chanMap = (long**)multiConfAlloc();\n  if (nLoF == NULL) nLoF = (long *)multiConfAlloc();\n  if (nHiF == NULL) nHiF = (long *)multiConfAlloc();\n  return cVectorProcessor::dataProcessorCustomFinalise();\n}\n\n\nvoid cMelspec::configureField(int idxi, long myN, long nOut)\n{\n  // compute filters:   // TODO?:: compute filters for each FIELD (however, only if fields are of different blocksize!)\n  const sDmLevelConfig *c = reader_->getLevelConfig();\n  double frameSizeSec;\n  if (isSet(\"overrideFrameSizeSec\")) {\n    frameSizeSec = getDouble(\"overrideFrameSizeSec\");\n    SMILE_IMSG(1, \"overriding input frame size sec. (%f) with manual setting due to given option overrideFrameSizeSec (%f)\",\n        c->frameSizeSec, frameSizeSec);\n  } else {\n    if (c->frameSizeSec > 0.0) {\n      frameSizeSec = c->frameSizeSec;\n    } else {\n      if (c->lastFrameSizeSec != 0.0) {\n        SMILE_IWRN(2, \"Using lastFrameSizeSec [%f] (from the input level of the input level...) because frameSizeSec of the current input level is 0 (functionals or other asynchronuous data).\", c->lastFrameSizeSec);\n        frameSizeSec = c->lastFrameSizeSec;\n      } else {\n        SMILE_IERR(1, \"cannot determine frame size of input spectrum! (frameSizeSec and lastFrameSizeSec are both 0). This can happen when multiple stages combine different frame sizes and/or asynchronuous processing is applied (use overrideFrameSizeSec to manually specify the correct size.)\");\n        COMP_ERR(\"aborting.\");\n      }\n    }\n  }\n  computeFilters(myN, frameSizeSec, getFconf(idxi));\n}\n\nint cMelspec::setupNamesForField(int i, const char*name, long nEl)\n{\n  return cVectorProcessor::setupNamesForField(i,name,nBands);\n}\n\n// MEL FUNCTIONS ----------------------------------------\n\n// blocksize is size of fft block, _T is period of fft frames\n// sampling period is reconstructed by: _T/((blocksize-1)*2)\nint cMelspec::computeFilters( long blocksize, double frameSizeSec, int idxc )\n{\n  FLOAT_DMEM *_filterCoeffs = filterCoeffs[idxc];\n  FLOAT_DMEM *_filterCfs = filterCfs[idxc];\n  long * _chanMap = chanMap[idxc];\n  long _nBands;\n\n  if (inverse) {\n    _nBands = blocksize;\n    blocksize = nBands;\n  } else {\n    if (blocksize < nBands) {\n      SMILE_ERR(1,\"nBands (%i) is greater than dimension of the input vector (%i)! This does not work... not computing mfcc filters!\",nBands,blocksize);\n      return 0;\n    }\n    _nBands = nBands;\n  }\n\n  if (_filterCoeffs != NULL) { free(_filterCoeffs);   }\n  if (_chanMap != NULL) { free(_chanMap);   }\n  if (_filterCfs != NULL) { free(_filterCfs);   }\n\n  bs = blocksize;\n  if (hfcc || customBandwidth) {  // || custom filter\n    // independent coefficients for every band\n    _filterCoeffs = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM) * blocksize * _nBands);\n    // channel map is different here: start and end fft bins of each band's filter\n    _chanMap = (long*)malloc(sizeof(long) * _nBands * 2);\n  } else {\n    _filterCoeffs = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM) * blocksize);\n    _chanMap = (long*)malloc(sizeof(long) * blocksize);\n  }\n  _filterCfs = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM) * (_nBands+2));\n\n  FLOAT_DMEM _N = (FLOAT_DMEM) ((blocksize-1)*2);\n  // TODO: use frequency info struct if available!! (see cPlp or cSpectral for examples...)\n  // TODO!! use frq[] from metadata to also be able to work with non-linear frequency scales as input...?\n  FLOAT_DMEM F0 = (FLOAT_DMEM)(1.0/frameSizeSec);\n  FLOAT_DMEM Fs = (FLOAT_DMEM)(_N/frameSizeSec);\n  FLOAT_DMEM M = (FLOAT_DMEM)_nBands;\n  \n  if ((lofreq < 0.0)||(lofreq>Fs/2.0)||(lofreq>hifreq)) lofreq = 0.0;\n  if ((hifreq<lofreq)||(hifreq>Fs/2.0)||(hifreq<=0.0)) hifreq = Fs/(FLOAT_DMEM)2.0; // Hertz(NtoFmel(blocksize+1,F0));\n  FLOAT_DMEM LoF = (FLOAT_DMEM)smileDsp_specScaleTransfFwd(lofreq, specScale, param);  // Lo Cutoff Freq (mel)\n  FLOAT_DMEM HiF = (FLOAT_DMEM)smileDsp_specScaleTransfFwd(hifreq, specScale, param);  // Hi Cutoff Freq (mel)\n  nLoF[idxc] = FtoN(lofreq,F0);  // Lo Cutoff Freq (fft bin)\n  nHiF[idxc] = FtoN(hifreq,F0);  // Hi Cutoff Freq (fft bin)\n  if (nLoF[idxc] > blocksize) nLoF[idxc] = blocksize;\n  if (nHiF[idxc] > blocksize) nHiF[idxc] = blocksize;\n  if (nLoF[idxc] < 0) nLoF[idxc] = 0; //  exclude DC component??\n  if (nHiF[idxc] < 0) nHiF[idxc] = 0;\n\n  // TODO: option for fully flexible filter bank: n (cf, bw) pairs\n  int showFbank = getInt(\"showFbank\");\n  if (hfcc) {\n    // custom bandwidth hfcc bank:\n\n    // centre frequencies (similar to standard mfcc, but still a bit different for first and last filter)\n    double B,C,b,c,a, bh, ch, ah;\n    int m,n;\n\n    // Moore and Glasberg's ERB coefficients for Hz scaling\n    a = 0.00000623;\n    b = 0.09339;\n    c = 28.52;\n\n    // first:\n    double fl1 = lofreq;\n    double fc1, fh1;\n\n    ah = 0.5/(700.0 + fl1);\n    bh = 700.0/(700.0 + fl1);\n    ch = -fl1/2.0 * (1.0 + 700.0/(700.0+fl1));\n\n    B = (b-bh)/(a-ah);\n    C = (c-ch)/(a-ah);\n    fc1 = 0.5*(-B+sqrt(B*B - 4*C));\n    fh1 = 2.0 * (a*fc1*fc1 + b*fc1 + c) + fl1; \n\n    // last:\n    double fhN = hifreq;\n    double fcN, flN;\n\n    ah = -0.5/(700.0 + fhN);\n    bh = -700.0/(700.0 + fhN);\n    ch = fhN/2.0 * (1.0 + 700.0/(700.0+fhN));\n\n    B = (b-bh)/(a-ah);\n    C = (c-ch)/(a-ah);\n    fcN = 0.5*(-B+sqrt(B*B - 4*C));\n    flN = -2.0 * (a*fcN*fcN + b*fcN + c) + fhN; \n\n    // equidistant spacing on mel-scale from fc1 to fcN of nBands-2 filters\n    double fcNmel = smileDsp_specScaleTransfFwd(fcN, specScale, param);\n    double fc1mel = smileDsp_specScaleTransfFwd(fc1, specScale, param);\n\n    FLOAT_DMEM mBandw = (FLOAT_DMEM)(fcNmel-fc1mel)/(M-(FLOAT_DMEM)1.0);\n    for (m=0; m<_nBands-1; m++) {\n      _filterCfs[m] = (FLOAT_DMEM)fc1mel + (FLOAT_DMEM)m*mBandw;\n    }\n    _filterCfs[m] = (FLOAT_DMEM)fcNmel;\n    // Fill frequency axis info struct (frame metadata)\n    double *_info = (double*)malloc(sizeof(double) * _nBands);\n    for (int m = 1; m <= _nBands; m++) {\n      _info[m - 1] = (double)smileDsp_specScaleTransfInv(_filterCfs[m], specScale, param);\n    }\n    writer_->setFieldInfo(-1, DATATYPE_SPECTRUM_BANDS_MAG, _info, _nBands * sizeof(double));\n    for (m=0; m<_nBands; m++) {\n      double fc = smileDsp_specScaleTransfInv(_filterCfs[m], specScale, param);\n      double ERB7 = a*fc*fc + b* fc + c + 700.0;\n      double fl,fh;\n\n      fl = -(ERB7) + sqrt((ERB7*ERB7) + fc*(fc+1400.0));\n      fh = fl + 2*(ERB7-700.0);\n\n      if (showFbank) {\n        SMILE_IMSG(1,\"Band %i : center = %f Hz (fl: %f , fh: %f Hz ; ERB: %f Hz)\",m,fc,fl,fh,(fh-fl)/2.0);\n      }\n\n      // start and end fft bins in chanMap\n      long flI = _chanMap[m*2] =   FtoN((FLOAT_DMEM)fl,F0); // start\n      long fcI = FtoN((FLOAT_DMEM)fc,F0);\n      long fhI = _chanMap[m*2+1] = FtoN((FLOAT_DMEM)fh,F0); // end\n\n      //// triangular filters\n      // rising slope\n      if (fl != fc) {\n        for (n=MAX(flI,0); (n<=fcI)&&(n<blocksize); n++) {\n          double f = NtoF(n,F0);\n          _filterCoeffs[m*blocksize + n] = (FLOAT_DMEM)( (f-fl)/(fc-fl) );\n        }\n      } else {\n        _filterCoeffs[m*blocksize + MAX(fcI, 0)] = 1.0;\n      }\n      // falling slope\n      if (fh != fc) {\n        for (n=MAX(fcI,0)+1; (n<=fhI)&&(n<blocksize); n++) {\n          double f = NtoF(n,F0);\n          _filterCoeffs[m*blocksize + n] = (FLOAT_DMEM)( (fh-f)/(fh-fc) );\n        }\n      }\n    }\n  } else if (customBandwidth) {\n    // custom bandwidth triangular filter bank:\n    // first:\n    double fl1 = lofreq;\n    double fc1 =  fl1;\n    // last:\n    double fhN = hifreq;\n    double fcN = fhN;\n    // equidistant spacing on target-scale from fc1 to fcN of nBands-2 filters\n    double fcNtarg = smileDsp_specScaleTransfFwd(fcN, specScale, param);\n    double fc1targ = smileDsp_specScaleTransfFwd(fc1, specScale, param);\n    FLOAT_DMEM mBandw = (FLOAT_DMEM)(fcNtarg-fc1targ)/(M+(FLOAT_DMEM)0.0);\n    if (showFbank) {\n      SMILE_IMSG(1, \"Constant spacing of filters in target frequency scale = %f\", mBandw);\n    }\n    // center frequencies\n    for (int m = 0; m < _nBands; m++) {\n      _filterCfs[m] = (FLOAT_DMEM)fc1targ + (FLOAT_DMEM)m * mBandw;\n    }\n    _filterCfs[_nBands - 1] = (FLOAT_DMEM)fcNtarg;\n    // Fill frequency axis info struct (frame metadata)\n    double *_info = (double*)malloc(sizeof(double) * _nBands);\n    for (int m = 0; m < _nBands; m++) {\n      _info[m] = (double)smileDsp_specScaleTransfInv(_filterCfs[m], specScale, param);\n    }\n    writer_->setFieldInfo(-1, DATATYPE_SPECTRUM_BANDS_MAG, _info, _nBands * sizeof(double));\n    // computes filters for each band:\n    for (int m = 0; m < _nBands; m++) {\n      double fc = smileDsp_specScaleTransfInv(_filterCfs[m], specScale, param);\n      double fl = fc - halfBwTarg;\n      double fh = fc + halfBwTarg;\n      if (fl < lofreq) {\n        fl = lofreq;\n      }\n      if (fh > hifreq) {\n        fh = hifreq;\n      }\n      if (showFbank) {\n        SMILE_IMSG(1,\"Band %i : center = %f Hz (fl: %f , fh: %f Hz ; bw/2 = %f)\", m, fc, fl, fh, (fh-fl)/2.0);\n      }\n      // start and end fft bins in chanMap\n      long flI = _chanMap[m*2] =   FtoN((FLOAT_DMEM)fl, F0); // start\n      long fcI = FtoN((FLOAT_DMEM)fc, F0);\n      long fhI = _chanMap[m*2+1] = FtoN((FLOAT_DMEM)fh, F0); // end\n      //// triangular filters\n      if (fl != fc) {\n        for (int n=MAX(flI,0); (n<=fcI)&&(n<blocksize); n++) {\n          double f = NtoF(n,F0);\n          _filterCoeffs[m*blocksize + n] = (FLOAT_DMEM)( (f-fl)/(fc-fl) );\n        }\n      } else {\n        _filterCoeffs[m*blocksize + MAX(fcI, 0)] = 1.0;\n      }\n      // falling slope\n      if (fh != fc) {\n        for (int n=MAX(fcI,0)+1; (n<=fhI)&&(n<blocksize); n++) {\n          double f = NtoF(n,F0);\n          _filterCoeffs[m*blocksize + n] = (FLOAT_DMEM)( (fh-f)/(fh-fc) );\n        }\n      }\n    }\n  } else {\n    // standard mel filter bank:\n    int m,n;\n    // compute mel center frequencies\n    FLOAT_DMEM mBandw = (HiF-LoF)/(M+(FLOAT_DMEM)1.0); // half bandwidth of mel bands\n    for (m=0; m<=_nBands+1; m++) {\n      _filterCfs[m] = LoF+(FLOAT_DMEM)m*mBandw;\n    }\n    // Fill frequency axis info struct (frame metadata)\n    if (inverse) {\n      double *_info = (double*)malloc(sizeof(double) * blocksize);\n      float F0 = (float)(1.0/frameSizeSec);\n      for (m=0; m < blocksize; m++) {\n        _info[m] = m * F0;\n      }\n      writer_->setFieldInfo(-1, DATATYPE_SPECTRUM_BANDS_MAG, _info, blocksize * sizeof(double));\n    } else {\n      double *_info = (double*)malloc(sizeof(double) * _nBands);\n      for (m=1; m <= _nBands; m++) {\n        _info[m-1] = (double)smileDsp_specScaleTransfInv(_filterCfs[m], specScale, param);\n      }\n      writer_->setFieldInfo(-1, DATATYPE_SPECTRUM_BANDS_MAG, _info, _nBands * sizeof(double));\n    }\n    if (showFbank) {\n      SMILE_IMSG(1, \"Band -1 (left bound) : center = %f Hz\",\n          smileDsp_specScaleTransfInv(_filterCfs[0], specScale, param));\n      for (m = 1; m <= _nBands; m++) {\n        SMILE_IMSG(1,\"Band %i : center = %f Hz ; bw/2 = %f Hz\", m - 1,\n            smileDsp_specScaleTransfInv(_filterCfs[m], specScale, param),\n            (smileDsp_specScaleTransfInv(_filterCfs[m + 1], specScale, param)\n                - smileDsp_specScaleTransfInv(_filterCfs[m - 1], specScale, param)) / 2.0);\n      }\n      SMILE_IMSG(1, \"Band %i (right bound) : center = %f Hz\", _nBands,\n          smileDsp_specScaleTransfInv(_filterCfs[_nBands + 1], specScale, param));\n    }\n\n    // compute channel mapping table:\n    m = 0;\n    for (n=0; n<blocksize; n++) {\n      if ( (n<=nLoF[idxc])||(n>=nHiF[idxc]) ) _chanMap[n] = -3;\n      else {\n        while (_filterCfs[m] < NtoFmel(n,F0)) {\n          if (m>_nBands) break;\n          m++;\n        }\n        _chanMap[n] = m-2;\n      }\n    }\n\n    // compute filter weights (rising slope only):\n    m = 0;\n    FLOAT_DMEM nM;\n    for (n=nLoF[idxc];n<nHiF[idxc];n++) {\n      nM = NtoFmel(n,F0);\n      while ((nM > _filterCfs[m+1]) && (m<=_nBands)) m++;\n      _filterCoeffs[n] = ( _filterCfs[m+1] - nM )/(_filterCfs[m+1] - _filterCfs[m]);\n    }\n\n  }\n\n  filterCoeffs[idxc] = _filterCoeffs;\n  filterCfs[idxc] = _filterCfs;\n  chanMap[idxc] = _chanMap;\n  return 0;\n}\n\nint cMelspec::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  int m,n;\n  idxi=getFconf(idxi);\n  FLOAT_DMEM *_filterCoeffs = filterCoeffs[idxi];\n  FLOAT_DMEM *_filterCfs = filterCfs[idxi];\n  long *_chanMap = chanMap[idxi];\n  FLOAT_DMEM *_src = NULL;\n\n  if (inverse) {\n\n    if (htkcompatible) {\n      _src = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*Nsrc);\n      if (src==NULL) OUT_OF_MEMORY;\n\n      for (m=0; m<Nsrc; m++) {\n        if (usePower) {\n          _src[m] = src[m] / (FLOAT_DMEM)(32767.0*32767.0);\n        } else {\n          _src[m] = src[m] / (FLOAT_DMEM)32767.0;\n        }\n      }\n      src = _src;\n    }\n\n    // inverse mel\n    // do the mel filtering by multiplying with the filters and summing up\n    memset(dst, 0, Ndst*sizeof(FLOAT_DMEM));\n\n    if (hfcc) {\n      SMILE_IERR(1,\"Inverse HFCC not yet implemented!!\");\n    } else if (customBandwidth) {\n      SMILE_IERR(1,\"Inverse Filter with customBandwidth not yet implemented!!\");\n    } else {\n      FLOAT_DMEM a;\n      for (n=nLoF[idxi]; n<MIN(Ndst,nHiF[idxi]); n++) {\n        m = _chanMap[n];\n        if (m>-2) {\n          if (m>-1) {\n            a = src[m] * _filterCoeffs[n];\n            dst[n] += a;\n            if (m < Nsrc-1) {\n              a = src[m+1] * ((FLOAT_DMEM)1.0 - _filterCoeffs[n]);\n              dst[n] += a;\n            }\n          }\n        }\n      }\n    }\n\n    // inverse power spectrum:\n    if (usePower) {\n      for (n=0; n<Ndst; n++) {\n        if (dst[n] > 0.0) {\n          dst[n] = sqrt(dst[n]);\n        } else { dst[n] = 0.0; }\n      }\n    }\n\n    if ((htkcompatible)&&(_src!=NULL)) free((void *)_src);\n\n  } else {\n    // copy & square the fft magnitude\n    if (usePower) {\n      _src = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*Nsrc);\n      if (src==NULL) OUT_OF_MEMORY;\n      for (n=0; n<Nsrc; n++) {\n        _src[n] = src[n]*src[n];\n      }\n      src = _src;\n    }\n\n    // do the mel filtering by multiplying with the filters and summing up\n    memset(dst, 0, Ndst*sizeof(FLOAT_DMEM));\n\n    if (hfcc || customBandwidth) {\n      // TODO: perform alternate (less optimised) multiplication for custom bandwidth methods.\n      for (m=0; m<nBands; m++) {\n        long n1, n2;\n        n1 = _chanMap[m*2];\n        n2 = _chanMap[m*2+1];\n        for (n=MAX(n1,nLoF[idxi]); (n<=n2)&&(n<nHiF[idxi]); n++) {\n          dst[m] += (FLOAT_DMEM)( (double)src[n] * (double)_filterCoeffs[m*Nsrc+n] );\n        }\n      }\n\n    } else {\n      double a;\n      for (n=nLoF[idxi]; n<nHiF[idxi]; n++) {\n        m = _chanMap[n];\n        a = (double)src[n] * (double)_filterCoeffs[n];\n        if (m>-2) {\n          if (m>-1) dst[m] += (FLOAT_DMEM)a;\n          if (m < nBands-1)\n            dst[m+1] += src[n] - (FLOAT_DMEM)a;\n        }\n      }\n\n    }\n\n    if ((usePower)&&(_src!=NULL)) free((void *)_src);\n\n    if (htkcompatible) {\n      for (m=0; m<nBands; m++) {\n        if (usePower) {\n          dst[m] *= (FLOAT_DMEM)(32767.0*32767.0);\n        } else {\n          dst[m] *= (FLOAT_DMEM)32767.0;\n        }\n        // the above is for HTK compatibility....\n        // HTK does not scale the input sample values to -1 / +1\n        // thus, we must multiply by the max 16bit sample value again.\n      }\n    }\n  }\n  return 1;\n}\n\ncMelspec::~cMelspec()\n{\n  multiConfFree(filterCoeffs);\n  multiConfFree(chanMap);\n  multiConfFree(filterCfs);\n  if (nLoF != NULL)\n    free(nLoF);\n  if (nHiF != NULL) \n    free(nHiF);\n}\n\n"
  },
  {
    "path": "src/lldcore/mfcc.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: cMfcc\n\ncomputes Mel-Frequency-Cepstral Coefficients (MFCC) from Mel-Spectrum\n\n*/\n\n\n#include <lldcore/mfcc.hpp>\n\n#define MODULE \"cMfcc\"\n\n\nSMILECOMPONENT_STATICS(cMfcc)\n\nSMILECOMPONENT_REGCOMP(cMfcc)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CMFCC;\n  sdescription = COMPONENT_DESCRIPTION_CMFCC;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"nameAppend\", NULL, \"mfcc\");\n    ct->setField(\"firstMfcc\",\"The first MFCC to compute\",1);\n    ct->setField(\"lastMfcc\",\"The last MFCC to compute\",12);\n    ct->setField(\"nMfcc\",\"Use this option to specify the number of MFCC, instead of specifying lastMfcc\",12);\n    ct->setField(\"melfloor\",\"The minimum value allowed for melspectra when taking the log spectrum (this parameter will be forced to 1.0 when htkcompatible=1)\",0.00000001); \n    ct->setField(\"doLog\", \"This defaults to 1 (on), set it to 0 to disable the log() operation on the (power) spectrum before applying the DCT. Note: If disabled, the output cannot be considered Cepstral coefficients anymore!\", 1);\n    ct->setField(\"cepLifter\",\"Parameter for cepstral 'liftering', set this to 0.0 to disable cepstral liftering\",22.0);\n    ct->setField(\"htkcompatible\",\"1 = append the 0-th coefficient at the end instead of placing it as the first element of the output vector\",1);\n    \n    ct->setField(\"inverse\",\"1/0 = on/off : comutation of inverse MFCC (i.e. input is MFCC array)\",0);\n    ct->setField(\"nBands\",\"number of mel/bark bands to create when computing the inverse MFCC (must be the same as the number of bands the forward transform was performed on).\",26);\n    ct->setField(\"printDctBaseFunctions\", \"1/0 = on/off: print the dct base functions in octave compatible syntax to standard output\", 0);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cMfcc);\n}\n\nSMILECOMPONENT_CREATE(cMfcc)\n\n//-----\n\ncMfcc::cMfcc(const char *_name) :\n  cVectorProcessor(_name),\n  costable(NULL),\n  sintable(NULL),\n  firstMfcc(1),\n  lastMfcc(12),\n  doLog_(1),\n  htkcompatible(0)\n{}\n\nvoid cMfcc::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n  \n  firstMfcc = getInt(\"firstMfcc\");\n  SMILE_IDBG(2,\"firstMfcc = %i\",firstMfcc);\n  lastMfcc = getInt(\"lastMfcc\");\n  melfloor = (FLOAT_DMEM)getDouble(\"melfloor\");\n  SMILE_IDBG(2,\"melfloor = %f\", melfloor);\n  doLog_ = getInt(\"doLog\");\n  SMILE_IDBG(2,\"doLog = %f\", doLog_);  \n  cepLifter = (FLOAT_DMEM)getDouble(\"cepLifter\");\n  SMILE_IDBG(2,\"cepLifter = %f\", cepLifter);\n\n  if (!isSet(\"lastMfcc\")&&isSet(\"nMfcc\")) {\n    nMfcc = getInt(\"nMfcc\");\n    lastMfcc = firstMfcc + nMfcc - 1;\n  } else {\n    nMfcc = lastMfcc - firstMfcc + 1;\n  }\n  SMILE_IDBG(2,\"lastMfcc = %i\",lastMfcc);\n  SMILE_IDBG(2,\"nMfcc = %i\",nMfcc);\n\n  htkcompatible = getInt(\"htkcompatible\");\n  if (htkcompatible) {\n    SMILE_IDBG(2,\"HTK compatible output is enabled\");\n\tmelfloor = 1.0;\n  }\n\n  inverse=getInt(\"inverse\");\n  nBands=getInt(\"nBands\");\n  printDctBaseFunctions=getInt(\"printDctBaseFunctions\");\n}\n\nint cMfcc::dataProcessorCustomFinalise()\n{\n  // allocate for multiple configurations..\n  if (sintable == NULL) sintable = (FLOAT_DMEM**)multiConfAlloc();\n  if (costable == NULL) costable = (FLOAT_DMEM**)multiConfAlloc();\n\n  return cVectorProcessor::dataProcessorCustomFinalise();\n}\n\nint cMfcc::setupNamesForField(int i, const char*name, long nEl)\n{\n  // compute sin/cos tables here:\n  if (inverse) {\n    initTables(nBands,getFconf(i));\n    name = \"iMelspec\";\n    if ((nameAppend_ != NULL)&&(strlen(nameAppend_)>0)) {\n      addNameAppendField(name,nameAppend_,nBands,0);\n    } else {\n      writer_->addField( name, nBands, 0);\n    }\n    return nBands;\n  } else {\n    initTables(nEl,getFconf(i));\n    if ((nameAppend_ != NULL)&&(strlen(nameAppend_)>0)) {\n      if (!copyInputName_) {\n        name=\"\";\n      }\n      addNameAppendField(name,nameAppend_,nMfcc,firstMfcc);\n    } else {\n      writer_->addField( name, nMfcc, firstMfcc);\n    }\n    return nMfcc;\n\n  }\n}\n\n\n// blocksize is size of mspec block (=nBands)\nint cMfcc::initTables( long blocksize, int idxc )\n{\n  int i,m;\n  FLOAT_DMEM *_costable = costable[idxc];\n  FLOAT_DMEM *_sintable = sintable[idxc];\n  \n  if (_costable != NULL) free(_costable);\n  _costable = (FLOAT_DMEM *)malloc(sizeof(FLOAT_DMEM)*blocksize*nMfcc);\n  if (_costable == NULL) OUT_OF_MEMORY;\n\n  double fnM = (double)(blocksize);\n  for (i=firstMfcc; i <= lastMfcc; i++) {\n    double fi = (double)i;\n    for (m=0; m<blocksize; m++) {\n      _costable[m+(i-firstMfcc)*blocksize] = (FLOAT_DMEM)cos((double)M_PI*(fi/fnM) * ( (double)(m) + (double)0.5) );\n    }\n  }\n\n  if (_sintable != NULL) free(_sintable);\n  _sintable = (FLOAT_DMEM *)malloc(sizeof(FLOAT_DMEM)*nMfcc);\n  if (_sintable == NULL) OUT_OF_MEMORY;\n\n  if (cepLifter > 0.0) {\n    for (i=firstMfcc; i <= lastMfcc; i++) {\n      _sintable[i-firstMfcc] = ((FLOAT_DMEM)1.0 + cepLifter/(FLOAT_DMEM)2.0 * sin((FLOAT_DMEM)M_PI*((FLOAT_DMEM)(i))/cepLifter));\n    }\n  } else {\n    for (i=firstMfcc; i <= lastMfcc; i++) {\n      _sintable[i-firstMfcc] = 1.0;\n    }\n  }\n  costable[idxc] = _costable;\n  sintable[idxc] = _sintable;\n  return 1;\n}\n\n// idxi=input field index\nint cMfcc::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) \n{\n  int i,m;\n  idxi = getFconf(idxi);\n  FLOAT_DMEM *_costable = costable[idxi];\n  FLOAT_DMEM *_sintable = sintable[idxi];\n\n  FLOAT_DMEM *_src;\n  _src = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*Nsrc);\n  if (_src==NULL) OUT_OF_MEMORY;\n  \n  if (inverse) {\n    FLOAT_DMEM factor = (FLOAT_DMEM)sqrt((double)2.0/(double)(nBands));\n    if (lastMfcc-firstMfcc+1 != Nsrc) {\n      SMILE_IERR(1,\"Input dimensionality mismatch! Expected (lastMfcc-firstMfcc+1): %i , actual: %i\",lastMfcc-firstMfcc+1,Nsrc);\n      return 0;\n    }\n\n    // inverse liftering\n    for (i=firstMfcc; i <= lastMfcc; i++) {\n      int i0 = i-firstMfcc;\n      int srcIdx = i0;\n      if (htkcompatible && (firstMfcc==0)) {\n        // ASSERTION: i == i0\n        if (i == 0) {\n          srcIdx = lastMfcc;\n        }\n        else {\n          srcIdx = i0 - 1;\n        }\n      }\n      FLOAT_DMEM * inc = _src+srcIdx;\n      *inc = src[srcIdx] / (_sintable[i0]);\n    }\n\n    // inverse DCT\n    for (m=0; m<nBands; m++) {\n      FLOAT_DMEM * outc = dst+m;\n\n      * outc = 0.0;\n      for (i=firstMfcc; i <= lastMfcc; i++) {\n        int i0 = i-firstMfcc;\n        int srcIdx = i0;\n        if (htkcompatible && (firstMfcc==0)) {\n          // ASSERTION: i == i0\n          if (i == 0) {\n             srcIdx = lastMfcc;\n          }\n          else {\n             srcIdx = i0 - 1;\n          }\n        }\n        //printf(\"i = %d, i0 = %d, srcIdx = %d\\n\", i, i0, srcIdx);\n        FLOAT_DMEM correctionfactor = 1.0;\n        if (i==0) correctionfactor = (FLOAT_DMEM) ( 0.5f );\n        *outc += _src[srcIdx] * _costable[m + i0*nBands] * correctionfactor * factor;\n      }\n\n      // inverse Log\n      if (doLog_) {\n        *outc = (FLOAT_DMEM)( exp(*outc) );\n      }\n    } \n  } else {\n\n  // compute log mel spectrum\n  if (doLog_) {\n    for (i = 0; i < Nsrc; i++) {\n      if (src[i] < melfloor) _src[i] = log(melfloor);\n      else _src[i] = (FLOAT_DMEM)log(src[i]);\n    }\n  } else {\n    for (i = 0; i < Nsrc; i++) {\n      _src[i] = (FLOAT_DMEM)src[i];\n    }\n  }\n\n  // compute dct of mel data & do cepstral liftering:\n  FLOAT_DMEM factor = (FLOAT_DMEM)sqrt((double)2.0/(double)(Nsrc));\n  for (i=firstMfcc; i <= lastMfcc; i++) {\n    int i0 = i-firstMfcc;\n    FLOAT_DMEM * outc = dst+i0;  // = outp + (i-obj->firstMFCC);\n    if (htkcompatible && (firstMfcc==0)) {\n      if (i==lastMfcc) { i0 = 0; }\n      else { i0 += 1; }\n    }\n    *outc = 0.0;\n    for (m=0; m<Nsrc; m++) {\n      *outc += _src[m] * _costable[m + i0*Nsrc];\n    }\n    if (printDctBaseFunctions) {\n      printf(\"base_mfcc_%i = [\", i);\n      for (m=0; m<Nsrc-1; m++) {\n        printf(\"%e \", _costable[m + i0*Nsrc]);\n      }\n      printf(\"%e];\\n\", _costable[m + i0*Nsrc]);\n    }\n    //*outc *= factor;   // use this line, if you want unliftered mfcc\n    // do cepstral liftering:\n    *outc *= _sintable[i0] * factor;\n  }\n  if (printDctBaseFunctions) {\n      printDctBaseFunctions = 0;\n  }\n\n  }\n  free(_src);\n  return 1;\n}\n\ncMfcc::~cMfcc()\n{\n  multiConfFree(costable);\n  multiConfFree(sintable);\n}\n\n"
  },
  {
    "path": "src/lldcore/mzcr.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\ntime signal properties: min/max sample value, mean and zero crossing rates\n\n*/\n\n\n#include <lldcore/mzcr.hpp>\n\n#define MODULE \"cMZcr\"\n\nSMILECOMPONENT_STATICS(cMZcr)\n\nSMILECOMPONENT_REGCOMP(cMZcr)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CMZCR;\n  sdescription = COMPONENT_DESCRIPTION_CMZCR;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"nameAppend\",\"(ignored here)\",(const char*)NULL);\n    ct->setField(\"zcr\",\"(1/0=yes/no) compute zero-crossing rate (zcr)\",1);\n    ct->setField(\"mcr\",\"(1/0=yes/no) compute mean-crossing rate (mcr) (i.e. the rate at which a signal crosses its mean, for signals with mean 0 this is identical to the zero-crossing rate)\",1);\n    ct->setField(\"amax\",\"(1/0=yes/no) enable output of the maximum *absolute* sample value\",1);\n    ct->setField(\"maxmin\",\"(1/0=yes/no) enable output of the maximum and minimum sample value\",1);\n    ct->setField(\"dc\",\"(1/0=yes/no) compute the DC-offset (= the arithmetic mean of input values)\",0);\n  )\n  SMILECOMPONENT_MAKEINFO(cMZcr);\n}\n\nSMILECOMPONENT_CREATE(cMZcr)\n\n//-----\n\ncMZcr::cMZcr(const char *_name) :\n  cVectorProcessor(_name),\n  zcr(0), mcr(0),\n  amax(0),\n  maxmin(0)\n{\n\n}\n\nvoid cMZcr::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n\n  zcr = getInt(\"zcr\");\n  mcr = getInt(\"mcr\");\n  amax = getInt(\"amax\");\n  maxmin = getInt(\"maxmin\");\n  dc = getInt(\"dc\");\n}\n\n\nint cMZcr::setupNamesForField(int i, const char*name, long nEl)\n{\n  int n=0;\n  char * xx=NULL;\n\n  if (zcr) {\n    xx = myvprint(\"%s_zcr\",name);\n    writer_->addField( xx, 1 );\n    free(xx); n++;\n  }\n\n  if (mcr) {\n    xx = myvprint(\"%s_mcr\",name);\n    writer_->addField( xx, 1 );\n    free(xx); n++;\n  }\n\n  if (amax) {\n    xx = myvprint(\"%s_absmax\",name);\n    writer_->addField( xx, 1 );\n    free(xx); n++;\n  }\n\n  if (maxmin) {\n    xx = myvprint(\"%s_max\",name);\n    writer_->addField( xx, 1 );\n    free(xx);\n    xx = myvprint(\"%s_min\",name);\n    writer_->addField( xx, 1 );\n    free(xx); n += 2;\n  }\n  if (dc) {\n    xx = myvprint(\"%s_dc\",name);\n    writer_->addField( xx, 1 );\n    free(xx); n++;\n  }\n\n  return n;\n}\n\n\n// a derived class should override this method, in order to implement the actual processing\nint cMZcr::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  // do domething to data in *src, save result to *dst\n  // NOTE: *src and *dst may be the same...\n  if (Nsrc == 0) return 0;\n  \n  FLOAT_DMEM mean=src[0];\n  FLOAT_DMEM nzc=0.0, nmc = 4.0;\n  FLOAT_DMEM max, min, absmax;\n\n  long i;\n  if (zcr || mcr || dc) {\n    for (i=1; i<Nsrc-1; i++) {\n      mean += src[i];\n      if (  ( (src[i-1] * src[i+1] <= 0.0) && (src[i]==0.0) ) || (src[i-1] * src[i] < 0.0)  ) nzc += 1.0;\n    }\n    nzc /= (FLOAT_DMEM)Nsrc;\n    mean /= (FLOAT_DMEM)Nsrc;\n  }\n  if (mcr) {\n    for (i=1; i<Nsrc-1; i++) {\n      if (  ( ((src[i-1]-mean) * (src[i+1]-mean) <= 0.0) && ((src[i]-mean)==0.0) ) || ((src[i-1]-mean) * (src[i]-mean) < 0.0)  ) nmc++;\n    }\n    nmc /= (FLOAT_DMEM)Nsrc;\n  }\n  if (amax || maxmin) {\n    max=min=src[0];\n    for (i=1; i<Nsrc; i++) {\n\t  if (src[i] < min) min = src[i];\n\t  if (src[i] > max) max = src[i];\n\t}\n\tif (fabs(min) > fabs(max)) absmax = fabs(min);\n\telse absmax = fabs(max);\n  }\n  int n=0;\n  if (zcr) dst[n++] = nzc;\n  if (mcr) dst[n++] = nmc;\n\n  if (amax) dst[n++] = absmax;\n  if (maxmin) {\n    dst[n++] = max;\n\tdst[n++] = min;\n  }\n  if (dc) {\n    dst[n++] = mean;\n  }\n  return n;\n}\n\ncMZcr::~cMZcr()\n{\n}\n\n"
  },
  {
    "path": "src/lldcore/pitchACF.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\npitch detection via ACF and Cepstrum\n\n*/\n\n\n\n#include <lldcore/pitchACF.hpp>\n\n#define MODULE \"cPitchACF\"\n\n\nSMILECOMPONENT_STATICS(cPitchACF)\n\nSMILECOMPONENT_REGCOMP(cPitchACF)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CPITCHACF;\n  sdescription = COMPONENT_DESCRIPTION_CPITCHACF;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n\n  // if the inherited config type was found, we register our configuration variables\n  SMILECOMPONENT_IFNOTREGAGAIN( {} // <- this is only to avoid compiler warnings...\n    // name append has a special role: it is defined in cDataProcessor, and can be overwritten here:\n\t// if you set description to NULL, the existing description will be used, thus the following call can\n\t// be used to update the default value:\n    //ct->setField(\"nameAppend\",NULL,\"processed\");\n    ct->setField(\"maxPitch\",\"Maximum detectable pitch in Hz\", 500.0);  \n    ct->setField(\"voiceProb\",\"1/0 = on/off: output of voicing probability\", 1);\n    ct->setField(\"voiceQual\",\"1/0 = on/off: output of voice 'quality' (= ZCR of ACF)\", 0);\n    ct->setField(\"HNR\",\"1/0 = on/off; output of log (base e) harmonics-to-noise ratio (HNR) computed from the ACF, pre 2.0 compatibility.\", 0);\n    ct->setField(\"HNRdB\",\"1/0 = on/off; output of log (dB, base 10) harmonics-to-noise ratio (HNR) computed from the ACF. Recommended.\", 0);\n    ct->setField(\"linHNR\",\"1/0 = on/off; output of linear harmonics-to-noise ratio (HNR) computed from the ACF.\", 0);\n    ct->setField(\"F0\",\"1/0 = on/off: output of F0 (pitch) (Note: the pitch output is 0 in unvoiced segments)\", 0);\n    ct->setField(\"F0raw\",\"1/0 = on/off: output of raw F0 candidate without thresholding in unvoiced segments\", 0);\n    ct->setField(\"F0env\",\"1/0 = on/off: output of F0 envelope (expontial decay smoothing) (Note: this differs from the envelope computed by the cPitchBase descendant components, such as cPitchSHS!)\", 0);\n\t  ct->setField(\"voicingCutoff\",\"This sets the voicing probability threshold for pitch detection [0.0 - 1.0]. Frames with voicing probability values above this threshold will be considered as voiced.\", 0.55);\n\t  ct->setField(\"processArrayFields\",NULL,0);\n  )\n\n  // The configType gets automatically registered with the config manger by the SMILECOMPONENT_IFNOTREGAGAIN macro\n  \n  // we now create out sComponentInfo, including name, description, success status, etc. and return that\n  SMILECOMPONENT_MAKEINFO(cPitchACF);\n}\n\nSMILECOMPONENT_CREATE(cPitchACF)\n\n//-----\n\ncPitchACF::cPitchACF(const char *_name) :\n  cVectorProcessor(_name),\n  fsSec(-1.0),\n  lastPitch(0.0),\n  lastlastPitch(0.0),\n  glMeanPitch(0.0),\n  onsFlag(0),\n  pitchEnv(0.0),\n  F0raw(0)\n{\n\n}\n\nvoid cPitchACF::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n  \n  HNR = getInt(\"HNR\");\n  SMILE_IDBG(2,\"HNR = %i\",HNR);\n  HNRdB = getInt(\"HNRdB\");\n  SMILE_IDBG(2,\"HNRdB = %i\",HNRdB);\n  linHNR = getInt(\"linHNR\");\n  SMILE_IDBG(2,\"linHNR = %i\",linHNR);\n  voiceProb = getInt(\"voiceProb\");\n  SMILE_IDBG(2,\"voiceProb = %i\",voiceProb);\n  voiceQual = getInt(\"voiceQual\");\n  SMILE_IDBG(2,\"voiceQual = %i\",voiceQual);\n  F0 = getInt(\"F0\");\n  SMILE_IDBG(2,\"F0 = %i\",F0);\n  F0raw = getInt(\"F0raw\");\n  SMILE_IDBG(2,\"F0raw = %i\",F0raw);\n  F0env = getInt(\"F0env\");\n  SMILE_IDBG(2,\"F0env = %i\",F0env);\n  \n  voicingCutoff = getDouble(\"voicingCutoff\");\n  if (voicingCutoff > 1.0) voicingCutoff = 1.0;\n  if (voicingCutoff < 0.0) voicingCutoff = 0.0;\n  SMILE_IDBG(2,\"voicingCutoff = %i\",voicingCutoff);\n\n  maxPitch = getDouble(\"maxPitch\");\n  if (maxPitch < 0.0) maxPitch = 0.0;\n  SMILE_IDBG(2,\"maxPitch = %lf\",maxPitch);\n  \n\n}\n\n\n// optional\n\nint cPitchACF::setupNewNames(long nEl)\n{\n  if (fsSec == -1.0) {\n    const sDmLevelConfig *c = reader_->getLevelConfig();\n    fsSec = (float)(c->frameSizeSec);\n  }\n\n  int n=0;\n  if (voiceProb) { writer_->addField( \"voiceProb\", 1 ); n++; }\n  if (HNR) { writer_->addField( \"HNR\", 1 ); n++;}\n  if (HNRdB) { writer_->addField( \"HNRdBacf\", 1 ); n++;}\n  if (linHNR) { writer_->addField( \"linearHNRacf\", 1 ); n++;}\n  if (voiceQual) { writer_->addField( \"voiceQual\", 1 ); n++; }\n  if (F0) { writer_->addField( \"F0\", 1 ); n++; }\n  if (F0raw) { writer_->addField( \"F0raw\", 1 ); n++; }\n  if (F0env) { writer_->addField( \"F0env\", 1 ); n++; }\n\n  namesAreSet_ = 1;\n\n  return n;\n//  return cVectorProcessor::setupNamesForField(i,name,nEl);\n}\n\n\n\n// implementation of the actual processing\nint cPitchACF::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  // do domething to data in *src, save result to *dst\n  // NOTE: *src and *dst may be the same...\n  long maxIdx;\n  double voicing;\n  double hnr = 0.0;\n  double hnrDB = 0.0;\n  double hnrLin = 0.0;\n  double acfZcr = 0.0;\n  //long N = (int)floor(Nsrc/2.0);\n  long N = (int)floor(Nsrc/2.0); // length of ACF: assumes ACF+Cepstrum input array, ACF is half size of cepstrum\n  //long N = Nsrc/2;\n\n  double _N = (double)(Nsrc);  // assumes ACF+Cepstrum input array, ACF is half size of cepstrum, where cepstrum is full frame size in samples\n  double F0fft = 1.0/fsSec;\n  double Tsamp = fsSec/_N;\n  // NO!!! don't hardcode samplerate! ;-)  double Tsamp = 1.0/44100.0;  // sampling period  \n\n  int preskip;\n  if (maxPitch<=0) preskip = 0;\n  else preskip = (int)(1.0 / (maxPitch*Tsamp));  // this variable determines the maximal pitch detectable\n  int halflen = (int)(_N/2.0)-preskip+1;\n  // detect voicing prob. and zero crossing rate (clarity) from normal acf:\n  voicing = voicingProb(src,N,preskip,&acfZcr);\n  // find pitch peak in log acf (cepstrum):\n  maxIdx = pitchPeak(src+N,N,preskip+1);\n  // compute HNR\n  if (HNR) {\n    hnr = computeHNR(src,maxIdx);\n  }\n  if (HNRdB) {\n    hnrDB = computeHNR_dB(src,maxIdx);\n  }\n  if (linHNR) {\n    hnrLin = computeHNR_lin(src,maxIdx);\n  }\n\n  int n=0;\n\n  if (voiceProb) dst[n++] = (FLOAT_DMEM)voicing;\n  if (HNR) dst[n++] = (FLOAT_DMEM)hnr;\n  if (HNRdB) dst[n++] = (FLOAT_DMEM)hnrDB;\n  if (linHNR) dst[n++] = (FLOAT_DMEM)hnrLin;\n  if (F0 || F0env || voiceQual || F0raw) {\n    FLOAT_DMEM vq = ((FLOAT_DMEM)maxPitch - (FLOAT_DMEM)fabs((acfZcr*maxPitch)-((FLOAT_DMEM)1.0/((FLOAT_DMEM)(maxIdx)*(FLOAT_DMEM)Tsamp))) )* (FLOAT_DMEM)voicing;\n    if (maxIdx == 0.0) vq = 0.0;\n    if (voiceQual) dst[n++] = vq;\n    FLOAT_DMEM pitch = 0.0;\n    FLOAT_DMEM rawF0 = 0.0;\n    if (maxIdx > 0) {\n      pitch = (FLOAT_DMEM)1.0/((FLOAT_DMEM)(maxIdx)*(FLOAT_DMEM)Tsamp);\n      rawF0 = pitch;\n    }\n    if (voicing < voicingCutoff) { maxIdx = 0; pitch = 0.0; }  //vq/maxPitch\n\n\n\n\n    // very simple pitch contour smoothing:\n\n    if ((lastPitch == 0.0)&&(pitch>0.0)) onsFlag = 1;\n    if ((lastPitch > 0.0)&&(pitch==0.0)&&(onsFlag==0)) onsFlag = -1;\n    if ((lastPitch > 0.0)&&(pitch>0.0)) onsFlag = 0;\n    if ((lastPitch == 0.0)&&(pitch==0.0)) onsFlag = 0;\n\n    if ((pitch==0.0)&&(onsFlag==1)) { lastPitch = 0.0; }\n\n    FLOAT_DMEM oPitch = pitch;\n    FLOAT_DMEM tol = (FLOAT_DMEM)0.4;\n    FLOAT_DMEM alpha = (FLOAT_DMEM)0.3;\n\n    if (pitch > 0.0) {\n      if (glMeanPitch == 0.0) glMeanPitch = pitch;\n      //if ((lastPitch == 0.0)||(onsFlag==1)) tol = 0.1;\n      if (!((pitch < ((FLOAT_DMEM)1.0+tol)*glMeanPitch)&&(pitch > ((FLOAT_DMEM)1.0-tol) * glMeanPitch))) {\n        pitch = glMeanPitch;\n        alpha /= (FLOAT_DMEM)3.0;\n      } \n      if (onsFlag&&(lastPitch > pitch)) lastPitch *= (FLOAT_DMEM)0.85;\n    } \n    if ((pitch>0.0)&&(onsFlag==-1)) { lastPitch = pitch; }\n\n\n    if (oPitch > (FLOAT_DMEM)0.0)\n      glMeanPitch = ((FLOAT_DMEM)1.0-alpha)*glMeanPitch + alpha*oPitch;    // TODO: pitch decay constant!\n\n\n    FLOAT_DMEM out;\n    if ((lastlastPitch!=(FLOAT_DMEM)0.0)&&(lastPitch!=0.0))\n      out = (FLOAT_DMEM)0.5*(lastlastPitch + lastPitch);\n    else \n      out = lastPitch;\n\n    if (F0) dst[n++] = out;   // TODO: normPitch option\n\n    if (F0raw) dst[n++] = rawF0;   // TODO: normPitch option\n\n    lastlastPitch = lastPitch;\n    lastPitch = pitch;\n\n    if (F0env) {\n      if (out > 0.0)\n        pitchEnv = (FLOAT_DMEM)0.75*pitchEnv + (FLOAT_DMEM)0.25*out;\n      dst[n++] = pitchEnv;\n    }\n  }\n\n  return n;\n}\n\ndouble cPitchACF::voicingProb(const FLOAT_DMEM *a, int n, int skip, double *Zcr)\n{\n  int zcr=0, mcr=0;\n  double mean=0.0;\n  double max;\n  \n  //n /= 2;\n  // zero crossings and max\n  max = a[n-1];\n  mean = a[skip];\n  for (int i=1; i<n; i++) {\n    if ( a[i-1]*a[i] < 0 ) zcr++;\n    if (i>=skip) {\n      if ((a[i] > max) && (a[i-1] < a[i])) max = a[i];\n      mean += a[i];\n    }\n  }\n  mean /= (double)(n-skip+1);\n\n  for (int i=1; i<n; i++) {\n    if ( (a[i-1]-mean)*(a[i]-mean) < 0 ) mcr++;\n  }\n\n  if (Zcr != NULL) {\n    if (mcr > zcr) {\n      *Zcr = (double)mcr / (double)n;\n    } else {\n      *Zcr = (double)zcr / (double)n;\n    }\n  }\n\n  if (a[0] > 0) \n    return max/a[0];  \n  else \n    return 0.0;\n}\n\nlong cPitchACF::pitchPeak(const FLOAT_DMEM *a, long n, long skip)\n{\n  double max;\n  double buf;\n  double sum = 0.0;\n\n  // first pass: compute mean and find absolute max\n  max = a[n-1];\n  for (int i=n-1; i>=0; i--) {\n    buf = a[i];\n    sum += fabs(buf);\n\tif (i>=skip) if (buf > max) max = buf;\n  }\n  sum /= n;\n\n  // second pass: peak detection\n  for (int i=skip+1; i<n-1; i++) {\n    if (a[i] > (max+sum)*0.6) {\n      if ( (a[i-1] < a[i]) && (a[i] > a[i+1]) ) { // we found a peak!\n        return i;\n      }\n    }\n  }\n  return 0;    \n}\n\ndouble cPitchACF::computeHNR(const FLOAT_DMEM *a, int f0Idx)\n{\n  double buf;\n  double ret;\n  if ((a[0]-a[f0Idx]) == 0.0) buf = 100000000000000000000.0;\n  else buf = a[f0Idx]/(a[0]-a[f0Idx]);\n    \n  if (buf>0.00000000001) {\n    ret = 10.0*log(buf);\n  } else {\n    ret = 10.0*log(0.00000000001);\n  }\n  return ret;\n}\n\n/* computes HNR from ACF in dB for a range -100 to +100 dB */\ndouble cPitchACF::computeHNR_dB(const FLOAT_DMEM *a, int f0Idx)\n{\n  double buf = a[0] - a[f0Idx];\n  if (buf == 0.0) {\n    buf = 10e10;\n  } else {\n    buf = a[f0Idx]/buf;\n  }\n  if (buf <= 10e-10) {\n    return -100.0;\n  } else if (buf >= 10e10) {\n    return +100.0;\n  } else {\n    return 10.0 * log(buf) / log(10.0);\n  }\n}\n\n/* computes HNR from ACF in dB for a range -100 to +100 dB */\ndouble cPitchACF::computeHNR_lin(const FLOAT_DMEM *a, int f0Idx)\n{\n  double buf = a[0] - a[f0Idx];\n  if (buf == 0.0) {\n    buf = 10e3;\n  } else {\n    buf = a[f0Idx]/buf;\n  }\n  if (buf <= 10e-3) {\n    return 10e-3;\n  } else if (buf >= 10e3) {\n    return 10e3;\n  } else {\n    return buf;\n  }\n}\n\ncPitchACF::~cPitchACF()\n{\n}\n\n"
  },
  {
    "path": "src/lldcore/pitchBase.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nBase class for pitch components, provides standard output values and configuration\n\n*/\n\n\n\n#include <lldcore/pitchBase.hpp>\n\n#define MODULE \"cPitchBase\"\n\n\nSMILECOMPONENT_STATICS(cPitchBase)\n\nSMILECOMPONENT_REGCOMP(cPitchBase)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CPITCHBASE;\n  sdescription = COMPONENT_DESCRIPTION_CPITCHBASE;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n\n  // if the inherited config type was found, we register our configuration variables\n  SMILECOMPONENT_IFNOTREGAGAIN( {} // <- this is only to avoid compiler warnings...\n    // name append has a special role: it is defined in cDataProcessor, and can be overwritten here:\n\t  // if you set description to NULL, the existing description will be used, thus the following call can\n  \t// be used to update the default value:\n    //ct->setField(\"nameAppend\",NULL,\"processed\");\n\n    // detectable pitch range:\n    ct->setField(\"maxPitch\",\"Maximum detectable pitch in Hz\", 620.0);  \n    ct->setField(\"minPitch\",\"Minimum detectable pitch in Hz\", 52.0);  \n\n    ct->setField(\"nCandidates\",\"The number of F0 candidates to output [1-20] (0 disables ouput of candidates AND their voicing probs.)\",3);\n    ct->setField(\"scores\",\"1/0 = on/off: output of F0 candidates scores, if available\",1);\n    ct->setField(\"voicing\",\"1/0 = on/off: output of voicing probability for F0 candidates\",1);\n\n    ct->setField(\"F0C1\",\"1/0 = on/off: output of raw best F0 candidate without thresholding in unvoiced segments\",0);\n    ct->setField(\"voicingC1\",\"1/0 = on/off: output of output voicing (pseudo) probability for best candidate\",0);\n    ct->setField(\"F0raw\",\"1/0 = on/off: output of raw F0 (best candidate), > 0 only for voiced segments (using voicingCutoff threshold)\",0);\n    ct->setField(\"voicingClip\",\"1/0 = on/off: output of voicing of raw F0 (best candidate), > 0 only for voiced segments (using voicingCutoff threshold)\",0);\n    \n    ct->setField(\"voicingCutoff\",\"This sets the voicing (pseudo) probability threshold for pitch detection. Frames with voicing probability values above this threshold will be considered as voiced.\",1.0);\n\n    ct->setField(\"inputFieldSearch\",\"A part of the name to find the pitch detectors input field by ('Mag' searches e.g. for *Mag*, and will match fftMag fields)\",\"Mag\");\n\n    // overwrite this in derived components:\n    ct->setField(\"octaveCorrection\",\"If this pitch detector algorithm offers algorithm specific low-level octave correction, enable it\",0);\n\n    ct->setField(\"processArrayFields\",NULL,0);\n  )\n\n  // The configType gets automatically registered with the config manger by the SMILECOMPONENT_IFNOTREGAGAIN macro\n  \n  // we now create out sComponentInfo, including name, description, success status, etc. and return that\n  SMILECOMPONENT_MAKEINFO_ABSTRACT(cPitchBase);\n}\n\nSMILECOMPONENT_CREATE_ABSTRACT(cPitchBase)\n\n//-----\n\ncPitchBase::cPitchBase(const char *_name) :\n  cVectorProcessor(_name),\n  inData(NULL), f0cand(NULL), candVoice(NULL), candScore(NULL)\n{\n\n}\n\nvoid cPitchBase::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n\n  maxPitch = getDouble(\"maxPitch\");\n  if (maxPitch < 0.0) maxPitch = 0.0;\n  SMILE_IDBG(2,\"maxPitch = %lf\",maxPitch);\n\n  minPitch = getDouble(\"minPitch\");\n  if (minPitch < 0.0) minPitch = 0.0;\n  if (minPitch > maxPitch) minPitch = maxPitch;\n  SMILE_IDBG(2,\"minPitch = %lf\",minPitch);\n\n  nCandidates = getInt(\"nCandidates\");\n  if (nCandidates < 1) nCandidates = 1;\n  if (nCandidates > 20) nCandidates = 20;\n  SMILE_IDBG(2,\"nCandidates = %i\",nCandidates);\n  scores = getInt(\"scores\");\n  SMILE_IDBG(2,\"scores = %i\",scores);\n  voicing = getInt(\"voicing\");\n  SMILE_IDBG(2,\"voicing = %i\",voicing);\n\n\n  F0C1 = getInt(\"F0C1\");\n  SMILE_IDBG(2,\"F0C1 = %i\",F0C1);\n  voicingC1 = getInt(\"voicingC1\");\n  SMILE_IDBG(2,\"voicingC1 = %i\",voicingC1);\n  F0raw = getInt(\"F0raw\");\n  SMILE_IDBG(2,\"F0raw = %i\",F0raw);\n  voicingClip = getInt(\"voicingClip\");\n  SMILE_IDBG(2,\"voicingClip = %i\",voicingClip);\n\n  voicingCutoff = (FLOAT_DMEM)getDouble(\"voicingCutoff\");\n  SMILE_IDBG(2,\"voicingCutoff = %f\",voicingCutoff);\n\n  octaveCorrection = getInt(\"octaveCorrection\");\n  SMILE_IDBG(2,\"octaveCorrection = %i\",octaveCorrection);\n\n  inputFieldPartial = getStr(\"inputFieldSearch\");\n  SMILE_IDBG(2,\"inputFieldSearch = '%s'\",inputFieldPartial);\n}\n\n\nint cPitchBase::setupNewNames(long nEl)\n{\n//  fsSec = getFrameSizeSec();\n  \n  findInputField(inputFieldPartial, 0, nEl);\n\n  int n=0;\n    //TODO: usw addNameAppendField to preserve base name\n  // candidates (in ranked order):\n  if (nCandidates>0) { // also save number of valid candidates\n    writer_->addField(\"nCandidates\", 1); n++; \n  } \n  if (nCandidates>0) { writer_->addField(\"F0Cand\", nCandidates); n += nCandidates; }\n  if ((nCandidates>0)&&(voicing)) { \n    writer_->addField(\"candVoicing\", nCandidates); n += nCandidates; \n  }\n  if ((nCandidates>0)&&(scores)) { \n    writer_->addField(\"candScores\", nCandidates); n += nCandidates; \n  }\n\n  if (candScore == NULL) candScore = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*nCandidates);\n  if (candVoice == NULL) candVoice = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*nCandidates);\n  if (f0cand == NULL) f0cand = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*nCandidates);\n\n  //// these are provided mainly for compatibility and to be able to use max. candidate directly without a post smoothing component\n  // raw first candidate:\n  if (F0C1) { writer_->addField( \"F0C1\", 1 ); n++; }\n  // raw voicing prob. of first candidate: \n  if (voicingC1) { writer_->addField( \"voicingC1\", 1 ); n++;}\n  // raw first candidate after voicing thresholding (unvoiced regions are zero...):\n  if (F0raw) { writer_->addField( \"F0raw\", 1 ); n++; }\n  if (voicingClip) { writer_->addField( \"voicingClip\", 1 ); n++; }\n  \n  // save a little meta data for the pitchSmoother component\n  cVectorMeta *mdata = writer_->getLevelMetaDataPtr();\n  if (mdata != NULL) {\n    //TODO: mdata ID!\n    mdata->fData[0] = voicingCutoff; \n  }\n\n  namesAreSet_ = 1;\n  return n;\n}\n\nint cPitchBase::pitchDetect(FLOAT_DMEM * _inData, long _N, double _fsSec, double _baseT, FLOAT_DMEM *_f0cand, FLOAT_DMEM *_candVoice, FLOAT_DMEM *_candScore, long _nCandidates)\n{\n  // to be implemented by child class\n\n  // return actual number of candidates on success (-1 on failure...)\n  return 0;\n}\n\nint cPitchBase::addCustomOutputs(FLOAT_DMEM *dstCur, long NdstLeft)\n{\n  // to be implemented by child class\n\n  // return the number of custom outputs that were added..\n  return 0;\n}\n\n// a derived class should override this method, in order to implement the actual processing\nint cPitchBase::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  // we assume we have fft magnitude as input...\n  //double _N = (double)(Nsrc);  \n  //double F0fft = 1.0/fsSec;\n  //double Tsamp = fsSec/_N;\n  int nCand=0; long i, j;\n\n  if (!getInputFieldData(src,Nsrc,&inData)) return 0;\n // printf(\"inputStart: %i  nInput: %i  Nsrc %i\\n\",inputStart,nInput,Nsrc);\n // for (i=0; i<Nsrc; i++) { if (src[i] != 9.0) fprintf(stderr,\"src[%i]\\n\",i); }\n // for (i=0; i<nInput; i++) { if (inData[i] != 9.0) fprintf(stderr,\"inData[%i]\\n\",i); }\n  // todo:  f0cand,candVoice,candScore point to appropriate positions in *dst\n\n  \n  // zero candidates\n  for (i=0; i<nCandidates; i++) {\n    f0cand[i] = 0.0;\n    candVoice[i] = 0.0;\n    candScore[i] = 0.0;\n  }\n  // main algorithm to be implemented by derived component\n  nCand = pitchDetect(inData,nInput_,getFrameSizeSec(),getBasePeriod(),f0cand,candVoice,candScore,nCandidates);\n\n  // post process candidates wrt. minPitch / maxPitch\n  // => remove out of range candidates\n  if ( nCand > 0 ) {\n      for (i=0; (i<nCandidates)&&(nCand>0); i++) {\n        if ( (f0cand[i] > maxPitch)||(f0cand[i] < minPitch) ) {\n          FLOAT_DMEM origF = f0cand[i];\n          for (j=i+1; j<nCandidates; j++) {\n            f0cand[j-1] = f0cand[j];\n            candVoice[j-1] = candVoice[j];\n            candScore[j-1] = candScore[j];\n          }\n          f0cand[j-1]=0;\n          candVoice[j-1]=0;\n          candScore[j-1]=0;\n          if (origF > 0.0) { nCand--; i--; }\n        }\n      }\n  }\n\n  // if candidates remain, add them to output\n  if ( nCand >= 0 ) {\n\n    long n=0;\n    if (nCandidates>0) {\n      *(dst++) = (FLOAT_DMEM)nCand;\n      \n      // TODO: move max score candidate to 0th (if !octaveCorrection)\n      long maxI = 0;\n        if (!octaveCorrection) {\n          FLOAT_DMEM max = candScore[0]; \n          for (i=1; i<nCandidates; i++) { // find max score (may be equal to voicing prob.)\n            if (candScore[i] > max) { max = candScore[i]; maxI = i; }\n          }\n        }\n        // swap\n        if (maxI > 0) {\n          FLOAT_DMEM tmp;\n          tmp = f0cand[0];\n          f0cand[0] = f0cand[maxI];\n          f0cand[maxI] = tmp;\n          tmp = candVoice[0];\n          candVoice[0] = candVoice[maxI];\n          candVoice[maxI] = tmp;\n          tmp = candScore[0];\n          candScore[0] = candScore[maxI];\n          candScore[maxI] = tmp;\n        }\n\n      // add raw candidates to output\n      for (i=0; i<nCandidates; i++) {\n        *(dst++) = f0cand[i];\n      }\n      n += nCandidates;\n      if (voicing) {\n        for (i=0; i<nCandidates; i++) {\n          *(dst++) = candVoice[i];\n        }\n        n += nCandidates;\n      }\n      if (scores) {\n        for (i=0; i<nCandidates; i++) {\n          *(dst++) = candScore[i];\n        }\n        n += nCandidates;\n      }\n\n      // now pick best candidate (if octaveCorrection is enabled, always use 0th candidate!)\n      if (F0C1||voicingC1||F0raw||voicingClip) {\n        long maxI = 0;\n        /*if (!octaveCorrection) {\n          FLOAT_DMEM max = candScore[0]; \n          for (i=1; i<nCandidates; i++) { // find max score (may be equal to voicing prob.)\n            if (candScore[i] > max) { max = candScore[i]; maxI = i; }\n          }\n        }*/\n\n        //FLOAT_DMEM _f0raw =  ;\n        if (F0C1) { *(dst++) = f0cand[maxI]; n++; }\n        if (voicingC1) { *(dst++) = candVoice[maxI]; n++; }\n        // and apply voicingCutoff\n        if (F0raw) {\n          if (candVoice[maxI] <= voicingCutoff) *(dst++) = 0.0;\n          else *(dst++) = f0cand[maxI]; \n          n++;\n        }\n        if (voicingClip) {\n          if (candVoice[maxI] <= voicingCutoff) *(dst++) = 0.0;\n          else *(dst++) = candVoice[maxI]; \n          n++;\n        }\n      }\n\n    }\n\n    n += addCustomOutputs(dst,Ndst-n);\n    return n;\n\n  } else { return 0; }\n\n}\n\ncPitchBase::~cPitchBase()\n{\n  if (inData != NULL) free(inData);\n  if (f0cand != NULL) free(f0cand);\n  if (candVoice != NULL) free(candVoice);\n  if (candScore != NULL) free(candScore);\n}\n\n"
  },
  {
    "path": "src/lldcore/pitchSmoother.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\n\n*/\n\n\n\n#include <lldcore/pitchSmoother.hpp>\n\n#define MODULE \"cPitchSmoother\"\n\n\nSMILECOMPONENT_STATICS(cPitchSmoother)\n\nSMILECOMPONENT_REGCOMP(cPitchSmoother)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CPITCHSMOOTHER;\n  sdescription = COMPONENT_DESCRIPTION_CPITCHSMOOTHER;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n\n  // if the inherited config type was found, we register our configuration variables\n  SMILECOMPONENT_IFNOTREGAGAIN( {} // <- this is only to avoid compiler warnings...\n    // name append has a special role: it is defined in cDataProcessor, and can be overwritten here:\n\t  // if you set description to NULL, the existing description will be used, thus the following call can\n  \t// be used to update the default value:\n    //ct->setField(\"nameAppend\",NULL,\"processed\");\n\n    ct->setField(\"medianFilter0\",\"Apply median filtering of candidates as the FIRST processing step; filter length is 'medianFilter0' if > 0\",0);\n    ct->setField(\"postSmoothing\",\"Apply post processing (median and spike remover) over 'postSmoothing' frames (0=no smoothing or use default set by postSmoothingMethod)\",0);\n    ct->setField(\"postSmoothingMethod\",\"Post processing method to use. One of the following:\\n   'none' disable post smoothing\\n   'simple' simple post smoothing using only 1 frame delay (will smooth out 1 frame octave spikes)\\n   'median' will apply a median filter to the output values (length = value of 'postProcessing')\",\"simple\");\n    ct->setField(\"octaveCorrection\",\"Enable intelligent cross candidate octave correction\",1);\n    \n    // new data\n    ct->setField(\"F0final\",\"1 = Enable output of final (corrected and smoothed) F0\",1);\n    ct->setField(\"F0finalEnv\",\"1 = Enable output of envelope of final smoothed F0 (i.e. there will be no 0 values (except for end and beginning))\",0);\n    ct->setField(\"no0f0\",\"1 = enable 'no zero F0', output data only when F0>0, i.e. a voiced frame is detected. This may cause problem with some functionals and framer components, which don't support this variable length data yet...\",0);\n\n    ct->setField(\"voicingFinalClipped\",\"1 = Enable output of final smoothed and clipped voicing (pseudo) probability. 'Clipped' means that the voicing probability is set to 0 for unvoiced regions, i.e. where the probability lies below the voicing threshold.\",0);\n    ct->setField(\"voicingFinalUnclipped\",\"1 = Enable output of final smoothed, raw voicing (pseudo) probability (UNclipped: not set to 0 during unvoiced regions).\",0);\n    \n    // data forwarded from pitch detector\n    ct->setField(\"F0raw\",\"1 = Enable output of 'F0raw' copied from input\",0);\n    ct->setField(\"voicingC1\",\"1 = Enable output of 'voicingC1' copied from input\",0);\n    ct->setField(\"voicingClip\",\"1 = Enable output of 'voicingClip' copied from input\",0);\n\n    ct->setField(\"processArrayFields\",NULL,0);\n  )\n\n  // The configType gets automatically registered with the config manger by the SMILECOMPONENT_IFNOTREGAGAIN macro\n  \n  // we now create out sComponentInfo, including name, description, success status, etc. and return that\n  SMILECOMPONENT_MAKEINFO(cPitchSmoother);\n}\n\nSMILECOMPONENT_CREATE(cPitchSmoother)\n\n//-----\n\ncPitchSmoother::cPitchSmoother(const char *_name) :\n  cVectorProcessor(_name),\n  nCands(NULL), nCandidates(NULL), \n  f0cand(NULL), candVoice(NULL), candScore(NULL),\n  voicingCutoff(NULL),\n  f0candI(NULL), candVoiceI(NULL), candScoreI(NULL),\n  voicingC1I(NULL), F0rawI(NULL), voicingClipI(NULL),\n  median0WorkspaceF0cand(NULL), lastFinal(NULL),\n  onsFlag(0), onsFlagO(0), firstFrame(1),\n  lastVoice(NULL), lastFinalF0(0), pitchEnv(0.0)\n{\n\n}\n\nvoid cPitchSmoother::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n\n  medianFilter0 = getInt(\"medianFilter0\");\n  SMILE_IDBG(2,\"medianFilter0 = %i\",medianFilter0);\n\n  postSmoothing = getInt(\"postSmoothing\");\n  const char * postSmoothingMethodStr = getStr(\"postSmoothingMethod\");\n  if (postSmoothingMethodStr != NULL){\n  if (!strncasecmp(postSmoothingMethodStr,\"none\",4)) {\n    postSmoothingMethod = POSTSMOOTHING_NONE;\n    postSmoothing = 0;\n  } else if (!strncasecmp(postSmoothingMethodStr,\"simp\",4)) {\n    postSmoothingMethod = POSTSMOOTHING_SIMPLE;\n    postSmoothing = 1;\n  } else if (!strncasecmp(postSmoothingMethodStr,\"medi\",4)) {\n    postSmoothingMethod = POSTSMOOTHING_MEDIAN;\n    if (postSmoothing < 2) postSmoothing = 2; \n  } else {\n    SMILE_IERR(1,\"unknown post smoothing method '%s'\",postSmoothingMethodStr);\n    postSmoothingMethod = POSTSMOOTHING_NONE;\n  }\n  }\n  SMILE_IDBG(2,\"postSmoothing = %i\",postSmoothing);\n  if (postSmoothing>0) {\n    lastFinal = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*postSmoothing);\n  }\n  \n  octaveCorrection = getInt(\"octaveCorrection\");\n  SMILE_IDBG(2,\"octaveCorrection = %i\",octaveCorrection);\n\n  \n  F0final = getInt(\"F0final\");\n  SMILE_IDBG(2,\"F0final = %i\",F0final);\n  F0finalEnv = getInt(\"F0finalEnv\");\n  SMILE_IDBG(2,\"F0finalEnv = %i\",F0finalEnv);\n  no0f0 = getInt(\"no0f0\");\n  SMILE_IDBG(2,\"no0f0 = %i (not yet well supported)\",no0f0);\n\n  voicingFinalClipped = getInt(\"voicingFinalClipped\");\n  SMILE_IDBG(2,\"voicingFinalClipped = %i\",voicingFinalClipped);\n  voicingFinalUnclipped = getInt(\"voicingFinalUnclipped\");\n  SMILE_IDBG(2,\"voicingFinalUnclipped = %i\",voicingFinalUnclipped);\n\n  F0raw = getInt(\"F0raw\");\n  SMILE_IDBG(2,\"F0raw = %i\",F0raw);\n  voicingC1 = getInt(\"voicingC1\");\n  SMILE_IDBG(2,\"voicingC1 = %i\",voicingC1);\n  voicingClip = getInt(\"voicingClip\");\n  SMILE_IDBG(2,\"voicingClip = %i\",voicingClip);\n\n}\n\n\nint cPitchSmoother::setupNewNames(long nEl)\n{\n\n  int n=0;\n    //TODO: usw addNameAppendField to preserve base name\n  // final (smoothed) output\n  if (F0final) { writer_->addField(\"F0final\", 1); n++; } \n  if (F0finalEnv) { writer_->addField(\"F0finEnv\", 1); n++; } \n  if (voicingFinalClipped) { writer_->addField(\"voicingFinalClipped\", 1); n++; } \n  if (voicingFinalUnclipped) { writer_->addField(\"voicingFinalUnclipped\", 1); n++; } \n\n  // copied from input:\n  if (voicingC1) { writer_->addField( \"voicingC1\", 1 ); n++;}\n  if (F0raw) { writer_->addField( \"F0raw\", 1 ); n++; }\n  if (voicingClip) { writer_->addField( \"voicingClip\", 1 ); n++; }\n\n  long i,idx,nC;\n  nInputLevels = reader_->getNLevels();\n  if (nInputLevels<1) nInputLevels=1;\n  voicingCutoff = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*nInputLevels);\n  nCandidates = (int*)calloc(1,sizeof(int)*nInputLevels);\n  nCands = (int*)calloc(1,sizeof(int)*nInputLevels);\n  f0candI = (int*)calloc(1,sizeof(int)*nInputLevels);\n  candVoiceI = (int*)calloc(1,sizeof(int)*nInputLevels);\n  candScoreI = (int*)calloc(1,sizeof(int)*nInputLevels);\n  F0rawI = (int*)calloc(1,sizeof(int)*nInputLevels);\n  voicingClipI = (int*)calloc(1,sizeof(int)*nInputLevels);\n  voicingC1I = (int*)calloc(1,sizeof(int)*nInputLevels);\n\n  totalCands = 0; \n  int more=0; int moreV=0; int moreS=0;\n  int moreC1=0; int moreRa=0; int moreVc=0;\n  \n  for (i=0; i<nInputLevels; i++) {\n\n    cVectorMeta *mdata = reader_->getLevelMetaDataPtr(i);\n    if (mdata != NULL) {\n      // TODO : check mdata ID\n      voicingCutoff[i] = mdata->fData[0];\n      SMILE_IMSG(3,\"voicing cutoff read from input level %i = %f\\n\",i,voicingCutoff[i]);\n    }\n    \n    if (F0raw) {\n      int idxRa = findField(\"F0raw\",0,NULL,NULL,-1,&moreRa); // TODO: check if nC == 1 here\n      //printf(\"idxRa %i moreRa %i  i %i\\n\",idxRa,moreRa,i);\n      F0rawI[i] = idxRa;\n      if (moreRa>0) { moreRa = idxRa+1; }\n    }\n    if (voicingClip) {\n      int idxVc = findField(\"voicingClip\",0,NULL,NULL,-1,&moreVc); // TODO: check if nC == 1 here\n      voicingClipI[i] = idxVc;\n      if (moreVc>0) { moreVc = idxVc+1; }\n    }\n    if (voicingC1) {\n      int idxC1 = findField(\"voicingC1\",0,NULL,NULL,-1,&moreC1); // TODO: check if nC == 1 here\n      voicingC1I[i] = idxC1;\n      if (moreC1>0) { moreC1 = idxC1+1; }\n    }\n\n    idx = findField(\"F0Cand\",0,&nC,NULL,-1,&more);\n    f0candI[i] = idx;\n    //printf(\"idx %i\\n\",idx);\n    if (idx >= 0) {\n      int idxV = findField(\"candVoicing\",0,NULL,NULL,-1,&moreV); \n      candVoiceI[i] = idxV;\n      if (moreV>0) { moreV = idxV+1; }\n      int idxS = findField(\"candScore\",0,NULL,NULL,-1,&moreS); // TODO: check if nC == N here\n      candScoreI[i] = idxS;\n      if (moreS>0) { moreS = idxS+1; }\n      nCandidates[i] = nC;\n      if (more>0) { more = idx+1; }\n      else {\n        totalCands += nC;\n        nInputLevels = i+1;\n        break;\n      }\n    } else {\n      nCandidates[i] = 0;\n      nInputLevels = i;\n      break;\n    }\n    totalCands += nC;\n    \n    \n  }\n\n  if (f0cand == NULL) f0cand = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*totalCands*3);\n  candVoice = f0cand+totalCands; //(FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*totalCands);\n  candScore = f0cand+totalCands*2; //(FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*totalCands);\n\n  if (medianFilter0 > 0) {\n    median0WorkspaceF0cand = smileUtil_temporalMedianFilterInitSl(totalCands, 2, medianFilter0);\n  }\n\n  namesAreSet_ = 1;\n  return n;\n}\n\n// NOTE: pitchSmoother introduces a delay of 1 frame, vIdx will not reflect the correct start time anymore,\n//  instead, tmeta->time should be used!\nint cPitchSmoother::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  long i, j;\n  long n=0;\n\n  // collect all input candidates\n  int c = 0;\n  for (i=0; i<nInputLevels; i++) {\n    for (j=0; j<nCandidates[i]; j++) {\n      candVoice[c] = src[candVoiceI[i]+j];\n      candScore[c] = src[candScoreI[i]+j];\n      f0cand[c++] = src[f0candI[i]+j];\n      //printf(\"f0candI[%i] %i\\n\",i,f0candI[i]);\n    }\n  }\n  \n  // median filter:\n  if (medianFilter0 > 0) {\n    smileUtil_temporalMedianFilterWslave(f0cand, c /*totalCands*/, 2, median0WorkspaceF0cand);\n  }\n  \n  if (octaveCorrection) {\n    // **ocatve correction**:\n    // best candidate is always the 0th (see pitchBase), all other candidates are in arbitrary order\n    // thus the smoothing here tries to validate the best candidate\n    // a) if another candidate (which is lower in f is found, we consider to use it)\n    // b) if the other candidates are multiples of half the 0th candidate, we consider to use half the 0th candidate\n    // c) we do global optimisation via median filtering (1st step actually)\n    // d) we do global optimisation via octave jump costs and evaluating a) and b) at octave jumps + voicing probs\n    int cand0ismin = 1;\n    FLOAT_DMEM vpMin = 0.0;\n    int minC = -1;\n    for (i=1; i<c; i++) {\n      if ((f0cand[i] > 0.0)&&(f0cand[i] < f0cand[0])) { // a)\n        if ((candVoice[i] > 0.9*candVoice[0])&&(candVoice[i] > vpMin)) {\n          vpMin = candVoice[i]; minC = i;\n        }\n        cand0ismin = 0;\n      } \n    }\n    if (!cand0ismin) {\n      if (minC >= 0) { // use the alternate, lower frequency candidate...\n        FLOAT_DMEM t = f0cand[0];\n        f0cand[0] = f0cand[minC];\n        f0cand[minC] = t;\n        t = candVoice[0];\n        candVoice[0] = candVoice[minC];\n        candVoice[minC] = t;\n        t = candScore[0];\n        candScore[0] = candScore[minC];\n        candScore[minC] = t;\n      } \n    } else {\n      //if (cand0ismin) { // check for b)\n      int halfed = 0; j=0;\n      while ((!halfed) && j<c-1) {\n        for (i=j+1; i<c; i++) {\n          if ((f0cand[i] > 0.0)&&(f0cand[j] > 0.0)) {\n            FLOAT_DMEM k = fabs(f0cand[i]-f0cand[j])*(FLOAT_DMEM)2.0/f0cand[0];\n            k = (FLOAT_DMEM)fabs(k-1.0);\n            if (k<0.1) { // b)\n              f0cand[0] /= (FLOAT_DMEM)2.0;\n              halfed = 1;\n              break;\n            } \n          }\n        }\n        j++;\n      }\n    //} else {\n    }\n  }\n\n\n  if (no0f0 && (candVoice[0] <= voicingCutoff[0])) {\n    // experimental: no output for 0 pitch.. (unvoiced..)\n    return 0;\n  }\n\n  /* output */\n  FLOAT_DMEM voiceC1 = candVoice[0];\n  if (F0final||F0finalEnv) {\n    FLOAT_DMEM pitch, pitchOut;\n    if (candVoice[0] > voicingCutoff[0]) {\n      pitch = f0cand[0]; \n    } else {\n      pitch = 0.0;\n    }\n\n    // post smoothing:\n    if (postSmoothing) {\n      if (postSmoothingMethod == POSTSMOOTHING_SIMPLE) {\n        if (firstFrame) { firstFrame = 0; return 0; } // for proper synchronisation\n        voiceC1 = lastVoice; lastVoice = candVoice[0];\n\n        // simple pitch contour smoothing (delay: 1 frame):\n\n        if ((lastFinal[0] == 0.0)&&(pitch>0.0)) onsFlag = 1;\n        if ((lastFinal[0] > 0.0)&&(pitch==0.0)&&(onsFlag==0)) onsFlag = -1;\n        if ((lastFinal[0] > 0.0)&&(pitch>0.0)) onsFlag = 0;\n        if ((lastFinal[0] == 0.0)&&(pitch==0.0)) onsFlag = 0;\n\n        if ((pitch==0.0)&&(onsFlag==1)) { lastFinal[0] = 0.0; }\n        else if ((pitch>0.0)&&(onsFlag==-1)) { lastFinal[0] = pitch; }\n        \n        \n        int doubling = 0; int halfing = 0;\n        if ((lastFinal[0]>0.0)&&(pitch>0.0)) {\n          FLOAT_DMEM factor = lastFinal[0]/pitch;\n          if (factor > 1.2) halfing = 1; /* old: fabs(factor-2.0)<0.15 */\n          else if (factor < 0.8) doubling = 1; /* old : fabs(factor-0.5)<0.05 */\n        }\n\n        if ((doubling)&&(onsFlagO==-1)) { lastFinal[0] = pitch; }\n        else if ((halfing)&&(onsFlagO==1)) { lastFinal[0] = pitch; }\n\n        if (doubling) onsFlagO = 1;\n        if (halfing && (onsFlag==0)) onsFlagO = -1;\n        if (!(halfing||doubling)) onsFlagO = 0;\n        \n\n\n\n        pitchOut = lastFinal[0]; // dst[n]\n        // shift last final...\n        for (i=postSmoothing-1; i>0; i--) {\n          lastFinal[i] = lastFinal[i-1];\n        }\n        lastFinal[0] = pitch;\n        \n      } else if (postSmoothingMethod == POSTSMOOTHING_MEDIAN) {\n        //if (firstFrame) { firstFrame = 0; return 0; }  // for proper synchronisation\n\n        // shift last final...\n        for (i=postSmoothing-1; i>0; i--) {\n          lastFinal[i] = lastFinal[i-1];\n        }\n        lastFinal[0] = pitch;\n        pitchOut /*dst[n]*/ = smileMath_median( lastFinal, postSmoothing, NULL );\n        \n\n      } else { // no smoothing...\n        pitchOut/*dst[n]*/ = pitch;\n      }\n    } else { // no smoothing...\n      pitchOut/*dst[n]*/ = pitch;\n    }\n    if (pitchOut > 0.0) lastFinalF0 = pitchOut;\n    if (F0final) {\n      dst[n++] = pitchOut;\n    }\n    if (F0finalEnv) {\n      //dst[n++] = lastFinalF0;\n      if (pitchOut > 0.0) {\n        if (pitchEnv == 0.0) pitchEnv = pitchOut;\n        else pitchEnv = (FLOAT_DMEM)0.75*pitchEnv + (FLOAT_DMEM)0.25*pitchOut;\n      }\n      dst[n++] = pitchEnv;\n    }\n  }\n\n  if (voicingFinalClipped) {\n    if (voiceC1 > voicingCutoff[0]) {\n      dst[n] = voiceC1;\n    } else {\n      dst[n] = 0.0;\n    }\n    n++;\n  }\n  if (voicingFinalUnclipped) {\n    dst[n] = voiceC1;\n    n++;\n  }\n\n  // copy raw data from input (if enabled) ( TODO: choose best input level!)\n  if (voicingC1) { \n    dst[n] = src[voicingC1I[0]]; n++;\n  }\n  if (F0raw) { \n    //printf(\"F0rawI[0] %i\\n\",F0rawI[0]);\n    dst[n] = src[F0rawI[0]]; n++; \n  }\n  if (voicingClip) { \n    dst[n] = src[voicingClipI[0]]; n++;\n  }\n\n\n  return n;\n}\n\ncPitchSmoother::~cPitchSmoother()\n{\n  if (voicingCutoff != NULL) free(voicingCutoff);\n  if (nCandidates != NULL) free(nCandidates);\n  if (nCands != NULL) free(nCands);\n  if (f0cand != NULL) free(f0cand);\n  //if (candVoice != NULL) free(candVoice);\n  //if (candScore != NULL) free(candScore);\n  if (f0candI != NULL) free(f0candI);\n  if (candVoiceI != NULL) free(candVoiceI);\n  if (candScoreI != NULL) free(candScoreI);\n  if (F0rawI != NULL) free(F0rawI);\n  if (voicingClipI != NULL) free(voicingClipI);\n  if (voicingC1I != NULL) free(voicingC1I);\n  if (median0WorkspaceF0cand != NULL) smileUtil_temporalMedianFilterFree(median0WorkspaceF0cand);\n  if (lastFinal != NULL) free(lastFinal);\n}\n\n"
  },
  {
    "path": "src/lldcore/plp.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: cPlp\n\nThis component computes PLP and RASTA-PLP cepstral coefficients from a critical band spectrum (generated by the cMelspec component, for example).\n\nThe component is capable of performing the following processing steps:\n   1) Take the natural logarithm of the critical band powers (doLog)\n   2) RASTA filtering\n   3) Computation of auditory spectrum (equal loudness curve and loudness compression)\n   4) Inverse of the natural logarithm\n   5) Inverse DFT to obtain autocorrelation coefficients\n   6) Linear prediction analysis on autocorr. coeff.\n   7) Computation of cepstral coefficients from lp coefficients\n   8) Cepstral 'liftering'\n\n */\n\n\n#include <lldcore/plp.hpp>\n\n#define MODULE \"cPlp\"\n\n\nSMILECOMPONENT_STATICS(cPlp)\n\nSMILECOMPONENT_REGCOMP(cPlp)\n{\n\tSMILECOMPONENT_REGCOMP_INIT\n\tscname = COMPONENT_NAME_CPLP;\n\tsdescription = COMPONENT_DESCRIPTION_CPLP;\n\n\t// we inherit cVectorProcessor configType and extend it:\n\tSMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n\n\tSMILECOMPONENT_IFNOTREGAGAIN(\n\t\t\t//ct->setField(\"nameAppend\", NULL, \");\n\n\t\t\tct->setField(\"lpOrder\",\"The order of the linear predictor (5th order is optimal according to Hermansky 1990, JASA)\",5);\n\tct->setField(\"nCeps\",\"The number of cepstral coefficients (must be <= lpOrder, set to -1 for max. (=lpOrder))\",-1);\n\tct->setField(\"firstCC\",\"The first cepstral coefficient to compute (set to 0 to include the 0th coefficient, which is defined as -log(1/lpcGain) )\",1);\n\tct->setField(\"lastCC\",\"The last cepstral coefficient to compute (set to -1 to use nCeps, else lastCC will override nCeps!)\",-1);\n\n\tct->setField(\"doLog\",\"Take the log of input bands (1=yes / 0=no)\",1);\n\tct->setField(\"doAud\",\"Do auditory processing (equal loudness curve and loudness compression) (1=yes / 0=no)\",1);\n\n\tct->setField(\"RASTA\",\"Perform RASTA (temporal) filtering (1=yes / 0=no)\",0);\n\tct->setField(\"newRASTA\",\"Perform RASTA (temporal) filtering (more stable filter, Type-II, initial filtering only with FIR part; thanks to Chris Landsiedl for this code!) (1=enable / 0=disable) Note: this option (if set to 1) will disable the 'RASTA' option.\",0);\n\tct->setField(\"rastaUpperCutoff\",\"Upper cut-off frequency of RASTA bandpass filter in Hz\",29.0);\n\tct->setField(\"rastaLowerCutoff\",\"Lower cut-off frequency of RASTA bandpass filter in Hz\",1.0);\n\n\tct->setField(\"doInvLog\",\"Apply inverse logarithm after power compression (1=yes / 0=no)\",1);\n\tct->setField(\"doIDFT\",\"Apply I(nverse)DFT after power compression and inverse log (1=yes / 0=no)\",1);\n\tct->setField(\"doLP\",\"Do lp analysis on autocorrelation function (1=yes / 0=no)\",1);\n\tct->setField(\"doLpToCeps\",\"Convert lp coefficients to cepstral coefficients (1=yes / 0=no)\",1);\n\n\tct->setField(\"cepLifter\",\"Parameter for cepstral 'liftering', set to 0.0 to disable cepstral liftering\",0);\n\tct->setField(\"compression\",\"Compression factor for 'power law of hearing'\",0.33);\n\n\tct->setField(\"melfloor\",\"Minimum value of melspectra when computing mfcc (will be forced to 1.0 when htkcompatible=1)\",0.00000000093);\n\tct->setField(\"htkcompatible\",\"Set correct mel-floor and force HTK compatible PLP output (1/0 = yes/no)\\n  htkcompatible == 1, forces the following settings:\\n  - melfloor = 1.0 (signal scaling 0..32767*32767)\\n  - append 0th coeff instead of having it as first value\\n  - doAud = 1 , doLog=0 , doInvLog=0   (doIDFT, doLP, and doLpToCeps are not forced to 1, this enables generation of HTK compatible auditory spectra, etc. (these, of course, are not compatible, i.e. are not the same as HTK's PLP))\\n  - the 0th audspec component is used as dc component in IDFT (else the DC component is zero)\",1);\n\t)\n\n\tSMILECOMPONENT_MAKEINFO(cPlp);\n}\n\nSMILECOMPONENT_CREATE(cPlp)\n\n//-----\n\ncPlp::cPlp(const char *_name) :\ncVectorProcessor(_name),\ncostable(NULL),\nsintable(NULL),\neqlCurve(NULL),\nacf(NULL), lpc(NULL), ceps(NULL),\nhtkcompatible(0),\nrasta_buf_fir(NULL),\nrasta_buf_iir(NULL)\n{\n\n}\n\nvoid cPlp::fetchConfig()\n{\n\tcVectorProcessor::fetchConfig();\n\n\tdoLog = getInt(\"doLog\");\n\tdoAud = getInt(\"doAud\");\n\tRASTA = getInt(\"RASTA\");\n\tnewRASTA = getInt(\"newRASTA\");\n\tdoInvLog = getInt(\"doInvLog\");\n\tdoIDFT = getInt(\"doIDFT\");\n\tdoLP = getInt(\"doLP\");\n\tdoLpToCeps = getInt(\"doLpToCeps\");\n\n\tlpOrder = getInt(\"lpOrder\");\n\tif (lpOrder <= 0) {\n\t\tlpOrder = 0;\n\t\tdoLP = 0; doLpToCeps = 0;\n\t}\n\tnCeps = getInt(\"nCeps\");\n\n\tfirstCC = getInt(\"firstCC\");\n\tlastCC = getInt(\"lastCC\");\n\tif (firstCC > lpOrder)  { firstCC = lpOrder; nCeps = 1; lastCC = lpOrder; }\n\telse if (firstCC < 0) firstCC = 0;\n\n\tif (nCeps < 0) {\n\t\tnCeps = lpOrder-firstCC+1; // Note: (+1) because the 0th coefficient is extra\n\t}\n\n\tif (lastCC < 0) { lastCC = firstCC+nCeps-1; }\n\telse if (lastCC >= firstCC) {\n\t\tnCeps = lastCC-firstCC+1;\n\t}\n\tif (lastCC > lpOrder) {\n\t\tSMILE_IWRN(1,\"number of last cepstral coefficient (%i) cannot be higher than lpOrder (%i)! (firstCC=%i, nCeps=%i)\",lastCC,lpOrder,firstCC,nCeps);\n\t\tlastCC=lpOrder;\n\t\tnCeps = lastCC-firstCC+1;\n\t}\n\tSMILE_IDBG(2,\"firstCC = %i\",firstCC);\n\tSMILE_IDBG(2,\"lastCC = %i\",lastCC);\n\tSMILE_IDBG(2,\"nCeps = %i\",nCeps);\n\n\tif (nCeps == 0) { doLpToCeps = 0; }\n\n\tif (doLpToCeps) {\n\t\tdoLP = 1;\n\t}\n\tif (doLP) {\n\t\tdoIDFT = 1;\n\t}\n\n\n\tcompression = (FLOAT_DMEM)getDouble(\"compression\");\n\tif (compression < 0.0) compression = 0.0;\n\tSMILE_IDBG(2,\"compression = %f\",compression);\n\n\tcepLifter = (FLOAT_DMEM)getInt(\"cepLifter\");\n\tif (cepLifter < 0) cepLifter = 0;\n\tSMILE_IDBG(2,\"cepLifter = %f\",cepLifter);\n\n\tmelfloor = (FLOAT_DMEM)getDouble(\"melfloor\");\n\tSMILE_IDBG(2,\"melfloor = %f\",melfloor);\n\n\thtkcompatible = getInt(\"htkcompatible\");\n\tif (htkcompatible) {\n\t\t// htkcompatible == 1, forces the following settings:\n\t\t// - melfloor = 1.0 (signal scaling 0..32767*32767)\n\t\t// - append 0th coeff instead of having it as first value\n\t\t// - doAud = 1 , doLog=0 , doInvLog=0   (doIDFT, doLP, and doLpToCeps are not forced to 1, this enables generation of HTK compatible auditory spectra, etc. (these, of course, are not compatible, i.e. are not the same as HTK's PLP))\n\t\t// - use 0th audspec component as dc component in IDFT (else DC is zero)\n\t\tSMILE_IDBG(2,\"HTK compatible output is enabled\");\n\t\tmelfloor = 1.0;\n\t\tdoAud = 1; doLog = 0; doInvLog=0;\n\t}\n\n\tif (doLog != doInvLog) {\n\t\tSMILE_IWRN(1,\"doLog (%i) != doInvLog (%i) , this makes no sense any may corrupt your features, are you sure you know what you are doing?\",doLog,doInvLog);\n\t}\n\n\tif (RASTA || newRASTA) {\n\t\tdoLog = 1; doInvLog = 1;\n\t\trastaUpperCutoff = (FLOAT_DMEM)getDouble(\"rastaUpperCutoff\");\n\t\tSMILE_IDBG(2,\"rastaUpperCutoff = %f\",rastaUpperCutoff);\n\t\trastaLowerCutoff = (FLOAT_DMEM)getDouble(\"rastaLowerCutoff\");\n\t\tSMILE_IDBG(2,\"rastaUpperCutoff = %f\",rastaUpperCutoff);\n\t}\n\tif (newRASTA) {RASTA = 0;}\n}\n\n/*\nint cPlp::myConfigureInstance()\n{\n  int ret=1;\n  ret *= cVectorProcessor::myConfigureInstance();\n  if (ret == 0) return 0;\n\n\n  return ret;\n}\n */\n\nint cPlp::dataProcessorCustomFinalise()\n{\n\t//  Nfi = reader->getLevelNf();\n\n\t// allocate for multiple configurations..\n\tif (sintable == NULL) sintable = (FLOAT_DMEM**)multiConfAlloc();\n\tif (costable == NULL) costable = (FLOAT_DMEM**)multiConfAlloc();\n\tif (eqlCurve == NULL) eqlCurve = (FLOAT_DMEM**)multiConfAlloc();\n\tif (acf == NULL) acf = (FLOAT_DMEM**)multiConfAlloc();\n\tif (lpc == NULL) lpc = (FLOAT_DMEM**)multiConfAlloc();\n\tif (ceps == NULL) ceps = (FLOAT_DMEM**)multiConfAlloc();\n\tif (rasta_buf_fir == NULL) rasta_buf_fir = (FLOAT_DMEM**)multiConfAlloc();\n\tif (rasta_buf_iir == NULL) rasta_buf_iir = (FLOAT_DMEM**)multiConfAlloc();\n\n\treturn cVectorProcessor::dataProcessorCustomFinalise();\n}\n\n/*\nint cPlp::configureWriter(const sDmLevelConfig *c)\n{\n  if (c==NULL) return 0;\n\n  // you must return 1, in order to indicate configure success (0 indicated failure)\n  return 1;\n}\n */\n\nint cPlp::setupNamesForField(int i, const char*name, long nEl)\n{\n\t// compute sin/cos tables and equal loudness weighting curve:\n\tinitTables(nEl,getFconf(i),i);\n\n\t/*name=\"pspec\";\n  if ((nameAppend != NULL)&&(strlen(nameAppend)>0)) {\n    addNameAppendField(name,nameAppend,nMfcc,firstMfcc);\n  } else {\n    writer->addField( name, nMfcc, firstMfcc);\n  }\n  return nMfcc;*/\n\n\t//same names as input fields  (maybe change the \"nameAppend\" depending on doIDFT flag...?)\n\tconst char *_name=NULL;\n\n\tint dt = 0;\n\tvoid *_info = NULL;\n\tint _infoSize = 0;\n\tif (doLpToCeps) {\n\t\tif (RASTA || newRASTA) {\n\t\t\t_name = \"RASTAPlpCC\";\n\t\t} else {\n\t\t\t_name = \"PlpCC\";\n\t\t}\n\t\tdt = DATATYPE_CEPSTRAL;\n\t\tnEl = nCeps;\n\t} else if (doLP) {\n\t\tif (RASTA) {\n\t\t\t_name = \"RASTAPlpc\";\n\t\t} else if (newRASTA) {\n\t\t\t_name = \"newRASTAPlpc\";\n\t\t} else {\n\t\t\t_name = \"Plpc\";\n\t\t}\n\t\tdt = DATATYPE_COEFFICIENTS;\n\t\tnEl = lpOrder;\n\t} else if (doIDFT) {\n\t\t_name = \"audAutoCor\";\n\t\tdt = DATATYPE_ACF;\n\t\tnEl = nAuto;\n\t} else {\n\t\t_name = \"audSpec\";\n\t\tdt = DATATYPE_SPECTRUM_BANDS_MAG;\n\t\tconst FrameMetaInfo * fmeta = reader_->getFrameMetaInfo();\n\t\tif ((fmeta != NULL) && (i<fmeta->N)) {\n\t\t\t_info = fmeta->field[i].info;\n\t\t\t_infoSize = fmeta->field[i].infoSize;\n\t\t}\n\t}\n// TODO: check why this is not setting the field info correctly!\n\twriter_->setFieldInfo(i,dt,_info,_infoSize);\n\n\treturn cVectorProcessor::setupNamesForField(i,_name,nEl);\n}\n\n\n// blocksize is size of mspec block (=nBands)\nint cPlp::initTables( long blocksize, int idxc, int fidx )\n{\n\tint i,m;\n\tFLOAT_DMEM *_costable = costable[idxc];\n\tFLOAT_DMEM *_sintable = sintable[idxc];\n\tFLOAT_DMEM *_eqlCurve = eqlCurve[idxc];\n\tFLOAT_DMEM *_acf = acf[idxc];\n\tFLOAT_DMEM *_lpc = lpc[idxc];\n\tFLOAT_DMEM *_ceps = ceps[idxc];\n\tFLOAT_DMEM *_rasta_buf_fir = rasta_buf_fir[idxc];\n\tFLOAT_DMEM *_rasta_buf_iir = rasta_buf_iir[idxc];\n\n\tnFreq = blocksize+2; // +DC + Nyquist...?\n\tif (doIDFT) {\n\t\tnAuto = lpOrder + 1;\n\t\tif (_costable != NULL) free(_costable);\n\t\t_costable = (FLOAT_DMEM *)malloc(sizeof(FLOAT_DMEM)*nAuto*nFreq);\n\t\tif (_costable == NULL) OUT_OF_MEMORY;\n\n\t\t// memory for acf:\n\t\t_acf = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*nAuto);\n\t\t// IDFT costable:\n\t\tFLOAT_DMEM a = (FLOAT_DMEM) M_PI / (FLOAT_DMEM)(nFreq-1);\n\t\tfor (i=0; i<nAuto; i++) {\n\t\t\tint ib = i*nFreq;\n\t\t\t_costable[ib] = 1.0;\n\t\t\tfor (m=1; m<(nFreq-1); m++) {\n\t\t\t\t_costable[m+ib] = (FLOAT_DMEM)( 2.0 * cos(a * (double)i * (double)m ) );\n\t\t\t}\n\t\t\t_costable[m+ib] = (FLOAT_DMEM)( cos(a * (double)i * (double)m ) );\n\t\t}\n\t}\n\n\t// memory for lp coefficients\n\tif (doLP) {\n\t\t_lpc = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*lpOrder);\n\t}\n\n\t// sintable for cepstral liftering\n\tif (doLpToCeps) {\n\t\tif (_sintable != NULL) free(_sintable);\n\t\t_sintable = (FLOAT_DMEM *)malloc(sizeof(FLOAT_DMEM)*nCeps);\n\t\tif (_sintable == NULL) OUT_OF_MEMORY;\n\n\t\tif (cepLifter > 0.0) {\n\t\t\tfor (i=firstCC; i <= lastCC; i++) {\n\t\t\t\t_sintable[i-firstCC] = ((FLOAT_DMEM)1.0 + cepLifter/(FLOAT_DMEM)2.0 * sin((FLOAT_DMEM)M_PI*((FLOAT_DMEM)(i))/cepLifter));\n\t\t\t}\n\t\t} else {\n\t\t\tfor (i=firstCC; i <= lastCC; i++) {\n\t\t\t\t_sintable[i-firstCC] = 1.0;\n\t\t\t}\n\t\t}\n\t\t_ceps = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*nCeps);\n\t}\n\n\t// equal loudness curve:\n\tif (doAud) {\n\t\tconst FrameMetaInfo * fmeta = reader_->getFrameMetaInfo();\n\t\tif ((fmeta != NULL)&&(fidx < fmeta->N)) {\n\t\t\tconst double * frq = (double *)(fmeta->field[fidx].info);\n\t\t\tnScale = fmeta->field[fidx].infoSize / sizeof(double);\n\t\t\tif (nScale != blocksize) {\n\t\t\t\tSMILE_IWRN(2,\"number of frequency axis points (from info struct) [%i] is not equal to blocksize [%i] ! Field index: %i (check the processArrayFields option).\",nScale,blocksize,fidx);\n\t\t\t\tnScale = MIN(nScale,blocksize);\n\t\t\t}\n\n\t\t\t_eqlCurve = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*nScale);\n\t\t\tint i;\n\t\t\tfor (i=0; i<nScale; i++) {\n\t\t\t\tif (htkcompatible) {\n\t\t\t\t\t_eqlCurve[i] = (FLOAT_DMEM)smileDsp_equalLoudnessWeight_htk((double)frq[i]);\n\t\t\t\t} else {\n\t\t\t\t\t_eqlCurve[i] = (FLOAT_DMEM)smileDsp_equalLoudnessWeight((double)frq[i]);\n\t\t\t\t}\n\t\t\t\tif (doLog) {\n\t\t\t\t\t_eqlCurve[i] = log(_eqlCurve[i]);\n\t\t\t\t\tSMILE_IDBG(2,\"log-eqlCurve (f=%f) = %f\",frq[i],_eqlCurve[i]);\n\t\t\t\t} else {\n\t\t\t\t\tSMILE_IDBG(2,\"lin-eqlCurve (f=%f) = %f\",frq[i],_eqlCurve[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// rasta filter\n\tif (RASTA) {\n\t\t// IIR part\n\t\trasta_iir = (FLOAT_DMEM)( 1.0 - sin(2.0 * M_PI * rastaLowerCutoff * reader_->getLevelT() ) );\n\n\t\t// FIR part:\n\t\tFLOAT_DMEM om = (FLOAT_DMEM)cos( 2.0 * M_PI * rastaUpperCutoff * reader_->getLevelT() );\n\t\tFLOAT_DMEM norm = (FLOAT_DMEM)sqrt( 10.0 * ( 32.0*om*om + 8.0) );\n\t\trasta_fir[0] = (FLOAT_DMEM)( 2.0 / norm );\n\t\trasta_fir[1] = (FLOAT_DMEM)( -4.0 * om / norm );\n\t\trasta_fir[2] = 0.0;\n\t\trasta_fir[3] = -rasta_fir[1];\n\t\trasta_fir[4] = -rasta_fir[0];\n\n\t\t_rasta_buf_iir = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*blocksize);\n\t\t_rasta_buf_fir = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*blocksize*5);\n\t\trasta_buf_fir_ptr = 0;\n\t\trasta_init = 0;\n\t}\n\tif (newRASTA) {\n\t\t// IIR part\n\t\trasta_iir = (FLOAT_DMEM)( 1.0 - sin(2.0 * M_PI * rastaLowerCutoff * reader_->getLevelT() ) );\n\n\t\t// FIR part:\n\t\tFLOAT_DMEM om = (FLOAT_DMEM)cos( 2.0 * M_PI * rastaUpperCutoff * reader_->getLevelT() );\n\t\tFLOAT_DMEM norm = (FLOAT_DMEM)sqrt( 10.0 * ( 32.0*om*om + 8.0) );\n\t\trasta_fir[0] = (FLOAT_DMEM)( 2.0 / norm );\n\t\trasta_fir[1] = (FLOAT_DMEM)( -4.0 * om / norm );\n\t\trasta_fir[2] = 0.0;\n\t\trasta_fir[3] = -rasta_fir[1];\n\t\trasta_fir[4] = -rasta_fir[0];\n\n\t\t//      _rasta_buf_iir = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*blocksize);\n\t\t_rasta_buf_fir = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*blocksize*4);\n\t\t//      rasta_buf_fir_ptr = 0;\n\t\trasta_init = 0;\n\t}\n\n\tacf[idxc] = _acf;\n\tlpc[idxc] = _lpc;\n\tceps[idxc] = _ceps;\n\n\tcostable[idxc] = _costable;\n\teqlCurve[idxc] = _eqlCurve;\n\tsintable[idxc] = _sintable;\n\n\trasta_buf_fir[idxc] = _rasta_buf_fir;\n\trasta_buf_iir[idxc] = _rasta_buf_iir;\n\n\treturn 1;\n}\n\n\n\n// a derived class should override this method, in order to implement the actual processing\nint cPlp::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n\tint i,m;\n\tidxi = getFconf(idxi);\n\tFLOAT_DMEM *_costable = costable[idxi];\n\tFLOAT_DMEM *_sintable = sintable[idxi];\n\tFLOAT_DMEM *_eqlCurve = eqlCurve[idxi];\n\tFLOAT_DMEM *_acf = acf[idxi];\n\tFLOAT_DMEM *_lpc = lpc[idxi];\n\tFLOAT_DMEM *_ceps = ceps[idxi];\n\tFLOAT_DMEM *_rasta_buf_fir = rasta_buf_fir[idxi];\n\tFLOAT_DMEM *_rasta_buf_iir = rasta_buf_iir[idxi];\n\n\tFLOAT_DMEM *_src;\n\t_src = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*Nsrc);\n\tif (_src==NULL) OUT_OF_MEMORY;\n\n\t// compute log spectrum\n\tif (doLog) {\n\t\tfor (i=0; i<Nsrc; i++) {\n\t\t\tif (src[i] < melfloor) _src[i] = log(melfloor);\n\t\t\telse _src[i] = (FLOAT_DMEM)log(src[i]);\n\t\t\t//if (!htkcompatible) _src[i] += 21;\n\t\t}\n\t} else {\n\t\tfor (i=0; i<Nsrc; i++) {\n\t\t\t_src[i] = src[i];\n\t\t}\n\t}\n\n\t// rasta filtering\n\tif (RASTA) {\n\t\tfor (i=0; i<Nsrc; i++) {\n\t\t\tFLOAT_DMEM sum;\n\t\t\t_rasta_buf_fir[i*5+rasta_buf_fir_ptr] = _src[i];\n\t\t\tsum = rasta_fir[0] * _src[i];\n\t\t\t// fir filter\n\t\t\tfor (m=1; m<5; m++) {\n\t\t\t\tsum += rasta_fir[m] * _rasta_buf_fir[i*5+((5-m+rasta_buf_fir_ptr)%5)];\n\t\t\t}\n\t\t\t// iir filter\n\t\t\tsum += rasta_iir * _rasta_buf_iir[i];\n\t\t\t//printf(\"rasta_iir = %f\\n\",rasta_iir);\n\t\t\t//if (i==2) printf(\"sum (%i)(%i): %f (%f) [%f , %f]\\n\",rasta_init,i,sum,_src[i],rasta_iir,rasta_buf_iir[i]);\n\t\t\t_rasta_buf_iir[i] = sum;\n\t\t\t// save output\n\n\t\t\tif (rasta_init>=5) { _src[i] = sum; }\n\t\t\telse {_src[i] = 0; }\n\t\t}\n\t\tif (rasta_init<5) {  rasta_init++; }\n\t\trasta_buf_fir_ptr = (rasta_buf_fir_ptr+1)%5;\n\t}\n\tif (newRASTA) {\n\t\tfor (i=0; i<Nsrc; i++) {\n\t\t\tFLOAT_DMEM out;\n\t\t\tout = rasta_fir[0] * _src[i] + _rasta_buf_fir[i*4 + 0];\n\t\t\t_rasta_buf_fir[i*4 + 0] = rasta_fir[1] * _src[i] + _rasta_buf_fir[i*4 + 1] + (rasta_init>=5) * rasta_iir * out;\n\t\t\t_rasta_buf_fir[i*4 + 1] = rasta_fir[2] * _src[i] + _rasta_buf_fir[i*4 + 2];\n\t\t\t_rasta_buf_fir[i*4 + 2] = rasta_fir[3] * _src[i] + _rasta_buf_fir[i*4 + 3];\n\t\t\t_rasta_buf_fir[i*4 + 3] = rasta_fir[4] * _src[i];\n\n\t\t\t//if (i==2) printf(\"sum (%i)(%i): %f (%f) [%f]\\n\",rasta_init,i,out,_src[i],rasta_iir);\n\n\t\t\tif (rasta_init>=5) { _src[i] = out; }\n\t\t\telse {_src[i] = 0; }\n\t\t}\n\t\tif (rasta_init<5) {  rasta_init++; }\n//\t\trasta_buf_fir_ptr = (rasta_buf_fir_ptr+1)%5;\n\t}\n\n\n\t// Auditory pre-emphasis and loudness compression\n\tif (doAud) {\n\t\tif (doLog) {\n\t\t\t// add (log) equal loudness curve  // TODO: check Nsrc == eqlCurve size -> i.e. nScale <= Nsrc!\n\t\t\tfor (i=0; i<nScale; i++) {\n\t\t\t\t_src[i] += _eqlCurve[i];\n\t\t\t}\n\t\t\t// power law of hearing, loudness compression in log-domain is multiplication with compression factor:\n\t\t\tfor (i=0; i<Nsrc; i++) {\n\t\t\t\t_src[i] *= compression;\n\t\t\t}\n\t\t} else {\n\t\t\t// multiply with equal loudness curve  // TODO: check Nsrc == eqlCurve size -> i.e. nScale <= Nsrc!\n\t\t\tfor (i=0; i<nScale; i++) {\n\t\t\t\tif (_src[i] < melfloor) _src[i] = melfloor;\n\t\t\t\t_src[i] *= _eqlCurve[i];\n\t\t\t}\n\t\t\t// power law of hearing, loudness compression in linear domain:\n\t\t\tfor (i=0; i<Nsrc; i++) {\n\t\t\t\t_src[i] = (FLOAT_DMEM)pow((double)_src[i] , (double)compression);\n\t\t\t}\n\t\t}\n\t}\n\n\t// inverse log\n\tif (doInvLog) {\n\t\tfor (i=0; i<Nsrc; i++) {\n\t\t\t//if (!htkcompatible) _src[i] -= 21;\n\t\t\t_src[i] = exp(_src[i]);\n\t\t}\n\t}\n\n\t// inverse DFT -> autocorrelation (since input spectra are power spectra)\n\t// Note: for inverse DFT we require a DC and a Nyquist component, we thus duplicate the first and last component\n\tif (doIDFT) {  // TODO: check nAuto<=nDst!\n\t\tfor (i=0; i<nAuto; i++) {\n\t\t\tdouble tmp = 0;\n\t\t\tif (htkcompatible) { tmp = (double)_costable[i*nFreq] * (double)_src[0]; }\n\n\t\t\tfor (m=1; m<nFreq-1; m++) {\n\t\t\t\ttmp += (double)_costable[m+i*nFreq] * (double)_src[m-1];\n\t\t\t}\n\t\t\ttmp += (double)_costable[m+i*nFreq] * (double)_src[nFreq-3];\n\t\t\t_acf[i] = (FLOAT_DMEM)(tmp / (2.0*(nFreq-1)));\n\t\t}\n\n\t\t// linear prediction analysis on ACF\n\t\tFLOAT_DMEM lpGain=0.0;\n\t\tif (doLP) {\n\t\t\tsmileDsp_calcLpcAcf(_acf, _lpc, lpOrder, &lpGain, NULL);\n\n\t\t\t// convert lp filter coefficients to cepstral representation\n\t\t\tif (doLpToCeps) {\n\t\t\t\tif (lpGain <= 0) {\n\t\t\t\t\tSMILE_IERR(1,\"negative or zero lpc gain! forcing lpcGain = 1.0!\");\n\t\t\t\t\tlpGain = (FLOAT_DMEM)1.0;\n\t\t\t\t}\n\n\t\t\t\t// lp to ceps\n\t\t\t\tFLOAT_DMEM *__ceps = _ceps;\n\t\t\t\tif (!htkcompatible && (firstCC==0)) __ceps++;\n\t\t\t\tFLOAT_DMEM zeroth = smileDsp_lpToCeps(_lpc,lpOrder,lpGain,__ceps,firstCC,lastCC);\n\t\t\t\tif (firstCC==0) {\n\t\t\t\t\tif (!htkcompatible) { _ceps[0] = zeroth; }\n\t\t\t\t\telse { _ceps[nCeps-1] = zeroth; }\n\t\t\t\t}\n\n\t\t\t\t// cepstral liftering:\n\t\t\t\tFLOAT_DMEM factor;\n\t\t\t\tif (cepLifter > 0.0) {\n\t\t\t\t\tfactor = (FLOAT_DMEM)sqrt((double)2.0/(double)(Nsrc));\n\t\t\t\t}\n\t\t\t\tfor (i=firstCC; i<=lastCC; i++) {\n\t\t\t\t\tint i0 = i-firstCC;\n\t\t\t\t\tint i1 = i0;\n\t\t\t\t\tif (htkcompatible && (firstCC==0)) {\n\t\t\t\t\t\tif (i==lastCC) { i1 = 0; }\n\t\t\t\t\t\telse { i1 += 1; }\n\t\t\t\t\t}\n\t\t\t\t\tif (cepLifter > 0.0) {\n\t\t\t\t\t\tdst[i0] = _ceps[i0] * _sintable[i1];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdst[i0] = _ceps[i0];// * _sintable[i1] * factor;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t} else { // save lp coeffs to dst[]\n\t\t\t\tfor (i=0; i<lpOrder; i++) {\n\t\t\t\t\tdst[i] = _lpc[i];\n\t\t\t\t}\n\t\t\t}\n\t\t} else { // save data in acf[] to dst[]\n\t\t\tfor (i=0; i<nAuto; i++) {\n\t\t\t\tdst[i] = _acf[i];\n\t\t\t}\n\t\t}\n\t} else { // no IDFT , save spectrum in _src[] to dst[]\n\t\tfor (i=0; i<Nsrc; i++) {\n\t\t\tdst[i] = _src[i];\n\t\t}\n\t}\n\n\tfree(_src);\n\n\treturn 1;\n}\n\ncPlp::~cPlp()\n{\n\tmultiConfFree(costable);\n\tmultiConfFree(sintable);\n\tmultiConfFree(eqlCurve);\n\tmultiConfFree(acf);\n\tmultiConfFree(lpc);\n\tmultiConfFree(ceps);\n\tmultiConfFree(rasta_buf_fir);\n\tmultiConfFree(rasta_buf_iir);\n}\n\n"
  },
  {
    "path": "src/lldcore/spectral.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\ncomputed spectral features such as flux, roll-off, centroid, etc.\n*/\n\n\n#include <lldcore/spectral.hpp>\n#include <math.h>\n\n#define MODULE \"cSpectral\"\n\n\nSMILECOMPONENT_STATICS(cSpectral)\n\nSMILECOMPONENT_REGCOMP(cSpectral)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CSPECTRAL;\n  sdescription = COMPONENT_DESCRIPTION_CSPECTRAL;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"squareInput\",\"1/0 = square input values (e.g. if input is magnitude and not power spectrum)\",1);\n    ct->setField(\"bands\",\"bands[n] = LoFrq[Hz]-HiFrq[Hz]  (e.g. 0-250), compute energy in this spectral band (only integer frequencies are allowed!)\",\"250-650\",ARRAY_TYPE);\n    ct->setField(\"normBandEnergies\",\"(1/0=yes/no) normalise the band energies to the total frame energy (-> relative band energies). Also affects 'harmonicity', normalises the average min to max variations in the spectrum by the total frame energy (sum of magnitudes or squares).\", 0);\n\n    ct->setField(\"rollOff\",\"rollOff[n] = X  (X in the range 0..1), compute X*100 percent spectral roll-off point\",0.90,ARRAY_TYPE);\n    ct->setField(\"specDiff\",\"(1/0=yes/no) enable computation of spectral difference (root-mean-square of absolute differences over all bins)\", 0);\n    ct->setField(\"specPosDiff\",\"(1/0=yes/no) enable computation of spectral positive difference (sum of squared positive differences normalised by number of bins and then sqrt taken)\", 0);\n    ct->setField(\"flux\",\"(1/0=yes/no) enable computation of spectral flux\",1);\n    ct->setField(\"fluxCentroid\",\"(1/0=yes/no) enable computation of spectral flux centroid (in Hz), i.e. the frequency with currently the most flux around it.\", 0);\n    ct->setField(\"fluxAtFluxCentroid\",\"(1/0=yes/no) enable computation of spectral flux only at and around (+- 2 bins) the centroid of flux (as computed by the 'fluxCentroid' option).\",0);\n    ct->setField(\"centroid\",\"(1/0=yes/no) enable computation of spectral centroid\",1);\n    ct->setField(\"maxPos\",\"(1/0=yes/no) enable computation of position of spectral maximum\",1);\n    ct->setField(\"minPos\",\"(1/0=yes/no) enable computation of position of spectral minimum\",1);\n    ct->setField(\"entropy\",\"(1/0=yes/no) enable computation of spectral entropy\",0);\n    ct->setField(\"standardDeviation\",\"(1/0=yes/no) enable computation of spectral standard deviation (root of variance)\", 0);\n    ct->setField(\"variance\",\"(1/0=yes/no) enable computation of spectral variance (mpeg7: spectral spread)\",0);\n    ct->setField(\"skewness\",\"(1/0=yes/no) enable computation of spectral skewness\",0);\n    ct->setField(\"kurtosis\",\"(1/0=yes/no) enable computation of spectral kurtosis\",0);\n    ct->setField(\"slope\",\"(1/0=yes/no) enable computation of spectral slope over maximal frequency range\",0);\n    ct->setField(\"slopes\",\"slopes[n] = LoFrq[Hz]-HiFrq[Hz] (e.g. 0-5000), computes spectral slope in the given band (only integer frequencies are allowed!)\", (const char*)NULL, ARRAY_TYPE);\n    ct->setField(\"alphaRatio\", \"(1/0=yes/no) enable computation of alpha ratio (ratio of energy above 1 kHz (up to 5 kHz) to energy below 1 kHz).\", 0);\n    ct->setField(\"hammarbergIndex\", \"(1/0=yes/no) enable computation of hammarberg index (ratio of energy peak (max) in 0-2 kHz region and energy peak (max) in 2-5 kHz region).\", 0);\n    ct->setField(\"sharpness\",\"(1/0=yes/no) enable computation of psychoacoustic parameter 'sharpness'. In order to obtain proper values, use a bark scale spectrum as input (see cSpecScale component).\",0);\n    ct->setField(\"tonality\",\"(1/0=yes/no) enable computation of consonance (ratio of consonance/dissonance, based on intervals between spectral peaks). (NOT YET IMPLEMENTED)\",0);\n    ct->setField(\"harmonicity\",\"(1/0=yes/no) enable computation of harmonicity (mean of consecutive local min-max differences). Optionally normalised by the total frame energy, if normBandEnergies is set to 1.\", 0);\n    ct->setField(\"flatness\",\"(1/0=yes/no) enable computation of spectral flatness (sfm = geometric_mean / arithmetic_mean of spectrum).\",0);\n    ct->setField(\"logFlatness\",\"(1/0=yes/no) if flatness is enabled, output ln(flatness).\", 0);\n\n    ct->setField(\"buggyRollOff\", \"(1/0=yes/no) for backwards feature set compatibility, enable buggy roll-off computation (pre May 2013, pre 2.0 release).\", 0);\n    ct->setField(\"oldSlopeScale\", \"(1/0=yes/no) for backwards feature set compatibility, enable (incorrectly) scaled spectral slope computation (pre July 2013, pre 2.0 final release). Enabled by default, to preserve compatibility with older feature sets. Disable in new designs!\", 1);\n    ct->setField(\"freqRange\", \"range of spectrum to consider for spectral parameter computation (syntax: lowerHz-upperHz, e.g. 0-8000; use 0-0 (default) for full range)\", \"0-0\");\n    ct->setField(\"useLogSpectrum\", \"(1/0=yes/no) Compute the following parameters (if enabled) from the log spectrum instead of the power spectrum: spectral slope(s), centroid, maxpos/minpos, entropy, moments, sharpness, harmonicity, flatness. Please note, that the band energies are computed from the power spectrum, but the output will be in dB (log) if this option is enabled (1). Spectral roll-off and flux will always be computed from the power spectrum (no log).\", 0);\n    ct->setField(\"specFloor\", \"When using the log Spectrum, the square(!) of this value is used as a floor value for the power spectrum.\", 0.0000001);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cSpectral);\n}\n\nSMILECOMPONENT_CREATE(cSpectral)\n\ncSpectral::cSpectral(const char *_name) :\n  cVectorProcessor(_name),\n  squareInput(1), nBands(0), nSlopes(0), nRollOff(0), entropy(0),\n  bandsL(NULL), bandsH(NULL), \n  slopesL(NULL), slopesH(NULL),\n  rollOff(NULL),\n  bandsLi(NULL), bandsHi(NULL),\n  wghtLi(NULL), wghtHi(NULL),\n  slopeBandsLi(NULL), slopeBandsHi(NULL),\n  slopeWghtLi(NULL), slopeWghtHi(NULL),\n  fsSec(-1.0), frq(NULL), frqScale(-1), frqScaleParam(0.0),\n  buggyRollOff(0), buggySlopeScale(0),\n  specRangeLower(0), specRangeUpper(0),\n  specRangeLowerBin(-1), specRangeUpperBin(-1),\n  specFloor((FLOAT_DMEM)(0.0000001 * 0.0000001)),\n  useLogSpectrum(0), logFlatness(0),\n  requireMagSpec(true), requireLogSpec(true), requirePowerSpec(true),\n  prevSpec(NULL), nSrcPrevSpec(NULL), nFieldsPrevSpec(0)\n{\n  logSpecFloor = (FLOAT_DMEM)(10.0 * log(specFloor) / log (10.0));\n}\n\nvoid cSpectral::parseRange(const char *text, long *lowerHz, long *upperHz)\n{\n  if (text == NULL || lowerHz == NULL || upperHz == NULL) {\n    return;\n  }\n  char *val = strdup(text);\n  char *orig = strdup(val);\n  int l = (int)strlen(val);\n  int err = 0;\n  char *s2 = strchr(val, '-');\n  if (s2 != NULL) {\n    *(s2++) = 0;\n    char *ep = NULL;\n    long r1 = strtol(val, &ep, 10);\n    if ((r1 == 0) && (ep == val)) {\n      err = 1;\n    } else if (r1 < 0) {\n      SMILE_IERR(1, \"lower frequency of frequency '%s'  is out of range (allowed: [0..+inf])\", orig);\n    }\n    ep = NULL;\n    long r2 = strtol(s2, &ep, 10);\n    if ((r2 == 0) && (ep == val)) {\n      err = 1;\n    } else {\n      if (r2 < 0) {\n        SMILE_IERR(1, \"upper frequency of frequency range in '%s'  is out of range (allowed: [0..+inf])\", orig);\n      }\n    }\n    if (!err) {\n      if (r1 <= r2) {\n        *lowerHz = r1;\n        *upperHz = r2;\n      } else {\n        *lowerHz = r2;\n        *upperHz = r1;\n      }\n    }\n  } else { err = 1; }\n\n  if (err==1) {\n    SMILE_IERR(1, \"Error parsing '%s'! (The frequency range must be X-Y, where X and Y are positive integer numbers specifiying frequency in Hertz!)\", orig);\n    *lowerHz = -1;\n    *upperHz = -1;\n  }\n  free(orig);\n  free(val);\n}\n\nint cSpectral::parseBandsConfig(const char * field, long ** bLow, long ** bHigh)\n{\n  int N = getArraySize(field);\n  if (N > 0) {\n    long * bL = (long *)calloc(1,sizeof(long)*N);\n    long * bH = (long *)calloc(1,sizeof(long)*N);\n    for (int i = 0; i < N; i++) {\n        const char *val = getStr_f(myvprint(\"%s[%i]\", field, i));\n        if (val == NULL) {\n          bL[i] = -1;\n          bH[i] = -1;\n          continue;\n        }\n        char *tmp = strdup(val);\n        char *orig = strdup(tmp);\n        int l = (int)strlen(tmp);\n        int err=0;\n        char *s2 = strchr(tmp,'-');\n        if (s2 != NULL) {\n          *(s2++) = 0;\n          char *ep=NULL;\n          long r1 = strtol(tmp,&ep,10);\n          if ((r1==0)&&(ep==tmp)) { \n            err=1; \n          } else if (r1 < 0) {\n            SMILE_ERR(1,\"(inst '%s', option '%s') low frequency of band %i in '%s'  is out of range (allowed: [0..+inf])\", getInstName(), field, i, orig);\n          }\n          ep=NULL;\n          long r2 = strtol(s2,&ep,10);\n          if ((r2 == 0) && (ep == tmp)) { \n            err = 1;\n          } else {\n            if (r2 < 0) {\n              SMILE_ERR(1,\"(inst '%s', option '%s') high frequency of band %i in '%s'  is out of range (allowed: [0..+inf])\", getInstName(), field, i, orig);\n            }\n          }\n          if (!err) {\n            if (r1 < r2) {\n              bL[i] = r1;\n              bH[i] = r2;\n            } else {\n              bL[i] = r2;\n              bH[i] = r1;\n            }\n          }\n        } else { err=1; }\n\n        if (err==1) {\n          SMILE_ERR(1, \"(inst '%s', option '%s') Error parsing %s[%i] = '%s'! (The band range must be X-Y, where X and Y are positive integer numbers specifiying frequency in Hertz!)\",\n                    getInstName(),field, field, i, orig);\n          bL[i] = -1;\n          bH[i] = -1;\n        }\n        free(orig);\n        free(tmp);\n    }\n    if (bLow != NULL) {\n      if (*bLow != NULL) free(bLow);\n      *bLow = bL;\n    }\n    if (bHigh != NULL) {\n      if (*bHigh != NULL) free(bHigh);\n      *bHigh = bH;\n    }\n  }\n  return N;\n}\n\nvoid cSpectral::setRequireLorPspec()\n{\n  if (useLogSpectrum) {\n    requireLogSpec = true;\n  } else {\n    requirePowerSpec = true;\n  }\n}\n\nvoid cSpectral::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n  \n  normBandEnergies = getInt(\"normBandEnergies\");\n\n  squareInput = getInt(\"squareInput\");\n  if (squareInput) { SMILE_IDBG(2,\"squaring of input values enabled\"); }\n\n  useLogSpectrum = getInt(\"useLogSpectrum\");\n  if (useLogSpectrum) {\n    specFloor = (FLOAT_DMEM)getDouble(\"specFloor\");\n    if (specFloor <= 0.0) {\n      SMILE_IWRN(1, \"specFloor must be > 0.0. Re-setting it to the default of 0.0000001\");\n    }\n    specFloor = specFloor * specFloor;\n    logSpecFloor = (FLOAT_DMEM)(10.0 * log(specFloor) / log (10.0));\n    SMILE_IMSG(2, \"logSpecFloor = %.2f  (specFloor = %e)\", logSpecFloor, specFloor);\n  }\n\n  specDiff = getInt(\"specDiff\");\n  if (specDiff) {\n    requireMagSpec = true;\n  }\n  specPosDiff = getInt(\"specPosDiff\");\n  if (specPosDiff) {\n    requireMagSpec = true;\n  }\n  flux = getInt(\"flux\");\n  if (flux) {\n    requireMagSpec = true;\n  }\n  fluxCentroid = getInt(\"fluxCentroid\");\n  if (flux) {\n    requireMagSpec = true;\n  }\n  fluxAtFluxCentroid = getInt(\"fluxAtFluxCentroid\");\n  if (flux) {\n    requireMagSpec = true;\n  }\n  /*\n  fluxAtSpecCentroid = getInt(\"fluxAtSpecCentroid\");\n  if (flux) {\n    requireMagSpec = true;\n  }\n  */\n  centroid = getInt(\"centroid\");\n  if (centroid) {\n    setRequireLorPspec();\n    SMILE_IDBG(2,\"spectral centroid computation enabled\");\n  }\n  maxPos = getInt(\"maxPos\");\n  if (maxPos) {\n    setRequireLorPspec();\n    SMILE_IDBG(2,\"spectral max. pos. computation enabled\");\n  }\n  minPos = getInt(\"minPos\");\n  if (minPos) {\n    setRequireLorPspec();\n    SMILE_IDBG(2,\"spectral min. pos. computation enabled\");\n  }\n\n  entropy = getInt(\"entropy\");\n  if (entropy) {\n    setRequireLorPspec();\n    SMILE_IDBG(2,\"spectral entropy computation enabled\");\n  }\n  standardDeviation = getInt(\"standardDeviation\");\n  if (standardDeviation) {\n    setRequireLorPspec();\n    SMILE_IDBG(2,\"spectral variance computation enabled\");\n  }\n  variance = getInt(\"variance\");\n  if (variance) {\n    setRequireLorPspec();\n    SMILE_IDBG(2,\"spectral variance computation enabled\");\n  }\n  skewness = getInt(\"skewness\");\n  if (skewness) {\n    setRequireLorPspec();\n    SMILE_IDBG(2,\"spectral skewness computation enabled\");\n  }\n  kurtosis = getInt(\"kurtosis\");\n  if (kurtosis) {\n    setRequireLorPspec();\n    SMILE_IDBG(2,\"spectral kurtosis computation enabled\");\n  }\n  slope = getInt(\"slope\");\n  if (slope) {\n    setRequireLorPspec();\n    SMILE_IDBG(2,\"spectral slope computation enabled\");\n  }\n  buggyRollOff = getInt(\"buggyRollOff\");\n  buggySlopeScale = getInt(\"oldSlopeScale\");\n\n  alphaRatio = getInt(\"alphaRatio\");\n  if (alphaRatio) {\n    requirePowerSpec = true;\n  }\n  hammarbergIndex = getInt(\"hammarbergIndex\");\n  if (hammarbergIndex) {\n    requirePowerSpec = true;\n  }\n\n  nBands = parseBandsConfig(\"bands\", &bandsL, &bandsH);\n  if (nBands > 0) {\n    requirePowerSpec = true;\n  }\n  nSlopes = parseBandsConfig(\"slopes\", &slopesL, &slopesH);\n  if (nSlopes > 0) {\n    setRequireLorPspec();\n  }\n  const char * specRange = getStr(\"freqRange\");\n  parseRange(specRange, &specRangeLower, &specRangeUpper);\n\n  nRollOff = getArraySize(\"rollOff\");\n  if (nRollOff > 0) {\n    requirePowerSpec = true;\n    rollOff = (double*)calloc(1,sizeof(double)*nRollOff);\n    for (int i = 0; i < nRollOff; i++) {\n      rollOff[i] = getDouble_f(myvprint(\"rollOff[%i]\",i));\n      if (rollOff[i] < 0.0) {\n        SMILE_ERR(1,\"rollOff[%i] = %f is out of range (allowed 0..1), clipping to 0.0\",i,rollOff[i]);\n        rollOff[i] = 0.0;\n      }\n      else if (rollOff[i] > 1.0) {\n        SMILE_ERR(1,\"rollOff[%i] = %f is out of range (allowed 0..1), clipping to 1.0\",i,rollOff[i]);\n        rollOff[i] = 1.0;\n      }\n    }\n  }\n\n  sharpness = getInt(\"sharpness\");\n  if (sharpness) {\n    requirePowerSpec = true;\n    SMILE_IDBG(2,\"sharpness computation enabled\");\n  }\n  tonality = getInt(\"tonality\");\n  if (tonality) {\n    //SMILE_IDBG(2,\"tonality computation enabled\");\n    SMILE_IERR(1, \"tonality (spectral) is not yet implemented!\");\n  }\n  harmonicity = getInt(\"harmonicity\");\n  if (harmonicity) {\n    setRequireLorPspec();\n    SMILE_IDBG(2,\"harmonicity computation enabled\");\n  }\n  flatness = getInt(\"flatness\");\n  if (flatness) {\n    setRequireLorPspec();\n    SMILE_IDBG(2,\"spectral flatness computation enabled\");\n  }\n  logFlatness = getInt(\"logFlatness\");\n  if (logFlatness) {\n    SMILE_IDBG(2, \"output of log flatness (=ln(flatness)) is enabled\");\n  }\n}\n\n\nint cSpectral::setupNamesForField(int i, const char*name, long nEl)\n{\n  int newNEl = 0;\n  int ii;\n  if (fsSec == -1.0) {\n    const sDmLevelConfig *c = reader_->getLevelConfig();\n    fsSec = c->frameSizeSec;\n  }\n  if (useLogSpectrum) {\n    for (ii=0; ii<nBands; ii++) {\n      if (isBandValid(bandsL[ii],bandsH[ii])) {\n        char *xx = myvprint(\"%s_logFband%i-%i\",name,bandsL[ii],bandsH[ii]);\n        writer_->addField( xx, 1 ); newNEl++; free(xx);\n      }\n    }\n  } else {\n    for (ii=0; ii<nBands; ii++) {\n      if (isBandValid(bandsL[ii],bandsH[ii])) {\n        char *xx = myvprint(\"%s_fband%i-%i\",name,bandsL[ii],bandsH[ii]);\n        writer_->addField( xx, 1 ); newNEl++; free(xx);\n      }\n    }\n  }\n  if (useLogSpectrum) {\n    for (ii=0; ii<nSlopes; ii++) {\n      if (isBandValid(slopesL[ii], slopesH[ii])) {\n        char *xx = myvprint(\"%s_logSpectralSlopeOfBand%i-%i\",name,slopesL[ii],slopesH[ii]);\n        writer_->addField( xx, 1 ); newNEl++; free(xx);\n      }\n    }\n  } else {\n    for (ii=0; ii<nSlopes; ii++) {\n      if (isBandValid(slopesL[ii], slopesH[ii])) {\n        char *xx = myvprint(\"%s_spectralSlopeOfBand%i-%i\",name,slopesL[ii],slopesH[ii]);\n        writer_->addField( xx, 1 ); newNEl++; free(xx);\n      }\n    }\n  }\n\n  if (useLogSpectrum) {\n    if (alphaRatio) {\n      char *xx = myvprint(\"%s_alphaRatioDB\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (hammarbergIndex) {\n      char *xx = myvprint(\"%s_hammarbergIndexDB\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n  } else {\n    if (alphaRatio) {\n      char *xx = myvprint(\"%s_alphaRatio\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (hammarbergIndex) {\n      char *xx = myvprint(\"%s_hammarbergIndex\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n  }\n\n  for (ii=0; ii<nRollOff; ii++) {\n    char *xx = myvprint(\"%s_spectralRollOff%.1f\",name,rollOff[ii]*100.0);\n    writer_->addField( xx, 1 ); newNEl++; free(xx);\n  }\n  if (specDiff) {\n    char *xx = myvprint(\"%s_spectralAbsoluteDifference\",name);\n    writer_->addField( xx, 1 ); newNEl++; free(xx);\n  }\n  if (specPosDiff) {\n    char *xx = myvprint(\"%s_spectralPositiveDifference\",name);\n    writer_->addField( xx, 1 ); newNEl++; free(xx);\n  }\n  if (flux) {\n    char *xx = myvprint(\"%s_spectralFlux\",name);\n    writer_->addField( xx, 1 ); newNEl++; free(xx);\n  }\n  if (fluxCentroid) {\n    char *xx = myvprint(\"%s_spectralFluxCentroid\",name);\n    writer_->addField( xx, 1 ); newNEl++; free(xx);\n  }\n  if (fluxAtFluxCentroid) {\n    char *xx = myvprint(\"%s_spectralFluxAtFluxCentroid\",name);\n    writer_->addField( xx, 1 ); newNEl++; free(xx);\n  }\n\n  if (useLogSpectrum) {\n    if (centroid) {\n      char *xx = myvprint(\"%s_logSpectralCentroid\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (maxPos) {\n      char *xx = myvprint(\"%s_spectralMaxPos\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (minPos) {\n      char *xx = myvprint(\"%s_spectralMinPos\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (entropy) {\n      char *xx = myvprint(\"%s_logSpectralEntropy\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (standardDeviation) {\n      char *xx = myvprint(\"%s_logSpectralStdDev\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (variance) {\n      char *xx = myvprint(\"%s_logSpectralVariance\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (skewness) {\n      char *xx = myvprint(\"%s_logSpectralSkewness\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (kurtosis) {\n      char *xx = myvprint(\"%s_logSpectralKurtosis\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (slope) {\n      char *xx = myvprint(\"%s_logSpectralSlope\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (sharpness) {\n      char *xx = myvprint(\"%s_psySharpness\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (tonality) {\n      char *xx = myvprint(\"%s_logSpectralTonality\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (harmonicity) {\n      char *xx = myvprint(\"%s_logSpectralHarmonicity\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (flatness) {\n      if (logFlatness) {\n        char *xx = myvprint(\"%s_logSpectralFlatnessLog\",name);\n        writer_->addField( xx, 1 ); newNEl++; free(xx);\n      } else {\n        char *xx = myvprint(\"%s_logSpectralFlatness\",name);\n        writer_->addField( xx, 1 ); newNEl++; free(xx);\n      }\n    }\n  } else {\n    if (centroid) {\n      char *xx = myvprint(\"%s_spectralCentroid\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (maxPos) {\n      char *xx = myvprint(\"%s_spectralMaxPos\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (minPos) {\n      char *xx = myvprint(\"%s_spectralMinPos\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (entropy) {\n      char *xx = myvprint(\"%s_spectralEntropy\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (standardDeviation) {\n      char *xx = myvprint(\"%s_spectralStdDev\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (variance) {\n      char *xx = myvprint(\"%s_spectralVariance\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (skewness) {\n      char *xx = myvprint(\"%s_spectralSkewness\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (kurtosis) {\n      char *xx = myvprint(\"%s_spectralKurtosis\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (slope) {\n      char *xx = myvprint(\"%s_spectralSlope\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (sharpness) {\n      char *xx = myvprint(\"%s_psySharpness\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (tonality) {\n      char *xx = myvprint(\"%s_spectralTonality\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (harmonicity) {\n      char *xx = myvprint(\"%s_spectralHarmonicity\",name);\n      writer_->addField( xx, 1 ); newNEl++; free(xx);\n    }\n    if (flatness) {\n      if (logFlatness) {\n        char *xx = myvprint(\"%s_spectralFlatnessLog\",name);\n        writer_->addField( xx, 1 ); newNEl++; free(xx);\n      } else {\n        char *xx = myvprint(\"%s_spectralFlatness\",name);\n        writer_->addField( xx, 1 ); newNEl++; free(xx);\n      }\n    }\n  }\n  if (i >= nFieldsPrevSpec) {\n    nFieldsPrevSpec = i + 1;\n  }\n  return newNEl;\n}\n\n// a derived class should override this method, in order to implement the actual processing\nint cSpectral::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  long n=0;\n  long i,j;\n\n  double _N = (double) ((Nsrc-1)*2);  // assumes FFT magnitude input array!!\n  double F0 = 1.0/fsSec;\n\n  if (frq == NULL) { // input block's frequency axis\n    // TODO: use frqSet flag to avoid doing the code below on every tick if info==NULL\n    const FrameMetaInfo * fmeta = reader_->getFrameMetaInfo();\n    if ((fmeta != NULL)&&(idxi < fmeta->N)) {\n      // TODO: check input block's type (in fmeta)\n      // fmeta->field[idxi].dataType & SPECTRAL == 1 ?\n      nScale = fmeta->field[idxi].infoSize / sizeof(double);\n      frq = (double *)(fmeta->field[idxi].info);\n      if (nScale > 0) {\n        // old frequency axis computation mode:\n        //nScale=0;\n        if (nScale != Nsrc) {\n          SMILE_IWRN(2,\"number of frequency axis points (from info struct) [%i] is not equal to Nsrc [%i] ! Field index: %i (check the processArrayFields option).\",nScale,Nsrc,idxi);\n          nScale = MIN(nScale,Nsrc);\n        }\n      }\n    }\n  }\n\n  if (frqScale == -1) {\n      cVectorMeta *mdata = writer_->getLevelMetaDataPtr();\n      if (mdata != NULL && mdata->ID == 1001 /* SCALED_SPEC */) {\n        frqScale = (int)mdata->fData[6];\n        frqScaleParam = (double)mdata->fData[7];\n      } else {\n        frqScale = SPECTSCALE_LINEAR;\n        frqScaleParam = 0.0;\n      }\n  }\n\n  if (specRangeLowerBin == -1) {\n    if (specRangeLower == specRangeUpper && specRangeUpper == 0) {\n      specRangeLowerBin = 1;\n      specRangeUpperBin = Nsrc - 1;\n    } else {\n      for (i = 0; i < Nsrc; i++) {\n        if ((double)specRangeLower >= frq[i]) {\n          specRangeLowerBin = i;\n        }\n        if ((double)specRangeUpper > frq[i]) {\n          specRangeUpperBin = i;\n        }\n      }\n      if (specRangeUpperBin == -1 || specRangeUpperBin >= Nsrc) {\n        specRangeUpperBin = Nsrc - 1;\n      }\n      if (specRangeLowerBin < 0) {\n        specRangeLowerBin = 0;\n      }\n    }\n    SMILE_IMSG(3, \"specRangeLower (Hz) = %i (bin = %i) ; specRangeUpper (Hz) = %i (bin = %i)\",\n        specRangeLower, specRangeLowerBin, specRangeUpper, specRangeUpperBin);\n  }\n  long nBins = specRangeUpperBin - specRangeLowerBin + 1;\n\n  if (Nsrc <= 0) {\n    return 0;\n  }\n\n  const FLOAT_DMEM *srcM = NULL; // magnitude spectrum\n  const FLOAT_DMEM *srcL = NULL; // log spectrum\n  const FLOAT_DMEM *srcP = NULL; // power spectrum\n  const FLOAT_DMEM *srcLP = NULL; // log or power spectrum\n  FLOAT_DMEM logSpecFactor = 1.0;\n  // TODO: we might get lof spectral densities as input\n  //        read the input type field and support all possible conversions!\n  if (requireMagSpec) {\n    if (squareInput) {\n      srcM = src;\n    } else {\n      // compute linear from squared\n      FLOAT_DMEM *srcTmp = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM) * Nsrc);\n      for (i = 0; i < Nsrc; i++) {\n        if (src[i] > 0.0) {\n          srcTmp[i] = sqrt(src[i]);\n        } else {\n          srcTmp[i] = 0.0;\n        }\n      }\n      srcM = srcTmp;\n    }\n  }\n  if (requirePowerSpec) {\n    if (squareInput) {\n      // compute squared from linear\n      FLOAT_DMEM *srcTmp = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM) * Nsrc);\n      for (i = 0; i < Nsrc; i++) {\n        srcTmp[i] = src[i] * src[i];\n      }\n      srcP = srcTmp;\n    } else {\n      srcP = src;\n    }\n  }\n  if (requireLogSpec) {\n    logSpecFactor = (FLOAT_DMEM)(10.0 / log(10.0));\n    FLOAT_DMEM myLogSpecFactor = logSpecFactor;\n    const FLOAT_DMEM *mySrc = NULL;\n    if (requirePowerSpec) {\n      // compute the log spectrum from the power spectrum we already have\n      mySrc = srcP;\n    } else if (requireMagSpec) {\n      // compute the log spectrum from the magnitude spectrum instead\n      mySrc = srcM;\n      logSpecFactor *= 2.0;\n    } else {\n      // find out what we have to do...\n      mySrc = src;\n      if (squareInput) {\n        logSpecFactor *= 2.0;\n      }\n    }\n    FLOAT_DMEM *srcTmp = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM) * Nsrc);\n    for (i = 0; i < Nsrc; i++) {\n      if (mySrc[i] <= specFloor) {\n        srcTmp[i] = logSpecFloor;\n      } else {\n        srcTmp[i] = myLogSpecFactor * log(mySrc[i]);\n      }\n    }\n    srcL = srcTmp;\n  }\n  if (useLogSpectrum) {\n    srcLP = srcL;\n  } else {\n    srcLP = srcP;\n  }\n\n  /*\n  if (squareInput || useLogSpectrum) {\n    src2 = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*Nsrc);\n    // NOTE: bands and slopes can be outside of the specRange parameter!\n    // thus, we need to square all inputs!\n    if (useLogSpectrum) {\n      src3 = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*Nsrc);\n      logSpecFactor = 10.0 / log(10.0);\n      if (squareInput) {\n        logSpecFactor *= 2.0;\n        for (i = 0; i < Nsrc; i++) {\n          if (src[i] < specFloor) {\n            src2[i] = logSpecFloor;\n          } else {\n            src2[i] = logSpecFactor * log(src[i]);\n          }\n          src3[i] = src[i] * src[i];\n        }\n      } else {\n        for (i = 0; i < Nsrc; i++) {\n          if (src[i] < specFloor) {\n            src2[i] = logSpecFloor;\n          } else {\n            src2[i] = logSpecFactor * log(src[i]);\n          }\n          src3[i] = src[i];\n        }\n      }\n    } else if (squareInput) {\n      for (i = 0; i < Nsrc; i++) {\n        src2[i] = src[i]*src[i];\n      }\n    }\n  } else {\n    srcP = (FLOAT_DMEM *)src;  // typecast ok here.. since we treat _src as read-only below...\n  }\n  */\n  \n  // compute total frame energy\n  double frameSum = 0.0;\n  if (normBandEnergies || sharpness || nRollOff > 0) {\n    for (i = specRangeLowerBin; i <= specRangeUpperBin; i++) {\n      frameSum += srcP[i];\n    }\n  }\n\n  // process spectral bands (rectangular \"filter\")\n  // NOTE: bands and slopes can be outside of the specRange parameter!\n  for (i=0; i<nBands; i++) {\n    if (isBandValid(bandsL[i],bandsH[i])) {\n      double idxL;\n      double wghtL;\n      if ((nScale < Nsrc)||(frq==NULL)) {\n        idxL =  (double)bandsL[i] / F0 ;\n        wghtL =  ceil(idxL) - idxL;\n      } else {\n        if (bandsLi == NULL) { // map the frequency to an fft bin index\n          int ii,iii;\n          bandsLi=(double*)malloc(sizeof(double)*nBands);\n          wghtLi=(double*)malloc(sizeof(double)*nBands);\n          for (iii=0; iii<nBands; iii++) {\n            for (ii=0; ii<nScale; ii++) {\n              if (frq[ii] > (double)bandsL[iii]) break;\n            }\n            if ((ii<nScale)&&(ii>0)) {\n              wghtLi[iii] = (frq[ii]-(double)bandsL[iii])/(frq[ii] - frq[ii-1]);\n            } else { wghtLi[iii] = 1.0; }\n            \n            bandsLi[iii] = (double)ii-1.0;\n            if (bandsLi[iii] < 0) bandsLi[iii] = 0;\n            if (bandsLi[iii] >= Nsrc) bandsLi[iii] = Nsrc;\n          }\n        }\n        idxL = bandsLi[i];\n        wghtL = wghtLi[i];\n      }\n      if (wghtL == 0.0) wghtL = 1.0;\n\n      double idxR;\n      double wghtR ;\n      if ((nScale < Nsrc)||(frq==NULL)) {\n        idxR =  (double)bandsH[i] / F0 ;\n        wghtR = idxR-floor(idxR);\n      } else {\n        if (bandsHi == NULL) { // map the frequency to an fft bin index\n          int ii, iii;\n          bandsHi=(double*)malloc(sizeof(double)*nBands);\n          wghtHi=(double*)malloc(sizeof(double)*nBands);\n          for (iii=0; iii<nBands; iii++) {\n            for (ii=0; ii<nScale; ii++) {\n              if (frq[ii] >= (FLOAT_DMEM)bandsH[iii]) break;\n            }\n            if ((ii<nScale)&&(ii>0)) {\n              wghtHi[iii] = ((double)bandsH[iii]-frq[ii-1])/(frq[ii] - frq[ii-1]);\n            } else { wghtHi[iii] = 1.0; }\n            //if (wghtHi[iii] == 0.0) { wghtHi[iii] = 1.0; }\n            if ((ii<nScale)&&(frq[ii] == (FLOAT_DMEM)bandsH[iii])) {\n              bandsHi[iii] = (double)ii;\n            } else {\n              bandsHi[iii] = (double)ii-1.0;\n            }\n            if (bandsHi[iii] >= Nsrc) bandsHi[iii] = Nsrc-1;\n          }\n        }\n        idxR = bandsHi[i];\n        wghtR = wghtHi[i];\n      }\n      // TODO: interpolation instead of rounding boundaries to next lower bin and next higher bin\n      // TODO: spectral band filter shapes...\n      // TODO: debug output of actual filter bandwidth & range based on rounded (or interpolated) boundaries!\n\n      if (wghtR == 0.0) wghtR = 1.0;\n  \n      long iL = (long)floor(idxL);\n      long iR = (long)floor(idxR);\n\n      if (iL >= Nsrc) { iL=iR=Nsrc-1; wghtR=0.0; wghtL=0.0; }\n      if (iR >= Nsrc) { iR=Nsrc-1; wghtR = 1.0; } \n      if (iL < 0) iL=0;\n      if (iR < 0) iR=0;\n      double sum=(double)srcP[iL]*wghtL;\n      for (j = iL + 1; j < iR; j++) {\n        sum += (double)srcP[j];\n      }\n      sum += (double)srcP[iR]*wghtR;\n      \n      if (normBandEnergies) {\n        // normalise band energy to frame energy\n        if (frameSum > 0.0) {  // energy ratio .. never in dB\n          dst[n++] = (FLOAT_DMEM)(sum/frameSum);\n        } else {\n          dst[n++] = (FLOAT_DMEM)0.0;\n        }\n      } else {\n        // normalise band energy to frame size\n        if (nBins > 0) {\n          if (useLogSpectrum) {\n            dst[n++] = (FLOAT_DMEM)(10.0 * log(sum/(double)nBins) / log(10.0));\n          } else {\n            dst[n++] = (FLOAT_DMEM)(sum/(double)nBins);\n          }\n        } else {\n          SMILE_IWRN(3, \"0 bins in band %i!\", i);\n          dst[n++] = 0.0;\n        }\n      }\n    }\n  }\n  \n  // compute spectral slopes in bands\n  for (i=0; i<nSlopes; i++) {\n    if (isBandValid(slopesL[i], slopesH[i])) {\n      double idxL = 0.0;\n      double wghtL = 0.0;\n      if ((nScale < Nsrc) || (frq == NULL)) {\n        idxL =  (double)slopesL[i] / F0 ;\n        wghtL =  ceil(idxL) - idxL;\n      } else {\n        if (slopeBandsLi == NULL) { // map the frequency to an fft bin index\n          int ii, iii;\n          slopeBandsLi = (double*)malloc(sizeof(double)*nSlopes);\n          slopeWghtLi = (double*)malloc(sizeof(double)*nSlopes);\n          for (iii=0; iii<nSlopes; iii++) {\n            for (ii=0; ii<nScale; ii++) {\n              if (frq[ii] > (double)slopesL[iii]) break;\n            }\n            if ((ii<nScale)&&(ii>0)) {\n              slopeWghtLi[iii] = (frq[ii]-(double)slopesL[iii])/(frq[ii] - frq[ii-1]);\n            } else { slopeWghtLi[iii] = 1.0; }\n            slopeBandsLi[iii] = (double)ii-1.0;\n            if (slopeBandsLi[iii] < 0) slopeBandsLi[iii] = 0;\n            if (slopeBandsLi[iii] >= Nsrc) slopeBandsLi[iii] = Nsrc;\n          }\n        }\n        idxL = slopeBandsLi[i];\n        wghtL = slopeWghtLi[i];\n      }\n      if (wghtL == 0.0) wghtL = 1.0;\n      double idxR = 0.0;\n      double wghtR = 0.0;\n      if ((nScale < Nsrc) || (frq == NULL)) {\n        idxR =  (double)slopesH[i] / F0 ;\n        wghtR = idxR - floor(idxR);\n      } else {\n        if (slopeBandsHi == NULL) { // map the frequency to an fft bin index\n          int ii, iii;\n          slopeBandsHi = (double*)malloc(sizeof(double)*nSlopes);\n          slopeWghtHi = (double*)malloc(sizeof(double)*nSlopes);\n          for (iii = 0; iii < nSlopes; iii++) {\n            for (ii = 0; ii < nScale; ii++) {\n              if (frq[ii] >= (FLOAT_DMEM)slopesH[iii]) break;\n            }\n            if ((ii<nScale)&&(ii>0)) {\n              slopeWghtHi[iii] = ((double)slopesH[iii]-frq[ii-1])/(frq[ii] - frq[ii-1]);\n            } else { slopeWghtHi[iii] = 1.0; }\n            if ((ii<nScale)&&(frq[ii] == (FLOAT_DMEM)slopesH[iii])) {\n              slopeBandsHi[iii] = (double)ii;\n            } else {\n              slopeBandsHi[iii] = (double)ii - 1.0;\n            }\n            if (slopeBandsHi[iii] >= Nsrc) slopeBandsHi[iii] = Nsrc - 1;\n          }\n        }\n        idxR = slopeBandsHi[i];\n        wghtR = slopeWghtHi[i];\n      }\n      if (wghtR == 0.0) wghtR = 1.0;\n      // TODO: interpolation instead of rounding boundaries to next lower bin and next higher bin\n      // TODO: spectral band filter shapes...\n      // TODO: debug output of actual filter bandwidth & range based on rounded (or interpolated) boundaries!\n  \n      long iL = (long)floor(idxL);\n      long iR = (long)floor(idxR);\n      if (iL >= Nsrc) { iL=iR=Nsrc-1; wghtR=0.0; wghtL=0.0; }\n      if (iR >= Nsrc) { iR=Nsrc-1; wghtR = 1.0; } \n      if (iL < 0) iL=0;\n      if (iR < 0) iR=0;\n\n      // actual spectral slope computation\n      double Sf = 0.0;\n      double S2f = 0.0;\n      double sumA = 0.0;\n      double sumB = 0.0;\n      double Nind = idxR - idxL;\n      if ((nScale >= Nsrc && nScale > 0) && (frq != NULL)) {\n        Sf  = (double)frq[iL] * wghtL;\n        S2f = Sf * Sf;\n        sumA = (double)frq[iL] * wghtL * (double)srcLP[iL];\n        sumB = wghtL * srcLP[iL];\n        int ii = iL + 1;\n        for ( ; ii < iR && ii < nScale; ii++) {\n          S2f += (double)frq[ii] * (double)frq[ii] ;\n          Sf += (double)frq[ii];   //NOTE: if this line is commented out: old code for compatibility, dont' check into SVN!!\n          sumA += (double)frq[ii] * (double)srcLP[ii];\n          sumB += (double)srcLP[ii];\n        }\n        S2f += (double)frq[iR] * wghtR * (double)frq[iR] * wghtR;\n        Sf  += (double)frq[iR] * wghtR;\n        sumA += (double)frq[iR] * wghtR * (double)srcLP[iR];\n        sumB += wghtR * (double)srcLP[iR];\n      } else { \n        Sf   = (double)iL * wghtL;\n        S2f  = Sf * Sf;\n        sumA = (double)iL * wghtL * (double)srcLP[iL];\n        sumB = wghtL * (double)srcLP[iL];\n        int ii = iL + 1;\n        for ( ; ii < iR && ii < nScale; ii++) {\n          S2f  += (double)ii * (double)ii;\n          Sf   += (double)ii;\n          sumA += (double)ii * (double)srcLP[ii];\n          sumB += (double)srcLP[ii];\n        }\n        S2f += (double)iR * wghtR * (double)iR * wghtR;\n        Sf  += (double)iR * wghtR;\n        sumA += (double)iR * wghtR * (double)srcLP[iR];\n        sumB += wghtR * (double)srcLP[iR];\n        S2f *= F0 * F0;\n        Sf  *= F0;\n        sumA *= F0;\n      }\n      double deno = (Nind * S2f - Sf * Sf);\n      double slope = 0.0;\n      if (deno != 0.0) slope = (Nind * sumA - Sf * sumB) / deno;\n      // TODO: more options for slope normalisation!\n      if (buggySlopeScale) {\n        dst[n++] = (FLOAT_DMEM)(slope*(Nind-1.0));\n      } else {\n        dst[n++] = (FLOAT_DMEM)(slope);\n      }\n    }\n  }\n\n  // alpha ratio  (1-5k energy / 0-1k energy)\n  if (alphaRatio) {\n    FLOAT_DMEM sum01 = 0.0;\n    FLOAT_DMEM sum15 = 0.0;\n    if ((nScale < Nsrc) || (frq == NULL)) {\n      double f = 0.0;\n      for (j = 0; j < Nsrc; j++) {\n        if (f > 5000.0) {\n          break;\n        }\n        if (f < 1000.0) {\n          sum01 += srcP[j];\n        } else {\n          sum15 += srcP[j];\n        }\n        f += F0;\n      }\n    } else {\n      for (j = 0; j < Nsrc; j++) {\n        if (frq[j] > 5000.0) {\n          break;\n        }\n        if (frq[j] < 1000.0) {\n          sum01 += srcP[j];\n        } else {\n          sum15 += srcP[j];\n        }\n      }\n    }\n    if (sum01 > 0.0) {\n      if (useLogSpectrum) {\n        if (sum15 > specFloor) {\n          dst[n++] = (FLOAT_DMEM)(10.0 * log(sum15 / sum01) / log(10.0));\n        } else {\n          dst[n++] = (FLOAT_DMEM)(10.0 * (log(specFloor) - log(sum01)) / log(10.0));\n        }\n      } else {\n        dst[n++] = sum15 / sum01;\n      }\n    } else {\n      dst[n++] = 0.0;\n    }\n  }\n\n  // hammarberg index\n  if (hammarbergIndex) {\n    FLOAT_DMEM max02 = 0.0;\n    FLOAT_DMEM max25 = 0.0;\n    if ((nScale < Nsrc) || (frq == NULL)) {\n      double f = 0.0;\n      for (j = 0; j < Nsrc; j++) {\n        if (f > 5000.0) {\n          break;\n        }\n        if (f < 2000.0) {\n          if (srcP[j] > max02) {\n            max02 = srcP[j];\n          }\n        } else {\n          if (srcP[j] > max25) {\n            max25 = srcP[j];\n          }\n        }\n        f += F0;\n      }\n    } else {\n      for (j = 0; j < Nsrc; j++) {\n        if (frq[j] > 5000.0) {\n          break;\n        }\n        if (frq[j] < 2000.0) {\n          if (srcP[j] > max02) {\n            max02 = srcP[j];\n          }\n        } else {\n          if (srcP[j] > max25) {\n            max25 = srcP[j];\n          }\n        }\n      }\n    }\n    if (max25 > 0.0) {\n      if (useLogSpectrum) {\n        if (max02 > specFloor) {\n          dst[n++] = (FLOAT_DMEM)(10.0 * log(max02 / max25) / log(10.0));\n        } else {\n          dst[n++] = (FLOAT_DMEM)(10.0 * (log(specFloor) - log(max25)) / log(10.0));\n        }\n      } else {\n        dst[n++] = max02 / max25;\n      }\n    } else {\n      dst[n++] = 0.0;\n    }\n  }\n\n  // sum of all spectral amplitudes/powers/logs, required for spectral centroid/sharpness and moments\n  double sumB=0.0, sumC=0.0;\n  if (normBandEnergies && !useLogSpectrum) {\n    sumB = frameSum;  // frameSum is the power spectrum sum\n  } else {\n    for (j = specRangeLowerBin; j <= specRangeUpperBin; j++) {\n      sumB += (double)srcLP[j];\n    }\n  }\n\n  \n  // compute rollOff(s):\n  FLOAT_DMEM *ro = (FLOAT_DMEM *)calloc(1,sizeof(FLOAT_DMEM)*nRollOff);\n  for (j = specRangeLowerBin; j <= specRangeUpperBin; j++) {\n    sumC += (double)srcP[j];\n    for (i=0; i<nRollOff; i++) {\n      if (buggyRollOff == 1 && i > 0) {\n        sumC += (double)srcP[j];\n      }\n      if ((ro[i] == 0.0) && (sumC >= rollOff[i] * frameSum)) {\n        if ((nScale >= Nsrc) && (frq!=NULL)) {\n          ro[i] = (FLOAT_DMEM)frq[j];   // TODO: norm frequency ??\n        } else {\n          ro[i] = (FLOAT_DMEM)j * (FLOAT_DMEM)F0;   // TODO: norm frequency ??\n        }\n      }\n    }\n  }\n  for (i=0; i<nRollOff; i++) {\n    dst[n++] = ro[i];\n  }\n  free(ro);\n\n  // flux  (requireMagSpec!)\n  if (specPosDiff || specDiff || flux || fluxCentroid || fluxAtFluxCentroid) {\n    if (prevSpec == NULL) {\n      prevSpec = (FLOAT_DMEM**)calloc(1, sizeof(FLOAT_DMEM*) * nFieldsPrevSpec);\n    }\n    if (nSrcPrevSpec == NULL) {\n      nSrcPrevSpec = (long*)calloc(1, sizeof(long) * nFieldsPrevSpec);\n    }\n    if (prevSpec[idxi] == NULL) {\n      nSrcPrevSpec[idxi] = nBins;\n      prevSpec[idxi] = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM) * nSrcPrevSpec[idxi]);\n      dst[n++] = 0.0;\n    } else {\n      double normP=1.0, normC=1.0;\n      FLOAT_DMEM *magP = prevSpec[idxi];\n      double myA = 0.0;\n      double myAf = 0.0;\n      double d = 0.0;\n      double dp = 0.0;\n      // simple absolute spectral difference (root of)\n      if (specDiff) {\n        for (j = specRangeLowerBin; j <= specRangeUpperBin; j++) {\n          double myd = (srcM[j] - magP[j - specRangeLowerBin]);\n          d += myd*myd;\n        }\n        d /= (double)(specRangeUpperBin - specRangeLowerBin + 1);\n        if (d > 0.0) {\n          dst[n++] = (FLOAT_DMEM)sqrt(d);\n        } else {\n          dst[n++] = 0.0;\n        }\n      }\n      // positive spectral differences only (root of)\n      if (specPosDiff) {\n        for (j = specRangeLowerBin; j <= specRangeUpperBin; j++) {\n          double myd = (srcM[j] - magP[j - specRangeLowerBin]);\n          if (myd > 0.0) {\n            dp += myd*myd;\n          }\n        }\n        dp /= (double)(specRangeUpperBin - specRangeLowerBin + 1);\n        if (dp > 0.0) {\n          dst[n++] = (FLOAT_DMEM)sqrt(dp);\n        } else {\n          dst[n++] = 0.0;\n        }\n      }\n      if (flux || fluxCentroid) {\n         for (j = specRangeLowerBin; j <= specRangeUpperBin; j++) {\n           double myB = ((double)srcM[j]/normC - (double)magP[j - specRangeLowerBin]/normP);\n           myA += myB*myB;\n         }\n      }\n      if (fluxCentroid) {\n        if ((nScale>specRangeUpperBin)&&(frq!=NULL)) {\n          for (j = specRangeLowerBin; j <= specRangeUpperBin; j++) {\n            double myB = ((double)srcM[j]/normC - (double)magP[j - specRangeLowerBin]/normP);\n            myAf += myB*myB * frq[j];\n          }\n        } else {\n          for (j = specRangeLowerBin; j <= specRangeUpperBin; j++) {\n            double myB = ((double)srcM[j]/normC - (double)magP[j - specRangeLowerBin]/normP);\n            myAf += myB*myB * (double)j * F0;\n          }\n        }\n      }\n      if (flux) {\n        double flux = 0.0;\n        if (nBins > 0) {\n          flux = myA / (double)(nBins);\n        }\n        if (flux > 0.0) {\n          dst[n++] = (FLOAT_DMEM)sqrt(flux);\n        } else {\n          dst[n++] = 0.0;\n        }\n      }\n      if (fluxCentroid || fluxAtFluxCentroid) {\n        double fluxCentr = 0.0;\n        if (myA > 0.0) {\n          fluxCentr = myAf / myA;\n        }\n        if (fluxCentroid) {\n          dst[n++] = (FLOAT_DMEM)fluxCentr;\n        }\n        if (fluxAtFluxCentroid) {\n          // TODO: map flux centroid back to bin...\n          int bin = specRangeUpperBin;\n          if ((nScale>specRangeUpperBin)&&(frq!=NULL)) {\n            for (j = specRangeLowerBin; j <= specRangeUpperBin; j++) {\n              if (frq[j] >= fluxCentr) {\n                bin = j;\n                break;\n              }\n            }\n          } else {\n            for (j = specRangeLowerBin; j <= specRangeUpperBin; j++) {\n              if ((double)j * F0 >= fluxCentr) {\n                bin = j;\n                break;\n              }\n            }\n          }\n          // range around bin...\n          int range = 2;\n          double myF = 0.0;\n          int start = bin - range;\n          int end = bin + range;\n          if (start < specRangeLowerBin) {\n            start = specRangeLowerBin;\n          }\n          if (end > specRangeUpperBin) {\n            end = specRangeUpperBin;\n          }\n          for (j = start; j <= end; j++) {\n            double myB = ((double)srcM[j]/normC - (double)magP[j - specRangeLowerBin]/normP);\n            myF += myB*myB;\n          }\n          if (end- start + 1 > 0) {\n            myF /= (double)(end - start + 1);\n          } else {\n            myF = 0.0;\n          }\n          dst[n++] = (FLOAT_DMEM)myF;\n        }\n      }\n    }\n    for (j = specRangeLowerBin; j <= specRangeUpperBin; j++) {\n      prevSpec[idxi][j - specRangeLowerBin] = srcM[j];\n    }\n  }\n\n  // centroid\n  FLOAT_DMEM ctr=0.0;\n  double sumA = 0.0;\n  double sumLog = 0.0;\n  double minE = 0.0;\n  double f = 0.0;\n  if (centroid||standardDeviation||variance||skewness||kurtosis||slope) { // spectral centroid (mpeg7)\n    if ((nScale >= Nsrc)&&(frq!=NULL)) {\n      minE = (double)srcLP[specRangeLowerBin];\n      for (j = specRangeLowerBin; j <= specRangeUpperBin; j++) {\n        sumA += (double)frq[j] * (double)srcLP[j];\n        if (useLogSpectrum && (double)srcLP[j] < minE) {\n          minE = (double)srcLP[specRangeLowerBin];\n        }\n      }\n      if (useLogSpectrum) {\n        for (j = specRangeLowerBin; j <= specRangeUpperBin; j++) {\n          sumLog += (double)frq[j] * minE;\n        }\n      }\n    } else {\n      if ((nScale>specRangeUpperBin)&&(frq!=NULL)) {\n        minE = (double)srcLP[specRangeLowerBin];\n        for (j = specRangeLowerBin; j <= specRangeUpperBin; j++) {\n          sumA += (double)frq[j] * (double)srcLP[j];\n          if (useLogSpectrum && (double)srcLP[j] < minE) {\n            minE = (double)srcLP[specRangeLowerBin];\n          }\n        }\n        if (useLogSpectrum) {\n          for (j = specRangeLowerBin; j <= specRangeUpperBin; j++) {\n            sumLog += (double)frq[j] * minE;\n          }\n        }\n      } else {\n        for (j = specRangeLowerBin; j <= specRangeUpperBin; j++) {\n          sumA += f * (double)srcLP[j];\n          f += F0;\n        }\n        if (useLogSpectrum) {\n          sumLog = F0 * minE * (double)nBins;\n        }\n      }\n    }\n    // TODO: in sumB computation the left and right boundary weights are considered for first and last bin\n    //       in sumA computation these are not considered! Need to fix?\n    if (sumB != 0.0) {\n      ctr = (FLOAT_DMEM)(sumA/sumB);  // spectral centroid in Hz (unnormalised)  // TODO: normFrequency option\n    }\n    if (centroid) {\n      if (useLogSpectrum) {\n        // output a warning that the log spectral centroid is not standard and has potentially bogus values...!\n        SMILE_IWRN(2, \"Log-spectral centroid is non-standard and should not be used as it has unstable and bogus values! Remove the 'useLogSpectrum' option when enabling the centroid feature unless you know what you are doing!\");\n      }\n      dst[n++] = ctr;\n    }\n  }\n  \n  if ((maxPos)||(minPos)) {\n    long maP=specRangeLowerBin;\n    long miP=specRangeLowerBin;\n    FLOAT_DMEM max=srcLP[specRangeLowerBin];\n    FLOAT_DMEM min=srcLP[specRangeLowerBin];\n    for (j = specRangeLowerBin + 1; j < specRangeUpperBin; j++) {\n      if (srcLP[j] < min) { min = srcLP[j]; miP = j; }\n      if (srcLP[j] > max) { max = srcLP[j]; maP = j; }\n    }\n    if ((nScale >= Nsrc)&&(frq!=NULL)) {\n      if (maxPos) dst[n++] = (FLOAT_DMEM)frq[maP];  // spectral minimum in Hz\n      if (minPos) dst[n++] = (FLOAT_DMEM)frq[miP]; // spectral maximum in Hz\n    } else {\n      if (maxPos) dst[n++] = (FLOAT_DMEM)(maP*F0);  // spectral minimum in Hz\n      if (minPos) dst[n++] = (FLOAT_DMEM)(miP*F0); // spectral maximum in Hz\n    }\n  }\n\n  // spectral entropy\n  if (entropy) {\n    // TODO: normalise??\n    dst[n++] = smileStat_entropy(srcLP + specRangeLowerBin, specRangeUpperBin - specRangeLowerBin + 1);\n  }\n\n  // compute various spectral moments\n  double u = ctr; // use centroid as mean value\n  double m2 = 0.0;\n  double m3 = 0.0;\n  double m4 = 0.0;\n\n  if (standardDeviation||variance||skewness||kurtosis) {\n    if ((nScale>=Nsrc)&&(frq!=NULL)) {\n      for (i = specRangeLowerBin; i <= specRangeUpperBin; i++) {\n        double t1 = ((double)frq[i]-u);\n        double m = t1*t1 * (double)srcLP[i];\n        m2 += m;\n        m *= t1;\n        m3 += m;\n        m4 += m*t1;\n      }\n    } else {\n      for (i = specRangeLowerBin; i <= specRangeUpperBin; i++) {\n        double fi = (double)i*F0;\n        double t1 = (fi-u);\n        double m = t1*t1 * (double)srcLP[i];\n        m2 += m;\n        m *= t1;\n        m3 += m;\n        m4 += m*t1;\n      }\n    }\n\n    double sigma2=0.0;\n    if (sumB != 0.0) {\n      sigma2 = m2/sumB;\n    }\n    if (standardDeviation) {\n      if (sigma2 > 0.0) {\n        dst[n++] = (FLOAT_DMEM)(sqrt(sigma2));\n      } else {\n        dst[n++] = (FLOAT_DMEM)0.0;\n      }\n    }\n    // spectral spread (mpeg7) = spectral variance\n    if (variance) { // save variance (sigma^2 = m2) in output vector\n      dst[n++] = (FLOAT_DMEM)(sigma2);\n    }\n    // spectral skewness\n    if (skewness) {\n      if (sigma2 <= 0.0) {\n        dst[n++] = 0.0;\n      } else {\n        dst[n++] = (FLOAT_DMEM)( m3/(sumB*sigma2*sqrt(sigma2)) );\n      }\n    }\n    // spectral kurtosis\n    if (kurtosis) {\n      if (sigma2 == 0.0) {\n        dst[n++] = 0.0;\n      } else {\n        dst[n++] = (FLOAT_DMEM)( m4/(sumB*sigma2*sigma2) );\n      }\n    }\n  }\n\n  // spectral slope\n  if (slope) {\n    double Sf = 0.0;\n    double S2f = 0.0;\n    double Nind = (double)nBins;\n    if ((nScale >= Nsrc && nScale > 0)&&(frq!=NULL)) {\n      for (i = specRangeLowerBin; i <= specRangeUpperBin && i < nScale; i++) {\n        S2f += (double)frq[i] * (double)frq[i] ;\n        Sf += (double)frq[i];   //NOTE: if this line is commented out: old code for compatibility, don't check into SVN!!\n      }\n    } else {\n      double NNm1;\n      double S1;\n      double S2;\n      NNm1 = Nind * (Nind - 1.0);\n      S1 = NNm1/(double)2.0;  // sum of all i=0..N-1\n      S2 = NNm1*((double)2.0*Nind-(double)1.0)/(double)6.0; // sum of all i^2 for i=0..N-1\n      Sf = S1 * F0;\n      S2f = S2 * F0*F0;\n    }\n    double deno = (Nind*S2f-Sf*Sf);\n    double slope = 0.0;\n    if (deno != 0.0) slope = (Nind*sumA-Sf*sumB)/deno;\n    if (buggySlopeScale) {\n      dst[n++] = (FLOAT_DMEM)(slope*(Nind-1.0));\n    } else {\n      dst[n++] = (FLOAT_DMEM)(slope);\n    }\n  }\n\n  if (sharpness) {\n     // TODO: check if we should use src3 when useLogSpectrum is on, or\n     //  if its actually correct to take the centroid of the log spectrum\n     // TODO: check the same for power spectrum!\n\n     // psychoacoustically correct spectral centroid (= sharpness)\n     FLOAT_DMEM ctr = 0.0;\n     FLOAT_DMEM sumAA = 0.0;\n     if (sharpness) { // spectral sharpness (weighted centroid, usually in bark scale)\n       if ((nScale >= Nsrc)&&(frq!=NULL)) {\n         // custom scale, frequency info given in meta data\n         for (j = specRangeLowerBin; j <= specRangeUpperBin && j < nScale; j++) {\n           // convert frequency to bark, if not already in bark\n           double f = (double)frq[j];\n           if (frqScale != SPECTSCALE_BARK) {\n             // transform to linear scale...\n             f = smileDsp_specScaleTransfInv(f,frqScale,frqScaleParam);\n             // ...then from linear to bark\n             f = smileDsp_specScaleTransfFwd(f,SPECTSCALE_BARK,0.0);\n           }\n           // NOTE: this double conversion is here for backwards numeric\n           // compatibility on Linux. Previously no explicit conversion was performed,\n           // which would be interpreted by GCC in the way it is now explicitely below.\n           // It might break compatiblity for Windows, as GCC\n           // tackles these issues differently. But at least Windows and Linux are\n           // now identical. For future updates, the best way would be to do all summing\n           // completely in double, and then convert when saving to dst[].\n           sumAA = (FLOAT_DMEM)((double)sumAA + (f * (double)srcP[j] * \n             smileDsp_getSharpnessWeightG(f, SPECTSCALE_BARK, 0.0)));\n         }\n       } else {\n         // linear scale, no frequency axis info given in meta data\n         for (j = specRangeLowerBin; j <= specRangeUpperBin; j++) {\n           double fb = smileDsp_specScaleTransfFwd(f,SPECTSCALE_BARK,0.0);\n           // NOTE: see above re. backwards compatibility.\n           sumAA = (FLOAT_DMEM)((double)sumAA + (fb * (double)srcP[j] * \n             smileDsp_getSharpnessWeightG(fb, SPECTSCALE_BARK, 0.0)));\n           f += F0;\n         }\n       }\n       if (frameSum != 0.0) {\n         ctr = sumAA/frameSum;  // weighted spectral centroid in Bark (unnormalised)\n       }\n       dst[n++] = (FLOAT_DMEM)(0.11 * ctr); /* scaling for psychoacoustic sharpness */\n     }\n   }\n\n   if (tonality) {\n     dst[n++] = 0.0; /* NOT YET IMPLEMENTED */\n   }\n\n   if (harmonicity) {\n     FLOAT_DMEM ptpSum=0.0; long nPtp=0;\n     FLOAT_DMEM lastPeak = -99.0;\n     for (j = specRangeLowerBin + 2; j < specRangeUpperBin - 1; j++) {\n       // min/max finder\n       if ( (srcLP[j-2] < srcLP[j] && srcLP[j-1] < srcLP[j] && srcLP[j] > srcLP[j+1] && srcLP[j] > srcLP[j+2])  //max\n           || (srcLP[j-2] > srcLP[j] && srcLP[j-1] > srcLP[j] && srcLP[j] < srcLP[j+1] && srcLP[j] < srcLP[j+2]) ) // min\n       {\n         if (lastPeak != -99.0) {\n           ptpSum += fabs(srcLP[j] - lastPeak);\n           nPtp++;\n         }\n         lastPeak = srcLP[j];\n       }\n     }\n     ptpSum /= 2.0;   // we only want to consider each peak once\n     // normalise to spectral mean energy (~ frame energy, normalized by bin size):\n     // NEW: this is linked to normBandEnergies.. only if this is set, then we will norm\n     if (normBandEnergies && sumB != 0.0) {\n       // NEW: we don't divide by number of bins and peaks anymore -> a single peak will have less harmonicity than a series of peaks\n       if (useLogSpectrum) {\n         ptpSum /= (FLOAT_DMEM)fabs(sumB);\n       } else {\n         ptpSum /= (FLOAT_DMEM)(frameSum);\n       }\n     } else {\n       ptpSum /= (FLOAT_DMEM)nBins;\n     }\n     dst[n++] = ptpSum;\n   }\n\n   if (flatness) {\n     FLOAT_DMEM sf = 0.0;\n     FLOAT_DMEM gmean = 0.0;\n     int nGm = 0;\n     if (sumB != 0.0) {\n       // compute geometric mean\n       for (j = specRangeLowerBin; j <= specRangeUpperBin; j++) {\n         if (srcLP[j] != 0.0) {\n           gmean += log(fabs(srcLP[j]));\n           nGm++;\n         }\n       }\n       if (nGm > 0) {\n         gmean /= (FLOAT_DMEM)nGm;\n       }\n       gmean = exp(gmean);\n       // compute flatness\n       sf = gmean / (FLOAT_DMEM)fabs(sumB/(double)nBins);\n     }\n     if (logFlatness) {\n       if (sf > 0.0) {\n         dst[n++] = (FLOAT_DMEM)log(sf);\n       } else {\n         dst[n++] = 0.0;\n       }\n     } else {\n       dst[n++] = sf;\n     }\n   }\n\n   if (srcP != NULL && srcP != src) {\n     free((FLOAT_DMEM*)srcP);\n   }\n   if (srcM != NULL && srcM != src) {\n     free((FLOAT_DMEM*)srcM);\n   }\n   if (srcL != NULL && srcL != src) {\n     free((FLOAT_DMEM*)srcL);\n   }\n   return 1;\n}\n\ncSpectral::~cSpectral()\n{\n  // TODO: manage extra bandsL/H slopes, rolloff, etc. for each input field!!\n  if (bandsL!=NULL) free(bandsL);\n  if (bandsH!=NULL) free(bandsH);\n  if (slopesL!=NULL) free(slopesL);\n  if (slopesH!=NULL) free(slopesH);\n  if (bandsLi!=NULL) free(bandsLi);\n  if (bandsHi!=NULL) free(bandsHi);\n  if (wghtLi!=NULL) free(wghtLi);\n  if (wghtHi!=NULL) free(wghtHi);\n  if (slopeBandsLi!=NULL) free(slopeBandsLi);\n  if (slopeBandsHi!=NULL) free(slopeBandsHi);\n  if (slopeWghtLi!=NULL) free(slopeWghtLi);\n  if (slopeWghtHi!=NULL) free(slopeWghtHi);\n  if (rollOff!=NULL) free(rollOff);\n  if (prevSpec != NULL) {\n    for (int i = 0; i < nFieldsPrevSpec; i++) {\n      if (prevSpec[i] != NULL) {\n        free(prevSpec[i]);\n      }\n    }\n    free(prevSpec);\n  }\n  if (nSrcPrevSpec != NULL) {\n    free(nSrcPrevSpec);\n  }\n}\n\n"
  },
  {
    "path": "src/other/bowProducer.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample dataSource\nwrites data to data memory...\n\n*/\n\n\n#include <other/bowProducer.hpp>\n#define MODULE \"cBowProducer\"\n\nSMILECOMPONENT_STATICS(cBowProducer)\n\nSMILECOMPONENT_REGCOMP(cBowProducer)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CBOWPRODUCER;\n  sdescription = COMPONENT_DESCRIPTION_CBOWPRODUCER;\n\n  // we inherit cDataSource configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSource\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"kwList\",\"text file with list of keywords (one word per line) to use for BoW\",(const char*)NULL);\n    ct->setField(\"kwListPrefixFilter\",\"keywords in kwList file are expected to have a prefix 'prefix'. Only those keywords will be loaded from the list, everything else will be ignored (i.e. line not beginning with 'prefix').\",0);\n    ct->setField(\"prefix\",\"prefix to append to keywords to create feature names\",\"BOW_\");\n    ct->setField(\"count\",\"1=count frequency of keyword in input / 0=binary output only (keyword present/not present)\",0);\n    ct->setField(\"textfile\",\"A file that contains sentences (words separated by spaces), which will be converted to BOW vectors. You can use this feature to use this component in offline mode (in online mode the text strings will be received as smile messages).\",(const char *)NULL);\n    ct->setField(\"singleSentence\",\"A single sentence to be converted to a BoW vector. Words must be separated by spaces.\",(const char *)NULL);\n    ct->setField(\"syncWithAudio\",\"If set to 1, wait for a 'turnFrameTime' message before writing the BoW vector to the output level. This applies only in message-based mode, i.e. this option has no effect if either 'textfile' or 'singleSentence' are used.\",1);\n    //ct->setField(\"useConf\",\"1=use confidence instead of count or binary word presence\",0);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cBowProducer);\n}\n\nSMILECOMPONENT_CREATE(cBowProducer)\n\n//-----\n\ncBowProducer::cBowProducer(const char *_name) :\n  cDataSource(_name),kwList(NULL),count(0),numKw(0),\n  keywords(NULL), prefix(NULL), dataFlag(0), filehandle(NULL), \n  lineNr(0), line(NULL), line_n(0), txtEof(0)\n{\n}\n\nvoid cBowProducer::fetchConfig()\n{\n  cDataSource::fetchConfig();\n  \n  kwList = getStr(\"kwList\");\n  SMILE_IDBG(2,\"kwList = '%s'\",kwList);\n  kwListPrefixFilter = getInt(\"kwListPrefixFilter\");\n  SMILE_IDBG(2,\"kwListPrefixFilter = '%i'\",kwListPrefixFilter);\n\n  count = getInt(\"count\");\n  SMILE_IDBG(2,\"count = %i\",count);\n  prefix = getStr(\"prefix\");\n  SMILE_IDBG(2,\"prefix = %s\",prefix);\n  textfile = getStr(\"textfile\");\n  SMILE_IDBG(2,\"textfile = %s\",textfile);\n  singleSentence = getStr(\"singleSentence\");\n  SMILE_IDBG(2,\"singleSentence = %s\",singleSentence);\n\n  syncWithAudio = getInt(\"syncWithAudio\");\n}\n\n/*\nint cBowProducer::myConfigureInstance()\n{\n  int ret = cDataSource::myConfigureInstance();\n  // ...\n\n  return ret;\n}\n*/\n\nint cBowProducer::configureWriter(sDmLevelConfig &c)\n{\n  // configure your writer by setting values in &c\n  c.T = 0; /* a-periodic level */\n  return 1;\n}\n\n/*\nint isEmptyLine(const char *line, int n)\n{\n  int i;\n  int empty=1;\n  if ((n==0)||(n>strlen(line))) n=strlen(line);\n  for (i=0; i<n; i++) {\n    if ( (line[i] != ' ')&&(line[i] != '\\t')&&(line[i] != '\\n') ) {\n      empty = 0; break;\n    }\n  }\n  return empty;\n}\n*/\n\nint cBowProducer::loadKwList()\n{\n  if (kwList != NULL) {\n    FILE * f = fopen(kwList,\"r\");\n    if (f==NULL) {\n      SMILE_IERR(1,\"cannot open keyword list file '%s' (fopen failed)!\",kwList);\n      return 0;\n    }\n    int lineNr=0;\n    int ret=1;\n    char *line = NULL;\n    size_t n,read; int len;\n\n    do {\n      read = smile_getline(&line, &n, f);\n      if ((read != (size_t)-1)&&(line!=NULL)) {\n        lineNr++;\n        len=(int)strlen(line);\n        if (len>0) { if (line[len-1] == '\\n') { line[len-1] = 0; len--; } }\n        if (len>0) { if (line[len-1] == '\\r') { line[len-1] = 0; len--; } }\n        while (((line[0] == ' ')||(line[0] == '\\t'))&&(len>=0)) { line[0] = 0; line++; len--; }\n        if (len > 0) {\n          if ((!kwListPrefixFilter)||(prefix == NULL)||(!strncmp(line,prefix,MIN(strlen(prefix),strlen(line))))) {\n            numKw++;\n            keywords = (char**)realloc(keywords,numKw*sizeof(char*));\n            keywords[numKw-1] = strdup(line);\n            SMILE_IDBG(4,\"read keyword '%s' from keyword list\",keywords[numKw-1]);\n          }\n        }\n      } else { break; }\n    } while (read != (size_t)-1);\n    if (line != NULL) free(line);\n\n    SMILE_IDBG(4,\"read %i keywords from keyword list '%s'\",numKw,kwList);\n    fclose(f);\n    return 1;\n  }\n  return 0;\n}\n\n// NOTE: nEl is always 0 for dataSources....\nint cBowProducer::setupNewNames(long nEl)\n{\n  /* load names from keyword list file */\n  if (!loadKwList()) {\n    SMILE_IERR(1,\"failed loading keyword list '%s'\",kwList);\n    COMP_ERR(\"aborting!\");\n  }\n\n  // if used in offline mode, check if textfile (input sentences) exists\n  if (textfile != NULL) {\n    filehandle = fopen(textfile,\"r\");\n    if (filehandle == NULL) {\n      SMILE_IERR(1,\"could not open input textfile '%s' for reading!\",textfile);\n      COMP_ERR(\"aborting!\");\n    } \n  }\n\n  // configure dateMemory level, names, etc.\n  int i;\n  for (i=0; i<numKw; i++) {\n    char *tmp;\n    if ((kwListPrefixFilter)&&(prefix != NULL)) {\n      writer_->addField(keywords[i],1);\n    } else {\n      if (prefix != NULL) {\n        tmp = myvprint(\"%s%s\",prefix,keywords[i]);\n      } else {\n        tmp = myvprint(\"BOW_%s\",keywords[i]);\n      }\n      writer_->addField(tmp,1);\n      free(tmp);\n    }\n  }\n\n  namesAreSet_=1;\n  allocVec(numKw); //??\n  return numKw;\n}\n\n/*\nint cBowProducer::myFinaliseInstance()\n{\n  return cDataSource::myFinaliseInstance();\n}\n*/\n#include <classifiers/julius/kwsjKresult.h>\n\n\n\n\nint cBowProducer::buildBoW( cComponentMessage *_msg )\n{\n  // build bag of words vector in 'vec' based on keywords in message\n  //Kresult *k = (Kresult *)(_msg->custData);\n  juliusResult *k = (juliusResult *)(_msg->custData);\n  int i,j;\n    // find keyword in list\n    // k->keyword[i]\n    // set index in vector\n  for (j=0; j<numKw; j++) {\n    int found = 0;\n    for (i=0; i<k->numW; i++) {\n      // NOTE: keyword comparison is case INsensitive ! is that ok?\n      if (!strcasecmp( k->word[i], keywords[j] )) {\n        vec_->dataF[j] = 1.0; found=1;\n        break;\n      }\n    }\n    if (found==0) vec_->dataF[j] = 0.0;\n  }\n  return 1; // was: 0,  does 1 break anything??\n}\n\nint cBowProducer::buildBoW( const char * str )\n{\n  int i,j;\n\n  if (str == NULL) return 0;\n\n  // split string into words at whitespaces\n  // and build bow vector...\n  \n  char * tmp = strdup(str);\n  int len = smileUtil_stripline(&tmp);\n  char * curWord = tmp;\n\n\n  // initialise BoW vector to zero:\n  \n  for (j=0; j<numKw; j++) {\n    vec_->dataF[j] = 0.0;\n  }\n\n  for (i=0; i<=len; i++) {\n\n    if (tmp[i] == ' ' || tmp[i] == 0) {\n      tmp[i] = 0;\n\n      // look for current word in keyword list...\n      //int found = 0;\n      for (j=0; j<numKw; j++) {\n        // NOTE: keyword comparison is case INsensitive ! is that ok?\n        if (!strcasecmp( curWord, keywords[j] )) {\n          vec_->dataF[j] = 1.0; //found=1;\n          break; // this assumes each word in kwlist is unique...? TODO: warn if words are not unique!\n        }\n      }\n  \n\n      i++;\n      while(tmp[i] == ' ' && i<len) { i++; }\n      curWord = tmp+i;\n    }\n\n  }\n\n  free(tmp);\n  return 1;\n}\n\nint cBowProducer::processComponentMessage( cComponentMessage *_msg )\n{\n  if (isMessageType(_msg,\"turnFrameTime\")) {\n    // write current keyword status\n    // the output is only written when a turn-frame time message is received (this ensures sync)\n    SMILE_IDBG(3,\"received 'turnFrameTime' message\");\n    if (syncWithAudio) {\n      writer_->setNextFrame(vec_);\n      dataFlag = 1;\n    }\n    //return queNextFrameData(_msg->floatData[0], _msg->floatData[1], _msg->intData[0]);\n  } else if (isMessageType(_msg,\"asrKeywordOutput\")) {  \n    SMILE_IDBG(3,\"received 'asrKeywordOutput' message\");\n    buildBoW(_msg);\n    if (!syncWithAudio) {\n      writer_->setNextFrame(vec_);\n      dataFlag = 1;\n    }\n    return 1;  // message was processed\n  } else if (isMessageType(_msg,\"textString\")) {  \n    SMILE_IDBG(3,\"received 'textString' message\");\n    buildBoW((const char *)(_msg->custData));\n    if (!syncWithAudio) {\n      writer_->setNextFrame(vec_);\n      dataFlag = 1;\n    }\n    return 1;  // message was processed\n  }\n\n  return 0;\n}\n\n\nint cBowProducer::myTick(long long t)\n{\n  if (textfile != NULL) {\n     \n  /* TODO: offline bow mode:\n     accept an array of sentences through the config and run buildBow during the first ticks for each sentence\n     then write the resulting bow vectors to the output until all have been processed and saved\n  */\n    if (txtEof) return 0;\n\n    if (filehandle == NULL) { \n      // open the input text file, if not yet opened.. (this should not happen actually as we open it during the init phase..)\n      filehandle = fopen(textfile,\"r\");\n      SMILE_IWRN(1,\"re-opening input text file, will read input from 1st line\");\n      lineNr=0;\n      if (filehandle == NULL) {\n        SMILE_IERR(1,\"error opening input text file for reading ('%s').\\n\",textfile);\n      }\n    }\n\n    // read next line\n    long read;\n    read = (long)smile_getline(&line, &line_n, filehandle);\n    if ((read != -1)&&(line!=NULL)) {\n      lineNr++;\n      // call buildBow\n      if (buildBoW(line)) {\n        writer_->setNextFrame(vec_);\n        return 1;\n      }\n\n    } else {\n      // if EOF, close file and filehandle=NULL;\n      fclose(filehandle); filehandle=NULL;\n      if (line != NULL) {\n        free(line);\n        line = NULL;\n      }\n      txtEof=1;\n      if (lineNr <= 0) {\n        SMILE_IWRN(1,\"<= 0 lines read from text input file '%s'! The file seems to be empty..?\",textfile);\n      } else {\n        SMILE_IMSG(3,\"read %i sentences (lines) from text input file '%s'. EOF reached, no more BoW output will be generated now.\",lineNr,textfile);\n      }\n    }\n\n    \n  } else if (singleSentence != NULL) { // single sentence from commandline\n    \n    if (txtEof) return 0;\n\n    if (buildBoW(singleSentence)) {\n      txtEof = 1;\n      writer_->setNextFrame(vec_);\n      return 1;\n    } \n\n  } else { // on-line, message-based mode:\n\n    if (dataFlag) {\n      dataFlag = 0;\n      return 1;\n    } \n\n  }\n  return 0;\n}\n\n\ncBowProducer::~cBowProducer()\n{\n  int i;\n  if (keywords != NULL) {\n    for (i=0; i<numKw; i++) {\n      free(keywords[i]);\n    } \n    free(keywords);\n  }\n\n  if (filehandle != NULL) fclose(filehandle);\n  if (line != NULL) free(line);\n}\n"
  },
  {
    "path": "src/other/maxIndex.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: cMaxIndex\n\ncomputes Mel-Frequency-Cepstral Coefficients (MFCC) from Mel-Spectrum\n\n*/\n\n\n#include <other/maxIndex.hpp>\n#include <set>\n\n#define MODULE \"cMaxIndex\"\n\n\nSMILECOMPONENT_STATICS(cMaxIndex)\n\nSMILECOMPONENT_REGCOMP(cMaxIndex)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CMAXINDEX;\n  sdescription = COMPONENT_DESCRIPTION_CMAXINDEX;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"nameAppend\", NULL, \"maxIndex\");\n    // TODO: Thresholding?\n    ct->setField(\"nIndices\", \"The number of indices to compute\", 1);\n    ct->setField(\"minFeature\", \"Start with this feature in computing the maximum index (1 = first feature)\", 1);\n    ct->setField(\"maxFeature\", \"End with this feature in computing the maximum index (0 = last feature)\", 0);\n    ct->setField(\"randNoise\", \"If > 0, add random noise with given range (+-'randNoise') to index values.\", 0.0);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cMaxIndex);\n}\n\nSMILECOMPONENT_CREATE(cMaxIndex)\n\n//-----\n\ncMaxIndex::cMaxIndex(const char *_name) :\n  cVectorProcessor(_name),\n  nIndices(1),\n  minFeature(1),\n  maxFeature(0)\n{\n\n}\n\nvoid cMaxIndex::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n  \n  nIndices = getInt(\"nIndices\");\n  minFeature = getInt(\"minFeature\");\n  maxFeature = getInt(\"maxFeature\");\n  noise = (FLOAT_DMEM)getDouble(\"randNoise\");\n}\n\n/*\nint cMaxIndex::myConfigureInstance()\n{\n  int ret=1;\n  ret *= cVectorProcessor::myConfigureInstance();\n  if (ret == 0) return 0;\n\n  \n  return ret;\n}\n*/\n\n/*int cMaxIndex::dataProcessorCustomFinalise()\n{\n  //  Nfi = reader->getLevelNf();\n\n  // allocate for multiple configurations..\n  if (sintable == NULL) sintable = (FLOAT_DMEM**)multiConfAlloc();\n  if (costable == NULL) costable = (FLOAT_DMEM**)multiConfAlloc();\n\n  return cVectorProcessor::dataProcessorCustomFinalise();\n}*/\n\n/*\nint cMaxIndex::configureWriter(const sDmLevelConfig *c)\n{\n  if (c==NULL) return 0;\n  \n  // you must return 1, in order to indicate configure success (0 indicated failure)\n  return 1;\n}\n*/\n\nint cMaxIndex::setupNamesForField(int i, const char*name, long nEl)\n{\n  // XXX: include min/maxFeature parameters?\n  //name=\"maxIndex\";\n  if ((nameAppend_ != NULL)&&(strlen(nameAppend_)>0)) {\n    addNameAppendField(name,nameAppend_,nIndices,0);\n  } else {\n    writer_->addField( \"maxIndex\", nIndices, 0);\n  }\n  return nIndices;\n}\n\n\n/*\nint cMaxIndex::myFinaliseInstance()\n{\n  int ret;\n  ret = cVectorProcessor::myFinaliseInstance();\n  return ret;\n}\n*/\n\n// a derived class should override this method, in order to implement the actual processing\n/*\nint cMaxIndex::processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  // do domething to data in *src, save result to *dst\n  // NOTE: *src and *dst may be the same...\n  \n  return 1;\n}\n*/\n\n// a derived class should override this method, in order to implement the actual processing\nint cMaxIndex::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  int i,k;\n  int last;\n\n  if (maxFeature == 0) last = (int)Nsrc;\n  else last = maxFeature;\n\n  SMILE_IDBG(2,\"maxFeature = %i\",maxFeature);\n  std::set<int> indices;\n  for (k = 0; k < nIndices; ++k) {\n    double max = 0.0;\n    int maxIndex = 1;\n    for (i = minFeature; i <= last; ++i) {\n      if (indices.find(i) == indices.end()) {\n        double elem = fabs(src[i-1]);\n        if (elem > max) {\n          max = elem;\n          maxIndex = i;\n        }\n      }\n    }\n    indices.insert(maxIndex);\n    FLOAT_DMEM x = (FLOAT_DMEM)maxIndex;\n    if (noise > 0.0) {\n      x += (FLOAT_DMEM)(rand()/RAND_MAX) * noise;\n    }\n    dst[k] = x;\n  }\n  return 1;\n}\n\ncMaxIndex::~cMaxIndex()\n{\n}\n\n"
  },
  {
    "path": "src/other/valbasedSelector.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component: valbased selector\n\nvector selector based on threshold of value <idx>\n\n*/\n\n\n#include <other/valbasedSelector.hpp>\n\n#define MODULE \"cValbasedSelector\"\n\nSMILECOMPONENT_STATICS(cValbasedSelector)\n\nSMILECOMPONENT_REGCOMP(cValbasedSelector)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CVALBASEDSELECTOR;\n  sdescription = COMPONENT_DESCRIPTION_CVALBASEDSELECTOR;\n\n  // we inherit cDataProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataProcessor\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"threshold\",\"Threshold for selection (see also 'invert' option)\",1.0);\n    ct->setField(\"adaptiveThreshold\", \"1/0 = on/off, use an adaptive threshold given by a running average (see adaptationLength[Sec] option).\", 0);\n    ct->setField(\"adaptationLengthSec\", \"Length of running average for adaptive threshold in seconds\", 2.0);\n    ct->setField(\"adaptationLength\", \"Length of running average for adaptive threshold in frames (if set, overrides the adaptationLengthSec; also used as default if neither option is specified)\", 200);\n    ct->setField(\"debugAdaptiveThreshold\", \"If > 0, the interval (in frames) at which to output the current adaptive threshold to the log at log-level 3.\", 0);\n    ct->setField(\"idx\", \"The index of element to base the selection decision on. Currently only 1 element is supported, NO vector based thresholds etc. are possible.\",0);\n    ct->setField(\"invert\", \"1 = output the frame when element[idx] < threshold ; 0 = output the frame if element[idx] => threshold\",0);\n    ct->setField(\"allowEqual\", \"if this option is set to 1, output the frame also, when element[idx] == threshold\",0);\n    ct->setField(\"removeIdx\", \"1 = remove field element[idx] in output vector ; 0 = keep it\",0);\n    ct->setField(\"zeroVec\" , \"1 = instead of not writing output to the output level if selection threshold is not met, output a vector with all values set to 'outputVal', which is 0 by default (removeIdx options still has the same effect).\", 0);\n    ct->setField(\"outputVal\" , \"Value all output elements will be set to when 'zeroVec=1'.\", 0.0)\n  )\n  \n  SMILECOMPONENT_MAKEINFO(cValbasedSelector);\n}\n\n\nSMILECOMPONENT_CREATE(cValbasedSelector)\n\n//-----\n\ncValbasedSelector::cValbasedSelector(const char *_name) :\n  cDataProcessor(_name),\n  myVec(NULL), idx(0), invert(0), removeIdx(0), threshold(0.0), outputVal(0.0), zerovec(0), elI(0),\n  valBuf_(NULL), valBufSize_(0), valBufIdx_(0),\n  valBufSum_(0.0), valBufN_(0.0)\n{\n}\n\nvoid cValbasedSelector::fetchConfig()\n{\n  cDataProcessor::fetchConfig();\n\n  // load all configuration parameters you will later require fast and easy access to here:\n\n  threshold = (FLOAT_DMEM)getDouble(\"threshold\");\n  SMILE_DBG(2,\"threshold = %f\",threshold);\n\n  adaptiveThreshold_ = (int)getInt(\"adaptiveThreshold\");\n  debugAdaptiveThreshold_ = (int)getInt(\"debugAdaptiveThreshold\");\n\n  idx = getInt(\"idx\");\n  invert = getInt(\"invert\");\n  allowEqual = getInt(\"allowEqual\");\n  removeIdx = getInt(\"removeIdx\");\n\n  outputVal = (FLOAT_DMEM)getDouble(\"outputVal\");\n  zerovec = getInt(\"zeroVec\");\n}\n\n\nint cValbasedSelector::setupNamesForField(int i, const char*name, long nEl)\n{\n  elI+=nEl;\n  if (removeIdx && elI-nEl <= idx && idx < elI) nEl--;\n\n  if (nEl > 0) {\n    if (copyInputName_) {\n      addNameAppendField( name, nameAppend_, nEl );\n    } else {\n      addNameAppendField( NULL, nameAppend_, nEl );\n    }\n  }\n  return nEl;\n}\n\nint cValbasedSelector::myFinaliseInstance()\n{\n  int ret = cDataProcessor::myFinaliseInstance();\n\n  if (adaptiveThreshold_) {\n    if (isSet(\"adaptationLength\")) {\n      valBufSize_ = (int)getInt(\"adaptationLength\");\n    } else {\n      if (isSet(\"adaptationLengthSec\")) {\n        const sDmLevelConfig *c = reader_->getLevelConfig();\n        double T = c->T;\n        double len = getDouble(\"adaptationLengthSec\");\n        if (T > 0.0) {\n          valBufSize_ = (int)floor(len / T);\n        } else {\n          valBufSize_ = (int)getInt(\"adaptationLength\");\n          SMILE_IERR(2, \"input level (%s) frame period is 0, cannot convert adaptationLengthSec to frames, please specify the length directly in frames with the adaptationLength option! Falling back to adaptationLength option (%i)\", c->name, valBufSize_);\n        }\n      } else {\n        // use the default of the adaptationLength option\n        valBufSize_ = (int)getInt(\"adaptationLength\");\n      }\n    }\n    if (valBufSize_ <= 0) {\n      SMILE_IERR(1, \"No value <= 0 allowed for the adaptationLength option. Setting a fall-back default of 200 (frames).\");\n      valBufSize_ = 200;\n    }\n    if (valBuf_ != NULL) {\n      free(valBuf_);\n    }\n    valBuf_ = (FLOAT_DMEM *)calloc(1, sizeof(FLOAT_DMEM));\n    valBufIdx_ = 0;\n    valBufSum_ = 0.0;\n    valBufN_ = 0.0;\n    valBufRefreshCnt_ = 0;\n  }\n  return ret;\n}\n\n\nint cValbasedSelector::myTick(long long t)\n{\n  SMILE_IDBG(4,\"tick # %i, processing value vector\",t);\n\n  // get next frame from dataMemory\n  cVector *vec = reader_->getNextFrame();\n  if (vec == NULL) {\n    return 0;\n  }\n\n  // add offset\n  int i = idx;\n  if (i >= vec->N) i = vec->N-1;\n  FLOAT_DMEM val = vec->dataF[i];\n\n  int copy = 0;\n  if (adaptiveThreshold_) {\n    if (valBufN_ < valBufSize_) {\n      valBuf_[valBufIdx_] = val;\n      valBufSum_ += val;\n      valBufN_ += 1.0;\n    } else {\n      valBufSum_ -= valBuf_[valBufIdx_];\n      valBuf_[valBufIdx_] = val;\n      valBufSum_ += val;\n      valBufRefreshCnt_++;\n      if (valBufRefreshCnt_ > 10000) {\n        valBufRefreshCnt_ = 0;\n        FLOAT_DMEM oldSum = valBufSum_;\n        valBufSum_ = 0.0;\n        for (int i = 0; i < valBufSize_; i++) {\n          valBufSum_ += valBuf_[i];\n        }\n        SMILE_IMSG(3, \"re-initialised threshold running average buffer after 10000 frames to keep numeric precision. drift is (old - new): %f\", oldSum - valBufSum_);\n      }\n      // TODO: after a couple thousand frames we might want to re-init the buffer\n      // to avoid slight drift due to numerical inaccuracies!\n    }\n    valBufIdx_++;\n    if (valBufIdx_ >= valBufSize_) {\n      valBufIdx_ = 0;\n    }\n    if (valBufN_ > 0) {\n      threshold = valBufSum_ / valBufN_;\n    } else {\n      copy = 1;\n    }\n    if (debugAdaptiveThreshold_ > 0 && valBufRefreshCnt_ > 0 && valBufRefreshCnt_ % debugAdaptiveThreshold_ == 0) {\n      SMILE_IMSG(3, \"Adaptive threshold is: %e\", threshold);\n    }\n  }\n\n  if ( ((!invert)&&(val > threshold)) || ((invert)&&(val < threshold))\n       || (allowEqual && (val==threshold)) ) {\n    copy = 1;\n  }\n  \n  if (copy) {\n    // TODO: remove threshold value if removeIdx == 1\n    if (removeIdx == 1) {\n\n      if (myVec==NULL) myVec = new cVector(vec->N-1 , vec->type);\n      int j,n=0;\n      for(j=0; j<vec->N; j++) {\n        if (j!=i) {\n          myVec->dataF[n] = vec->dataF[j];\n          n++;\n        }\n      }\n      myVec->tmetaReplace(vec->tmeta);\n      //myVec->tmeta->cloneFrom();\n      // save to dataMemory\n      writer_->setNextFrame(myVec);\n      //delete myVec;\n\n    } else {\n      // save to dataMemory\n      writer_->setNextFrame(vec);\n    }\n  } else {\n    if (zerovec==1) {\n      int j;\n      // output a zero (or predefined value) vector\n      if (removeIdx == 1) {\n        if (myVec==NULL) myVec = new cVector(vec->N-1 , vec->type);\n        for(j=0; j<myVec->N; j++) {\n          myVec->dataF[j] = outputVal;\n        }\n        myVec->tmetaReplace(vec->tmeta);\n        writer_->setNextFrame(myVec);\n      } else {\n        for(j=0; j<vec->N; j++) {\n          vec->dataF[j] = outputVal;\n        }\n        writer_->setNextFrame(vec);\n      }\n    }\n  }\n\n  return 1;\n}\n\n\ncValbasedSelector::~cValbasedSelector()\n{\n  // cleanup...\n  if (myVec != NULL) {\n    delete myVec;\n  }\n  if (valBuf_ != NULL) {\n    free(valBuf_);\n  }\n}\n\n"
  },
  {
    "path": "src/other/vectorConcat.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nconcatenates vectors from multiple levels and copy to another level\n\n*/\n\n\n#include <other/vectorConcat.hpp>\n\n#define MODULE \"cVectorConcat\"\n\nSMILECOMPONENT_STATICS(cVectorConcat)\n\nSMILECOMPONENT_REGCOMP(cVectorConcat)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CVECTORCONCAT;\n  sdescription = COMPONENT_DESCRIPTION_CVECTORCONCAT;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n  \n    SMILECOMPONENT_IFNOTREGAGAIN( {}\n    //ct->setField(\"expandFields\", \"expand fields to single elements, i.e. each field in the output will correspond to exactly one element in the input [not yet implemented]\", 0);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cVectorConcat);\n}\n\nSMILECOMPONENT_CREATE(cVectorConcat)\n\n//-----\n\ncVectorConcat::cVectorConcat(const char *_name) :\n  cVectorProcessor(_name)\n{\n}\n\n\nint cVectorConcat::processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  if (dst!=src)\n    memcpy( dst, src,  MIN(Ndst,Nsrc)*sizeof(INT_DMEM) );\n  return 1;\n}\n\nint cVectorConcat::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  if (dst!=src)\n    memcpy( dst, src,  MIN(Ndst,Nsrc)*sizeof(FLOAT_DMEM) );\n  return 1;\n}\n\ncVectorConcat::~cVectorConcat()\n{\n}\n\n"
  },
  {
    "path": "src/other/vectorOperation.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\ndo elementary operations on vectors \n(i.e. basically everything that does not require history or context,\n everything that can be performed on single vectors w/o external data (except for constant parameters, etc.))\n\n*/\n\n\n\n#include <other/vectorOperation.hpp>\n#include <cmath>\n\n#define MODULE \"cVectorOperation\"\n\n\nSMILECOMPONENT_STATICS(cVectorOperation)\n\nSMILECOMPONENT_REGCOMP(cVectorOperation)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CVECTOROPERATION;\n  sdescription = COMPONENT_DESCRIPTION_CVECTOROPERATION;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cVectorProcessor\")\n\n  // if the inherited config type was found, we register our configuration variables\n  SMILECOMPONENT_IFNOTREGAGAIN( {} // <- this is only to avoid compiler warnings...\n    // name append has a special role: it is defined in cDataProcessor, and can be overwritten here:\n      // if you set description to NULL, the existing description will be used, thus the following call can\n      // be used to update the default value:\n    //ct->setField(\"nameAppend\",NULL,\"processed\");\n  ct->setField(\"operation\",\"A string which specifies the type of operation to perform:\\n   norm = normalise vector length (euclidean norm, L2) to 1\\n   nr1 = normalise range to +1, -1\\n   nr0 = normalise range to +1, 0\\n   mul = multiply vector by param1\\n   add = add param1 to each element\\n   log = compute natural logarithm\\n   lgA = compute logarithm to base param1\\n   nl1 = normalise vector sum (L1 norm) to 1\\n   sqrt = compute square root\\n   pow = take values to the power of param1\\n   exp = raise param1 to the power of the vector elements\\n   ee = raise the base e to the power of the vector elements\\n   abs = take absolute value of each element\\n   agn = add Gaussian noise with mean param1 and std.dev. param2\\n   min = take the min of vector and param1\\n   max = take the max of vector and param1\\n   sum = compute sum of vector elements, there will be a single output only\\n   ssm = compute sum of squared vector elements, there will be a single output only\\n   ll1 = compute sum of vector elements normalised by the number of vector elements, there will be a single output only\\n   ll2 = compute euclidean length (root of sum of squares normalised by vector length), there will be a single output only\\n   fla(tten) = flattening of comb filter energy spectra, as in 2007 ICASSP Paper and Ballroom dance style recognition.\\n   dBp = convert a power to decibel with 10*log10(x).\\n   dBv = convert an amplitude/magnitude/voltage to decibel with 20*log10(x)\\n   fconv_aaa_bbb = convert frequency from scale aaa to scale bbb\\n     lin = linear (Hz)\\n     bark = Bark (Traunmueller, 1990)\\n     mel = Mel-scale\\n     oct = semitone/octave scale (music), param1 = freq. of first note in Hz.\", \"norm\");\n  ct->setField(\"param1\",\"parameter 1\", 1.0);\n  ct->setField(\"param2\",\"parameter 2\", 1.0);\n  ct->setField(\"logfloor\",\"floor for log operation\", 0.000000000001);\n  ct->setField(\"powOnlyPos\",\"if 'operation' = 'pow', do not take negative values to the power of 'param1'; instead, output 0. This is necessary to avoid 'nan' values if the exponent is rational. \", 0);\n  ct->setField(\"nameBase\",\"base of output feature name when performing n->1 mapping operations (currently 'euc' and 'sum')\", (const char*)NULL);\n  ct->setField(\"appendOperationToName\", \"(1/0 = yes/no) append the operation name from the 'operation' option to the feature name. This will override any nameAppend option (inherited from cDataProcessor).\", 0);\n  )\n\n  // The configType gets automatically registered with the config manger by the SMILECOMPONENT_IFNOTREGAGAIN macro\n  \n  // we now create out sComponentInfo, including name, description, success status, etc. and return that\n  SMILECOMPONENT_MAKEINFO(cVectorOperation);\n}\n\nSMILECOMPONENT_CREATE(cVectorOperation)\n\n//-----\n\ncVectorOperation::cVectorOperation(const char *_name) :\n  cVectorProcessor(_name),\n  param1(0.0),\n  param2(0.0),\n  nameBase(NULL),\n  operationString_(NULL),\n  targFreqScaleStr(NULL)\n{\n\n}\n\nvoid cVectorOperation::fetchConfig()\n{\n  cVectorProcessor::fetchConfig();\n\n  param1 = (FLOAT_DMEM)getDouble(\"param1\");\n  param2 = (FLOAT_DMEM)getDouble(\"param2\");\n  powOnlyPos = (int)getInt(\"powOnlyPos\");\n  fscaleA = SPECTSCALE_LINEAR;\n  fscaleB = SPECTSCALE_LINEAR;\n\n  const char * op = getStr(\"operation\");\n  operation=VOP_NORMALISE;\n  if (!strncmp(op,\"nor\",3)) {\n    operation=VOP_NORMALISE;\n  } else if (!strncmp(op,\"nr1\",3)) {\n    operation=VOP_NORM_RANGE1;\n  } else if (!strncmp(op,\"nr0\",3)) {\n    operation=VOP_NORM_RANGE0;\n  } else if (!strncmp(op,\"mul\",3)) {\n    operation=VOP_MUL;\n  } else if (!strncmp(op,\"add\",3)) {\n    operation=VOP_ADD;\n  } else if (!strncmp(op,\"log\",3)) {\n    operation=VOP_LOG;\n  } else if (!strncmp(op,\"lgA\",3)) {\n    operation=VOP_LOGA;\n    if (param1 <= 0) {\n      SMILE_IWRN(1,\"log-base cannot be negative! setting base to exp(1) (-> natural logarithm)\");\n      param1 = (FLOAT_DMEM)std::exp(1.0);\n    }\n    if (param1 == 1.0) {\n      SMILE_IWRN(1,\"log-base cannot be 1.0! setting base to exp(1) (-> natural logarithm)\");\n      param1 = (FLOAT_DMEM)std::exp(1.0);\n    }\n  } else if (!strncmp(op,\"nl1\",3)) {\n    operation=VOP_NORMALISE_L1;\n  } else if (!strncmp(op,\"sqr\",3)) {\n    operation=VOP_SQRT;\n  } else if (!strncmp(op,\"pow\",3)) {\n    operation=VOP_POW;\n  } else if (!strncmp(op,\"exp\",3)) {\n    operation=VOP_EXP;\n  } else if (!strncmp(op,\"ee\",2)) {\n    operation=VOP_E;\n  } else if (!strncmp(op,\"abs\",3)) {\n    operation=VOP_ABS;\n  } else if (!strncmp(op,\"agn\",3)) {\n    operation=VOP_AGN;\n  } else if (!strncmp(op,\"min\",3)) {\n    operation=VOP_MIN;\n  } else if (!strncmp(op,\"max\",3)) {\n    operation=VOP_MAX;\n  } else if (!strncmp(op,\"sum\",3)) {\n    operation=VOP_X_SUM;\n  } else if (!strncmp(op,\"ssm\",3)) {\n    operation=VOP_X_SUMSQ;\n  } else if (!strncmp(op,\"ll1\",3)) {\n    operation=VOP_X_L1;\n  } else if (!strncmp(op,\"ll2\",3)) {\n    operation=VOP_X_L2;\n  } else if (!strncmp(op,\"fla\",3)) {\n      operation=VOP_FLATTEN;\n  } else if (!strncmp(op,\"dBp\",3)) {\n    operation=VOP_DB_POW;\n  } else if (!strncmp(op,\"dBv\",3)) {\n    operation=VOP_DB_MAG;\n  } else if (!strncmp(op,\"fconv_\",6)) {\n    const char * strA = op+6;\n    const char * strB = NULL;\n    operation=VOP_FCONV;\n    if (!strncmp(strA, \"lin_\", 4)) {\n      fscaleA = SPECTSCALE_LINEAR;\n      strB = strA + 4;\n    }\n    else if (!strncmp(strA, \"linear_\", 7)) {\n      fscaleA = SPECTSCALE_LINEAR;\n      strB = strA + 7;\n    }\n    else if (!strncmp(strA, \"bark_\", 5)) {\n      fscaleA = SPECTSCALE_BARK;\n      strB = strA + 5;\n    }\n    else if (!strncmp(strA, \"mel_\", 4)) {\n      fscaleA = SPECTSCALE_MEL;\n      strB = strA + 4;\n    }\n    else if (!strncmp(strA, \"oct_\", 4)) {\n      fscaleA = SPECTSCALE_SEMITONE;\n      strB = strA + 4;\n    }\n    else if (!strncmp(strA, \"octave_\", 7)) {\n      fscaleA = SPECTSCALE_SEMITONE;\n      strB = strA + 7;\n    }\n    else if (!strncmp(strA, \"semitone_\", 9)) {\n      fscaleA = SPECTSCALE_SEMITONE;\n      strB = strA + 9;\n    }\n    else if (!strncmp(strA, \"semi_\", 5)) {\n      fscaleA = SPECTSCALE_SEMITONE;\n      strB = strA + 5;\n    }\n    else {\n      SMILE_IERR(1, \"Unknown frequency scales '%s'. Using 'lin'(ear) for scale A and B.\", strA);\n      strB = NULL;\n    }\n\n    if (strB != NULL) {\n      if (!strncmp(strB, \"lin\", 3)) {\n        fscaleB = SPECTSCALE_LINEAR;\n        targFreqScaleStr = \"linearHzScale\";\n      }\n      else if (!strncmp(strB, \"bark\", 4)) {\n        fscaleB = SPECTSCALE_BARK;\n        targFreqScaleStr = \"barkScale\";\n      }\n      else if (!strncmp(strB, \"mel\", 3)) {\n        fscaleB = SPECTSCALE_MEL;\n        targFreqScaleStr = \"melScale\";\n      }\n      else if (!strncmp(strB, \"oct\", 3)) {\n        fscaleB = SPECTSCALE_SEMITONE;\n        targFreqScaleStr = \"octaveScale\";\n      }\n      else if (!strncmp(strB, \"semi_\", 4)) {\n        fscaleB = SPECTSCALE_SEMITONE;\n        targFreqScaleStr = \"octaveScale\";\n      } else {\n        SMILE_IERR(1, \"unknown operation B '%s' specified in config file. Using 'lin'(ear) for scale B.\", strB);\n      }\n    } else {\n      SMILE_IERR(1, \"unknown operation B '%s' specified in config file. Using 'lin'(ear) for scale B.\", strB);\n    }\n    SMILE_PRINT(\"fscale conversion: %i to %i  \", fscaleA, fscaleB);\n  }\n\n  if (getInt(\"appendOperationToName\")) {\n    if (operation == VOP_LOGA) {\n      operationString_ = myvprint(\"%s%.1f\", op, param1);\n    } else {\n      operationString_ = myvprint(\"%s\", op);\n    }\n  }\n  nameBase = getStr(\"nameBase\");\n\n  logfloor = (FLOAT_DMEM)getDouble(\"logfloor\");\n  if (logfloor <= 0) { \n    SMILE_IWRN(1,\"log-floor cannot be <= 0 ! setting to 0.00000000001 !\");\n    logfloor = (FLOAT_DMEM)0.000000000001;\n  }\n}\n\nint cVectorOperation::setupNamesForField(int i, const char*name, long nEl)\n{\n  if (operation == VOP_FCONV) {\n    if (nameAppend_ == NULL || nameAppend_[0] == 0) {\n      nameAppend_ = targFreqScaleStr;\n    }\n  }\n  else if (operation > VOP_X) {\n    if (nameAppend_ == NULL || nameAppend_[0] == 0) {\n      if (operation == VOP_X_SUM) nameAppend_ = \"sum\";\n      if (operation == VOP_X_SUMSQ) nameAppend_ = \"sumSq\";\n      if (operation == VOP_X_L1) nameAppend_ = \"lengthL1norm\";\n      if (operation == VOP_X_L2) nameAppend_ = \"lengthL2norm\";\n    }\n    nEl = 1;\n  } else {\n    if (operationString_ != NULL) {\n      nameAppend_ = operationString_;\n    }\n  }\n  if (nameBase != NULL && nameBase[0] != 0) {\n    name = nameBase;\n  }\n  return cVectorProcessor::setupNamesForField(i, name, nEl);\n}\n\n/*\nint cVectorOperation::setupNewNames(long ni)\n{\n  return 0;\n\n  long No=0;\n\n  if (operation > VOP_X) {\n    No = 1;\n    if (copyInputName_) {\n      if (operation == VOP_X_SUM) addNameAppendField(nameBase,\"sum\",1,0);\n      if (operation == VOP_X_SUMSQ) addNameAppendField(nameBase,\"sumSq\",1,0);\n      if (operation == VOP_X_L1) addNameAppendField(nameBase,\"lengthL1norm\",1,0);\n      if (operation == VOP_X_L2) addNameAppendField(nameBase,\"lengthL2norm\",1,0);\n      namesAreSet_ = 1;\n    } else {\n      if (nameAppend_ != NULL && nameAppend_[0] != 0) {\n        addNameAppendField(NULL, nameAppend_, 1, 0);\n      }\n    }\n  } else {\n    // TODO: append name of operation to output!\n      // set nameAppend variable?\n    if (operationString_ != NULL) {\n      nameAppend_ = operationString_;\n    }\n  }\n  return No;\n}\n*/\n\n// a derived class should override this method, in order to implement the actual processing\nint cVectorOperation::processVectorInt(const INT_DMEM *src, INT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  // do domething to data in *src, save result to *dst\n  // NOTE: *src and *dst may be the same...\n  \n  return 1;\n}\n\n// a derived class should override this method, in order to implement the actual processing\nint cVectorOperation::processVectorFloat(const FLOAT_DMEM *src, FLOAT_DMEM *dst, long Nsrc, long Ndst, int idxi) // idxi=input field index\n{\n  // do domething to data in *src, save result to *dst\n  // NOTE: *src and *dst may be the same...\n  FLOAT_DMEM sum =0.0;\n  FLOAT_DMEM max, min, range;\n  FLOAT_DMEM factor = 1.0;\n  long i;\n  switch(operation) {\n    case VOP_NORMALISE:\n      // normalise L2 norm of all incoming vectors\n      for (i=0; i<MIN(Nsrc,Ndst); i++) {\n        sum+=src[i]*src[i];\n      }\n      if (sum <= 0.0) {\n        sum = 1.0;\n      }\n      sum = sqrt(sum/(FLOAT_DMEM)(MIN(Nsrc,Ndst)));\n      for (i=0; i<MIN(Nsrc,Ndst); i++) {\n        dst[i] = src[i] / sum;\n      }\n\n      break;\n\n    case VOP_NORMALISE_L1:\n\n      // normalise L1 norm of all incoming vectors\n      for (i=0; i<MIN(Nsrc,Ndst); i++) {\n        sum+=src[i];\n      }\n      if (sum <= 0.0) {\n        sum = 1.0;\n      }\n      for (i=0; i<MIN(Nsrc,Ndst); i++) {\n        dst[i] = src[i] / sum;\n      }\n\n      break;\n\n    case VOP_NORM_RANGE0:\n    case VOP_NORM_RANGE1:\n\n       // normalise vector range\n       max=src[0]; min=src[0];\n       for (i=1; i<MIN(Nsrc,Ndst); i++) {\n         if (src[i] > max) max = src[i];\n         if (src[i] < min) min = src[i];\n       }\n       range = max-min; if (range == 0.0) range = 1.0;\n\n       if (operation == VOP_NORM_RANGE0) { // 0..1\n         for (i=0; i<MIN(Nsrc,Ndst); i++) {\n           dst[i] = (src[i] - min) / range;\n         }\n       } else { // VOP_NORM_RANGE1 : -1 .. +1\n         range *= 0.5;\n         for (i=0; i<MIN(Nsrc,Ndst); i++) {\n           dst[i] = ( (src[i] - min) / range ) - (FLOAT_DMEM)1.0;\n         }\n       }\n       break;\n\n\n    case VOP_ADD:\n      for (i=0; i<MIN(Nsrc,Ndst); i++) {\n        dst[i] = src[i] + param1;\n      }\n      break;\n\n    case VOP_MUL:\n      for (i=0; i<MIN(Nsrc,Ndst); i++) {\n        dst[i] = src[i] * param1;\n      }\n      break;\n\n    case VOP_LOG:\n      for (i=0; i<MIN(Nsrc,Ndst); i++) {\n        if (src[i]>logfloor) {\n          dst[i] = std::log(src[i]);\n        } else {\n          dst[i] = std::log(logfloor);\n        }\n      }\n      break;\n\n    case VOP_LOGA:\n      sum = std::log(param1);\n      for (i=0; i<MIN(Nsrc,Ndst); i++) {\n        if (src[i]>logfloor) {\n          dst[i] = std::log(src[i]) / sum;\n        } else {\n          dst[i] = std::log(logfloor) / sum;\n        }\n      }\n      break;\n\n    case VOP_SQRT:\n      for (i=0; i<MIN(Nsrc,Ndst); i++) {\n        if (src[i]>0.0) {\n          dst[i] = std::sqrt(src[i]);\n        } else {\n          dst[i] = 0.0;\n        }\n      }\n      break;\n\n    case VOP_POW:\n      for (i=0; i<MIN(Nsrc,Ndst); i++) {\n        if (powOnlyPos) {\n          if (src[i]>0.0) {\n            dst[i] = std::pow(src[i],param1);\n          } else {\n            dst[i] = 0.0;\n          }\n        } else {\n          dst[i] = std::pow(src[i],param1);\n        }\n      }\n      break;\n\n    case VOP_EXP:\n      for (i=0; i<MIN(Nsrc,Ndst); i++) {\n        dst[i] = std::pow(param1,src[i]);\n      }\n      break;\n    \n    case VOP_E:\n      for (i=0; i<MIN(Nsrc,Ndst); i++) {\n        dst[i] = std::exp(src[i]);\n      }\n      break;\n\n    case VOP_ABS:\n      for (i=0; i<MIN(Nsrc,Ndst); i++) {\n        dst[i] = fabs(src[i]);\n      }\n      break;\n\n    case VOP_AGN:\n      for (i = 0; i < MIN(Nsrc,Ndst); i++) {\n        dst[i] = src[i] + param2 * (FLOAT_DMEM)gnGenerator() + param1;\n      }\n      break;\n\n    case VOP_MIN:\n      for (i = 0; i < MIN(Nsrc,Ndst); i++) {\n        if (src[i] < param1) {\n          dst[i] = src[i];\n        } else {\n          dst[i] = param1;\n        }\n      }\n      break;\n\n    case VOP_MAX:\n      for (i=0; i<MIN(Nsrc,Ndst); i++) {\n        if (src[i] > param1) {\n          dst[i] = src[i];\n        } else {\n          dst[i] = param1;\n        }\n      }\n      break;\n\n    case VOP_X_SUM:\n      dst[0] = 0.0;\n      for (i=0; i<Nsrc; i++) {\n        dst[0] += src[i];\n      }\n      break;\n\n   case VOP_X_SUMSQ:\n      dst[0] = 0.0;\n      for (i=0; i<Nsrc; i++) {\n        dst[0] += src[i]*src[i];\n      }\n      break;\n\n    case VOP_X_L1:\n      dst[0] = 0.0;\n      for (i=0; i<Nsrc; i++) {\n        dst[0] += src[i];\n      }\n      if (Nsrc > 0) dst[0] /= (FLOAT_DMEM)Nsrc;\n      break;\n\n    case VOP_X_L2:\n      dst[0] = 0.0;\n      for (i=0; i<Nsrc; i++) {\n        dst[0] += src[i]*src[i];\n      }\n      if (dst[0] > 0.0) dst[0] = sqrt(dst[0]);\n      if (Nsrc > 0) dst[0] /= (FLOAT_DMEM)Nsrc;\n      break;\n\n    case VOP_FLATTEN:\n      if (Nsrc > 0) {\n        FLOAT_DMEM m1=0.0,m2=0.0;\n        for (i=0; i<MIN(Nsrc,5); i++) {\n          m1 += src[i];\n        } m1 /= (FLOAT_DMEM)(MIN(Nsrc,5));\n        for (i=MAX(0,Nsrc-5); i<Nsrc; i++) {\n          m2 += src[i];\n        } m2 /= (FLOAT_DMEM)(MIN(Nsrc,5));\n        FLOAT_DMEM slope = (m1-m2)/(FLOAT_DMEM)Nsrc;\n        for (i=0; i<MIN(Nsrc,Ndst); i++) {\n          dst[i] = src[i] - m2 - slope * (FLOAT_DMEM)(Nsrc-i);\n        }\n      }\n      break;\n\n    case VOP_DB_POW:\n      factor = (FLOAT_DMEM)(10.0 / std::log(10.0));\n      for (i=0; i<MIN(Nsrc,Ndst); i++) {\n        if (src[i]>logfloor) {\n          dst[i] = factor * std::log(src[i]);\n        } else {\n          dst[i] = factor * std::log(logfloor);\n        }\n      }\n      break;\n    case VOP_DB_MAG:\n      factor = (FLOAT_DMEM)(20.0 / std::log(10.0));\n      for (i=0; i<MIN(Nsrc,Ndst); i++) {\n        if (src[i]>logfloor) {\n          dst[i] = factor * std::log(src[i]);\n        } else {\n          dst[i] = factor * std::log(logfloor);\n        }\n      }\n      break;\n    case VOP_FCONV:\n      for (i=0; i<MIN(Nsrc,Ndst); i++) {\n        double ftmp = src[i];\n        if (fscaleA != SPECTSCALE_LINEAR) {\n          ftmp = smileDsp_specScaleTransfInv(ftmp, fscaleA, param1);\n        }\n        dst[i] = (FLOAT_DMEM)smileDsp_specScaleTransfFwd(ftmp, fscaleB, param1);\n      }\n      break;\n    default:  // no operation\n      for (i=0; i<MIN(Nsrc,Ndst); i++) {\n        dst[i] = src[i];\n      }\n      break;\n  }\n  return 1;\n}\n\n\n// Code contributed by Felix Weninger\n// Gaussian noise generator\ndouble cVectorOperation::gnGenerator() {\n  static bool haveNumber = false;\n  static double number = 0.0;\n  if (haveNumber) {\n    haveNumber = false;\n    return number;\n  }\n  else {\n    double q = 2.0;\n    double x, y;\n    // Use Polar Method to obtain normally distributed random numbers.\n    while (q > 1.0) {\n        x = ((double)rand() / RAND_MAX) * 2.0 - 1.0;\n        y = ((double)rand() / RAND_MAX) * 2.0 - 1.0;\n        q = x * x + y * y;\n    }\n    double z = -2.0 * log(q) / q;\n    number = y * sqrt(z);\n    haveNumber = true;\n    return x * sqrt(z);\n  }\n}\n\n\ncVectorOperation::~cVectorOperation()\n{\n  if (operationString_ != NULL) {\n    free(operationString_);\n  }\n}\n\n"
  },
  {
    "path": "src/portaudio/portaudioDuplex.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nportaudio dataPorcessor for full-duplex simultaneous recording and playback from the same audio device\nNOTE: this does not work on all sound-card devices and it does not work at all sample-rates (often only 48kHz are supported on cheap devices)\n(?? known to work on windows, linux, and mac)\n\n*/\n\n\n#include <portaudio/portaudioDuplex.hpp>\n#define MODULE \"cPortaudioDuplex\"\n\n#ifdef HAVE_PORTAUDIO\n\nSMILECOMPONENT_STATICS(cPortaudioDuplex)\n\nSMILECOMPONENT_REGCOMP(cPortaudioDuplex)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CPORTAUDIODUPLEX;\n  sdescription = COMPONENT_DESCRIPTION_CPORTAUDIODUPLEX;\n\n  // we inherit cDataSink configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataProcessor\")\n\n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"monoMixdownPB\",\"mix down all channels to 1 mono channel (for playback)\",0);\n    ct->setField(\"monoMixdownREC\",\"mix down all channels to 1 mono channel (for recording)\",0);\n    ct->setField(\"device\",\"PortAudio device to use (device number)\",-1);\n    ct->setField(\"listDevices\",\"(1/0=yes/no) list available portaudio devices during initialisation phase\",0);\n    ct->setField(\"sampleRate\",\"recording AND playback sample rate (WARNING: no sample rate conversion of input level data will be performed prior to playback!)\",44100);\n    ct->setField(\"nBits\",\"number of bits per sample and channel to use for playback (0=pass float values to portaudio)  [ NOT IMPLEMENTED YET ]\",0);\n    ct->setField(\"channels\",\"number of channels to record\",1);\n    ct->setField(\"audioBuffersize\",\"size of port audio playback&recording buffer in samples\",1000);\n    ct->setField(\"audioBuffersize_sec\",\"size of port audio playback&recording buffer in seconds\",0.05);\n  )\n  SMILECOMPONENT_MAKEINFO(cPortaudioDuplex);\n}\n\nSMILECOMPONENT_CREATE(cPortaudioDuplex)\n\n//-----\n\ncPortaudioDuplex::cPortaudioDuplex(const char *_name) :\ncDataProcessor(_name),\n//mBuffersize(2000),\naudioBuffersize(-1),\naudioBuffersize_sec(-1.0),\n//  curReadPos(0),\neof(0),  abort(0),\nmonoMixdownPB(0),\nmonoMixdownREC(0),\ndeviceId(0),\nlistDevices(0),\nsampleRate(0),\nchannels(1),\ndataFlagR(1),\ndataFlagW(1),\nnBits(16),\nisPaInit(0),\ncallbackMatrix(NULL),\nlastDataCount(0),\nstream(NULL),\nstreamStatus(PA_STREAM_STOPPED)\n{\n  smileMutexCreate(callbackMtx);\n  smileCondCreate(callbackCond);\n}\n\nvoid cPortaudioDuplex::fetchConfig()\n{\n  cDataProcessor::fetchConfig();\n\n  monoMixdownPB = getInt(\"monoMixdownPB\");\n  if (monoMixdownPB) { SMILE_IDBG(2,\"monoMixdown for playback enabled!\"); }\n  monoMixdownREC = getInt(\"monoMixdownREC\");\n  if (monoMixdownREC) { SMILE_IDBG(2,\"monoMixdown for recording enabled!\"); }\n\n  /*\n  mBuffersize = getInt(\"buffersize\");\n  if (mBuffersize < 1) mBuffersize=1;\n  SMILE_DBG(2,\"buffersize = %i\",mBuffersize);\n*/\n\n\n  if (isSet(\"audioBuffersize\")) {\n    audioBuffersize = getInt(\"audioBuffersize\");\n    if (audioBuffersize < 1) audioBuffersize=1;\n    SMILE_DBG(2,\"audioBuffersize = %i\",audioBuffersize);\n  }\n  if (isSet(\"audioBuffersize_sec\")) {\n    audioBuffersize_sec = getInt(\"audioBuffersize_sec\");\n    if (audioBuffersize_sec < 1) audioBuffersize_sec = 1;\n    SMILE_DBG(2,\"audioBuffersize_sec = %i\",audioBuffersize_sec);\n  } \n\n  listDevices = getInt(\"listDevices\");\n  if (listDevices) { SMILE_IDBG(3,\"listDevices enabled!\"); }\n\n  deviceId = getInt(\"device\");\n  SMILE_IDBG(2,\"using portAudio device # %i\",deviceId);\n\n  sampleRate = getInt(\"sampleRate\");\n  if (sampleRate != 0) { SMILE_IDBG(2,\"user-defined playback sample rate = %i\",sampleRate); }\n\n  channels = getInt(\"channels\");\n  if (channels < 1) channels=1;\n  SMILE_DBG(2,\"No. of recording channels = %i\",channels);\n\n  nBits = getInt(\"nBits\");\n  switch(nBits) {\n    case 8: nBPS=1; break;\n    case 16: nBPS=2; break;\n    case 24: nBPS=4; break;\n    case 32: nBPS=4; break;\n    case 33: nBPS=4; break;\n    default:\n      SMILE_IERR(1,\"invalid number of bits requested: %i (allowed: 8, 16, 24, 32, 33(for 23-bit float))\\n   Setting number of bits to default (16)\",nBits);\n      nBits=16;\n  }\n  SMILE_IDBG(2,\"No. of bits per sample = %i\",nBits);\n\n  //  // TODO: buffersize in seconds.. AND unlink buffersize = buffersize in datamemory!\n}\n\nint cPortaudioDuplex::configureWriter(sDmLevelConfig &c)\n{\n  if (audioBuffersize > 0) {\n    c.blocksizeWriter = audioBuffersize;\n  } else if (audioBuffersize_sec > 0) {\n    double TT = 1.0;\n    if (c.T != 0.0) TT = c.T;\n    c.blocksizeWriter = audioBuffersize = (long)ceil( audioBuffersize_sec / TT );\n  } else {\n    SMILE_IMSG(3,\"using default audioBuffersize (1000 samples) since no option was given in config file\");\n    c.blocksizeWriter = audioBuffersize = 1000;\n  }\n\n  c.T = 1.0 / (double)(sampleRate);\n\n  reader_->setupSequentialMatrixReading(audioBuffersize, audioBuffersize);\n  \n  return 1;\n}\n\nint cPortaudioDuplex::myConfigureInstance()\n{\n  int ret = 1;\n\n  // initialise port audio\n  if (!isPaInit) {\n    PaError err = Pa_Initialize(); \n    if( err != paNoError ) COMP_ERR(0,\"error initialising portaudio library (code %i)\\n\",err);\n    isPaInit=1;\n  }\n\n#ifdef HAVE_PORTAUDIO_V19\n  numDevices = Pa_GetDeviceCount();\n#else\n  numDevices = Pa_CountDevices();\n#endif\n\n  // list devices...\n  if (listDevices) {\n    if (listDevices != -1) {\n      printDeviceList();\n      listDevices=-1;\n      SMILE_IMSG(1,\"Device list was printed, cPortaudioDuplex::myConfigureInstance will now return 0 in order to stop openSMILE initialisation!\");\n    }\n    return 0;\n  } else {\n    if (numDevices <= 0) {\n      SMILE_IERR(1,\"NO PortAudio devices found! Cannot play live audio!\");\n    }\n  }\n\n\n  return cDataProcessor::myConfigureInstance();\n}\n\nint cPortaudioDuplex::setupNewNames(long nEl)\n{\n  writer_->addField(\"pcm\",channels);\n  namesAreSet_ = 1;\n  return 1;\n}\n\nint cPortaudioDuplex::myFinaliseInstance()\n{\n  int ret = cDataProcessor::myFinaliseInstance();\n\n  if (ret) {\n    callbackMatrix = new cMatrix( getChannels(), audioBuffersize );\n\n    channels = reader_->getLevelN();\n    if (channels > 2) {\n      SMILE_IWRN(1,\"channels was > 2 , it was limited to 2! This might cause problems...\");\n      channels=2;\n    }\n    if (channels < 1) {\n      SMILE_IWRN(1,\"channels was < 1 , it was automatically adjusted to 1! This might cause problems...\");\n      channels=1;\n    }\n\n\t  if (sampleRate == 0) \n      sampleRate = (int)(1.0/(reader_->getLevelT()));\n\n    SMILE_IDBG(2,\"setting playback sampleRate: %i Hz\",sampleRate);\n    //    printf(\"XXXXXXXXXXXXXXx computed sampleRate as: %i Hz (per = %f)\\n\",sampleRate,reader->getLevelT()*1000);\n\n  }\n\n  return ret;\n}\n\n\nint cPortaudioDuplex::myTick(long long t)\n{\n  if (isEOI()) return 0; //XXX ????\n\n  if (streamStatus == PA_STREAM_STOPPED) {\n    if (!startDuplex()) return 0;\n  }\n/*\n  smileMutexLock(callbackMtx);\n  int ret = (dataFlagR&dataFlagW);\n  if ((dataFlagR == 0)&&(dataFlagW == 0)) {\n    smileCondTimedWaitWMtx(callbackCond,1000,callbackMtx);\n    //dataFlagR = dataFlagW = 0;\n  } else {\n    \n  }\n  \n  smileMutexUnlock(callbackMtx);\n  \n  return ret;\n  */\n  smileMutexLock(callbackMtx);\n  if ((dataFlagW == 0)&&(dataFlagR==0)) {\n    smileCondTimedWaitWMtx(callbackCond,1000,callbackMtx);\n  }\n  int ret = dataFlagW|dataFlagR;\n  dataFlagW=0; dataFlagR=0;\n  \n  // TODO: if dataFlagW == 0, then increase counter, after timeout set end of playback\n  //       add option, terminate at end of playback....\n\n  smileMutexUnlock(callbackMtx);\n\n\n  return 1; // ret\n}\n\n\ncPortaudioDuplex::~cPortaudioDuplex()\n{\n  if (isPaInit) {\n    smileMutexLock(callbackMtx);\n    stopDuplex();\n\n    // TODO: set a flag to inform the callback recording has stoppped!!\n    //   and, do not call Pa_terminate while the callback is running... i.e. introduce a callback mutex!\n    isPaInit = 0;\n    PaError err = Pa_Terminate();\n    if( err != paNoError ) {\n      SMILE_ERR(2,\"PortAudio error (Pa_Terminate): %s\\n\", Pa_GetErrorText( err ) );\n    }\n    smileMutexUnlock(callbackMtx);\n  }\n\n  smileMutexDestroy(callbackMtx);\n  smileCondDestroy(callbackCond);\n  if (callbackMatrix != NULL) delete callbackMatrix;\n}\n\n//--------------------------------------------------  portaudio specific\n\n\n// channels = number of output channels (can be 1 or 2)\nint matrixToPcmDataFloat_d(void *outputBuffer, long __N, cMatrix *_mat, int channels, int mixdown=0) \n{\n  int i,c,n;\n\n  float *out = (float*)outputBuffer;\n\n  for (i=0; i<MIN(_mat->nT,__N); i++) {\n    if (mixdown) {\n      out[i*channels] = 0.0;\n      for (c=0; c<channels; c++) {\n        for (n=0; n<_mat->N; n++) \n          out[i*channels+c] += (float)(_mat->dataF)[i*(_mat->N)+n];\n      }\n    } else {\n      int minc = channels;\n      if (_mat->N < minc) minc = _mat->N;\n      for (c=0; c<channels; c++) {\n        out[i*channels+c] = (float)(_mat->dataF)[i*(_mat->N)+c];\n      }\n    }\n  }\n  return 1;\n}\n\n// channels = number of output channels (can be 1 or 2)\nint pcmDataFloatToMatrix_d(const void *inputBuffer, long __N, cMatrix *_mat, int channels, int mixdown=0) \n{\n  int i,c,n;\n\n  const float *in = (const float*)inputBuffer;\n  FLOAT_DMEM *out = _mat->dataF;\n\n  for (i=0; i<MIN(_mat->nT,__N); i++) {\n    if (mixdown) {\n      out[i*_mat->N] = (FLOAT_DMEM)0.0;\n      for (c=0; c<channels; c++) {\n        for (n=0; n<_mat->N; n++) \n          out[i*_mat->N+n] += (FLOAT_DMEM)(in[i*channels+c]);\n      }\n    } else {\n      int minc = channels;\n      if (_mat->N < minc) minc = _mat->N;\n      for (c=0; c<channels; c++) {\n        if (c>minc) {\n          out[i*_mat->N+c] = (FLOAT_DMEM)(0.0);\n        } else {\n          out[i*_mat->N+c] = (float)(in[i*channels+c]);\n        }\n      }\n    }\n  }\n  return 1;\n}\n\n\n\n/* This routine will be called by the PortAudio engine when audio is available.\n** It may be called at interrupt level on some machines so don't do anything\n** that could mess up the system like calling malloc() or free().\n*/\nstatic int paDuplex_duplexCallback( const void *inputBuffer, void *outputBuffer,\n                                 unsigned long framesPerBuffer,\n#ifdef HAVE_PORTAUDIO_V19\n                                 const PaStreamCallbackTimeInfo* timeInfo,\n                                 PaStreamCallbackFlags statusFlags,\n#else // V18 (old API)\n                                 PaTimestamp outTime,\n#endif\n                                 void *userData )\n{\n  cPortaudioDuplex * obj = (cPortaudioDuplex *)userData;\n  \n  if (obj == NULL) { \n    memset(outputBuffer, 0, sizeof(float)*obj->getChannels()*framesPerBuffer);\n    return paAbort; \n  }\n\n  if (!smileMutexLock(obj->callbackMtx)) {\n    memset(outputBuffer, 0, sizeof(float)*obj->getChannels()*framesPerBuffer);\n    return paAbort;\n  }\n  if (obj->isAbort()) {\n    memset(outputBuffer, 0, sizeof(float)*obj->getChannels()*framesPerBuffer);\n    smileMutexUnlock(obj->callbackMtx);\n    return paAbort;\n  }\n\n  #ifdef HAVE_PORTAUDIO_V19\n  if (statusFlags & paInputOverflow) { SMILE_DBG(3,\"paInputOverflow\"); }\n  if (statusFlags & paInputUnderflow) { SMILE_DBG(3,\"paInputUnderflow\"); }\n  if (statusFlags & paOutputOverflow) { SMILE_DBG(3,\"paOutputOverflow\"); }\n  if (statusFlags & paOutputUnderflow) { SMILE_DBG(3,\"paOutputUnderflow\"); }\n  #endif\n\n  cDataReader * reader = obj->getReader();\n  cDataWriter * writer = obj->getWriter();\n\n  //printf(\"CBM I:%i  O:%i \\n\",(long)inputBuffer,(long)outputBuffer);\n\n  if (inputBuffer!=NULL) {\n\n  \n  if (writer->checkWrite(framesPerBuffer)) {\n    // make matrix.. // TODO... move this \"new\" to the init code...!\n    cMatrix * mat = obj->callbackMatrix; //new cMatrix( obj->getChannels(), framesPerBuffer );\n    if (mat==NULL) {\n      memset(outputBuffer, 0, sizeof(float)*obj->getChannels()*framesPerBuffer);\n      smileMutexUnlock(obj->callbackMtx);\n      return paAbort;\n    }\n\n    pcmDataFloatToMatrix_d(inputBuffer, framesPerBuffer, mat, obj->getChannels(), obj->isMonoMixdownREC());\n\n    obj->dataFlagW=1;\n    smileCondSignal(obj->callbackCond);\n\n    // save to datamemory\n    writer->setNextMatrix(mat);\n  } else {\n    obj->dataFlagW=0; // ??\n    //printf(\"ERR: audio data was lost! increase data memory buffersize of cPortaudioSource components!\\n\");\n  }\n\n  } \n\n  if (outputBuffer != NULL) {\n\n  cMatrix * _mat = reader->getNextMatrix();  // TODO::: if problems on some architectures are encountered... get rid of the inherent malloc in getNextMatrix...?\n\n  if (_mat != NULL) {\n    matrixToPcmDataFloat_d(outputBuffer, framesPerBuffer, _mat, obj->getChannels(), obj->isMonoMixdownPB());\n    obj->dataFlagR=1;\n    smileCondSignal(obj->callbackCond);\n  } else {\n    // we missed data....\n    // concealment strategy... pad with zeros\n    memset(outputBuffer, 0, sizeof(float)*obj->getChannels()*framesPerBuffer);\n\n    if (obj->dataFlagR == 1) \n      SMILE_MSG(3,\"dropped (>=%i) frames during playback! (maybe increase audioBuffersize ?) [instance: '%s']\",framesPerBuffer,obj->getInstName());\n    // OR: repeat last frame...?    \n\n    obj->dataFlagR=0;\n  }\n\n  }\n\n  smileMutexUnlock(obj->callbackMtx);\n\n  return paContinue;\n}\n\n\nint cPortaudioDuplex::startDuplex()\n{\n  PaStreamParameters  inputParameters;\n  PaStreamParameters  outputParameters;\n  PaError             err = paNoError;\n\n#ifdef HAVE_PORTAUDIO_V19\n  if (Pa_IsStreamActive( stream ) == 1) {\n#else\n  if (Pa_StreamActive( stream ) == 1) {\n#endif\n    SMILE_WRN(2,\"portAudio stream is already active (in startDuplex).\");\n    return 1;\n  }\n\n  if (deviceId < 0) {\n    inputParameters.device = Pa_GetDefaultInputDevice(); /* default input device */\n    outputParameters.device = Pa_GetDefaultOutputDevice(); /* default input device */\n  } else {\n    inputParameters.device = deviceId;\n    outputParameters.device = deviceId;\n  }\n  //\n\n  SMILE_IMSG(2,\"playing on portAudio device with index %i\",outputParameters.device);\n  SMILE_IMSG(2,\"recording on portAudio device with index %i\",inputParameters.device);\n  inputParameters.channelCount = channels;\n  inputParameters.sampleFormat = paFloat32;\n  outputParameters.channelCount = channels;\n  outputParameters.sampleFormat = paFloat32;\n\n#ifdef HAVE_PORTAUDIO_V19\n  const PaDeviceInfo * info = Pa_GetDeviceInfo( inputParameters.device );\n  if (info != NULL) {\n    inputParameters.suggestedLatency =\n      info->defaultLowInputLatency;\n  } else {\n    inputParameters.suggestedLatency = 0;\n  }\n  inputParameters.hostApiSpecificStreamInfo = NULL;\n\n  info = Pa_GetDeviceInfo( outputParameters.device );\n  if (info != NULL) {\n    outputParameters.suggestedLatency =\n      info->defaultLowOutputLatency;\n  } else {\n    outputParameters.suggestedLatency = 0;\n  }\n  outputParameters.hostApiSpecificStreamInfo = NULL;\n#endif\n\n  /* Setup recording stream -------------------------------------------- */\n  err = Pa_OpenStream(\n    &stream,\n#ifdef HAVE_PORTAUDIO_V19\n    &inputParameters,\n    &outputParameters,\n#else // V18 (old API)\n    inputParameters.device, \n    inputParameters.channelCount, \n    inputParameters.sampleFormat, \n    NULL,\n    outputParameters.device, \n    outputParameters.channelCount, \n    outputParameters.sampleFormat, \n    NULL,\n#endif\n    sampleRate,\n    audioBuffersize,\n/*\n#ifndef HAVE_PORTAUDIO_V19\n    1,\n#endif\n    */\n    paClipOff,      /* we won't output out of range samples so don't bother clipping them */\n    paDuplex_duplexCallback,\n    (void*) this );\n\n  if( err != paNoError ) {\n    COMP_ERR(\"error opening portaudio playback stream (code %i) \\n  check samplerate(-> %i , maybe it is not supported?) \\n  maybe incorrect device? (\\\"listDevices=1\\\" in config file displays a list of devices)\\n\",err,sampleRate);\n  }\n\n  smileMutexLock(callbackMtx);\n  err = Pa_StartStream( stream );\n  if( err != paNoError ) COMP_ERR(\"cannot start portaudio stream (code %i)\\n\",err);\n  streamStatus = PA_STREAM_STARTED;\n  smileMutexUnlock(callbackMtx);\n\n  return 1;\n}\n\nint cPortaudioDuplex::stopDuplex()\n{\n  PaError             err = paNoError;\n  if (streamStatus == PA_STREAM_STOPPED) return 0;\n\n  streamStatus =  PA_STREAM_STOPPED;\n\n  abort = 1;\n\n  err = Pa_CloseStream( stream );\n  if( err != paNoError ) {\n    SMILE_ERR(1,\"cannot close portaudio stream (code %i)\\n\",err);\n    return 0;\n  }\n\n  return 1;\n}\n\nint cPortaudioDuplex::stopDuplexWait()\n{\n  PaError             err = paNoError;\n  if (streamStatus == PA_STREAM_STOPPED) return 0;\n\n  streamStatus =  PA_STREAM_STOPPED;\n\n  abort = 1;\n\n  err = Pa_StopStream( stream );\n  if( err != paNoError ) {\n    SMILE_ERR(1,\"cannot close portaudio stream (code %i)\\n\",err);\n    return 0;\n  }\n\n  return 1;\n}\n\nvoid cPortaudioDuplex::printDeviceList(void)\n{\n  // query devices:\n  SMILE_PRINT(\"== cPortAudioSink ==  There are %i audio devices:\", numDevices );\n  if( numDevices < 0 ) {\n    SMILE_ERR(1, \"Pa_CountDevices returned 0x%x\\n\", numDevices );\n    return;\n  }\n  if( numDevices == 0 ) {\n    SMILE_ERR(1, \"No PortAudio audio devices were found! (Pa_CountDevices()=0)\\n\", numDevices );\n    return;\n  }\n\n  const PaDeviceInfo *deviceInfo;\n\n  int i;\n  for( i=0; i<numDevices; i++ )\n  {\n    deviceInfo = Pa_GetDeviceInfo( i );\n    SMILE_PRINT(\"  -> Device #%i: '%s'\\n       #inputChan=%i #outputChan=%i\\n\",i,deviceInfo->name, deviceInfo->maxInputChannels, deviceInfo->maxOutputChannels);\n  }\n\n#ifdef HAVE_PORTAUDIO_V19\n  SMILE_PRINT(\"  The default device is #%i\\n\",Pa_GetDefaultInputDevice());\n#else\n  SMILE_PRINT(\"  The default device is #%i\\n\",Pa_GetDefaultInputDeviceID());\n#endif\n\n}\n\n#endif // HAVE_PORTAUDIO\n"
  },
  {
    "path": "src/portaudio/portaudioSink.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nportaudio dataSink for live recording from sound device\nknown to work on windows, linux, and mac\n\n*/\n\n\n#include <portaudio/portaudioSink.hpp>\n#define MODULE \"cPortaudioSink\"\n\n#ifdef HAVE_PORTAUDIO\n\nSMILECOMPONENT_STATICS(cPortaudioSink)\n\nSMILECOMPONENT_REGCOMP(cPortaudioSink)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CPORTAUDIOSINK;\n  sdescription = COMPONENT_DESCRIPTION_CPORTAUDIOSINK;\n\n  // we inherit cDataSink configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSink\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"monoMixdown\",\"mix down all channels to 1 mono channel\",0);\n    ct->setField(\"device\",\"PortAudio device to use (device number)\",-1);\n    ct->setField(\"listDevices\",\"(1/0=yes/no) list available portaudio devices during initialisation phase\",0);\n    ct->setField(\"sampleRate\",\"force output sample rate (0=determine sample rate from input level)\",0);\n//    ct->setField(\"channels\",\"number of channels to record\",1);\n    //ct->setField(\"nBits\",\"number of bits per sample and channel to use for playback (0=pass float values to portaudio)  [ NOT IMPLEMENTED YET ]\",0);\n    ct->setField(\"audioBuffersize\",\"size of port audio recording buffer in samples (overwrites audioBuffersize_sec, if set)\",1000);\n    ct->setField(\"audioBuffersize_sec\",\"size of port audio recording buffer in seconds\",0.05);\n  )\n  SMILECOMPONENT_MAKEINFO(cPortaudioSink);\n}\n\nSMILECOMPONENT_CREATE(cPortaudioSink)\n\n//-----\n\ncPortaudioSink::cPortaudioSink(const char *_name) :\n  cDataSink(_name),\n  audioBuffersize(-1),\n  audioBuffersize_sec(-1.0),\n  eof(0),  abort(0),\n  monoMixdown(0),\n  deviceId(0),\n  listDevices(0),\n  sampleRate(0),\n  channels(1),\n  dataFlag(1),\n  nBits(16),\n  isPaInit(0),\n  callbackMatrix(NULL),\n  lastDataCount(0),\n  stream(NULL),\n  streamStatus(PA_STREAM_STOPPED)\n{\n  //smileMutexCreate(dataFlagMtx);\n  smileMutexCreate(callbackMtx);\n  smileCondCreate(callbackCond);\n}\n\nvoid cPortaudioSink::fetchConfig()\n{\n  cDataSink::fetchConfig();\n  \n  monoMixdown = getInt(\"monoMixdown\");\n  if (monoMixdown) { SMILE_IDBG(2,\"monoMixdown enabled!\"); }\n\n  if (isSet(\"audioBuffersize\")) {\n    audioBuffersize = getInt(\"audioBuffersize\");\n    if (audioBuffersize < 1) audioBuffersize=1;\n    SMILE_IDBG(2,\"audioBuffersize = %i\",audioBuffersize);\n  }\n  if (isSet(\"audioBuffersize_sec\")) {\n    audioBuffersize_sec = getInt(\"audioBuffersize_sec\");\n    if (audioBuffersize_sec < 1) audioBuffersize_sec = 1;\n    SMILE_DBG(2,\"audioBuffersize_sec = %i\",audioBuffersize_sec);\n  } \n\n  listDevices = getInt(\"listDevices\");\n  if (listDevices) { SMILE_IDBG(3,\"listDevices enabled!\"); }\n\n  deviceId = getInt(\"device\");\n  SMILE_IDBG(2,\"using portAudio device # %i\",deviceId);\n\n  sampleRate = getInt(\"sampleRate\");\n  if (sampleRate != 0) { SMILE_IDBG(2,\"user-defined playback sample rate = %i\",sampleRate); }\n\n//  channels = getInt(\"channels\");\n//  if (channels < 1) channels=1;\n//  SMILE_DBG(2,\"No. of recording channels = %i\",channels);\n\n  /*nBits = getInt(\"nBits\");\n  switch(nBits) {\n    case 8: nBPS=1; break;\n    case 16: nBPS=2; break;\n    case 24: nBPS=4; break;\n    case 32: nBPS=4; break;\n    case 33: nBPS=4; break;\n    default:\n      SMILE_IERR(1,\"invalid number of bits requested: %i (allowed: 8, 16, 24, 32, 33(for 23-bit float))\\n   Setting number of bits to default (16)\",nBits);\n      nBits=16;\n  }\n  SMILE_IDBG(2,\"No. of bits per sample = %i\",nBits);\n*/\n  nBits = 33;\n  nBPS=4;\n\n//  // TODO: buffersize in seconds.. AND unlink buffersize = buffersize in datamemory!\n}\n\nint cPortaudioSink::configureReader()\n{\n  if (audioBuffersize > 0) {\n    \n  } else if (audioBuffersize_sec > 0) {\n    double TT = reader_->getLevelT();\n    if (TT == 0.0) TT = 1.0;\n    audioBuffersize = (long)ceil( audioBuffersize_sec / TT );\n  } else {\n    SMILE_IMSG(3,\"using default audioBuffersize (1000 samples) since no option was given in config file\");\n    audioBuffersize = 1000;\n  }\n\n  reader_->setupSequentialMatrixReading(audioBuffersize, audioBuffersize);\n\n  return 1;\n}\n\nint cPortaudioSink::myConfigureInstance()\n{\n  // initialise port audio\n  if (!isPaInit) {\n    PaError err = Pa_Initialize(); \n    if( err != paNoError ) COMP_ERR(0,\"error initialising portaudio library (code %i)\\n\",err);\n    isPaInit=1;\n  }\n\n#ifdef HAVE_PORTAUDIO_V19\n  numDevices = Pa_GetDeviceCount();\n#else\n  numDevices = Pa_CountDevices();\n#endif\n\n  // list devices...\n  if (listDevices) {\n    if (listDevices != -1) {\n      printDeviceList();\n      listDevices=-1;\n      SMILE_IMSG(1,\"Device list was printed, cPortaudioSink::myConfigureInstance will now return 0 in order to stop openSMILE initialisation!\");\n    }\n    return 0;\n  } else {\n    if (numDevices <= 0) {\n      SMILE_IERR(1,\"NO PortAudio devices found! Cannot play live audio!\");\n    }\n  }\n  \n  return cDataSink::myConfigureInstance();\n}\n\nint cPortaudioSink::myFinaliseInstance()\n{\n  int ret;\n\n  ret = cDataSink::myFinaliseInstance();\n\n  if (ret) {\n    channels = reader_->getLevelN();\n    if (channels > 2) {\n      SMILE_IWRN(1,\"channels was > 2 , it was limited to 2! This might cause problems...\");\n      channels=2;\n    }\n    if (channels < 1) {\n      SMILE_IWRN(1,\"channels was < 1 , it was automatically adjusted to 1! This might cause problems...\");\n      channels=1;\n    }\n\n\t  if (sampleRate == 0) \n      sampleRate = (int)(1.0/(reader_->getLevelT()));\n\n    SMILE_IDBG(2,\"setting playback sampleRate: %i Hz\",sampleRate);\n    //    printf(\"XXXXXXXXXXXXXXx computed sampleRate as: %i Hz (per = %f)\\n\",sampleRate,reader->getLevelT()*1000);\n  }\n\n  return ret;\n}\n\n\nint cPortaudioSink::myTick(long long t)\n{\n  if (isEOI()) return 0; //XXX ????\n  \n  if (streamStatus == PA_STREAM_STOPPED) {\n    dataFlag = 1;\n    if (!startPlayback()) return 0;\n  }\n\n  smileMutexLock(callbackMtx);\n\n  if (dataFlag == 0) {\n    smileCondTimedWaitWMtx(callbackCond,1000,callbackMtx);\n  }\n\n  smileMutexUnlock(callbackMtx);\n\n  return dataFlag;\n}\n\n\ncPortaudioSink::~cPortaudioSink()\n{\n  if (isPaInit) {\n    smileMutexLock(callbackMtx);\n    stopPlaybackWait();\n\n// TODO: set a flag to inform the callback recording has stoppped!!\n//   and, do not call Pa_terminate while the callback is running... i.e. introduce a callback mutex!\n    isPaInit = 0;\n    PaError err = Pa_Terminate();\n    if( err != paNoError ) {\n      SMILE_ERR(2,\"PortAudio error (Pa_Terminate): %s\\n\", Pa_GetErrorText( err ) );\n    }\n    smileMutexUnlock(callbackMtx);\n  }\n\n  //smileMutexDestroy(dataFlagMtx);\n  smileMutexDestroy(callbackMtx);\n  smileCondDestroy(callbackCond);\n  if (callbackMatrix != NULL) delete callbackMatrix;\n}\n\n//--------------------------------------------------  portaudio specific\n\n\n// channels = number of output channels (can be 1 or 2)\nint matrixToPcmDataFloat(void *outputBuffer, long __N, cMatrix *_mat, int channels, int mixdown=0) \n{\n  int i,c,n;\n\n  float *out = (float*)outputBuffer;\n  \n  for (i=0; i<MIN(_mat->nT,__N); i++) {\n\tif (mixdown) {\n      out[i*channels] = 0.0;\n      for (c=0; c<channels; c++) {\n\t    for (n=0; n<_mat->N; n++) \n          out[i*channels+c] += (float)(_mat->dataF)[i*(_mat->N)+n];\n      }\n\t} else {\n\t  int minc = channels;\n\t  if (_mat->N < minc) minc = _mat->N;\n      for (c=0; c<channels; c++) {\n        out[i*channels+c] = (float)(_mat->dataF)[i*(_mat->N)+c];\n\t  }\n\t}\n  }\n  return 1;\n}\n\n/* This routine will be called by the PortAudio engine when audio is available.\n** It may be called at interrupt level on some machines so don't do anything\n** that could mess up the system like calling malloc() or free().\n*/\nstatic int paSink_playbackCallback( const void *inputBuffer, void *outputBuffer,\n                           unsigned long framesPerBuffer,\n#ifdef HAVE_PORTAUDIO_V19\n                           const PaStreamCallbackTimeInfo* timeInfo,\n                           PaStreamCallbackFlags statusFlags,\n#else // V18 (old API)\n                           PaTimestamp outTime,\n#endif\n                           void *userData )\n{\n  cPortaudioSink * obj = (cPortaudioSink *)userData;\n\n  if (obj == NULL) { return paAbort; }\n\n  if (!smileMutexLock(obj->callbackMtx)) return paAbort;\n\n  if (obj->isAbort()) {\n    smileMutexUnlock(obj->callbackMtx);\n    return paAbort;\n  }\n  if (outputBuffer==NULL) {\n    smileMutexUnlock(obj->callbackMtx);\n\t  return paContinue;\n  }\n\n  cDataReader * reader = obj->getReader();\n\n  cMatrix * _mat = reader->getNextMatrix();  // TODO::: if problems on some architectures are encountered... get rid of the inherent malloc in getNextMatrix...?\n  \n  if (_mat != NULL) {\n    matrixToPcmDataFloat(outputBuffer, framesPerBuffer, _mat, obj->getChannels(), obj->isMonoMixdown());\n    smileCondSignal(obj->callbackCond);\n\t  obj->dataFlag=1;\n  } else {\n    // we missed data....\n\t  // concealment strategy... pad with zeros\n    memset(outputBuffer, 0, sizeof(float)*obj->getChannels()*framesPerBuffer);\n\t\n\tif (obj->dataFlag == 1) \n\t  SMILE_MSG(3,\"dropped (>=%i) frames during playback! (maybe increase audioBuffersize ?) [instance: '%s']\",framesPerBuffer,obj->getInstName());\n      // OR: repeat last frame...?    \n\n\tobj->dataFlag=0;\n  }\n\n  smileMutexUnlock(obj->callbackMtx);\n  return paContinue;\n}\n\n\nint cPortaudioSink::startPlayback()\n{\n    PaStreamParameters  outputParameters;\n    PaError             err = paNoError;\n\n#ifdef HAVE_PORTAUDIO_V19\n    if (Pa_IsStreamActive( stream ) == 1) {\n#else\n    if (Pa_StreamActive( stream ) == 1) {\n#endif\n      SMILE_WRN(2,\"portAudio stream is already active (in startPlayback).\");\n      return 1;\n    }\n\n    if (deviceId < 0) {\n      outputParameters.device = Pa_GetDefaultOutputDevice(); /* default input device */\n    } else {\n      outputParameters.device = deviceId;\n    }\n//\n\n    SMILE_MSG(2,\"playing on portAudio device with index %i\",outputParameters.device);\n    outputParameters.channelCount = channels;\n\toutputParameters.sampleFormat = paFloat32;\n\n/*\tswitch (nBits) {\n      case 8: outputParameters.sampleFormat = paInt8; break;\n      case 16: outputParameters.sampleFormat = paInt16; break;\n      case 24: outputParameters.sampleFormat = paInt24; break;\n      case 32: outputParameters.sampleFormat = paInt32; break;\n      case 33: outputParameters.sampleFormat = paFloat32; break;\n      default:\n        COMP_ERR(\"invalid number of bits requested: %i (allowed: 8, 16, 24, 32, 33(for 23-bit float))\\n\",nBits);\n    }*/\n\n#ifdef HAVE_PORTAUDIO_V19\n    const PaDeviceInfo * info = Pa_GetDeviceInfo( outputParameters.device );\n    if (info != NULL) {\n      outputParameters.suggestedLatency =\n        info->defaultLowInputLatency;\n    } else {\n      outputParameters.suggestedLatency = 0;\n    }\n    outputParameters.hostApiSpecificStreamInfo = NULL;\n#endif\n\n    /* Setup recording stream -------------------------------------------- */\n    err = Pa_OpenStream(\n              &(stream),\n#ifdef HAVE_PORTAUDIO_V19\n              NULL,\n              &outputParameters,\n#else // V18 (old API)\n              paNoDevice,\n              0,\n              0,\n              NULL,\n              outputParameters.device, \n\t\t\t  outputParameters.channelCount, \n\t\t\t  outputParameters.sampleFormat, \n\t\t\t  NULL,\n#endif\n              sampleRate,\n              audioBuffersize,\n#ifndef HAVE_PORTAUDIO_V19\n              1,\n#endif\n              paClipOff,      /* we won't output out of range samples so don't bother clipping them */\n              paSink_playbackCallback,\n              (void*) this );\n\n    if( err != paNoError ) {\n        COMP_ERR(\"error opening portaudio playback stream (code %i) \\n  check samplerate(-> %i , maybe it is not supported?) \\n  maybe incorrect device? (\\\"listDevices=1\\\" in config file displays a list of devices)\\n\",err,sampleRate);\n    }\n\n\tsmileMutexLock(callbackMtx);\n    err = Pa_StartStream( stream );\n    if( err != paNoError ) COMP_ERR(\"cannot start portaudio stream (code %i)\\n\",err);\n    streamStatus = PA_STREAM_STARTED;\n    smileMutexUnlock(callbackMtx);\n\n    return 1;\n}\n\nint cPortaudioSink::stopPlayback()\n{\n  PaError             err = paNoError;\n  if (streamStatus == PA_STREAM_STOPPED) return 0;\n\n  streamStatus =  PA_STREAM_STOPPED;\n\n  abort = 1;\n\n  err = Pa_CloseStream( stream );\n  if( err != paNoError ) {\n    SMILE_ERR(1,\"cannot close portaudio stream (code %i)\\n\",err);\n    return 0;\n  }\n\n  return 1;\n}\n\nint cPortaudioSink::stopPlaybackWait()\n{\n  PaError             err = paNoError;\n  if (streamStatus == PA_STREAM_STOPPED) return 0;\n\n  streamStatus =  PA_STREAM_STOPPED;\n\n  abort = 1;\n\n  smileMutexUnlock(callbackMtx);\n  err = Pa_StopStream( stream );\n  smileMutexLock(callbackMtx);\n\n  if( err != paNoError ) {\n    SMILE_ERR(1,\"cannot close portaudio stream (code %i)\\n\",err);\n    return 0;\n  }\n\n  return 1;\n}\n\nvoid cPortaudioSink::printDeviceList(void)\n{\n  // query devices:\n  SMILE_PRINT(\"== cPortAudioSink ==  There are %i audio devices:\", numDevices );\n  if( numDevices < 0 ) {\n     SMILE_ERR(1, \"Pa_CountDevices returned 0x%x\\n\", numDevices );\n     return;\n  }\n  if( numDevices == 0 ) {\n     SMILE_ERR(1, \"No PortAudio audio devices were found! (Pa_CountDevices()=0)\\n\", numDevices );\n     return;\n  }\n\n  const PaDeviceInfo *deviceInfo;\n\n  int i;\n  for( i=0; i<numDevices; i++ )\n  {\n     deviceInfo = Pa_GetDeviceInfo( i );\n     SMILE_PRINT(\"  -> Device #%i: '%s'\\n       #inputChan=%i #outputChan=%i\\n\",i,deviceInfo->name, deviceInfo->maxInputChannels, deviceInfo->maxOutputChannels);\n  }\n\n#ifdef HAVE_PORTAUDIO_V19\n  SMILE_PRINT(\"  The default device is #%i\\n\",Pa_GetDefaultOutputDevice());\n#else\n  SMILE_PRINT(\"  The default device is #%i\\n\",Pa_GetDefaultOutputDeviceID());\n#endif\n\n}\n\n#endif // HAVE_PORTAUDIO\n"
  },
  {
    "path": "src/portaudio/portaudioSource.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nportaudio dataSource for live recording from sound device\nknown to work on windows, linux, and mac\n\n*/\n\n\n#include <portaudio/portaudioSource.hpp>\n#define MODULE \"cPortaudioSource\"\n\n#ifdef HAVE_PORTAUDIO\n#include <portaudio.h>\n\nSMILECOMPONENT_STATICS(cPortaudioSource)\n\nSMILECOMPONENT_REGCOMP(cPortaudioSource)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CPORTAUDIOSOURCE;\n  sdescription = COMPONENT_DESCRIPTION_CPORTAUDIOSOURCE;\n\n  // we inherit cDataSource configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSource\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"monoMixdown\",\"Mix down all recorded channels to 1 mono channel\",0);\n    ct->setField(\"device\",\"PortAudio device to use (device number, see the option 'listDevices' to get information on device numbers)\",-1);\n    ct->setField(\"period\",(const char*)NULL,0,0,0);\n    ct->setField(\"listDevices\",\"If set to 1, openSMILE will list available portaudio devices during initialisation phase and exit immediately after that (you might get an error message on windows, which you can ignore).\",0);\n    ct->setField(\"sampleRate\",\"The sampling rate to use for audio recording (if supported by device!)\",16000);\n    ct->setField(\"channels\",\"The number of channels to record (check your device's capabilities!\",1);\n    ct->setField(\"selectChannel\",\"Select only the specified channel from 'channels' that are recorded. Set to -1 to grab all channels.\",-1);\n    ct->setField(\"nBits\",\"The number of bits per sample and channel\",16);\n    ct->setField(\"nBPS\",\"The number of bytes per sample and channel (0=determine automatically from nBits)\",0,0,0);\n    ct->setField(\"audioBuffersize\",\"The size of the portaudio recording buffer in samples (overwrites audioBuffersize_sec, if set)\",0,0,0);\n    ct->setField(\"audioBuffersize_sec\",\"size of the portaudio recording buffer in seconds. This value has influence on the system latency. Setting it too high might introduce a high latency. A too low value might lead to dropped samples and reduced performance.\",0.05);\n    ct->setField(\"byteSwap\",\"1 = swap bytes, big endian <-> little endian (usually not required)\",0,0,0);\n  )\n  SMILECOMPONENT_MAKEINFO(cPortaudioSource);\n}\n\nSMILECOMPONENT_CREATE(cPortaudioSource)\n\n//-----\n\ncPortaudioSource::cPortaudioSource(const char *_name) :\n  cDataSource(_name),\n  //mBuffersize(2000),\n  audioBuffersize(-1),\n  audioBuffersize_sec(-1.0),\n  curReadPos(0),\n  eof(0),  abort(0),\n  monoMixdown(0),\n  deviceId(0),\n  listDevices(0),\n  sampleRate(0),\n  channels(1),\n  dataFlag(1),\n  nBits(16),\n  isPaInit(0),\n  callbackMatrix(NULL),\n  lastDataCount(0),\n  stream(NULL),\n  streamStatus(PA_STREAM_STOPPED),\n  byteSwap(0),\n  warned(0)\n{\n  smileMutexCreate(dataFlagMtx);\n  smileMutexCreate(callbackMtx);\n  smileCondCreate(callbackCond);\n}\n\nvoid cPortaudioSource::fetchConfig()\n{\n  cDataSource::fetchConfig();\n  \n  monoMixdown = getInt(\"monoMixdown\");\n  if (monoMixdown) { SMILE_IDBG(2,\"monoMixdown enabled!\"); }\n\n  /*\n  mBuffersize = getInt(\"buffersize\");\n  if (mBuffersize < 1) mBuffersize=1;\n  SMILE_DBG(2,\"buffersize = %i\",mBuffersize);\n*/\n  \n  if (isSet(\"audioBuffersize\")) {\n    audioBuffersize = getInt(\"audioBuffersize\");\n//    if (audioBuffersize < 1024) audioBuffersize=1024;\n    SMILE_DBG(2,\"audioBuffersize = %i\",audioBuffersize);\n    //printf(\"audioBuffersize = %i\",audioBuffersize);\n  }\n  if (isSet(\"audioBuffersize_sec\")) {\n    audioBuffersize_sec = getDouble(\"audioBuffersize_sec\");\n//    if (audioBuffersize_sec < 0.0) audioBuffersize_sec = 0.05;\n    SMILE_DBG(2,\"audioBuffersize_sec = %i\",audioBuffersize_sec);\n    //printf(\"audioBuffersize_sec = %f\",audioBuffersize_sec);\n  } \n\n  listDevices = getInt(\"listDevices\");\n  if (listDevices) { SMILE_IDBG(3,\"listDevices enabled!\"); }\n\n  deviceId = getInt(\"device\");\n  SMILE_DBG(2,\"using portAudio device # %i\",deviceId);\n\n  sampleRate = getInt(\"sampleRate\");\n  SMILE_DBG(2,\"recording sample rate = %i\",sampleRate);\n\n  channels = getInt(\"channels\");\n  if (channels < 1) channels=1;\n  SMILE_DBG(2,\"No. of recording channels = %i\",channels);\n\n  selectChannel = getInt(\"selectChannel\");\n  if (selectChannel >= 0) { SMILE_DBG(2,\"only selected %i. channel.\",selectChannel); }\n  \n  nBits = getInt(\"nBits\");\n  nBPS = getInt(\"nBPS\");\n  if (nBPS==0) {\n  switch(nBits) {\n    case 8: nBPS=1; break;\n    case 16: nBPS=2; break;\n    case 24: nBPS=4; break;\n    case 32: nBPS=4; break;\n    case 33: nBPS=4; break;\n    case 0:  nBPS=4; nBits=32; break;\n    default:\n      SMILE_ERR(1,\"invalid number of bits requested: %i (allowed: 8, 16, 24, 32, 33(for 23-bit float))\\n   Setting number of bits to default (16)\",nBits);\n      nBits=16;\n  }\n  }\n  SMILE_DBG(2,\"No. of bits per sample = %i\",nBits);\n\n  byteSwap = getInt(\"byteSwap\");\n//  // TODO: AND unlink buffersize = buffersize in datamemory!\n}\n\nint cPortaudioSource::configureWriter(sDmLevelConfig &c)\n{\n  c.T = 1.0 / (double)(sampleRate);\n\n  if (audioBuffersize > 0) {\n    c.blocksizeWriter = audioBuffersize;\n    blocksizeW_ = audioBuffersize;\n  } else if (audioBuffersize_sec > 0.0) {\n    double TT = 1.0;\n    if (c.T != 0.0) TT = c.T;\n    c.blocksizeWriter = blocksizeW_ = audioBuffersize = (long)ceil( audioBuffersize_sec / TT );\n    blocksizeW_sec = audioBuffersize_sec;\n  } else {\n    SMILE_IMSG(3,\"using default audioBuffersize (1024 samples) since no option was given in config file\");\n    c.blocksizeWriter = audioBuffersize = 1024;\n  }\n//  printf(\"blocksizeWriter: %i ab: %i %f\\n\",c.blocksizeWriter,audioBuffersize,audioBuffersize_sec);\n//  COMP_ERR(\"stop\");\n\n  return 1;\n}\n\nint cPortaudioSource::myConfigureInstance()\n{\n  int ret = 1;\n\n  // initialise port audio, if not already initialised!\n  if (!isPaInit) {\n    PaError err = Pa_Initialize(); isPaInit=1;\n    if( err != paNoError ) COMP_ERR(0,\"error initialising portaudio library (code %i)\\n\",err);\n  }\n\n#ifdef HAVE_PORTAUDIO_V19\n  numDevices = Pa_GetDeviceCount();\n#else\n  numDevices = Pa_CountDevices();\n#endif\n\n  // list devices...\n  if (listDevices) {\n    if (listDevices != -1) {\n      printDeviceList();\n      listDevices=-1;\n      SMILE_MSG(1,\"Device list was printed, cPortaudioSource::myConfigureInstance will now return 0 in order to stop openSMILE initialisation!\");\n    }\n    return 0;\n  } else {\n    if (numDevices <= 0) {\n      SMILE_ERR(1,\"NO PortAudio devices found! Cannot record live audio!\");\n    }\n  }\n\n  return cDataSource::myConfigureInstance();\n}\n\nint cPortaudioSource::setupNewNames(long nEl)\n{\n  if ((monoMixdown)||(selectChannel>=0)) {\n    writer_->addField(\"pcm\", 1);\n  } else {\n    writer_->addField(\"pcm\", channels);\n  }\n  namesAreSet_ = 1;\n  return 1;\n}\n\nint cPortaudioSource::myFinaliseInstance()\n{\n  int ret = cDataSource::myFinaliseInstance();\n  if (ret) {\n    if ((monoMixdown)||(selectChannel>=0)) {\n      callbackMatrix = new cMatrix( 1, audioBuffersize );\n    } else {\n      callbackMatrix = new cMatrix( getChannels(), audioBuffersize );\n    }\n    //ret*=startRecording(); \n    // we start recording during first tick... this will ensure that all componentes are finalised when the first callback is called!\n  }\n  return ret;\n}\n\nint cPortaudioSource::pauseEvent()\n{\n  stopRecording();\n  return 1;\n}\n\nvoid cPortaudioSource::resumeEvent()\n{\n  startRecording();\n}\n\nint cPortaudioSource::myTick(long long t)\n{\n  if (isPaused() || isEOI()) return 0;\n  \n  if (streamStatus == PA_STREAM_STOPPED) {\n    if (!startRecording()) return 0;\n  }\n\n  // this will always try to fill the buffer as much as possible... for multiple threads this is absolutely ok,\n  //   for single threads the buffer might overflow... thus for single threads we might also want to check for (writer->getNAvail() < audioBuffersize )\n//writer->getN\n  if ((writer_->checkWrite(audioBuffersize)) && (writer_->getNAvail() < audioBuffersize )) {\n    //printf(\"wait\\n\");\n    smileCondTimedWait(callbackCond,1000);\n  } else {\n    //printf(\"no wait! %i  %i  %i bs=%i\\n\",t,writer->getNAvail(), (writer->checkWrite(audioBuffersize)), audioBuffersize);\n    if (writer_->getNFree() < audioBuffersize*2) {\n      if (!warned) {\n        SMILE_WRN(3,\"audio buffer FULL, processing seems to be too slow. audio data possibly lost.\");\n        warned=1;\n      }\n    } else {\n      warned = 0;\n    }\n  }\n\n  return 1;\n  \n/*\n  // here we check wether we will wait for data, i.e. yield time to other threads or not...\n  if (writer->checkWrite(audioBuffersize) && (writer->getNAvail() < audioBuffersize )) {\n//                                           printf(\"pa wait...\\n\");\n    smileCondTimedWait(callbackCond,1000);\n                                           //printf(\"pa wait END...\\n\");\n    return 1;\n  } else {\n    if (writer->getNAvail() >= audioBuffersize ) { smileYield(); return 1; }\n    else return 0;\n  }\n  \n  if (writer->getNAvail() <= 0) {\n    SMILE_ERR(1,\"no input data from portaudio recording device for 1000 ticks after dataMemory level was empty! aborting!\");\n    return 0;\n  }\n\n                                           printf(\"pa re 1...\\n\");\n  return 0;\n  */\n}\n\n\ncPortaudioSource::~cPortaudioSource()\n{\n  if (isPaInit) {\n    smileMutexLock(callbackMtx);\n    stopRecording();\n\n//  usleep(10000);\n// TODO: set a flag to inform the callback recording has stoppped!!\n//   and, do not call Pa_terminate while the callback is running... i.e. introduce a callback mutex!\n    isPaInit = 0;\n    PaError err = Pa_Terminate();\n    if( err != paNoError ) {\n      SMILE_ERR(2,\"PortAudio error (Pa_Terminate): %s\\n\", Pa_GetErrorText( err ) );\n    }\n    smileMutexUnlock(callbackMtx);\n  }\n  smileMutexDestroy(dataFlagMtx);\n  smileMutexDestroy(callbackMtx);\n  smileCondDestroy(callbackCond);\n  if (callbackMatrix != NULL) delete callbackMatrix;\n}\n\n//--------------------------------------------------  portaudio specific\n\n\nint pcmDataToMatrix(const void *buf, cMatrix *m, int nBPS, int nBits, int nChan, int monoMixdown, int selectChannel)\n{\n    int i,c;\n    const int8_t *b8=(int8_t*)buf;\n    const uint8_t *ub8=(uint8_t*)buf;\n    const int16_t *b16 = (int16_t*)buf;\n    const int32_t *b32 = (int32_t*)buf;\n    const float *b32f = (float*)buf;\n\n    if (selectChannel >= 0) { // select a single channel by index from a multi channel recording\n\n      switch(nBPS) {\n        case 1: // 8-bit int\n          for (i=0; i<m->nT; i++) {\n            FLOAT_DMEM tmp;\n            tmp = (FLOAT_DMEM)b8[i*nChan+selectChannel];\n            m->setF(0,i,tmp/(FLOAT_DMEM)127.0);\n          }\n          break;\n        case 2: // 16-bit int\n          for (i=0; i<m->nT; i++) {\n            FLOAT_DMEM tmp;\n            tmp = (FLOAT_DMEM)b16[i*nChan+selectChannel];\n            m->setF(0,i,tmp/(FLOAT_DMEM)32767.0);\n          }\n          break;\n        case 3: // 24-bit int\n          COMP_ERR(\"pcmDataToMatrix: 24-bit wave file with 3 bytes per sample encoding not yet supported!\");\n        /*\n        int24_t *b24 = (int24_t*)buf;\n        for (i=0; i<m->nT; i++) for (c=0; c<nChan; c++) {\n          m->setF(c,i,((FLOAT_DMEM)b24[i*nChan+c])/(32767.0*256.0));\n        } break;\n        */\n          break;\n        case 4: // 32-bit int or 24-bit packed int\n          if (nBits == 24) {\n            for (i=0; i<m->nT; i++) {\n              FLOAT_DMEM tmp;\n              tmp = (FLOAT_DMEM)(b32[i*nChan+selectChannel]&0xFFFFFF);\n              m->setF(0,i,tmp/(FLOAT_DMEM)(32767.0*256.0));\n            }\n            break;\n          } else if (nBits == 32) {\n            for (i=0; i<m->nT; i++) {\n              FLOAT_DMEM tmp;\n              tmp = (FLOAT_DMEM)(b32[i*nChan+selectChannel]);\n              m->setF(0,i,tmp/(FLOAT_DMEM)(32767.0*32767.0*2.0));\n            }\n            break;\n//TODO: case nBits=33  : 32-bit float samples from portaudio....\n\n      /*      for (i=0; i<m->nT; i++) for (c=0; c<nChan; c++) {\n              m->setF(c,i,((FLOAT_DMEM)b32[i*nChan+c])/(32767.0*32767.0*2.0));\n            } break;*/\n        }\n        default:\n          SMILE_ERR(1,\"pcmDataToMatrix: cannot convert unknown sample format to float! (nBPS=%i, nBits=%i)\",nBPS,nBits);\n          return 0;\n      }\n\n    } else if (monoMixdown) {\n\n      switch(nBPS) {\n        case 1: // 8-bit int\n          for (i=0; i<m->nT; i++) {\n            FLOAT_DMEM tmp = 0.0;\n            for (c=0; c<nChan; c++) {\n              tmp += (FLOAT_DMEM)b8[i*nChan+c];\n            }\n            m->setF(0,i,(tmp/(FLOAT_DMEM)nChan)/(FLOAT_DMEM)127.0);\n          }\n          break;\n        case 2: // 16-bit int\n          for (i=0; i<m->nT; i++) {\n            FLOAT_DMEM tmp = 0.0;\n            for (c=0; c<nChan; c++) {\n              tmp += (FLOAT_DMEM)b16[i*nChan+c];\n            }\n            m->setF(0,i,(tmp/(FLOAT_DMEM)nChan)/(FLOAT_DMEM)32767.0);\n          }\n          break;\n        case 3: // 24-bit int\n          COMP_ERR(\"pcmDataToMatrix: 24-bit wave file with 3 bytes per sample encoding not yet supported!\");\n        /*\n        int24_t *b24 = (int24_t*)buf;\n        for (i=0; i<m->nT; i++) for (c=0; c<nChan; c++) {\n          m->setF(c,i,((FLOAT_DMEM)b24[i*nChan+c])/(32767.0*256.0));\n        } break;\n        */\n          break;\n        case 4: // 32-bit int or 24-bit packed int\n          if (nBits == 24) {\n            for (i=0; i<m->nT; i++) {\n              FLOAT_DMEM tmp = 0.0;\n              for (c=0; c<nChan; c++) {\n                tmp += (FLOAT_DMEM)(b32[i*nChan+c]&0xFFFFFF);\n              }\n              m->setF(0,i,(tmp/(FLOAT_DMEM)nChan)/(FLOAT_DMEM)(32767.0*256.0));\n            }\n            break;\n          } else if (nBits == 32) {\n            for (i=0; i<m->nT; i++) {\n              FLOAT_DMEM tmp = 0.0;\n              for (c=0; c<nChan; c++) {\n                tmp += (FLOAT_DMEM)(b32[i*nChan+c]);\n              }\n              m->setF(0,i,(tmp/(FLOAT_DMEM)nChan)/(FLOAT_DMEM)(32767.0*32767.0*2.0));\n            }\n            break;\n//TODO: case nBits=33  : 32-bit float samples from portaudio....\n\n      /*      for (i=0; i<m->nT; i++) for (c=0; c<nChan; c++) {\n              m->setF(c,i,((FLOAT_DMEM)b32[i*nChan+c])/(32767.0*32767.0*2.0));\n            } break;*/\n        }\n        default:\n          SMILE_ERR(1,\"pcmDataToMatrix: cannot convert unknown sample format to float! (nBPS=%i, nBits=%i)\",nBPS,nBits);\n          return 0;\n      }\n\n    } else { // no mixdown, multi-channel matrix output\n\n      switch(nBPS) {\n        case 1: // 8-bit int\n          for (i=0; i<m->nT; i++) for (c=0; c<nChan; c++) {\n            m->setF(c,i,((FLOAT_DMEM)b8[i*nChan+c])/(FLOAT_DMEM)127.0);\n          } break;\n        case 2: // 16-bit int\n          for (i=0; i<m->nT; i++) for (c=0; c<nChan; c++) {\n            m->setF(c,i,((FLOAT_DMEM)b16[i*nChan+c])/(FLOAT_DMEM)32767.0);\n          } break;\n        case 3: // 24-bit int\n        //  COMP_ERR(\"pcmDataToMatrix: 24-bit wave file with 3 bytes per sample encoding not yet supported!\");\n        \n        //b8 = (uint8_t*)buf;\n        for (i=0; i<m->nT; i++) \n          for (c=0; c<nChan; c++) {\n            FLOAT_DMEM tmp = (FLOAT_DMEM)ub8[i*3*nChan+c] * (FLOAT_DMEM)(256.0*256.0) + (FLOAT_DMEM)ub8[i*3*nChan+c+1]*(FLOAT_DMEM)256.0 + (FLOAT_DMEM)ub8[i*3*nChan+c+2]; \n            m->setF(c,i,(tmp/(FLOAT_DMEM)(32767.0*256.0)));\n          } break;\n        \n        //  break;\n        case 4: // 32-bit int or 24-bit packed int\n          if (nBits == 24) {\n            for (i=0; i<m->nT; i++) for (c=0; c<nChan; c++) {\n              //m->setF(c,i,((FLOAT_DMEM)(b32[i*nChan+c]&0xFFFFFF))/(32767.0*32767.0*2.0));\n              m->setF(c,i,((FLOAT_DMEM)((b32[i*nChan+c]&0xFFFFFFFF)>>8))/(FLOAT_DMEM)(32767.0*256.0));\n            } break;\n          } else if (nBits == 32) {\n            for (i=0; i<m->nT; i++) for (c=0; c<nChan; c++) {\n              // byte swap:\n              uint8_t xx[4];\n              int32_t *xxx = (int32_t *)&xx;\n              *xxx = b32[i*nChan+c];\n/*\n              uint8_t tmp2 = xx[0];\n              xx[0] = xx[3];\n              xx[3] = tmp2;\n              tmp2 = xx[1];\n              xx[1] = xx[2];\n              xx[2] = tmp2;*/\n              m->setF(c,i,((FLOAT_DMEM)(*xxx))/(FLOAT_DMEM)(32767.0*32767.0*2.0));\n//              m->setF(c,i,((FLOAT_DMEM)b32[i*nChan+c])/(32767.0*32767.0*4.0));\n\n            } break;\n          } else if (nBits == 33) {\n            for (i=0; i<m->nT; i++) for (c=0; c<nChan; c++) {\n              m->setF(c,i,((FLOAT_DMEM)b32f[i*nChan+c]));\n            } break;\n          }\n//TODO: case nBits=33  : 32-bit float samples from portaudio....\n\n\n        default:\n          SMILE_ERR(1,\"pcmDataToMatrix: cannot convert unknown sample format to float! (nBPS=%i, nBits=%i)\",nBPS,nBits);\n          return 0;\n      }\n    }\n    \n    return 1;\n}\n\n/* This routine will be called by the PortAudio engine when audio is available.\n** It may be called at interrupt level on some machines so don't do anything\n** that could mess up the system like calling malloc() or free().\n*/\nstatic int paSource_recordCallback( const void *inputBuffer, void *outputBuffer,\n                           unsigned long framesPerBuffer,\n#ifdef HAVE_PORTAUDIO_V19\n                           const PaStreamCallbackTimeInfo* timeInfo,\n                           PaStreamCallbackFlags statusFlags,\n#else // V18 (old API)\n                           PaTimestamp outTime,\n#endif\n                           void *userData )\n{\n  cPortaudioSource * obj = (cPortaudioSource *)userData;\n\n  if (obj == NULL) { return paAbort; }\n\n  if (!smileMutexLock(obj->callbackMtx)) return paAbort;\n  \n  if (obj->isAbort() || obj->isPaused()) {\n    smileMutexUnlock(obj->callbackMtx);\n    return paAbort;\n  }\n  cDataWriter * writer = obj->getWriter();\n\n  //printf(\"PA_callback data arrived %i!!\\n\",framesPerBuffer); fflush(stdout);\n\n  if (writer->checkWrite(framesPerBuffer)) {\n\n    // make matrix.. // TODO... move this \"new\" to the init code...!\n    cMatrix * mat = obj->callbackMatrix; //new cMatrix( obj->getChannels(), framesPerBuffer );\n    if (mat==NULL) {\n      smileMutexUnlock(obj->callbackMtx);\n      return paAbort;\n    }\n  \n    pcmDataToMatrix(inputBuffer, mat, obj->getNBPS(), obj->getNBits(), obj->getChannels(), obj->isMonoMixdown(), obj->getSelectedChannel());\n\n    obj->setNewDataFlag();\n    smileCondSignal(obj->callbackCond);\n\n    // save to datamemory\n    writer->setNextMatrix(mat);\n    // TODO... move this \"delete\" to the destructor...!\n//    delete mat;\n  } else {\n    //printf(\"ERR: audio data was lost! increase data memory buffersize of cPortaudioSource components!\\n\");\n  }\n\n  smileMutexUnlock(obj->callbackMtx);\n  return paContinue;\n}\n\n\nint cPortaudioSource::startRecording()\n{\n    PaStreamParameters  inputParameters;\n    PaError             err = paNoError;\n//paFrames=audio\n    // ????? //if (paFrames == 0) return 0;\n#ifdef HAVE_PORTAUDIO_V19\n    if (Pa_IsStreamActive( stream ) == 1) {\n#else\n    if (Pa_StreamActive( stream ) == 1) {\n#endif\n      SMILE_WRN(2,\"portAudio stream is already active (in startRecording).\");\n      return 1;\n    }\n\n    if (deviceId < 0) {\n      inputParameters.device = Pa_GetDefaultInputDevice(); /* default input device */\n    } else {\n      inputParameters.device = deviceId;\n    }\n//\n\n    SMILE_MSG(2,\"recording from portAudio device with index %i\",inputParameters.device);\n    inputParameters.channelCount = channels;\n    switch (nBits) {\n      case 8: inputParameters.sampleFormat = paInt8; break;\n      case 16: inputParameters.sampleFormat = paInt16; break;\n      case 24: inputParameters.sampleFormat = paInt24; break;\n      case 32: inputParameters.sampleFormat = paInt32; break;\n      case 33: inputParameters.sampleFormat = paFloat32; break;\n      default:\n        COMP_ERR(\"invalid number of bits requested: %i (allowed: 8, 16, 24, 32, 33(for 23-bit float))\\n\",nBits);\n    }\n\n#ifdef HAVE_PORTAUDIO_V19\n    const PaDeviceInfo * info = Pa_GetDeviceInfo( inputParameters.device );\n    if (info != NULL) {\n      inputParameters.suggestedLatency =\n        info->defaultLowInputLatency;\n    } else {\n      inputParameters.suggestedLatency = 0;\n    }\n    inputParameters.hostApiSpecificStreamInfo = NULL;\n#endif\n\n//    obj->bufWrapper  = pcmBufferMakeWrapper( obj->bufWrapper, 0, 1, SAMPLETYPE_I16, 0, 0, NULL);\n    /* Setup recording stream -------------------------------------------- */\n    err = Pa_OpenStream(\n              &(stream),\n#ifdef HAVE_PORTAUDIO_V19\n              &inputParameters,\n              NULL,                  /* &outputParameters, */\n#else // V18 (old API)\n              inputParameters.device,\n              inputParameters.channelCount,\n              inputParameters.sampleFormat,\n              NULL,\n              paNoDevice, 0, 0, NULL,\n#endif\n              sampleRate,\n              audioBuffersize,\n#ifndef HAVE_PORTAUDIO_V19\n              1,\n#endif\n              paClipOff,      /* we won't output out of range samples so don't bother clipping them */\n              paSource_recordCallback,\n              (void*) this );\n\n    if( err != paNoError ) {\n        COMP_ERR(\"error opening portaudio recording stream (code %i) \\n  check samplerate(-> %i , maybe it is not supported?) \\n  maybe incorrect device? (\\\"listDevices=1\\\" in config file displays a list of devices)\\n\",err,sampleRate);\n    }\n\n\tsmileMutexLock(callbackMtx);\n    err = Pa_StartStream( stream );\n    if( err != paNoError ) COMP_ERR(\"cannot start portaudio stream (code %i)\\n\",err);\n\n//    obj->absTimeStart = liveInput_getTime();\n    streamStatus = PA_STREAM_STARTED;\n    smileMutexUnlock(callbackMtx);\n\n    return 1;\n}\n\nint cPortaudioSource::stopRecording()\n{\n  PaError             err = paNoError;\n  if (streamStatus == PA_STREAM_STOPPED) return 0;\n\n  streamStatus =  PA_STREAM_STOPPED;\n  // TODO: timestamp!\n//  absTimeStop = liveInput_getTime();\n\n  err = Pa_CloseStream( stream );\n  if( err != paNoError ) {\n    SMILE_ERR(1,\"cannot close portaudio stream (code %i)\\n\",err);\n    return 0;\n  }\n\n  return 1;\n}\n\nint cPortaudioSource::stopRecordingWait()\n{\n  PaError             err = paNoError;\n  if (streamStatus == PA_STREAM_STOPPED) return 0;\n\n  streamStatus =  PA_STREAM_STOPPED;\n  // TODO: timestamp!\n//  absTimeStop = liveInput_getTime();\n\n  err = Pa_StopStream( stream );\n  if( err != paNoError ) {\n    SMILE_ERR(1,\"cannot close portaudio stream (code %i)\\n\",err);\n    return 0;\n  }\n\n  return 1;\n}\n\nvoid cPortaudioSource::printDeviceList(void)\n{\n\n//  PaError err = Pa_Initialize();\n//  if( err != paNoError ) {\n//    COMP_ERR(\"error initialising portaudio library (code %i)\\n\",err);\n//    return 0;\n//  }\n\n  // query devices:\n  SMILE_PRINT(\"== cPortAudioSource ==  There are %i audio devices:\", numDevices );\n  if( numDevices < 0 ) {\n     SMILE_ERR(1, \"Pa_CountDevices returned 0x%x\\n\", numDevices );\n     return;\n  }\n  if( numDevices == 0 ) {\n     SMILE_ERR(1, \"No PortAudio audio devices were found! (Pa_CountDevices()=0)\\n\", numDevices );\n     return;\n  }\n\n  const PaDeviceInfo *deviceInfo;\n\n  int i;\n  for( i=0; i<numDevices; i++ )\n  {\n     deviceInfo = Pa_GetDeviceInfo( i );\n     SMILE_PRINT(\"  -> Device #%i: '%s'\\n       #inputChan=%i #outputChan=%i\\n\",i,deviceInfo->name, deviceInfo->maxInputChannels, deviceInfo->maxOutputChannels);\n  }\n\n#ifdef HAVE_PORTAUDIO_V19\n  SMILE_PRINT(\"  The default device is #%i\\n\",Pa_GetDefaultInputDevice());\n#else\n  SMILE_PRINT(\"  The default device is #%i\\n\",Pa_GetDefaultInputDeviceID());\n#endif\n\n//  err = Pa_Terminate();\n//  if( err != paNoError ) {\n//    SMILE_ERR(2,\"PortAudio error (Pa_Terminate): %s\\n\", Pa_GetErrorText( err ) );\n//  }\n\n  return;\n}\n\n#endif // HAVE_PORTAUDIO\n"
  },
  {
    "path": "src/portaudio/portaudioWavplayer.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nportaudio dataSink for live recording from sound device\nknown to work on windows, linux, and mac\n\n*/\n\n\n#include <portaudio/portaudioWavplayer.hpp>\n#define MODULE \"cPortaudioWavplayer\"\n\n#ifdef HAVE_PORTAUDIO\n\n\n\n\nSMILECOMPONENT_STATICS(cPortaudioWavplayer)\n\nSMILECOMPONENT_REGCOMP(cPortaudioWavplayer)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CPORTAUDIOWAVPLAYER;\n  sdescription = COMPONENT_DESCRIPTION_CPORTAUDIOWAVPLAYER;\n\n  // we inherit cDataSink configType and extend it:\n  SMILECOMPONENT_CREATE_CONFIGTYPE\n    //SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSink\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"monoMixdown\",\"mix down all channels to 1 mono channel\",0);\n    ct->setField(\"device\",\"PortAudio device to use (device number)\",-1);\n    ct->setField(\"listDevices\",\"(1/0=yes/no) list available portaudio devices during initialisation phase\",0);\n    ct->setField(\"sampleRate\",\"force output sample rate (0=determine sample rate from input level)\",0);\n\n    ct->setField(\"wavefile\",\"The filenames of the wavesample(s) to play (triggered via smile message or numbers read from the input level).\",(const char*)NULL,ARRAY_TYPE);\n    ct->setField(\"keyword\",\"List of keywords or classnames (in same order as wave files)\",(const char*)NULL,ARRAY_TYPE);\n    ct->setField(\"indices\",\"List of class indicies for classification results (same order as wave files)\",-1.0,ARRAY_TYPE);\n\n    ct->setField(\"semaineCallbackRcpt\",\"Reciepient of SEMAINE callback message for echo feedback supression (start speaking / stop speaking messages, i.e. when player starts playing/stops playing).\",(const char*)NULL);\n    ct->setField(\"audioBuffersize\",\"size of port audio playback buffer in samples (overwrites audioBuffersize_sec, if set)\",1000);\n  )\n  SMILECOMPONENT_MAKEINFO(cPortaudioWavplayer);\n}\n\nSMILECOMPONENT_CREATE(cPortaudioWavplayer)\n\n//-----\n\ncPortaudioWavplayer::cPortaudioWavplayer(const char *_name) :\n  cSmileComponent(_name),\n  audioBuffersize(-1),\n  audioBuffersize_sec(-1.0),\n  eof(0),  abort(0),\n  monoMixdown(0),\n  deviceId(0),\n  listDevices(0),\n  sampleRate(0),\n  channels(1),\n  inputChannels(0),\n  playback(0),\n  playPtr(0),\n  playIndex(0),\n  dataFlag(1),\n  wavedata(NULL),\n  wavelength(NULL),\n  numKw(0),\n  keywords(NULL),\n  nWavs(0),\n  wavsLoaded(0),\n  numInd(0),\n  indices(NULL),\n  nBits(16),\n  isFirst(1),\n  isPaInit(0),\n  stream(NULL),\n  streamStatus(PA_STREAM_STOPPED)\n{\n  //smileMutexCreate(dataFlagMtx);\n  smileMutexCreate(callbackMtx);\n  smileCondCreate(callbackCond);\n}\n\nvoid cPortaudioWavplayer::fetchConfig()\n{\n  //cDataSink::fetchConfig();\n  \n  monoMixdown = getInt(\"monoMixdown\");\n  if (monoMixdown) { \n    SMILE_IDBG(2,\"monoMixdown enabled!\"); \n    channels = 1;\n  } else {\n    channels = 2;\n  }\n\n  if (isSet(\"audioBuffersize\")) {\n    audioBuffersize = getInt(\"audioBuffersize\");\n    if (audioBuffersize < 1) audioBuffersize=1;\n    SMILE_IDBG(2,\"audioBuffersize = %i\",audioBuffersize);\n  }\n  if (isSet(\"audioBuffersize_sec\")) {\n    audioBuffersize_sec = getInt(\"audioBuffersize_sec\");\n    if (audioBuffersize_sec < 1) audioBuffersize_sec = 1;\n    SMILE_DBG(2,\"audioBuffersize_sec = %i\",audioBuffersize_sec);\n  } \n\n  listDevices = getInt(\"listDevices\");\n  if (listDevices) { SMILE_IDBG(3,\"listDevices enabled!\"); }\n\n  deviceId = getInt(\"device\");\n  SMILE_IDBG(2,\"using portAudio device # %i\",deviceId);\n\n  sampleRate = getInt(\"sampleRate\");\n  if (sampleRate != 0) { SMILE_IDBG(2,\"user-defined playback sample rate = %i\",sampleRate); }\n\n  numKw = getArraySize(\"keyword\");\n  keywords = (const char **)calloc(1,sizeof(const char*)*numKw);\n  int i;\n  for (i=0; i<numKw; i++) {\n    keywords[i] = getStr_f(myvprint(\"keyword[%i]\",i));\n  }\n\n  numInd = getArraySize(\"indices\");\n  indices = (int *)calloc(1,sizeof(int*)*numInd);\n  for (i=0; i<numInd; i++) {\n    indices[i] = getInt_f(myvprint(\"indices[%i]\",i));\n  }\n\n  semaineCallbackRcpt = getStr(\"semaineCallbackRcpt\");\n//  channels = getInt(\"channels\");\n//  if (channels < 1) channels=1;\n//  SMILE_DBG(2,\"No. of recording channels = %i\",channels);\n\n  /*nBits = getInt(\"nBits\");\n  switch(nBits) {\n    case 8: nBPS=1; break;\n    case 16: nBPS=2; break;\n    case 24: nBPS=4; break;\n    case 32: nBPS=4; break;\n    case 33: nBPS=4; break;\n    default:\n      SMILE_IERR(1,\"invalid number of bits requested: %i (allowed: 8, 16, 24, 32, 33(for 23-bit float))\\n   Setting number of bits to default (16)\",nBits);\n      nBits=16;\n  }\n  SMILE_IDBG(2,\"No. of bits per sample = %i\",nBits);\n*/\n  nBits = 33;\n  nBPS=4;\n\n//  // TODO: buffersize in seconds.. AND unlink buffersize = buffersize in datamemory!\n}\n\n\nint cPortaudioWavplayer::myConfigureInstance()\n{\n  // pre-load wave files snippets..\n  if (!wavsLoaded) {\n    nWavs = getArraySize(\"wavefile\");\n    wavedata = (float **)calloc(1,sizeof(float *)*nWavs);\n    wavelength = (long *)calloc(1,sizeof(long)*nWavs);\n    int i;\n    for (i=0; i<nWavs; i++) {\n      // open wave file\n      const char * filename = getStr_f(myvprint(\"wavefile[%i]\",i));\n      FILE * filehandle;\n      filehandle = fopen(filename, \"rb\");\n      if (filehandle == NULL) COMP_ERR(\"failed to open wave file '%s'\",filename);\n  \n      // read size from header\n      sWaveParameters pcmParam;\n      smilePcm_readWaveHeader(filehandle, &pcmParam, filename);\n\n      // check whether files have same sampling rate and channels\n      if (sampleRate == 0) sampleRate = pcmParam.sampleRate;\n      else if (sampleRate != pcmParam.sampleRate) {\n        SMILE_IERR(1,\"Error loading wave files. The file '%s' has a sample rate (%i) which differs from the other (previously loaded) files (%i).\",filename,pcmParam.sampleRate,sampleRate);\n        COMP_ERR(\"aborting\");\n      }\n\n      if (inputChannels==0) inputChannels = pcmParam.nChan;\n      else if (inputChannels != pcmParam.nChan) {\n        SMILE_IERR(1,\"mismatch in number of channels while loading wave files!\");\n        COMP_ERR(\"aborting\");\n      }\n\n      // allocate memory\n      wavelength[i] = pcmParam.blockSize*pcmParam.nBlocks;\n      wavedata[i] = (float*)calloc(1,sizeof(float)*wavelength[i]);\n\n      // load data\n      smilePcm_readSamples(&filehandle, &pcmParam, wavedata[i], pcmParam.nChan, wavelength[i], monoMixdown);\n\n      if (filehandle != NULL) fclose(filehandle);\n    }\n    wavsLoaded = 1;\n  }\n\n\n  // initialise port audio\n  if (!isPaInit) {\n    PaError err = Pa_Initialize(); \n    if( err != paNoError ) COMP_ERR(0,\"error initialising portaudio library (code %i)\\n\",err);\n    isPaInit=1;\n  }\n\n#ifdef HAVE_PORTAUDIO_V19\n  numDevices = Pa_GetDeviceCount();\n#else\n  numDevices = Pa_CountDevices();\n#endif\n\n  // list devices...\n  if (listDevices) {\n    if (listDevices != -1) {\n      printDeviceList();\n      listDevices=-1;\n      SMILE_IMSG(1,\"Device list was printed, cPortaudioWavplayer::myConfigureInstance will now return 0 in order to stop openSMILE initialisation!\");\n    }\n    return 0;\n  } else {\n    if (numDevices <= 0) {\n      SMILE_IERR(1,\"NO PortAudio devices found! Cannot play live audio!\");\n    }\n  }\n  \n  return cSmileComponent::myConfigureInstance();\n}\n\nint cPortaudioWavplayer::myFinaliseInstance()\n{\n  int ret;\n\n  ret = cSmileComponent::myFinaliseInstance();\n\n  if (ret) {\n    SMILE_IDBG(2,\"setting playback sampleRate: %i Hz\",sampleRate);\n    //    printf(\"XXXXXXXXXXXXXXx computed sampleRate as: %i Hz (per = %f)\\n\",sampleRate,reader->getLevelT()*1000);\n  }\n\n  return ret;\n}\n\n#ifdef HAVE_JULIUSLIB\n// return value = -1 , if no keyword was found in current result string\n// TODO: set a flag if multiple keywords are found in string, currently we return after finding the first keyword\nint cPortaudioWavplayer::getPlayIdxFromKeyword(juliusResult *k) \n{\n  int i,j;\n\n  // for each word\n  for (i=0; i<k->numW; i++) {\n    int found = 0;\n    // find in keyword list, and get the playback index\n    for (j=0; j<numKw; j++) {\n\n      // NOTE: keyword comparison is case INsensitive ! is that ok?\n      if (!strcasecmp( k->word[i], keywords[j] )) {\n        return j;\n      }\n\n    }\n  }\n\n  return -1;\n}\n#endif\n\nint cPortaudioWavplayer::getPlayIdxFromClassname(const char *cls) \n{\n  int j;\n\n  // find in keyword list, and get the playback index\n  for (j=0; j<numKw; j++) {\n\n    // NOTE: keyword comparison is case INsensitive ! is that ok?\n    if (!strcasecmp( cls, keywords[j] )) {\n      return j;\n    }\n\n  }\n\n  return -1;\n}\n\nint cPortaudioWavplayer::getPlayIdxFromClassidx(float idx) \n{\n  int j;\n  if (idx < 0) return -1;\n\n  // find in keyword list, and get the playback index\n  for (j=0; j<numInd; j++) {\n\n    // NOTE: keyword comparison is case INsensitive ! is that ok?\n    if ((int)idx == indices[j] ) {\n      return j;\n    }\n\n  }\n\n  return -1;\n}\nvoid cPortaudioWavplayer::sendEndMessage()\n{\n  cComponentMessage msg(\"semaineCallback\");\n  msg.msgname[0] = 'e';\n  msg.msgname[1] = 'n';\n  msg.msgname[2] = 'd';\n  sendComponentMessage( semaineCallbackRcpt, &msg );\n}\n\nint cPortaudioWavplayer::triggerPlayback(int idx) \n{\n  if (isFirst) {\n    isFirst = 0;\n    return 0;\n  }\n\n  cComponentMessage msg(\"semaineCallback\");\n  msg.msgname[0] = 's';\n  msg.msgname[1] = 't';\n  msg.msgname[2] = 'a';\n  msg.msgname[3] = 'r';\n  msg.msgname[4] = 't';\n  sendComponentMessage( semaineCallbackRcpt, &msg );\n  \n  // mutex lock\n  smileMutexLock(callbackMtx);\n\n  if (idx < 0) idx = 0;\n  if (idx >= nWavs) idx = nWavs-1;\n\n  if (playback) {\n    smileMutexUnlock(callbackMtx);\n    return 0;\n  }\n\n  playback = 1;\n  playIndex = idx;\n  playPtr = 0;\n\n  // mutex unlock\n  smileMutexUnlock(callbackMtx);\n\n  return 1;\n}\n\nint cPortaudioWavplayer::processComponentMessage( cComponentMessage *_msg )\n{\n  int playIdx = -1;\n  // get a keyword message, trigger playback\n  if (isMessageType(_msg,\"asrKeywordOutput\")) {  \n#ifdef HAVE_JULIUSLIB\n    if (_msg->intData[0] == 1) { // pass 1\n      SMILE_IDBG(3,\"received 'asrKeywordOutput' message\");\n      juliusResult *k = (juliusResult *)(_msg->custData);\n      playIdx = getPlayIdxFromKeyword(k);\n      if (playIdx >= 0) triggerPlayback(playIdx);\n    }\n    return 1;  // message was processed\n#else\n    SMILE_IWRN(2, \"asrKeywordOutput message received, but portaudio components were compiled without julius support (HAVE_JULIUSLIB not defined).\");\n    return 0;\n#endif\n  } else if (isMessageType(_msg,\"classificationResult\")) {\n    SMILE_IDBG(3,\"received 'classificationResult' message\");\n    // get play index from class string....\n    playIdx = getPlayIdxFromClassname(_msg->msgtext);\n    if (playIdx == -1) {\n      playIdx = getPlayIdxFromClassidx((float)(_msg->floatData[0]));\n    }\n    if (playIdx >= 0) triggerPlayback(playIdx);\n  }\n  return 0;\n}\n\nint cPortaudioWavplayer::myTick(long long t)\n{\n  if (streamStatus == PA_STREAM_STOPPED) {\n    if (!startPlayback()) return 0;\n  }\n\n  return playback;\n}\n\n\ncPortaudioWavplayer::~cPortaudioWavplayer()\n{\n  if (isPaInit) {\n    smileMutexLock(callbackMtx);\n    stopPlaybackWait();\n\n// TODO: set a flag to inform the callback recording has stoppped!!\n//   and, do not call Pa_terminate while the callback is running... i.e. introduce a callback mutex!\n    isPaInit = 0;\n    PaError err = Pa_Terminate();\n    if( err != paNoError ) {\n      SMILE_ERR(2,\"PortAudio error (Pa_Terminate): %s\\n\", Pa_GetErrorText( err ) );\n    }\n    smileMutexUnlock(callbackMtx);\n  }\n\n  //smileMutexDestroy(dataFlagMtx);\n  smileMutexDestroy(callbackMtx);\n  smileCondDestroy(callbackCond);\n\n  if (wavedata != NULL) {\n    int i;\n    for (i=0; i<nWavs; i++) {\n      free(wavedata[i]);\n    }\n    free(wavedata);\n  }\n  if (wavelength != NULL) { free(wavelength); }\n\n  if (keywords != NULL) free(keywords);\n  if (indices != NULL) free(indices);\n}\n\n//--------------------------------------------------  portaudio specific\n\n\n// channels = number of output channels (can be 1 or 2)\nint pcmFloatChannelConvert(void *outputBuffer, long __N, float *in, int iChan, int oChan, int mixdown=0) \n{\n  int i,c;\n\n  float *out = (float*)outputBuffer;\n  \n  for (i=0; i<__N; i++) {\n    if (mixdown) {\n      out[i] = 0.0;\n      for (c=0; c<iChan; c++) {\n        out[i] += in[i*iChan+c];\n      }\n    } else {\n      int minc = oChan;\n      if (iChan < minc) minc = iChan;\n      for (c=0; c<oChan; c++) {\n        out[i*oChan+c] = in[i*iChan+c];\n      }\n    }\n  }\n  return 1;\n}\n\n/* This routine will be called by the PortAudio engine when audio is available.\n** It may be called at interrupt level on some machines so don't do anything\n** that could mess up the system like calling malloc() or free().\n*/\nstatic int paSink_playbackCallback( const void *inputBuffer, void *outputBuffer,\n                           unsigned long framesPerBuffer,\n#ifdef HAVE_PORTAUDIO_V19\n                           const PaStreamCallbackTimeInfo* timeInfo,\n                           PaStreamCallbackFlags statusFlags,\n#else // V18 (old API)\n                           PaTimestamp outTime,\n#endif\n                           void *userData )\n{\n  cPortaudioWavplayer * obj = (cPortaudioWavplayer *)userData;\n\n  if (obj == NULL) { return paAbort; }\n\n\n  if (!smileMutexLock(obj->callbackMtx)) return paAbort;\n  if (obj->isAbort()) {\n    smileMutexUnlock(obj->callbackMtx);\n    return paAbort;\n  }\n  if (outputBuffer==NULL) {\n    smileMutexUnlock(obj->callbackMtx);\n\t  return paContinue;\n  }\n\n  if (obj->playback) {\n\n    if (obj->playPtr+(long)framesPerBuffer > obj->wavelength[obj->playIndex]) {\n      // EOF\n      // copy last bits of buffer\n      pcmFloatChannelConvert(outputBuffer, obj->wavelength[obj->playIndex] - obj->playPtr, obj->wavedata[obj->playIndex]+obj->playPtr, obj->getInputChannels(), obj->getChannels(), obj->isMonoMixdown());\n      // fill remaining buffer with zeros\n      int i;\n      for (i=obj->wavelength[obj->playIndex] - obj->playPtr; i<(long)framesPerBuffer; i++) { ((float*)outputBuffer)[i] = 0.0; }\n\n      obj->playback=0;\n      obj->playIndex=0;\n      \n      obj->sendEndMessage();\n\n      /* continuous loop playback for debugging this component\n      \n      if (obj->playIndex < obj->nWavs-1) {\n      obj->playIndex++;\n      obj->playback=1;\n      }*/\n\n      obj->playPtr=0;\n    \n    } else {\n\n      // playback of current wave file snippet\n      pcmFloatChannelConvert(outputBuffer, framesPerBuffer, obj->wavedata[obj->playIndex]+obj->playPtr, obj->getInputChannels(), obj->getChannels(), obj->isMonoMixdown());\n      obj->playPtr += framesPerBuffer;\n\n    }\n    \n\n  } else {\n    // output silence\n\n    memset(outputBuffer, 0, sizeof(float)*obj->getChannels()*framesPerBuffer);\n  }\n\n  smileMutexUnlock(obj->callbackMtx);\n  return paContinue;\n}\n\n\nint cPortaudioWavplayer::startPlayback()\n{\n    PaStreamParameters  outputParameters;\n    PaError             err = paNoError;\n\n#ifdef HAVE_PORTAUDIO_V19\n    if (Pa_IsStreamActive( stream ) == 1) {\n#else\n    if (Pa_StreamActive( stream ) == 1) {\n#endif\n      SMILE_WRN(2,\"portAudio stream is already active (in startPlayback).\");\n      return 1;\n    }\n\n    if (deviceId < 0) {\n      outputParameters.device = Pa_GetDefaultOutputDevice(); /* default input device */\n    } else {\n      outputParameters.device = deviceId;\n    }\n//\n\n    SMILE_MSG(2,\"playing on portAudio device with index %i\",outputParameters.device);\n    outputParameters.channelCount = channels;\n\toutputParameters.sampleFormat = paFloat32;\n\n/*\tswitch (nBits) {\n      case 8: outputParameters.sampleFormat = paInt8; break;\n      case 16: outputParameters.sampleFormat = paInt16; break;\n      case 24: outputParameters.sampleFormat = paInt24; break;\n      case 32: outputParameters.sampleFormat = paInt32; break;\n      case 33: outputParameters.sampleFormat = paFloat32; break;\n      default:\n        COMP_ERR(\"invalid number of bits requested: %i (allowed: 8, 16, 24, 32, 33(for 23-bit float))\\n\",nBits);\n    }*/\n\n#ifdef HAVE_PORTAUDIO_V19\n    const PaDeviceInfo * info = Pa_GetDeviceInfo( outputParameters.device );\n    if (info != NULL) {\n      outputParameters.suggestedLatency =\n        info->defaultLowInputLatency;\n    } else {\n      outputParameters.suggestedLatency = 0;\n    }\n    outputParameters.hostApiSpecificStreamInfo = NULL;\n#endif\n\n    /* Setup recording stream -------------------------------------------- */\n    err = Pa_OpenStream(\n              &(stream),\n#ifdef HAVE_PORTAUDIO_V19\n              NULL,\n              &outputParameters,\n#else // V18 (old API)\n              paNoDevice,\n              0,\n              0,\n              NULL,\n              outputParameters.device, \n\t\t\t  outputParameters.channelCount, \n\t\t\t  outputParameters.sampleFormat, \n\t\t\t  NULL,\n#endif\n              sampleRate,\n              audioBuffersize,\n#ifndef HAVE_PORTAUDIO_V19\n              1,\n#endif\n              paClipOff,      /* we won't output out of range samples so don't bother clipping them */\n              paSink_playbackCallback,\n              (void*) this );\n\n    if( err != paNoError ) {\n        COMP_ERR(\"error opening portaudio playback stream (code %i) \\n  check samplerate(-> %i , maybe it is not supported?) \\n  maybe incorrect device? (\\\"listDevices=1\\\" in config file displays a list of devices)\\n\",err,sampleRate);\n    }\n\n\tsmileMutexLock(callbackMtx);\n    err = Pa_StartStream( stream );\n    if( err != paNoError ) COMP_ERR(\"cannot start portaudio stream (code %i)\\n\",err);\n    streamStatus = PA_STREAM_STARTED;\n    smileMutexUnlock(callbackMtx);\n\n    return 1;\n}\n\nint cPortaudioWavplayer::stopPlayback()\n{\n  PaError             err = paNoError;\n  if (streamStatus == PA_STREAM_STOPPED) return 0;\n\n  streamStatus =  PA_STREAM_STOPPED;\n\n  abort = 1;\n\n  err = Pa_CloseStream( stream );\n  if( err != paNoError ) {\n    SMILE_ERR(1,\"cannot close portaudio stream (code %i)\\n\",err);\n    return 0;\n  }\n\n  return 1;\n}\n\nint cPortaudioWavplayer::stopPlaybackWait()\n{\n  PaError             err = paNoError;\n  if (streamStatus == PA_STREAM_STOPPED) return 0;\n\n  streamStatus =  PA_STREAM_STOPPED;\n\n  abort = 1;\n\n  smileMutexUnlock(callbackMtx);\n  err = Pa_StopStream( stream );\n  smileMutexLock(callbackMtx);\n\n  if( err != paNoError ) {\n    SMILE_ERR(1,\"cannot close portaudio stream (code %i)\\n\",err);\n    return 0;\n  }\n\n  return 1;\n}\n\nvoid cPortaudioWavplayer::printDeviceList(void)\n{\n  // query devices:\n  SMILE_PRINT(\"== cPortAudioSink ==  There are %i audio devices:\", numDevices );\n  if( numDevices < 0 ) {\n     SMILE_ERR(1, \"Pa_CountDevices returned 0x%x\\n\", numDevices );\n     return;\n  }\n  if( numDevices == 0 ) {\n     SMILE_ERR(1, \"No PortAudio audio devices were found! (Pa_CountDevices()=0)\\n\", numDevices );\n     return;\n  }\n\n  const PaDeviceInfo *deviceInfo;\n\n  int i;\n  for( i=0; i<numDevices; i++ )\n  {\n     deviceInfo = Pa_GetDeviceInfo( i );\n     SMILE_PRINT(\"  -> Device #%i: '%s'\\n       #inputChan=%i #outputChan=%i\\n\",i,deviceInfo->name, deviceInfo->maxInputChannels, deviceInfo->maxOutputChannels);\n  }\n\n#ifdef HAVE_PORTAUDIO_V19\n  SMILE_PRINT(\"  The default device is #%i\\n\",Pa_GetDefaultOutputDevice());\n#else\n  SMILE_PRINT(\"  The default device is #%i\\n\",Pa_GetDefaultOutputDeviceID());\n#endif\n\n}\n\n#endif // HAVE_PORTAUDIO\n"
  },
  {
    "path": "src/rnn/rnn.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n#include <core/smileCommon.hpp>\n#include <rnn/rnn.hpp>\n#include <string>\n#include <smileutil/JsonClasses.hpp>\n#include <fstream>\n\n#ifdef BUILD_MODELCRYPT\n#include <private/modelEncryption.hpp>\n#endif\n\n#define MODULE \"smileRnn\"\n\n#ifdef BUILD_RNN\n\nstatic const FLOAT_NN expLim = log(FLT_MAX);\n\nFLOAT_NN nnTf_logistic(FLOAT_NN x)\n{\n  if (x > expLim) { return 1.0; }\n  else if (x < -expLim) { return 0.0; }\n  return (FLOAT_NN)(1.0 / (1.0 + exp(-x)));\n}\n\n/**************************** cNnLSTMcell *******************************************/\n\nvoid cNnLSTMcell::setPeepWeights(FLOAT_NN *x, long N, int copy=1)\n{ // function currently works for 1 cell per block only..\n  if (N != 3*nCells) { // 3 is the number of gates... thus the number of peephole connections per cell\n    RNN_ERR(1, \"cNnLSTMcell: number of peep weights in cell %i.%i (%i) does not match expected number (%i x %i (=cellsPerBlock) = %i)!\",\n            (int)layerIndex, (int)cellIndex, (int)N, 3, (int)nCells, 3*(int)nCells);\n  }\n  if (copy) {\n    peep = (FLOAT_NN*)malloc(sizeof(FLOAT_NN)*N);\n    memcpy(peep, x, N*sizeof(FLOAT_NN));\n  } else {\n    peep = x;\n  }\n  nPeeps = N;\n}\n\n// reset the cell\nvoid cNnLSTMcell::reset() \n{\n  // reset parent cell object\n  cNnNNcell::reset();\n  // reset cell state\n  long i;\n  for (i=0; i<nCells; i++) { \n    sc[i] = 0.0;\n  }\n  // reset outputs\n  if ((cellOutputs != NULL) && (nOutputs > 1)) {\n    long i; for (i=0; i<nCells; i++) { cellOutputs[i] = 0.0; }\n  }\n}\n\n\n// feed data through the cell and compute the cell output (return value)\n// note: for an lstm block with nCells > 1, the number of output values will be > 1... how to handle this??\nconst FLOAT_NN * cNnLSTMcell::forward(const FLOAT_NN *x, long *N) \n{\n  // x[0] IG input\n  // x[1] FG input\n  // x[2] cell input to cell 1\n  //( x[3] cell input to cell 2...)\n  //( x[4] cell input to cell 3...)\n  // ...\n  // x[N] OG input\n\n  FLOAT_NN actIG, actFG, actOG;\n\n  if (nCells == 1) { // quick version for one cell per block\n\n    // input Gate\n    actIG = transferGate->f( x[0] + (*sc)*peep[0] );\n    // forget Gate\n    actFG = transferGate->f( x[1] + (*sc)*peep[1] );\n    // cell\n    *sc = actIG * *cNnNNcell::forward(x+2) + (*sc)*actFG;\n    // output Gate\n    actOG = transferGate->f( x[3] + (*sc)*peep[2] );\n    // cell output\n\n    cellOutput =  actOG * transferOut->f( *sc );\n    //XX//fprintf(stderr,\"pg: %f --> cellOutput %f   actOG %f   ag: %f\\n\",*sc,cellOutput,actOG,transferOut->f( *sc ));\n\n    if (N!=NULL) *N=1;\n    return &cellOutput;\n\n  } else { // long version\n    long i;\n    FLOAT_NN sum=0.0;\n\n    // input Gate\n    for (i=0; i<nCells; i++) {  // TODO: check the order of the peephole weights\n      sum += (sc[i])*peep[i];\n    }\n    actIG = transferGate->f( x[0] + sum );\n\n    // forget Gate // TODO: add multi-dim. forget gate acts...? \"num_seq_dims\"\n    sum = 0.0;\n    for (i=0; i<nCells; i++) {  // TODO: check the order of the peephole weights\n      sum += (sc[i])*peep[i+nCells];\n    }\n    actFG = transferGate->f( x[1] + sum );\n\n    // cell\n    for (i=0; i<nCells; i++) {  \n      sc[i] = actIG * *cNnNNcell::forward(x+2+i) + (sc[i])*actFG;\n      // TODO: add multi-dim. forget gate acts...? \"num_seq_dims\"\n    }\n\n    // output Gate\n    sum = 0.0;\n    for (i=0; i<nCells; i++) {  // TODO: check the order of the peephole weights\n      sum += (sc[i])*peep[i+2*nCells];\n    }\n    actOG = transferGate->f( x[3] + sum );\n\n    // cell output\n    for (i=0; i<nCells; i++) {  \n      cellOutputs[i] = actOG * transferOut->f(sc[i]);\n    }\n\n    if (N!=NULL) *N=nOutputs;\n    return (const FLOAT_NN*)cellOutputs;\n  }\n\n}\n\n\n/**************************** cNnLayer *******************************************/\n\n\n// feed data forward, N must match the layer's input size (nInputs)\nvoid cNnLayer::forward(FLOAT_NN *x, long N) \n{\n  long i;\n  FLOAT_NN * curoutp = output + curPtr * nOutputs;\n  for (i=0; i<nCells; i++) {\n    long n = nCellInputs;\n    const FLOAT_NN *tmpout = cell[i]->forward(x,&n);\n    x += nCellInputs;\n    // add tmpout to our output vector\n    memcpy(curoutp+i*nCellOutputs,tmpout,sizeof(FLOAT_NN)*nCellOutputs);\n  }\n  if (nContext > 0) {\n    curPtr++; \n    if (curPtr > nContext) curPtr = 0;  /* NOTE: the buffersize of the output buffer is nContext + 1 */\n    else nDelayed++;\n  } /* else {\n    memcpy(output+i*nCellOutputs,tmpout,sizeof(FLOAT_NN)*nCellOutputs);\n    }*/\n\n}\n\nvoid cNnLayer::resetLayer() \n{\n  // reset the output activation buffer\n  nDelayed = 0;\n  curPtr = 0;\n  bzero(output , nContext*nOutputs*sizeof(FLOAT_NN));\n  // reset the cells\n  long i;\n  for (i=0; i<nCells; i++) {\n    cell[i]->reset();\n  }\n}\n\n\n/**************************** cNnSoftmaxLayer *******************************************/\n\nvoid cNnSoftmaxLayer::forward(FLOAT_NN *x, long N) \n{\n  long i; \n  double sum = 0.0;\n  //TODO: handle curPtr and context buffered output..!? OR: ensure nContext always == 1\n  if (N > MIN(nInputs,nOutputs)) { N = MIN(nInputs,nOutputs); }\n  for (i=0; i<N; i++) {\n    if (x[i] == -INFINITY) { output[i] = 0.0; }\n    else if (x[i] > expLim) { output[i] = DBL_MAX; }\n    else output[i] = exp(x[i]);\n    sum += output[i];\n  }\n  if (sum != 0.0) {\n    for (i=0; i<N; i++) {\n      output[i] = (FLOAT_NN)((double)output[i] / sum); \n    }\n  }\n}\n\n/**************************************************************************************/\n/**************************** cNnConnection *******************************************/\n/**************************************************************************************/\n\n\nvoid cNnConnection::initialise(long _bidir_bufsize)\n{\n  int i; int bidir=0;\n  // get i/o size parameters from input layers:\n  inputSize = 0;\n  for (i=0; i<nInputs; i++) {\n    inputStart[i] = inputSize;\n    inputSize += input[i]->getOutputSize();\n    if (input[i]->isReverse()) bidir = 1;\n  }\n  // get number of outputs:\n  outputSize = output->getInputSize();\n  // allocate weight memory for inputSize*outputSize weights:\n  nWeights = inputSize*outputSize;\n  //printf(\"iS: %i, oS: %i, nWeights:%i\\n\",inputSize,outputSize,nWeights); fflush(stdout);\n  weight = (FLOAT_NN*)malloc(sizeof(FLOAT_NN)*nWeights);\n  // allocate bias weight memory for outputSize weights:\n  nBias = outputSize;\n  bias = (FLOAT_NN*)malloc(sizeof(FLOAT_NN)*nBias);\n  // allocate current output vector/buffer:\n  /* we don't require the buffer in the connection object, it is in the layers\n  if (bidir) {\n  // bidirectional nets require buffered output for the \"backward\" pass\n  //?? outputs = (FLOAT_NN*)calloc(1,sizeof(FLOAT_NN)*outputSize);\n  } else {\n  // caching of one output vector is sufficient for unidirectional (recurrent) nets\n  */\n  outputs = (FLOAT_NN*)calloc(1,sizeof(FLOAT_NN)*outputSize);\n  //}\n}\n\n// print human readable connection information \nvoid cNnConnection::printInfo()\n{\n  int i;\n  fprintf(stderr,\"  from: \");\n  for (i=0; i<nInputs; i++) {\n    if (input[i] != NULL) \n      fprintf(stderr,\" '%s' (%i); \",input[i]->getName(),input[i]->getLayerIdx());\n  }\n  fprintf(stderr,\"   -> to: '%s' (%i)\\n\",output->getName(),output->getLayerIdx());\n}\n\n// forward data (one timestep) from the input layers to the output layer\nvoid cNnConnection::forward() \n{\n  // the job of the connection class is:\n  //   to read the layer outputs from the input layers (the first layer must initialised with forward() externally)\n  //   apply the weights\n  //   and build the input vectors for the output layer cells\n  //   then call forward() on the output layer to \"compute the next layer\"\n  int i;\n  long j,n; \n  FLOAT_NN *wght = weight;\n  FLOAT_NN *outp;\n\n  for (j=0; j<outputSize; j++) {\n    outputs[j] = bias[j];\n  }\n\n  /* handling of (buffered) bidirectional nets.... */\n  /*\n\n  check if output is reverse layer...\n  if no:   \n  forward data as usual, however only if all inputs from bidirectional input layers are available \n  if yes:\n  forward data only (nContext times backward) if the input buffer is full (nDelayed == nContext)\n  IMPORTANT: output only one next frame...?\n  prob: the output activations get stored by the net..., so we only forward the top element of the activations...\n\n  PROBLEM: theoretically every hidden layer in a bi-directional net introduces a delay\n  */\n  /****/\n\n  // check if output is bidirectional reverse layer:\n  int bidirOut = output->isReverse();\n\n  // check for bidirectional inputs (if one is present we must delay processing)\n  int bidirIn = 0;\n  for (i=0; i<nInputs; i++) {\n    if (input[i]->isReverse()) { bidirIn = 1; break; }\n  }\n\n\n  if (!bidirOut) { // \"forward pass\"\n    //printf(\"fw \");\n    // read input layer outputs, multiply with weights and sum to output\n    for (i=0; i<nInputs; i++) {\n      //printf(\"OAV(%i) = %i \",i,input[i]->outputAvailable());\n      if (!(input[i]->outputAvailable())) { return; }\n\n      long _NN=0;\n      long _idx = 0;\n      if (!input[i]->isReverse()) { _idx = input[i]->getNContext(); } // pull top index from reverse layers...?\n\n      const FLOAT_NN *tmp = input[i]->getOutput(&_NN,_idx);\n      long size = input[i]->getOutputSize();\n\n      //XX//for (n=0; n<size; n++) { if (tmp[n] != 0.0) { fprintf(stderr,\"input %i , tmp %i\\n\",i,n); } }\n\n      // TODO: check _NN == outputSize ??\n\n      outp = outputs;\n      for (j=0; j<outputSize; j++) {\n        for (n=0; n<size; n++) {\n          //XX//if (*wght != 0.0012) fprintf(stderr,\"n  %i j %i\\n\",n,j);\n          *outp += tmp[n]* (*(wght++));\n        }\n        outp++;\n      }\n      //XX//fprintf(stderr,\"outputS   %i %i\\n\",outputSize,size);\n    }\n\n    // pass output to output layer\n    //XX//for (n=0; n<outputSize; n++) { if (outputs[n] != 0.0) { fprintf(stderr,\"FWoutput %i = %f\\n\",n,outputs[n]); } }\n    output->forward(outputs,outputSize);\n\n  } else { // \"backward pass\" over full buffer\n\n\n\n    // we first must reset the layer, then gather the inputs at the end of the buffer (t=0)\n    // and forward .. then loop through the buffer until we reach (t = -bufsize)\n    // this is our first valid output of the output level \n    output->resetLayer();\n\n    // check if input is available in all forward input layers... EXCLUDE self recurrent connections!\n    for (i=0; i<nInputs; i++) {\n      // we check if nContext samples are available in this input layer...\n      if ((input[i]!=output)&&(!(input[i]->outputAvailable()))) { return; }\n    }\n\n    long nContext = output->getNContext();\n    // Note: nContext in input an outout layers should be the same.. if not, we have to use a different value for nContext..? input context size?\n    //printf(\"bw nCO=%i \",nContext);\n    long c;\n    for (c=0; c<nContext; c++) {\n\n      wght = weight;\n      // read input layer outputs, multiply with weights and sum to output\n      for (i=0; i<nInputs; i++) {\n\n        //printf(\"OAV(%i) = %i \",i,input[i]->outputAvailable()); fflush(stdout);\n        // NOTE: backward recurrent connections must be forwarded disregarding the output available.... (we go through the data backwards anyways)\n\n\n        long _NN=0;\n        long _idx = 0;\n        if (input[i]->isReverse() && (input[i] != output)) { _idx = c; } // TODO?: pull top index from reverse layers, except the self recurrent layers...?\n        else { _idx = c ; }\n        if (input[i] == output) { _idx = 0; }\n\n        const FLOAT_NN *tmp = input[i]->getOutput(&_NN, _idx);\n        long size = input[i]->getOutputSize();\n\n        //XX//for (n=0; n<size; n++) { if (tmp[n] != 0.0) { fprintf(stderr,\"input %i , tmp %i\\n\",i,n); } }\n\n        // TODO: check _NN == outputSize ??\n\n        outp = outputs;\n        //printf(\"size %i outputSize %i  (* = %i) nweights=%i\\n\",size,outputSize,size*outputSize,nWeights); fflush(stdout);\n        for (j=0; j<outputSize; j++) {\n          for (n=0; n<size; n++) {\n            //XX//if (*wght != 0.0012) fprintf(stderr,\"n  %i j %i\\n\",n,j);\n            *outp += tmp[n]* (*(wght++));\n          }\n          outp++;\n        }\n        //XX//fprintf(stderr,\"outputS   %i %i\\n\",outputSize,size);\n      }\n\n      // pass output to output layer\n      //XX//for (n=0; n<outputSize; n++) { if (outputs[n] != 0.0) { fprintf(stderr,\"FWoutput %i = %f\\n\",n,outputs[n]); } }\n      output->forward(outputs,outputSize);\n\n    }\n\n  }\n  //printf(\"\\n\");\n}\n\n\n/**************************************************************************************/\n/**************************** cNnRnn **************************************************/\n/**************************************************************************************/\n\n// feed data forward through the net and compute the next output activations vector\nvoid cNnRnn::forward(FLOAT_NN *x, long N)\n{\n  long i;\n  // feed input to first layer (input layer)\n  layer[0]->forward(x,N);\n  // iterate through connections...\n  for (i=1; i<=nConnections; i++) {\n    if (connection[i] != NULL) connection[i]->forward();\n    else { RNN_ERR(1,\"connection[%i] is NULL\",i); }\n  }\n}\n\n\n// print the connections in human readable format to the log\nvoid cNnRnn::printConnections()\n{\n  int i;\n  fprintf(stderr,\"%i net layers:\\n\",nLayers);\n  for (i=0; i<nLayers; i++) {\n    fprintf(stderr,\"  %i : '%s'\\n\",i,layer[i]->getName());\n  }\n  for (i=1; i<=nConnections; i++) {\n    if (connection[i] != NULL) {\n      fprintf(stderr,\"--CONNECTION %i--\\n\",i);\n      connection[i]->printInfo();\n    }\n  }\n}\n\n\n/********************************************* RNN init *******************************/\n\n\nlong smileRnn_parseLayerNumber(char *s, unsigned long *dir)\n{\n  char *x = strchr(s,'_');\n  if (dir != NULL) {\n    *dir = LAYER_DIR_FWD;\n  }\n  if (x != NULL) { // two numbers separated by _, e.g. 0_1\n    if ((*(x+1) == '1')&&(dir != NULL)) {\n        *dir = LAYER_DIR_RWD;\n    }\n    *x = 0;\n    return (unsigned long)strtol(s,NULL,10);\n  } else { // only one number\n    return (unsigned long)strtol(s,NULL,10);\n  }\n  return -1;\n}\n\ncRnnWeightVector *smileRnn_createWeightVectorFromLine(char *line)\n{\n  long i=0;\n  char *lastl = line;\n  char *curl=line;\n  char *name = NULL;\n\n  // get name\n  while(1) {\n    if ((*curl == ' ')||(*curl == 0)) { \n      if (*curl == 0) return NULL;\n      *curl = 0; name = lastl; curl++; lastl = curl; break; \n    }\n    curl++;\n  }\n  // check for \"_weights\"\n  char *_to=NULL, *_from=NULL;\n  int isPeep = 0;\n  char *ww = strstr(name,\"_weights\");\n  if (ww != NULL) {\n    // truncate\n    ww[0] = 0;\n    ww = strstr(name,\"_to_\");\n    if (ww != NULL) {\n      ww[0] = 0;\n      _to = ww+4;\n      ww = strstr(_to,\"_delay_1\"); // remove the\n      if (ww != NULL) ww[0] = 0;   // delay_1 suffix for recurrent connections...\n      ww = strstr(_to,\"_delay_-1\"); // remove the\n      if (ww != NULL) ww[0] = 0;   // delay_-1 suffix for recurrent connections...\n      _from = name;\n    } else { // peepholes?\n      ww = strstr(name,\"_peepholes\");\n      if (ww != NULL) { // yes, peephole weights\n        ww[0] = 0;\n        _from = name; // assign only from !\n        isPeep = 1;\n      } else { //syntax error\n        return NULL;\n      }\n    }\n  } else {\n    // if not found (no weight vector!)\n    return NULL;\n  }\n\n  // get number of weights\n  char *numw=NULL;\n  while(1) {\n    if ((*curl == ' ')||(*curl == 0)) { \n      if (*curl == 0) return NULL;\n      *curl = 0; numw = lastl; curl++; lastl = curl; break; \n    }\n    curl++;\n  }\n  // convert numw to int\n  long nWeights = strtol(numw,NULL,10);\n\n  if (nWeights > 0) {\n    if (isPeep) {\n      SMILE_MSG(3,\"%i peephole weights in layer '%s'\",nWeights,_from);\n    } else {\n      SMILE_MSG(3,\"%i weights : from '%s' to '%s'\",nWeights,_from,_to);\n    }\n    // create weights vector\n    cRnnWeightVector *l = new cRnnWeightVector(nWeights);\n    // copy from and to names..\n    if (_to != NULL) { strncpy(l->to,_to,100); }\n    if (_from != NULL) { strncpy(l->from,_from,100); }\n    // parse from and to names...?\n    if (isPeep) { // peephole weights require only the \"from\" field (they are layer internal)\n      l->F = 0; l->T=-1;\n      if (!strncmp(l->from,\"hidden_\",7)) { l->F = LAYER_HIDDEN; }\n      l->F |= LAYER_PEEPHOLES;\n      // layer number and direction ...\n      unsigned long dir=0;\n      l->F |= smileRnn_parseLayerNumber(l->from+7,&dir);\n      l->F |= dir;\n    } else {\n      l->F = 0; l->T=-1;\n      if (!strncmp(l->from,\"bias\",4)) { l->F = LAYER_BIAS; }\n      else if (!strncmp(l->from,\"hidden_\",7)) {  // || (!strncmp(l->from,\"gather_\",7))\n        l->F = LAYER_HIDDEN; \n        // layer number and direction ...\n        unsigned long dir=0;\n        l->F |= smileRnn_parseLayerNumber(l->from+7,&dir);\n        l->F |= dir;\n      } else if (!strncmp(l->from,\"gather_\",7)) {  // || (!strncmp(l->from,\"gather_\",7))\n        l->F = LAYER_HIDDEN_GATHER; \n        // layer number and direction ...\n        //unsigned long dir=0;\n        l->F |= smileRnn_parseLayerNumber(l->from+7,NULL);\n        //l->F |= dir;\n        printf(\"layer F: %i\\n\",l->F);\n      }\n      else if (!strncmp(l->from,\"input\",5)) { l->F = LAYER_INPUT; }\n\n      if (!strncmp(l->to,\"hidden_\",7)) { \n        l->T = LAYER_HIDDEN;\n        // layer number and direction ...\n        unsigned long dir=0;\n        l->T |= smileRnn_parseLayerNumber(l->to+7,&dir);\n        l->T |= dir;\n      }\n      else if (!strncmp(l->to,\"output\",6)) { l->T = LAYER_OUTPUT; }\n    }\n\n    //XX//fprintf(stderr,\"strL curl %i\\n\",strlen(curl));\n    // copy weights to vector\n    long curW = 0;\n    char *w=NULL;\n    while(1) {\n      if (*curl == ' ') { \n        *curl=0; char *ep=NULL;\n        FLOAT_NN wf = (FLOAT_NN)strtod(lastl, &ep);\n        l->weights[curW++] = wf;\n        if (nWeights == curW) {\n          SMILE_ERR(1,\"too many weights on line, expected only %i weights ('%s')\",nWeights,lastl);\n          break;\n        }\n        //XX//if (wf != 0.001) { fprintf(stderr,\"curW %i of %i\\n\", curW,nWeights); }\n        curl++; lastl = curl; \n      } else if ((*curl == '\\n')||(*curl == '\\r')||(*curl == 0)) { \n        *curl=0; char *ep=NULL;\n        FLOAT_NN wf = (FLOAT_NN)strtod(lastl,&ep);\n        l->weights[curW++] = wf;\n        \n        //curl++; lastl = curl; \n        break;\n      } else {\n        curl++;\n      }\n    }\n\n    return l;\n  }\n  return NULL;\n}\n\n//void smileRnn_readJsonFile(rapidjson::Document *doc, const std::string &filename);\nint smileRnn_readJsonFile(rapidjson::Document *doc, const std::string &filename)\n{\n    // open the file\n    std::ifstream ifs(filename.c_str(), std::ios::binary);\n    if (!ifs.good()) {\n      SMILE_ERR(1, \"smileRnn_readJsonFile: Cannot open file '%s' for reading.\", filename.c_str());\n      return 0;\n    }\n    // calculate the file size in bytes\n    ifs.seekg(0, std::ios::end);\n    std::streamoff size = ifs.tellg();\n    ifs.seekg(0, std::ios::beg);\n\n    char magicNumber;\n    ifs >> magicNumber;\n    size_t net_size = (size_t)size;\n    bool commercialModelFormat = false;\n    if (magicNumber == 1) {\n        commercialModelFormat = true;\n        SMILE_MSG(2, \"Net file format: 22\");\n        // pointer is at 1 where content starts\n        net_size--;\n    } else {\n        SMILE_MSG(2, \"Net file format: 21\");\n        // need to seek to 0 again\n        ifs.seekg(0, std::ios::beg);\n    }\n    // read the file into a buffer\n    char *buffer = new char[(long) net_size + 1];\n    SMILE_MSG(3, \"File size: %d bytes\", size);\n    SMILE_MSG(3, \"Net size: %d bytes\", net_size);\n#ifdef BUILD_MODELCRYPT\n    cSmileModelcrypt crypt;\n    crypt.read(ifs, buffer, net_size, commercialModelFormat);\n#else    \n    if (commercialModelFormat) {\n      SMILE_ERR(1, \"This model file (%s) type is not supported by the open-source release of openSMILE. You need a commercial license to run it.\");\n      ifs.close();\n      return 0;\n    } else {\n      ifs.read(buffer, net_size);\n      buffer[net_size] = '\\0';\n    }\n#endif\n    std::string docStr(buffer);\n    delete[] buffer;\n    // extract the JSON tree\n    if (doc->Parse<0>(docStr.c_str()).HasParseError()) {\n      SMILE_ERR(1, \"Json Parse error in smileRnn_readJsonFile: %s\", doc->GetParseError());\n      return 0;\n    }\n    return 1;\n}\n\nint smileRnn_parseHiddenType(const char *n1, int layerIdx, cRnnNetFile &net, const char *filename = NULL)\n{\n  if (!strncmp(n1,\"lstm\",4)) {\n    net.hiddenType[layerIdx] = NNLAYERTYPE_LSTM;\n    net.hiddenActType[layerIdx] = NNLSTMACT_TANHTANHLOGI;\n    layerIdx++;\n  } else if (!strncmp(n1,\"blstm\",5)) {\n    net.hiddenType[layerIdx] = NNLAYERTYPE_LSTM;\n    net.hiddenActType[layerIdx] = NNLSTMACT_TANHTANHLOGI;\n    layerIdx++;\n  } else if (!strncmp(n1,\"linear_lstm\",11)) {\n    net.hiddenType[layerIdx] = NNLAYERTYPE_LSTM;\n    net.hiddenActType[layerIdx] = NNLSTMACT_TANHIDENLOGI;\n    layerIdx++;\n  } else if (!strncmp(n1,\"tanh\",4)) {\n    net.hiddenType[layerIdx] = NNLAYERTYPE_RNN;\n    net.hiddenActType[layerIdx] = NNACT_TANH;\n    layerIdx++;\n  } else if (!strncmp(n1,\"linear\",6)) {\n    net.hiddenType[layerIdx] = NNLAYERTYPE_RNN;\n    net.hiddenActType[layerIdx] = NNACT_IDEN;\n    layerIdx++;\n  } else if (!strncmp(n1,\"logistic\",8)) {\n    net.hiddenType[layerIdx] = NNLAYERTYPE_RNN;\n    net.hiddenActType[layerIdx] = NNACT_LOGI;\n    layerIdx++;\n  } else if (!strncmp(n1,\"feedforward_tanh\", 16)) {  // currennt specific name\n    net.hiddenType[layerIdx] = NNLAYERTYPE_NN;\n    net.hiddenActType[layerIdx] = NNACT_TANH;\n    layerIdx++;\n  } else if (!strncmp(n1,\"feedforward_linear\", 18)) {  // currennt specific name\n    net.hiddenType[layerIdx] = NNLAYERTYPE_NN;\n    net.hiddenActType[layerIdx] = NNACT_IDEN;\n    layerIdx++;\n  } else if (!strncmp(n1,\"feedforward_logistic\", 20)) {  // currennt specific name ?\n    net.hiddenType[layerIdx] = NNLAYERTYPE_NN;\n    net.hiddenActType[layerIdx] = NNACT_LOGI;\n    layerIdx++;\n  } else if (!strncmp(n1,\"recurrent_tanh\", 14)) {  // currennt specific name\n    net.hiddenType[layerIdx] = NNLAYERTYPE_RNN;\n    net.hiddenActType[layerIdx] = NNACT_TANH;\n    layerIdx++;\n  } else if (!strncmp(n1,\"recurrent_linear\", 16)) {  // currennt specific name\n    net.hiddenType[layerIdx] = NNLAYERTYPE_RNN;\n    net.hiddenActType[layerIdx] = NNACT_IDEN;\n    layerIdx++;\n  } else if (!strncmp(n1,\"recurrent_logistic\", 18)) {  // currennt specific name ?\n    net.hiddenType[layerIdx] = NNLAYERTYPE_RNN;\n    net.hiddenActType[layerIdx] = NNACT_LOGI;\n    layerIdx++;\n  }\n  else {\n    SMILE_ERR(1,\"unsupported hidden layer type '%s' ('hiddenType' option) while reading '%s'.\", n1, filename);\n  }\n  return layerIdx;\n}\n\nint smileRnn_loadNetJson(const char *filename, cRnnNetFile &net) \n{\n  rapidjson::Document netDoc;\n  if (!smileRnn_readJsonFile(&netDoc, filename)) {\n    return 0;\n  }\n\n  smileutil::json::JsonDocument jsonDoc(netDoc);\n  // check the layers and weight sections\n  if (!jsonDoc->HasMember(\"layers\")) {\n    SMILE_ERR(1, \"smileRnn_loadNetJson: Missing section 'layers'. (file '%s')\", filename);\n    return 0;\n  }\n  rapidjson::Value &layersSection  = (*jsonDoc)[\"layers\"];\n  if (!layersSection.IsArray()) {\n    SMILE_ERR(1, \"smileRnn_loadNetJson: 'layers' is not an array. (file '%s')\", filename);\n    return 0;\n  }\n\n  smileutil::json::JsonValue weightsSection;\n  if (jsonDoc->HasMember(\"weights\")) {\n    if (!(*jsonDoc)[\"weights\"].IsObject()) {\n      SMILE_ERR(1, \"smileRnn_loadNetJson: Section 'weights' is not an object. (file '%s')\", filename);\n      return 0;\n    }\n    weightsSection = smileutil::json::JsonValue(&(*jsonDoc)[\"weights\"]);\n  }\n\n  // extract the layers\n  net.nWeightVectors = 0;\n  net.bidirectional = 0;\n  int max_hidden_layer_number = -1;\n  int nLayers = 0;\n  int nHiddenLayers = 0;\n  const int nmap[4] = {2, 0, 1, 3};\n  for (rapidjson::Value::ValueIterator layerChild = layersSection.Begin();\n      layerChild != layersSection.End(); ++layerChild) {\n    // check the layer child type\n    if (!layerChild->IsObject()) {\n      SMILE_ERR(1, \"smileRnn_loadNetJson: A layer section in the 'layers' array is not an object. (file '%s')\", filename);\n      return 0;\n    }\n    // extract the layer type\n    if (!layerChild->HasMember(\"type\")) {\n      SMILE_ERR(1, \"smileRnn_loadNetJson: Missing value 'type' in layer description. (file '%s')\", filename);\n      return 0;\n    }\n    std::string layerType = (*layerChild)[\"type\"].GetString();\n    // extract the layer name\n    if (!layerChild->HasMember(\"name\")) {\n      SMILE_ERR(1, \"smileRnn_loadNetJson: Missing value 'name' in layer description. (file '%s')\", filename);\n      return 0;\n    }\n    std::string layerName = (*layerChild)[\"name\"].GetString();\n    int layerSize = (*layerChild)[\"size\"].GetInt();\n\n    if (weightsSection.isValid()) {\n      if (!strncmp(layerName.c_str(), \"input\", 5)) {\n        nLayers++;\n        // no weight vector is needed, as they are in the weight sections of the hidden layers\n        // we might only store the size here (as previous size) to verify the level_0 inputsize\n        net.inputSize = layerSize;\n        continue;\n      }\n\n      if (!weightsSection->HasMember(layerName.c_str())) {\n        if (strncmp(layerName.c_str(), \"postoutput\", 10)) {\n          SMILE_ERR(1, \"smileRnn_loadNetJson: Missing weights section for layer '%s'. (file '%s')\", layerName.c_str(), filename);\n        }\n        continue;\n      }\n      const rapidjson::Value &weightsChild = (*weightsSection)[layerName.c_str()];\n      if (!weightsChild.IsObject()) {\n        SMILE_ERR(1, \"smileRnn_loadNetJson: Weights section for layer '%s' is not an object. (file '%s')\", layerName.c_str(), filename);\n        return 0;\n      }\n\n      if (!weightsChild.HasMember(\"input\") || !weightsChild[\"input\"].IsArray()) {\n        SMILE_ERR(1, \"smileRnn_loadNetJson: Missing array 'weights/%s/input'. (file '%s')\", layerName.c_str(), filename);\n        return 0;\n      }\n      if (!weightsChild.HasMember(\"bias\") || !weightsChild[\"bias\"].IsArray()) {\n        SMILE_ERR(1, \"smileRnn_loadNetJson: Missing array 'weights/%s/bias'. (file '%s')\", layerName.c_str(), filename);\n        return 0;\n      }\n      if (!weightsChild.HasMember(\"internal\") || !weightsChild[\"internal\"].IsArray()) {\n        SMILE_ERR(1, \"smileRnn_loadNetJson: Missing array 'weights/%s/internal'. (file '%s')\", layerName.c_str(), filename);\n        return 0;\n      }\n      const rapidjson::Value &inputWeightsChild    = weightsChild[\"input\"];\n      const rapidjson::Value &biasWeightsChild     = weightsChild[\"bias\"];\n      const rapidjson::Value &internalWeightsChild = weightsChild[\"internal\"];\n\n      /* TODO\n            if (inputWeightsChild.Size() != this->size() * inputWeightsPerBlock * m_precedingLayer.size())\n              throw std::runtime_error(std::string(\"Invalid number of input weights for layer '\") + this->name() + \"'\");\n            if (biasWeightsChild.Size() != this->size() * inputWeightsPerBlock)\n              throw std::runtime_error(std::string(\"Invalid number of bias weights for layer '\") + this->name() + \"'\");\n            if (internalWeightsChild.Size() != this->size() * internalWeightsPerBlock)\n              throw std::runtime_error(std::string(\"Invalid number of internal weights for layer '\") + this->name() + \"'\");\n       */\n\n      // fill layer metadata\n      // get layer category (input, hidden, output)\n      long n = 0;\n      if (!strncmp(layerName.c_str(), \"output\", 6)) {\n        nLayers++;\n        SMILE_MSG(3, \"[rnn] output layer %i size %i\", nHiddenLayers, layerSize);\n        SMILE_MSG(3, \"[rnn] output layer #%i w size %i\", nHiddenLayers, (int)inputWeightsChild.Size());\n        net.outputSize = layerSize;\n        // output (input) weights\n        cRnnWeightVector *v = new cRnnWeightVector(inputWeightsChild.Size());\n        v->F = LAYER_HIDDEN;\n        v->F |= max_hidden_layer_number;\n        v->F |= LAYER_DIR_FWD;  // TODO: replace by variable like max_hidden_layer_dir\n        v->T = LAYER_OUTPUT;\n        // fill layer weights\n        n = 0;\n        for (rapidjson::Value::ConstValueIterator it = inputWeightsChild.Begin();\n            it != inputWeightsChild.End(); ++it) {\n          v->weights[n++] = (FLOAT_NN)(it->GetDouble());\n        }\n        // add to layer weight vector collection\n        net.wv[net.nWeightVectors++] = v;\n        // output bias:\n        v = new cRnnWeightVector(biasWeightsChild.Size());\n        v->F = LAYER_BIAS;\n        v->T = LAYER_OUTPUT;\n        // fill layer weights\n        n = 0;\n        for (rapidjson::Value::ConstValueIterator it = biasWeightsChild.Begin();\n            it != biasWeightsChild.End(); ++it) {\n          v->weights[n++] = (FLOAT_NN)(it->GetDouble());\n        }\n        // add to layer weight vector collection\n        net.wv[net.nWeightVectors++] = v;\n\n      } else if (!strncmp(layerType.c_str(), \"lstm\", 4) && !strncmp(layerName.c_str(), \"lstm_level_\", 11)) {\n        //const char * layerNum = layerName.c_str() + 11;\n        //char * eptr = NULL;\n        //int layer_number = strtol(layerNum, &eptr, 10);\n        smileRnn_parseHiddenType(layerType.c_str(), nHiddenLayers, net, filename);\n        // NEW: override the parsed number to get the actual number!\n        int layer_number = nHiddenLayers;\n        if (layer_number > max_hidden_layer_number) {\n          max_hidden_layer_number = layer_number;\n        }\n        net.hiddenSize[nHiddenLayers++] = layerSize;\n        nLayers++;\n        SMILE_MSG(3, \"[rnn] lstm layer %i size %i\", layer_number, layerSize);\n        SMILE_MSG(3, \"[rnn] lstm input %i w size %i\", layer_number, (int)inputWeightsChild.Size());\n        // create input weight vector\n        cRnnWeightVector *v = new cRnnWeightVector(inputWeightsChild.Size());\n        double *weightTmp = new double[inputWeightsChild.Size()];\n        if (v != NULL) {\n          v->T = LAYER_HIDDEN;\n          v->T |= layer_number;\n          v->T |= LAYER_DIR_FWD;\n          if (layer_number == 0) {\n            v->F = LAYER_INPUT;\n          } else {\n            v->F = LAYER_HIDDEN;\n            v->F |= layer_number - 1;\n          }\n          // fill layer weights\n          n = 0;\n          for (rapidjson::Value::ConstValueIterator it = inputWeightsChild.Begin();\n              it != inputWeightsChild.End(); ++it) {\n            weightTmp[n++] = it->GetDouble();\n          }\n          // re-order layer weights from current to rnnlib/smile ordering\n          int prevSize = inputWeightsChild.Size() / (layerSize * 4);\n          double *weightCell = weightTmp;\n          double *weightIg = weightTmp + prevSize * layerSize;\n          double *weightFg = weightTmp + 2 * prevSize * layerSize;\n          double *weightOg = weightTmp + 3 * prevSize * layerSize;\n          for (int j = 0; j < layerSize; j++) {\n            int jp4 = j * prevSize * 4;\n            int jp = j * prevSize;\n            for (int i = 0; i < prevSize; i++) {\n              v->weights[jp4 + i] = (FLOAT_NN)weightIg[jp + i];\n              v->weights[jp4 + prevSize + i] = (FLOAT_NN)weightFg[jp + i];\n              v->weights[jp4 + prevSize * 2 + i] = (FLOAT_NN)weightCell[jp + i];\n              v->weights[jp4 + prevSize * 3 + i] = (FLOAT_NN)weightOg[jp + i];\n            }\n          }\n          // add to layer weight vector collection\n          net.wv[net.nWeightVectors++] = v;\n        }\n        delete[] weightTmp;\n\n        // create bias weight vector\n        v = new cRnnWeightVector(biasWeightsChild.Size());\n        weightTmp = new double[biasWeightsChild.Size()];\n        if (v != NULL) {\n          v->F = LAYER_BIAS;\n          v->T = LAYER_HIDDEN;\n          v->T |= LAYER_DIR_FWD;\n          v->T |= layer_number;\n          // fill layer weights\n          n = 0;\n          /*for (rapidjson::Value::ConstValueIterator it = biasWeightsChild.Begin();\n              it != biasWeightsChild.End(); ++it) {\n            //v->weights[n++] = (FLOAT_NN)(it->GetDouble());\n            int nb = n / 4;\n            int nl = nmap[n % 4];\n            v->weights[nb + nl] = it->GetDouble();\n            n++;\n          }*/\n          // fill layer weights\n          n = 0;\n          for (rapidjson::Value::ConstValueIterator it = biasWeightsChild.Begin();\n              it != biasWeightsChild.End(); ++it) {\n            weightTmp[n++] = it->GetDouble();\n          }\n          // re-order layer weights from current to rnnlib/smile ordering\n          int prevSize = biasWeightsChild.Size() / (layerSize * 4);  // should be 1...\n          double *weightCell = weightTmp;\n          double *weightIg = weightTmp + prevSize * layerSize;\n          double *weightFg = weightTmp + 2 * prevSize * layerSize;\n          double *weightOg = weightTmp + 3 * prevSize * layerSize;\n          for (int j = 0; j < layerSize; j++) {\n            int jp4 = j * prevSize * 4;\n            int jp = j * prevSize;\n            for (int i = 0; i < prevSize; i++) {\n              v->weights[jp4 + i] = (FLOAT_NN)weightIg[jp + i];\n              v->weights[jp4 + prevSize + i] = (FLOAT_NN)weightFg[jp + i];\n              v->weights[jp4 + prevSize * 2 + i] = (FLOAT_NN)weightCell[jp + i];\n              v->weights[jp4 + prevSize * 3 + i] = (FLOAT_NN)weightOg[jp + i];\n            }\n          }\n          // add to layer weight vector collection\n          net.wv[net.nWeightVectors++] = v;\n        }\n        delete[] weightTmp;\n\n        // check:\n        if (4 * layerSize * layerSize + 3 * layerSize != internalWeightsChild.Size()) {\n          SMILE_ERR(1, \"There is something wrong with the size of the internal weight array on layer '%s' (num %i) (size %i).\", layerName.c_str(), layer_number, layerSize);\n          return 0;\n        }\n\n        // create internal (recurrent) weight vector\n        v = new cRnnWeightVector(4 * layerSize * layerSize);\n        weightTmp = new double[4 * layerSize * layerSize];\n        if (v != NULL) {\n          v->T = LAYER_HIDDEN;\n          v->T |= layer_number;\n          v->T |= LAYER_DIR_FWD;\n          v->F = LAYER_HIDDEN;\n          v->F |= layer_number;\n          v->F |= LAYER_DIR_FWD;\n          // fill layer weights\n          n = 0;\n          for (rapidjson::Value::ConstValueIterator it = internalWeightsChild.Begin();\n              it != internalWeightsChild.Begin() + 4 * layerSize * layerSize; ++it) {\n            weightTmp[n++] = it->GetDouble();\n          }\n          // re-order layer weights from current to rnnlib/smile ordering\n          int prevSize = layerSize;\n          double *weightCell = weightTmp;\n          double *weightIg = weightTmp + prevSize * layerSize;\n          double *weightFg = weightTmp + 2 * prevSize * layerSize;\n          double *weightOg = weightTmp + 3 * prevSize * layerSize;\n          for (int j = 0; j < layerSize; j++) {\n            int jp4 = j * prevSize * 4;\n            int jp = j * prevSize;\n            for (int i = 0; i < prevSize; i++) {\n              v->weights[jp4 + i] = (FLOAT_NN)weightIg[jp + i];\n              v->weights[jp4 + prevSize + i] = (FLOAT_NN)weightFg[jp + i];\n              v->weights[jp4 + prevSize * 2 + i] = (FLOAT_NN)weightCell[jp + i];\n              v->weights[jp4 + prevSize * 3 + i] = (FLOAT_NN)weightOg[jp + i];\n            }\n          }\n          // add to layer weight vector collection\n          net.wv[net.nWeightVectors++] = v;\n        }\n        delete[] weightTmp;\n\n        // create peep weight vector\n        v = new cRnnWeightVector(3 * layerSize);\n        if (v != NULL) {\n          v->T = -1;\n          v->F = LAYER_HIDDEN;\n          v->F |= layer_number;\n          v->F |= LAYER_PEEPHOLES;\n          v->F |= LAYER_DIR_FWD;\n          // fill layer weights\n          n = 0;\n          for (rapidjson::Value::ConstValueIterator it = internalWeightsChild.End() - 3 * layerSize;\n              it != internalWeightsChild.End() - 2 * layerSize; ++it) {\n            // input\n            v->weights[n] = (FLOAT_NN)(it->GetDouble());\n            n += 3;\n          }\n          n = 1;\n          for (rapidjson::Value::ConstValueIterator it = internalWeightsChild.End() - 2 * layerSize;\n              it != internalWeightsChild.End() - layerSize; ++it) {\n            // input\n            v->weights[n] = (FLOAT_NN)(it->GetDouble());\n            n += 3;\n          }\n          n = 2;\n          for (rapidjson::Value::ConstValueIterator it = internalWeightsChild.End() - layerSize;\n              it != internalWeightsChild.End(); ++it) {\n            // input\n            v->weights[n] = (FLOAT_NN)(it->GetDouble());\n            n += 3;\n          }\n          // add to layer weight vector collection\n          net.wv[net.nWeightVectors++] = v;\n        }\n\n      } else if (!strncmp(layerType.c_str(), \"blstm\", 5) && !strncmp(layerName.c_str(), \"blstm_level_\", 12)) {\n        const char * layerNum = layerName.c_str() + 11;\n        char * eptr = NULL;\n        long layer_number = strtol(layerNum, &eptr, 10);\n        // TODO: need l->F = LAYER_HIDDEN_GATHER; somwhere!\n        if (layer_number > max_hidden_layer_number) {\n          max_hidden_layer_number = layer_number;\n        }\n        smileRnn_parseHiddenType(layerType.c_str(), nHiddenLayers, net, filename);\n        net.hiddenSize[nHiddenLayers++] = layerSize / 2;\n        nLayers++;\n        net.bidirectional = 1;\n        SMILE_ERR(1, \"[rnn] BLSTM layers not yet supported!\");\n        SMILE_MSG(3, \"[rnn] blstm layer %i size %i\\n\", layer_number, layerSize);\n        SMILE_MSG(3, \"[rnn] blstm input %i w size %i\\n\", layer_number, (int)inputWeightsChild.Size());\n        //if (!strncmp(layerName.c_str(), \"neuron_level_\", xx)) {\n      } else if (!strncmp(layerType.c_str(), \"feedforward\", 11) /*&& !strncmp(layerName.c_str(), \"subsample_\", 10)*/)  {\n        //const char * layerNum = layerName.c_str() + 10;  // subsample_X_Y  (use X as layer number?) // UNUSED!\n        //char * eptr = NULL;\n        //int layer_number = strtol(layerNum, &eptr, 10);\n        int layer_number = nHiddenLayers;\n        if (layer_number > max_hidden_layer_number) {\n          max_hidden_layer_number = layer_number;\n        }\n        smileRnn_parseHiddenType(layerType.c_str(), nHiddenLayers, net, filename);\n        net.hiddenSize[nHiddenLayers++] = layerSize;\n        nLayers++;\n        SMILE_MSG(3, \"[rnn] feedforward (nn) layer %i size %i\", layer_number, layerSize);\n        SMILE_MSG(3, \"[rnn] feedforward (nn) input %i w size %i\", layer_number, (int)inputWeightsChild.Size());\n\n        // feedforward layer weights\n        cRnnWeightVector *v = new cRnnWeightVector(inputWeightsChild.Size());\n        if (v != NULL) {\n          v->T = LAYER_HIDDEN; // + LAYER_SUBSAMPLE;\n          v->T |= layer_number;\n          v->T |= LAYER_DIR_FWD;\n          if (layer_number == 0) {\n            v->F = LAYER_INPUT;\n          } else {\n            v->F = LAYER_HIDDEN;\n            v->F |= layer_number - 1;\n          }\n          // copy the weights\n          n = 0;\n          for (rapidjson::Value::ConstValueIterator it = inputWeightsChild.Begin();\n              it != inputWeightsChild.End(); ++it) {\n            v->weights[n++] = (FLOAT_NN)(it->GetDouble());\n          }\n          // add to layer weight vector collection\n          net.wv[net.nWeightVectors++] = v;\n        }\n        // bias layer weights\n        v = new cRnnWeightVector(biasWeightsChild.Size());\n        if (v != NULL) {\n          v->F = LAYER_BIAS;\n          v->T = LAYER_HIDDEN;\n          v->T |= LAYER_DIR_FWD;\n          v->T |= layer_number;\n          // copy the weights\n          n = 0;\n          for (rapidjson::Value::ConstValueIterator it = biasWeightsChild.Begin();\n              it != biasWeightsChild.End(); ++it) {\n            v->weights[n++] = (FLOAT_NN)(it->GetDouble());\n          }\n          // add to layer weight vector collection\n          net.wv[net.nWeightVectors++] = v;\n        }\n      }\n    }\n  }\n\n  // check if we have at least one input, one output and one post output layer\n  if (nLayers < 3) {\n    SMILE_ERR(1, \"smileRnn_loadNetJson: Not enough layers defined. (file '%s')\", filename);\n    return 0;\n  }\n\n  // net task - set via config (TODO)\n  const char *task = \"regression\";\n  if (!strncmp(task,\"regression\",10)) {\n    net.task = NNTASK_REGRESSION;\n  } else if (!strncmp(task,\"classification\",14)) {\n    net.task = NNTASK_CLASSIFICATION;\n  } else if (!strncmp(task,\"transcription\",13)) {\n    net.task = NNTASK_TRANSCRIPTION;\n    //SMILE_IERR(1,\"CTC decoding (task = transcription) not yet supported!\");\n  }\n  // set these via config..?\n  net.nContext = 0;  // context for online blstm\n  net.loaded = 1;\n  net.nHiddenLayers = nHiddenLayers;\n  net.cellsPerBlock = 1; // FIXME...!\n  return 1;\n}\n\n\n\nint smileRnn_loadNet(const char *filename, cRnnNetFile &net)\n{\n  int bidirectional = 1;\n  bool encryptedFile = false;\n  net.nContext = 0;\n#ifdef BUILD_MODELCRYPT\n  cSmileModelcrypt crypt;\n#endif\n  if (filename != NULL) {\n    FILE *f = fopen(filename,\"rb\");\n    if (f != NULL) {\n      int magicNumber = fgetc(f);\n      if (magicNumber == 1) {\n        encryptedFile = true;\n        SMILE_MSG(2, \"Net file format: 2\");\n        // ignore magic number\n      } else {\n        SMILE_MSG(2, \"Net file format: 1\");\n        fseek(f, 0, 0);\n        // first byte is part of text ...\n      }\n      char *line=NULL;\n      size_t n=0;\n      int ret;\n      do { // read the net file line by line...\n#ifdef BUILD_MODELCRYPT\n        ret = crypt.getLine(&line, &n, f, encryptedFile);\n#else\n        if (encryptedFile) {\n          SMILE_ERR(1, \"This model file (%s) type is not supported by this release of openSMILE.\");\n          fclose(f);\n          return 0;\n        } else {\n          ret = smile_getline(&line, &n, f);\n        }\n#endif\n//        printf(\"line = %s\\n\", line);\n        if ((ret > 1)&&(line!=NULL)) {\n          if (!strncmp(line,\"weightContainer_\",16)) { // weight vector line...\n            cRnnWeightVector *v = smileRnn_createWeightVectorFromLine(line+16);\n            if (v != NULL) { // add to a collection..\n              net.wv[net.nWeightVectors++] = v;\n            }\n          } else {\n            // net config line\n            // we are interested in reading 'hiddenSize', 'hiddenType', 'task' (output layer!), and possibly (?) 'actSmoothing' and 'actDecay'\n            if (!strncmp(line,\"hiddenSize \",11)) {\n              // parse string with sizes of hidden layer, space separated\n              long i=0;\n              char *n1=line+11, *n2=line+11;\n              while(1) {\n                if ((*n2 == ',')||(*n2=='\\n')||(*n2=='\\r')||(*n2==0)) {\n                  char myc = *n2;\n                  *n2 = 0;\n                  long l = strtol(n1,NULL,10);\n                  net.hiddenSize[i++] = l;\n                  if ((myc=='\\n')||(myc=='\\r')||(myc==0)) { break; }\n                  n2++; n1=n2;\n                } else { n2++; }\n              }\n              net.nHiddenLayers = i;\n            } else if (!strncmp(line,\"hiddenType \",11)) {\n              // parse string with types of hidden layers (space separated?)\n              long i=0;\n              char *n1=line+11, *n2=line+11;\n              while(1) {\n                if ((*n2 == ',')||(*n2=='\\n')||(*n2=='\\r')||(*n2==0)) {\n                  char myc = *n2;\n                  *n2 = 0;\n                  i = smileRnn_parseHiddenType(n1, i, net, filename);\n                  /*\n                   *\n                  if (!strncmp(n1,\"lstm\",4)) {\n                    net.hiddenType[i] = NNLAYERTYPE_LSTM;\n                    net.hiddenActType[i] = NNLSTMACT_TANHTANHLOGI;\n                    i++;\n                  } else if (!strncmp(n1,\"linear_lstm\",11)) {\n                    net.hiddenType[i] = NNLAYERTYPE_LSTM;\n                    net.hiddenActType[i] = NNLSTMACT_TANHIDENLOGI;\n                    i++;\n                  } else if (!strncmp(n1,\"tanh\",4)) {\n                    net.hiddenType[i] = NNLAYERTYPE_RNN;\n                    net.hiddenActType[i] = NNACT_TANH;\n                    i++;\n                  } else if (!strncmp(n1,\"linear\",6)) {\n                    net.hiddenType[i] = NNLAYERTYPE_RNN;\n                    net.hiddenActType[i] = NNACT_IDEN;\n                    i++;\n                  } else if (!strncmp(n1,\"logistic\",8)) {\n                    net.hiddenType[i] = NNLAYERTYPE_RNN;\n                    net.hiddenActType[i] = NNACT_LOGI;\n                    i++;\n                  } else {\n                    SMILE_ERR(1,\"unsupported hidden layer type '%s' ('hiddenType' option) while reading '%s'.\",n1,filename);\n                  }\n                  */\n                  if ((myc=='\\n')||(myc=='\\r')||(myc==0)) { break; }\n                  n2++; n1=n2;\n                } else { n2++; }\n              }\n              // duplicate hiddenType if # < nHiddenLayers:\n             /* if (i<net.nHiddenLayers) {\n                for(; i<net.nHiddenLayers; i++) {\n                  net.hiddenActType[i] = net.hiddenActType[i-1];\n                  net.hiddenType[i] = net.hiddenType[i-1];\n                }\n              }*/\n              if (net.nHiddenLayers > i) { // if less types than layer sizes given, assume the following layers are of the same type as the last layer...?\n                int tp = net.hiddenType[i-1];\n                int ac = net.hiddenActType[i-1];\n                for (; i<net.nHiddenLayers; i++) {\n                  net.hiddenType[i] = tp;\n                  net.hiddenActType[i] = ac;\n                }\n              }\n            } else if (!strncmp(line,\"task \",5)) {\n              // net task\n              if (!strncmp(line+5,\"regression\",10)) {\n                net.task = NNTASK_REGRESSION;\n              } else if (!strncmp(line+5,\"classification\",14)) {\n                net.task = NNTASK_CLASSIFICATION;\n              } else if (!strncmp(line+5,\"transcription\",13)) {\n                net.task = NNTASK_TRANSCRIPTION;\n                //SMILE_IERR(1,\"CTC decoding (task = transcription) not yet supported!\");\n              }\n            } else if (!strncmp(line,\"bidirectional \",14)) {\n              if (!strncmp(line+14,\"false\",5)) bidirectional = 0;\n              else if (!strncmp(line+14,\"true\",4)) bidirectional = 1;\n            } else if (!strncmp(line,\"contextLength \",13)) { // <-- this option is new, it is not an rnnlib option!\n              if (!strncmp(line+13,\"inf\",3)) net.nContext = 0;\n              else {\n                net.nContext = strtol(line+13,NULL,10);\n              }\n            }\n          }\n        } else { if (ret <= 0) break; }\n      } while (1);\n      fclose(f);\n      free(line);\n      //// now determine inputSize and outputSize from connection weights\n      //// (the rnnlib determiens these sizes from the .nc files, which we don't have...)\n      // 1. find bias_to_output to get output size...\n      int i;\n      for (i=0; i<net.nWeightVectors; i++) {\n        if ((net.wv[i]->F == LAYER_BIAS) && (net.wv[i]->T == LAYER_OUTPUT)) { net.outputSize = net.wv[i]->nWeights; break; }\n      }\n      // 2. find input_to_hidden_0_x\n      for (i=0; i<net.nWeightVectors; i++) {\n        if ((net.wv[i]->F == LAYER_INPUT) && ( (net.wv[i]->T & LAYER_HIDDEN) == LAYER_HIDDEN)) { \n          long f = 1;\n          if (net.hiddenType[0] == NNLAYERTYPE_LSTM) { f = 4; }\n          net.inputSize = net.wv[i]->nWeights / (net.hiddenSize[0] * f); \n        }\n      }\n      net.cellsPerBlock = 1; // FIXME...!\n      // test for bidirectional network topology\n      net.bidirectional = bidirectional; // FIXME??\n      /*for (i=0; i<net.nWeightVectors; i++) {  // do this as extra check ???\n        if (net.wv[i]->F & LAYER_DIR_RWD == LAYER_DIR_RWD) net.bidirectional = 1;\n      }*/\n\n      // fix gather layers for the unidirectional case ....\n/*      if (!bidirectional) {\n        for (i=0; i<net.nWeightVectors; i++) {\n          if (net.wv[i]->F == LAYER_HIDDEN_GATHER) net.wv[i]->F = LAYER_HIDDEN;\n          // Note: the direction is FWD by default (0), so we don't need to set it here\n        }\n      }*/\n      // TODO: gather layers for bidirectional case...??\n\n\n      net.loaded = 1;\n      \n      return 1;\n    } else {\n      SMILE_ERR(1,\"failed to open rnn net file '%s'.\",filename);\n    }\n  } else {\n    SMILE_ERR(1,\"failed to open rnn net file, the filename is a NULL string.\");\n  }\n  return 0;\n}\n\ncNnLSTMlayer *smileRnn_createLstmLayer(int i, int idx, int dir, cRnnNetFile &net)\n{\n  // create the forward layer\n  cNnLSTMlayer * l = new cNnLSTMlayer(net.hiddenSize[i],idx,dir,net.nContext);\n  // create cells with activation functions\n  cNnTf * tfI=NULL, * tfO=NULL, *tfG=NULL;\n  if (net.hiddenActType[i] == NNLSTMACT_TANHTANHLOGI) {\n    tfI = new cNnTfTanh();\n    tfO = new cNnTfTanh();\n    tfG = new cNnTfLogistic();\n  } else if (net.hiddenActType[i] == NNLSTMACT_TANHIDENLOGI) {\n    tfI = new cNnTfTanh();\n    tfO = new cNnTfIdentity();\n    tfG = new cNnTfLogistic();\n  } else {\n    COMP_ERR(\"unknown hiddenActType[%i] %i while creating an LSTM layer!\",i,net.hiddenActType[i]);\n  }\n  l->createCells(tfI,tfO,tfG , net.cellsPerBlock);\n\n  return l;\n}\n\ncNnNNlayer *smileRnn_createFeedforwardLayer(int i, int idx, int dir, cRnnNetFile &net)\n{\n  // create the forward layer\n  cNnNNlayer * l = new cNnNNlayer(net.hiddenSize[i],idx,dir,net.nContext);\n  // create cells with activation functions\n  cNnTf * tf = NULL;\n  if (net.hiddenActType[i] == NNACT_TANH) {\n    tf = new cNnTfTanh();\n  } else if (net.hiddenActType[i] == NNACT_IDEN) {\n    tf = new cNnTfIdentity();\n  } else if (net.hiddenActType[i] == NNACT_LOGI) {\n    tf = new cNnTfLogistic();\n  } else {\n    COMP_ERR(\"unknown hiddenActType[%i] %i while creating a feedforward layer!\", i, net.hiddenActType[i]);\n  }\n  l->createCells(tf);\n  return l;\n}\n\nint smileRnn_findPeepWeights(unsigned long id, cRnnNetFile &net) \n{\n  int j;\n  for (j=0; j<net.nWeightVectors; j++) {\n    if ( net.wv[j]->F == (id|LAYER_PEEPHOLES) ) {\n      // return the weightVector index..\n      return j;\n    }\n  }\n  return -1;\n}\n\nint smileRnn_findWeights(unsigned long idFrom, unsigned long idTo, cRnnNetFile &net) \n{\n  int j;\n  for (j=0; j<net.nWeightVectors; j++) {\n    if ((net.wv[j]->F == idFrom)&&(net.wv[j]->T == idTo)) {\n      // return the weightVector index..\n      return j;\n    }\n  }\n  return -1;\n}\n\nint smileRnn_getInputSelection(cRnnNetFile &net, FLOAT_NN **weights)\n{\n  if (weights == NULL) return 0;\n\n  int j = smileRnn_findWeights(LAYER_INPUT, LAYER_DIR_FWD | LAYER_HIDDEN | 0, net);\n  \n  // get number of input units\n  *weights = (FLOAT_NN *)calloc(1,sizeof(FLOAT_NN)*net.inputSize);\n\n  long nOut = net.wv[j]->nWeights / net.inputSize;\n\n  // sum up input weights\n  FLOAT_NN *w = net.wv[j]->weights;\n\n  long i,n;\n  for (i=0; i<net.inputSize; i++) {\n    for (n=0; n<nOut; n++) {\n      (*weights)[i] += fabs( *(w++) );\n    }\n    (*weights)[i] /= (FLOAT_NN)nOut;\n  }\n\n  // output weight vector:\n  return net.inputSize;\n}\n\n// create a network from a successfully loaded net config file (loadNet function)\nint smileRnn_createNet(cRnnNetFile &net, cNnRnn *&rnn, int printConnections)\n{\n  int i,j,idx=0;\n  if (net.loaded) {\n    int nlayers = net.nHiddenLayers+2;\n    if (net.bidirectional) nlayers += net.nHiddenLayers;\n    rnn = new cNnRnn(nlayers); // +1 input, +1 ouput layer\n\n    // input layer...\n    SMILE_DBG(2,\"net input size: %i\",net.inputSize);\n    cNnNNlayer *nl = new cNnNNlayer(net.inputSize,0,0,net.nContext);\n    cNnTf * tf = new cNnTfIdentity(); // identity at the inputs\n    nl->createCells(tf);\n    nl->setName(\"input\");\n    SMILE_MSG(3, \"[rnn-c] adding input layer (%i)\", idx);\n    rnn->addLayer(nl, idx++);\n\n    // hidden layers...\n    unsigned long dir = LAYER_DIR_FWD;  // no blstm supported yet, or not needed?\n    for (i=0; i<net.nHiddenLayers; i++) {\n      cNnLayer *l = NULL;\n      int recurrent = 0;\n\n      ////////////// forward layers and backward layers (depends on odd/even iteration and net config)\n\n      if (net.hiddenType[i] == NNLAYERTYPE_LSTM) {\n        cNnLSTMlayer * ll = smileRnn_createLstmLayer(i,idx,(dir==LAYER_DIR_FWD?0:1),net);\n        char *tmp = myvprint(\"hidden_lstm_%i_%c\",i,(dir==LAYER_DIR_FWD?'f':'b'));\n        ll->setName(tmp);\n        free(tmp);\n        //// peephole weights\n        j = smileRnn_findPeepWeights(dir | LAYER_HIDDEN | i, net);\n        if (j>=0) ll->setPeepWeights(net.wv[j]->weights, net.wv[j]->nWeights);\n        l= (cNnLayer*)ll;\n        recurrent = 1;\n      } else if (net.hiddenType[i] == NNLAYERTYPE_NN) {\n        cNnNNlayer * ll = smileRnn_createFeedforwardLayer(i,idx,(dir==LAYER_DIR_FWD?0:1),net);\n        char *tmp = myvprint(\"hidden_feedforward_%i_%c\",i,(dir==LAYER_DIR_FWD?'f':'b'));\n        ll->setName(tmp);\n        l = (cNnLayer*)ll;\n      } else if (net.hiddenType[i] == NNLAYERTYPE_RNN) {\n        SMILE_ERR(1, \"[rnn] recurrent standard neuron (nn) layers are not yet supported!\");\n        l = new cNnNNlayer(net.hiddenSize[i],idx,(dir==LAYER_DIR_FWD?0:1),net.nContext);\n        // TODO... weights, transfer functions, createCells, bias...\n\n        char *_tmp;\n          recurrent = 1; \n          _tmp = myvprint(\"hidden_rnn_%i_%c\",i,(dir==LAYER_DIR_FWD?'f':'b'));\n        l->setName(_tmp);\n        free(_tmp);\n      }\n\n      // add the new layer\n      rnn->addLayer(l, idx);\n      // connect hidden layer\n      rnn->connectTo(idx,1+recurrent);\n      // the input connection \n      if ((net.bidirectional)&&(idx>1)) {\n        rnn->connectFrom(idx-2,idx); // TODO: consider gather layers...??\n      } else {\n        rnn->connectFrom(idx-1,idx); // previous layer only\n        SMILE_MSG(3, \"[rnn-c] connecting layer %i from layer %i\", idx, idx - 1);\n      }\n      if (recurrent) {\n        // the recurrent connection\n        rnn->connectFrom(idx,idx); \n      }\n\n      // initialise this connection\n      rnn->initialise(idx);\n\n      //// set weights\n      // the bias weights\n      j = smileRnn_findWeights(LAYER_BIAS, dir | LAYER_HIDDEN | i, net);\n      rnn->setBias(idx,net.wv[j]->weights, net.wv[j]->nWeights);\n\n\n      // set connection weights\n      if (net.bidirectional) {\n        // bidirectional layers...\n        // input: input layer? ?\n        if (idx > 2) {\n          // TODO: connect previous gather layer as input to both fwd and rwd layer\n          j = smileRnn_findWeights(LAYER_HIDDEN_GATHER | i-1, dir | LAYER_HIDDEN | i, net);\n        } else {\n          // connect input layer to both fwd and rwd layers\n          j = smileRnn_findWeights(LAYER_INPUT, dir | LAYER_HIDDEN | i , net);\n        }\n      } else if (idx > 1) {\n        // previous hidden layer, non-bidirectional  (in the non-bidirectional case this is equivalent to the gather layer)\n        j = smileRnn_findWeights(LAYER_HIDDEN_GATHER | i-1, dir | LAYER_HIDDEN | i, net);\n        if (j < 0) {\n          j = smileRnn_findWeights(LAYER_HIDDEN | i-1, dir | LAYER_HIDDEN | i, net);\n        }\n      } else {\n        // input layer..\n        j = smileRnn_findWeights(LAYER_INPUT, dir | LAYER_HIDDEN | i, net);\n      }\n      rnn->setWeights(0,idx,net.wv[j]->weights, net.wv[j]->nWeights);\n\n\n      if (recurrent) {\n        // the recurrent connection weights\n        j = smileRnn_findWeights(dir | LAYER_HIDDEN | i, dir | LAYER_HIDDEN | i, net);\n        rnn->setWeights(1,idx,net.wv[j]->weights, net.wv[j]->nWeights);\n      }\n\n      idx++; // to next layer...\n\n      if (net.bidirectional) { ///// add the backward layers in the next loop iteration ...\n        if (dir == LAYER_DIR_FWD) { /* 0 = FWD */\n          i--;\n          dir = LAYER_DIR_RWD; /* 1 = reverse */\n        } else {\n          dir = LAYER_DIR_FWD;\n        }\n      }\n\n    }\n\n    // output layer... (TODO: other output layer types than regression...)\n    SMILE_MSG(2,\"[rnn] net-task: %i\",net.task);\n    SMILE_MSG(3,\"[rnn] net output size: %i\",net.outputSize);\n    if (net.task == NNTASK_CLASSIFICATION) {\n      cNnSoftmaxLayer * sfl = new cNnSoftmaxLayer(net.outputSize,idx);\n      sfl->setName(\"softmax_output\");\n      rnn->addLayer(sfl, idx);\n    } else if (net.task == NNTASK_TRANSCRIPTION) {\n      cNnSoftmaxLayer * sfl = new cNnSoftmaxLayer(net.outputSize,idx);\n      sfl->setName(\"CTCsoftmax_output\");\n      rnn->addLayer(sfl, idx);\n    } else {\n      nl = new cNnNNlayer(net.outputSize,idx);\n      tf = new cNnTfIdentity(); // default sigmoid unit..? or identity at the inputs??\n      nl->createCells(tf);\n      nl->setName(\"output\");\n      rnn->addLayer(nl, idx);\n      //rnn->addLayer(new cNnNNlayer(net.outputSize,idx), idx);\n    }\n\n    // connect output layer\n    if (net.bidirectional) { // TODO.... memory!\n      SMILE_ERR(1, \"Bidirectional nets likely not yet supported!\");\n      rnn->connectTo(idx, 2);\n      rnn->connectFrom(idx-1, idx);\n      rnn->connectFrom(idx-2, idx);\n    } else {\n      SMILE_MSG(3, \"[rnn-c] connecting layer %i (output layer) from layer %i\", idx, idx - 1);\n      rnn->connectTo(idx, 1);\n      rnn->connectFrom(idx-1, idx);\n    }\n\n    rnn->initialise(idx);\n\n    j = smileRnn_findWeights(LAYER_BIAS, LAYER_OUTPUT, net);\n    rnn->setBias(idx,net.wv[j]->weights, net.wv[j]->nWeights);\n\n    j = smileRnn_findWeights(LAYER_DIR_FWD | LAYER_HIDDEN | (net.nHiddenLayers-1), LAYER_OUTPUT, net);\n    //    fprintf(stderr,\"setW j=%i  %i  %i\\n\",j,idx,net.wv[j]->nWeights);\n    if (j >= 0) {\n      rnn->setWeights(0,idx,net.wv[j]->weights, net.wv[j]->nWeights);\n    } else {\n      SMILE_ERR(1, \"No weights from hidden layer (forward) %i to output layer found!\", (net.nHiddenLayers)); // +1 due to input layer\n      return 0;\n    }\n    if (net.bidirectional) {\n      j = smileRnn_findWeights(LAYER_DIR_RWD | LAYER_HIDDEN | (net.nHiddenLayers-1), LAYER_OUTPUT, net);\n      if (j >= 0) {\n        rnn->setWeights(1,idx,net.wv[j]->weights, net.wv[j]->nWeights);\n      } else {\n        SMILE_ERR(1, \"No weights from hidden layer (backwards) %i to output layer found!\", (net.nHiddenLayers-1));\n        return 0;\n      }\n    }\n\n    if (printConnections) rnn->printConnections();\n\n    return 1;\n  }\n  return 0;\n}\n\n#endif // BUILD_RNN\n"
  },
  {
    "path": "src/rnn/rnnProcessor.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\n example of a vector processor\n\n*/\n\n\n\n#include <rnn/rnnProcessor.hpp>\n\n#define MODULE \"cRnnProcessor\"\n\n#ifdef BUILD_RNN\n\nSMILECOMPONENT_STATICS(cRnnProcessor)\n\nSMILECOMPONENT_REGCOMP(cRnnProcessor)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CRNNPROCESSOR;\n  sdescription = COMPONENT_DESCRIPTION_CRNNPROCESSOR;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataProcessor\")\n\n  // if the inherited config type was found, we register our configuration variables\n  SMILECOMPONENT_IFNOTREGAGAIN( {} // <- this is only to avoid compiler warnings...\n    // name append has a special role: it is defined in cDataProcessor, and can be overwritten here:\n    //ct->setField(\"nameAppend\",NULL,\"processed\");\n    ct->setField(\"netfile\",\"The file which contains the trained network created by rnnlib\",(const char *)NULL);\n    ct->setField(\"jsonNet\", \"1/0 = yes/no. Flag that indicates whether 'netfile' is in json format (1) (trained with current) or in rnnlib format (0).\", 0);\n    ct->setField(\"classlabels\",\"Give a string of comma separated (NO spaces allowed!!) class names (e.g. class1,class2,class3) for a classification or transcription task\",(const char*)NULL);\n    ct->setField(\"printConnections\",\"1/0 = yes/no : print human readable information on the network layers on connections\",0);\n    //ct->setField(\"printInputStats\",\"1/0 = yes/no : print input weight sums (can be used for feature selection...)\",0);\n  )\n\n  // The configType gets automatically registered with the config manger by the SMILECOMPONENT_IFNOTREGAGAIN macro\n  \n  // we now create out sComponentInfo, including name, description, success status, etc. and return that\n  SMILECOMPONENT_MAKEINFO(cRnnProcessor);\n}\n\nSMILECOMPONENT_CREATE(cRnnProcessor)\n\n//-----\n\ncRnnProcessor::cRnnProcessor(const char *_name) :\n  cDataProcessor(_name), frameO(NULL), nClasses(0),\n  classlabels_(NULL), classlabelArr_(NULL), net_created_(0)\n{\n\n}\n\nvoid cRnnProcessor::fetchConfig()\n{\n  cDataProcessor::fetchConfig();\n  \n  netfile = getStr(\"netfile\");\n  SMILE_IDBG(2,\"netfile = '%s'\",netfile);\n\n  jsonNet = getInt(\"jsonNet\");\n\n  const char * classlabels = getStr(\"classlabels\");\n  SMILE_IDBG(2,\"classlabels = '%s'\", classlabels);\n  if (classlabels != NULL) {\n    classlabels_ = strdup(classlabels);\n    // count number of classes:\n    nClasses = 1;\n    char *cl = classlabels_;\n    while(1) {\n      char *x = strchr(cl,',');\n      if (x!=NULL) {\n        cl=x+1;\n        nClasses++;\n      } else {\n        break;\n      }\n    }\n\n    // allocate memory for classes array\n    classlabelArr_ = (const char **)calloc(1,sizeof(const char *)*nClasses);\n\n    // parse class names\n    long i=0;\n    cl = classlabels_;\n    while(1) {\n      char *x = strchr(cl,',');\n      if (x!=NULL) {\n        *x=0;\n        classlabelArr_[i] = (const char *)cl;\n        if (*(x+1) == 0) { nClasses--; break; }\n        cl = x+1;\n        i++;\n      } else {\n        classlabelArr_[i] = (const char *)cl;\n        i++;\n        break;\n      }\n    }\n   \n  }\n  \n  printConnections = getInt(\"printConnections\");\n  SMILE_IDBG(2,\"printConnections = %i\",printConnections);\n}\n\n\nint cRnnProcessor::myConfigureInstance()\n{\n  int ret = cDataProcessor::myConfigureInstance();\n  if (ret) {\n    if (net.loaded == 0) {\n      if (jsonNet) {\n        ret = smileRnn_loadNetJson(netfile,net);\n      } else {\n        ret = smileRnn_loadNet(netfile,net);\n      }\n    }\n    //TODO: create individual nets for each idxi, or only one net if \"processArrayFields=0\"\n    // thus: move this code to  setupNamesForField\n  }\n  return ret;\n}\n\nint cRnnProcessor::setupNewNames(long nEl)\n{\n  if ((net.task == NNTASK_CLASSIFICATION)||(net.task == NNTASK_TRANSCRIPTION)) {\n    long i;\n   if (net.outputSize) printf(\"outputsize: %i\\n\",net.outputSize);\n   if (nClasses) printf(\"classes: %i\\n\",nClasses);\n    for (i=0; i<MIN(nClasses,net.outputSize); i++) {\n      addNameAppendField(\"RNNoutpAct\", classlabelArr_[i], 1);\n    }\n    if (net.outputSize > nClasses) {\n      if (net.task == NNTASK_TRANSCRIPTION) {\n        for (i=nClasses; i<net.outputSize-1; i++) {\n          addNameAppendField(\"RNNoutpAct\",\"unlabelled\",1);\n        }\n        addNameAppendField(\"RNNoutpAct\",\"ctcOther\",1);\n      } else {\n        for (i=nClasses; i<net.outputSize; i++) {\n          addNameAppendField(\"RNNoutpAct\",\"unlabelled\",1);\n        }\n      }\n    }\n  } else {\n    addNameAppendField(\"RNNoutpAct\", nameAppend_, net.outputSize);\n  }\n\tnamesAreSet_ = 1;\n  return 1;\n}\n\n\n\nint cRnnProcessor::myFinaliseInstance()\n{\n  int ret = cDataProcessor::myFinaliseInstance();\n\n  if (ret) {\n    /*\n    if (getInt(\"printInputStats\")) {\n      FLOAT_NN *wg = NULL;\n      long N = smileRnn_getInputSelection(net, &wg);\n      long i;\n      if (wg != NULL) {\n        SMILE_PRINT(\"input weighting:\");\n        for (i=0; i<N; i++) {\n          SMILE_PRINT(\"%i: %f\",i,wg[i]);\n        }\n      } else {\n        SMILE_IERR(1,\"input weighting information is not available\");\n      }\n    }\n    */\n    if (net_created_ == 0) {\n      ret = smileRnn_createNet(net,rnn,printConnections);\n      if (ret) {\n        in = (FLOAT_NN*)malloc(sizeof(FLOAT_NN)*net.inputSize);\n        out = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*net.outputSize);\n        frameO = new cVector(net.outputSize);\n        net_created_ = 1;\n      }\n    }\n  }\n  return ret;\n}\n\n\n// a derived class should override this method, in order to implement the actual processing\nint cRnnProcessor::myTick(long long t)\n{\n  cVector * frame = reader_->getNextFrame();\n  if (frame == NULL) return 0;\n\n  // pass current vector to net\n  long i, _N=0;\n  for (i=0; i<MIN(frame->N,net.inputSize); i++) { in[i] = (FLOAT_NN)(frame->dataF[i]); }\n  rnn->forward(in, MIN(frame->N,net.inputSize));\n  \n  // get output\n  const FLOAT_NN *outp = rnn->getOutput(&_N);\n  \n  //copy to *dst;\n  for (i=0; i<MIN(frameO->N,_N); i++) {\n    frameO->dataF[i] = (FLOAT_DMEM)outp[i];\n  }\n\n  writer_->setNextFrame(frameO);\n\n  return 1;\n}\n\ncRnnProcessor::~cRnnProcessor()\n{\n  if (in != NULL) free(in);\n  if (out != NULL) free(out);\n  if (rnn != NULL) delete rnn;\n  if (classlabels_ != NULL) free(classlabels_);\n  if (classlabelArr_ != NULL) free(classlabelArr_);\n  if (frameO != NULL) delete frameO;\n}\n\n#endif // BUILD_RNN\n"
  },
  {
    "path": "src/rnn/rnnSink.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nexample dataSink:\nreads data from data memory and outputs it to console/logfile (via smileLogger)\nthis component is also useful for debugging\n\n*/\n\n\n#include <rnn/rnnSink.hpp>\n\n\n\n\n#define MODULE \"cRnnSink\"\n\n#ifdef BUILD_RNN\n\nSMILECOMPONENT_STATICS(cRnnSink)\n\nSMILECOMPONENT_REGCOMP(cRnnSink)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n\n  scname = COMPONENT_NAME_CRNNSINK;\n  sdescription = COMPONENT_DESCRIPTION_CRNNSINK;\n\n  // we inherit cDataSink configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSink\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"netfile\",\"The file which contains the trained network created by rnnlib\",(const char *)NULL);\n    ct->setField(\"actoutput\",\"A text file to which the raw output activations will be saved. Each frame will be saved on a separate line (this is rnnlib's activation output format transposed).\",(const char*)NULL);\n    ct->setField(\"classoutput\",\"A text file to which the winning class label will be saved (task = classification or transcription). The result for each frame will be saved on a separate line.\",(const char*)NULL);\n    //TODO: label output\n\n    ct->setField(\"classlabels\",\"Give a string of comma separated (NO spaces allowed!!) class names (e.g. class1,class2,class3) for a classification or transcription task\",(const char*)NULL);\n    ct->setField(\"ctcDecode\",\"1/0 = yes/no : Do basic ctc (transcription) decoding, i.e. remove duplicate labels and (TODO: compute label alignments.)\",1);\n    ct->setField(\"printConnections\",\"1/0 = yes/no : print human readable information on the network layers on connections\",0);\n    ct->setField(\"printInputStats\",\"1/0 = yes/no : print input weight sums (can be used for feature selection...)\",0);\n    //ct->setField(\"lag\",\"Output data <lag> frames behind\",0,0,0);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cRnnSink);\n}\n\nSMILECOMPONENT_CREATE(cRnnSink)\n\n\n\n//-----\n\ncRnnSink::cRnnSink(const char *_name) :\n  cDataSink(_name),\n  netfile(NULL), in(NULL), out(NULL), rnn(NULL), classlabelArr(NULL), \n  ctcDecode(0), actoutput(NULL), classlabels(NULL), nClasses(0),\n  outfile(NULL), outfileC(NULL)\n{\n  // ...\n}\n\nvoid cRnnSink::fetchConfig()\n{\n  cDataSink::fetchConfig();\n  \n  netfile = getStr(\"netfile\");\n  SMILE_IDBG(2,\"netfile = '%s'\",netfile);\n\n  actoutput = getStr(\"actoutput\");\n  SMILE_IDBG(2,\"actoutput = '%s'\",actoutput);\n\n  classoutput = getStr(\"classoutput\");\n  SMILE_IDBG(2,\"classoutput = '%s'\",classoutput);\n\n  const char * _classlabels = getStr(\"classlabels\");\n  SMILE_IDBG(2,\"classlabels = '%s'\",_classlabels);\n  if (_classlabels != NULL) {\n    classlabels = strdup(_classlabels);\n    // count number of classes:\n    nClasses = 1;\n    char *cl = classlabels;\n    while(1) {\n      char *x = strchr(cl,',');\n      if (x!=NULL) {\n        cl=x+1;\n        nClasses++;\n      } else {\n        break;\n      }\n    }\n\n    // allocate memory for classes array\n    classlabelArr = (const char **)calloc(1,sizeof(const char *)*nClasses);\n\n    // parse class names\n    long i=0;\n    cl = classlabels;\n    while(1) {\n      char *x = strchr(cl,',');\n      if (x!=NULL) {\n        *x=0;\n        classlabelArr[i] = (const char *)cl;\n        if (*(x+1) == 0) { nClasses--; break; }\n        cl = x+1;\n        i++;\n      } else {\n        classlabelArr[i] = (const char *)cl;\n        i++;\n        break;\n      }\n    }\n   \n  }\n\n  ctcDecode = getInt(\"ctcDecode\");\n  SMILE_IDBG(2,\"ctcDecode = %i\",ctcDecode);\n\n  printConnections = getInt(\"printConnections\");\n  SMILE_IDBG(2,\"printConnections = %i\",printConnections);\n}\n\n#if 0\nunsigned long parseLayerNumber(char *s, unsigned long *dir)\n{\n  char *x = strchr(s,'_');\n  if (dir != NULL) {\n    *dir = LAYER_DIR_FWD;\n  }\n  if (x != NULL) { // two numbers separated by _, e.g. 0_1\n    if ((*(x+1) == '1')&&(dir != NULL)) {\n        *dir = LAYER_DIR_RWD;\n    }\n    *x = 0;\n    return (unsigned long)strtol(s,NULL,10);\n  } else { // only one number\n    return (unsigned long)strtol(s,NULL,10);\n  }\n  return -1;\n}\n\ncRnnWeightVector *cRnnSink::createWeightVectorFromLine(char *line)\n{\n  long i=0;\n  char *lastl = line;\n  char *curl=line;\n  char *name = NULL;\n\n  // get name\n  while(1) {\n    if ((*curl == ' ')||(*curl == 0)) { \n      if (*curl == 0) return NULL;\n      *curl = 0; name = lastl; curl++; lastl = curl; break; \n    }\n    curl++;\n  }\n  // check for \"_weights\"\n  char *_to=NULL, *_from=NULL;\n  int isPeep = 0;\n  char *ww = strstr(name,\"_weights\");\n  if (ww != NULL) {\n    // truncate\n    ww[0] = 0;\n    ww = strstr(name,\"_to_\");\n    if (ww != NULL) {\n      ww[0] = 0;\n      _to = ww+4;\n      ww = strstr(_to,\"_delay_1\"); // remove the\n      if (ww != NULL) ww[0] = 0;   // delay_1 suffix for recurrent connections...\n      ww = strstr(_to,\"_delay_-1\"); // remove the\n      if (ww != NULL) ww[0] = 0;   // delay_-1 suffix for recurrent connections...\n      _from = name;\n    } else { // peepholes?\n      ww = strstr(name,\"_peepholes\");\n      if (ww != NULL) { // yes, peephole weights\n        ww[0] = 0;\n        _from = name; // assign only from !\n        isPeep = 1;\n      } else { //syntax error\n        return NULL;\n      }\n    }\n  } else {\n    // if not found (no weight vector!)\n    return NULL;\n  }\n\n  // get number of weights\n  char *numw=NULL;\n  while(1) {\n    if ((*curl == ' ')||(*curl == 0)) { \n      if (*curl == 0) return NULL;\n      *curl = 0; numw = lastl; curl++; lastl = curl; break; \n    }\n    curl++;\n  }\n  // convert numw to int\n  long nWeights = strtol(numw,NULL,10);\n\n  if (nWeights > 0) {\n    if (isPeep) {\n      SMILE_IMSG(3,\"%i peephole weights in layer '%s'\",nWeights,_from);\n    } else {\n      SMILE_IMSG(3,\"%i weights : from '%s' to '%s'\",nWeights,_from,_to);\n    }\n    // create weights vector\n    cRnnWeightVector *l = new cRnnWeightVector(nWeights);\n    // copy from and to names..\n    if (_to != NULL) { strncpy(l->to,_to,100); }\n    if (_from != NULL) { strncpy(l->from,_from,100); }\n    // parse from and to names...?\n    if (isPeep) { // peephole weights require only the \"from\" field (they are layer internal)\n      l->F = 0; l->T=-1;\n      if (!strncmp(l->from,\"hidden_\",7)) { l->F = LAYER_HIDDEN; }\n      l->F |= LAYER_PEEPHOLES;\n      // layer number and direction ...\n      unsigned long dir=0;\n      l->F |= parseLayerNumber(l->from+7,&dir);\n      l->F |= dir;\n    } else {\n      l->F = 0; l->T=-1;\n      if (!strncmp(l->from,\"bias\",4)) { l->F = LAYER_BIAS; }\n      else if (!strncmp(l->from,\"hidden_\",7)) {  // || (!strncmp(l->from,\"gather_\",7))\n        l->F = LAYER_HIDDEN; \n        // layer number and direction ...\n        unsigned long dir=0;\n        l->F |= parseLayerNumber(l->from+7,&dir);\n        l->F |= dir;\n      } else if (!strncmp(l->from,\"gather_\",7)) {  // || (!strncmp(l->from,\"gather_\",7))\n        l->F = LAYER_HIDDEN_GATHER; \n        // layer number and direction ...\n        //unsigned long dir=0;\n        l->F |= parseLayerNumber(l->from+7,NULL);\n        //l->F |= dir;\n        printf(\"layer F: %i\\n\",l->F);\n      }\n      else if (!strncmp(l->from,\"input\",5)) { l->F = LAYER_INPUT; }\n\n      if (!strncmp(l->to,\"hidden_\",7)) { \n        l->T = LAYER_HIDDEN;\n        // layer number and direction ...\n        unsigned long dir=0;\n        l->T |= parseLayerNumber(l->to+7,&dir);\n        l->T |= dir;\n      }\n      else if (!strncmp(l->to,\"output\",6)) { l->T = LAYER_OUTPUT; }\n    }\n\n    //XX//fprintf(stderr,\"strL curl %i\\n\",strlen(curl));\n    // copy weights to vector\n    long curW = 0;\n    char *w=NULL;\n    while(1) {\n      if (*curl == ' ') { \n        *curl=0; char *ep=NULL;\n        FLOAT_NN wf = strtod(lastl,&ep);\n        l->weights[curW++] = wf;\n        if (nWeights == curW) {\n          SMILE_IERR(1,\"too many weights on line, expected only %i weights ('%s')\",nWeights,lastl);\n          break;\n        }\n        //XX//if (wf != 0.001) { fprintf(stderr,\"curW %i of %i\\n\", curW,nWeights); }\n        curl++; lastl = curl; \n      } else if ((*curl == '\\n')||(*curl == '\\r')||(*curl == 0)) { \n        *curl=0; char *ep=NULL;\n        FLOAT_NN wf = strtod(lastl,&ep);\n        l->weights[curW++] = wf;\n        \n        //curl++; lastl = curl; \n        break;\n      } else {\n        curl++;\n      }\n    }\n\n    return l;\n  }\n  return NULL;\n}\n\n\nint cRnnSink::loadNet(const char *filename)\n{\n  int bidirectional = 1;\n  net.nContext = 0;\n  if (filename != NULL) {\n    FILE *f = fopen(filename,\"r\");\n    if (f != NULL) {\n      char *line=NULL;\n      size_t n=0;\n      int ret;\n      do { // read the net file line by line...\n        ret = smile_getline(&line,&n,f);\n        if ((ret > 1)&&(line!=NULL)) {\n          if (!strncmp(line,\"weightContainer_\",16)) { // weight vector line...\n            cRnnWeightVector *v = createWeightVectorFromLine(line+16);\n            if (v != NULL) { // add to a collection..\n              net.wv[net.nWeightVectors++] = v;\n            }\n          } else {\n            // net config line\n            // we are interested in reading 'hiddenSize', 'hiddenType', 'task' (output layer!), and possibly (?) 'actSmoothing' and 'actDecay'\n            if (!strncmp(line,\"hiddenSize \",11)) {\n              // parse string with sizes of hidden layer, space separated\n              long i=0;\n              char *n1=line+11, *n2=line+11;\n              while(1) {\n                if ((*n2 == ',')||(*n2=='\\n')||(*n2=='\\r')||(*n2==0)) {\n                  char myc = *n2;\n                  *n2 = 0;\n                  long l = strtol(n1,NULL,10);\n                  net.hiddenSize[i++] = l;\n                  if ((myc=='\\n')||(myc=='\\r')||(myc==0)) { break; }\n                  n2++; n1=n2;\n                } else { n2++; }\n              }\n              net.nHiddenLayers = i;\n            } else if (!strncmp(line,\"hiddenType \",11)) {\n              // parse string with types of hidden layers (space separated?)\n              long i=0;\n              char *n1=line+11, *n2=line+11;\n              while(1) {\n                if ((*n2 == ',')||(*n2=='\\n')||(*n2=='\\r')||(*n2==0)) {\n                  char myc = *n2;\n                  *n2 = 0;\n                  if (!strncmp(n1,\"lstm\",4)) {\n                    net.hiddenType[i] = NNLAYERTYPE_LSTM;\n                    net.hiddenActType[i] = NNLSTMACT_TANHTANHLOGI;\n                    i++;\n                  } else if (!strncmp(n1,\"linear_lstm\",11)) {\n                    net.hiddenType[i] = NNLAYERTYPE_LSTM;\n                    net.hiddenActType[i] = NNLSTMACT_TANHIDENLOGI;\n                    i++;\n                  } else if (!strncmp(n1,\"tanh\",4)) {\n                    net.hiddenType[i] = NNLAYERTYPE_RNN;\n                    net.hiddenActType[i] = NNACT_TANH;\n                    i++;\n                  } else if (!strncmp(n1,\"linear\",6)) {\n                    net.hiddenType[i] = NNLAYERTYPE_RNN;\n                    net.hiddenActType[i] = NNACT_IDEN;\n                    i++;\n                  } else if (!strncmp(n1,\"logistic\",8)) {\n                    net.hiddenType[i] = NNLAYERTYPE_RNN;\n                    net.hiddenActType[i] = NNACT_LOGI;\n                    i++;\n                  } else {\n                    SMILE_IERR(1,\"unsupported hidden layer type '%s' ('hiddenType' option) while reading '%s'.\",n1,netfile);\n                  }\n                  if ((myc=='\\n')||(myc=='\\r')||(myc==0)) { break; }\n                  n2++; n1=n2;\n                } else { n2++; }\n              }\n              // duplicate hiddenType if # < nHiddenLayers:\n             /* if (i<net.nHiddenLayers) {\n                for(; i<net.nHiddenLayers; i++) {\n                  net.hiddenActType[i] = net.hiddenActType[i-1];\n                  net.hiddenType[i] = net.hiddenType[i-1];\n                }\n              }*/\n              if (net.nHiddenLayers > i) { // if less types than layer sizes given, assume the following layers are of the same type as the last layer...?\n                int tp = net.hiddenType[i-1];\n                int ac = net.hiddenActType[i-1];\n                for (; i<net.nHiddenLayers; i++) {\n                  net.hiddenType[i] = tp;\n                  net.hiddenActType[i] = ac;\n                }\n              }\n            } else if (!strncmp(line,\"task \",5)) {\n              // net task\n              if (!strncmp(line+5,\"regression\",10)) {\n                net.task = NNTASK_REGRESSION;\n              } else if (!strncmp(line+5,\"classification\",14)) {\n                net.task = NNTASK_CLASSIFICATION;\n              } else if (!strncmp(line+5,\"transcription\",13)) {\n                net.task = NNTASK_TRANSCRIPTION;\n                //SMILE_IERR(1,\"CTC decoding (task = transcription) not yet supported!\");\n              }\n            } else if (!strncmp(line,\"bidirectional \",14)) {\n              if (!strncmp(line+14,\"false\",5)) bidirectional = 0;\n              else if (!strncmp(line+14,\"true\",4)) bidirectional = 1;\n            } else if (!strncmp(line,\"contextLength \",13)) { // <-- this option is new, it is not an rnnlib option!\n              if (!strncmp(line+13,\"inf\",3)) net.nContext = 0;\n              else {\n                net.nContext = strtol(line+13,NULL,10);\n              }\n            }\n          }\n        } else { if (ret <= 0) break; }\n      } while (1);\n      fclose(f);\n      //// now determine inputSize and outputSize from connection weights\n      //// (the rnnlib determiens these sizes from the .nc files, which we don't have...)\n      // 1. find bias_to_output to get output size...\n      int i;\n      for (i=0; i<net.nWeightVectors; i++) {\n        if ((net.wv[i]->F == LAYER_BIAS) && (net.wv[i]->T == LAYER_OUTPUT)) { net.outputSize = net.wv[i]->nWeights; break; }\n      }\n      // 2. find input_to_hidden_0_x\n      for (i=0; i<net.nWeightVectors; i++) {\n        if ((net.wv[i]->F == LAYER_INPUT) && ( (net.wv[i]->T & LAYER_HIDDEN) == LAYER_HIDDEN)) { \n          long f = 1;\n          if (net.hiddenType[0] == NNLAYERTYPE_LSTM) { f = 4; }\n          net.inputSize = net.wv[i]->nWeights / (net.hiddenSize[0] * f); \n        }\n      }\n      net.cellsPerBlock = 1; // FIXME...!\n      // test for bidirectional network topology\n      net.bidirectional = bidirectional; // FIXME??\n      /*for (i=0; i<net.nWeightVectors; i++) {  // do this as extra check ???\n        if (net.wv[i]->F & LAYER_DIR_RWD == LAYER_DIR_RWD) net.bidirectional = 1;\n      }*/\n\n      // fix gather layers for the unidirectional case ....\n/*      if (!bidirectional) {\n        for (i=0; i<net.nWeightVectors; i++) {\n          if (net.wv[i]->F == LAYER_HIDDEN_GATHER) net.wv[i]->F = LAYER_HIDDEN;\n          // Note: the direction is FWD by default (0), so we don't need to set it here\n        }\n      }*/\n      // TODO: gather layers for bidirectional case...??\n\n\n      net.loaded = 1;\n      \n      return 1;\n    } else {\n      SMILE_IERR(1,\"failed to open rnn net file '%s'.\",filename);\n    }\n  } else {\n    SMILE_IERR(1,\"failed to open rnn net file, the filename is a NULL string.\");\n  }\n  return 0;\n}\n\ncNnLSTMlayer *cRnnSink::createLstmLayer(int i, int idx, int dir)\n{\n  // create the forward layer\n  cNnLSTMlayer * l = new cNnLSTMlayer(net.hiddenSize[i],idx,dir,net.nContext);\n  // create cells with activation functions\n  cNnTf * tfI=NULL, * tfO=NULL, *tfG=NULL;\n  if (net.hiddenActType[i] == NNLSTMACT_TANHTANHLOGI) {\n    tfI = new cNnTfTanh();\n    tfO = new cNnTfTanh();\n    tfG = new cNnTfLogistic();\n  } else if (net.hiddenActType[i] == NNLSTMACT_TANHIDENLOGI) {\n    tfI = new cNnTfTanh();\n    tfO = new cNnTfIdentity();\n    tfG = new cNnTfLogistic();\n  } else {\n    COMP_ERR(\"unknown hiddenActType[%i] %i while creating an LSTM layer!\",i,net.hiddenActType[i]);\n  }\n  l->createCells(tfI,tfO,tfG , net.cellsPerBlock);\n\n  return l;\n}\n\nint cRnnSink::findPeepWeights(unsigned long id) \n{\n  int j;\n  for (j=0; j<net.nWeightVectors; j++) {\n    if ( net.wv[j]->F == (id|LAYER_PEEPHOLES) ) {\n      // return the weightVector index..\n      return j;\n    }\n  }\n  return -1;\n}\n\nint cRnnSink::findWeights(unsigned long idFrom, unsigned long idTo) \n{\n  int j;\n  for (j=0; j<net.nWeightVectors; j++) {\n    if ((net.wv[j]->F == idFrom)&&(net.wv[j]->T == idTo)) {\n      // return the weightVector index..\n      return j;\n    }\n  }\n  return -1;\n}\n\n// create a network from a successfully loaded net config file (loadNet function)\nint cRnnSink::createNet()\n{\n  int i,j,idx=0;\n  if (net.loaded) {\n    int nlayers = net.nHiddenLayers+2;\n    if (net.bidirectional) nlayers += net.nHiddenLayers;\n    rnn = new cNnRnn(nlayers); // +1 input, +1 ouput layer\n\n    // input layer...\n    SMILE_IDBG(2,\"net input size: %i\",net.inputSize);\n    cNnNNlayer *nl = new cNnNNlayer(net.inputSize,0,0,net.nContext);\n    cNnTf * tf = new cNnTfIdentity(); // identity at the inputs\n    nl->createCells(tf);\n    nl->setName(\"input\");\n    rnn->addLayer(nl, idx++);\n \n    \n    // hidden layers...\n    unsigned long dir = LAYER_DIR_FWD;\n    for (i=0; i<net.nHiddenLayers; i++) {\n      cNnLayer *l = NULL;\n      int recurrent = 0;\n\n      ////////////// forward layers and backward layers (depends on odd/even iteration and net config)\n\n      if (net.hiddenType[i] == NNLAYERTYPE_LSTM) {\n        cNnLSTMlayer * _l = createLstmLayer(i,idx,(dir==LAYER_DIR_FWD?0:1));\n        char *_tmp = myvprint(\"hidden_lstm_%i_%c\",i,(dir==LAYER_DIR_FWD?'f':'b'));\n        _l->setName(_tmp);\n        free(_tmp);\n        //// peephole weights\n        j = findPeepWeights(dir | LAYER_HIDDEN | i);\n        if (j>=0) _l->setPeepWeights(net.wv[j]->weights, net.wv[j]->nWeights);\n        l=(cNnLayer*)_l;\n        recurrent = 1;\n      } else if ((net.hiddenType[i] == NNLAYERTYPE_RNN)||(net.hiddenType[i] == NNLAYERTYPE_NN)) {\n        l = new cNnNNlayer(net.hiddenSize[i],idx,(dir==LAYER_DIR_FWD?0:1),net.nContext);\n        // TODO... weights, transfer functions, createCells, bias...\n\n        char *_tmp;\n        if (net.hiddenType[i] == NNLAYERTYPE_RNN) { \n          recurrent = 1; \n          _tmp = myvprint(\"hidden_rnn_%i_%c\",i,(dir==LAYER_DIR_FWD?'f':'b'));\n        } else {\n          _tmp = myvprint(\"hidden_nn_%i_%c\",i,(dir==LAYER_DIR_FWD?'f':'b'));\n        }\n        l->setName(_tmp);\n        free(_tmp);\n      }\n      \n      // add the new layer\n      rnn->addLayer(l, idx);\n      // connect hidden layer\n      rnn->connectTo(idx,1+recurrent);\n      // the input connection \n      if ((net.bidirectional)&&(idx>1)) {\n        rnn->connectFrom(idx-2,idx); // TODO: consider gather layers...??\n      } else {\n        rnn->connectFrom(idx-1,idx); // previous layer only\n      }\n      if (recurrent) {\n        // the recurrent connection\n        rnn->connectFrom(idx,idx); \n      }\n\n      // initialise this connection\n      rnn->initialise(idx);\n\n\n      //// set weights\n      // the bias weights\n      j = findWeights(LAYER_BIAS, dir | LAYER_HIDDEN | i);\n      rnn->setBias(idx,net.wv[j]->weights, net.wv[j]->nWeights);\n\n      \n      // set connection weights\n      if (net.bidirectional) {\n        // bidirectional layers...\n        // input: input layer? ?\n        if (idx > 2) {\n          // TODO: connect previous gather layer as input to both fwd and rwd layer\n          j = findWeights(LAYER_HIDDEN_GATHER | i-1, dir | LAYER_HIDDEN | i);\n        } else {\n          // connect input layer to both fwd and rwd layers\n          j = findWeights(LAYER_INPUT, dir | LAYER_HIDDEN | i);\n        }\n      } else if (idx > 1) {\n        // previous hidden layer, non-bidirectional  (in the non-bidirectional case this is equivalent to the gather layer)\n        j = findWeights(LAYER_HIDDEN_GATHER | i-1, dir | LAYER_HIDDEN | i);\n      } else {\n        // input layer..\n        j = findWeights(LAYER_INPUT, dir | LAYER_HIDDEN | i);\n      }\n      rnn->setWeights(0,idx,net.wv[j]->weights, net.wv[j]->nWeights);\n      \n\n      if (recurrent) {\n        // the recurrent connection weights\n        j = findWeights(dir | LAYER_HIDDEN | i, dir | LAYER_HIDDEN | i);\n        rnn->setWeights(1,idx,net.wv[j]->weights, net.wv[j]->nWeights);\n      }\n\n      idx++; // to next layer...\n\n      if (net.bidirectional) { ///// add the backward layers in the next loop iteration ...\n        if (dir == LAYER_DIR_FWD) { /* 0 = FWD */\n          i--;\n          dir = LAYER_DIR_RWD; /* 1 = reverse */\n        } else {\n          dir = LAYER_DIR_FWD;\n        }\n      }\n\n    }\n\n    // output layer... (TODO: other output layer types than regression...)\n    SMILE_IMSG(2,\"net-task: %i\",net.task);\n    SMILE_IDBG(2,\"net output size: %i\",net.outputSize);\n    if (net.task == NNTASK_CLASSIFICATION) {\n      cNnSoftmaxLayer * sfl = new cNnSoftmaxLayer(net.outputSize,idx);\n      sfl->setName(\"softmax_output\");\n      rnn->addLayer(sfl, idx);\n    } else if (net.task == NNTASK_TRANSCRIPTION) {\n      cNnSoftmaxLayer * sfl = new cNnSoftmaxLayer(net.outputSize,idx);\n      sfl->setName(\"CTCsoftmax_output\");\n      rnn->addLayer(sfl, idx);\n    } else {\n      nl = new cNnNNlayer(net.outputSize,idx);\n      tf = new cNnTfIdentity(); // default sigmoid unit..? or identity at the inputs??\n      nl->createCells(tf);\n      nl->setName(\"output\");\n      rnn->addLayer(nl, idx);\n      //rnn->addLayer(new cNnNNlayer(net.outputSize,idx), idx);\n    }\n\n    // connect output layer\n    if (net.bidirectional) { // TODO.... memory!\n      rnn->connectTo(idx, 2);\n      rnn->connectFrom(idx-1, idx);\n      rnn->connectFrom(idx-2, idx);\n    } else {\n      rnn->connectTo(idx, 1);\n      rnn->connectFrom(idx-1, idx);\n    }\n\n    rnn->initialise(idx);\n\n    j = findWeights(LAYER_BIAS, LAYER_OUTPUT);\n    rnn->setBias(idx,net.wv[j]->weights, net.wv[j]->nWeights);\n\n    j = findWeights(LAYER_DIR_FWD | LAYER_HIDDEN | (net.nHiddenLayers-1), LAYER_OUTPUT);\n//    fprintf(stderr,\"setW j=%i  %i  %i\\n\",j,idx,net.wv[j]->nWeights);\n    rnn->setWeights(0,idx,net.wv[j]->weights, net.wv[j]->nWeights);\n    if (net.bidirectional) {\n      j = findWeights(LAYER_DIR_RWD | LAYER_HIDDEN | (net.nHiddenLayers-1), LAYER_OUTPUT);\n      rnn->setWeights(1,idx,net.wv[j]->weights, net.wv[j]->nWeights);\n    }\n\n    if (printConnections) rnn->printConnections();\n\n    return 1;\n  }\n  return 0;\n}\n\n#endif\n\nint cRnnSink::myConfigureInstance()\n{\n  int ret = cDataSink::myConfigureInstance();\n  if (ret) {\n    if (actoutput != NULL) { \n      outfile = fopen(actoutput,\"w\");  // TODO: \"append\" option\n      if (outfile == NULL) {\n        SMILE_IERR(1,\"cannot open output activations output file '%s' for writing! Check if the path etc. exists and is writeable, also check for free disk space!\",actoutput);\n        COMP_ERR(\"aborting\");\n      }\n    }\n    if (classoutput != NULL) {\n      outfileC = fopen(classoutput,\"w\");  // TODO: \"append\" option\n      if (outfileC == NULL) {\n        SMILE_IERR(1,\"cannot open class output file '%s' for writing! Check if the path etc. exists and is writeable, also check for free disk space!\",classoutput);\n        COMP_ERR(\"aborting\");\n      }\n    }\n    ret = smileRnn_loadNet(netfile,net);\n  }\n  return ret;\n}\n\n\nint cRnnSink::myFinaliseInstance()\n{\n  int ret = cDataSink::myFinaliseInstance();\n\n  if (ret) {\n    if (getInt(\"printInputStats\")) {\n      FLOAT_NN *wg = NULL;\n      long N = smileRnn_getInputSelection(net, &wg);\n      long i;\n      if (wg != NULL) {\n        SMILE_PRINT(\"input weighting:\");\n        for (i=0; i<N; i++) {\n          SMILE_PRINT(\"%i: %f\",i,wg[i]);\n        }\n      } else {\n        SMILE_IERR(1,\"input weighting information is not available\");\n      }\n    }\n    ret = smileRnn_createNet(net,rnn,printConnections);\n    if (ret) {\n      in = (FLOAT_NN*)malloc(sizeof(FLOAT_NN)*net.inputSize);\n      out = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*net.outputSize);\n    }\n  }\n  return ret;\n}\n\n\nint cRnnSink::myTick(long long t)\n{\n  SMILE_DBG(4,\"tick # %i, reading value vector:\",t);\n  cVector *vec= reader_->getNextFrame();\n  if (vec == NULL) return 0;\n  \n  long vi = vec->tmeta->vIdx;\n  double tm = vec->tmeta->time;\n  \n// pass current vector to net\n  long i, _N=0;\n  for (i=0; i<MIN(vec->N,net.inputSize); i++) { in[i] = (FLOAT_NN)(vec->dataF[i]); }\n  rnn->forward(in, /*vec->N*/ MIN(vec->N,net.inputSize));\n  const FLOAT_NN *outp = rnn->getOutput(&_N);\n//printf(\"outp[0]= %f , vec->dataF[0] = %f\\n\",outp[0],vec->dataF[0]);  \n\n  // for now, print the output vector to stdout...\n  //printf(\"--- vi = %i ---\\n\",vi);\n  double max=0.0; int maxi=-1;\n  if (outfile) {\n    for (i=0; i<_N-1; i++) {\n      fprintf(outfile,\"%f \",outp[i]);\n      if (outp[i]>max) { maxi=i; max=outp[i]; }\n    }\n    fprintf(outfile,\"%f\\n\",outp[i]);\n    if (outp[i]>max) { maxi=i; max=outp[i]; }\n  } else {\n    for (i=0; i<_N; i++) {\n      if (outp[i]>max) { maxi=i; max=outp[i]; }\n    }\n  }\n\n  //printf(\"voice: %f\\n\",outp[1]);\n\n  if (ctcDecode && (net.task == NNTASK_TRANSCRIPTION)) {\n\n    if (lasti != maxi) {\n      // TODO: output to file\n      // TODO: send smileMessage of a new type to be created...\n      if (classlabelArr != NULL) {\n        if (maxi < nClasses) printf(\"%s \",classlabelArr[maxi]);\n        if ((maxi > -1) &&(maxi < nClasses) && (outfileC != NULL)) {\n          fprintf(outfileC,\"%s\\n\",classlabelArr[maxi]);\n\t}\n      } else { // fallback to 39 phone TIMIT set, alphabetical order ...\n        switch(maxi){\n      case 0: printf(\"ae \"); break;\n      case 1: printf(\"ah \"); break;\n      case 2: printf(\"ao \"); break;\n      case 3: printf(\"aw \"); break;\n      case 4: printf(\"ay \"); break;\n      case 5: printf(\"b \"); break;\n      case 6: printf(\"ch \"); break;\n      case 7: printf(\"d \"); break;\n      case 8: printf(\"dh \"); break;\n      case 9: printf(\"dx \"); break;\n      case 10: printf(\"eh \"); break;\n      case 11: printf(\"el \"); break;\n      case 12: printf(\"en \"); break;\n      case 13: printf(\"er \"); break;\n      case 14: printf(\"ey \"); break;\n      case 15: printf(\"f \"); break;\n      case 16: printf(\"g \"); break;\n      case 17: printf(\"h \"); break;\n      case 18: printf(\"hh \"); break;\n      case 19: printf(\"ih \"); break;\n      case 20: printf(\"iy \"); break;\n      case 21: printf(\"jh \"); break;\n      case 22: printf(\"k \"); break;\n      case 23: printf(\"m \"); break;\n      case 24: printf(\"ng \"); break;\n      case 25: printf(\"ow \"); break;\n      case 26: printf(\"oy \"); break;\n      case  27: printf(\"p \"); break;\n      case  28: printf(\"r \"); break;\n      case  29: printf(\"s \"); break;\n      case  30: printf(\"sh \"); break;\n        //case  31: printf(\"sil \"); break;\n      case  32: printf(\"t \"); break;\n      case  33: printf(\"th \"); break;\n      case  34: printf(\"uh \"); break;\n      case  35: printf(\"uw \"); break;\n      case  36: printf(\"v \"); break;\n      case  37: printf(\"w \"); break;\n      case  38: printf(\"y \"); break;\n      case  39: printf(\"z \"); break;\n        }\n      }\n      fflush(stdout);\n      lasti = maxi;\n    }\n\n  } else if (net.task == NNTASK_TRANSCRIPTION || net.task == NNTASK_CLASSIFICATION) {\n    // output of winning class\n    if ((maxi > -1) &&(maxi < nClasses) && (outfileC != NULL)) {\n      fprintf(outfileC,\"%s\\n\",classlabelArr[maxi]);\n    }\n    // TODO: send classification result message!\n\n  }\n\n  // TODO: a cVectorProcessor RNN component...!\n  // TODO: rnn functions in extra hpp/cpp file for more reusability!\n\n  // tick success\n  return 1;\n}\n\n\ncRnnSink::~cRnnSink()\n{\n  if (outfile != NULL) { fclose(outfile); }\n  if (outfileC != NULL) { fclose(outfileC); }\n  if (in != NULL) free(in);\n  if (out != NULL) free(out);\n  if (rnn != NULL) delete rnn;\n  if (classlabels != NULL) free(classlabels);\n  if (classlabelArr != NULL) free(classlabelArr);\n}\n\n\n#endif // BUILD_RNN\n"
  },
  {
    "path": "src/rnn/rnnVad2.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nrnnVad\n\nAlthough this component is called rnnVad, it does not contain nor use an RNN.\nIt reads the RNN output activation, and applies some thresholds and logic to smooth it to a\nstable VAD decision. For the SEMAINE system it supports VAD supression, when\nthen agent is talking.\n\n*/\n\n\n\n#include <rnn/rnnVad2.hpp>\n\n#define MODULE \"cRnnVad2\"\n\n\nSMILECOMPONENT_STATICS(cRnnVad2)\n\nSMILECOMPONENT_REGCOMP(cRnnVad2)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_CRNNVAD2;\n  sdescription = COMPONENT_DESCRIPTION_CRNNVAD2;\n\n  // we inherit cVectorProcessor configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataProcessor\")\n\n  // if the inherited config type was found, we register our configuration variables\n  SMILECOMPONENT_IFNOTREGAGAIN( {} // <- this is only to avoid compiler warnings...\n    // name append has a special role: it is defined in cDataProcessor, and can be overwritten here:\n    //ct->setField(\"nameAppend\",NULL,\"processed\");\n  ct->setField(\"voiceIdx\",\"The index of the field which contains the 'voice' class output activation. (0 is the first field)\",0);\n  ct->setField(\"agentIdx\",\"The index of the field which contains the 'agent/alien' class output activation. (0 is the first field)\",1);\n    ct->setField(\"voiceThresh\",\"The threshold to apply to the 'voice' output activation.\",0.4);\n    ct->setField(\"agentThresh\",\"The threshold to apply to the 'agent' output activation.\",0.3);\n    ct->setField(\"energyIdx\",\"The index of the field which contains the energy/loudness/intensity/etc. value (set to -1 to disable)\",2);\n    ct->setField(\"f0Idx\",\"Index of F0 input field (set to -1 to disable)\",3);\n//    ct->setField(\"nPost\",\"Number of silence frames after speech before silence is detected.\",10);\n    // agent block by energy...\n    //ct->setField(\"agentBlockTime\",\"initial user speech time during which to block agent in frames (this must be high enough in order to have robust enough models)\",1000);\n    ct->setField(\"agentTurnPastBlock\",\"time the VAD will be blocked after receiving an agent speech end message (in frames, usually 100fps) (use 20 for the SEMAINE speech2speech system, and 60 for the speech2face system).\",20);\n  \tct->setField(\"alwaysRejectAgent\", \"1 = never detect a speaker turn while the agent is speaking\",0);\n    ct->setField(\"smartRejectAgent\", \"1 = apply different VAD strategy while agent is speaking\",1);\n\n    ct->setField(\"userEavgHold\",\"Hold time for user energy envelope and average computation (10ms frames as unit).\",500);  // 600\n    ct->setField(\"userEavgDecay\",\"Decay (linear) time for user energy envelope and average computation (10ms frames as unit).\",500);  // 300\n\n    ct->setField(\"agentEavgHold\",\"Hold time for user energy envelope and average computation (10ms frames as unit).\",200);\n    ct->setField(\"agentEavgDecay\",\"Decay (linear) time for user energy envelope and average computation (10ms frames as unit).\",200); // 100\n\n    ct->setField(\"vadDebug\",\"1 = output energy and VAD statistics for debugging (set to 2 to always force vad output value to 0 while debugging).\",0);\n    ct->setField(\"allowEoverride\",\"1 = allow VAD output even if LSTM does not detect voice when the energy is in the range of the user's current energy envelope (NOTE: this reduces noise robustness, e.g. when moving a headset etc.)\",1);\n\n    /*\nagent reject based on mean energy:\nlearning:\n  mean energy of user & agent\nproductive:\n  user speech turn only detected when energy >> mean agent energy ??\n*/\n  )\n\n  // The configType gets automatically registered with the config manger by the SMILECOMPONENT_IFNOTREGAGAIN macro\n  \n  // we now create out sComponentInfo, including name, description, success status, etc. and return that\n  SMILECOMPONENT_MAKEINFO(cRnnVad2);\n}\n\nSMILECOMPONENT_CREATE(cRnnVad2)\n\n\n//-----\n\n\ncRnnVad2::cRnnVad2(const char *_name) :\n  cDataProcessor(_name), voiceThresh(0.0), frameO(NULL),\n  doReset(0), agentTurn(0), userPresence(0), agentTurnCntdn(0),\n  eUser(NULL), eCurrent(NULL), eAgent(NULL), eBg(NULL), cnt(0)\n{\n\n}\n\nvoid cRnnVad2::fetchConfig()\n{\n  cDataProcessor::fetchConfig();\n \n  voiceIdx = getInt(\"voiceIdx\");\n  SMILE_IDBG(2,\"voiceIdx = %i\",voiceIdx);\n\n  agentIdx = getInt(\"agentIdx\");\n  SMILE_IDBG(2,\"agentIdx = %i\",agentIdx);\n\n  energyIdx = getInt(\"energyIdx\");\n  SMILE_IDBG(2,\"energyIdx = %i\",energyIdx);\n\n  f0Idx = getInt(\"f0Idx\");\n  SMILE_IDBG(2,\"f0Idx = %i\",f0Idx);\n\n//  nPost = getInt(\"nPost\");\n\n  voiceThresh = (FLOAT_DMEM)getDouble(\"voiceThresh\");\n  agentThresh = (FLOAT_DMEM)getDouble(\"agentThresh\");\n\n  //agentBlockTime = getInt(\"agentBlockTime\");\n  agentTurnPastBlock = getInt(\"agentTurnPastBlock\");\n  smartRejectAgent = getInt(\"smartRejectAgent\");\n  alwaysRejectAgent = getInt(\"alwaysRejectAgent\");\n\n  allowEoverride = getInt(\"allowEoverride\");\n  vadDebug = getInt(\"vadDebug\");\n\n  int userEavgHold = getInt(\"userEavgHold\");\n  int userEavgDecay = getInt(\"userEavgDecay\");\n  int agentEavgHold = getInt(\"agentEavgHold\");\n  int agentEavgDecay = getInt(\"agentEavgDecay\");\n\n  \n\n  eCurrent = new cEavgHold(20, 10); /* short-term envelope and average */\n  eUser = new cEavgHold(userEavgHold, userEavgDecay); /* user energy level, long term */\n  eAgent = new cEavgHold(agentEavgHold, agentEavgDecay); /* user energy level, long term */\n  eBg = new cEavgHold(1000, 1000);\n}\n\n\n\nint cRnnVad2::setupNewNames(long nEl)\n{\n  writer_->addField(\"voiceAct\");\n\tnamesAreSet_=1;\n  return 1;\n}\n\n\n\nint cRnnVad2::myFinaliseInstance()\n{\n  int ret = cDataProcessor::myFinaliseInstance();\n\n  if (ret) {\n    frameO = new cVector(1);\n  }\n\n  return ret;\n}\n\n\nint cRnnVad2::processComponentMessage( cComponentMessage *_msg )\n{\n\tif (isMessageType(_msg,\"semaineCallback\")) {\n\t\t// determine origin by message's user-defined name, which can be set in the config file\n\t\tSMILE_IDBG(3,\"received 'semaineCallback' message '%s'\",_msg->msgname);\n    if (!strncmp(_msg->msgname,\"start\",5)) { agentTurn = 1; agentTurnCntdn = 0; }\n    else if (!strncmp(_msg->msgname,\"end\",3)) {\n      agentTurn = 0; agentTurnCntdn = agentTurnPastBlock;\n    }\n    else if (!strncmp(_msg->msgname,\"present\",7)) { if (userPresence != 1) { userPresence = 1; doReset=1; } }\n    else if (!strncmp(_msg->msgname,\"absent\",6)) { if (userPresence != 0) { userPresence = 0; doReset=1; } }\n\t\treturn 1;  // message was processed\n\t}\n\n\treturn 0; // if message was not processed\n}\n\n\n// a derived class should override this method, in order to implement the actual processing\nint cRnnVad2::myTick(long long t)\n{\n  cVector * frame = reader_->getNextFrame();\n  if (frame == NULL) return 0;\n\n  cnt++;\n\n  int vad = 0;\n  FLOAT_DMEM E = 0.0;\n  FLOAT_DMEM vact = frame->dataF[voiceIdx];\n  FLOAT_DMEM aact = 0.0;\n  \n  if (agentIdx >= 0) aact = frame->dataF[agentIdx];\n\n  /* get frame energy */\n  if (energyIdx >= 0) {\n    E = frame->dataF[energyIdx];\n    eCurrent->nextE(E); \n  }\n\n  /*\n    get the \"agent's talking state\" ..\n  */\n  int _agentTurn = 0;\n  int noV = 0;\n  lockMessageMemory();\n  if (doReset == 1) {\n\n    doReset=0;\n  }\n  _agentTurn = agentTurn;\n  if ((agentTurn)||(agentTurnCntdn>0)) {\n    if (smartRejectAgent || alwaysRejectAgent) { noV = 1; }\n    //if (cnt < agentBlockTime) { noV=1; }\n  }\n  if (agentTurnCntdn > 0) agentTurnCntdn--;\n  unlockMessageMemory();\n\n\n  /* case A: we know it's the agent's turn, and we apply a different strategy for getting the user's voice */\n  if (noV) {\n    if (energyIdx >= 0 && !alwaysRejectAgent) {\n\n      if (vact > voiceThresh) {\n        /* energy based user voice detection with a high threshold */\n        /*if (eCurrent->getEnv() > eUser->getAvg()*1.2 && eCurrent->getEnv() > eAgent->getEnv()*0.9 && aact < agentThresh && eUser->getAvg() > 0.0) {\n          vad = 8;\n        } else */\n          if (eCurrent->getEnv() > eUser->getEnv()*0.9 && eCurrent->getEnv() > eAgent->getEnv()*0.9 && aact < agentThresh-0.1 && eUser->getEnv() > 0.0 && eAgent->getEnv() > 0.0) {\n          vad = 9;\n        } else if (eCurrent->getEnv() > eAgent->getEnv()*1.1 && aact < agentThresh+0.1 && eAgent->getEnv() > 0.0) {\n          vad = 10;\n        }\n      }\n\n      /* update agent energy stats */\n      if (vact > voiceThresh && aact > 0.1 && vad == 0 && eCurrent->getEnv() < eUser->getEnv()*0.9) {\n        eAgent->nextE(E);\n      }\n\n    }\n  } else {\n\n  /* case B: no agent turn, we look for user voice primarily */\n  if (vact > voiceThresh) {\n    if (energyIdx >= 0) {\n      if (aact <= agentThresh+0.05 && eCurrent->getEnv() > eBg->getAvg()*1.1 && eBg->getAvg() > 0.0) { /* if no agent voice is detected, update user energy stats */\n        eUser->nextE(E);\n      } /*else {\n        //eAgent->nextE(E);\n      }*/\n      if ((eCurrent->getEnv() > eUser->getEnv()*0.75 || vact > 0.95 || eUser->getEnv() == 0.0 || eCurrent->getEnv() == 0.0) && aact < agentThresh) { /* Energy verification, low threshold */\n        vad = 1;\n      } else {\n        /* energy based user voice detection with a high threshold */\n        if (eCurrent->getEnv() > eUser->getEnv()*0.9 && eUser->getEnv() > 0.0) {\n          vad = 3;\n        } /* else if (eCurrent->getEnv() > eUser->getEnv()*0.6 && eUser->getEnv() > 0.0) {\n          vad = 4;\n        }*/\n      }\n    } else {\n      vad = 5;\n    }\n  } else {\n    if (energyIdx >= 0) {\n      /* energy based user voice detection with a high threshold */\n      if (eCurrent->getEnv() > eUser->getEnv()*0.8  && vact > 0.3 && eUser->getEnv() > 0.0) {\n        vad = 6; /* higher thresh */\n      } else if (eCurrent->getEnv() > eUser->getEnv()*0.9 && eCurrent->getEnv() < eUser->getEnv()*1.1 && eUser->getEnv() > 0.0 && vact > 0.1) {\n        vad = 7;\n      } else {\n        /* update background energy model */\n        eBg->nextE(E);\n      }\n    }\n  }\n\n  }\n\n  if (vadDebug) {\n    printf(\"noV=%i vact=%.3f aact=%.3f eU=%.3f eCur=%.3f eBg=%.3f eAg=%.3f v=%i\\n\",noV,vact,aact,eUser->getEnv(),eCurrent->getEnv(),eBg->getEnv(),eAgent->getEnv(),vad);\n  }\n\n  /*\n    generate output frame with voicing info\n  */\n  if (cnt < 100) vad=0; /* block vad output at the beginning, it may confuse the turnDetector otherwise */\n  if (vad > 0) vad = 1; /* map the internal VAD states to binary 0/1 */\n  \n  if (vadDebug==2) { vad=0; } /* Disable VAD output for debugging ONLY vad functionality without other interfering components */\n\n  frameO->dataF[0] = (FLOAT_DMEM)(vad);\n  writer_->setNextFrame(frameO);\n\n  return 1;\n}\n\ncRnnVad2::~cRnnVad2()\n{\n  if (frameO != NULL) delete frameO;\n  if (eCurrent != NULL) delete eCurrent;\n  if (eUser != NULL) delete eUser;\n  if (eAgent != NULL) delete eAgent;\n  if (eBg != NULL) delete eBg;\n}\n\n"
  },
  {
    "path": "src/smileutil/smileUtil.c",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n/*\n\nSmile Util:\n\n* modular DSP functions\n* math functions\n* sort algoritms\n* wave file I/O functions\n* vector file I/O functions (for dumping debug data)\n\n... and other utility functions \n\n*/\n//------ remove this include if you are using smileUtil as standalone code...\n//#include <exceptions.hpp>\n//--------------------\n\n#include <smileutil/smileUtil.h>\n#include <string.h>\n\n//#include <smileTypes.hpp>\n\n\n/*******************************************************************************************\n ***********************=====   Misc functions   ===== **************************************\n *******************************************************************************************/\n\nint smileUtil_stripline(char ** _line)\n{\n  char * line;\n  int len;\n\n  if (_line != NULL) line = *_line;\n  else return 0;\n\n  len=(int)strlen(line);\n  // strip newline characters at end of line\n  if (len>0) { if (line[len-1] == '\\n') { line[len-1] = 0; len--; } }\n  if (len>0) { if (line[len-1] == '\\r') { line[len-1] = 0; len--; } }\n  // strip whitespaces at beginning and end of line\n  while (((line[0] == ' ')||(line[0] == '\\t'))&&(len>=0)) { line[0] = 0; line++; len--; }\n  while ((len>=0)&&((line[len-1] == ' ')||(line[len-1] == '\\t'))) { line[len-1] = 0; len--; }\n  \n  *_line = line; // <- this is a new pointer, so caller must save old pointer for a call to free!!\n  return len; \n}\n\n\n/*******************************************************************************************\n ***********************=====   Sort functions   ===== **************************************\n *******************************************************************************************/\n\n/** inplace quicksort algorithms **/\n\n/* QuickSort algorithm for a float array with nEl elements */\nvoid smileUtil_quickSort_float(float *arr, long nEl)\n{\n  #ifdef MAX_LEVELS\n  #undef MAX_LEVELS\n  #endif\n  #define  MAX_LEVELS  300\n\n  float piv;\n  long beg[MAX_LEVELS], end[MAX_LEVELS],swap;\n  long i=0, L, R;\n\n  beg[0]=0; end[0]=nEl;\n  while (i>=0) {\n    L=beg[i]; R=end[i]-1;\n    if (L<R) {\n      piv=arr[L]; \n      while (L<R) {\n        while (arr[R]>=piv && L<R) R--; if (L<R) arr[L++]=arr[R];\n        while (arr[L]<=piv && L<R) L++; if (L<R) arr[R--]=arr[L]; }\n      arr[L]=piv; beg[i+1]=L+1; end[i+1]=end[i]; end[i++]=L;\n      if (end[i]-beg[i]>end[i-1]-beg[i-1]) {\n        swap=beg[i]; beg[i]=beg[i-1]; beg[i-1]=swap;\n        swap=end[i]; end[i]=end[i-1]; end[i-1]=swap;\n      }\n    } else { i--; }\n  }\n}\n\n/* QuickSort algorithm for a double array with nEl elements */\nvoid smileUtil_quickSort_double(double *arr, long nEl)\n{\n  #ifndef MAX_LEVELS\n  #define MAX_LEVELS  300\n  #endif\n\n  double piv;\n  long beg[MAX_LEVELS], end[MAX_LEVELS],swap;\n  long i=0, L, R;\n  \n  beg[0]=0; end[0]=nEl;\n  while (i>=0) {\n    L=beg[i]; R=end[i]-1;\n    if (L<R) {\n      piv=arr[L];\n      while (L<R) {\n        while (arr[R]>=piv && L<R) R--; if (L<R) arr[L++]=arr[R];\n        while (arr[L]<=piv && L<R) L++; if (L<R) arr[R--]=arr[L]; }\n      arr[L]=piv; beg[i+1]=L+1; end[i+1]=end[i]; end[i++]=L;\n      if (end[i]-beg[i]>end[i-1]-beg[i-1]) {\n        swap=beg[i]; beg[i]=beg[i-1]; beg[i-1]=swap;\n        swap=end[i]; end[i]=end[i-1]; end[i-1]=swap;\n      }\n    } else { i--; }\n  }\n}\n\n/* QuickSort algorithm for a FLOAT_DMEM array with nEl elements */\nvoid smileUtil_quickSort_FLOATDMEM(FLOAT_DMEM *arr, long nEl)\n{\n  #ifndef MAX_LEVELS\n  #define MAX_LEVELS  300\n  #endif\n\n  FLOAT_DMEM piv;\n  long beg[MAX_LEVELS], end[MAX_LEVELS],swap;\n  long i=0, L, R;\n  \n  beg[0]=0; end[0]=nEl;\n  while (i>=0) {\n    L=beg[i]; R=end[i]-1;\n    if (L<R) {\n      piv=arr[L];\n      while (L<R) {\n        while (arr[R]>=piv && L<R) R--; if (L<R) arr[L++]=arr[R];\n        while (arr[L]<=piv && L<R) L++; if (L<R) arr[R--]=arr[L]; }\n      arr[L]=piv; beg[i+1]=L+1; end[i+1]=end[i]; end[i++]=L;\n      if (end[i]-beg[i]>end[i-1]-beg[i-1]) {\n        swap=beg[i]; beg[i]=beg[i-1]; beg[i-1]=swap;\n        swap=end[i]; end[i]=end[i-1]; end[i-1]=swap;\n      }\n    } else { i--; }\n  }\n}\n\n/* Reverse the order in an array of elements, i.e. swap first and last element, etc. */\nvoid smileUtil_reverseOrder_FLOATDMEM(FLOAT_DMEM *arr, long nEl)\n{\n  long i; int range;\n  FLOAT_DMEM tmp;\n  if (nEl % 2 == 0) {\n    range = nEl>>1;\n  } else {\n    range = (nEl-1)>>1;\n  }\n  for (i=0; i<nEl>>1; i++) {\n    tmp = arr[i];\n    arr[i] = arr[nEl-i-1];\n    arr[nEl-i-1] = tmp;\n  }\n}\n\n\n/*******************************************************************************************\n ***********************=====   Filter functions   ===== **************************************\n *******************************************************************************************/\n\n\n\n/* allocate workspace (history matrix) for a temporal median filter */\nFLOAT_DMEM * smileUtil_temporalMedianFilterInit(long N, long T)\n{\n  FLOAT_DMEM *ws = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*(N*(T+1)+2+T));\n  // NOTE: first two floats of workspace are N and T\n  if (ws != NULL) {\n    ws[0] = (FLOAT_DMEM)N;\n    ws[1] = (FLOAT_DMEM)T;\n  }\n  return ws;\n}\n\n\n\n/* allocate workspace (history matrix) for a temporal median filter */\nFLOAT_DMEM * smileUtil_temporalMedianFilterInitSl(long N, long Ns, long T)\n{\n  FLOAT_DMEM *ws = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*(N*(Ns+1)*(T+1)+2+2*T));\n  // NOTE: first two floats of workspace are N and T\n  if (ws != NULL) {\n    ws[0] = (FLOAT_DMEM)(N*(Ns+1));\n    ws[1] = (FLOAT_DMEM)T;\n  }\n  return ws;\n}\n\n/* free the temporal median filter workspace and return NULL */\nFLOAT_DMEM * smileUtil_temporalMedianFilterFree(FLOAT_DMEM *workspace)\n{\n  if (workspace != NULL) free(workspace);\n  return NULL;\n}\n\n/*\n  Perform median filter of each element in frame x (over time) using a history matrix given in *workspace\n  The workspace must be created with smileUtil_temporalMedianFilterInit.\n  workspace : ptr el0 el0 el0(t-1)... el0(t) ; ptr el1 el1 el1(t-1) ... el1(t)\n*/\nvoid smileUtil_temporalMedianFilter(FLOAT_DMEM *x, long N, FLOAT_DMEM *workspace)\n{\n  long i;\n  long _N;\n  long Nw;\n  long T, T1;\n  FLOAT_DMEM *ws;\n\n  if (workspace == NULL) return;\n  if (N<=0) return;\n  \n  \n  // check for matching N and find minimal _N we will work with\n  Nw = (long)workspace[0];\n  if (Nw > N) _N = N;\n  else _N = Nw;\n  T = (long)workspace[1];\n  T1 = T+1;\n\n  ws = workspace + Nw*(T+1)+2;\n\n  for (i=0; i<_N; i++) { // apply median filter to each element 0.._N-1\n    long ws0 = i*T1+2;\n\n    // add new element to history\n    long ptr = (long)(workspace[ws0])+1;\n    workspace[ws0+(ptr++)] = x[i];\n    if (ptr > T) ptr = 1;\n    workspace[ws0] = (FLOAT_DMEM)(ptr-1);\n\n    // compute median and save in vector x\n    x[i] = smileMath_median(&(workspace[ws0+1]), T, ws);\n  }\n}\n\n/*\n  Perform median filter of each element in frame x (over time) using a history matrix given in *workspace\n  The workspace must be created with smileUtil_temporalMedianFilterInit.\n  workspace : ptr el0 el0 el0(t-1)... el0(t) ; ptr el1 el1 el1(t-1) ... el1(t)\n  **> Filter with slave data (Ns is number of slave elements for each element in x (total size of x thus is N*Ns))\n      The workspace must be allocated for N*(Ns+1) elements!\n*/\nvoid smileUtil_temporalMedianFilterWslave(FLOAT_DMEM *x, long N, long Ns, FLOAT_DMEM *workspace)\n{\n  long i,j;\n  long _N;\n  long Nw;\n  long T, T1;\n  FLOAT_DMEM *ws;\n\n  if (workspace == NULL) return;\n  if (N<=0) return;\n  \n  \n  // check for matching N and find minimal _N we will work with\n  Nw = (long)workspace[0];\n  if (Nw > N) _N = N;\n  else _N = Nw;\n  T = (long)workspace[1];\n  T1 = T+1;\n\n  ws = workspace + Nw*(T+1)+2;\n\n  for (i=0; i<_N; i++) { // apply median filter to each element 0.._N-1\n    long ws0 = i*T1+2;\n\n    // add new element to history\n    long ptr = (long)(workspace[ws0])+1;\n    workspace[ws0+(ptr++)] = x[i];\n    if (ptr > T) ptr = 1;\n    workspace[ws0] = (FLOAT_DMEM)(ptr-1);\n\n    // add slave elements to history\n    if (Nw >= N*(Ns+1)) {\n      for (j=1; j<=Ns; j++) {\n        long ws0 = (i+j*Nw/(Ns+1))*T1+2;\n        long ptr = (long)(workspace[ws0])+1;\n        workspace[ws0+(ptr++)] = x[i+j*N];\n        if (ptr > T) ptr = 1;\n        workspace[ws0] = (FLOAT_DMEM)(ptr-1);\n      }\n    }\n\n    // compute median and save in vector x\n    x[i] = smileMath_medianOrdered(&(workspace[ws0+1]), T, ws);\n\n    // use indicies in ws to sort slave data (if workspace is large enough)\n    if (Nw >= N*Ns) {\n      for (j=1; j<=Ns; j++) {\n        if (T&1) { // odd\n          long ws0 = (i+j*Nw/(Ns+1))*T1+2;\n          long ptr = (long)(workspace[ws0]+(FLOAT_DMEM)1.0-ws[0]);\n          if (ptr < 1) ptr += T;\n          x[i+j*N] = workspace[ws0+ptr]; \n        } else { // even\n          long ws0 = (i+j*Nw/(Ns+1))*T1+2;\n          long ptr0 = (long)(workspace[ws0]+(FLOAT_DMEM)1.0-ws[0]);\n          long ptr1 = (long)(workspace[ws0]+(FLOAT_DMEM)1.0-ws[1]);\n          if (ptr0 < 1) ptr0 += T;\n          if (ptr1 < 1) ptr1 += T;\n          x[i+j*N] = (FLOAT_DMEM)0.5 * (workspace[ws0+ptr0] + workspace[ws0+ptr1]);\n        }\n      }\n    }\n  }\n}\n\n/*******************************************************************************************\n ***********************=====   FIR filters   ===== ****************************************\n *******************************************************************************************/\n\n// FIR impulse responses are clipped to a finite length N\n// This function fades out the impulse response linearly in the\n// left and right border regions (10% of the full length at each side)\n// NOTE: the fadeout function breaks normalisation!\nvoid smileDsp_impulse_response_linearFadeout(sSmileDspImpulseResponse *ir) {\n  if (ir != NULL) {\n    int N = ir->N / 10;\n    int i;\n    for (i = 0; i < N; i++) {\n      ir->h[i] *= ((float)i/(float)N);\n      ir->h[N - 1 - i] *= ((float)i/(float)N);\n    }\n  }\n}\n\n// FIR impulse responses are clipped to a finite length N\n// This function fades out the impulse response linearly in the\n// left and right border regions (10% of the full length at each side)\n// NOTE: the fadeout function breaks normalisation!\n// Use normalise = true to normalise the output.\nvoid smileDsp_impulse_response_gaussFadeout(sSmileDspImpulseResponse *ir,\n    //float sigma=0.5, bool normalise=false) {\n    float sigma, bool normalise) {\n  if (sigma < 0.000001) {\n    sigma = 0.000001;\n  }\n  if (ir != NULL) {\n    float Nf = (float)ir->N;\n    float Nf2 = Nf/2.0;\n    float sigmaNf2 = sigma * Nf2;\n    FLOAT_DMEM *h = ir->h;\n    float mine = (-Nf2 + 1.0)/sigmaNf2;\n    float ming = exp(-0.5 * mine * mine);\n    float scale = 1.0/(1.0 - ming);\n    float sum = 0.0;\n    float n;\n    for (n = -Nf2 + 1.0; n < Nf2; n += 1.0) {\n      float e = n/(sigmaNf2);\n      float g = scale * (exp( -0.5 * e * e) - ming);\n      *h = *h * g;\n      if (normalise) {\n        sum += *h;\n      }\n      h++;\n    }\n    if (normalise) {\n      int i;\n      for (i = 0; i < ir->N; i++) {\n        ir->h[i] /= sum;\n      }\n    }\n  }\n}\n\n// Initialises an impulse response structure for N taps\nsSmileDspImpulseResponse *smileDsp_impulse_response_init(int N, \n    sSmileDspImpulseResponse *s) {\n  if (N <= 0) {\n    return NULL;\n  }\n  if (s == NULL) {\n    s = (sSmileDspImpulseResponse *)\n          calloc(1, sizeof(sSmileDspImpulseResponse));\n  } else {\n    if (s->h != NULL) {\n      free(s->h);\n    }\n  }\n  s->offset = 0;\n  s->N = N;\n  s->h = (FLOAT_DMEM *)calloc(1, sizeof(FLOAT_DMEM) * N);\n  return s;\n}\n\n// Normalises an impulse response, so that the convolution of a signal\n// with the impulse response has the same gain/amplitude as the input signal\nvoid smileDsp_normalise_impulse_response(sSmileDspImpulseResponse *ir) {\n  float sum = 0.0;\n  int i;\n  for (i = 0; i < ir->N; i++) {\n    sum += fabs(ir->h[i]);\n  }\n  for (i = 0; i < ir->N; i++) {\n    ir->h[i] /= sum;\n  }\n}\n\n// Sinc impulse response for a low-pass filter\n// with Gaussian fadeout (fixed sigma 0.5) (if fadeout = true ; preferred!)\n// If highpass is set to true, the filter is \"inverted\"\n// in the frequency domain, i.e. it becomes a high-pass filter.\nvoid smileDsp_sincGauss_impulse_response(sSmileDspImpulseResponse *ir,\n    float cutoffHz, float Ts, float sigma, bool highpass, \n    bool fadeout) {\n  // float sigma=0.5, bool highpass=false,     bool fadeout=true\n  if (cutoffHz < 1.0) {\n    cutoffHz = 1.0;\n  }\n  if (ir != NULL) {\n    float a = 2.0 * cutoffHz;\n    float b = a * M_PI * Ts;\n    float Nf = (float)ir->N;\n    float Nf2 = Nf/2.0;\n    FLOAT_DMEM *h = ir->h;\n    float n;\n    ir->offset = ir->N/2;\n    for (n = -Nf2 + 1.0; n < Nf2; n += 1.0) {\n      if (n != 0.0) {\n        float x = b * n;\n        *(h++) = (FLOAT_DMEM)(a * sin(x) / x);\n      } else {\n        *(h++) = (FLOAT_DMEM)(1.0);\n      }\n    }\n    if (fadeout) {\n      smileDsp_impulse_response_gaussFadeout(ir, sigma, true);\n    } else {\n      smileDsp_normalise_impulse_response(ir);\n    }\n    if (highpass) {\n      // transformation of low-pass IR to highpass IR:\n      float n;\n      h = ir->h;\n      for (n = -Nf2 + 1.0; n < Nf2; n += 1.0) {\n        *h = -(*h);\n        if (n == 0.0) {\n          *h += 1.0;\n        }\n        h++;\n      }\n    }\n  }\n}\n\n// Creates a gammatone bandpass impulse response of length ir->N\n// with center frequency fc and bandwidth bw for a sampling period of Ts\n// set N in ir before calling this function!\nvoid smileDsp_gammatone_impulse_response(sSmileDspImpulseResponse *ir,\n    float fc, float bw, float Ts, float a, int order, bool fadeout) {\n    //float a = 1.0, int order = 1, bool fadeout=true\n  if (ir != NULL) {\n    int n;\n    for (n = 0; n < ir->N; n++) {\n      ir->h[n] = a * Ts * pow((float)n, (float)(order - 1))\n        * exp(-2.0 * M_PI * bw * n * Ts) * cos(2.0 * M_PI * fc * n * Ts);\n    }\n    if (fadeout) {\n      smileDsp_impulse_response_gaussFadeout(ir, 0.5, true);\n    } else {\n      smileDsp_normalise_impulse_response(ir);\n    }\n  }\n}\n\n// Creates a gabor bandpass impulse response of length ir->N\n// with center frequency fc and bandwidth bw for a sampling period of Ts\n// set N in ir before calling this function!\nvoid smileDsp_gabor_impulse_response(sSmileDspImpulseResponse *ir, float fc, \n    float bw, float Ts, bool fadeout) {\n  if (ir != NULL) {\n    float b2 = bw * sqrt(2.0 * M_PI) * Ts;\n    float c = 2.0 * M_PI * fc * Ts;\n    float Nf = (float)ir->N;\n    FLOAT_DMEM *h = ir->h;\n    float n;\n    b2 = - b2 * b2;\n    for (n = -Nf/2.0 + 1.0; n < Nf/2.0; n += 1.0) {\n      *(h++) = exp(b2 * n * n) * cos(c * n);\n    }\n    ir->offset = ir->N/2;\n    if (fadeout) {\n      smileDsp_impulse_response_gaussFadeout(ir, 0.5, true);\n    } else {\n      smileDsp_normalise_impulse_response(ir);\n    }\n  }\n}\n\n// Initializes a block convolver work area\nsSmileDspConvolverState *smileDsp_block_convolve_init(int blocksize, sSmileDspImpulseResponse *ir,\n    sSmileDspConvolverState *s) {\n  if (s == NULL) {\n    s = (sSmileDspConvolverState *)calloc(1, sizeof(sSmileDspConvolverState));\n  } else {\n    if (s->x_buf != NULL) {\n      free(s->x_buf);\n    }\n  }\n  s->blocksize = blocksize;\n  s->bufsize = ir->N;\n  s->ir.offset = ir->offset;\n  s->ir.N = ir->N;\n  s->ir.h = ir->h;\n  s->x_buf_ptr = 0;\n  s->x_buf = (FLOAT_DMEM*)calloc(1, sizeof(FLOAT_DMEM) * s->bufsize);\n  return s;\n}\n\n// Frees a block convolver work area\nvoid smileDsp_block_convolve_destroy(sSmileDspConvolverState * s,\n    bool noFreeIr, bool noFreePtr) {\n  if (s != NULL) {\n    if (!noFreeIr && s->ir.h != NULL) {\n      free(s->ir.h);\n    }\n    if (s->x_buf != NULL) {\n      free(s->x_buf);\n    }\n    if (!noFreePtr) {\n      free(s);\n    }\n  }\n}\n\n// Performs a discrete convolution on a block of N input samples in *x.\n// The output will be saved in *y.\n// Using a larger blocksize will reduce the overhead in\n//   a) calling this function\n//   b) rotating the buffer of past samples\n// N must be >= s->blocksize\n// outputStep: the distance (in samples between two output samples (for matrix output))\n// outputOffset: the index of the first output\nvoid smileDsp_block_convolve(sSmileDspConvolverState *s, FLOAT_DMEM *x,\n    FLOAT_DMEM *y, int N, int outputStep, int outputOffset) {\n  int i;\n  int n_to_copy;\n  if (N < s->blocksize) {\n    // error! or adapt blocksize, etc.?\n    return;\n  }\n  y += outputOffset;\n  // the actual convolution loop\n  for (i = 0; i < N; i++) {\n    FLOAT_DMEM *h = s->ir.h;\n    int i_pt = s->x_buf_ptr + i + s->bufsize;\n    int j;\n    *y = 0.0;\n    for (j = 0; j < s->ir.N; j++) {\n      if (i >= j) {  // use signal\n        *y += *h * x[i - j];\n      } else {  // use past buffer\n        *y += *h * s->x_buf[(i_pt - j) % s->bufsize];\n      }\n      h++;\n    }\n    y += outputStep;\n  }\n  // update past buffer\n  if (s->bufsize < N) {\n    n_to_copy = s->bufsize;\n  } else {\n    n_to_copy = N;\n  }\n  x += N - n_to_copy;\n  for (i = 0; i < n_to_copy; i++) {\n    s->x_buf[s->x_buf_ptr] = x[i];\n    s->x_buf_ptr++;\n    s->x_buf_ptr %= s->bufsize;\n  }\n}\n\n\n/*******************************************************************************************\n ***********************=====   Math functions   ===== **************************************\n *******************************************************************************************/\n\nstatic FLOAT_DMEM expLimDmem = 0.0;\n\nFLOAT_DMEM smileMath_logistic(FLOAT_DMEM x)\n{\n  if (expLimDmem == 0.0)\n    expLimDmem = log(FLOAT_DMEM_MAX);\n  if (x > expLimDmem) { return 1.0; }\n  else if (x < -expLimDmem) { return 0.0; }\n  return 1.0 / (1.0 + exp(-x));\n}\n\nFLOAT_DMEM smileMath_tanh(FLOAT_DMEM x) {\n  return (FLOAT_DMEM)2.0 * smileMath_logistic((FLOAT_DMEM)2.0 * x) - (FLOAT_DMEM)1.0;\n}\n\n// linear up to +- limit1, then sigmoid converging at +-limit2\nFLOAT_DMEM smileMath_ratioLimit(FLOAT_DMEM x,\n    FLOAT_DMEM limit1, FLOAT_DMEM excessToLimit2) {\n  if (x > limit1) {\n    FLOAT_DMEM y = smileMath_tanh((sqrt(x - limit1 + 1.0) - 1.0) / (excessToLimit2 * 0.5)) * excessToLimit2 + limit1;\n    return y;\n  } else if (x < -limit1) {\n    FLOAT_DMEM y = smileMath_tanh(-(sqrt(-1.0*(x + limit1) + 1.0) - 1.0) / (excessToLimit2 * 0.5)) * excessToLimit2 - limit1;\n    return y;\n  }\n  // linear in [-limit1 ; 0; limit1]\n  return x;\n}\n\n/*\n  median of vector x\n  (workspace can be a pointer to an array of N FLOAT_DMEMs which is used to sort the data in x without changing x)\n  (if workspace is NULL , the function will allocate and free the workspace internally)\n*/\nFLOAT_DMEM smileMath_median(const FLOAT_DMEM *x, long N, FLOAT_DMEM *workspace)\n{\n  long i;\n  FLOAT_DMEM median=0.0;\n  FLOAT_DMEM *tmp = workspace;\n  if (tmp == NULL) tmp = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*N);\n  if (tmp==NULL) return 0.0;\n  for (i=0; i<N; i++) { tmp[i] = x[i]; }\n  //memcpy(tmp, x, sizeof(FLOAT_DMEM)*N);\n  \n  smileUtil_quickSort_FLOATDMEM(tmp,N);\n  if (N&1) { // easy median for odd N\n    median = tmp[N>>1];\n  } else { // median as mean of the two middle elements for even N\n    median = (FLOAT_DMEM)0.5 * (tmp[N/2]+tmp[N/2-1]);\n  }\n  if (workspace == NULL) free(tmp);\n  return median;\n}\n\n/*\n  median of vector x\n  (workspace can be a pointer to an array of 2*N (!) FLOAT_DMEMs which is used to sort the data in x without changing x)\n  (if workspace is NULL , the function will allocate and free the workspace internally)\n  THIS function should return the original vector index of the median in workspace[0] (and workspace[1] if N is even), to use this functionality you must provide a workspace pointer!\n*/\nFLOAT_DMEM smileMath_medianOrdered(const FLOAT_DMEM *x, long N, FLOAT_DMEM *workspace)\n{\n  long i,j;\n  long oi0=0, oi1=0;\n  FLOAT_DMEM median=0.0;\n  FLOAT_DMEM *tmp = workspace;\n  if (tmp == NULL) tmp = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*2*N);\n  if (tmp==NULL) return 0.0;\n\n  \n  for (i=0; i<N; i++) { tmp[i] = x[i]; }\n  //memcpy(tmp, x, sizeof(FLOAT_DMEM)*N);\n\n  for (i=0; i<N; i++) {\n    tmp[N+i] = (FLOAT_DMEM)i;\n  }\n  \n  // we cannot use quicksort, since it doesn't preserve the original indexing\n  //smileUtil_quickSort_FLOATDMEM(tmp,N);\n  for (i=0; i<N; i++) {\n    for (j=i+1; j<N; j++) {\n      if (tmp[i] > tmp[j]) { //swap data and indicies\n        FLOAT_DMEM t = tmp[i]; // swap data\n        tmp[i] = tmp[j];\n        tmp[j] = t;\n        t = tmp[i+N]; // swap indicies\n        tmp[i+N] = tmp[j+N];\n        tmp[j+N] = t;\n      }\n    }\n  }\n\n  if (N&1) { // easy median for odd N\n    median = tmp[N>>1];\n    tmp[0] = tmp[N+(N>>1)];\n  } else { // median as mean of the two middle elements for even N\n    median = (FLOAT_DMEM)0.5 * (tmp[N>>1]+tmp[(N>>1)-1]);\n    tmp[0] = tmp[N+(N>>1)-1];\n    tmp[1] = tmp[N+(N>>1)];\n  }\n  if (workspace == NULL) free(tmp);\n  return median;\n}\n\n/* check if number is power of 2 (positive or negative) */\nlong smileMath_isPowerOf2(long x)\n{\n  if (x==1) return 1;  // 1 is a power of 2\n  if (((x&1) == 0)&&(x != 0)) { // only even numbers > 1\n    x=x>>1;\n    while ((x&1) == 0) { x=x>>1;  }\n    return ((x==1)||(x==-1));\n  }\n  return 0;\n}\n\n/* round to nearest power of two */\nlong smileMath_roundToNextPowOf2(long x)\n{\n  // round x up to nearest power of 2\n  unsigned long int flng = (unsigned long int)x;\n  unsigned long int fmask = 0x8000;\n  while ( (fmask & flng) == 0) { fmask = fmask >> 1; }\n  // fmask now contains the MSB position\n  if (fmask > 1) {\n    if ( (fmask>>1)&flng ) { flng = fmask<<1; }\n    else { flng = fmask; }\n  } else {\n    flng = 2;\n  }\n\n  return (long)flng;\n}\n\ndouble smileMath_log2(double x)\n{\n  return log(x)/log(2.0);\n}\n\n/* round up to next power of 2 */\nlong smileMath_ceilToNextPowOf2(long x)\n{\n  long y = smileMath_roundToNextPowOf2(x);\n  if (y<x) y *= 2;\n  return y;\n}\n\n/* round down to next power of two */\nlong smileMath_floorToNextPowOf2(long x)\n{\n  long y = smileMath_roundToNextPowOf2(x);\n  if (y>x) y /= 2;\n  return y;\n}\n\nFLOAT_DMEM smileMath_crossCorrelation(const FLOAT_DMEM * x, long Nx, const FLOAT_DMEM * y, long Ny)\n{\n  long N = MIN(Nx,Ny);\n  long i;\n  double cc = 0.0;\n  double mx = 0.0;\n  double my = 0.0;\n  double nx = 0;\n  double ny = 0;\n  for (i = 0; i < N; i++) {\n    mx += x[i];\n    my += y[i];\n  }\n  mx /= (double)N;\n  my /= (double)N;\n  for (i=0; i<N; i++) {\n    cc += (x[i] - mx) * (y[i] - my);\n    nx += (x[i] - mx) * (x[i] - mx);\n    ny += (y[i] - my) * (y[i] - my);\n  }\n  cc /= sqrt(nx) * sqrt(ny);\n  return cc;\n}\n\n/***** vector math *******/\n\n/* compute euclidean norm of given vector x */\nFLOAT_DMEM smileMath_vectorLengthEuc(FLOAT_DMEM *x, long N)\n{\n  long i; FLOAT_DMEM norm = 0.0;\n  for (i=0; i<N; i++) norm += x[i]*x[i];\n  return (FLOAT_DMEM)sqrt(norm);\n}\n\n/* compute L1 norm (absolute sum) of given vector x */\nFLOAT_DMEM smileMath_vectorLengthL1(FLOAT_DMEM *x, long N)\n{\n  long i; FLOAT_DMEM norm = 0.0;\n  for (i=0; i<N; i++) norm += (FLOAT_DMEM)fabs(x[i]);\n  return norm;\n}\n\n/* normalise euclidean length of x to 1 */\nFLOAT_DMEM smileMath_vectorNormEuc(FLOAT_DMEM *x, long N)\n{\n  FLOAT_DMEM norm = smileMath_vectorLengthEuc(x,N);\n  long i; \n  if (norm > 0.0) for (i=0; i<N; i++) x[i] /= norm;\n  return norm;\n}\n\n/* normalise vector sum to 1 */\nFLOAT_DMEM smileMath_vectorNormL1(FLOAT_DMEM *x, long N)\n{\n  FLOAT_DMEM norm = smileMath_vectorLengthL1(x,N);\n  long i; \n  if (norm > 0.0) for (i=0; i<N; i++) x[i] /= norm;\n  return norm;\n}\n\n/* normalise values of vector x to range [min - max] */\nvoid smileMath_vectorNormMax(FLOAT_DMEM *x, long N, FLOAT_DMEM min, FLOAT_DMEM max)\n{\n  long i;\n  FLOAT_DMEM _min=x[0];\n  FLOAT_DMEM _max=x[0];\n  FLOAT_DMEM scale;\n  for (i=0; i<N; i++) {\n    if (x[i] < _min) _min = x[i];\n    else if (x[i] > _max) _max = x[i];\n  }\n  if (_max==_min) scale = 1.0;\n  else scale = (max-min)/(_max-_min);\n  for (i=0; i<N; i++) {\n    x[i] = (x[i]-_min)*scale+min;\n  }\n}\n\n/* compute the arithmetic mean of vector x */\nFLOAT_DMEM smileMath_vectorAMean(FLOAT_DMEM *x, long N)\n{\n  long i; FLOAT_DMEM sum = 0.0;\n  for (i=0; i<N; i++) sum += x[i];\n  return sum / (FLOAT_DMEM)N;\n}\n\n/* root of each element in a vector */\nvoid smileMath_vectorRoot(FLOAT_DMEM *x, long N)\n{\n  long i;\n  for (i=0; i<N; i++) { if (x[i]>=(FLOAT_DMEM)0.0) x[i]=(FLOAT_DMEM)sqrt(x[i]); }\n}\n\n/* root of each element in a vector */\nvoid smileMath_vectorRootD(double *x, long N)\n{\n  long i;\n  for (i=0; i<N; i++) { if (x[i]>=0.0) x[i]=sqrt(x[i]); }\n}\n\n/**** complex number math ****/\n\n/* compute A/B , store in C */\nvoid smileMath_complexDiv(double ReA, double ImA, double ReB, double ImB, double *ReC, double *ImC)\n{\n  double r, den;\n  double R=0,I=0;\n\n  if (fabs (ReB) >= fabs (ImB)) {\n    if (ReB != 0.0) {\n      r = ImB / ReB;\n      den = ReB + r * ImB;\n      if (den != 0.0) {\n        R = (ReA + ImA*r ) / den; // R = (ReA  + r*ImA ) / den;\n        I = (ImA - r*ReA) / den; // I = (ImA * ReB - r * ReA) / den;\n      }\n    }\n  } else {\n    if (ImB != 0.0) {\n      r = ReB / ImB;\n      den = ImB + r * ReB;\n      if (den != 0.0) {\n        R = (ReA * r + ImA) / den;\n        I = (ImA * r - ReA) / den;\n      }\n    }\n  }\n  if (ReC != NULL) *ReC = R;\n  if (ImC != NULL) *ImC = I;\n}\n\ndouble smileMath_complexAbs(double Re, double Im)\n{\n  return sqrt (Re*Re + Im*Im);\n}\n\n/* fix roots to inside the unit circle */\n// ensure all roots are within the unit circle\n// if abs(root) > 1  (outside circle)\n// then root = 1 / root*\n//\n// *roots is an array of n complex numbers (2*n doubles)\nvoid smileMath_complexIntoUnitCircle(double *roots, int n)\n{\n  long i;\n  for (i=0; i<n; i++) {\n    long i2 = i*2;\n    // if abs(root) > 1.0 \n    if (smileMath_complexAbs(roots[i2],roots[i2+1]) > 1.0) {\n      // root = 1.0 / root*\n      smileMath_complexDiv(1.0 , 0.0 , roots[i2], -roots[i2+1], &roots[i2], &roots[i2+1]);\n    }\n  }\n}\n\n\n\n// constructs a parabola from three points (parabolic interpolation)\n// returns: peak x of parabola, and optional (if not NULL) the y value of the peak in *y and the steepness in *_a\ndouble smileMath_quadFrom3pts(double x1, double y1, double x2, double y2, double x3, double y3, double *y, double *_a)\n{\n  double den = x1*x1*x2 + x2*x2*x3 + x3*x3*x1 - x3*x3*x2 - x2*x2*x1 - x1*x1*x3;\n  if (den != 0.0) {\n    double a = (y1*x2 + y2*x3 + y3*x1 - y3*x2 - y2*x1 - y1*x3)/den;\n    double b = (x1*x1*y2 + x2*x2*y3 + x3*x3*y1 - x3*x3*y2 - x2*x2*y1 - x1*x1*y3) / den;\n    double c = (x1*x1*x2*y3 + x2*x2*x3*y1 + x3*x3*x1*y2 - x3*x3*x2*y1 - x2*x2*x1*y3 - x1*x1*x3*y2) / den;\n    if (a != 0.0) {\n      double x;\n      if (_a != NULL) *_a = a;\n      x = -b/(2.0*a);\n      if (y!=NULL) *y = c - a*x*x;\n      return x;\n    } \n  } \n      \n  // fallback to peak picking if we can't construct a parabola\n  if (_a!=NULL) *_a = 0.0;\n  if ((y1>y2)&&(y1>y3)) { if (y!=NULL) *y = y1; return x1; }\n  else if ((y2>y1)&&(y2>y3)) { if (y!=NULL) *y = y2; return x2; }\n  else if ((y3>y1)&&(y3>y2)) { if (y!=NULL) *y = y3; return x3; }\n  \n  // fallback to keep compiler happy.. this will only happen if all input values are equal:\n  if (y!=NULL) *y = y1; return x1;\n}\n\n\n/*******************************************************************************************\n ***********************=====   DSP functions   ===== **************************************\n *******************************************************************************************/\n\n/* Hermansky 1990, JASA , scale corrected to max == 1 */\ndouble smileDsp_equalLoudnessWeight(double frequency) \n{\n  double w = 2.0*M_PI*frequency;\n  double w2 = w*w;\n  double c = w2 + 6300000.0;\n  if (c > 0.0) {\n  //  printf(\"x = %f\\n\",((w2 +56.8*1000000.0)*w2*w2 ) / (c*c * (w2 + 380000000.0)));\n    //return 1.755e27*((w2 +56.8e6)*w2*w2 ) / (c*c * (w2 + 0.38e9)*(w2*w2*w2 + 9.58e26));\n    return ( 1e32 * ((w2 +56.8e6)*w2*w2 ) / (c*c * (w2 + 0.38e9)*(w2*w2*w2*w + 1.7e31))  );\n  } else {\n    return 0.0;\n  }\n}\n\ndouble smileDsp_equalLoudnessWeight_htk(double frequency) \n{\n  /* HTK version of the PLP equal loudness curve:*/\n  double f2 = (frequency * frequency);\n  double fs = f2/(f2 + 1.6e5);\n  return fs * fs * ((f2 + 1.44e6)/(f2 + 9.61e6));\n}\n\n/* frequency weighting for computing the psychoacoustic measure of spectral sharpness */\ndouble smileDsp_getSharpnessWeightG(double frq, int frqScale, double param)\n{\n  if (frqScale != SPECTSCALE_BARK) {\n    // transform to linear scale...\n    frq = smileDsp_specScaleTransfInv(frq,frqScale,param);\n    // ...then from linear to bark\n    frq = smileDsp_specScaleTransfFwd(frq,SPECTSCALE_BARK,0.0);\n  }\n  // get Zwicker's weighting g(z):\n  if (frq <= 16.0) {\n    return 1.0;\n  } else {\n    return pow( (frq-16.0)/4.0, 1.5849625 /*log(3.0)/log(2.0)*/ ) + 1.0;\n  }\n}\n\n  /*======= spectral scaling functions === */\n\n// equivalent rectangular bandwidth (in linear frequency)\n// of critical band filter at a given linear centre frequency\ndouble smileDsp_ERB(double x)\n{\n  return 0.00000623*x*x + 0.09339*x + 28.52;\n}\n\n// +++ forward scale transformation function (source (linear) -> target) +++\n// 'x' : is the (linear) source frequency in Hertz\n// 'scale' : is one of the following:\n//   SPECTSCALE_LOG, SPECTSCALE_SEMITONE, SPECTSCALE_BARK, \n//   SPECTSCALE_BARK_SCHROED, SPECTSCALE_BARK_SPEEX, SPECTSCALE_MEL\n// 'param' is either:\n//   logScaleBase if scale == SPECTSCALE_LOG\n//   firstNote    if scale == SPECTSCALE_SEMITONE\ndouble smileDsp_specScaleTransfFwd(double x, int scale, double param)\n{\n  switch(scale) {\n    case SPECTSCALE_LOG: \n      return log(x)/log(param); // param = logScaleBase\n    case SPECTSCALE_SEMITONE:\n      if (x/param>1.0) // param = firstNote\n        return 12.0 * smileMath_log2(x / param); // param = firstNote\n      else return 0.0;\n    case SPECTSCALE_BARK_OLD:\n      if (x>0) {\n        return (26.81 / (1.0 + 1960.0/x)) - 0.53;\n      } else { \n        return 0.0; \n      }\n    case SPECTSCALE_BARK: // Bark scale according to : H. Traunm�ller (1990) \"Analytical expressions for the tonotopic sensory scale\" J. Acoust. Soc. Am. 88: 97-100.   \n      if (x>0) {\n        //OLD: return (26.81 / (1.0 + 1960.0/x)) - 0.53;\n        // now: exact for high and low frequencies(!)\n        double zz = (26.81 / (1.0 + 1960.0/x)) - 0.53;\n        if (zz < 2) {\n          return (0.85 * zz + 0.3);\n        } else if (zz > 20.1) {\n          return (1.22*zz - 0.22 * 20.1); \n        } else {\n          return zz;\n        }\n      } else {\n        return 0.0;\n      }\n    case SPECTSCALE_BARK_SCHROED:\n      if (x>0) {\n        double f6 = x/600.0;\n        return (6.0 * log(f6 + sqrt(f6*f6 + 1.0) ) );\n      } else return 0.0;\n    case SPECTSCALE_BARK_SPEEX:\n        return (13.1*atan(.00074*x)+2.24*atan(x*x*1.85e-8)+1e-4*x);\n    case SPECTSCALE_MEL: // Mel scale according to: L.L. Beranek (1949) Acoustic Measurements, New York: Wiley. \n      if (x>0.0) {\n        return 1127.0 * log(1.0 + x/700.0);\n      } else return 0.0;\n    case SPECTSCALE_LINEAR: \n    default:\n      return x;\n  }\n  return x;\n}\n\n// +++ inverse scale transformation function (linear -> target) +++\n// 'x' : is the (non-linear) source frequency in Bark/Mel/etc. scale ...\n// 'scale' : is one of the following:\n//   SPECTSCALE_LOG, SPECTSCALE_SEMITONE, SPECTSCALE_BARK, \n//   SPECTSCALE_BARK_SCHROED, SPECTSCALE_BARK_SPEEX, SPECTSCALE_MEL\n// 'param' is either:\n//   logScaleBase if scale == SPECTSCALE_LOG\n//   firstNote    if scale == SPECTSCALE_SEMITONE\n// return value: linear frequency in Hertz\ndouble smileDsp_specScaleTransfInv(double x, int scale, double param)\n{\n  double zz;\n  double z0;\n  switch(scale) {\n    case SPECTSCALE_LOG: \n      return exp(x * log(param)); // param = logScaleBase\n    case SPECTSCALE_SEMITONE:\n      return param * pow(2.0, x/12.0); // param = firstNote\n    case SPECTSCALE_BARK_OLD: { // Bark scale according to : H. Traunm�ller (1990) \"Analytical expressions for the tonotopic sensory scale\" J. Acoust. Soc. Am. 88: 97-100.   \n      double z0 = (x+0.53)/26.81;\n      if (z0 != 1.0) return (1960.0 * z0)/(1.0-z0);\n      else return 0.0;\n      }\n    case SPECTSCALE_BARK:\n      {\n      zz = x;\n      if (x > 20.1) {\n        zz = (x + 0.22*20.1)/1.22;\n      } else if (x < 2) {\n        zz = (x - 0.3)/0.85;\n      }\n      z0 = 26.81 / (zz + 0.53);\n      if (z0 != 1.0) {\n        return 1960.0 / (z0 - 1.0);\n      } else { \n        return 0.0; \n      }\n      }\n    case SPECTSCALE_BARK_SCHROED:\n      return 600.0 * sinh(x/6.0);\n      //return 0.0;\n    case SPECTSCALE_BARK_SPEEX:\n      fprintf(stderr,\"smileDsp_specScaleTransfInv: SPECTSCALE_BARK_SPEEX: inversion not yet implemented\");\n    case SPECTSCALE_MEL :  // Mel scale according to: L.L. Beranek (1949) Acoustic Measurements, New York: Wiley. \n      return 700.0*(exp(x/1127.0)-1.0);        \n    case SPECTSCALE_LINEAR:\n    default:\n      return x;\n  }\n  return x;\n}\n\n\n  /*======= window functions ==========*/\n\n/* sinc function (modified) : (sin 2pi*x) / x */\ndouble smileDsp_lcSinc(double x)\n{\n  double y = M_PI * x;\n  return sin(y)/(y);\n}\n\n/* sinc function : (sin x) / x  */\ndouble smileDsp_sinc(double x)\n{\n  return sin(x)/(x);\n}\n\n/* rectangular window */\ndouble * smileDsp_winRec(long _N)\n{\n  int i;\n  double * ret = (double *)malloc(sizeof(double)*_N);\n  double * x = ret;\n  for (i=0; i<_N; i++) {\n    *x = 1.0; x++;\n  }\n  return ret;\n}\n\n/* triangular window (non-zero endpoints) */\ndouble * smileDsp_winTri(long _N)\n{\n  long i;\n  double * ret = (double *)malloc(sizeof(double)*_N);\n  double * x = ret;\n  for (i=0; i<_N/2; i++) {\n    *x = 2.0*(double)(i+1)/(double)_N;\n    x++;\n  }\n  for (i=_N/2; i<_N; i++) {\n    *x = 2.0*(double)(_N-i)/(double)_N;\n    x++;\n  }\n  return ret;\n}\n\n/* powered triangular window (non-zero endpoints) */\ndouble * smileDsp_winTrP(long _N)\n{\n  double *w = smileDsp_winTri(_N);\n  double *x = w;\n  long n; for (n=0; n<_N; n++) *x = *x * (*(x++));\n  return w;\n}\n\n/* bartlett (triangular) window (zero endpoints) */\ndouble * smileDsp_winBar(long _N)\n{\n  long i;\n  double * ret = (double *)malloc(sizeof(double)*_N);\n  double * x = ret;\n  for (i=0; i<_N/2; i++) {\n    *x = 2.0*(double)(i)/(double)(_N-1);\n    x++;\n  }\n  for (i=_N/2; i<_N; i++) {\n    *x = 2.0*(double)(_N-1-i)/(double)(_N-1);\n    x++;\n  }\n  return ret;\n}\n\n/* hann(ing) window */\ndouble * smileDsp_winHan(long _N)\n{\n  double i;\n  double * ret = (double *)malloc(sizeof(double)*_N);\n  double * x = ret;\n  double NN = (double)_N;\n  for (i=0.0; i<NN; i += 1.0) {\n    *x = 0.5*(1.0-cos( (2.0*M_PI*i)/(NN-1.0) ));\n    x++;\n  }\n  return ret;\n}\n\n/* hamming window */\ndouble * smileDsp_winHam(long _N)\n{\n  double i;\n  double * ret = (double *)malloc(sizeof(double)*_N);\n  double * x = ret;\n  double NN = (double)_N;\n  for (i=0.0; i<NN; i += 1.0) {\n/*    *x = 0.53836 - 0.46164 * cos( (2.0*M_PI*i)/(NN-1.0) ); */\n    *x = 0.54 - 0.46 * cos( (2.0*M_PI*i)/(NN-1.0) );\n    x++;\n  }\n  return ret;\n}\n\n/* half-wave sine window (cosine window) */\ndouble * smileDsp_winSin(long _N)\n{\n  double i;\n  double * ret = (double *)malloc(sizeof(double)*_N);\n  double * x = ret;\n  double NN = (double)_N;\n  for (i=0.0; i<NN; i += 1.0) {\n    *x = sin( (1.0*M_PI*i)/(NN-1.0) );\n    x++;\n  }\n  return ret;\n}\n\n/* Lanczos window */\ndouble * smileDsp_winLac(long _N)\n{\n  double i;\n  double * ret = (double *)malloc(sizeof(double)*_N);\n  double * x = ret;\n  double NN = (double)_N;\n  for (i=0.0; i<NN; i += 1.0) {\n    *x = smileDsp_lcSinc( (2.0*i)/(NN-1.0) - 1.0 );\n    x++;\n  }\n  return ret;\n}\n\n/* gaussian window ...??? */\ndouble * smileDsp_winGau(long _N, double sigma)\n{\n  double i;\n  double * ret = (double *)malloc(sizeof(double)*_N);\n  double * x = ret;\n  double NN = (double)_N;\n  double tmp;\n  if (sigma <= 0.0) sigma = 0.01;\n  if (sigma > 0.5) sigma = 0.5;\n  for (i=0.0; i<NN; i += 1.0) {\n    tmp = (i-(NN-1.0)/2.0)/(sigma*(NN-1.0)/2.0);\n    *x = exp( -0.5 * ( tmp*tmp ) );\n    x++;\n  }\n  return ret;\n}\n\n/* Blackman window */\ndouble * smileDsp_winBla(long _N, double alpha0, double alpha1, double alpha2)\n{\n  double i;\n  double * ret = (double *)malloc(sizeof(double)*_N);\n  double * x = ret;\n  double NN = (double)_N;\n  double tmp;\n  for (i=0.0; i<NN; i += 1.0) {\n    tmp = (2.0*M_PI*i)/(NN-1.0);\n    *x = alpha0 - alpha1 * cos( tmp ) + alpha2 * cos( 2.0*tmp );\n    x++;\n  }\n  return ret;\n\n}\n\n/* Bartlett-Hann window */\ndouble * smileDsp_winBaH(long _N, double alpha0, double alpha1, double alpha2)\n{\n  double i;\n  double * ret = (double *)malloc(sizeof(double)*_N);\n  double * x = ret;\n  double NN = (double)_N;\n  for (i=0.0; i<NN; i += 1.0) {\n    *x = alpha0 - alpha1 * fabs( i/(NN-1.0) - 0.5 ) - alpha2 * cos( (2.0*M_PI*i)/(NN-1.0) );\n    x++;\n  }\n  return ret;\n}\n\n/* Blackman-Harris window */\ndouble * smileDsp_winBlH(long _N, double alpha0, double alpha1, double alpha2, double alpha3)\n{\n  double i;\n  double * ret = (double *)malloc(sizeof(double)*_N);\n  double * x = ret;\n  double NN = (double)_N;\n  double tmp;\n  for (i=0.0; i<NN; i += 1.0) {\n    tmp = (2.0*M_PI*i)/(NN-1.0);\n    *x = alpha0 - alpha1 * cos( tmp ) + alpha2 * cos( 2.0*tmp ) - alpha3 * cos( 3.0*tmp );\n    x++;\n  }\n  return ret;\n}\n\nint winFuncToInt(const char * winF)\n{\n  int winFunc;\n  if ((!strcmp(winF,\"Han\"))||(!strcmp(winF,\"han\"))||(!strcmp(winF,\"Hanning\"))||(!strcmp(winF,\"hanning\"))||(!strcmp(winF,\"hann\"))||(!strcmp(winF,\"Hann\")))\n    { winFunc = WINF_HANNING; }\n  else if ((!strcmp(winF,\"Ham\"))||(!strcmp(winF,\"ham\"))||(!strcmp(winF,\"Hamming\"))||(!strcmp(winF,\"hamming\")))\n    { winFunc = WINF_HAMMING; }\n  else if ((!strcmp(winF,\"Rec\"))||(!strcmp(winF,\"rec\"))||(!strcmp(winF,\"Rectangular\"))||(!strcmp(winF,\"rectangular\"))||(!strcmp(winF,\"none\"))||(!strcmp(winF,\"None\")))\n    { winFunc = WINF_RECTANGLE; }\n  else if ((!strcmp(winF,\"Gau\"))||(!strcmp(winF,\"gau\"))||(!strcmp(winF,\"Gauss\"))||(!strcmp(winF,\"gauss\"))||(!strcmp(winF,\"Gaussian\"))||(!strcmp(winF,\"gaussian\")))\n    { winFunc = WINF_GAUSS; }\n  else if ((!strcmp(winF,\"Sin\"))||(!strcmp(winF,\"sin\"))||(!strcmp(winF,\"Sine\"))||(!strcmp(winF,\"sine\"))||(!strcmp(winF,\"cosine\"))||(!strcmp(winF,\"Cosine\"))||(!strcmp(winF,\"Cos\"))||(!strcmp(winF,\"cos\")))\n    { winFunc = WINF_SINE; }\n  else if ((!strcmp(winF,\"Tri\"))||(!strcmp(winF,\"tri\"))||(!strcmp(winF,\"Triangle\"))||(!strcmp(winF,\"triangle\")))\n    { winFunc = WINF_TRIANGLE; }\n  else if ((!strcmp(winF,\"Bla\"))||(!strcmp(winF,\"bla\"))||(!strcmp(winF,\"Blackman\"))||(!strcmp(winF,\"blackman\")))\n    { winFunc = WINF_BLACKMAN; }\n  else if ((!strcmp(winF,\"BlH\"))||(!strcmp(winF,\"blh\"))||(!strcmp(winF,\"Blackman-Harris\"))||(!strcmp(winF,\"blackman-harris\")))\n    { winFunc = WINF_BLACKHARR; }\n  else if ((!strcmp(winF,\"Bar\"))||(!strcmp(winF,\"bar\"))||(!strcmp(winF,\"Bartlett\"))||(!strcmp(winF,\"bartlett\")))\n    { winFunc = WINF_BARTLETT; }\n  else if ((!strcmp(winF,\"BaH\"))||(!strcmp(winF,\"bah\"))||(!strcmp(winF,\"Bartlett-Hann\"))||(!strcmp(winF,\"bartlett-hann\"))||(!strcmp(winF,\"Bartlett-Hanning\"))||(!strcmp(winF,\"bartlett-hanning\")))\n    { winFunc = WINF_BARTHANN; }\n  else if ((!strcmp(winF,\"Lac\"))||(!strcmp(winF,\"lac\"))||(!strcmp(winF,\"Lanczos\"))||(!strcmp(winF,\"lanczos\")))\n    { winFunc = WINF_LANCZOS; }\n  else {\n    winFunc = WINF_UNKNOWN;\n  }\n  return winFunc;\n}\n\n/****** FFT related dsp functions *****/\n\nvoid smileDsp_fftPhaseUnwrap(FLOAT_DMEM * phaseRadians, long N) {\n  FLOAT_DMEM correction = 0.0;\n  FLOAT_DMEM prevPhase = phaseRadians[0];\n  long i;\n  for (i = 1; i < N; i++) {\n    FLOAT_DMEM delta = phaseRadians[i] - prevPhase;\n    prevPhase = phaseRadians[i];\n    if (delta > M_PI) {\n      correction -= 2.0 * M_PI;\n    }\n    else if (delta < -M_PI) {\n      correction += 2.0 * M_PI;\n    }\n    phaseRadians[i] += correction;\n  }\n}\n\n// important: caller must ensure the following:\n// mag is of size N+1\n// phase is of size N+1\nlong smileDsp_fftComputeMagPhase(const FLOAT_DMEM *complex, long N,\n    FLOAT_DMEM *mag, FLOAT_DMEM *phase, int normaliseFft)\n{\n  long n;\n  if (phase != NULL && mag != NULL) {\n    mag[0] = fabs(complex[0]);\n    phase[0] = (complex[0] >= 0) ? 0 : M_PI;\n    for (n = 2; n < N; n += 2) {\n      mag[n >> 1] = sqrt(complex[n] * complex[n]\n                         + complex[n + 1] * complex[n + 1]);\n      phase[n >> 1] = atan2(complex[n + 1], complex[n]);\n    }\n    mag[N / 2] = complex[1];\n    phase[N / 2] = (complex[1] >= 0) ? 0 : M_PI;\n  }\n  else if (mag != NULL) {\n    mag[0] = fabs(complex[0]);\n    for (n = 2; n < N; n += 2) {\n      mag[n >> 1] = sqrt(complex[n] * complex[n]\n                         + complex[n + 1] * complex[n + 1]);\n    }\n    mag[N / 2] = complex[1];\n  }\n  else if (phase != NULL) {\n    phase[0] = (complex[0] >= 0) ? 0 : M_PI;\n    for (n = 2; n < N; n += 2) {\n      phase[n >> 1] = atan2(complex[n + 1], complex[n]);\n    }\n    phase[N / 2] = (complex[1] >= 0) ? 0 : M_PI;\n  }\n  if (normaliseFft && mag != NULL) {\n    for (n = 0; n <= N / 2; n++) {\n      mag[n] /= ((FLOAT_DMEM)N * 2.0);\n    }\n  }\n  return N / 2 + 1;\n}\n\n/****** other dsp functions *******/\n\n/* compute harmonic product spectrum from a linear scale magnitude spectrum, use up to maxMul down-scaled spectra */\nlong smileDsp_harmonicProductLin(const FLOAT_DMEM *src, long Nsrc, FLOAT_DMEM *dst, long Ndst, int maxMul)\n{\n  long i; int m;\n  long oLen = Ndst;\n  if (Nsrc < oLen) oLen = Nsrc;\n  for (i=0; i<oLen; i++) {\n    dst[i] = src[i];\n    for (m=2; m<=maxMul; m++) {\n      long idx = i*m;\n      if (idx < Nsrc) dst[i] *= src[idx];\n    }\n  }\n  return oLen;\n}\n\n/* compute harmonic sum spectrum from a linear scale magnitude spectrum, use up to maxMul down-scaled spectra */\nlong smileDsp_harmonicSumLin(const FLOAT_DMEM *src, long Nsrc, FLOAT_DMEM *dst, long Ndst, int maxMul)\n{\n  long i; int m;\n  long oLen = Ndst;\n  if (Nsrc < oLen) oLen = Nsrc;\n  for (i=0; i<oLen; i++) {\n    dst[i] = src[i];\n    for (m=2; m<=maxMul; m++) {\n      long idx = i*m;\n      if (idx < Nsrc) dst[i] += src[idx]/(FLOAT_DMEM)m;\n    }\n  }\n  return oLen;\n}\n\n\n/* convert lp coefficients to cepstra \n   HTKbook , equation 5.11\n */\nFLOAT_DMEM smileDsp_lpToCeps(const FLOAT_DMEM *lp, int nLp, FLOAT_DMEM lpGain, FLOAT_DMEM *ceps, int firstCC, int lastCC) \n{\n  // CHECK: nCeps <= nLp !\n  int i;\n  int n;\n  int nCeps;\n  \n  if (firstCC < 1) \n    firstCC = 1;\n  if (lastCC > nLp) \n    lastCC = nLp;\n  nCeps = lastCC - firstCC + 1;\n\n  for (n = firstCC; n <= lastCC; n++) {\n    double sum = 0;\n    for (i = 1; i < n; i++) { \n      sum += (n - i) * lp[i - 1] * ceps[n - i - 1]; \n    }\n    ceps[n - firstCC] = -(lp[n - firstCC] + (FLOAT_DMEM)(sum / (double)n));\n  }\n  if (lpGain <= 0.0) { \n    lpGain = (FLOAT_DMEM)1.0; \n  }\n  return (FLOAT_DMEM)(-log(1.0/(double)lpGain));\n}\n\n\n/* Autocorrelation in the time domain (for ACF LPC method) */\nvoid smileDsp_autoCorr(const FLOAT_DMEM *x, const int n, FLOAT_DMEM *outp, int lag)\n{\n  int i;\n  while (lag) {\n    outp[--lag] = 0.0;\n    for (i=lag; i < n; i++) {\n      outp[lag] += x[i] * x[i-lag];\n    }\n  }\n}\n\n/* LPC analysis via acf (=implementation of Durbin recursion)*/\nint smileDsp_calcLpcAcf(FLOAT_DMEM * r, FLOAT_DMEM *a, int p, FLOAT_DMEM *gain, FLOAT_DMEM *k)\n{\n  int i, m = 0;\n  FLOAT_DMEM e;\n  int errF = 1;\n  FLOAT_DMEM k_m;\n  FLOAT_DMEM *al;\n\n  if (a == NULL) return 0;\n  if (r == NULL) return 0;\n\n  if ((r[0] == 0.0)||(r[0] == -0.0)) {\n    for (i=0; i < p; i++) { a[i] = 0.0; }\n    return 0;\n  }\n\n  al = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*(p));\n  \n  // Initialisation, Gl. 158\n  e = r[0];\n  if (e==0.0) {\n    for (i=0; i<=p; i++) {\n      a[i] = 0.0;\n      if (k!=NULL) k[m] = 0.0;\n    }\n  } else {\n    // Iterations: m = 1... p, Gl. 159\n    for (m=1; m<=p; m++) {\n      // Gl. 159 (a) \n      FLOAT_DMEM sum = (FLOAT_DMEM)1.0 * r[m];\n      for (i=1; i<m; i++) {\n        sum += a[i-1] * r[m-i];\n      }\n      k_m = ( (FLOAT_DMEM)-1.0 / e ) * sum;\n      // copy refl. coeff.\n      if (k != NULL) k[m-1] = k_m;\n      // Gl. 159 (b)\n      a[m-1] = k_m;\n      for (i=1; i<=m/2; i++) {\n        FLOAT_DMEM x = a[i-1];\n        a[i-1] += k_m * a[m-i-1];\n        if ((i < (m/2))||((m&1)==1)) a[m-i-1] += k_m * x;\n      }\n      // update error\n      e *= ((FLOAT_DMEM)1.0-k_m*k_m);\n      if (e==0.0) {\n        for (i=m; i<=p; i++) {\n          a[i] = 0.0;\n          if (k!=NULL) k[m] = 0.0;\n        }\n        break;\n      }\n    }\n  }\n  free(al);\n\n  if (gain != NULL) *gain=e;\n  return 1;\n}\n\nint smileDsp_calcLpcBurg(const FLOAT_DMEM *samples, long N,\n    FLOAT_DMEM *coeffs, int M, FLOAT_DMEM *lpcgain,\n    FLOAT_DMEM **gbb, FLOAT_DMEM **gb2, FLOAT_DMEM **gaa)\n{\n  FLOAT_DMEM order_p = 0.0;\n  FLOAT_DMEM tmp_x = 0.0;\n  FLOAT_DMEM *tmp_aa = NULL;\n  FLOAT_DMEM *tmp_b1 = NULL;\n  FLOAT_DMEM *tmp_b2 = NULL;\n  long i = 1;\n  long j = 0;\n  int burgStatus = 0;\n\n  if ((N < M) || (M <= 0)) {\n    return 0;\n  }\n  if (samples == NULL) {\n    return 0;\n  }\n  if (coeffs == NULL) {\n    return 0;\n  }\n\n  if (gaa != NULL) {\n    tmp_aa = *gaa;\n  }\n  if (tmp_aa == NULL) {\n    tmp_aa = (FLOAT_DMEM*)calloc(1, sizeof(FLOAT_DMEM)*M);\n  }\n  if (gbb != NULL) {\n    tmp_b1 = *gbb;\n  }\n  if (tmp_b1 == NULL) {\n    tmp_b1 = (FLOAT_DMEM*)calloc(1, sizeof(FLOAT_DMEM)*N);\n  }\n  if (gb2 != NULL) {\n    tmp_b2 = *gb2;\n  }\n  if (tmp_b2 == NULL) {\n    tmp_b2 = (FLOAT_DMEM*)calloc(1, sizeof(FLOAT_DMEM)*N);\n  }\n\n  for (j = 0; j < N; j++) {\n    order_p += samples[j] * samples[j];\n  }\n  tmp_x = order_p / N;\n  if (tmp_x > 0) {\n    tmp_b1[0] = samples[0];\n    tmp_b2[N - 2] = samples[N-1];\n    for (j = 1; j < N - 1; j++) {\n      tmp_b1[j] = tmp_b2[j - 1] = samples[j];\n    }\n    for (i = 0; i < M; i++) {\n      FLOAT_DMEM nominator = 0.0;\n      FLOAT_DMEM denominator = 0.0;\n      for (j = 0; j < N - i - 1; j++) {\n        nominator += tmp_b1[j] * tmp_b2[j];\n        denominator += tmp_b1[j] * tmp_b1[j] + tmp_b2[j] * tmp_b2[j];\n      }\n      if (denominator <= 0) {\n        burgStatus = -1;\n        break;\n      }\n      coeffs[i] = (FLOAT_DMEM)2.0 * nominator / denominator;\n      tmp_x *= (FLOAT_DMEM)1.0 - coeffs[i] * coeffs[i];\n      for (j = 0; j < i; j++) {\n        coeffs[j] = tmp_aa[j] - coeffs[i] * tmp_aa[i - j - 1];\n      }\n      if (i < M - 1) {\n        // Algorithm note: i --> i + 1\n        for (j = 0; j <= i; j++) {\n          tmp_aa[j] = coeffs[j];\n        }\n        for (j = 0; j < N - i - 2; j++) {\n          tmp_b1[j] -= tmp_aa[i] * tmp_b2[j];\n          tmp_b2[j] = tmp_b2[j + 1] - tmp_aa[i] * tmp_b1[j + 1];\n        }\n      }\n    }\n    if (burgStatus == 0) {\n      burgStatus = 1;\n    }\n  }\n  // Free the temporary data\n  if (gaa != NULL) {\n    *gaa = tmp_aa;\n  } else if (tmp_aa != NULL) {\n    free(tmp_aa);\n  }\n  if (gbb != NULL) {\n    *gbb = tmp_b1;\n  } else if (tmp_b1 != NULL) {\n    free(tmp_b1);\n  }\n  if (gb2 != NULL) {\n    *gb2 = tmp_b2;\n  } else if (tmp_b2 != NULL) {\n    free(tmp_b2);\n  }\n\n  // Coefficients are inverted here to maintain compatibility with\n  // the ACF method for estimating LPC coefficients\n  for (j = 0; j < i; j++) {\n    coeffs[j] = -coeffs[j];\n  }\n  // The remaining coefficients are padded with zeros\n  for (j = i; j < M; j++) {\n    coeffs[j] = 0.0;\n  }\n  // Finally, the gain is adjusted and returned:\n  if (lpcgain != NULL) {\n    *lpcgain = tmp_x * (FLOAT_DMEM)N;\n  }\n  return burgStatus;\n}\n\n// initialise a inverse RDFT work area\n// K is number of frequency bins (input)\n// I is the number of actual output samples to compute\n// nI is the denominator of the sin/cos functions (usually =I) \nsDftWork * smileDsp_initIrdft(long K, long I, double nI, int antialias)\n{\n  long i,k;\n  double pi2 = 2.0*M_PI;\n  sDftWork * w = (sDftWork *)malloc(sizeof(sDftWork));\n\n  w->K = K;\n  w->I = I;\n  if (antialias) {\n    w->kMax = K>I ? I : K; // MIN(K,I);\n  } else {\n    w->kMax = K;\n  }\n  if (w->kMax & 1) { w->kMax--; } // \"round\" down to even number\n\n  w->antiAlias = antialias;\n\n  /* fill cos and sin tables: */\n  w->costable = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*(w->kMax/2)*I);\n  w->sintable = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*(w->kMax/2)*I);\n\n  for (i=0; i<I; i++) {\n    long i_n = i*w->kMax/2 - 1;\n    if (I>=K)\n      w->costable[i_n+K/2] = (FLOAT_DMEM)cos((pi2*(double)((K/2)*i))/nI) ; /* Nyquist */\n    \n    for (k=2; k<w->kMax; k+=2) {\n      double kn = pi2 * (double)(k/2 * i) / nI;\n      w->costable[i_n + k/2] = (FLOAT_DMEM)cos(kn); /*real*/\n      w->sintable[i_n + k/2] = (FLOAT_DMEM)sin(kn); /*imaginary*/\n    }\n  }\n\n  return w;\n}\n\n// free a DFT work area\nsDftWork * smileDsp_freeDftwork(sDftWork * w)\n{\n  if (w != NULL) {\n    if (w->costable != NULL) free(w->costable);\n    if (w->sintable != NULL) free(w->sintable);\n    free(w);\n  }\n  return NULL;\n}\n\n// perform an arbitrary inverse RDFT (slow version)\nvoid smileDsp_irdft(const FLOAT_DMEM * inData, FLOAT_DMEM *out, sDftWork *w) \n{\n  FLOAT_DMEM * costable = w->costable - 1;\n  FLOAT_DMEM * sintable = w->sintable - 1;\n  long i,k;\n  for (i=0; i<w->I; i++) {\n    //long i_n = i*w->kMax/2 - 1;\n    out[i] = inData[0]; /* DC */\n    if (w->I >= w->K) \n      out[i] += inData[1] * costable[w->K/2]; /* Nyquist */\n\n    for (k=2; k<w->kMax; k+=2) {\n      long k2 = k>>1;\n      out[i] += inData[k] * costable[k2]; /*real*/\n      out[i] += inData[k+1] * sintable[k2]; /*imaginary*/\n    }\n    out[i] /= (FLOAT_DMEM)(w->K/2);\n    costable += w->kMax/2;\n    sintable += w->kMax/2;\n  }\n}\n\n\nsResampleWork * smileDsp_resampleWorkFree(sResampleWork * work)\n{\n  if (work != NULL) {\n    if (work->winF != NULL) free(work->winF);\n    if (work->winFo != NULL) free(work->winFo);\n    if (work->_w != NULL) free(work->_w);\n    if (work->_ip != NULL) free(work->_ip);\n    if (work->x != NULL) free(work->x);\n    smileDsp_freeDftwork(work->irdftWork);\n    free(work);\n  }\n  return NULL;\n}\n\nsResampleWork * smileDsp_resampleWorkInit(long Nin)\n{\n  sResampleWork * ret = (sResampleWork *)calloc(1,sizeof(sResampleWork));\n  ret->x = (FLOAT_DMEM*)malloc(sizeof(FLOAT_DMEM)*Nin);\n  return ret;\n}\n\nint smileDsp_doResample(FLOAT_TYPE_FFT *x, long Nin, FLOAT_DMEM *y, long Nout, double nd, sResampleWork ** _work)\n{\n  long i;\n  sResampleWork *work;\n\n  if (x==NULL) return 0;\n  if (y==NULL) return 0;\n  if (_work == NULL) return 0;\n  \n  if (*_work==NULL) {\n    *_work = smileDsp_resampleWorkInit(Nin);\n  }\n  work = *_work;\n\n  // window the frame\n  if (work->winF == NULL) {\n    work->winF = smileDsp_winHan(Nin);\n    smileMath_vectorRootD(work->winF,Nin);\n  }\n  for (i=0; i<Nin; i++) {\n    x[i] *= (FLOAT_DMEM)(work->winF[i]);\n  }\n  // fft the frame\n  if (work->_ip == NULL) { work->_ip = (int *)calloc(1,sizeof(int)*(Nin+2)); }\n  if (work->_w==NULL) work->_w = (FLOAT_TYPE_FFT *)calloc(1,sizeof(FLOAT_TYPE_FFT)*(Nin*5)/4+2);\n  rdft(Nin, 1, x, work->_ip, work->_w);\n\n  // convert from FLOAT_TYPE_FFT to FLOAT_DMEM if necessary\n#if FLOAT_FFT_NUM != FLOAT_DMEM_NUM\n  for (i=0; i<Nin; i++) {\n    work->x[i] = (FLOAT_DMEM)x[i];\n  }\n  // inverse dft to new sample rate:\n  if (work->irdftWork == NULL) { work->irdftWork = smileDsp_initIrdft(Nin, Nout, nd, 1); } \n  smileDsp_irdft(work->x, y, work->irdftWork);\n#else\n  // inverse dft to new sample rate:\n  if (work->irdftWork == NULL) { work->irdftWork = smileDsp_initIrdft(Nin, Nout, nd, 1); } \n  smileDsp_irdft(x, y, work->irdftWork);\n\n  // window again\n  if (work->winFo == NULL) {\n    work->winFo = smileDsp_winHan(Nout);\n    smileMath_vectorRootD(work->winFo,Nout);\n  }\n  for (i=0; i<Nout; i++) {\n    y[i] *= (FLOAT_DMEM)(work->winFo[i]);\n  }\n\n#endif\n  return 1;\n}\n\n\n/* Implementation of a lattice filter, processes a single value per call */\nFLOAT_DMEM smileDsp_lattice(FLOAT_DMEM *k, FLOAT_DMEM *b, int M, FLOAT_DMEM in, FLOAT_DMEM *bM)\n{\n  int i;\n  FLOAT_DMEM f0,f1,b0,b1;\n  /* initialisation */\n  b0 = f0 = in;\n  for (i=0; i<M; i++) {\n    f1 = f0 + k[i] * b[i];\n    b1 = k[i] * f0 + b[i];\n    b[i] = b0; // store b[n-1]\n    // save coefficients for next iteration:\n    f0 = f1;\n    b0 = b1;\n  }\n  /* return b (optional) */\n  if (bM != NULL) *bM = b1;\n  /* return f */\n  return f1;\n}\n\n/* Implementation of a lattice filter for an array *in of N floats, NOTE: *bM is an array of size N here! */\nvoid smileDsp_latticeArray(FLOAT_DMEM *k, FLOAT_DMEM *b, int M, FLOAT_DMEM *in, FLOAT_DMEM *out, FLOAT_DMEM *bM, int N)\n{\n  int i,n;\n  FLOAT_DMEM f0,f1,b0,b1;\n\n  for (n=0; n<N; n++) {\n\n    /* initialisation */\n    b0 = f0 = in[n];\n    for (i=0; i<M; i++) {\n      f1 = f0 + k[i] * b[i]; \n      b1 = k[i] * f0 + b[i]; \n      b[i] = b0; \n      f0 = f1; \n      b0 = b1; \n    }\n    /* return b (optional) */\n    if (bM != NULL) bM[n] = b1;\n    /* return f */\n    out[n] = f1;\n\n  }\n}\n\n/* Implementation of an inverse lattice filter, processes a single value per call */\nFLOAT_DMEM smileDsp_invLattice(FLOAT_DMEM *k, FLOAT_DMEM *b, int M, FLOAT_DMEM out)\n{\n  int i;\n  FLOAT_DMEM fM;\n  FLOAT_DMEM last = b[M-1];\n  /* initialisation */\n  fM = out;\n  for (i=M-1; i>0; i--) {\n    fM -= k[i]*b[i-1];\n    b[i] = k[i]*fM + b[i-1];\n  }\n  b[M-1] = last;\n  fM = fM - k[0]*b[M-1];\n  b[0] = k[0]*fM + b[M-1];\n  b[M-1] = fM;\n  /* return fM */\n  return fM;\n}\n\n/* peak enhancement in a linear magnitude spectrum */\nint smileDsp_specEnhanceSHS (double *a, long n)\n{\n  long i = 0;\n  long j = 0;\n  long nmax = 0;\n  long *posmax = (long *)calloc(1, sizeof(long)*( (n + 1) / 2 + 1));\n  if ((n < 2) || (posmax == NULL)) {\n    return 0;\n  }\n  if (a[0] > a[1]) {\n    posmax[nmax++] = 0;\n  }\n  for (i = 1; i < n - 1; i++) {\n    if (a[i] > a[i - 1] && a[i] >= a[i + 1]) {\n      posmax[nmax++] = i;\n    }\n  }\n  if (a[n - 1] > a[n - 2]) {\n    posmax[nmax++] = n - 1;\n  }\n  if (nmax == 1) {\n    for (j = 0; j <= posmax[1] - 3; j++) {\n      a[j] = 0;\n    }\n    for (j = posmax[1] + 3; j < n; j++) {\n      a[j] = 0;\n    }\n  } else {\n    for (i = 1; i < nmax; i++) {\n      for (j = posmax[i - 1] + 3; j <= posmax[i] - 3; j++) {\n        a[j] = 0;\n      }\n    }\n  }\n  free(posmax);\n  return 1;\n}\n\n/* smooth a magnitude spectrum (linear) */\nvoid smileDsp_specSmoothSHS (double *a, long n)\n{\n  double ai = 0.0;\n  double aim1 = 0.0;\n  long i = 0;\n  for ( ; i < n - 1; i++) {\n    ai = a[i];\n    a[i] = (aim1 + 2.0 * ai + a[i + 1]) / 4.0;\n    aim1 = ai;\n  }\n}\n\n/* computes formant frequencies and bandwidths from lpc polynomial roots \n    return value: number of valid formants detected from given lpc polynomial roots\n */\nint smileDsp_lpcrootsToFormants(double *r, int nR, double *fc, double *bc, int nF, double samplePeriod, double fLow, double fHigh)\n{\n  double f;\n  int i;\n  int n = nF;\n  int nFormants = 0;\n  double spPi = samplePeriod * M_PI;  // (1/sp*2*pi)\n  double spPi2 = spPi * 2.0;\n  if ((fHigh < fLow) || (fHigh > 1.0/samplePeriod)) {\n    fHigh = 0.5 / samplePeriod - fLow;\n  }\n  for (i = 0; i < nR; i++) {\n    int iRe = i * 2;\n    int iIm = iRe + 1;\n    // only use complex poles, real-valued only is only spectrum slope\n    if (r[iIm] < 0) {\n      continue;\n    }\n    // compute formant frequency (= the phase of the complex number)\n    f = fabs (atan2 (r[iIm], r[iRe])) / (spPi2);\n    if ((f >= fLow) && (f <= fHigh)) { // if frequency is in range, compute the bandwidth\n      if (bc != NULL) {\n        bc[nFormants] = -log(smileMath_complexAbs(r[iRe],r[iIm])) / spPi;\n      }\n      fc[nFormants] = f;\n      nFormants++;\n      if (nFormants >= nF) break;\n    }\n  }\n  for (i = nFormants; i < nF; i++) {\n    fc[i] = 0.0; \n    if (bc != NULL) bc[i] = 0.0;\n  }\n  return nFormants;\n}\n\n/* converts an amplitude ratio to decibel (dB) \n     using the equation: 20*log10(a)\n   a must be > 0\n */ \ndouble smileDsp_amplitudeRatioToDB(double a)\n{\n  if (a > 10e-50) {\n    return 20.0 * log(a) / log(10.0);\n  } else {\n    return -1000.0;\n  }\n}\n\n\n\n/*******************************************************************************************\n ***********************=====   Statistics functions   ===== *******************************\n *******************************************************************************************/\n\n/*\nNote: the entropy functions compute entropy from a PMF, thus a sequence of values must be converted to a PMF beforehand!\nFor spectral entropy the normalised spectrum is assumed to be a PMF, thus it is not converted...\n*/\n\nconst double entropy_floor = 0.0000001;\n\n/* compute entropy of normalised values (the values will be normalised to represent probabilities by this function) */\nFLOAT_DMEM smileStat_entropy(const FLOAT_DMEM *vals, long N)\n{\n  double e = 0.0;\n  int i;\n  double dn = 0.0;\n  FLOAT_DMEM min=0.0;\n  double l2 = (double)log(2.0);\n  // get sum of values and minimum value\n  for (i=0; i<N; i++) {\n    dn += (double)vals[i];\n    if (vals[i] < min) min = vals[i];\n  }\n  // add minimum to values, if minimum is < 0\n  if (min < 0.0) {\n    double mf = entropy_floor + min;\n    for (i=0; i<N; i++) {\n      //vals[i] -= min;\n      if (vals[i] <= mf) {\n        //vals[i] = (FLOAT_DMEM)entropy_floor;\n        dn += mf - vals[i];\n      }\n      dn -= (double)min;\n    }\n  } else {\n    min = 0.0;\n  }\n  if (dn < (FLOAT_DMEM)entropy_floor) {\n    dn = (FLOAT_DMEM)entropy_floor;\n  }\n  // normalise sample values and compute entropy\n  for (i=0; i<N; i++) {\n    double v = vals[i] - min;\n    double ln;\n    if (v <= entropy_floor) {\n      v = entropy_floor;\n    }\n    ln = v / dn;\n    if (ln > 0.0) {\n      e += ln * (double)log(ln) / l2;\n    }\n  }\n  return (FLOAT_DMEM)(-e);\n}\n\n/* compute entropy of normalised values (the values will be normalised to represent probabilities by this function) */\n// ??? difference to normal entropy ???\nFLOAT_DMEM smileStat_relativeEntropy(const FLOAT_DMEM *vals, long N)\n{\n  double e = 0.0;\n  int i;\n  double dn = 0.0;\n  FLOAT_DMEM min=0.0;\n  double lnorm = (double)log((double)N);\n  // get sum of values and minimum value\n  for (i=0; i<N; i++) {\n    dn += (double)vals[i];\n    if (vals[i] < min) min = vals[i];\n  }\n  // add minimum to values, if minimum is < 0\n  if (min < 0.0) {\n    double mf = entropy_floor + min;\n    for (i=0; i<N; i++) {\n      //vals[i] -= min;\n      if (vals[i] <= mf) {\n        //vals[i] = (FLOAT_DMEM)entropy_floor;\n        dn += mf - vals[i];\n      }\n      dn -= (double)min;\n    }\n  } else {\n    min = 0.0;\n  }\n  if (dn < (FLOAT_DMEM)entropy_floor) {\n    dn = (FLOAT_DMEM)entropy_floor;\n  }\n  // normalise sample values and compute entropy\n  for (i=0; i<N; i++) {\n    double v = vals[i] - min;\n    double ln;\n    if (v <= entropy_floor) {\n      v = entropy_floor;\n    }\n    ln = v / dn;\n    if (ln > 0.0) \n      e += ln * (double)log(ln) / lnorm;\n  }\n  return (FLOAT_DMEM)(-e);\n}\n\n\n/* TODO:\ncompute a PMF from a sample sequence using a histogram sampling method\n\nif a valid pointer is given in h->bins, then the histogram will be added to the existing data,\nthe resulting histogram will then be unnormalised, you will have to call smileMath_vectorNormEuc in the end..\n--TODO: this is not the correct way of handling things....! We must normalise both histograms, add and divide by 2\n--actually the input histogram is normalised.. so we only divide by 2\n\nif h->bins is NULL the histogram will be initialised with zeros and the output will be normalised.\n\nthe memory pointed to by *h must be initialised with 0s! (at least h->bins must be NULL...)\n\nset range to 0.0 to automatically have it determined from the data (max-min)\n*/\nvoid smileStat_getPMF(FLOAT_DMEM *_vals, long N, sHistogram *h)\n{\n  long i; long x; int renorm=0;\n  //double sum=(double)_vals[0];\n  FLOAT_DMEM min=_vals[0];\n  FLOAT_DMEM max=_vals[0];\n  FLOAT_DMEM p = (FLOAT_DMEM)(1.0/(double)N);\n\n  if (h == NULL) return;\n\n  if (h->Nbins == 0) h->Nbins = 1000;\n  if (h->bins == NULL) {\n    h->bins = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*h->Nbins);\n    if ((h->min == 0.0) && (h->max == 0.0)) {\n      // get sum of values and min/max value\n      for (i=1; i<N; i++) {\n        //sum += (double)_vals[i];\n        if (_vals[i] < min) min = _vals[i];\n        if (_vals[i] > max) max = _vals[i];\n      }\n      h->max = max;\n      h->min = min;\n    }\n    h->stepsize = (h->max - h->min) / (FLOAT_DMEM)(h->Nbins);\n    //printf(\"stepsize = %f  min = %f  max=%f (_vals0=%f)\\n\",h->stepsize,h->min, h->max,_vals[0]);\n  } else {\n    renorm = 1;\n  }\n  \n  if (renorm && (h->weight > 1.0)) {\n    for (i=0; i<h->Nbins; i++) {\n      h->bins[i] *= h->weight;\n    }\n    p = 1.0;\n  }\n\n  for (i=0; i<N; i++) {\n    x = (long)floor((_vals[i] - h->min)/h->stepsize);\n    if (x<0) x = 0;  /* range clipping*/\n    else if (x>=h->Nbins) x=h->Nbins-1; /* range clipping*/\n    h->bins[x] += p;\n  }\n\n  if (renorm) {\n    if (h->weight > 1.0) {\n      h->weight += (FLOAT_DMEM)N;\n      for (i=0; i<h->Nbins; i++) {\n        h->bins[i] /= h->weight;\n      }\n    } else {\n      for (i=0; i<h->Nbins; i++) {\n        h->bins[i] /= 2.0;\n      }\n    }\n  } else {\n    h->weight = (FLOAT_DMEM)N;\n  }\n}\n\n/* Estimate the probability of a value x belonging to a given pmf h (the pmf must be normalised to sum 1!) */\nFLOAT_DMEM smileStat_probEstim(FLOAT_DMEM x, sHistogram *h, FLOAT_DMEM probFloor)\n{\n  long i = (long)floor((x - h->min)/h->stepsize);\n  FLOAT_DMEM ret;\n  if (h==NULL) return 0.0;\n  if (i>=h->Nbins) return 0.0;\n  if (i<0) return 0.0;\n  // TODO: interpolate actual value more accurately by considering neighbour probabilities\n  ret = MAX(h->bins[i],probFloor);\n  if (ret > 1.0) {\n#ifdef DEBUG\n    fprintf(\"WARNING: Clipped probability to 1.0 in smileStat_probEstim (%f) (probFloor = %f)\\n\",ret,probFloor);\n#endif\n    ret = 1.0; // perform clipping\n  }\n  return ret;\n}\n\n/* get a PMF vector from a data matrix (result is a pmf histogram for each row of the matrix) */\n/* *h must point to an allocated array of R x sHistogram */\n/* N: number of colums in matrix  , R: number of rows in the matrix (must match the size of *h) */\n/* matrix in _vals is read rowwise.. cMatrix in openSMILE is read columnwise, so you must transpose here!*/\nvoid smileStat_getPMFvec(FLOAT_DMEM *_vals, long N, long R, sHistogram *h)\n{\n  long i;\n  if (h== NULL) return;\n  if (_vals == NULL) return;\n  for (i=0; i<R; i++) {\n    smileStat_getPMF(_vals+(N*i), N, h+i);\n  }\n}\n\n/* get a PMF vector from a data matrix (result is a pmf histogram for each row of the matrix) */\n/* *h must point to an allocated array of R x sHistogram */\n/* N: number of colums in matrix  , R: number of rows in the matrix (must match the size of *h) */\n/* matrix in _vals is read columnwise.. use this for compatiblity with openSMILE cMatrix!*/\nvoid smileStat_getPMFvecT(FLOAT_DMEM *_vals, long N, long R, sHistogram *h)\n{\n  long i,n;\n  FLOAT_DMEM *_row;\n  if (h== NULL) return;\n  if (_vals == NULL) return;\n  _row = (FLOAT_DMEM *)malloc(sizeof(FLOAT_DMEM)*N);\n  for (i=0; i<R; i++) {\n    for (n=0; n<N; n++) {\n      _row[n] = _vals[n*R+i];\n    }\n    smileStat_getPMF(_row, N, h+i);\n  }\n}\n\n/* estimate probability of a vector belonging to a pmf array */\nvoid smileStat_probEstimVec(FLOAT_DMEM *x, sHistogram *h, FLOAT_DMEM **p, long R, FLOAT_DMEM probFloor)\n{\n  long i;\n  if (x==NULL) return;\n  if (h==NULL) return;\n  if (p==NULL) return;\n  \n  if (*p==NULL) \n     *p = (FLOAT_DMEM*)calloc(1,sizeof(FLOAT_DMEM)*R);\n\n  for (i=0; i<R; i++) {\n    (*p)[i] = smileStat_probEstim(x[i], h+i, probFloor);\n  }\n}\n\n/* estimate probability of a vector belonging to a pmf array */\nFLOAT_DMEM smileStat_probEstimVecLin(FLOAT_DMEM *x, sHistogram *h, long R, FLOAT_DMEM probFloor)\n{\n  FLOAT_DMEM *p = NULL;\n  FLOAT_DMEM P = 1.0;\n  long i;\n  smileStat_probEstimVec(x,h,&p,R,probFloor);\n  for (i=0; i<R; i++) {\n    P *= p[i];\n  }\n  //P/=(FLOAT_DMEM)R;\n  if (p!=NULL) free(p);\n  return MAX(P,probFloor);\n}\n\n/* estimate probability of a vector belonging to a pmf array */\nFLOAT_DMEM smileStat_probEstimVecLog(FLOAT_DMEM *x, sHistogram *h, long R, FLOAT_DMEM probFloorLog)\n{\n  FLOAT_DMEM *p = NULL;\n  FLOAT_DMEM P = 1.0;\n  long i;\n  smileStat_probEstimVec(x,h,&p,R,0.0);\n  for (i=0; i<R; i++) {\n    if (p[i] < exp(probFloorLog)) P += probFloorLog;\n    else P += (FLOAT_DMEM)log(p[i]);\n  }\n  if (p!=NULL) free(p);\n  return MAX(P,probFloorLog);\n}\n\n/*******************************************************************************************\n ***********************=====   WAVE file I/O   ===== **************************************\n *******************************************************************************************/\n\n\n/* WAVE Header struct, valid only for PCM Files */\ntypedef struct {\n  uint32_t\tRiff;    /* Must be little endian 0x46464952 (RIFF) */\n  uint32_t\tFileSize;\n  uint32_t\tFormat;  /* Must be little endian 0x45564157 (WAVE) */\n\n  uint32_t\tSubchunk1ID;  /* Must be little endian 0x20746D66 (fmt ) */\n  uint32_t\tSubchunk1Size;\n  uint16_t\tAudioFormat;\n  uint16_t\tNumChannels;\n  uint32_t\tSampleRate;\n  uint32_t\tByteRate;\n  uint16_t\tBlockAlign;\n  uint16_t\tBitsPerSample;\n\n  uint32_t\tSubchunk2ID;  /* Must be little endian 0x61746164 (data) */\n  uint32_t  Subchunk2Size;\n} sRiffPcmWaveHeader;\n\ntypedef struct {\n  uint32_t SubchunkID;\n  uint32_t SubchunkSize;\n} sRiffChunkHeader;\n\n\n/* parse wave header from in-memory wave file pointed to by *raw */\nint smilePcm_parseWaveHeader(void *raw, long long N, sWaveParameters *pcmParam)\n{\n  if ((raw != NULL)&&(pcmParam!=NULL)) {\n    long long nRead;\n    sRiffPcmWaveHeader *head;\n    sRiffChunkHeader *chunkhead;\n    int safetytimeout = 20;  // max <safetytimeout> chunks of 99kb size before 'data' chunk\n    long long ptr = 0;\n\n    head = (sRiffPcmWaveHeader *)raw;\n    nRead = sizeof(sRiffPcmWaveHeader);\n    if (N<nRead) nRead=N;\n    raw = (char*)raw + nRead;\n    ptr += nRead;\n    if (nRead != sizeof(sRiffPcmWaveHeader)) {\n      printf(\"smilePcm: Error reading %i bytes (header) from beginning of wave data! The given array is too short (N=%i)!\",sizeof(sRiffPcmWaveHeader),(long)N);\n      return 0;\n    }\n\n    /* Check for valid header , TODO: support other endianness */\n\tif ((head->Riff != 0x46464952) ||\n\t\t(head->Format != 0x45564157) ||\n\t\t(head->Subchunk1ID != 0x20746D66) ||\n//\t\t(head->Subchunk2ID != 0x61746164) ||\n\t\t(head->AudioFormat != 1) ||\n\t\t(head->Subchunk1Size != 16)) {\n                            fprintf(stderr,\"smilePcm:  Riff: %x\\n  Format: %x\\n  Subchunk1ID: %x\\n  Subchunk2ID: %x\\n  AudioFormat: %x\\n  Subchunk1Size: %x\",\n                                        head->Riff, head->Format, head->Subchunk1ID, head->Subchunk2ID, head->AudioFormat, head->Subchunk1Size);\n                            fprintf(stderr,\"smilePcm: bogus wave/riff header or data/file in wrong format!\");\n                            return 0;\n        }\n\n    while ((head->Subchunk2ID != 0x61746164)&&(safetytimeout>0)) { // 0x61746164 = 'data'\n      // keep searching for 'data' chunk:\n      if (head->Subchunk2Size < 99999) {\n        //char * tmp = (char*)malloc(head->Subchunk2Size);\n        //nRead = (int)fread(tmp, 1, head->Subchunk2Size, filehandle);\n        //nRead = head->Subchunk2Size + ...;\n        char * tmp = (char *)raw; \n        raw = (char * )raw + head->Subchunk2Size;\n        ptr += head->Subchunk2Size; \n        if (ptr > N) {\n          fprintf(stderr,\"smilePcm: less bytes read from wave data than indicated by Subchunk2Size (%i)! File seems broken!\\n\",head->Subchunk2Size);\n          return 0;\n        }\n        free(tmp);\n      } else {\n        fprintf(stderr,\"smilePcm: Subchunk2Size > 99999. This seems to be a bogus file!\\n\");\n        return 0;\n      }\n      chunkhead = (sRiffChunkHeader *)raw;\n      raw = (char*)raw + sizeof(sRiffChunkHeader);\n      ptr += sizeof(sRiffChunkHeader);\n      //nRead = (int)fread(&chunkhead, 1, sizeof(chunkhead), filehandle);\n      if (ptr > N) {\n        fprintf(stderr,\"smilePcm: less bytes read from wave data than there should be (%i) while reading sub-chunk header! File seems broken!\\n\",sizeof(sRiffChunkHeader));\n        return 0;\n      }\n      head->Subchunk2ID = chunkhead->SubchunkID;\n      head->Subchunk2Size = chunkhead->SubchunkSize;\n      safetytimeout--;\n    }\n    if (safetytimeout <= 0) {\n      fprintf(stderr,\"smilePcm: No 'data' subchunk found in wave-file among the first %i chunks! corrupt file?\\n\",safetytimeout);\n      return 0;\n    }\n    \n    pcmParam->sampleRate = head->SampleRate;\n    pcmParam->nChan = head->NumChannels;\n    pcmParam->nBPS = head->BlockAlign/head->NumChannels;\n    pcmParam->nBits = head->BitsPerSample;\n    pcmParam->nBlocks = head->Subchunk2Size / head->BlockAlign;\n    pcmParam->blockSize = head->BlockAlign;\n\n    // TODO: ???\n    pcmParam->byteOrder = BYTEORDER_LE;\n    pcmParam->memOrga = MEMORGA_INTERLV;\n     \n    return 1;\n\n  }\n  return 0;\n}\n\n// filename is optional and can be NULL ! It is used only for log messages.\nint smilePcm_readWaveHeader(FILE *filehandle, sWaveParameters *pcmParam, const char *filename)\n{\n  if (filename == NULL) filename = \"unknown\";\n\n  if ((filehandle != NULL)&&(pcmParam!=NULL)) {\n\n    int nRead;\n    sRiffPcmWaveHeader head;\n    sRiffChunkHeader chunkhead;\n    int safetytimeout = 20;  // max <safetytimeout> chunks of 99kb size before 'data' chunk\n\n    fseek(filehandle, 0, SEEK_SET);\n    nRead = (int)fread(&head, 1, sizeof(head), filehandle);\n    if (nRead != sizeof(head)) {\n      printf(\"smilePcm: Error reading %i bytes (header) from beginning of wave file '%s'! File too short??\",sizeof(head),filename);\n      return 0;\n    }\n    \n    /* Check for valid header , TODO: support other endianness */\n    if ((head.Riff != 0x46464952) ||\n        (head.Format != 0x45564157) ||\n        (head.Subchunk1ID != 0x20746D66) ||\n//      (head.Subchunk2ID != 0x61746164) ||\n        (head.AudioFormat != 1) ||   // 32-bit: 0xfffe\n        (head.Subchunk1Size != 16)) {  // 32-bit: 28\n          fprintf(stderr,\"smilePcm:  Riff: %x\\n  Format: %x\\n  Subchunk1ID: %x\\n  Subchunk2ID: %x\\n  AudioFormat: %x\\n  Subchunk1Size: %x\",\n                  head.Riff, head.Format, head.Subchunk1ID, head.Subchunk2ID, head.AudioFormat, head.Subchunk1Size);\n          fprintf(stderr,\"smilePcm: bogus wave/riff header or file in wrong format ('%s')! (maybe you are trying to read a 32-bit wave file which is not yet supported (new header type...)?)\",filename);\n          return 0;\n        }\n\n    while ((head.Subchunk2ID != 0x61746164)&&(safetytimeout>0)) { // 0x61746164 = 'data'\n      // keep searching for 'data' chunk:\n      if (head.Subchunk2Size < 99999) {\n        char * tmp = (char*)malloc(head.Subchunk2Size);\n        nRead = (int)fread(tmp, 1, head.Subchunk2Size, filehandle);\n        if (nRead != head.Subchunk2Size) {\n          fprintf(stderr,\"smilePcm: less bytes read (%i) from wave file '%s' than indicated by Subchunk2Size (%i)! File seems broken!\\n\",nRead,filename,head.Subchunk2Size);\n          return 0;\n        }\n        free(tmp);\n      } else {\n        fprintf(stderr,\"smilePcm: Subchunk2Size > 99999. This seems to be a bogus file!\\n\");\n        return 0;\n      }\n      nRead = (int)fread(&chunkhead, 1, sizeof(chunkhead), filehandle);\n      if (nRead != sizeof(chunkhead)) {\n        fprintf(stderr,\"smilePcm: less bytes read (%i) from wave file '%s' than there should be (%i) while reading sub-chunk header! File seems broken!\\n\",nRead,filename,sizeof(chunkhead));\n        return 0;\n      }\n      head.Subchunk2ID = chunkhead.SubchunkID;\n      head.Subchunk2Size = chunkhead.SubchunkSize;\n      safetytimeout--;\n    }\n    if (safetytimeout <= 0) {\n      fprintf(stderr,\"smilePcm: No 'data' subchunk found in wave-file among the first %i chunks! corrupt file?\\n\",safetytimeout);\n      return 0;\n    }\n    \n    pcmParam->sampleRate = head.SampleRate;\n    pcmParam->nChan = head.NumChannels;\n    pcmParam->nBPS = head.BlockAlign/head.NumChannels;\n    pcmParam->nBits = head.BitsPerSample;\n//    p->bits = head.BitsPerSample;\n//    SMILE_DBG(5,\"bits per sample = %i\",head.BitsPerSample);\n//    pcmParam.sampleType = pcmBitsToSampleType( head.BitsPerSample, BYTEORDER_LE, 0 );\n/*\n    if (head.NumChannels * head.BitsPerSample / 8 != head.BlockAlign) {\n      FEATUM_ERR_FATAL(0,\"Error reading wave file header: head.BlockAlign != head.NumChannels * head.BitsPerSample / 8\");\n      return 0;\n    }\n    */\n    pcmParam->nBlocks = head.Subchunk2Size / head.BlockAlign;\n    pcmParam->blockSize = head.BlockAlign;\n    pcmParam->byteOrder = BYTEORDER_LE;\n    pcmParam->memOrga = MEMORGA_INTERLV;\n    pcmParam->headerOffset = ftell(filehandle);\n    return 1;\n  }\n  return 0;\n}\n\n// Converts integer PCM sample values to float sample values in [-1,+1].\n// nChan is the number of channels allocated in *a.\n// Requires nBits, nBPS, and nChan in pcmParam\nint smilePcm_convertSamples(uint8_t *buf, sWaveParameters *pcmParam, float *a, int nChan, int nSamples, int monoMixdown)\n{\n  int i,c;\n  #define smilePcm_setFMatrix(xx_a,xx_nChan,xx_c,xx_s,xx_val) xx_a[xx_nChan * xx_s + xx_c] = xx_val;\n\n  int8_t *b8=(int8_t*)buf;\n  uint8_t *bu8=(uint8_t*)buf;\n  int16_t *b16 = (int16_t*)buf;\n  int32_t *b32 = (int32_t*)buf;\n\n  if (a==NULL) return 0;\n  if (pcmParam==NULL) return 0;\n  if (buf==NULL) return 0;\n\n  // TODO: add selectChannel option to select a single channel from multi-channel instead of monoMixdown\n  if (monoMixdown) {\n    switch(pcmParam->nBPS) {\n      case 1: // 8-bit int\n        for (i=0; i<nSamples; i++) {\n          float tmp = 0.0;\n          for (c=0; c<pcmParam->nChan; c++) {\n            tmp += (float)b8[i*pcmParam->nChan+c];\n          }\n          smilePcm_setFMatrix(a,nChan,0,i,(tmp/(float)pcmParam->nChan)/(float)127.0);\n        }\n        break;\n      case 2: // 16-bit int\n        for (i=0; i<nSamples; i++) {\n          float tmp = 0.0;\n          for (c=0; c<pcmParam->nChan; c++) {\n            tmp += (float)b16[i*pcmParam->nChan+c];\n          }\n          smilePcm_setFMatrix(a,nChan,0,i,(tmp/(float)pcmParam->nChan)/(float)32767.0);\n        }\n        break;\n      case 3: // 24-bit int\n        for (i=0; i<nSamples; i++) {\n          float tmp = 0.0;\n          for (c=0; c<pcmParam->nChan; c++) {\n            // the only known file with 3bytes was exported by matlab\n            // a byte order conversion was necessary here.. is that always the case?? FIXME!\n            uint32_t is=0;\n            int32_t * iis;\n            is |= (uint32_t)(bu8[(i*pcmParam->nChan+c)*3])<<8;\n            is |= (uint32_t)(bu8[(i*pcmParam->nChan+c)*3+1])<<16;\n            is |= (uint32_t)(bu8[(i*pcmParam->nChan+c)*3+2])<<24;\n            iis = (int32_t*)&is;\n            tmp += (float)(*iis >> 8);\n          }\n          smilePcm_setFMatrix(a,nChan,0,i,(tmp/(float)pcmParam->nChan)/(float)(32767.0*256.0));\n        }\n        break;\n      case 4: // 32-bit int or 24-bit packed int\n        if (pcmParam->nBits == 24) {\n          for (i=0; i<nSamples; i++) {\n            float tmp = 0.0;\n            for (c=0; c<pcmParam->nChan; c++) {\n              tmp += (float)(b32[i*pcmParam->nChan+c]&0xFFFFFF);\n            }\n            smilePcm_setFMatrix(a,nChan,0,i,(tmp/(float)pcmParam->nChan)/(float)(32767.0*256.0));\n          }\n        } else if (pcmParam->nBits == 32) {\n          for (i=0; i<nSamples; i++) {\n            float tmp = 0.0;\n            for (c=0; c<pcmParam->nChan; c++) {\n              tmp += (float)(b32[i*pcmParam->nChan+c]);\n            }\n            smilePcm_setFMatrix(a,nChan,0,i,(tmp/(float)pcmParam->nChan)/(float)(32767.0*32767.0*2.0));\n          }\n        }\n        break;\n      default:\n        fprintf(stderr,\"smilePcm: readData: cannot convert unknown sample format to float! (nBPS=%i, nBits=%i)\",pcmParam->nBPS,pcmParam->nBits);\n        fflush(stderr);\n        break;\n    }\n\n  } else { // no mixdown, multi-channel matrix output\n    if (nChan != pcmParam->nChan) {\n      fprintf(stderr, \"ERROR: smilePcm: if not using monomixdown option, the number of channels in the wave file (pcmData.nChan) must match the number of channels in the data matrix (nChan)!\\n\");\n      return 0;\n    }\n    switch(pcmParam->nBPS) {\n      case 1: // 8-bit int\n        for (i=0; i<nSamples; i++) for (c=0; c<pcmParam->nChan && c < nChan; c++) {\n          smilePcm_setFMatrix(a,nChan,c,i,((float)b8[i*pcmParam->nChan+c])/(float)127.0);\n        } break;\n      case 2: // 16-bit int\n        for (i=0; i<nSamples; i++) for (c=0; c<pcmParam->nChan && c < nChan; c++) {\n          smilePcm_setFMatrix(a,nChan,c,i,((float)b16[i*pcmParam->nChan+c])/(float)32767.0);\n        } break;\n      case 3: // 24-bit int\n        for (i=0; i<nSamples; i++) {\n            float tmp = 0.0;\n            for (c=0; c<pcmParam->nChan && c < nChan; c++) {\n              // the only known file with 3bytes was exported by matlab\n              // a byte order conversion was necessary here.. is that always the case?? FIXME!\n              uint32_t is=0;\n              int32_t * iis;\n              is |= (uint32_t)(bu8[(i*pcmParam->nChan+c)*3])<<8;\n              is |= (uint32_t)(bu8[(i*pcmParam->nChan+c)*3+1])<<16;\n              is |= (uint32_t)(bu8[(i*pcmParam->nChan+c)*3+2])<<24;\n              iis = (int32_t*)&is;\n              tmp = (float)(*iis >> 8);\n              smilePcm_setFMatrix(a,nChan,c,i,(tmp)/(float)(32767.0*256.0));\n            }\n          }\n        break;\n      case 4: // 32-bit int or 24-bit packed int\n        if (pcmParam->nBits == 24) {\n          for (i=0; i<nSamples; i++) for (c=0; c<pcmParam->nChan && c < nChan; c++) {\n            smilePcm_setFMatrix(a,nChan,c,i,((float)(b32[i*pcmParam->nChan+c]&0xFFFFFF))/(float)(32767.0*32767.0*2.0));\n          } break;\n        } else if (pcmParam->nBits == 32) {\n          for (i=0; i<nSamples; i++) for (c=0; c<pcmParam->nChan && c < nChan; c++) {\n            smilePcm_setFMatrix(a,nChan,c,i,((float)b32[i*pcmParam->nChan+c])/(float)(32767.0*32767.0*2.0));\n          } break;\n        }\n\n      default:\n        fprintf(stderr,\"smilePcm: readData: cannot convert unknown sample format to float! (nBPS=%i, nBits=%i)\",pcmParam->nBPS,pcmParam->nBits);\n        fflush(stderr);\n    }\n  }\n  return nSamples;\n}\n\n// Reads pcm data from a filehandle and converts it to float array with value range -1 to +1.\n// Return value: -1 eof, 0 error, > 0 , num samples read\nint smilePcm_readSamples(FILE **filehandle, sWaveParameters *pcmParam, float *a, int nChan, int nSamples, int monoMixdown)\n{\n  // reads data into matix m, size is determined by m, also performs format conversion to float samples and matrix format\n  int bs, nRead;\n  uint8_t *buf;\n\n  if (filehandle==NULL) return -1;\n  if (*filehandle==NULL) return 0;\n  if (a==NULL) return 0;\n  if (pcmParam==NULL) return 0;\n  if (feof(*filehandle)) {\n    return -1;\n  }\n  \n  bs = pcmParam->blockSize * nSamples;\n  buf = (uint8_t *)malloc(bs);\n  if (buf==NULL) return 0;\n\n  nRead = (int)fread(buf, 1, bs, *filehandle);\n  if (nRead != bs) {\n    nSamples = nRead / pcmParam->blockSize; // int div rounds down..!? it should better do so...\n    // Close files, as we assume EOF here...\n    fclose(*filehandle); *filehandle = NULL;\n  }\n  if (nRead > 0) {\n    nSamples = smilePcm_convertSamples(buf, pcmParam, a, nChan, nSamples, monoMixdown);\n  }\n  free(buf);\n  return nSamples;\n}\n\n#if 0 // old version\n//return : -1 eof, 0 error, > 0 , num samples read\nint smilePcm_readSamples(FILE **filehandle, sWaveParameters *pcmParam, float *a, int nChan, int nSamples, int monoMixdown)\n{\n  #define SETF(c,s,val) a[nChan*s+c]=val;\n\n// reads data into matix m, size is determined by m, also performs format conversion to float samples and matrix format\n//int cWaveSource::readData(cMatrix *m)\n//{\n  int bs, nRead;\n  uint8_t *buf;\n\n  if (filehandle==NULL) return -1;\n  if (*filehandle==NULL) return 0;\n  if (a==NULL) return 0;\n  if (pcmParam==NULL) return 0;\n  if (feof(*filehandle)) {\n    //fprintf(stderr,\"smilePcm: not reading from file, already EOF\");\n    return -1;\n  }\n\n  bs = pcmParam->blockSize * nSamples;\n  buf = (uint8_t *)malloc(bs);\n\n  if (buf==NULL) return 0;\n  nRead = (int)fread(buf, 1, bs, *filehandle);\n  if (nRead != bs) {\n    nSamples = nRead / pcmParam->blockSize; // int div rounds down..!? it should better do so...\n    fclose(*filehandle); *filehandle = NULL;\n  }\n\n  if (nRead > 0) {\n\n    int i,c;\n    int8_t *b8=(int8_t*)buf;\n    uint8_t *bu8=(uint8_t*)buf;\n    int16_t *b16 = (int16_t*)buf;\n    int32_t *b32 = (int32_t*)buf;\n\n    if (monoMixdown) {\n\n      switch(pcmParam->nBPS) {\n        case 1: // 8-bit int\n          for (i=0; i<nSamples; i++) {\n            float tmp = 0.0;\n            for (c=0; c<pcmParam->nChan; c++) {\n              tmp += (float)b8[i*pcmParam->nChan+c];\n            }\n            SETF(0,i,(tmp/(float)pcmParam->nChan)/(float)127.0);\n          }\n          break;\n        case 2: // 16-bit int\n          for (i=0; i<nSamples; i++) {\n            float tmp = 0.0;\n            for (c=0; c<pcmParam->nChan; c++) {\n              tmp += (float)b16[i*pcmParam->nChan+c];\n            }\n            SETF(0,i,(tmp/(float)pcmParam->nChan)/(float)32767.0);\n          }\n          break;\n        case 3: // 24-bit int\n\n          for (i=0; i<nSamples; i++) {\n              float tmp = 0.0;\n              for (c=0; c<pcmParam->nChan; c++) {\n                // the only known file with 3bytes was exported by matlab\n                // a byte order conversion was necessary here.. is that always the case?? FIXME!\n                uint32_t is=0;\n                int32_t * iis;\n                is |= (uint32_t)(bu8[(i*pcmParam->nChan+c)*3])<<8;\n                is |= (uint32_t)(bu8[(i*pcmParam->nChan+c)*3+1])<<16;\n                is |= (uint32_t)(bu8[(i*pcmParam->nChan+c)*3+2])<<24;\n                iis = (int32_t*)&is;\n                tmp += (float)(*iis >> 8);\n              }\n              SETF(0,i,(tmp/(float)pcmParam->nChan)/(float)(32767.0*256.0));\n            }\n\n          break;\n        case 4: // 32-bit int or 24-bit packed int\n          if (pcmParam->nBits == 24) {\n            for (i=0; i<nSamples; i++) {\n              float tmp = 0.0;\n              for (c=0; c<pcmParam->nChan; c++) {\n                tmp += (float)(b32[i*pcmParam->nChan+c]&0xFFFFFF);\n              }\n              SETF(0,i,(tmp/(float)pcmParam->nChan)/(float)(32767.0*256.0));\n            }\n            break;\n          } else if (pcmParam->nBits == 32) {\n            for (i=0; i<nSamples; i++) {\n              float tmp = 0.0;\n              for (c=0; c<pcmParam->nChan; c++) {\n                tmp += (float)(b32[i*pcmParam->nChan+c]);\n              }\n              SETF(0,i,(tmp/(float)pcmParam->nChan)/(float)(32767.0*32767.0*2.0));\n            }\n            break;\n        }\n        default:\n          fprintf(stderr,\"smilePcm: readData: cannot convert unknown sample format to float! (nBPS=%i, nBits=%i)\",pcmParam->nBPS,pcmParam->nBits);\n          nRead=0;\n      }\n\n    } else { // no mixdown, multi-channel matrix output\n\n      switch(pcmParam->nBPS) {\n        case 1: // 8-bit int\n          for (i=0; i<nSamples; i++) for (c=0; c<pcmParam->nChan; c++) {\n            SETF(c,i,((float)b8[i*pcmParam->nChan+c])/(float)127.0);\n          } break;\n        case 2: // 16-bit int\n          for (i=0; i<nSamples; i++) for (c=0; c<pcmParam->nChan; c++) {\n            SETF(c,i,((float)b16[i*pcmParam->nChan+c])/(float)32767.0);\n          } break;\n        case 3: // 24-bit int\n          for (i=0; i<nSamples; i++) {\n              float tmp = 0.0;\n              for (c=0; c<pcmParam->nChan; c++) {\n                // the only known file with 3bytes was exported by matlab\n                // a byte order conversion was necessary here.. is that always the case?? FIXME!\n                uint32_t is=0;\n                int32_t * iis;\n                is |= (uint32_t)(bu8[(i*pcmParam->nChan+c)*3])<<8;\n                is |= (uint32_t)(bu8[(i*pcmParam->nChan+c)*3+1])<<16;\n                is |= (uint32_t)(bu8[(i*pcmParam->nChan+c)*3+2])<<24;\n                iis = (int32_t*)&is;\n                tmp = (float)(*iis >> 8);\n                SETF(c,i,(tmp)/(float)(32767.0*256.0));\n              }\n            }\n          break;\n        case 4: // 32-bit int or 24-bit packed int\n          if (pcmParam->nBits == 24) {\n            for (i=0; i<nSamples; i++) for (c=0; c<pcmParam->nChan; c++) {\n              SETF(c,i,((float)(b32[i*pcmParam->nChan+c]&0xFFFFFF))/(float)(32767.0*32767.0*2.0));\n            } break;\n          } else if (pcmParam->nBits == 32) {\n            for (i=0; i<nSamples; i++) for (c=0; c<pcmParam->nChan; c++) {\n              SETF(c,i,((float)b32[i*pcmParam->nChan+c])/(float)(32767.0*32767.0*2.0));\n            } break;\n          }\n\n        default:\n          fprintf(stderr,\"smilePcm: readData: cannot convert unknown sample format to float! (nBPS=%i, nBits=%i)\",pcmParam->nBPS,pcmParam->nBits);\n          nRead=0;\n      }\n    }\n  }\n  free(buf);\n  return nSamples; //(nRead>0);\n}\n#endif\n\n/*void smilePcm_setFMatrix(float* m, int nChan, int c, int s, float val)\n{\n  m[nChan*s+c]=val;\n}*/\n\n/*******************************************************************************************\n *******************=====   Vector save/load debug helpers   ===== *************************\n *******************************************************************************************/\n\n/* these functions are not safe and should only be used for data output during debugging ! */\n\n#include <stdio.h>\n\nvoid saveDoubleVector_csv(const char * filename, double * vec, long N, int append)\n{\n  FILE * f = NULL;\n  if (append)\n    f = fopen(filename,\"a\");\n  else\n    f = fopen(filename,\"w\");\n\n  if (f!=NULL) {\n    long i;\n    for (i=0; i<N-1; i++) \n      fprintf(f, \"%f,\", vec[i]);\n    fprintf(f, \"%f\\n\", vec[i]);\n    fclose(f);\n  }\n}\n\nvoid saveFloatVector_csv(const char * filename, float * vec, long N, int append)\n{\n  FILE * f = NULL;\n  if (append)\n    f = fopen(filename,\"ab\");\n  else\n    f = fopen(filename,\"wb\");\n\n  if (f!=NULL) {\n    long i;\n    for (i=0; i<N-1; i++) \n      fprintf(f, \"%f,\", vec[i]);\n    fprintf(f, \"%f\\n\", vec[i]);\n    fclose(f);\n  }\n}\n\nvoid saveFloatDmemVector_csv(const char * filename, FLOAT_DMEM * vec, long N, int append)\n{\n  FILE * f = NULL;\n  if (append)\n    f = fopen(filename,\"ab\");\n  else\n    f = fopen(filename,\"wb\");\n\n  if (f!=NULL) {\n    long i;\n    for (i=0; i<N-1; i++) \n      fprintf(f, \"%f,\", vec[i]);\n    fprintf(f, \"%f\\n\", vec[i]);\n    fclose(f);\n  }\n}\n\n\nvoid saveDoubleVector_bin(const char * filename, double * vec, long N, int append)\n{\n  FILE * f = NULL;\n  if (append)\n    f = fopen(filename,\"ab\");\n  else\n    f = fopen(filename,\"wb\");\n\n  if (f!=NULL) {\n    fwrite(vec, sizeof(double)*N, 1, f);\n    fclose(f);\n  }\n}\n\nvoid saveFloatVector_bin(const char * filename, float * vec, long N, int append)\n{\n  FILE * f = NULL;\n  if (append)\n    f = fopen(filename,\"ab\");\n  else\n    f = fopen(filename,\"wb\");\n\n  if (f!=NULL) {\n    fwrite(vec, sizeof(float)*N, 1, f);\n    fclose(f);\n  }\n}\n\nvoid saveFloatDmemVector_bin(const char * filename, FLOAT_DMEM * vec, long N, int append)\n{\n  FILE * f = NULL;\n  if (append)\n    f = fopen(filename,\"ab\");\n  else\n    f = fopen(filename,\"wb\");\n\n  if (f!=NULL) {\n    fwrite(vec, sizeof(FLOAT_DMEM)*N, 1, f);\n    fclose(f);\n  }\n}\n\nvoid saveFloatDmemVectorWlen_bin(const char * filename, FLOAT_DMEM * vec, long N, int append)\n{\n  FILE * f = NULL;\n  if (append)\n    f = fopen(filename,\"ab\");\n  else\n    f = fopen(filename,\"wb\");\n\n  if (f!=NULL) {\n    FLOAT_DMEM Nf = (FLOAT_DMEM)N;\n    fwrite(&Nf, sizeof(FLOAT_DMEM), 1, f);\n    fwrite(vec, sizeof(FLOAT_DMEM)*N, 1, f);\n    fclose(f);\n  }\n}\n\n//** HTK \n\nstatic int smileHtk_vax = 0;\n\n__inline void smileHtk_Swap32 ( uint32_t *p )\n{\n  uint8_t temp,*q;\n  q = (uint8_t*) p;\n  temp = *q; *q = *( q + 3 ); *( q + 3 ) = temp;\n  temp = *( q + 1 ); *( q + 1 ) = *( q + 2 ); *( q + 2 ) = temp;\n}\n\n__inline void smileHtk_Swap16 ( uint16_t *p ) \n{\n  uint8_t temp,*q;\n  q = (uint8_t*) p;\n  temp = *q; *q = *( q + 1 ); *( q + 1 ) = temp;\n}\n\nvoid smileHtk_SwapFloat( float *p )\n{\n  uint8_t temp,*q;\n  q = (uint8_t*) p;\n  temp = *q; *q = *( q + 3 ); *( q + 3 ) = temp;\n  temp = *( q + 1 ); *( q + 1 ) = *( q + 2 ); *( q + 2 ) = temp;\n}\n\nvoid smileHtk_prepareHeader( sHTKheader *h )\n{\n  if ( smileHtk_vax ) {\n    smileHtk_Swap32 ( &(h->nSamples) );\n    smileHtk_Swap32 ( &(h->samplePeriod) );\n    smileHtk_Swap16 ( &(h->sampleSize) );\n    smileHtk_Swap16 ( &(h->parmKind) );\n  }\n}\n\nint smileHtk_readHeader(FILE *filehandle, sHTKheader *head)\n{\n  if (filehandle==NULL) return 0;\n  if (!fread(head, sizeof(sHTKheader), 1, filehandle)) {\n    SMILE_IERR(1,\"error reading HTK header from file.\");\n    return 0;\n  }\n  smileHtk_prepareHeader(head); // convert to host byte order\n  return 1;\n}\n\n#include <string.h>\n\nint smileHtk_writeHeader(FILE *filehandle, sHTKheader *_head)\n{\n  sHTKheader head;  // local copy, due to prepareHeader! we don't want to change 'header' variable!\n  if (filehandle==NULL) return 0;\n\n  // adjust endianness\n  memcpy(&head, _head, sizeof(sHTKheader));\n  smileHtk_prepareHeader(&head);\n\n  // seek to beginning of file:\n  fseek(filehandle, 0 , SEEK_SET);\n  \n  // write header:\n  if (!fwrite(&head, sizeof(sHTKheader), 1, filehandle)) {\n    SMILE_IERR(1,\"Error writing to htk feature file!\");\n    return 0;\n  }\n\n  return 1;\n}\n\nint smileHtk_IsVAXOrder ()\n{\n  short x;\n  unsigned char *pc;\n  pc = (unsigned char *) &x;\n  *pc = 1; *( pc + 1 ) = 0;\t\t\t// store bytes 1 0\n  smileHtk_vax = (x==1);\t  \t\t// does it read back as 1?\n  return smileHtk_vax; \n}\n"
  },
  {
    "path": "src/smileutil/smileUtilSpline.c",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  SmileUtilSpline\n    =========\n\ncontains modular DSP functions for splines\n\n*/\n\n#include <smileutil/smileUtilSpline.h>\n\nint smileMath_spline(const double *xval, const double *yval,\n  long N, double y1p, double ynp, double *y2, \n  double **workarea)\n{\n  long i = 0;\n  long j = 0;\n  double p = 0.0;\n  double qn = 0.0;\n  double sigma = 0.0;\n  double un = 0.0;\n  double *u = NULL;\n\n  if (workarea != NULL) {\n    u = *workarea;\n  }\n  if (u == NULL) {\n    u = (double*)calloc(1, sizeof(double) * (N - 1));\n  }\n  if (y1p > 0.99e30) {\n    u[0] = 0.0;\n    y2[0] = 0.0;\n  } else {\n    u[0] = (3.0 / (xval[1] - xval[0])) *\n        ((yval[1] - yval[0]) / (xval[1] - xval[0]) - y1p);\n    y2[0] = -0.5;\n  }\n\n  for (i = 1; i < N - 1; i++) {\n    sigma = (xval[i] - xval[i - 1]) / (xval[i + 1] - xval[i - 1]);\n    p = sigma * y2[i - 1] + 2.0;\n    y2[i] = (sigma - 1.0) / p;\n    u[i] = (yval[i + 1] - yval[i]) / (xval[i + 1] - xval[i])\n        - (yval[i] - yval[i - 1]) / (xval[i] - xval[i - 1]);\n    u[i] = 1.0 / p * (6.0 * u[i] / (xval[i + 1] - xval[i - 1])\n        - sigma * u[i - 1]);\n  }\n\n  if (ynp > 0.99e30) {\n    qn = 0.0; \n    un = 0.0;\n  } else {\n    un = (3.0 / (xval[N - 1] - xval[N - 2])) * (ynp - (yval[N - 1] - yval[N - 2]) \n           / (xval[N - 1] - xval[N - 2]));\n    qn = 0.5;\n  }\n\n  y2[N - 1] = (un - qn * u[N - 2]) \n               / (qn * y2[N - 2] + 1.0);\n  for (j = N - 2; j >= 0; j--) {\n    y2[j] = y2[j] * y2[j + 1] + u[j];\n  }\n\n  if (workarea == NULL) {\n    free(u);\n  } else {\n    *workarea = u;\n  }\n  return 1;\n}\n\nint smileMath_spline_FLOAT_DMEM(const FLOAT_DMEM *xval, const FLOAT_DMEM *yval,\n  long N, FLOAT_DMEM y1p, FLOAT_DMEM ynp, FLOAT_DMEM *y2,\n  FLOAT_DMEM **workarea)\n{\n  long i = 0;\n  long j = 0;\n  FLOAT_DMEM p = 0.0;\n  FLOAT_DMEM qn = 0.0;\n  FLOAT_DMEM sigma = 0.0;\n  FLOAT_DMEM un = 0.0;\n  FLOAT_DMEM *u = NULL;\n\n  if (workarea != NULL) {\n    u = *workarea;\n  }\n  if (u == NULL) {\n    u = (FLOAT_DMEM*)calloc(1, sizeof(FLOAT_DMEM) * (N - 1));\n  }\n  if (y1p > (FLOAT_DMEM)0.99e30) {\n    u[0] = (FLOAT_DMEM)0.0;\n    y2[0] = (FLOAT_DMEM)0.0;\n  } else {\n    u[0] = ((FLOAT_DMEM)3.0 / (xval[1] - xval[0]))\n        * ((yval[1] - yval[0]) / (xval[1] - xval[0]) - y1p);\n    y2[0] = (FLOAT_DMEM)-0.5;\n  }\n\n  for (i = 1; i < N - 1; i++) {\n    sigma = (xval[i] - xval[i - 1]) / (xval[i + 1] - xval[i - 1]);\n    p = sigma * y2[i - 1] + (FLOAT_DMEM)2.0;\n    y2[i] = (sigma - (FLOAT_DMEM)1.0) / p;\n    u[i] = (yval[i + 1] - yval[i]) / (xval[i + 1] - xval[i])\n        - (yval[i] - yval[i - 1]) / (xval[i] - xval[i - 1]);\n    u[i] = (FLOAT_DMEM)1.0 / p * ((FLOAT_DMEM)6.0 * u[i] / (xval[i + 1] - xval[i - 1])\n        - sigma * u[i - 1]);\n  }\n\n  if (ynp > (FLOAT_DMEM)0.99e30) {\n    qn = (FLOAT_DMEM)0.0;\n    un = (FLOAT_DMEM)0.0;\n  } else {\n    un = ((FLOAT_DMEM)3.0 / (xval[N - 1] - xval[N - 2])) * (ynp - (yval[N - 1] - yval[N - 2])\n           / (xval[N - 1] - xval[N - 2]));\n    qn = (FLOAT_DMEM)0.5;\n  }\n\n  y2[N - 1] = (un - qn * u[N - 2])\n               / (qn * y2[N - 2] + (FLOAT_DMEM)1.0);\n  for (j = N - 2; j >= 0; j--) {\n    y2[j] = y2[j] * y2[j + 1] + u[j];\n  }\n\n  if (workarea == NULL) {\n    free(u);\n  } else {\n    *workarea = u;\n  }\n  return 1;\n}\n\n/* smileMath_splint: \n    Does spline interpolation of y value for a given x value of function ya=f(xa).\n\n    xorig[1..n] and yorig[1..n] contain the function f to be interpolated,\n     --> yorig[i] = f(xorig[i]), where xorig[1] < xorig[2] < ... < xorig[n]\n    y2[1..n] is the output of smileMath_spline(...) above, which contains the second order derivatives.\n    N contains the length of both xorig and yorig arrays.\n    'x' holds the x position at which to interpolate *y = f(x)\n*/\nint smileMath_splint(const double *xorig, const double *yorig, const double *y2, long N,\n    double x, double *y)\n{\n  long klower = 1;\n  long kupper = N;\n  long kcurrent = 0;\n  double range = 0.0;\n  double b = 0.0;\n  double a = 0.0;\n\n  while (kupper - klower > 1) {\n    kcurrent = (kupper + klower) >> 1;\n    if (xorig[kcurrent - 1] > x) {\n      kupper = kcurrent;\n    } else {\n      klower = kcurrent;\n    }\n  }\n  kupper--; \n  klower--;\n  range = xorig[kupper] - xorig[klower];\n  if (range == 0.0) {\n    printf(\"smileMath_splint(): bad input (range == 0)!\\n\");\n    return 0;\n  }\n  a = (xorig[kupper] - x) / range;\n  b = (x - xorig[klower]) / range;\n  *y = a * yorig[klower] + b * yorig[kupper] + ((a * a * a - a) * y2[klower] +\n    (b * b * b - b) * y2[kupper]) * (range * range) / 6.0;\n  return 1;\n}\n\nint smileMath_splint_FLOAT_DMEM(const FLOAT_DMEM *xorig, const FLOAT_DMEM *yorig,\n    const FLOAT_DMEM *y2, long N, FLOAT_DMEM x, FLOAT_DMEM *y)\n{\n  long klower = 1;\n  long kupper = N;\n  long kcurrent = 0;\n  FLOAT_DMEM range = (FLOAT_DMEM)0.0;\n  FLOAT_DMEM b = (FLOAT_DMEM)0.0;\n  FLOAT_DMEM a = (FLOAT_DMEM)0.0;\n\n  while (kupper - klower > 1) {\n    kcurrent = (kupper + klower) >> 1;\n    if (xorig[kcurrent - 1] > x) {\n      kupper = kcurrent;\n    } else {\n      klower = kcurrent;\n    }\n  }\n  kupper--;\n  klower--;\n  range = xorig[kupper] - xorig[klower];\n  if (range == 0.0) {\n    printf(\"smileMath_splint(): bad input (range == 0)!\\n\");\n    return 0;\n  }\n  a = (xorig[kupper] - x) / range;\n  b = (x - xorig[klower]) / range;\n  *y = a * yorig[klower] + b * yorig[kupper] + ((a * a * a - a) * y2[klower] +\n    (b * b * b - b) * y2[kupper]) * (range * range) / (FLOAT_DMEM)6.0;\n  return 1;\n}\n\n\n\n\n"
  },
  {
    "path": "src/smileutil/zerosolve.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n#include <stdio.h>\n#include <math.h>\n#include <smileutil/zerosolve.h>\n#include <core/smileCommon.hpp>\n\n#define MODULE \"zerosolve\"\n\n// matrix element access helpers\n#define MATC(m,i,j,n) ((m)[(i)*(n) + (j)])\n#define MATF(m,i,j,n) ((m)[((i)-1)*(n) + ((j)-1)])\n\nconst double radix = 2.0;\nconst double radix2 = radix * radix;\n\nvoid zerosolveBalanceCmatrix(double *cMat, long nCol)\n{\n  int converged = 0;\n  double normedRow = 0;\n  double normedCol = 0;\n  while (!converged) {\n    double tmp1;\n    double tmp2;\n    double tmp3;\n    converged = 1;\n    for (long i = 0; i < nCol; i++) {\n      // normalise columns, exclude diagonal elements\n      if (i != nCol - 1) {\n        normedCol = fabs(MATC(cMat, i + 1, i, nCol));\n      } else {\n        normedCol = 0.0;\n        for (long j = 0; j < nCol - 1; j++) {\n          normedCol += fabs(MATC(cMat, j, nCol - 1, nCol));\n        }\n      }\n      // normalise rows, exclude diagonal elements\n      if (i == 0) {\n        normedRow = fabs(MATC(cMat, 0, nCol - 1, nCol));\n      } else if (i == nCol - 1) {\n        normedRow = fabs(MATC(cMat, i, i - 1, nCol));\n      } else {\n        normedRow = (fabs(MATC(cMat, i, i - 1, nCol))\n            + fabs(MATC(cMat, i, nCol - 1, nCol)));\n      }\n      if (normedCol == 0.0 || normedRow == 0.0)\n        continue;\n\n      tmp2 = 1.0;\n      tmp1 = normedRow / radix;\n      tmp3 = normedCol + normedRow;\n      while (normedCol < tmp1) {\n        tmp2 *= radix;\n        normedCol *= radix2;\n      }\n      tmp1 = normedRow * radix;\n      while (normedCol > tmp1) {\n        tmp2 /= radix;\n        normedCol /= radix2;\n      }\n      if ((normedRow + normedCol) < 0.95 * tmp3 * tmp2) {\n        converged = 0;\n        tmp1 = 1.0 / tmp2;\n        if (i == 0) {\n          MATC(cMat, 0, nCol - 1, nCol) *= tmp1;\n        } else {\n          MATC(cMat, i, i - 1, nCol) *= tmp1;\n          MATC(cMat, i, nCol - 1, nCol) *= tmp1;\n        }\n        if (i == nCol - 1) {\n          for (long j = 0; j < nCol; j++) {\n            MATC(cMat, j, i, nCol) *= tmp2;\n          }\n        } else {\n          MATC(cMat, i + 1, i, nCol) *= tmp2;\n        }\n      }\n    }\n  }\n}\n\nvoid zerosolveSetCmatrix(const double *a, long nCol, double *cMat)\n{\n  for (long i = 0; i < nCol; i++) {\n    for (long j = 0; j < nCol; j++) {\n      MATC(cMat, i, j, nCol) = 0.0;\n    }\n  }\n  for (long i = 1; i < nCol; i++) {\n    MATC(cMat, i, i - 1, nCol) = 1.0;\n  }\n  for (long i = 0; i < nCol; i++) {\n    MATC(cMat, i, nCol - 1, nCol) = -a[i] / a[nCol];\n  }\n}\n\nint zerosolveQRhelper(double *h, long nc,\n    tZerosolverComplexNumberPointer xRoot)\n{\n  long i = 0, j = 0, k = 0, m = 0;\n  long e = 0;\n  long nIterations = 0;\n  long N = nc;\n  double w = 0.0, s = 0.0;\n  double x = 0.0, y = 0.0, z = 0.0;\n  double p = 0.0;\n  double q = 0.0;\n  double r = 0.0;\n  double t = 0.0;\n  int isNotLast = 0;\n  if (N == 0) {\n    return 1;\n  }\n\n  while (1) {\n    for (e = N; e >= 2; e--) {\n      double a1 = fabs(MATF(h, e, e - 1, nc));\n      double a2 = fabs(MATF(h, e - 1, e - 1, nc));\n      double a3 = fabs(MATF(h, e, e, nc));\n      if (a1 <= ZEROSOLVER_DBL_EPSILON * (a2 + a3)) {\n        break;\n      }\n    }\n    x = MATF(h, N, N, nc);\n    if (e == N) {\n      ZEROSOLVER_SET_COMPLEX_NUMBER(xRoot, N - 1, x + t, 0);\n      N--;\n      if (N == 0) {\n        return 1;\n      }\n      nIterations = 0;\n      continue;\n    }\n    y = MATF(h, N - 1, N - 1, nc);\n    w = MATF(h, N - 1, N, nc) * MATF(h, N, N - 1, nc);\n    if (e == N - 1) {\n      p = (y - x) / 2;\n      q = p * p + w;\n      y = sqrt(fabs(q));\n      x += t;\n      if (q > 0) {\n        if (p < 0) {\n          y = -y;\n        }\n        y += p;\n        ZEROSOLVER_SET_COMPLEX_NUMBER(xRoot, N-1, x - w / y, 0);\n        ZEROSOLVER_SET_COMPLEX_NUMBER(xRoot, N-2, x + y, 0);\n      } else {\n        ZEROSOLVER_SET_COMPLEX_NUMBER(xRoot, N-1, x + p, -y);\n        ZEROSOLVER_SET_COMPLEX_NUMBER(xRoot, N-2, x + p, y);\n      }\n      N -= 2;\n      if (N == 0) {\n        return 1;\n      }\n      nIterations = 0;\n      continue;\n    }\n\n    // No other roots found, one more iteration though\n    if (nIterations == 70) {\n      return 0;\n    }\n    if (nIterations % 10 == 0 && nIterations > 0) {\n      // shift roots\n      t += x;\n      for (i = 1; i <= N; i++) {\n        MATF(h, i, i, nc) -= x;\n      }\n      s = fabs(MATF(h, N, N - 1, nc)) + fabs(MATF(h, N - 1, N - 2, nc));\n      y = 3.0 / 4.0 * s;\n      x = y;\n      w = -0.4375 * s * s;\n    }\n    nIterations++;\n\n    for (m = N - 2; m >= e; m--) {\n      double a1, a2, a3;\n      z = MATF(h, m, m, nc);\n      r = x - z;\n      s = y - z;\n      p = MATF(h, m, m + 1, nc) + (r * s - w) / MATF(h, m + 1, m, nc);\n      q = MATF(h, m + 1, m + 1, nc) - z - r - s;\n      r = MATF(h, m + 2, m + 1, nc);\n      s = fabs(p) + fabs(q) + fabs(r);\n      p /= s;\n      q /= s;\n      r /= s;\n\n      if (m == e) {\n        break;\n      }\n\n      a1 = fabs(MATF(h, m, m - 1, nc));\n      a2 = fabs(MATF(h, m - 1, m - 1, nc));\n      a3 = fabs(MATF(h, m + 1, m + 1, nc));\n\n      if (a1 * (fabs(q) + fabs(r)) <= ZEROSOLVER_DBL_EPSILON * fabs(p) * (a2 + a3)) {\n        break;\n      }\n    }\n    for (i = m + 2; i <= N; i++) {\n      MATF(h, i, i - 2, nc) = 0;\n    }\n    for (i = m + 3; i <= N; i++) {\n      MATF(h, i, i - 3, nc) = 0;\n    }\n\n    // A QR step (twice)\n    for (k = m; k <= N - 1; k++) {\n      isNotLast = (k != N - 1);\n      if (k != m) {\n        p = MATF (h, k, k - 1, nc);\n        q = MATF (h, k + 1, k - 1, nc);\n        if (isNotLast) {\n          r = MATF(h, k + 2, k - 1, nc);\n        } else {\n          r = 0.0;\n        }\n        x = fabs(p) + fabs(q) + fabs(r);\n        if (x == 0) {\n          continue;\n        }\n        p /= x;\n        q /= x;\n        r /= x;\n      }\n      s = sqrt(p*p + q*q + r*r);\n      if (p < 0) {\n        s = -s;\n      }\n      if (k != m) {\n        MATF(h, k, k - 1, nc) = -s * x;\n      } else if (e != m) {\n        MATF(h, k, k - 1, nc) *= -1;\n      }\n      p += s;\n      z = r / s;\n      y = q / s;\n      x = p / s;\n      r /= p;\n      q /= p;\n\n      // QR row modifications\n      for (j = k; j <= N; j++) {\n        p = MATF(h, k, j, nc) + q * MATF(h, k + 1, j, nc);\n        if (isNotLast) {\n          p += r * MATF(h, k + 2, j, nc);\n          MATF(h, k + 2, j, nc) -= p * z;\n        }\n        MATF(h, k + 1, j, nc) -= p * y;\n        MATF(h, k, j, nc) -= p * x;\n      }\n      if (k + 3 < N) {\n        j = k + 3;\n      } else {\n        j = N;\n      }\n      // QR column modifications\n      for (i = e; i <= j; i++) {\n        p = x * MATF(h, i, k, nc) + y * MATF(h, i, k + 1, nc);\n        if (isNotLast) {\n          p += z * MATF(h, i, k + 2, nc);\n          MATF(h, i, k + 2, nc) -= p * r;\n        }\n        MATF(h, i, k + 1, nc) -= p * q;\n        MATF(h, i, k, nc) -= p;\n      }\n    }\n  }\n  return 0;\n}\n\nsZerosolverPolynomialComplexWs * zerosolverPolynomialComplexWorkspaceAllocate(long N)\n{\n  long nCol;\n  sZerosolverPolynomialComplexWs * workspace;\n  if (N <= 0) {\n    SMILE_ERR(1, \"zerosolve: matrix size N must be > 0\");\n  }\n  workspace = (sZerosolverPolynomialComplexWs *)malloc(sizeof(sZerosolverPolynomialComplexWs));\n  if (workspace == NULL) {\n    SMILE_ERR(1, \"zerosolve: failed to allocate workspace memory\");\n  }\n  nCol = N - 1;\n  workspace->nCol = nCol;\n  workspace->mat = (double *)malloc(nCol * nCol * sizeof(double));\n  if (workspace->mat == NULL) {\n    free(workspace);\n    SMILE_ERR(1, \"zerosolve: failed to allocate workspace matrix array\");\n  }\n  return workspace;\n}\n\nvoid zerosolverPolynomialComplexWorkspaceFree(sZerosolverPolynomialComplexWs * workspace)\n{\n  if (workspace != NULL) {\n    if (workspace->mat != NULL) {\n      free(workspace->mat);\n    }\n    free(workspace);\n  }\n}\n\nint zerosolverPolynomialComplexSolve(const double *a, long N,\n      sZerosolverPolynomialComplexWs * w, tZerosolverComplexNumberPointer z)\n{\n  int status = 0;\n  double *m = NULL;\n  if (N == 0) {\n    SMILE_ERR(1, \"zerosolve: number of terms must be > 0!\");\n  }\n  if (N == 1) {\n    SMILE_ERR(1, \"zerosolve: cannot solve for only a single term!\");\n  }\n  if (a[N - 1] == 0.0) {\n    SMILE_ERR(1, \"zerosolve: first coefficient of polynomial must be != 0.0\");\n  }\n  if (w->nCol != N - 1) {\n    SMILE_ERR(1, \"zerosolve: dimensionality of workspace does not match the number of polynomial coefficients!\");\n  }\n  m = w->mat;\n  zerosolveSetCmatrix(a, N - 1, m);\n  zerosolveBalanceCmatrix(m, N - 1);\n  status = zerosolveQRhelper(m, N - 1, z);\n  if (!status) {\n    SMILE_ERR(1, \"zerosolve: the QR-method for root solving did not converge!\");\n    return 0;\n  }\n  return 1;\n}\n\n"
  },
  {
    "path": "src/video/openCVSource.cpp",
    "content": "/*F***************************************************************************\n * \n * openSMILE - the Munich open source Multimedia Interpretation by \n * Large-scale Extraction toolkit\n * \n * This file is part of openSMILE.\n * \n * openSMILE is copyright (c) by audEERING GmbH. All rights reserved.\n * \n * See file \"COPYING\" for details on usage rights and licensing terms.\n * By using, copying, editing, compiling, modifying, reading, etc. this\n * file, you agree to the licensing terms in the file COPYING.\n * If you do not agree to the licensing terms,\n * you must immediately destroy all copies of this file.\n * \n * THIS SOFTWARE COMES \"AS IS\", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,\n * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF\n * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST\n * INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE\n * OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL\n * ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS\n * DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.\n * NEITHER TUM NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY\n * DAMAGES RELATED TO THE SOFTWARE OR THIS LICENSE AGREEMENT, INCLUDING\n * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE\n * MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON.\n * ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE\n * THE SOFTWARE OR DERIVATIVE WORKS.\n * \n * Main authors: Florian Eyben, Felix Weninger, \n * \t      Martin Woellmer, Bjoern Schuller\n * \n * Copyright (c) 2008-2013, \n *   Institute for Human-Machine Communication,\n *   Technische Universitaet Muenchen, Germany\n * \n * Copyright (c) 2013-2015, \n *   audEERING UG (haftungsbeschraenkt),\n *   Gilching, Germany\n * \n * Copyright (c) 2016,\t \n *   audEERING GmbH,\n *   Gilching Germany\n ***************************************************************************E*/\n\n\n/*  openSMILE component:\n\nOpenCVFaceSource\nCaptures frames from either webcam or file stream and extracts a square region containing the face(s).\nReturns the LBP, HSV and optical flow histogram of this area.\nAuthor: Florian Gross\n\n*/\n\n#include <video/openCVSource.hpp>\n\n#ifdef HAVE_OPENCV\n\n#ifdef WINDOWS_COMPILE\n#include<time.h>\n#else\n#include <sys/time.h>\n#endif\n\n#define MODULE \"cOpenCVSource\"\n\nusing namespace std;\nusing namespace cv;\n\n\n\nSMILECOMPONENT_STATICS(cOpenCVSource)\n\nSMILECOMPONENT_REGCOMP(cOpenCVSource)\n{\n  SMILECOMPONENT_REGCOMP_INIT\n  scname = COMPONENT_NAME_COPENCVSOURCE;\n  sdescription = COMPONENT_DESCRIPTION_COPENCVSOURCE;\n\n  // we inherit cDataSource configType and extend it:\n  SMILECOMPONENT_INHERIT_CONFIGTYPE(\"cDataSource\")\n  \n  SMILECOMPONENT_IFNOTREGAGAIN(\n    ct->setField(\"display\", \"Show original and extracted video\", 1);\n    ct->setField(\"videoSource\", \"Choose Video Source: WEBCAM or FILE\", \"WEBCAM\");\n    ct->setField(\"filename\", \"Filename of video, if VideoSource = FILE\", \"\");\n    ct->setField(\"fps\", \"Frames per second\", 30.0);\n    ct->setField(\"face_cascade_path\", \"Path to OpenCV face cascade xml file\", \"/usr/share/opencv/data/lbpcascades/lbpcascade_frontalface.xml\");\n    ct->setField(\"eyes_cascade_path\", \"Path to OpenCV eyes cascade xml file\", \"/usr/share/opencv/data/haarcascades/haarcascade_eye_tree_eyeglasses.xml\");\n    ct->setField(\"extract_face\", \"Extract face and eyes?\", 1);\n    ct->setField(\"extract_hsv_histogram\", \"Extract HSV histogram?\", 1);\n    ct->setField(\"extract_lbp_histogram\", \"Extract LBP histogram?\", 1);\n    ct->setField(\"extract_optical_flow\", \"Extract optical flow histogram?\", 1);\n    ct->setField(\"include_face_features\", \"Include face features (eye position + distance etc.) in feature vector?\", 0);\n    ct->setField(\"ignore_invalid_frames\", \"Ignore invalid frames (e.g. when no face is detected. Cave: Might lead to synchronisation errors.\", 1);\n    ct->setField(\"face_width\", \"Width/height of extracted face square\", 60);\n    ct->setField(\"lbp_uniformpatterns\", \"Use uniform patterns for LBP histogram\", 0);\n    ct->setField(\"hsv_histogram_h_bins\", \"HSV histogram: Hue bins\", 50);\n    ct->setField(\"hsv_histogram_s_bins\", \"HSV histogram: Saturation bins\", 50);\n    ct->setField(\"hsv_histogram_v_bins\", \"HSV histogram: Value bins\", 50);\n    ct->setField(\"of_histogram_bins\", \"Optical flow histogram: Bins\", 10);\n    ct->setField(\"normalize_histograms\", \"Normalize histograms (L1-norm)\", 0);\n    ct->setField(\"of_histogram_max_flow\", \"Optical flow histogram: Max flow\", 0.2);\n    ct->setField(\"of_histogram_downsample\", \"Optical flow histogram: Downsample\", 0.3);\n    ct->setField(\"use_lbpc\", \"Use LBP-C (circular LBP)\", 0);\n    ct->setField(\"lbpc_radius\", \"LBP-C radius\", 1);\n    ct->setField(\"lbpc_points\", \"LBP-C points (currently only 8 points supported)\", 8);\n  )\n\n  SMILECOMPONENT_MAKEINFO(cOpenCVSource);\n}\n\nSMILECOMPONENT_CREATE(cOpenCVSource)\n\n//-----\n\ncOpenCVSource::cOpenCVSource(const char *_name) :\n  cDataSource(_name)\n{\n\t// ...\n\tmPrevFrame_gray_resized = cv::Mat();\n\tSMILE_MSG(1, \"cOpenCVSource::cOpenCVSource()\");\n\tSMILE_MSG(1, \"OpenCV Version: %i.%i.%i\", CV_MAJOR_VERSION, CV_MINOR_VERSION, CV_SUBMINOR_VERSION);\n}\n\nvoid cOpenCVSource::fetchConfig()\n{\n\tcDataSource::fetchConfig();\n\tSMILE_MSG(1, \"cLBPHistSource::fetchConfig()\");\n\n\tcfgDisplay = getInt(\"display\");\n\tSMILE_DBG(2, \"cfgDisplay = %i\", cfgDisplay);\n\n\tcfgVideoSource = getStr(\"videoSource\");\n\tSMILE_DBG(2, \"cfgVideoSource = %s\", cfgVideoSource);\n\n\tcfgFilename = getStr(\"filename\");\n\tSMILE_DBG(2, \"cfgFilename = %s\", cfgFilename);\n\n\tcfgFps = getDouble(\"fps\");\n\tif(cfgFps == 0.0)\n\t{\n\t\tcfgFps = 30.0; // Assume 30 fps\n\t}\n\tSMILE_DBG(2, \"cfgFps = %s\", cfgFps);\n\n\n\tcfgFace_cascade_name = getStr(\"face_cascade_path\");\n\tSMILE_DBG(2, \"cfgFace_cascade_name = %s\", cfgFace_cascade_name);\n\n\tcfgEyes_cascade_name = getStr(\"eyes_cascade_path\");\n\tSMILE_DBG(2, \"cfgEyes_cascade_name = %s\", cfgEyes_cascade_name);\n\n\tcfgExtractFace = getInt(\"extract_face\");\n\tSMILE_DBG(2, \"cfgExtractFace = %i\", cfgExtractFace);\n\n\tcfgExtractHSVHist = getInt(\"extract_hsv_histogram\");\n\tSMILE_DBG(2, \"cfgExtractHSVHist = %i\", cfgExtractHSVHist);\n\n\tcfgExtractLBPHist = getInt(\"extract_lbp_histogram\");\n\tSMILE_DBG(2, \"cfgExtractLBPHist = %i\", cfgExtractLBPHist);\n\n\tcfgExtractOpticalFlow = getInt(\"extract_optical_flow\");\n\tSMILE_DBG(2, \"cfgExtractOpticalFlow = %i\", cfgExtractOpticalFlow);\n\t\n\tcfgIncludeFaceFeatures = getInt(\"include_face_features\");\n\tSMILE_DBG(2, \"cfgIncludeFaceFeatures = %i\", cfgIncludeFaceFeatures);\n\t\n\tcfgIgnoreInvalid = getInt(\"ignore_invalid_frames\");\n\tSMILE_DBG(2, \"cfgIgnoreInvalid = %i\", cfgIgnoreInvalid);\n\t\n\tcfgFaceWidth = getInt(\"face_width\");\n\tSMILE_DBG(2, \"cfgFaceWidth = %i\", cfgFaceWidth);\n\t\n\tcfgLBPUniformPatterns = getInt(\"lbp_uniformpatterns\");\n\tSMILE_DBG(2, \"cfgLBPUniformPatterns = %i\", cfgLBPUniformPatterns);\n\n\tcfgHueBins = getInt(\"hsv_histogram_h_bins\");\n\tSMILE_DBG(2, \"cfgHueBins = %i\", cfgHueBins);\n\n\tcfgSatBins = getInt(\"hsv_histogram_s_bins\");\n\tSMILE_DBG(2, \"cfgSatBins = %i\", cfgSatBins);\n\n\tcfgValBins = getInt(\"hsv_histogram_v_bins\");\n\tSMILE_DBG(2, \"cfgValBins = %i\", cfgValBins);\n\n\tcfgFlowBins = getInt(\"of_histogram_bins\");\n\tSMILE_DBG(2, \"cfgFlowBins = %i\", cfgFlowBins);\n\t\n\tcfgNormalizeHistograms = getInt(\"normalize_histograms\");\n\tSMILE_DBG(2, \"cfgNormalizeHistograms = %i\", cfgNormalizeHistograms);\n\n\tcfgMaxFlow = getDouble(\"of_histogram_max_flow\");\n\tSMILE_DBG(2, \"cfgMaxFlow = %i\", cfgMaxFlow);\n\n\tcfgFlowDownsample = getDouble(\"of_histogram_downsample\");\n\tSMILE_DBG(2, \"cfgFlowDownsample = %i\", cfgFlowDownsample);\n\t\n\tcfgUseLBPC = getDouble(\"use_lbpc\");\n\tSMILE_DBG(2, \"cfgUseLBPC = %i\", cfgUseLBPC);\n\t\n\tcfgLBPCRadius = getDouble(\"lbpc_radius\");\n\tSMILE_DBG(2, \"cfgLBPCRadius = %i\", cfgLBPCRadius);\n\t\n\tcfgLBPCPoints = getDouble(\"lbpc_points\");\n\tSMILE_DBG(2, \"cfgLBPCPoints = %i\", cfgLBPCPoints);\n}\n\n\nint cOpenCVSource::myConfigureInstance()\n{\t\n  SMILE_MSG(1, \"cOpenCVSource::myConfigureInstance()\");\n  int ret = cDataSource::myConfigureInstance();\n\n  return ret;\n}\n\nint cOpenCVSource::configureWriter(sDmLevelConfig &c)\n{\n  // configure your writer by setting values in &c\n  c.T = 1 / (double) cfgFps;\n\n  return 1;\n}\n\n// NOTE: nEl is always 0 for dataSources....\nint cOpenCVSource::setupNewNames(long nEl)\n{\n\tSMILE_MSG(1, \"cOpenCVSource::setupNewNames()\");\n\tmLBPSize = 0;\n\t\n\tif(cfgExtractFace && cfgIncludeFaceFeatures)\n\t{\n\t\twriter_->addField(\"Face_found\", 1);\n\t\twriter_->addField(\"Eyes_found\", 1);\n\t\twriter_->addField(\"Face_rectangle:_Top_left_X\", 1);\n\t\twriter_->addField(\"Face_rectangle:_Top_left_Y\", 1);\n\t\twriter_->addField(\"Face_rectangle:_Width\", 1);\n\t\twriter_->addField(\"Face_rectangle:_Height\", 1);\n\n\t\twriter_->addField(\"Left_eye:_X\", 1);\n\t\twriter_->addField(\"Left_eye:_Y\", 1);\n\t\twriter_->addField(\"Right_eye:_X\", 1);\n\t\twriter_->addField(\"Right_eye:_Y\", 1);\n\t}\n\tif(cfgExtractLBPHist)\n\t{\n\t\tif(cfgLBPUniformPatterns)\n\t\t{\n\t\t\twriter_->addField(\"LBP_histogram\", 59);\n\t\t\tmLBPSize = 59;\n\t\t}\n\t\telse\n\t\t{\n\t\t\twriter_->addField(\"LBP_histogram\", 256);\n\t\t\tmLBPSize = 256;\n\t\t}\n\t}\n\tif(cfgExtractHSVHist)\n\t{\n\t\twriter_->addField(\"HSV_histogram:_Hue\", cfgHueBins);\n\t\twriter_->addField(\"HSV_histogram:_Saturation\", cfgSatBins);\n\t\twriter_->addField(\"HSV_histogram:_Value\", cfgValBins);\n\t}\n\tif(cfgExtractOpticalFlow)\n\t{\n\t\twriter_->addField(\"Optical_flow:_Mean\", 2);\n\t\twriter_->addField(\"Optical_flow:_Standard_deviation\", 2);\n\t\twriter_->addField(\"Optical_flow_histogram\", cfgFlowBins);\n\t}\n\t\n\t\n\tmVectorSize = cfgExtractFace*cfgIncludeFaceFeatures*10 + cfgExtractHSVHist * (cfgHueBins + cfgSatBins + cfgValBins) + cfgExtractLBPHist * mLBPSize + cfgExtractOpticalFlow * (cfgFlowBins + 4);\n\tallocVec(mVectorSize);\n\treturn 1;\n}\n\n// Used for setting up video capture etc.\nint cOpenCVSource::myFinaliseInstance()\n{\n\tint ret = cDataSource::myFinaliseInstance();\n\tif (ret==0) return 0;\n  \n\tSMILE_MSG(1, \"cOpenCVSource::myFinaliseInstance()\");\n\tif(cfgVideoSource == \"WEBCAM\")\n\t{\n\t\tmVideoCapture.open(0); // open default camera (e.g. webcam)\n\t}\n\telse if(cfgVideoSource == \"FILE\")\n\t{\n\t\tbool success = mVideoCapture.open(cfgFilename); // open video stream from file\n\n\t\t// Doesn't work for linux, assume 30 fps...\n\t\tif(mVideoCapture.get(CV_CAP_PROP_FPS) != 0)\n\t\t{\n\t\t\tcfgFps = mVideoCapture.get(CV_CAP_PROP_FPS);\n\t\t}\n\t}\n\telse\n\t{\n\t\tSMILE_ERR(1, \"No video source specified.\");\n\t}\n\n\tif(!mVideoCapture.isOpened())\n\t{\n\t\tSMILE_ERR(1, \"Could not open video!\");\n\t\treturn 0;\n\t}\n\tif(mFace_cascade.empty())\n\t{\n\t\tif( !mFace_cascade.load( cfgFace_cascade_name ) ){ SMILE_ERR(1, \"--(!)Error loading face cascade\\n\"); };\n\t}\n\tif(mEyes_cascade.empty())\n\t{\n\t\tif( !mEyes_cascade.load( cfgEyes_cascade_name ) ){ SMILE_ERR(1, \"--(!)Error loading eye cascade\\n\"); };\n\t}\n\n\tmIdentityMap = LBPHistogram::compute_identity_map_<unsigned char>();\n\tmUniformMap = LBPHistogram::compute_uniform_map_<unsigned char>();\n\n\treturn ret;\n}\n\nint cOpenCVSource::myTick(long long t)\n{\n\ttimeval begin;\n\tgettimeofday(&begin, NULL);\n\t//SMILE_MSG(1,\"cOpenCVSource::myTick # %i ...\",t);\n\t//std::vector<FLOAT_DMEM> nextFrame;\n\t//nextFrame.reserve(mVectorSize);\n\tcVector nextVector(mVectorSize, DMEM_FLOAT);\n\tint vectorPosition = 0;\n\n\tmVideoCapture >> mCurrentFrame_bgr; // Get new frame from cap stream\n\t\n\ttimeval grabFrame;\n\tgettimeofday(&grabFrame, NULL);\n\t\n\tdouble grabFrame_elapsed = (grabFrame.tv_usec - begin.tv_usec) / 1000.0;\n\tdouble convertColor_elapsed = 0;\n\tdouble extrF_elapsed = 0;\n\tdouble extrLBP_elapsed = 0;\n\tdouble extrHSV_elapsed = 0;\n\tdouble extrOF_elapsed = 0;\n\n\t//-- 3. Apply the classifier to the frame\n\tif( !mCurrentFrame_bgr.empty() )\n\t{\n\t\tif (cfgDisplay)\n\t\t{\n\t\t\tmCurrentFrameDisplay_bgr = mCurrentFrame_bgr.clone();\n\t\t}\n\n\t\tcvtColor( mCurrentFrame_bgr, mCurrentFrame_gray, CV_BGR2GRAY );\n\t\tequalizeHist( mCurrentFrame_gray, mCurrentFrame_gray );\n\t\t\n\t\ttimeval convertColor;\n\t\tgettimeofday(&convertColor, NULL);\n\t\tconvertColor_elapsed = (convertColor.tv_usec - grabFrame.tv_usec) / 1000.0;\n\n\t\tif(cfgExtractFace)\n\t\t{\n\t\t\tExtractedFace extractedFace = this->extractFace(mCurrentFrame_bgr, mCurrentFrame_gray);\n\n\t\t\tif(extractedFace.faceFound == true)\n\t\t\t{\n\t\t\t\tmCurrentFrame_bgr = extractedFace.faceColor;\n\t\t\t\tmCurrentFrame_gray = extractedFace.faceGray;\n\t\t\t}\n\t\t\t\n\t\t\tif(extractedFace.faceFound == false && cfgIgnoreInvalid == 1)\n\t\t\t{\n\t\t\t\t// Discard frame\n\t\t\t\tSMILE_MSG(1, \"No face detected, frame discarded.\");\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\t\n\t\t\tif(cfgIncludeFaceFeatures)\n\t\t\t{\n\t\t\t\tnextVector.setF(vectorPosition++, static_cast<FLOAT_DMEM>(extractedFace.faceFound));\n\t\t\t\tnextVector.setF(vectorPosition++, static_cast<FLOAT_DMEM>(extractedFace.eyesFound));\n\t\t\t\tnextVector.setF(vectorPosition++, static_cast<FLOAT_DMEM>(extractedFace.faceRect.tl().x)); // top left corner\n\t\t\t\tnextVector.setF(vectorPosition++, static_cast<FLOAT_DMEM>(extractedFace.faceRect.tl().y));\n\t\t\t\tnextVector.setF(vectorPosition++, static_cast<FLOAT_DMEM>(extractedFace.faceRect.width)); // width+height\n\t\t\t\tnextVector.setF(vectorPosition++, static_cast<FLOAT_DMEM>(extractedFace.faceRect.height));\n\n\t\t\t\tnextVector.setF(vectorPosition++, static_cast<FLOAT_DMEM>(extractedFace.leftEye.x)); // left eye, xy\n\t\t\t\tnextVector.setF(vectorPosition++, static_cast<FLOAT_DMEM>(extractedFace.leftEye.y));\n\t\t\t\tnextVector.setF(vectorPosition++, static_cast<FLOAT_DMEM>(extractedFace.rightEye.x)); // right eye, xy\n\t\t\t\tnextVector.setF(vectorPosition++, static_cast<FLOAT_DMEM>(extractedFace.rightEye.y));\n\t\t\t}\n\n\t\t\tif (cfgDisplay) {\n\t\t\t\timshow( \"Resized face\", mCurrentFrame_gray );\n\t\t\t}\n\t\t}\n\t\t\n\t\ttimeval extrF;\n\t\tgettimeofday(&extrF, NULL);\n\t\textrF_elapsed = (extrF.tv_usec - convertColor.tv_usec) / 1000.0;\n\n\t\tif(cfgExtractLBPHist)\n\t\t{\n\t\t\tMat lbpFace;\n\t\t\t\n\t\t\tif(cfgUseLBPC == 1)\n\t\t\t{\n\t\t\t        lbpFace = LBPHistogram::computeCircularLBPImage(mCurrentFrame_gray, cfgLBPCRadius, cfgLBPCPoints);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t        lbpFace = LBPHistogram::computeLBPImage(mCurrentFrame_gray);\n\t\t\t}\n\t\t\t\n\t\t\tstd::map<unsigned char, FLOAT_DMEM> currentLBPHistogram;\n\t\t\tif(cfgLBPUniformPatterns)\n\t\t\t{\n\t\t\t\tcurrentLBPHistogram = LBPHistogram::computeLBPHistogram(lbpFace, mUniformMap, cfgNormalizeHistograms);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcurrentLBPHistogram = LBPHistogram::computeLBPHistogram(lbpFace, mIdentityMap, cfgNormalizeHistograms);\n\t\t\t}\n\n\t\t\t// Create std::vector out ouf map\n\t\t\tstd::map<unsigned char, FLOAT_DMEM>::iterator i = currentLBPHistogram.begin();\n\t\t\tfor( ; i != currentLBPHistogram.end(); ++i )\n\t\t\t{\n\t\t\t\tnextVector.setF(vectorPosition++, i->second);\n\t\t\t}\n\t\t\tif (cfgDisplay)\n\t\t\t{\n\t\t\t\timshow( \"LBP face\", lbpFace );\n\t\t\t}\n\t\t}\n\t\t\n\t\ttimeval extrLBP;\n\t\tgettimeofday(&extrLBP, NULL);\n\t\textrLBP_elapsed = (extrLBP.tv_usec - extrF.tv_usec) / 1000.0;\n\n\t\tif(cfgExtractHSVHist)\n\t\t{\n\t\t\tstd::vector<cv::Mat> hsvHists = HSVHistogram::computeHSVHistogram(mCurrentFrame_bgr, cfgHueBins, cfgSatBins, cfgValBins, cfgNormalizeHistograms);\n\t\t\t\n\t\t\t//SMILE_MSG(1, \"Ges: [0] -> %lf, [12] -> %lf\", hsvHists[0].at<FLOAT_DMEM>(0), hsvHists[0].at<FLOAT_DMEM>(12));\n\n\t\t\tfor(int i = 0; i < cfgHueBins; i++)\n\t\t\t{\n\t\t\t\tnextVector.setF(vectorPosition++, hsvHists[0].at<FLOAT_DMEM>(i));\n\t\t\t}\n\t\t\tfor(int i = 0; i < cfgSatBins; i++)\n\t\t\t{\n\t\t\t\tnextVector.setF(vectorPosition++, hsvHists[1].at<FLOAT_DMEM>(i));\n\t\t\t}\n\t\t\tfor(int i = 0; i < cfgValBins; i++)\n\t\t\t{\n\t\t\t\tnextVector.setF(vectorPosition++, hsvHists[2].at<FLOAT_DMEM>(i));\n\t\t\t}\n\t\t}\n\t\t\n\n\t\ttimeval extrHSV;\n\t\tgettimeofday(&extrHSV, NULL);\n\t\textrHSV_elapsed = (extrHSV.tv_usec - extrLBP.tv_usec) / 1000.0;\n\n\t\tif(cfgExtractOpticalFlow)\n\t\t{\n\t\t\tOpticalFlow::FrameFtExtrParams featureSettings;\n\t\t\tfeatureSettings.flo_bins = cfgFlowBins;\n\t\t\tfeatureSettings.max_flow = cfgMaxFlow;\n\t\t\tfeatureSettings.flow_downsample = cfgFlowDownsample;\n\n\t\t\tcv::Mat currentFrame_gray_resized;\n\t\t\tcv::resize(mCurrentFrame_gray, currentFrame_gray_resized, cv::Size(), featureSettings.flow_downsample, featureSettings.flow_downsample, 1);\n\n\t\t\t// If size changes, face not detected for example\n\t\t\t//printf(\"Current: %i x %i px, prev: %i x %i px \\n\", currentFrame_gray_resized.size().width, currentFrame_gray_resized.size().height, mPrevFrame_gray_resized.size().width, mPrevFrame_gray_resized.size().height);\n\t\t\tif(mPrevFrame_gray_resized.size() != currentFrame_gray_resized.size() && mPrevFrame_gray_resized.size().width != 0)\n\t\t\t{\n\t\t\t\t// Resize image\n\t\t\t\t//cv::resize(mPrevFrame_gray_resized, mPrevFrame_gray_resized, currentFrame_gray_resized.size());\n\t\t\t\t// Discard image (optical flow would be erroneous)\n\t\t\t\tSMILE_MSG(2, \"Size changed, previous frame for optical flow discarded.\");\n\t\t\t\tmPrevFrame_gray_resized = cv::Mat();\n\t\t\t}\n\n\n\t\t\tstd::vector<FLOAT_DMEM> opticalFlowHist = OpticalFlow::computeOpticalFlowHistogram(currentFrame_gray_resized, mPrevFrame_gray_resized, featureSettings, cfgDisplay, cfgNormalizeHistograms);\n\t\t\tmPrevFrame_gray_resized = currentFrame_gray_resized.clone(); //save frame for next optical flow step\n\t\t\t// ... copy to nextFrame ...\n\t\t\tfor(int i = 0; i < opticalFlowHist.size(); i++)\n\t\t\t{\n\t\t\t\tnextVector.setF(vectorPosition++, opticalFlowHist.at(i));\n\t\t\t}\n\t\t\topticalFlowHist.clear();\n\t\t}\n\t\t\n\t\t\n\t\ttimeval extrOF;\n\t\tgettimeofday(&extrOF, NULL);\n\t\textrOF_elapsed = (extrOF.tv_usec - extrHSV.tv_usec) / 1000.0;\n\n\t\tif(cfgDisplay)\n\t\t{\n\t\t\timshow( \"video\", mCurrentFrameDisplay_bgr );\n\t\t}\n\t}\n\telse\n\t{\n\t\tSMILE_MSG(1, \" --(!) No captured frame -- Stop!\");\n\t\treturn 0;\n\t}\n\t\n\n\tif(cfgDisplay)\n\t{\n\t\t// At least one ms required for event processing (freezes otherwise)\n\t\twaitKey(1);\n\t}\n\n\t/*vec_->dataF = nextFrame.data(); // This part caused an error when program finishes... (double free)\n\tvec_->tmeta->smileTime = (t / cfgFps); // Set timestamp\n\tvec_->tmeta->time = (t / cfgFps); // Timestamp\n\twriter_->setNextFrame(vec_);*/\n\t\n\t\n\tnextVector.tmeta->time = (double) (t / cfgFps); // Set Timestamp\n\tnextVector.tmeta->period = (double) 1 / cfgFps;\n\twriter_->setNextFrame(&nextVector);\n\t\n\tbool measureTime = false; // Set to true to measure execution time (+ RTF) of several parts of this code\n\tif(measureTime)\n\t{\n\t\ttimeval end;\n\t\tgettimeofday(&end, NULL);\n\t\tdouble total_elapsed = (end.tv_usec - begin.tv_usec) / 1000.0;\n\t\n\t\tSMILE_MSG(1, \"      Function     |  Elapsed time |  RTF   \");\n\t\tSMILE_MSG(1, \"-------------------+-------------+--------\");\n\t\tSMILE_MSG(1, \" grab frame        |  %3.4f ms  | %.5f   \", grabFrame_elapsed, grabFrame_elapsed/1000*cfgFps);\n\t\tSMILE_MSG(1, \"-------------------+-------------+--------\");\n\t\tSMILE_MSG(1, \" convert to gray   |  %3.4f ms  | %.5f   \", convertColor_elapsed, convertColor_elapsed/1000*cfgFps);\n\t\tSMILE_MSG(1, \"-------------------+-------------+--------\");\n\t\tSMILE_MSG(1, \" extract Face      |  %3.4f ms | %.5f   \", extrF_elapsed, extrF_elapsed/1000*cfgFps);\n\t\tSMILE_MSG(1, \"-------------------+-------------+--------\");\n\t\tSMILE_MSG(1, \" LBP               |  %3.4f ms  | %.5f   \", extrLBP_elapsed, extrLBP_elapsed/1000*cfgFps);\n\t\tSMILE_MSG(1, \"-------------------+-------------+--------\");\n\t\tSMILE_MSG(1, \" HSV               |  %3.4f ms  | %.5f   \", extrHSV_elapsed, extrHSV_elapsed/1000*cfgFps);\n\t\tSMILE_MSG(1, \"-------------------+-------------+--------\");\n\t\tSMILE_MSG(1, \" Optical Flow      |  %3.4f ms  | %.5f   \", extrOF_elapsed, extrOF_elapsed/1000*cfgFps);\n\t\tSMILE_MSG(1, \"-------------------+-------------+--------\");\n\t\tSMILE_MSG(1, \" Total             |  %3.4f ms  | %.5f   \", total_elapsed, total_elapsed/1000*cfgFps);\n\t}\n\n\treturn 1;\n}\n\nExtractedFace cOpenCVSource::extractFace(cv::Mat& frame, cv::Mat& frame_gray)\n{\n\tExtractedFace extractedFace;\n\textractedFace.faceFound = false;\n\textractedFace.eyesFound = false;\n\textractedFace.faceRect = cv::Rect();\n\textractedFace.leftEye = cv::Point();\n\textractedFace.rightEye = cv::Point();\n\textractedFace.faceColor = cv::Mat();\n\textractedFace.faceGray = cv::Mat();\n\t\n\tcv::Rect matBoundingRect = cv::Rect(0, 0, frame_gray.cols, frame_gray.rows);\n\n\tstd::vector<cv::Rect> faces;\n\n\tmFace_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0, Size(80, 80) );\n\n\t   if (faces.size() >= 1)\n\t      {\n\t      \t cv::Rect insideFrame = faces[0] & matBoundingRect;\n\t      \t // (0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows\n\t      \t //std::cout << \"roi.x = \" << insideFrame.x << \", roi.y = \" << insideFrame.y << \", roi.width = \" << insideFrame.width\n\t      \t //\t\t\t<< \", roi.height = \" << insideFrame.height << \", m.cols = \" << frame_gray.cols\n  \t \t\t //\t\t\t<< \", m.rows = \" << frame_gray.rows << std::endl;\n\t      \t \n\t\t  \t if(insideFrame.area() > 0)\n\t\t  \t {\n\t\t  \t \t extractedFace.faceFound = true;\n\t\t\t\t extractedFace.faceRect = faces[0];\n\t\t\t     Mat faceROI = frame_gray(insideFrame).clone();\n\t\t\t     Mat faceResized_gray = Mat::zeros(faceROI.rows, faceROI.cols, faceROI.type());\n\t\t\t     std::vector<Rect> eyes;\n\t\t\t     mEyes_cascade.detectMultiScale( faceROI, eyes, 1.1, 2, 0 |CV_HAAR_SCALE_IMAGE, Size(30, 30) );\n\t\t\t     if( eyes.size() == 2)\n\t\t\t     {\n\t\t\t    \textractedFace.eyesFound = true;\n\t\t\t        std::vector<Point> eyeCenters(eyes.size());\n\t\t\t        Point leftEye, rightEye;\n\t\t\t        for( size_t j = 0; j < eyes.size(); j++ )\n\t\t\t        {\n\t\t\t           //eyeCenters[j] = Point(eyes[j].x + eyes[j].width / 2, eyes[j].y + eyes[j].height / 2);\n\t\t\t           eyeCenters[j] = Point(faces[0].x + eyes[j].x + eyes[j].width / 2,\n\t\t\t               faces[0].y + eyes[j].y + eyes[j].height / 2);\n\t\t\t        }\n\t\t\t        if (eyeCenters[0].x > eyeCenters[1].x)\n\t\t\t        {\n\t\t\t           rightEye = eyeCenters[0];\n\t\t\t           leftEye = eyeCenters[1];\n\t\t\t        }\n\t\t\t        else\n\t\t\t        {\n\t\t\t           rightEye = eyeCenters[1];\n\t\t\t           leftEye = eyeCenters[0];\n\t\t\t        }\n\n\t\t\t        extractedFace.leftEye = leftEye;\n\t\t\t        extractedFace.rightEye = rightEye;\n\n\t\t\t        Size faceSize = cv::Size(cfgFaceWidth, cfgFaceWidth);\n\t\t\t        LBPHistogram::cropFace(frame_gray, faceResized_gray, leftEye, rightEye, 0.3, 0.3, faceSize);\n\t\t\t        extractedFace.faceGray = faceResized_gray;\n\n\t\t\t        LBPHistogram::cropFace(frame, extractedFace.faceColor, leftEye, rightEye, 0.3, 0.3, faceSize);\n\n\t\t\t        if (cfgDisplay)\n\t\t\t        {\n\t\t\t            // imshow( \"lbp_uni\", lbpFaceUni );\n\n\n\t\t\t            for( size_t j = 0; j < eyes.size(); j++ )\n\t\t\t             { //-- Draw the eyes\n\t\t\t               Point eye_center( faces[0].x + eyes[j].x + eyes[j].width/2, faces[0].y + eyes[j].y + eyes[0].height/2 );\n\t\t\t               int radius = cvRound( (eyes[j].width + eyes[j].height)*0.25 );\n\t\t\t               circle( mCurrentFrameDisplay_bgr, eye_center, radius, Scalar( 255, 0, 255 ), 3, 8, 0 );\n\t\t\t             }\n\t\t\t        }\n\t\t\t      }\n\t\t\t      else\n\t\t\t      {\n\t\t\t        SMILE_MSG(1, \"No eyes detected!\");\n\n\t\t\t        resize(faceROI, faceResized_gray, Size(cfgFaceWidth, cfgFaceWidth));\n\t\t\t        resize(frame(insideFrame), extractedFace.faceColor, Size(cfgFaceWidth, cfgFaceWidth));\n\t\t\t        extractedFace.eyesFound = false;\n\t\t\t        extractedFace.faceGray = faceResized_gray;\n\n\t\t\t      }\n\n\t\t\t     if (cfgDisplay)\n\t\t\t     {\n\t\t\t        //-- Draw the face\n\t\t\t        Point center( faces[0].x + faces[0].width/2, faces[0].y + faces[0].height/2 );\n\t\t\t        ellipse( mCurrentFrameDisplay_bgr, center, Size( faces[0].width/2, faces[0].height/2), 0, 0, 360, Scalar( 255, 0, 0 ), 2, 8, 0 );\n\t\t\t     }\n\t\t\t } // if(insideFrame.area() > 0)\n\t\t\t else\n\t\t\t {\n\t\t\t \tSMILE_MSG(1, \"Face not in image region -> discarded.\");\n\t\t\t \textractedFace.faceFound = false;\n\t\t\t }\n\t      } // if (faces.size() >= 1)\n\t      else\n\t      {\n\t        //SMILE_MSG(1, \"No face detected!\");\n\t        extractedFace.faceFound = false;\n\t      }\n\n\t   return extractedFace;\n}\n\n\ncOpenCVSource::~cOpenCVSource()\n{\n\n}\n\n#endif // HAVE_OPENCV\n"
  },
  {
    "path": "update_build_version.sh",
    "content": "#!/bin/sh\necho \"#define OPENSMILE_SOURCE_REVISION \\\"2014:2043\\\"\" > src/include/core/svn_version.hpp\necho \"#define OPENSMILE_BUILD_DATE \\\"Fri Oct 28 21:16:39 CEST 2016\\\"\" >> src/include/core/svn_version.hpp\necho \"#define OPENSMILE_BUILD_BRANCH \\\"opensmile-2.3.0\\\"\" >> src/include/core/svn_version.hpp\n"
  }
]