# HG changeset patch
# User tomwalters
# Date 1266527561 0
# Node ID fcbf85ce59fb57b1691ea64e8319abb8b9fa1b04
# Parent 1a1988ec40e7869c0fb5209ab0e9e327503496cd
- Lots of changes to make cpplint happy. It still complains about header guards, but that's pretty much it now.
diff -r 1a1988ec40e7 -r fcbf85ce59fb src/Main/aimc.cc
--- a/src/Main/aimc.cc Thu Feb 18 20:04:04 2010 +0000
+++ b/src/Main/aimc.cc Thu Feb 18 21:12:41 2010 +0000
@@ -16,31 +16,31 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
+#include
+
#include
-#include
-
#include "Modules/Input/ModuleFileInput.h"
#include "Modules/BMM/ModuleGammatone.h"
#include "Modules/BMM/ModulePZFC.h"
#include "Modules/NAP/ModuleHCL.h"
#include "Modules/Strobes/ModuleParabola.h"
#include "Modules/SAI/ModuleSAI.h"
-//#include "Modules/SSI/ModuleSSI.h"
-//#include "Modules/Profile/ModuleProfile.h"
+// #include "Modules/SSI/ModuleSSI.h"
+// #include "Modules/Profile/ModuleProfile.h"
#include "Modules/Features/ModuleGaussians.h"
#include "Modules/Output/FileOutputHTK.h"
-int main (int argc, char* argv[]) {
+int main(int argc, char* argv[]) {
aimc::Parameters params;
aimc::ModuleFileInput input(¶ms);
- //aimc::ModuleGammatone bmm(¶ms);
+ // aimc::ModuleGammatone bmm(¶ms);
aimc::ModulePZFC bmm(¶ms);
aimc::ModuleHCL nap(¶ms);
aimc::ModuleParabola strobes(¶ms);
aimc::ModuleSAI sai(¶ms);
- //aimc::ModuleSSI ssi(¶ms);
- //aimc::ModuleProfile profile(¶ms);
+ // aimc::ModuleSSI ssi(¶ms);
+ // aimc::ModuleProfile profile(¶ms);
aimc::ModuleGaussians features(¶ms);
aimc::FileOutputHTK output(¶ms);
@@ -52,8 +52,8 @@
nap.AddTarget(&strobes);
strobes.AddTarget(&sai);
sai.AddTarget(&features);
- //ssi.AddTarget(&profile);
- //profile.AddTarget(&features);
+ // ssi.AddTarget(&profile);
+ // profile.AddTarget(&features);
features.AddTarget(&output);
output.OpenFile("test_output.htk", params.GetFloat("sai.frame_period_ms"));
@@ -62,4 +62,4 @@
} else {
printf("LoadFile failed");
}
-}
\ No newline at end of file
+}
diff -r 1a1988ec40e7 -r fcbf85ce59fb src/Modules/BMM/ModuleGammatone.cc
--- a/src/Modules/BMM/ModuleGammatone.cc Thu Feb 18 20:04:04 2010 +0000
+++ b/src/Modules/BMM/ModuleGammatone.cc Thu Feb 18 21:12:41 2010 +0000
@@ -24,8 +24,8 @@
* \version \$Id$
*/
+#include
#include
-#include
#include "Support/ERBTools.h"
#include "Modules/BMM/ModuleGammatone.h"
@@ -64,8 +64,8 @@
float erb_current = erb_min;
for (int i = 0; i < num_channels_; ++i) {
- centre_frequencies_[i] = ERBTools::ERB2Freq(erb_current);
- erb_current += delta_erb;
+ centre_frequencies_[i] = ERBTools::ERB2Freq(erb_current);
+ erb_current += delta_erb;
}
forward_.resize(num_channels_);
@@ -82,8 +82,8 @@
// Bandwidth parameter
float b = 1.019f * 2.0f * M_PI * erb;
- // All of the following expressions are derived in Apple TR #35, "An
- // Efficient Implementation of the Patterson-Holdsworth Cochlear
+ // All of the following expressions are derived in Apple TR #35, "An
+ // Efficient Implementation of the Patterson-Holdsworth Cochlear
// Filter Bank".
// Calculate the gain:
@@ -152,7 +152,7 @@
for (int ch = 0; ch < num_channels_; ++ch, ++a, ++b, ++s) {
for (int i = 0; i < input.buffer_length(); ++i) {
- // Direct-form-II IIR filter
+ // Direct-form-II IIR filter
float in = input.sample(audio_channel, i);
float out = (*b)[0] * in + (*s)[0];
for (unsigned int stage = 1; stage < s->size(); ++stage)
@@ -163,4 +163,4 @@
PushOutput();
}
-} // namespace aimc
\ No newline at end of file
+} // namespace aimc
diff -r 1a1988ec40e7 -r fcbf85ce59fb src/Modules/BMM/ModuleGammatone.h
--- a/src/Modules/BMM/ModuleGammatone.h Thu Feb 18 20:04:04 2010 +0000
+++ b/src/Modules/BMM/ModuleGammatone.h Thu Feb 18 21:12:41 2010 +0000
@@ -23,6 +23,8 @@
* \date created 2009/11/13
* \version \$Id$
*/
+#ifndef _AIMC_MODULES_BMM_GAMMATONE_H_
+#define _AIMC_MODULES_BMM_GAMMATONE_H_
#include
@@ -34,9 +36,10 @@
using std::vector;
class ModuleGammatone : public Module {
public:
- ModuleGammatone(Parameters *params);
+ explicit ModuleGammatone(Parameters *params);
virtual ~ModuleGammatone();
- //! \brief Process a buffer
+ /*! \brief Process a buffer
+ */
virtual void Process(const SignalBank &input);
private:
@@ -50,4 +53,5 @@
float max_frequency_;
float min_frequency_;
};
-} // namespace aimc
\ No newline at end of file
+} // namespace aimc
+#endif // _AIMC_MODULES_BMM_GAMMATONE_H_
diff -r 1a1988ec40e7 -r fcbf85ce59fb src/Modules/BMM/ModulePZFC.h
--- a/src/Modules/BMM/ModulePZFC.h Thu Feb 18 20:04:04 2010 +0000
+++ b/src/Modules/BMM/ModulePZFC.h Thu Feb 18 21:12:41 2010 +0000
@@ -16,14 +16,15 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-//! \file
-//! \brief Dick Lyon's Pole-Zero Filter Cascade - implemented in C++ by Tom
-//! Walters from the AIM-MAT module based on Dick Lyon's code.
-//!
-//! \author Thomas Walters
-//! \date created 2008/02/05
-//! \version \$Id: ModulePZFC.h 2 2010-02-02 12:59:50Z tcw $
-//!
+/*! \file
+ * \brief Dick Lyon's Pole-Zero Filter Cascade - implemented in C++ by Tom
+ * Walters from the AIM-MAT module based on Dick Lyon's code.
+ *
+ * \author Thomas Walters
+ * \date created 2008/02/05
+ * \version \$Id: ModulePZFC.h 2 2010-02-02 12:59:50Z tcw $
+ */
+
#ifndef _AIMC_MODULES_BMM_PZFC_H_
#define _AIMC_MODULES_BMM_PZFC_H_
@@ -37,36 +38,44 @@
using std::vector;
class ModulePZFC : public Module {
public:
- ModulePZFC(Parameters *pParam);
+ explicit ModulePZFC(Parameters *pParam);
virtual ~ModulePZFC();
- //! \brief Process a buffer
+ /*! \brief Process a buffer
+ */
virtual void Process(const SignalBank &input);
private:
- //! \brief Reset all internal state variables to their initial values
- virtual void ResetInternal();
+ /*! \brief Reset all internal state variables to their initial values
+ */
+ virtual void ResetInternal();
- //! \brief Prepare the module
- //! \param input Input SignalBank
- //! \param output true on success false on failure
+ /*! \brief Prepare the module
+ * \param input Input SignalBank
+ * \param output true on success false on failure
+ */
virtual bool InitializeInternal(const SignalBank &input);
- //! \brief Set the filterbank parameters according to a fit matrix from Unoki
- //! and Lyon's fitting routine
+ /*! \brief Set the filterbank parameters according to a fit matrix from Unoki
+ * and Lyon's fitting routine
+ */
bool SetPZBankCoeffsERBFitted();
- //! \brief Sets the general filterbank coefficients
+ /*! \brief Sets the general filterbank coefficients
+ */
bool SetPZBankCoeffs();
- //! \brief Automatic Gain Control
+ /*! \brief Automatic Gain Control
+ */
void AGCDampStep();
- //! \brief Detector function - halfwave rectification etc. Used internally,
- //! but not applied to the output.
+ /*! \brief Detector function - halfwave rectification etc. Used internally,
+ * but not applied to the output.
+ */
float DetectFun(float fIN);
- //! \brief Minimum
+ /*! \brief Minimum
+ */
inline float Minimum(float a, float b);
int channel_count_;
diff -r 1a1988ec40e7 -r fcbf85ce59fb src/Modules/Features/ModuleGaussians.cc
--- a/src/Modules/Features/ModuleGaussians.cc Thu Feb 18 20:04:04 2010 +0000
+++ b/src/Modules/Features/ModuleGaussians.cc Thu Feb 18 21:12:41 2010 +0000
@@ -96,15 +96,15 @@
++iSample) {
m_pSpectralProfile[iChannel] += input[iChannel][iSample];
}
- m_pSpectralProfile[iChannel] /= static_cast(input.buffer_length());
+ m_pSpectralProfile[iChannel] /= static_cast(input.buffer_length());
}
- double spectral_profile_sum = 0.0f;
+ float spectral_profile_sum = 0.0f;
for (int i = 0; i < input.channel_count(); ++i) {
spectral_profile_sum += m_pSpectralProfile[i];
}
- double logsum = log(spectral_profile_sum);
+ float logsum = log(spectral_profile_sum);
if (!isinf(logsum)) {
output_.set_sample(m_iParamNComp - 1, 0, logsum);
} else {
@@ -119,33 +119,34 @@
RubberGMMCore(2, true);
- double fMean1 = m_pMu[0];
- double fMean2 = m_pMu[1];
- //LOG_INFO(_T("Orig. mean 0 = %f"), m_pMu[0]);
- //LOG_INFO(_T("Orig. mean 1 = %f"), m_pMu[1]);
- //LOG_INFO(_T("Orig. prob 0 = %f"), m_pA[0]);
- //LOG_INFO(_T("Orig. prob 1 = %f"), m_pA[1]);
+ float fMean1 = m_pMu[0];
+ float fMean2 = m_pMu[1];
+ // LOG_INFO(_T("Orig. mean 0 = %f"), m_pMu[0]);
+ // LOG_INFO(_T("Orig. mean 1 = %f"), m_pMu[1]);
+ // LOG_INFO(_T("Orig. prob 0 = %f"), m_pA[0]);
+ // LOG_INFO(_T("Orig. prob 1 = %f"), m_pA[1]);
- double fA1 = 0.05 * m_pA[0];
- double fA2 = 1.0 - 0.25 * m_pA[1];
+ float fA1 = 0.05 * m_pA[0];
+ float fA2 = 1.0 - 0.25 * m_pA[1];
- //LOG_INFO(_T("fA1 = %f"), fA1);
- //LOG_INFO(_T("fA2 = %f"), fA2);
+ // LOG_INFO(_T("fA1 = %f"), fA1);
+ // LOG_INFO(_T("fA2 = %f"), fA2);
- double fGradient = (fMean2 - fMean1) / (fA2 - fA1);
- double fIntercept = fMean2 - fGradient * fA2;
+ float fGradient = (fMean2 - fMean1) / (fA2 - fA1);
+ float fIntercept = fMean2 - fGradient * fA2;
- //LOG_INFO(_T("fGradient = %f"), fGradient);
- //LOG_INFO(_T("fIntercept = %f"), fIntercept);
+ // LOG_INFO(_T("fGradient = %f"), fGradient);
+ // LOG_INFO(_T("fIntercept = %f"), fIntercept);
for (int i = 0; i < m_iParamNComp; ++i) {
- m_pMu[i] = ((double)i / ((double)m_iParamNComp - 1.0f))
- * fGradient + fIntercept;
- //LOG_INFO(_T("mean %d = %f"), i, m_pMu[i]);
+ m_pMu[i] = (static_cast(i)
+ / (static_cast(m_iParamNComp) - 1.0f))
+ * fGradient + fIntercept;
+ // LOG_INFO(_T("mean %d = %f"), i, m_pMu[i]);
}
for (int i = 0; i < m_iParamNComp; ++i) {
- m_pA[i] = 1.0f / (double)m_iParamNComp;
+ m_pA[i] = 1.0f / static_cast(m_iParamNComp);
}
RubberGMMCore(m_iParamNComp, false);
@@ -165,7 +166,7 @@
int iSizeX = m_iNumChannels;
// Normalise the spectral profile
- double fSpectralProfileTotal = 0.0f;
+ float fSpectralProfileTotal = 0.0f;
for (int iCount = 0; iCount < iSizeX; iCount++) {
fSpectralProfileTotal += m_pSpectralProfile[iCount];
}
@@ -175,18 +176,18 @@
if (bDoInit) {
// Uniformly spaced components
- double dd = (iSizeX - 1.0f) / iNComponents;
+ float dd = (iSizeX - 1.0f) / iNComponents;
for (int i = 0; i < iNComponents; i++) {
m_pMu[i] = dd / 2.0f + (i * dd);
m_pA[i] = 1.0f / iNComponents;
}
}
- vector pA_old;
+ vector pA_old;
pA_old.resize(iNComponents);
- vector pP_mod_X;
+ vector pP_mod_X;
pP_mod_X.resize(iSizeX);
- vector pP_comp;
+ vector pP_comp;
pP_comp.resize(iSizeX * iNComponents);
for (int iIteration = 0; iIteration < m_iParamMaxIt; iIteration++) {
@@ -199,8 +200,9 @@
for (int i = 0; i < iNComponents; i++) {
for (int iCount = 0; iCount < iSizeX; iCount++) {
pP_mod_X[iCount] += 1.0f / sqrt(2.0f * M_PI * m_fParamVar)
- * exp((-0.5f) * pow(((double)(iCount + 1)-m_pMu[i]), 2)
- / m_fParamVar) * m_pA[i];
+ * exp((-0.5f)
+ * pow(static_cast(iCount+1) - m_pMu[i], 2)
+ / m_fParamVar) * m_pA[i];
}
}
@@ -212,17 +214,18 @@
for (int iCount = 0; iCount < iSizeX; iCount++) {
pP_comp[iCount + i * iSizeX] =
1.0f / sqrt(2.0f * M_PI * m_fParamVar)
- * exp((-0.5f) * pow(((double)(iCount + 1) - m_pMu[i]), 2) / m_fParamVar);
+ * exp((-0.5f) * pow((static_cast(iCount + 1) - m_pMu[i]), 2)
+ / m_fParamVar);
pP_comp[iCount + i * iSizeX] =
pP_comp[iCount + i * iSizeX] * m_pA[i] / pP_mod_X[iCount];
}
}
for (int iCount = 0; iCount < iSizeX; ++iCount) {
- double fSum = 0.0f;
+ float fSum = 0.0f;
for (int i = 0; i < iNComponents; ++i) {
pP_comp[iCount+i*iSizeX] = pow(pP_comp[iCount + i * iSizeX],
- m_fParamPosteriorExp); // expansion
+ m_fParamPosteriorExp); // expansion
fSum += pP_comp[iCount+i*iSizeX];
}
for (int i = 0; i < iNComponents; ++i)
@@ -239,27 +242,28 @@
}
// finish when already converged
- double fPrdist = 0.0f;
+ float fPrdist = 0.0f;
for (int i = 0; i < iNComponents; ++i) {
fPrdist += pow((m_pA[i] - pA_old[i]), 2);
}
fPrdist /= iNComponents;
if (fPrdist < m_fParamPriorsConverged) {
- //LOG_INFO("Converged!");
+ // LOG_INFO("Converged!");
break;
}
- //LOG_INFO("Didn't converge!");
+ // LOG_INFO("Didn't converge!");
// update means (positions)
for (int i = 0 ; i < iNComponents; ++i) {
- double mu_old = m_pMu[i];
+ float mu_old = m_pMu[i];
if (m_pA[i] > 0.0f) {
m_pMu[i] = 0.0f;
for (int iCount = 0; iCount < iSizeX; ++iCount) {
m_pMu[i] += m_pSpectralProfile[iCount]
- * pP_comp[iCount + i * iSizeX] * (double)(iCount + 1);
+ * pP_comp[iCount + i * iSizeX]
+ * static_cast(iCount + 1);
}
m_pMu[i] /= m_pA[i];
if (isnan(m_pMu[i])) {
@@ -267,7 +271,7 @@
}
}
}
- } // loop over iterations
+ } // loop over iterations
// Ensure they are sorted, using a really simple bubblesort
bool bSorted = false;
@@ -275,7 +279,7 @@
bSorted = true;
for (int i = 0; i < iNComponents - 1; ++i) {
if (m_pMu[i] > m_pMu[i + 1]) {
- double fTemp = m_pMu[i];
+ float fTemp = m_pMu[i];
m_pMu[i] = m_pMu[i + 1];
m_pMu[i + 1] = fTemp;
fTemp = m_pA[i];
@@ -287,5 +291,5 @@
}
return true;
}
-} //namespace aimc
+} // namespace aimc
diff -r 1a1988ec40e7 -r fcbf85ce59fb src/Modules/Features/ModuleGaussians.h
--- a/src/Modules/Features/ModuleGaussians.h Thu Feb 18 20:04:04 2010 +0000
+++ b/src/Modules/Features/ModuleGaussians.h Thu Feb 18 21:12:41 2010 +0000
@@ -39,17 +39,18 @@
*/
namespace aimc {
using std::vector;
-class ModuleGaussians : public Module
-{
+class ModuleGaussians : public Module {
public:
- ModuleGaussians(Parameters *pParam);
+ explicit ModuleGaussians(Parameters *pParam);
virtual ~ModuleGaussians();
- //! \brief Process a buffer
+ /*! \brief Process a buffer
+ */
virtual void Process(const SignalBank &input);
private:
- //! \brief Reset the internal state of the module
+ /*! \brief Reset the internal state of the module
+ */
virtual void ResetInternal();
/*! \brief Prepare the module
@@ -66,11 +67,11 @@
/*! \brief Constant variance of Gaussians
*/
- double m_fParamVar;
+ float m_fParamVar;
/*! \brief posterior probability expansion exponent
*/
- double m_fParamPosteriorExp;
+ float m_fParamPosteriorExp;
/*! \brief Maximum Number of iterations
*/
@@ -78,19 +79,19 @@
/*! \brief convergence criterion
*/
- double m_fParamPriorsConverged;
+ float m_fParamPriorsConverged;
/*! \brief The amplitudes of the components (priors)
*/
- vector m_pA;
+ vector m_pA;
/*! \brief The means of the components (priors)
*/
- vector m_pMu;
+ vector m_pMu;
/*! \brief The spectral profile of the incoming buffer
*/
- vector m_pSpectralProfile;
+ vector m_pSpectralProfile;
int m_iNumChannels;
};
diff -r 1a1988ec40e7 -r fcbf85ce59fb src/Modules/Input/ModuleFileInput.cc
--- a/src/Modules/Input/ModuleFileInput.cc Thu Feb 18 20:04:04 2010 +0000
+++ b/src/Modules/Input/ModuleFileInput.cc Thu Feb 18 21:12:41 2010 +0000
@@ -58,11 +58,12 @@
bool ModuleFileInput::LoadFile(const char* filename) {
// Open the file
SF_INFO sfinfo;
- memset((void*)&sfinfo, 0, sizeof(SF_INFO));
+ memset(reinterpret_cast(&sfinfo), 0, sizeof(SF_INFO));
file_handle_ = sf_open(filename, SFM_READ, &sfinfo);
if (file_handle_ == NULL) {
- //! \todo Also display error reason
+ /*! \todo Also display error reason
+ */
LOG_ERROR(_T("Couldn't read audio file '%s'"), filename);
return false;
}
diff -r 1a1988ec40e7 -r fcbf85ce59fb src/Modules/Input/ModuleFileInput.h
--- a/src/Modules/Input/ModuleFileInput.h Thu Feb 18 20:04:04 2010 +0000
+++ b/src/Modules/Input/ModuleFileInput.h Thu Feb 18 21:12:41 2010 +0000
@@ -37,7 +37,7 @@
namespace aimc {
class ModuleFileInput : public Module {
public:
- ModuleFileInput(Parameters *pParam);
+ explicit ModuleFileInput(Parameters *pParam);
virtual ~ModuleFileInput();
/*! \brief Initializes this input device using an audio file
@@ -46,29 +46,36 @@
*/
bool LoadFile(const char *sFilename);
- //! \brief Process the loaded file.
+ /*! \brief Process the loaded file.
+ */
void Process();
- //! \brief Dummy Initialize function. Call LoadFile instead.
+ /*! \brief Dummy Initialize function. Call LoadFile instead.
+ */
virtual bool Initialize(const SignalBank &input);
- //! \brief Dummy funciton to comply with the Module specification. Gives an
- // error message when called.
+ /*! \brief Dummy funciton to comply with the Module specification. Gives an
+ * error message when called.
+ */
virtual void Process(const SignalBank &input);
private:
- //! \brief Prepare the module
- //! \param input Input SignalBank
- //! \param output true on success false on failure
+ /*! \brief Prepare the module
+ * \param input Input SignalBank
+ * \param output true on success false on failure
+ */
virtual bool InitializeInternal(const SignalBank &input);
- //! \brief Rewind to the start of the file
+ /*! \brief Rewind to the start of the file
+ */
virtual void ResetInternal();
- //! \brief File descriptor
+ /*! \brief File descriptor
+ */
SNDFILE *file_handle_;
- //! \brief Current position in time of the file
+ /*! \brief Current position in time of the file
+ */
int file_position_samples_;
bool file_loaded_;
int audio_channels_;
@@ -77,4 +84,4 @@
};
} // namespace aimc
-#endif // _AIMC_MODULES_INPUT_FILE_H_
+#endif // _AIMC_MODULES_INPUT_FILE_H_
diff -r 1a1988ec40e7 -r fcbf85ce59fb src/Modules/NAP/ModuleHCL.cc
--- a/src/Modules/NAP/ModuleHCL.cc Thu Feb 18 20:04:04 2010 +0000
+++ b/src/Modules/NAP/ModuleHCL.cc Thu Feb 18 21:12:41 2010 +0000
@@ -80,7 +80,7 @@
} else {
float s = input[c][i];
if (do_log_) {
- s *= pow(2.0f,15);
+ s *= pow(2.0f, 15);
if (s < 1.0f) s = 1.0f;
s = 20.0f * log10(s);
}
@@ -88,7 +88,7 @@
}
}
if (do_lowpass_) {
- float b = exp( -1.0f / (input.sample_rate() * time_constant_));
+ float b = exp(-1.0f / (input.sample_rate() * time_constant_));
float gain = 1.0f / (1.0f - b);
for (int j = 0; j < lowpass_order_; j++) {
for (int k = 0; k < output_.buffer_length(); ++k) {
diff -r 1a1988ec40e7 -r fcbf85ce59fb src/Modules/NAP/ModuleHCL.h
--- a/src/Modules/NAP/ModuleHCL.h Thu Feb 18 20:04:04 2010 +0000
+++ b/src/Modules/NAP/ModuleHCL.h Thu Feb 18 21:12:41 2010 +0000
@@ -38,7 +38,7 @@
using std::vector;
class ModuleHCL : public Module {
public:
- ModuleHCL(Parameters *parameters);
+ explicit ModuleHCL(Parameters *parameters);
virtual ~ModuleHCL();
virtual void Process(const SignalBank &input);
@@ -52,25 +52,33 @@
virtual void ResetInternal();
- //! \brief Do lowpass filtering?
+ /*! \brief Do lowpass filtering?
+ */
bool do_lowpass_;
- //! \brief Do log compression?
+ /*! \brief Do log compression?
+ */
bool do_log_;
- //! \brief Cutoff frequency for lowpass filter
+ /*! \brief Cutoff frequency for lowpass filter
+ */
float lowpass_cutoff_;
- //! \brief Order of Lowpass Filter
+ /*! \brief Order of Lowpass Filter
+ */
int lowpass_order_;
- //! \brief Internal record of the number of channels in the input
+ /*! \brief Internal record of the number of channels in the input
+ */
int channel_count_;
- //! \brief Time constant corresponsing to the lowpass filter cutoff freqency
+ /*! \brief Time constant corresponsing to the lowpass filter
+ * cutoff freqency
+ */
float time_constant_;
- //! \brief Lowpass filter state variables
+ /*! \brief Lowpass filter state variables
+ */
float xn_;
float yn_;
vector > yns_;
diff -r 1a1988ec40e7 -r fcbf85ce59fb src/Modules/Output/FileOutputHTK.cc
--- a/src/Modules/Output/FileOutputHTK.cc Thu Feb 18 20:04:04 2010 +0000
+++ b/src/Modules/Output/FileOutputHTK.cc Thu Feb 18 21:12:41 2010 +0000
@@ -27,10 +27,10 @@
*/
#ifdef _WINDOWS
-# include // for _mkdir&_rmdir
+# include // for _mkdir&_rmdir
#else
# include
-# include // for opendir&friends
+# include // for opendir&friends
#endif
#include
#include
@@ -63,7 +63,7 @@
}
// Check that the output file exists and is writeable
- if ((file_handle_ = fopen(filename, "wb"))==NULL ) {
+ if ((file_handle_ = fopen(filename, "wb")) == NULL) {
LOG_ERROR(_T("Couldn't open output file '%s' for writing."), filename);
return false;
}
@@ -157,7 +157,7 @@
for (int i = 0; i < input.buffer_length(); i++) {
s = input.sample(ch, i);
s = ByteSwapFloat(s);
- fwrite(&s, sizeof(float), 1, file_handle_);
+ fwrite(&s, sizeof(s), 1, file_handle_);
}
}
sample_count_++;
@@ -195,5 +195,5 @@
return a;
}
-} //namespace aimc
+} // namespace aimc
diff -r 1a1988ec40e7 -r fcbf85ce59fb src/Modules/Output/FileOutputHTK.h
--- a/src/Modules/Output/FileOutputHTK.h Thu Feb 18 20:04:04 2010 +0000
+++ b/src/Modules/Output/FileOutputHTK.h Thu Feb 18 21:12:41 2010 +0000
@@ -1,46 +1,62 @@
+// Copyright 2006-2010, Thomas Walters, Willem van Engen
+//
+// AIM-C: A C++ implementation of the Auditory Image Model
+// http://www.acousticscale.org/AIMC
+//
+// 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.
+//
+// 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.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+
/*!
* \file
* \brief File output to HTK format class definition
*
- * \author Tom Walters and Willem van Engen
+ * \author Tom Walters
+ * \author Willem van Engen
* \date created 2006/10/30
* \version \$Header$
*/
-/* (c) 2006, University of Cambridge, Medical Research Council
- * http://www.pdn.cam.ac.uk/groups/cnbh/aimmanual
- */
+
#ifndef _AIMC_MODULE_OUTPUT_HTK_H_
#define _AIMC_MODULE_OUTPUT_HTK_H_
#include "Support/Module.h"
#include "Support/SignalBank.h"
+// Defines taken from HTKwrite.c and The HTK Book
+#define H_WAVEFORM 0 // sampled waveform
+#define H_LPC 1 // linear prediction filter coefficients
+#define H_LPREFC 2 // linear prediction reflection coefficients
+#define H_LPCEPSTRA 3 // LPC cepstral coefficients
+#define H_LPDELCEP 4 // LPC cepstra plus delta coefficients
+#define H_IREFC 5 // LPC reflection coef in 16 bit integer format
+#define H_MFCC 6 // mel-frequency cepstral coefficients
+#define H_FBANK 7 // log mel-filter bank channel outputs
+#define H_MELSPEC 8 // linear mel-filter bank channel outputs
+#define H_USER 9 // user defined sample kind
+#define H_DISCRETE 10 // vector quantised data
+#define H_PLP 11 // Perceptual Linear Prediction
+#define H_ANON 12 // Anonymous
-// Defines taken from HTKwrite.c and The HTK Book
-#define H_WAVEFORM 0 //sampled waveform
-#define H_LPC 1 //linear prediction filter coefficients
-#define H_LPREFC 2 //linear prediction reflection coefficients
-#define H_LPCEPSTRA 3 //LPC cepstral coefficients
-#define H_LPDELCEP 4 //LPC cepstra plus delta coefficients
-#define H_IREFC 5 //LPC reflection coef in 16 bit integer format
-#define H_MFCC 6 //mel-frequency cepstral coefficients
-#define H_FBANK 7 //log mel-filter bank channel outputs
-#define H_MELSPEC 8 //linear mel-filter bank channel outputs
-#define H_USER 9 //user defined sample kind
-#define H_DISCRETE 10 //vector quantised data
-#define H_PLP 11 // Perceptual Linear Prediction
-#define H_ANON 12
-
-#define H_E 64 //has energy
-#define H_N 128 //absolute energy suppressed
-#define H_D 256 //has delta coefficients
-#define H_A 512 //has acceleration coefficients
-#define H_C 1024 //is compressed
-#define H_Z 2048 //has zero mean static coef.
-#define H_K 4096 //has CRC checksum
-#define H_O 8192 //has 0th cepstral coef.
-#define H_V 16384 // Attach vq index
-#define H_T 32768 // Attach delta-delta-delta index
+#define H_E 64 // has energy
+#define H_N 128 // absolute energy suppressed
+#define H_D 256 // has delta coefficients
+#define H_A 512 // has acceleration coefficients
+#define H_C 1024 // is compressed
+#define H_Z 2048 // has zero mean static coef.
+#define H_K 4096 // has CRC checksum
+#define H_O 8192 // has 0th cepstral coef.
+#define H_V 16384 // Attach vq index
+#define H_T 32768 // Attach delta-delta-delta index
// HTK fomat is big-endian...
#define ByteSwap16(n) \
@@ -66,7 +82,7 @@
/*! \brief Create a new file output for an HTK format file. Use of this
* class only really makes sense for the output of 1-D frames.
*/
- FileOutputHTK(Parameters *pParam);
+ explicit FileOutputHTK(Parameters *pParam);
~FileOutputHTK();
/*! \brief Initialize the output to HTK.
@@ -85,15 +101,20 @@
void WriteHeader(int nelements, float sampPeriod);
- //! \brief Whether initialization is done or not
+ /*! \brief Whether initialization is done or not
+ */
bool header_written_;
- //! \brief Filename
+ /*! \brief Filename
+ */
char filename_[PATH_MAX];
- //! \brief Internal pointer to the output file
+
+ /*! \brief Internal pointer to the output file
+ */
FILE *file_handle_;
- //! \brief Count of the number of samples in the file, written on close
+ /*! \brief Count of the number of samples in the file, written on close
+ */
int sample_count_;
int channel_count_;
diff -r 1a1988ec40e7 -r fcbf85ce59fb src/Modules/SAI/ModuleSAI.cc
--- a/src/Modules/SAI/ModuleSAI.cc Thu Feb 18 20:04:04 2010 +0000
+++ b/src/Modules/SAI/ModuleSAI.cc Thu Feb 18 21:12:41 2010 +0000
@@ -69,7 +69,7 @@
LOG_ERROR("Failed to create output buffer in SAI module");
return false;
}
- for (int i = 0; i < input.channel_count(); ++i ) {
+ for (int i = 0; i < input.channel_count(); ++i) {
output_.set_centre_frequency(i, input.centre_frequency(i));
}
@@ -114,7 +114,6 @@
}
void ModuleSAI::Process(const SignalBank &input) {
-
// Reset the next strobe times
next_strobes_.clear();
next_strobes_.resize(output_.channel_count(), 0);
@@ -213,8 +212,7 @@
}
next_strobes_[ch] = next_strobe_index;
-
- } // End loop over channels
+ } // End loop over channels
fire_counter_--;
@@ -243,7 +241,7 @@
output_.set_start_time(input.start_time() + i);
PushOutput();
}
- } // End loop over samples
+ } // End loop over samples
}
ModuleSAI::~ModuleSAI() {
diff -r 1a1988ec40e7 -r fcbf85ce59fb src/Modules/SAI/ModuleSAI.h
--- a/src/Modules/SAI/ModuleSAI.h Thu Feb 18 20:04:04 2010 +0000
+++ b/src/Modules/SAI/ModuleSAI.h Thu Feb 18 21:12:41 2010 +0000
@@ -37,7 +37,7 @@
using std::vector;
class ModuleSAI : public Module {
public:
- ModuleSAI(Parameters *parameters);
+ explicit ModuleSAI(Parameters *parameters);
virtual ~ModuleSAI();
void Process(const SignalBank &input);
@@ -50,28 +50,36 @@
virtual void ResetInternal();
- //! \brief Temporary buffer for constructing the current SAI frame
+ /*! \brief Temporary buffer for constructing the current SAI frame
+ */
SignalBank sai_temp_;
- //! \brief List of strobes for each channel
+ /*! \brief List of strobes for each channel
+ */
vector active_strobes_;
- //! \brief Buffer decay parameter
+ /*! \brief Buffer decay parameter
+ */
float buffer_memory_decay_;
- //! \brief Sample index of minimum strobe delay
+ /*! \brief Sample index of minimum strobe delay
+ */
int min_strobe_delay_idx_;
- //! \brief Sample index of maximum strobe delay
+ /*! \brief Sample index of maximum strobe delay
+ */
int max_strobe_delay_idx_;
- //! \brief Factor with which the SAI should be decayed
+ /*! \brief Factor with which the SAI should be decayed
+ */
float sai_decay_factor_;
- //! \brief Precomputed 1/n^alpha values for strobe weighting
+ /*! \brief Precomputed 1/n^alpha values for strobe weighting
+ */
vector strobe_weights_;
- //! \brief Next Strobe for each channels
+ /*! \brief Next Strobe for each channels
+ */
vector next_strobes_;
float strobe_weight_alpha_;
@@ -83,7 +91,8 @@
int fire_counter_;
- //! \brief Period in milliseconds between output frames
+ /*! \brief Period in milliseconds between output frames
+ */
float frame_period_ms_;
int frame_period_samples_;
diff -r 1a1988ec40e7 -r fcbf85ce59fb src/Modules/Strobes/ModuleParabola.h
--- a/src/Modules/Strobes/ModuleParabola.h Thu Feb 18 20:04:04 2010 +0000
+++ b/src/Modules/Strobes/ModuleParabola.h Thu Feb 18 21:12:41 2010 +0000
@@ -42,10 +42,10 @@
using std::vector;
class ModuleParabola : public Module {
public:
- ModuleParabola(Parameters *params);
+ explicit ModuleParabola(Parameters *params);
virtual ~ModuleParabola();
void Process(const SignalBank& input);
-private:
+ private:
/*! \brief Prepare the module
* \param input Input signal bank
* \param output true on success false on failure
@@ -55,7 +55,9 @@
virtual void ResetInternal();
- //! \brief Number of samples over which the strobe should be decayed to zero
+ /*! \brief Number of samples over which the strobe should be decayed to
+ * zero
+ */
int strobe_decay_samples_;
/*! \brief Current strobe thresholds, one for each bank channel.
@@ -70,25 +72,32 @@
*/
vector last_threshold_;
- //! \brief Parabola height parameter
+ /*! \brief Parabola height parameter
+ */
float height_;
- //! \brief Parabola width paramters
+ /*! \brief Parabola width paramters
+ */
float parabw_;
- //! \brief Parabola a value
+ /*! \brief Parabola a value
+ */
vector parab_a_;
- //! \brief Parabola b value
+ /*! \brief Parabola b value
+ */
vector parab_b_;
- //! \brief Parabola calculation variable
+ /*! \brief Parabola calculation variable
+ */
vector parab_wnull_;
- //! \brief Parabola calculation variable
+ /*! \brief Parabola calculation variable
+ */
vector parab_var_samples_;
- //! \brief Storage for the number of samples since the last strobe
+ /*! \brief Storage for the number of samples since the last strobe
+ */
vector samples_since_last_strobe_;
vector prev_sample_;
diff -r 1a1988ec40e7 -r fcbf85ce59fb src/Support/Common.h
--- a/src/Support/Common.h Thu Feb 18 20:04:04 2010 +0000
+++ b/src/Support/Common.h Thu Feb 18 21:12:41 2010 +0000
@@ -85,7 +85,7 @@
# define AIM_ASSERT(x) { \
if (!(x)) { \
LOG_ERROR("Assertion failed.\n"); \
- *((char*)0) = 0; \
+ *(reinterpret_cast(0)) = 0; \
} \
}
#else
diff -r 1a1988ec40e7 -r fcbf85ce59fb src/Support/Module.cc
--- a/src/Support/Module.cc Thu Feb 18 20:04:04 2010 +0000
+++ b/src/Support/Module.cc Thu Feb 18 21:12:41 2010 +0000
@@ -131,5 +131,5 @@
}
}
}
-} // namespace aimc
+} // namespace aimc
diff -r 1a1988ec40e7 -r fcbf85ce59fb src/Support/Module.h
--- a/src/Support/Module.h Thu Feb 18 20:04:04 2010 +0000
+++ b/src/Support/Module.h Thu Feb 18 21:12:41 2010 +0000
@@ -107,7 +107,7 @@
/*! \brief Reset the internal state of this module and all its children to
* their initial state.
*/
- void Reset() ;
+ void Reset();
/*! \brief
*/
diff -r 1a1988ec40e7 -r fcbf85ce59fb src/Support/Parameters.cc
--- a/src/Support/Parameters.cc Thu Feb 18 20:04:04 2010 +0000
+++ b/src/Support/Parameters.cc Thu Feb 18 21:12:41 2010 +0000
@@ -16,13 +16,14 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-//!
-//! \file
-//! \brief Main parameters store
-//!
-//! \author Willem van Engen
-//! \date created 2006/09/21
-//! \version \$Id: Parameters.cc 4 2010-02-03 18:44:58Z tcw $
+/*!
+ * \file
+ * \brief Main parameters store
+ *
+ * \author Willem van Engen
+ * \date created 2006/09/21
+ * \version \$Id: Parameters.cc 4 2010-02-03 18:44:58Z tcw $
+ */
#include
#include
@@ -130,14 +131,14 @@
}
float Parameters::GetFloat(const char *sName) {
- return (float)atof(GetString(sName));
+ return atof(GetString(sName));
}
bool Parameters::GetBool(const char *sName) {
const char *sVal = GetString(sName);
- if (strcmp(sVal, "true")==0 || strcmp(sVal, "on")==0 ||
- strcmp(sVal, "yes")==0 || strcmp(sVal, "1")==0 ||
- strcmp(sVal, "y")==0 || strcmp(sVal, "t")==0)
+ if (strcmp(sVal, "true") == 0 || strcmp(sVal, "on") == 0 ||
+ strcmp(sVal, "yes") == 0 || strcmp(sVal, "1") == 0 ||
+ strcmp(sVal, "y") == 0 || strcmp(sVal, "t") == 0)
return true;
else
return false;
@@ -145,11 +146,12 @@
bool Parameters::IsSet(const char *sName) {
AIM_ASSERT(m_pIni);
- return m_pIni->GetValue(m_SDefaultIniSection, sName, NULL)!=NULL;
+ return m_pIni->GetValue(m_SDefaultIniSection, sName, NULL) != NULL;
}
bool Parameters::Parse(const char *sCmd) {
- //! \todo There is some code duplication here from Parameters::Merge()
+ /*! \todo There is some code duplication here from Parameters::Merge()
+ */
CSimpleIniCase *pIni2 = new CSimpleIniCase(false, false, true);
AIM_ASSERT(pIni2);
@@ -193,9 +195,9 @@
}
m_iNestCount++;
- if ( (siErr=m_pIni->LoadFile(sParamFilename))<0 ) {
+ if ((siErr=m_pIni->LoadFile(sParamFilename)) < 0) {
// Don't complain if file not found, but do return error
- if (siErr!=SI_FILE)
+ if (siErr != SI_FILE)
LOG_ERROR(_T("Couldn't parse parameters from '%s'"), sParamFilename);
m_iNestCount--;
return false;
@@ -255,7 +257,7 @@
return false;
}
- if ((siErr = m_pIni->SaveFile(pSaveFile)) < 0 ) {
+ if ((siErr = m_pIni->SaveFile(pSaveFile)) < 0) {
LOG_ERROR(_T("Couldn't save parameters in file '%s'"), sParamFilename);
return false;
}
@@ -270,7 +272,7 @@
SI_Error siErr;
std::string output_string;
- if ((siErr = m_pIni->Save(output_string)) < 0 ) {
+ if ((siErr = m_pIni->Save(output_string)) < 0) {
LOG_ERROR(_T("Couldn't write parameters to string"));
return false;
}
diff -r 1a1988ec40e7 -r fcbf85ce59fb src/Support/Parameters.h
--- a/src/Support/Parameters.h Thu Feb 18 20:04:04 2010 +0000
+++ b/src/Support/Parameters.h Thu Feb 18 21:12:41 2010 +0000
@@ -1,4 +1,4 @@
-// Copyright 2006-2010, Willem van Engen
+// Copyright 2006-2010, Willem van Engen, Thomas Walters
//
// AIM-C: A C++ implementation of the Auditory Image Model
// http://www.acousticscale.org/AIMC
@@ -16,31 +16,22 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-//!
-//! \file
-//! \brief Main parameters store
-//!
-//! \author Willem van Engen
-//! \date created 2006/09/21
-//! \version \$Id: Parameters.h 4 2010-02-03 18:44:58Z tcw $
+/*!
+ * \file
+ * \brief Main parameters store
+ *
+ * \author Willem van Engen
+ * \author Thomas Walters
+ * \date created 2006/09/21
+ * \version \$Id: Parameters.h 4 2010-02-03 18:44:58Z tcw $
+ */
#ifndef _AIMC_SUPPORT_PARAMETERS_H_
#define _AIMC_SUPPORT_PARAMETERS_H_
#include
-// If not _WINDOWS, please compile in Support/ConvertUTF.c
-#ifdef _UNICODE
-// Here we want to use the ANSI version of all the non wxWidgets stuff, but
-// convert stribngs to Unicode when used in wxWidgets. This allows all the
-// string handling in the non-GUI version to use ANSI text only, but to pass
-// unicode text to the GUI
-#undef _UNICODE
#include "Support/SimpleIni.h"
-#define _UNICODE
-#else
-#include "Support/SimpleIni.h"
-#endif
namespace aimc {
/*!
@@ -48,7 +39,7 @@
* \brief Main parameter store for parameters
*/
class Parameters {
-public:
+ public:
Parameters();
~Parameters();
@@ -176,12 +167,13 @@
* \param sName pointer to a string
* \return true on success
*/
- std::string WriteString();
+ std::string WriteString();
- //! \brief Maximum length of a parameter name in characters
+ /*! \brief Maximum length of a parameter name in characters
+ */
static const unsigned int MaxParamNameLength = 128;
-protected:
+ protected:
/*!
* \brief Load parameter file
* \param sParamFilename Filename of parameter file to read
@@ -203,11 +195,14 @@
*/
static const char *m_SDefaultIniSection;
- //! \brief Parameter file object
+ /*! \brief Parameter file object
+ */
CSimpleIniCase *m_pIni;
- //! \brief \c preset.include nesting counter to avoid loops
+ /*! \brief \c preset.include nesting counter to avoid loops
+ */
unsigned int m_iNestCount;
- //! \brief maximum value m_iNestCount may reach
+ /*! \brief maximum value m_iNestCount may reach
+ */
static const unsigned int m_iNestCountMaximum = 16;
};
}
diff -r 1a1988ec40e7 -r fcbf85ce59fb src/Support/StrobeList.h
--- a/src/Support/StrobeList.h Thu Feb 18 20:04:04 2010 +0000
+++ b/src/Support/StrobeList.h Thu Feb 18 21:12:41 2010 +0000
@@ -28,8 +28,8 @@
#ifndef _AIMC_SUPPORT_STROBE_LIST_H_
#define _AIMC_SUPPORT_STROBE_LIST_H_
+#include
#include
-#include
namespace aimc {
using std::deque;
@@ -38,9 +38,9 @@
float weight;
float working_weight;
StrobePoint() {
- time = 0;
- weight = 0.0f;
- working_weight = 0.0f;
+ time = 0;
+ weight = 0.0f;
+ working_weight = 0.0f;
}
};
@@ -60,22 +60,26 @@
inline ~StrobeList() {
};
- //! \brief Return the strobe time (in samples, can be negative)
+ /*! \brief Return the strobe time (in samples, can be negative)
+ */
inline StrobePoint Strobe(int strobe_number) {
return strobes_.at(strobe_number);
};
- //! \brief Set the strobe weight
+ /*! \brief Set the strobe weight
+ */
inline void SetWeight(int strobe_number, float weight) {
strobes_.at(strobe_number).weight = weight;
};
- //! \brief Set the strobe's working weight
+ /*! \brief Set the strobe's working weight
+ */
inline void SetWorkingWeight(int strobe_number, float working_weight) {
strobes_.at(strobe_number).working_weight = working_weight;
};
- //! \brief Add a strobe to the list (must be in order)
+ /*! \brief Add a strobe to the list (must be in order)
+ */
inline void AddStrobe(int time, float weight) {
StrobePoint s;
s.time = time;
@@ -83,18 +87,21 @@
strobes_.push_back(s);
};
- //! \brief Delete a strobe from the list
+ /*! \brief Delete a strobe from the list
+ */
inline void DeleteFirstStrobe() {
strobes_.pop_front();
};
- //! \brief Get the number of strobes
+ /*! \brief Get the number of strobes
+ */
inline int strobe_count() const {
return strobes_.size();
};
- //! \brief Shift the position of all strobes by subtracting offset from
- //! the time value of each
+ /*! \brief Shift the position of all strobes by subtracting offset from
+ * the time value of each
+ */
inline void ShiftStrobes(int offset) {
for (unsigned int i = 0; i < strobes_.size(); ++i)
strobes_[i].time -= offset;