annotate src/Support/Parameters.h @ 16:2a5354042241

-Updated the Slaney IIR gammatone to use a cascase of four second-order filters as per the implementtion in Slaney's auditory toolbox. This is more numerically stable at high sample rates and low centre frequencies.
author tomwalters
date Sat, 20 Feb 2010 17:56:40 +0000
parents bd370910aa05
children 491b1b1d1dc5
rev   line source
tomwalters@8 1 // Copyright 2006-2010, Willem van Engen, Thomas Walters
tomwalters@0 2 //
tomwalters@0 3 // AIM-C: A C++ implementation of the Auditory Image Model
tomwalters@0 4 // http://www.acousticscale.org/AIMC
tomwalters@0 5 //
tomwalters@0 6 // This program is free software: you can redistribute it and/or modify
tomwalters@0 7 // it under the terms of the GNU General Public License as published by
tomwalters@0 8 // the Free Software Foundation, either version 3 of the License, or
tomwalters@0 9 // (at your option) any later version.
tomwalters@0 10 //
tomwalters@0 11 // This program is distributed in the hope that it will be useful,
tomwalters@0 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
tomwalters@0 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
tomwalters@0 14 // GNU General Public License for more details.
tomwalters@0 15 //
tomwalters@0 16 // You should have received a copy of the GNU General Public License
tomwalters@0 17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
tomwalters@0 18
tomwalters@8 19 /*!
tomwalters@8 20 * \file
tomwalters@8 21 * \brief Main parameters store
tomwalters@8 22 *
tomwalters@8 23 * \author Willem van Engen <cnbh@willem.engen.nl>
tomwalters@8 24 * \author Thomas Walters <tom@acousticscale.org>
tomwalters@8 25 * \date created 2006/09/21
tomwalters@8 26 * \version \$Id: Parameters.h 4 2010-02-03 18:44:58Z tcw $
tomwalters@8 27 */
tomwalters@0 28
tomwalters@11 29 #ifndef AIMC_SUPPORT_PARAMETERS_H_
tomwalters@11 30 #define AIMC_SUPPORT_PARAMETERS_H_
tomwalters@0 31
tomwalters@1 32 #include <string>
tomwalters@1 33
tomwalters@0 34 #include "Support/SimpleIni.h"
tomwalters@0 35
tomwalters@0 36 namespace aimc {
tomwalters@0 37 /*!
tomwalters@0 38 * \class Parameters "Support/Parameters.h"
tomwalters@0 39 * \brief Main parameter store for parameters
tomwalters@0 40 */
tomwalters@0 41 class Parameters {
tomwalters@8 42 public:
tomwalters@0 43 Parameters();
tomwalters@0 44 ~Parameters();
tomwalters@0 45
tomwalters@0 46 /*!
tomwalters@0 47 * \brief Load parameter file
tomwalters@0 48 * \param sParamFilename Filename of parameter file to read
tomwalters@0 49 * \return true on succes, false on error
tomwalters@0 50 *
tomwalters@0 51 */
tomwalters@0 52 bool Load(const char *sParamFilename);
tomwalters@0 53
tomwalters@0 54 /*! \brief Save Parameter File
tomwalters@0 55 * \param sParamFilename Filename of parameter file to save
tomwalters@0 56 * \return true on success, false on error
tomwalters@0 57 */
tomwalters@0 58 bool Save(const char *sParamFilename);
tomwalters@0 59
tomwalters@0 60 /*!
tomwalters@0 61 * \brief Load parameter file and merge parameters with current, overwriting
tomwalters@0 62 * duplicates.
tomwalters@0 63 * \param sParamFilename Filename of parameter file to read
tomwalters@0 64 * \return true on succes, false on error
tomwalters@0 65 */
tomwalters@0 66 bool Merge(const char *sParamFilename);
tomwalters@0 67
tomwalters@0 68 /*! \brief Get a parameter, setting it with a default value if it is not
tomwalters@0 69 * already set
tomwalters@0 70 * \param sName Name of parameter
tomwalters@0 71 * \param val Value of the parameter
tomwalters@0 72 */
tomwalters@0 73 const char * DefaultString(const char* sName, const char *val);
tomwalters@0 74
tomwalters@0 75 /*! \overload
tomwalters@0 76 */
tomwalters@0 77 int DefaultInt(const char* sName, int val);
tomwalters@0 78
tomwalters@0 79 /*! \overload
tomwalters@0 80 */
tomwalters@0 81 unsigned int DefaultUInt(const char* sName, unsigned int val);
tomwalters@0 82
tomwalters@0 83 /*! \overload
tomwalters@0 84 */
tomwalters@0 85 float DefaultFloat(const char* sName, float val);
tomwalters@0 86
tomwalters@0 87 /*! \overload
tomwalters@0 88 */
tomwalters@0 89 bool DefaultBool(const char* sName, bool val);
tomwalters@0 90
tomwalters@0 91
tomwalters@0 92 /*! \brief Set a parameter
tomwalters@0 93 * \param sName Name of parameter
tomwalters@0 94 * \param val Value of parameter
tomwalters@0 95 */
tomwalters@0 96 void SetString(const char *sName, const char *val);
tomwalters@0 97
tomwalters@0 98 /*! \overload
tomwalters@0 99 */
tomwalters@0 100 void SetInt(const char *sName, int val);
tomwalters@0 101
tomwalters@0 102 /*! \overload
tomwalters@0 103 */
tomwalters@0 104 void SetUInt(const char *sName, unsigned int val);
tomwalters@0 105
tomwalters@0 106 /*! \overload
tomwalters@0 107 */
tomwalters@0 108 void SetFloat(const char *sName, float val);
tomwalters@0 109
tomwalters@0 110 /*! \overload
tomwalters@0 111 */
tomwalters@0 112 void SetBool(const char *sName, bool val);
tomwalters@0 113
tomwalters@0 114 /*! \brief Get the value of a parameter
tomwalters@0 115 * \param sName Name of parameter
tomwalters@0 116 * \return Value of parameter
tomwalters@0 117 *
tomwalters@0 118 * The specified parameter _must_ exist. So put every parameter you may
tomwalters@0 119 * possibly require into the default parameter file. This method returns
tomwalters@0 120 * the empty string when a value doesn't exist, but that is only to keep
tomwalters@0 121 * the application from crashing: don't count on it.
tomwalters@0 122 * You can use IsSet() however to check for a parameter's existence.
tomwalters@0 123 */
tomwalters@0 124 const char *GetString(const char *sName);
tomwalters@0 125
tomwalters@0 126 /*! \overload
tomwalters@0 127 */
tomwalters@0 128 int GetInt(const char *sName);
tomwalters@0 129
tomwalters@0 130 /*! \overload
tomwalters@0 131 */
tomwalters@0 132 unsigned int GetUInt(const char *sName);
tomwalters@0 133
tomwalters@0 134 /*! \overload
tomwalters@0 135 */
tomwalters@0 136 float GetFloat(const char *sName);
tomwalters@0 137
tomwalters@0 138 /*! \overload
tomwalters@0 139 */
tomwalters@0 140 bool GetBool(const char *sName);
tomwalters@0 141
tomwalters@0 142 /*! \brief Returns if the parameters exists or not
tomwalters@0 143 * \param sName Name of parameter
tomwalters@0 144 * \return true if exists, false if not
tomwalters@0 145 */
tomwalters@0 146 bool IsSet(const char *sName);
tomwalters@0 147
tomwalters@0 148 /*! \brief Sets a parameter assignment from a string
tomwalters@0 149 * \param sCmd String to parse
tomwalters@0 150 * \return true if parsing succeeded, false if an error occured.
tomwalters@0 151 *
tomwalters@0 152 * This function parses a string like "foo.bar=50" and sets the parameter
tomwalters@0 153 * accordingly. Use this function to parse parameter assignments as given
tomwalters@0 154 * by the user, for example on the command-line or in a parameter file.
tomwalters@0 155 */
tomwalters@0 156 bool Parse(const char *sCmd);
tomwalters@0 157
tomwalters@0 158 /*! \brief Delete a parameter. GetSection may not return correctly after
tomwalters@0 159 * this call, so it may not be possible to repopulate the parameter grid
tomwalters@0 160 * after deleting a parameter
tomwalters@0 161 * \param sName Parameter name
tomwalters@0 162 * \return true on success
tomwalters@0 163 */
tomwalters@0 164 bool Delete(const char *sName);
tomwalters@0 165
tomwalters@1 166 /*! \brief Append parameters to a string
tomwalters@1 167 * \param sName pointer to a string
tomwalters@1 168 * \return true on success
tomwalters@1 169 */
tomwalters@8 170 std::string WriteString();
tomwalters@1 171
tomwalters@8 172 /*! \brief Maximum length of a parameter name in characters
tomwalters@8 173 */
tomwalters@0 174 static const unsigned int MaxParamNameLength = 128;
tomwalters@0 175
tomwalters@8 176 protected:
tomwalters@0 177 /*!
tomwalters@0 178 * \brief Load parameter file
tomwalters@0 179 * \param sParamFilename Filename of parameter file to read
tomwalters@0 180 * \return true on succes, false on error
tomwalters@0 181 */
tomwalters@0 182 bool LoadFile(const char *sParamFilename);
tomwalters@0 183 /*!
tomwalters@0 184 * \brief Load parameter file and merge parameters with current,
tomwalters@0 185 * overwriting duplicates.
tomwalters@0 186 * \param sParamFilename Filename of parameter file to read
tomwalters@0 187 * \return true on succes, false on error
tomwalters@0 188 */
tomwalters@0 189 bool MergeFile(const char *sParamFilename);
tomwalters@0 190
tomwalters@0 191 /*! \brief Default ini-section to use
tomwalters@0 192 *
tomwalters@0 193 * Since SimpleIni is an ini-parser but we don't want the sections,
tomwalters@0 194 * we use the empty section. This gives use the behaviour desired.
tomwalters@0 195 */
tomwalters@0 196 static const char *m_SDefaultIniSection;
tomwalters@0 197
tomwalters@8 198 /*! \brief Parameter file object
tomwalters@8 199 */
tomwalters@0 200 CSimpleIniCase *m_pIni;
tomwalters@8 201 /*! \brief \c preset.include nesting counter to avoid loops
tomwalters@8 202 */
tomwalters@0 203 unsigned int m_iNestCount;
tomwalters@8 204 /*! \brief maximum value m_iNestCount may reach
tomwalters@8 205 */
tomwalters@0 206 static const unsigned int m_iNestCountMaximum = 16;
tomwalters@0 207 };
tomwalters@0 208 }
tomwalters@0 209
tomwalters@11 210 #endif // AIMC_SUPPORT_PARAMETERS_H_
tomwalters@0 211