bool Model::initialize(const SignalBank &input) { outputModules_.clear(); modules_.clear(); if(!initializeInternal(input)) { LOUDNESS_ERROR(name_ << ": Not initialised!"); return 0; } else { if (outputModules_.empty()) { LOUDNESS_ERROR(name_ << ": Invalid, this Model has no outputs."); return 0; } LOUDNESS_DEBUG(name_ << ": initialised."); nModules_ = (int)modules_.size(); //initialise all from root module modules_[0] -> initialize(input); configureSignalBankAggregation(); LOUDNESS_DEBUG(name_ << ": Module targets set and initialised."); initialized_ = 1; return 1; } }
bool OME::interpolateResponse(const RealVec &freqs) { if(freqs.empty()) { LOUDNESS_ERROR("OME: Input vector has no elements."); return 0; } else { response_.resize(freqs.size(), 0.0); //load the data into vectors getData(); //the spline spline s; //middle ear if(middleEarType_ != NONE) { s.set_points(middleEarFreqPoints_, middleEardB_); for (uint i=0; i < freqs.size(); i++) { if((freqs[i]<=75) && (middleEarType_ == ANSIS342007_MIDDLE_EAR_HPF)) response_[i] = -14.6; //Post HPF correction else if(freqs[i] >= middleEarFreqPoints_[40]) response_[i] = middleEardB_[40]; else response_[i] = s(freqs[i]); } } else { LOUDNESS_WARNING("OME: No middle ear filter used."); } //outer ear if(outerEarType_ != NONE) { Real lastFreq = outerEarFreqPoints_.back(); Real lastDataPoint = outerEardB_.back(); s.set_points(outerEarFreqPoints_, outerEardB_); for(uint i = 0; i < freqs.size(); i++) { if(freqs[i] >= lastFreq) response_[i] += lastDataPoint; else response_[i] += s(freqs[i]); } } else { LOUDNESS_WARNING("OME: No outer ear filter used."); } return 1; } }
bool Model::initialize(const TrackBank &input) { if(!initializeInternal(input)) { LOUDNESS_ERROR(name_ << ": Not initialised!"); return 0; } else { LOUDNESS_DEBUG(name_ << ": initialised."); //set up the chain nModules_ = (int)modules_.size(); for(int i=0; i<nModules_-1; i++) modules_[i]->setTargetModule(modules_[i+1].get()); //initialise all modules_[0]->initialize(input); LOUDNESS_DEBUG(name_ << ": Targets set and all modules initialised."); initialized_ = 1; return 1; } }
/* * Decided not to return const ref because of bounds checking. * Just return copy instead. */ string Model::getModuleName(int module) const { if(module < (int)modules_.size()) return modules_[module] -> getName(); else { LOUDNESS_ERROR(name_ << ": index out of bounds."); return ""; } }
bool Butter::initializeInternal(const SignalBank &input) { switch(order_) { case 3: { aCoefs_.resize(4); bCoefs_.resize(4); Real T = 1.0/input.getFs(); Real wc = 2.0/T * tan(2*PI*fc_*T/2.0); Real c1 = T*T*wc*wc; Real c2 = c1*T*wc/8.0; Real c3 = T*wc; bCoefs_[0] = 1.0; bCoefs_[1] = -3.0; bCoefs_[2] = 3.0; bCoefs_[3] = -1.0; aCoefs_[0] = c2 + 0.5 * c1 + c3 + 1; aCoefs_[1] = 3*c2 + 0.5 * c1 - c3 - 3; aCoefs_[2] = 3*c2 - 0.5 * c1 - c3 + 3; aCoefs_[3] = c2 - 0.5 * c1 + c3 - 1; break; } default: { LOUDNESS_ERROR(name_ << ": Only third order low pass implemented."); return 0; } } //normalise by a[0] normaliseCoefs(); //delay line z_.assign(input.getNEars() * 2 * order_,0.0); //output SignalBank output_.initialize(input); return 1; }