Example #1
0
void SoundPlayer::explosion()
{
	noise(700, 40, 20);
	noise(450, 30, 15);
	noise(300, 20, 10);
	noise(250, 20, 10);
	noise(120, 30, 50);
	noise(100, 40, 50);

}
Example #2
0
		double octaveNoise(double x, double y, double z, std::int32_t octaves) const
		{
			double result = 0.0;
			double amp = 1.0;

			for (std::int32_t i = 0; i < octaves; ++i)
			{
				result += noise(x, y, z) * amp;
				x *= 2.0;
				y *= 2.0;
				z *= 2.0;
				amp *= 0.5;
			}

			return result;
		}
double PerlinNoise::OctavePerlin(double x, double y, double z, int octaves, double persistence) {
	double total = 0;
	double frequency = 1;
	double amplitude = 1;
	double maxValue = 0;  // Used for normalizing result to 0.0 - 1.0
	for (int i = 0; i<octaves; i++) {
		total += /*(1 - abs(*/noise(x * frequency, y * frequency, z * frequency)/*))*/ * amplitude;

		maxValue += amplitude;

		amplitude *= persistence;
		frequency *= 2;
	}

	return total;// maxValue;
}
Example #4
0
double PerlinNoise::octaveNoise( double x, double y, double z, int octaves ) const
{
	double result = 0.0;
	double amp = 1.0;

	for(int i=0; i<octaves; ++i)
	{
		result += noise(x,y,z) * amp;
		x   *= 2.0;
		y   *= 2.0;
		z   *= 2.0;
		amp *= 0.5;
	}

	return result;
}
Example #5
0
/*
	Name		SimplexNoise::ridgedMultifractal
	Syntax		SimplexNoise::ridgedMultifractal(double xin, double yin, double zin, double win, int octaves, float lacunarity, float gain, float offset)
	Brief		Generates 4D gradiated and ridged multifractcal noise values
*/
double SimplexNoise::ridgedMultifractal(double xin, double yin, double zin, double win, int octaves, float lacunarity, float gain, float offset)
{
	double sum = 0;
	float frequency = 1.0;
	float amplitude = 0.5;
	float previous = 1.0;
	for(int i = 0; i < octaves; i++) 
	{
		double n = ridge(noise(xin * frequency, yin * frequency, zin * frequency, win * frequency), offset);
		sum += n * amplitude * previous;
		previous = n;
		frequency *= lacunarity;
		amplitude *= gain;
	}
	return sum;
}
Example #6
0
float CPerlinNoise3D::Get(float x, float y, float z)
{
	Fvector3 vec	= {x,y,z};
	float result	= 0.0f;
	float amp		= mAmplitude;
	vec[0]			*=mFrequency;
	vec[1]			*=mFrequency;
	vec[2]			*=mFrequency;
	for(int i=0; i<mOctaves; i++){
		result		+= noise(vec)*amp;
		vec[0]		*= 2.0f;
		vec[1]		*= 2.0f;
		vec[2]		*= 2.0f;
		amp			*= 0.5f;
	}
	return result;
}
int SpatialNoiseShader::shade(Stroke &ioStroke) const
{
  Interface0DIterator v, v2;
  v = ioStroke.verticesBegin();
  Vec2r p(v->getProjectedX(), v->getProjectedY());
  v2 = v;
  ++v2;
  Vec2r p0(v2->getProjectedX(), v2->getProjectedY());
  p0 = p + 2 * (p - p0);
  StrokeVertex *sv;
  sv = dynamic_cast<StrokeVertex *>(&(*v));
  real initU = sv->strokeLength() * real(NB_VALUE_NOISE);
  if (_pureRandom)
    initU += RandGen::drand48() * real(NB_VALUE_NOISE);

  Functions0D::VertexOrientation2DF0D fun;
  while (!v.isEnd()) {
    sv = dynamic_cast<StrokeVertex *>(&(*v));
    Vec2r p(sv->getPoint());
    if (fun(v) < 0)
      return -1;
    Vec2r vertexOri(fun.result);
    Vec2r ori2d(vertexOri[0], vertexOri[1]);
    ori2d = Vec2r(p - p0);
    ori2d.normalizeSafe();

    PseudoNoise mynoise;
    real bruit;

    if (_smooth)
      bruit = mynoise.turbulenceSmooth(_xScale * sv->curvilinearAbscissa() + initU, _nbOctave);
    else
      bruit = mynoise.turbulenceLinear(_xScale * sv->curvilinearAbscissa() + initU, _nbOctave);

    Vec2r noise(-ori2d[1] * _amount * bruit, ori2d[0] * _amount * bruit);

    sv->setPoint(p[0] + noise[0], p[1] + noise[1]);
    p0 = p;

    ++v;
  }

  ioStroke.UpdateLength();

  return 0;
}
Example #8
0
File: warp.cpp Project: i80and/warp
float Warp::fbm(float x, float y) const {
    float amplitude = _persistence;
    float k = _scale;
    float val = 0;

    for(int i = 0; i < OCTAVES; i += 1) {
        float xcoord = x / (_width/k);
        float ycoord = y / (_height/k);

        val += noise(xcoord, ycoord) * amplitude;

        amplitude /= 2;
        k *= 2;
    }

    return val;
}
	void pose1Callback(
			const geometry_msgs::PoseWithCovarianceStampedConstPtr& msg) {
		Eigen::Quaterniond orientation;
		Eigen::Vector3d position;

		tf::pointMsgToEigen(msg->pose.pose.position, position);
		tf::quaternionMsgToEigen(msg->pose.pose.orientation, orientation);

		SE3Type pose(orientation, position);
		SE3Type transformed_pose = T_imu_cam.inverse() * pose;
		std::cout<<"Pose1 Position"<<"\n"<<transformed_pose.translation();
		Matrix6 noise(&msg->pose.covariance[0]);
		std::cout<<"Noise "<<"\n"<<noise<<std::endl;

		ukf->measurePose( pose,noise);


	}
