# HG changeset patch # User tomwalters # Date 1266592767 0 # Node ID b4cafba48e9d80abb19d6cdccfd1c23f6b4c47b9 # Parent ba2f7596d1a214b0ae47f613e68368dbc67ff4c4 - replaced wit where possible -SSI support added but not yet tested diff -r ba2f7596d1a2 -r b4cafba48e9d src/Modules/BMM/ModuleGammatone.cc --- a/src/Modules/BMM/ModuleGammatone.cc Fri Feb 19 14:19:32 2010 +0000 +++ b/src/Modules/BMM/ModuleGammatone.cc Fri Feb 19 15:19:27 2010 +0000 @@ -24,7 +24,7 @@ * \version \$Id$ */ -#include +#include #include #include "Support/ERBTools.h" diff -r ba2f7596d1a2 -r b4cafba48e9d src/Modules/NAP/ModuleHCL.cc --- a/src/Modules/NAP/ModuleHCL.cc Fri Feb 19 14:19:32 2010 +0000 +++ b/src/Modules/NAP/ModuleHCL.cc Fri Feb 19 15:19:27 2010 +0000 @@ -25,7 +25,7 @@ * \version \$Id: ModuleHCL.cc 4 2010-02-03 18:44:58Z tcw $ */ -#include +#include #include "Modules/NAP/ModuleHCL.h" diff -r ba2f7596d1a2 -r b4cafba48e9d src/Modules/Profile/ModuleSlice.cc --- a/src/Modules/Profile/ModuleSlice.cc Fri Feb 19 14:19:32 2010 +0000 +++ b/src/Modules/Profile/ModuleSlice.cc Fri Feb 19 15:19:27 2010 +0000 @@ -110,6 +110,8 @@ return; } + output_.set_start_time(input.start_time()); + if (temporal_profile_) { for (int i = 0; i < input.buffer_length(); ++i) { float val = 0.0f; diff -r ba2f7596d1a2 -r b4cafba48e9d src/Modules/SAI/ModuleSAI.cc --- a/src/Modules/SAI/ModuleSAI.cc Fri Feb 19 14:19:32 2010 +0000 +++ b/src/Modules/SAI/ModuleSAI.cc Fri Feb 19 15:19:27 2010 +0000 @@ -25,7 +25,7 @@ * \date created 2007/08/29 * \version \$Id: ModuleSAI.cc 4 2010-02-03 18:44:58Z tcw $ */ -#include +#include #include "Modules/SAI/ModuleSAI.h" diff -r ba2f7596d1a2 -r b4cafba48e9d src/Modules/SSI/ModuleSSI.cc --- a/src/Modules/SSI/ModuleSSI.cc Fri Feb 19 14:19:32 2010 +0000 +++ b/src/Modules/SSI/ModuleSSI.cc Fri Feb 19 15:19:27 2010 +0000 @@ -22,6 +22,8 @@ * \version \$Id$ */ +#include + #include "Modules/SSI/ModuleSSI.h" namespace aimc { @@ -31,7 +33,8 @@ module_type_ = "ssi"; module_version_ = "$Id$"; - do_pitch_cutoff_ = parameters_->DefaultBool("ssi.pitch_cutoff", false); + //do_pitch_cutoff_ = parameters_->DefaultBool("ssi.pitch_cutoff", false); + ssi_width_cycles_ = parameters_->DefaultFloat("ssi.width_cycles", 20.0f); } ModuleSSI::~ModuleSSI() { @@ -44,17 +47,23 @@ buffer_length_ = input.buffer_length(); channel_count_ = input.channel_count(); - // If this module produces any output, then the output signal bank needs to - // be initialized here. - // Example: - // output_.Initialize(channel_count, buffer_length, sample_rate); + float lowest_cf = input.centre_frequency(0); + ssi_width_samples_ = sample_rate_ * ssi_width_cycles_ / lowest_cf; + if (ssi_width_samples_ > buffer_length_) { + ssi_width_samples_ = buffer_length_; + float cycles = ssi_width_samples_ * lowest_cf / sample_rate_; + LOG_INFO(_T("Requested SSI width of %f cycles is too long for the " + "input buffer length of %d samples. The SSI will be " + "truncated at %d samples wide. This corresponds to a width " + "of %f cycles."), ssi_width_cycles_, buffer_length_, + ssi_width_samples_, cycles); + ssi_width_cycles_ = cycles; + } + output_.Initialize(channel_count_, ssi_width_samples_, sample_rate_); return true; } void ModuleSSI::ResetInternal() { - // Reset any internal state variables to their default values here. After a - // call to ResetInternal(), the module should be in the same state as it is - // just after a call to InitializeInternal(). } void ModuleSSI::Process(const SignalBank &input) { @@ -74,13 +83,34 @@ return; } - // Input is read from the input signal bank using calls like - // float value = input_.sample(channel_number, sample_index); + output_.set_start_time(input.start_time()); - // Output is fed into the output signal bank (assuming that it was - // initialized during the call to InitializeInternal()) like this: - // output_.set_sample(channel_number, sample_index, sample_value); + for (int ch = 0; ch < channel_count_; ++ch) { + // Copy the buffer from input to output, addressing by h-value + for (int i = 0; i < ssi_width_samples_; ++i) { + float h = static_cast(i) * ssi_width_cycles_ + / static_cast(ssi_width_samples_); + float cycle_samples = sample_rate_ / input.centre_frequency(ch); + // The index into the input array is a floating-point number, which is + // split into a whole part and a fractional part. The whole part and + // fractional part are found, and are used to linearly interpolate + // between input samples to yield an output sample. + double whole_part; + float frac_part = modf(h * cycle_samples, &whole_part); + int sample = static_cast(whole_part); + + float val; + if (sample < buffer_length_ - 1) { + float curr_sample = input.sample(ch, sample); + float next_sample = input.sample(ch, sample + 1); + val = curr_sample + frac_part * (next_sample - curr_sample); + } else { + val = 0.0f; + } + output_.set_sample(ch, i, val); + } + } PushOutput(); } } // namespace aimc diff -r ba2f7596d1a2 -r b4cafba48e9d src/Modules/SSI/ModuleSSI.h --- a/src/Modules/SSI/ModuleSSI.h Fri Feb 19 14:19:32 2010 +0000 +++ b/src/Modules/SSI/ModuleSSI.h Fri Feb 19 15:19:27 2010 +0000 @@ -52,6 +52,8 @@ float sample_rate_; int buffer_length_; int channel_count_; + int ssi_width_samples_; + float ssi_width_cycles_; bool do_pitch_cutoff_; }; diff -r ba2f7596d1a2 -r b4cafba48e9d src/Modules/Strobes/ModuleParabola.cc --- a/src/Modules/Strobes/ModuleParabola.cc Fri Feb 19 14:19:32 2010 +0000 +++ b/src/Modules/Strobes/ModuleParabola.cc Fri Feb 19 15:19:27 2010 +0000 @@ -26,7 +26,7 @@ * \version \$Id:$ */ -#include +#include #include "Modules/Strobes/ModuleParabola.h" diff -r ba2f7596d1a2 -r b4cafba48e9d src/Support/ERBTools.h --- a/src/Support/ERBTools.h Fri Feb 19 14:19:32 2010 +0000 +++ b/src/Support/ERBTools.h Fri Feb 19 15:19:27 2010 +0000 @@ -28,7 +28,7 @@ #ifndef AIMC_SUPPORT_ERBTOOLS_H_ #define AIMC_SUPPORT_ERBTOOLS_H_ -#include +#include namespace aimc { class ERBTools { diff -r ba2f7596d1a2 -r b4cafba48e9d src/Support/StrobeList.h --- a/src/Support/StrobeList.h Fri Feb 19 14:19:32 2010 +0000 +++ b/src/Support/StrobeList.h Fri Feb 19 15:19:27 2010 +0000 @@ -28,7 +28,7 @@ #ifndef AIMC_SUPPORT_STROBELIST_H_ #define AIMC_SUPPORT_STROBELIST_H_ -#include +#include #include namespace aimc {