# HG changeset patch # User tom@acousticscale.org # Date 1288068536 0 # Node ID 733a11a65f3da9399add5eb10ddd4ed013df7991 # Parent 31d2b3f2c13bc30862f1fb3e43311b6d0cfb7090 - Allow processing without re-initialization. diff -r 31d2b3f2c13b -r 733a11a65f3d trunk/experiments/scripts/cnbh-syllables/feature_generation/ssi_profile_features.aimcopycfg --- a/trunk/experiments/scripts/cnbh-syllables/feature_generation/ssi_profile_features.aimcopycfg Tue Oct 26 04:09:31 2010 +0000 +++ b/trunk/experiments/scripts/cnbh-syllables/feature_generation/ssi_profile_features.aimcopycfg Tue Oct 26 04:48:56 2010 +0000 @@ -48,6 +48,9 @@ module10.name = SAI module10.id = weighted_sai +module10.parameters = <<(&sfinfo), 0, sizeof(SF_INFO)); @@ -79,7 +71,7 @@ */ LOG_ERROR(_T("Couldn't read audio file '%s'"), global_parameters_->GetString("input_filename")); - return false; + return; } file_loaded_ = true; @@ -90,12 +82,15 @@ if (audio_channels_ < 1 || buffer_length_ < 1 || sample_rate_ < 0.0f) { LOG_ERROR(_T("Problem with file: audio_channels = %d, buffer_length_ = %d, sample_rate = %f"), audio_channels_, buffer_length_, sample_rate_); - return false; + return; } output_.Initialize(audio_channels_, buffer_length_, sample_rate_); output_.set_start_time(0); - +} + +bool ModuleFileInput::InitializeInternal(const SignalBank& input) { + ResetInternal(); return true; } diff -r 31d2b3f2c13b -r 733a11a65f3d trunk/src/Modules/SAI/ModuleSAI.cc --- a/trunk/src/Modules/SAI/ModuleSAI.cc Tue Oct 26 04:09:31 2010 +0000 +++ b/trunk/src/Modules/SAI/ModuleSAI.cc Tue Oct 26 04:48:56 2010 +0000 @@ -107,6 +107,8 @@ void ModuleSAI::ResetInternal() { // Active Strobes + output_.Clear(); + sai_temp_.Clear(); active_strobes_.clear(); active_strobes_.resize(channel_count_); fire_counter_ = frame_period_samples_ - 1; diff -r 31d2b3f2c13b -r 733a11a65f3d trunk/src/Modules/SSI/ModuleSSI.cc --- a/trunk/src/Modules/SSI/ModuleSSI.cc Tue Oct 26 04:09:31 2010 +0000 +++ b/trunk/src/Modules/SSI/ModuleSSI.cc Tue Oct 26 04:48:56 2010 +0000 @@ -103,6 +103,21 @@ output_.set_centre_frequency(i, input.centre_frequency(i)); } + h_.resize(ssi_width_samples_, 0.0); + float gamma_min = -1.0f; + float gamma_max = log2(ssi_width_cycles_); + for (int i = 0; i < ssi_width_samples_; ++i) { + if (log_cycles_axis_) { + float gamma = gamma_min + (gamma_max - gamma_min) + * static_cast(i) + / static_cast(ssi_width_samples_); + h_[i]= pow(2.0f, gamma); + } else { + h_[i] = static_cast(i) * ssi_width_cycles_ + / static_cast(ssi_width_samples_); + } + } + output_.Initialize(channel_count_, ssi_width_samples_, sample_rate_); return true; } @@ -157,9 +172,6 @@ if (do_pitch_cutoff_) { pitch_index = ExtractPitchIndex(input); } - - float gamma_min = -1.0f; - float gamma_max = log2(ssi_width_cycles_); for (int ch = 0; ch < channel_count_; ++ch) { float centre_frequency = input.centre_frequency(ch); @@ -186,30 +198,20 @@ // Copy the buffer from input to output, addressing by h-value. for (int i = 0; i < ssi_width_samples_; ++i) { - float h; - if (log_cycles_axis_) { - float gamma = gamma_min + (gamma_max - gamma_min) - * static_cast(i) - / static_cast(ssi_width_samples_); - h = pow(2.0f, gamma); - } else { - h = static_cast(i) * ssi_width_cycles_ - / static_cast(ssi_width_samples_); - } - + // 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); + float frac_part = modf(h_[i] * cycle_samples, &whole_part); int sample = floor(whole_part); float weight = channel_weight; if (do_smooth_offset_ && do_pitch_cutoff_) { // Smoothing around the pitch cutoff line. - float pitch_weight = (1.0f + tanh((pitch_h - h) + float pitch_weight = (1.0f + tanh((pitch_h - h_[i]) * smooth_pitch_constant)) / 2.0f; weight *= pitch_weight; //LOG_INFO("Channel %d, Sample %d. Pitch weight: %f", ch, i, pitch_weight); diff -r 31d2b3f2c13b -r 733a11a65f3d trunk/src/Modules/SSI/ModuleSSI.h --- a/trunk/src/Modules/SSI/ModuleSSI.h Tue Oct 26 04:09:31 2010 +0000 +++ b/trunk/src/Modules/SSI/ModuleSSI.h Tue Oct 26 04:48:56 2010 +0000 @@ -24,6 +24,7 @@ #ifndef AIMC_MODULES_SSI_SSI_H_ #define AIMC_MODULES_SSI_SSI_H_ +#include #include "Support/Module.h" namespace aimc { @@ -56,6 +57,7 @@ int ssi_width_samples_; float ssi_width_cycles_; float pivot_cf_; + vector h_; bool do_pitch_cutoff_; bool weight_by_cutoff_; diff -r 31d2b3f2c13b -r 733a11a65f3d trunk/src/Support/SignalBank.cc --- a/trunk/src/Support/SignalBank.cc Tue Oct 26 04:09:31 2010 +0000 +++ b/trunk/src/Support/SignalBank.cc Tue Oct 26 04:48:56 2010 +0000 @@ -94,6 +94,13 @@ return true; } +void SignalBank::Clear() { + for (int i = 0; i < channel_count_; ++i) { + signals_[i].assign(buffer_length_, 0.0f); + strobes_[i].resize(0); + } +} + bool SignalBank::Validate() const { if (sample_rate_ <= 0.0f) return false; diff -r 31d2b3f2c13b -r 733a11a65f3d trunk/src/Support/SignalBank.h --- a/trunk/src/Support/SignalBank.h Tue Oct 26 04:09:31 2010 +0000 +++ b/trunk/src/Support/SignalBank.h Tue Oct 26 04:48:56 2010 +0000 @@ -99,6 +99,7 @@ void set_centre_frequency(int i, float cf); bool initialized() const; int channel_count() const; + void Clear(); private: int channel_count_; int buffer_length_;