Example #10
0
float simplex_noise( int o, float x, float y, float z, float s, float a)
{
	float value = 0;
	float m, w;
	int i;

	for (i = 0; i < o; i++)
	{
		a = pow( a, i );
		
		m = s / pow( 2, i );
		w = 1.0 / m;
		
		value += ( noise((double) x*w,(double) y*w,(double) z*w) ) * a;
	}

	return value;
}
Example #11
0
void addNoise(cv::Mat &image)
{
    if (image.channels() > 1)
    {
        SD_TRACE("addNoise : image should have single channel");
        return;
    }
    int initDepth=image.depth();
    if (initDepth < CV_32F)
        image.convertTo(image, CV_32F);

    cv::Mat noise(image.rows, image.cols, image.type());
    cv::randn(noise, 100, 25);
    image = image + noise;

    if (initDepth == CV_8U)
        ImageCommon::convertTo8U(image, image);
}
	void DefaultTransitionModel::transitionParticle( Particle& particle, 
													 const SensorData& data )
	{

		PoseSE2 noise( xNoise.Sample(), yNoise.Sample(), thNoise.Sample() );
		PoseSE2 corruptedPose = particle.getPose() * noise * data.displacement;
		particle.setPose( corruptedPose );
		
// 		if(newX>map.GetXSize()){ newX = map.GetXSize(); }
// 		if(newX<0){ newX = 0; }
// 		if(newY>map.GetXSize()){ newY = map.GetYSize(); }
// 		if(newY<0){ newY = 0; }
// 		if(newTheta>2*M_PI){ newTheta = newTheta - 2*M_PI; }
// 		if(newTheta<0){ newTheta = 2*M_PI+newTheta; }	
// 		
// 		PoseSE2 newPose = PoseSE2( newX, newY, newTheta );
    
	}
