Giter Club home page Giter Club logo

Comments (1)

Pmax65 avatar Pmax65 commented on September 14, 2024

Hi DisLord,
Ok,
to fix the glitches at the band change points do as follow.

Substitute the IS_HARMONIC_MODE(f) macro with the function
int8_t IS_HARMONIC_MODE(uint32_t freq) here below

int8_t IS_HARMONIC_MODE(uint32_t freq){
	if (freq > FREQ_HARMONICS * 5 ) {
		return 3;
	}
	else{
		if (freq > FREQ_HARMONICS * 3) {
			return 2;
		}
		else{
		  if (freq > FREQ_HARMONICS) {
			  return 1;
		  }
		  else{
			  return 0;
		  }
		}
	}
}

And change the code into static void cal_interpolate(int s) this way:

#if __NewBandChangeInterpolation__ == 1
          float k1 = (float)(f - src->_frequencies[j])
                          / (src->_frequencies[j+1] - src->_frequencies[j]);

          // avoid glitch between freqs in different harmonics mode
          if (IS_HARMONIC_MODE(src->_frequencies[j]) != IS_HARMONIC_MODE(src->_frequencies[j+1])) {
              int m;
        	  if (IS_HARMONIC_MODE(f)==IS_HARMONIC_MODE(src->_frequencies[j+1])){
				  float k0 = 2 - k1;
				  k1 = k1 - 1;
				  for (eterm = 0; eterm < 5; eterm++) {
					cal_data[eterm][i][0] = src->_cal_data[eterm][j+1][0] * k0 + src->_cal_data[eterm][j+2][0] * k1;
					cal_data[eterm][i][1] = src->_cal_data[eterm][j+1][1] * k0 + src->_cal_data[eterm][j+2][1] * k1;
				  }
        	  }
        	  else{
				  float k0 = - k1;
				  k1 = k1 + 1;
				  if (j == 0){
					  m = j;
				  }
				  else{
					  m = j - 1;
				  }
				  for (eterm = 0; eterm < 5; eterm++) {
					cal_data[eterm][i][0] = src->_cal_data[eterm][m][0] * k0 + src->_cal_data[eterm][j][0] * k1;
					cal_data[eterm][i][1] = src->_cal_data[eterm][m][1] * k0 + src->_cal_data[eterm][j][1] * k1;
				  }
        	  }
          }
          else{
              float k0 = 1.0 - k1;
              for (eterm = 0; eterm < 5; eterm++) {
                cal_data[eterm][i][0] = src->_cal_data[eterm][j][0] * k0 + src->_cal_data[eterm][j+1][0] * k1;
                cal_data[eterm][i][1] = src->_cal_data[eterm][j][1] * k0 + src->_cal_data[eterm][j+1][1] * k1;
              }
          }

          break;

#else
          float k1 = (float)(f - src->_frequencies[j])
                          / (src->_frequencies[j+1] - src->_frequencies[j]);

          // avoid glitch between freqs in different harmonics mode
          if (IS_HARMONIC_MODE(src->_frequencies[j]) != IS_HARMONIC_MODE(src->_frequencies[j+1])) {
            // assume f[j] < f[j+1]
            k1 = IS_HARMONIC_MODE(f) ? 1.0 : 0.0;
          }

          float k0 = 1.0 - k1;
          for (eterm = 0; eterm < 5; eterm++) {
            cal_data[eterm][i][0] = src->_cal_data[eterm][j][0] * k0 + src->_cal_data[eterm][j+1][0] * k1;
            cal_data[eterm][i][1] = src->_cal_data[eterm][j][1] * k0 + src->_cal_data[eterm][j+1][1] * k1;
          }
          break;
#endif

Substantially the only line changed respect my previous message is this:
if (IS_HARMONIC_MODE(f)){

Which turned to:
if (IS_HARMONIC_MODE(f)==IS_HARMONIC_MODE(src->_frequencies[j+1])){

After that, the glitches at the band change points are fixed.

Have a great day,
Massimo - IK1IZA

from nanovna-h.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.