Example #1
0
NumberScale SpectrogramSettings::GetScale
(float minFreq, float maxFreq, double rate, bool bins) const
{
   NumberScaleType type = nstLinear;
   const auto half = GetFFTLength() / 2;

   // Don't assume the correspondence of the enums will remain direct in the future.
   // Do this switch.
   switch (scaleType) {
   default:
      wxASSERT(false);
   case stLinear:
      type = nstLinear; break;
   case stLogarithmic:
      type = nstLogarithmic; break;
   case stMel:
      type = nstMel; break;
   case stBark:
      type = nstBark; break;
   case stErb:
      type = nstErb; break;
   case stPeriod:
      type = nstPeriod; break;
   }

   return NumberScale(type, minFreq, maxFreq,
      bins ? rate / (2 * half) : 1.0f);
}
NumberScale SpectrogramSettings::GetScale
(double rate, bool bins) const
{
   int minFreq, maxFreq;
   NumberScaleType type = nstLinear;
   const int half = GetFFTLength() / 2;

   // Don't assume the correspondence of the enums will remain direct in the future.
   // Do this switch.
   switch (scaleType) {
   default:
      wxASSERT(false);
   case stLinear:
      type = nstLinear; break;
   case stLogarithmic:
      type = nstLogarithmic; break;
   case stMel:
      type = nstMel; break;
   case stBark:
      type = nstBark; break;
   case stErb:
      type = nstErb; break;
   case stUndertone:
      type = nstUndertone; break;
   }

   switch (scaleType) {
   default:
      wxASSERT(false);
   case stLinear:
      minFreq = GetMinFreq(rate);
      maxFreq = GetMaxFreq(rate);
      break;
   case stLogarithmic:
   case stMel:
   case stBark:
   case stErb:
      minFreq = GetLogMinFreq(rate);
      maxFreq = GetLogMaxFreq(rate);
      break;
   case stUndertone:
   {
      const float bin2 = rate / half;
      minFreq = std::max(int(0.5 + bin2), GetLogMinFreq(rate));
      maxFreq = GetLogMaxFreq(rate);
   }
   break;
   }

   return NumberScale(type, minFreq, maxFreq,
      bins ? rate / (2 * half) : 1.0f);
}
Example #3
0
void XFunctions::StoreConfigurationValues() 
{
   wxString path;
   path.Printf(wxT("/Aurora/XFunctions/FftSize"));
   m_pAuroraCfg->Write(path, GetFFTLength());
   path.Printf(wxT("/Aurora/XFunctions/WindowType"));
   m_pAuroraCfg->Write(path, AFSampleCount(GetWindowType()));
   
   path.Printf(wxT("/Aurora/XFunctions/XFunctionType"));
   m_pAuroraCfg->Write(path, AFSampleCount(GetXFunctionType()));

   path.Printf(wxT("/Aurora/XFunctions/ProbeFreeField"));
   m_pAuroraCfg->Write(path, IsProbeFreeField());
   path.Printf(wxT("/Aurora/XFunctions/ProbeRigidTerminated"));
   m_pAuroraCfg->Write(path, IsProbeRigidTerminated());
   path.Printf(wxT("/Aurora/XFunctions/SoundSpeed"));
   m_pAuroraCfg->Write(path, GetSoundSpeed());
   path.Printf(wxT("/Aurora/XFunctions/ProbeMicDistance"));
   m_pAuroraCfg->Write(path, GetProbeDistance());
   path.Printf(wxT("/Aurora/XFunctions/ProbeMaxFreq"));
   m_pAuroraCfg->Write(path, GetProbeMaxFreq());
   
   path.Printf(wxT("/Aurora/XFunctions/FollowingFilter"));
   m_pAuroraCfg->Write(path, IsFollowingFilterEnabled());
   path.Printf(wxT("/Aurora/XFunctions/FollowingBandwidth"));
   m_pAuroraCfg->Write(path, GetFollowingBandwidth());
   
   path.Printf(wxT("/Aurora/XFunctions/Normalize"));
   m_pAuroraCfg->Write(path, IsNormalizeSet());
   path.Printf(wxT("/Aurora/XFunctions/ShiftToHalfWindow"));
   m_pAuroraCfg->Write(path, IsShiftToHalfWindowSet());
   path.Printf(wxT("/Aurora/XFunctions/CoherenceWeighting"));
   m_pAuroraCfg->Write(path, IsCoherenceWeightingSet());
   path.Printf(wxT("/Aurora/XFunctions/HilbertTransform"));
   m_pAuroraCfg->Write(path, IsHilbertTransformSet());
   path.Printf(wxT("/Aurora/XFunctions/TimeReversal"));
   m_pAuroraCfg->Write(path, IsTimeReversalSet());
   path.Printf(wxT("/Aurora/XFunctions/SaveMultispectrum"));
   m_pAuroraCfg->Write(path, IsSaveMultispectrumSet());
   path.Printf(wxT("/Aurora/XFunctions/DiracPulse"));
   m_pAuroraCfg->Write(path, IsDiracPulseSet());
   
   path.Printf(wxT("/Aurora/XFunctions/TriggerLevel"));
   m_pAuroraCfg->Write(path, GetTriggerLevel());
   
   // Writes immediately changes
   m_pAuroraCfg->Flush();
}
Example #4
0
size_t SpectrogramSettings::NBins() const
{
   // Omit the Nyquist frequency bin
   return GetFFTLength() / 2;
}