Example #13
0
Array< double, 2 > generateNoise( Vector2ui size, unsigned int seed, unsigned int octaves, double dropoff, bool tile ) {
	// Initialize the noise
	Array< double, 2 > noise( size.x, size.y );
	for( unsigned int x = 0; x < size.x; ++x ) {
		for( unsigned int y = 0; y < size.y; ++y ) {
			noise[ x ][ y ] = 0;
		}
	}

	// Loop through the octaves
	double scaling_x = 1;
	double scaling_y = 1;
	double scale_factor_x = pow( static_cast< double >( size.x ), 1. / static_cast< double >( octaves - 1 ) );
	double scale_factor_y = pow( static_cast< double >( size.y ), 1. / static_cast< double >( octaves - 1 ) );
	for( unsigned int i = 0; i < octaves; ++i ) {
		Array< double, 2 > octave( size.x, size.y );

		// Untiled octave
		if( !tile ) {
			octave = generateNoiseOctaveUntiled( size, seed, scaling_x, scaling_y );
		}

		// Tiled octave
		else {
			octave = generateNoiseOctaveTiled( size, seed, scaling_x, scaling_y );
		}

		// Combine octaves
		for( unsigned int x = 0; x < size.x; ++x ) {
			for( unsigned int y = 0; y < size.y; ++y ) {
				noise[ x ][ y ] = noise[ x ][ y ] * dropoff + octave[ x ][ y ];
			}
		}

		// Update octave parameters
		scaling_x *= scale_factor_x;
		scaling_y *= scale_factor_y;
	}

	// Normalize the noise
	noise = normalizeNoise( noise );

	return noise;
}
Example #14
0
void dNoise(double result[3], double xin, double yin, double zin) {
    const double epsilon = 0.001;
    
    result[0] = noise(xin + epsilon, yin, zin) - noise(xin - epsilon, yin, zin);
    result[1] = noise(xin, yin + epsilon, zin) - noise(xin, yin - epsilon, zin);
    result[2] = noise(xin, yin, zin + epsilon) - noise(xin, yin, zin - epsilon);
    
    double length = sqrt(result[0] * result[0] + result[1] * result[1] + result[2] * result[2]);
    
    result[0] /= length;
    result[1] /= length;
    result[2] /= length;
}
Example #15
0
// パーリンノイズ算出
float PerlinNoise2D::Noise(float x, float y)
{
#if 0
    int ix = int(x) & 255;
    int iy = int(y) & 255;
    float fx = x - int(x);
    float fy = y - int(y);
    float ret;
    
    if (interpType_ == Interp_Cubic)
    {
        float w[4];
        for (int i = 0; i < 4; i++) {
            float v0 = IntNoise(ix-1, iy-1 + i);
            float v1 = IntNoise(ix,   iy-1 + i);
            float v2 = IntNoise(ix+1, iy-1 + i);
            float v3 = IntNoise(ix+2, iy-1 + i);
            w[i] = CubicInterporate(v0, v1, v2, v3, fx);
        }
        ret = CubicInterporate(w[0], w[1], w[2], w[3], fy);
    }
    else
    {
        printf("%d %d %f %f\n", ix, iy, fx, fy);
        const float to0_1 = 1.f / 255.f;
        int A = permutation_[ix  ] + iy;
        int B = permutation_[ix+1] + iy;
        float v0 = permutation_[A] * to0_1;
        float v1 = permutation_[B] * to0_1;
        float v2 = permutation_[A+1] * to0_1;
        float v3 = permutation_[B+1] * to0_1;
        float (*fade)(float) = pFadeFuncs[interpType_];
        float f = fade(fx);
        v0 = Lerp(v0, v1, f);
        v1 = Lerp(v2, v3, f);
        ret = Lerp(v0, v1, fade(fy));
    }
    return ret;
#else
    float ret = (float)noise(x, y, 0);
    //printf("%f\n", ret);
    return ret;
#endif
}
Example #16
0
File: malloc.c Project: Abioy/FUZIX
/* This function will search for a chunk in memory of at least 'mem_size'
 * when found, if the chunk is too big it'll be split, and pointer to the
 * chunk returned. If none is found NULL is returned.
 */
Static mem *__search_chunk(unsigned mem_size)
{
	register mem *p1, *p2;
	if (chunk_list == 0)	/* Simple case first */
		return 0;

	/* Search for a block >= the size we want */
	p1 = m_next(chunk_list);
	p2 = chunk_list;

	do {
		noise("CHECKED", p1);
		if (m_size(p1) >= mem_size)
			break;
		p2 = p1;
		p1 = m_next(p1);
	} while (p2 != chunk_list);

	/* None found, exit */
	if (m_size(p1) < mem_size)
		return 0;

	/* If it's exactly right remove it */
	if (m_size(p1) < mem_size + 2) {
		noise("FOUND RIGHT", p1);
		chunk_list = m_next(p2) = m_next(p1);
		if (chunk_list == p1)
			chunk_list = 0;
		return p1;
	}
	noise("SPLIT", p1);

	/* Otherwise split it */
	m_next(p2) = m_add(p1, mem_size);
	chunk_list = p2;
	p2 = m_next(p2);
	m_size(p2) = m_size(p1) - mem_size;
	m_next(p2) = m_next(p1);
	m_size(p1) = mem_size;
	if (chunk_list == p1)
		chunk_list = p2;

#ifdef VERBOSE
	p1[1].size = 0xAAAA;

#endif				/*  */
	noise("INSERT CHUNK", p2);
	noise("FOUND CHUNK", p1);
	noise("LIST IS", chunk_list);
	return p1;
}
bool SSAOBuffer::load(unsigned int screenWidth, unsigned int screenHeight)
{
	glGenFramebuffers(2, FBOs);

	for (unsigned int i = 0; i < 2; ++i)
	{
		glBindFramebuffer(GL_FRAMEBUFFER, FBOs[i]);

		glGenTextures(1, &textures[i]);
	
		glBindTexture(GL_TEXTURE_2D, textures[i]);
		glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, screenWidth, screenHeight, 0, GL_RGB, GL_FLOAT, NULL);
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[i], 0);
	
		if (i == 0)
		{
			glGenTextures(1, &noiseTexture);
			std::uniform_real_distribution<GLfloat> randomFloats(0.0f, 1.0f); // generates random floats between 0.0 and 1.0
			std::default_random_engine generator;
			std::vector<glm::vec3> ssaoNoise;

			for (GLuint i = 0; i < 16; i++)
			{
				glm::vec3 noise(randomFloats(generator) * 2.0f - 1.0f, randomFloats(generator) * 2.0f - 1.0f, 0.0f); // rotate around z-axis (in tangent space)
				ssaoNoise.push_back(noise);
			}

			glBindTexture(GL_TEXTURE_2D, noiseTexture);
			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, 4, 4, 0, GL_RGB, GL_FLOAT, &ssaoNoise[0]);
			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
			glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
			glBindTexture(GL_TEXTURE_2D, 0);
		}
	}

	glBindFramebuffer(GL_FRAMEBUFFER, 0);
	if (!Error::checkGL()) return false;
	return true;
}
Example #18
0
static t_rgb	noise_wood(t_noise *n, int x, int y)
{
	double	f;
	double	value;
	t_rgb	color;
	t_vec3	c1;
	t_vec3	c2;

	c1 = vec3(1.0, 0.99, 0.98);
	c2 = vec3(0.2, 0.12, 0.02);
	value = fmod(noise(n, x, y), 0.2);
	if (value > 0.2 / 2)
		value = 0.2 - value;
	f = (1 - cos(PI * value / (0.2 / 2))) / 2;
	color.x = (c1.x * (1 - f) + c2.x * f) * 255;
	color.y = (c1.x * (1 - f) + c2.y * f) * 255;
	color.z = (c1.z * (1 - f) + c2.z * f) * 255;
	return (color);
}
Example #19
0
float CPerlinNoise1D::GetContinious(float v)
{
	float t_v=v;
	if (mPrevContiniousTime!=0.0f)
	{
		v-=mPrevContiniousTime;
	}
	mPrevContiniousTime=t_v;
	float result	= 0.0f;
	float amp		= mAmplitude;
	v				*=mFrequency;
	for(int i=0; i<mOctaves; i++){
		float		octave_time=mTimes[i];
		mTimes[i]	=octave_time+v;
		result		+= noise(octave_time+v)*amp;
		v			*= 2.0f;
		amp			*= 0.5f;
	}
	return result;
}
Example #20
0
void Scene::generate_hextille_grid(const unsigned nb)
{
    FT step = 1.0 / nb;
    std::vector<Point> points;
    for (unsigned i = 0; i < nb; ++i)
    {
        FT y = (i + 0.5)*step;
        for (unsigned j = 0; j < nb; ++j)
        {
            FT x = (j + 0.5)*step;
            if (i % 2 == 1) x += 0.5*step;
            points.push_back(Point(x, y));
        }
    }
    
    std::vector<FT> noise(points.size(), 0.0);
    std::vector<FT> weights(points.size(), 0.0);
    construct_triangulation(points, weights, noise);
    std::cout << "Insert " << points.size() << std::endl;
}
Example #21
0
void Scene::generate_regular_grid(const unsigned nx, const unsigned ny)
{
    FT stepx = 1.0 / nx;
    FT stepy = 1.0 / ny;
    std::vector<Point> points;
    for (unsigned i = 0; i < nx; ++i)
    {
        FT x = (i + 0.5)*stepx;
        for (unsigned j = 0; j < ny; ++j)
        {
            FT y = (j + 0.5)*stepy;
            points.push_back(Point(x, y));
        }
    }
    
    std::vector<FT> noise(points.size(), 0.0);
    std::vector<FT> weights(points.size(), 0.0);
    construct_triangulation(points, weights, noise);
    std::cout << "Insert " << points.size() << std::endl;
}
Example #22
0
void impact_crater_function_1pass(const vector3d &p, double &out, const double height)
{
	double n = fabs(noise(p));
	const double ejecta_outer = 0.6;
	const double outer = 0.9; 
	const double midrim = 0.93;
	double hrim;
	double descent;
	if (n > midrim) {
		out -= height;
	} else if (n > outer) {
		hrim = midrim - outer;
		descent = (n-outer)/hrim;
		out -= height * descent * descent;
	} else if (n > ejecta_outer) {
		// blow down walls of other craters too near this one,
		// so we don't have sharp transition
		//out *= (outer-n)/-(ejecta_outer-outer);
	}
}
Example #23
0
void read_data(uint32 datum_count) {
  uint32 data[datum_count];
  data_package pack = {datum_count, data};

  for (uint32 cur = 0; cur < datum_count; cur++) {
    uint32 datum;
    cgc_read(&datum, sizeof(datum));
    data[cur] = datum;
  }

  while(1) {
    transmit_all(STDOUT, "CHRT", 4);
    transmit_all(STDOUT, (char*)(&datum_count), 4);

    uint32 choice;
    cgc_read(&choice, sizeof(choice));
    
    switch(choice) {
    case 1:
      sparks(pack);
      break;
    case 3:
      bars(pack);
      break;
    case 4:
      echo();
      break;
    case 5:
      seed();
      break;
    case 6:
      noise();
      break;
    case 7:
      replacer(pack);
      break;
    default:
      _terminate(0);
    }
  }
}
Example #24
0
//szum Perlina 2d krok diamond
void Map::diamond(int x, int y, int step, double amp)
{
	if(step > 0) {
		double sum = 0;
		int n = 0;
		if(x > 0) sum += hmap[x-step][y], ++n;
		if(x < n_nodes) sum += hmap[x+step][y], ++n;
		if(y > 0) sum += hmap[x][y-step], ++n;
		if(y < n_nodes) sum += hmap[x][y+step], ++n;
		
		hmap[x][y] = sum / n + noise(amp);
		
		step = step >> 1;
		
		if(step > 0) {
			if(x >= step && y >= step) square(x-step, y-step, step, amp * map_eh);
			if(x >= step && y <= n_nodes-step) square(x-step, y+step, step, amp * map_eh);
			if(x <= n_nodes-step && y >= step) square(x+step, y-step, step, amp * map_eh);
			if(x <= n_nodes-step && y <= n_nodes-step) square(x+step, y+step, step, amp * map_eh);
		}
	}
Example #25
0
// Octaves of 3d simplex noise
float Simplex::octave_noise(int octaves, float freq, float persistence, float x, float y, float z, NoiseContext& nc)
{
	float max = 0;
	float sum = 0;
	float amplitude = 1;

	for (int i = 0; i < octaves; i++)
	{
		// add a layer of noise
		sum += noise(x * freq, y * freq, z * freq, nc) * amplitude;

		// double frequency
		freq *= 2;
		// increase normalization
		max += amplitude;
		// get next amplitude
		amplitude *= persistence;
	}

	return sum / max;
}
Example #26
0
float Simplex::turbulence(int octaves, float freq, float gain, float x, float y, float z, NoiseContext& nc)
{
	float max = 0;
	float sum = 0;
	float amplitude = 1;
	
	for (int i = 0; i < octaves; i++)
	{
		// add a layer of noise
		float signal = (1 - fabs(noise(x * freq, y * freq, z * freq, nc)));
		signal = signal * signal;
		sum += signal * amplitude * pow(freq, -gain);
		// increase normalization
		max += amplitude * pow(freq, -gain);
		// double frequency
		freq *= 2;
		// get next amplitude
		amplitude = signal * gain;
	}

	return sum / max;
}
Example #27
0
File: warp.cpp Project: i80and/warp
void Warp::fbmLine(float y, float xOffset, float* buf, int outWidth) const {
    float amplitude = _persistence;
    float k = _scale;

    memset(buf, 0, sizeof(float)*outWidth);

    for(int octave = 0; octave < OCTAVES; octave += 1) {
        float x = xOffset;

        for(int i = 0; i < outWidth; i += 1) {
            float xcoord = x / (_width/k);
            float ycoord = y / (_height/k);

            buf[i] += noise(xcoord, ycoord) * amplitude;

            x += 1;
        }

        amplitude /= 2;
        k *= 2;
    }
}
Example #28
0
// Encoder
EncoderPhaseShift3::EncoderPhaseShift3(unsigned int _screenCols, unsigned int _screenRows, CodecDir _dir) : Encoder(_screenCols, _screenRows, _dir){

    // Set N
    N = 3;

    // Precompute encoded patterns
    const float pi = M_PI;
    for(unsigned int i=0; i<N; i++){
        float phase = 2.0*pi/float(N) * i;
        float pitch = screenCols;

//        cv::Mat patternI = pstools::computePhaseVector(screenCols, phase, pitch);

        // Loop through vector
        cv::Mat phaseVector(screenCols, 1, CV_32F);
        for(int i=0; i<phaseVector.rows; i++){
            // Amplitude of channels
            float amp = 0.5*(1+cos(2*pi*i/pitch - phase));
            phaseVector.at<float>(i, 0) = amp;
        }

        phaseVector = phaseVector.t();

        // Repeat pattern
        phaseVector = cv::repeat(phaseVector, screenRows, 1);

        // Add noise
        cv::Mat noise(phaseVector.size(), CV_32F);
        cv::randn(noise, 0.0, 0.05);
        phaseVector += noise;

        phaseVector.convertTo(phaseVector, CV_8U, 255.0);

        // Repeat texture
        cv::Mat patternI(screenRows, screenCols, CV_8UC3);
        cv::cvtColor(phaseVector, patternI, cv::COLOR_GRAY2RGB);
        patterns.push_back(patternI);
    }
}
//*************************************
uint8_t vidHardPDRemoval::configure (AVDMGenericVideoStream * in)
{
       _in=in;
    
#define PX(x) &(_param->x)
        
    diaElemUInteger   thresh(PX(threshold),QT_TR_NOOP("_Threshold:"),0,99,
        QT_TR_NOOP("If value is smaller than threshold it is considered valid."
            " Smaller value might mean more false positive"));
    diaElemUInteger   noise(PX(noise),QT_TR_NOOP("_Noise:"),0,99,QT_TR_NOOP("If pixels are closer than noise, they are considered to be the same"));
    diaElemUInteger   identical(PX(identical),QT_TR_NOOP("_Identical:"),0,99,QT_TR_NOOP("If metric is less than identical, images are considered identical"));
    diaElemToggle     show(PX(show),QT_TR_NOOP("_Show metrics"),QT_TR_NOOP("Show metric in image (debug)"));
    
       diaElem *elems[]={&thresh,&noise,&identical,&show};
  
   if(  diaFactoryRun(QT_TR_NOOP("Hard IVTC Removal"),sizeof(elems)/sizeof(diaElem *),elems))
   {
        _lastRemoved=0xFFFFFFF;
        return 1;
    }
        return 0;
}
Example #30
0
static void equivalence_test(const SRCParams &params)
{
  // Source noise
  Samples noise(noise_size);
  RNG(seed).fill_samples(noise, noise_size);
  // Upsampled buffer
  Samples buf1(size_t(double(noise_size + 1) * params.fd / params.fs) + 1);
  // Downsampled buffer
  Samples buf2(noise_size + 100);

  StreamingSRC src;
  BufferSRC test;
  BOOST_MESSAGE("Transform: " << params.fs << "Hz <-> " << params.fd);

  /////////////////////////////////////////////////////////
  // Resample using StreamingSRC

  BOOST_REQUIRE(src.open(params));
  size_t buf1_data = resample(src, noise, noise_size, buf1, buf1.size());

  BOOST_REQUIRE(src.open(SRCParams(params.fd, params.fs, params.a, params.q)));
  size_t buf2_data = resample(src, buf1, buf1_data, buf2, buf2.size());

  /////////////////////////////////////////////////////////
  // Resample using BufferSRC and check the difference

  BOOST_REQUIRE(test.open(params));
  test.process(noise, noise_size);
  BOOST_REQUIRE_EQUAL(test.size(), buf1_data);
  sample_t diff = peak_diff(test.result(), buf1, buf1_data);
  BOOST_CHECK_LE(diff, SAMPLE_THRESHOLD);

  BOOST_REQUIRE(test.open(SRCParams(params.fd, params.fs, params.a, params.q)));
  test.process(buf1, buf1_data);
  BOOST_REQUIRE_EQUAL(test.size(), buf2_data);
  diff = peak_diff(test.result(), buf2, buf2_data);
  BOOST_CHECK_LE(diff, SAMPLE_THRESHOLD);
}