예제 #1
0
float blinnPhong(Vec3f camPos, Vec3f source, Vec3f vertex, Vec3f * triangle, float s)
{
    Vec3f wi(source - vertex);
    Vec3f wo(camPos - vertex);
    Vec3f n = getNormalwithRayComes(triangle, -wo);
    wi.normalize();
    wo.normalize();
    n.normalize();

    Vec3f wh(wi + wo);
    wh.normalize();

    return pow(dot(n, wh),s);
}
예제 #2
0
MyRGBColor
GlossyReflector::area_light_shade(ShadeRec& sr) {
	MyRGBColor L(Phong::area_light_shade(sr));	// direct illumination
	
	Vector3D wo(-sr.ray.d);
	Vector3D wi;
	float pdf;
	MyRGBColor fr(glossy_specular_brdf->sample_f(sr, wi, wo, pdf));
	Ray reflected_ray(sr.hit_point, wi);
	
	L += fr * sr.w.tracer_ptr->trace_ray(reflected_ray, sr.depth + 1) * (sr.normal * wi);
	
	return (L);
}
예제 #3
0
	Spectrum sample(BSDFSamplingRecord &bRec, const Point2 &sample) const {
		if (!(bRec.typeMask & EDiffuseReflection) || Frame::cosTheta(bRec.wi) <= 0)
			return Spectrum(0.0f);

		bRec.wo = warp::squareToCosineHemisphere(sample);
		bRec.eta = 1.0f;
		bRec.sampledComponent = 0;
		bRec.sampledType = EDiffuseReflection;

		djb::vec3 wi(bRec.wi.x, bRec.wi.y, bRec.wi.z);
		djb::vec3 wo(bRec.wo.x, bRec.wo.y, bRec.wo.z);
		djb::vec3 brdf = m_tabular_anisotropic->eval(djb::dir(wi),djb::dir(wo));

		return M_PI * Color3(brdf.x, brdf.y, brdf.z);
	}
예제 #4
0
bool PlasticBsdf::sample(SurfaceScatterEvent &event) const
{
    if (event.wi.z() <= 0.0f)
        return false;

    bool sampleR = event.requestedLobe.test(BsdfLobes::SpecularReflectionLobe);
    bool sampleT = event.requestedLobe.test(BsdfLobes::DiffuseReflectionLobe);

    const Vec3f &wi = event.wi;
    float eta = 1.0f/_ior;
    float Fi = Fresnel::dielectricReflectance(eta, wi.z());
    float substrateWeight = _avgTransmittance*(1.0f - Fi);
    float specularWeight = Fi;
    float specularProbability;
    if (sampleR && sampleT)
        specularProbability = specularWeight/(specularWeight + substrateWeight);
    else if (sampleR)
        specularProbability = 1.0f;
    else if (sampleT)
        specularProbability = 0.0f;
    else
        return false;

    if (sampleR && event.sampler->nextBoolean(specularProbability)) {
        event.wo = Vec3f(-wi.x(), -wi.y(), wi.z());
        event.pdf = specularProbability;
        event.weight = Vec3f(Fi/specularProbability);
        event.sampledLobe = BsdfLobes::SpecularReflectionLobe;
    } else {
        Vec3f wo(SampleWarp::cosineHemisphere(event.sampler->next2D()));
        float Fo = Fresnel::dielectricReflectance(eta, wo.z());
        Vec3f diffuseAlbedo = albedo(event.info);

        event.wo = wo;
        event.weight = ((1.0f - Fi)*(1.0f - Fo)*eta*eta)*(diffuseAlbedo/(1.0f - diffuseAlbedo*_diffuseFresnel));
        if (_scaledSigmaA.max() > 0.0f)
            event.weight *= std::exp(_scaledSigmaA*(-1.0f/event.wo.z() - 1.0f/event.wi.z()));

        event.pdf = SampleWarp::cosineHemispherePdf(event.wo)*(1.0f - specularProbability);
        event.weight /= 1.0f - specularProbability;
        event.sampledLobe = BsdfLobes::DiffuseReflectionLobe;
    }
    return true;
}
	Float eval(const PhaseFunctionSamplingRecord &pRec) const {
		Float Sxx, Sxy, Sxz, Syy, Syz, Szz;
	/*	vec3 omega3(pRec.mRec.orientation.x, pRec.mRec.orientation.y, pRec.mRec.orientation.z);
		omega3 = normalize(omega3);
		Sxx = sigma3*sigma3*omega3.x*omega3.x + omega3.y*omega3.y + omega3.z*omega3.z;
		Sxy = sigma3*sigma3*omega3.x*omega3.y - omega3.x*omega3.y;
		Sxz = sigma3*sigma3*omega3.x*omega3.z - omega3.x*omega3.z;
		Syy = sigma3*sigma3*omega3.y*omega3.y + omega3.x*omega3.x + omega3.z*omega3.z;
		Syz = sigma3*sigma3*omega3.y*omega3.z - omega3.y*omega3.z;
		Szz = sigma3*sigma3*omega3.z*omega3.z + omega3.x*omega3.x + omega3.y*omega3.y;*/
		Sxx = pRec.mRec.S[0]; Syy = pRec.mRec.S[1]; Szz = pRec.mRec.S[2];
		Sxy = pRec.mRec.S[3]; Sxz = pRec.mRec.S[4];	Syz = pRec.mRec.S[5];
		if (Sxx*Sxx + Syy*Syy + Szz*Szz + Sxy*Sxy + Sxz*Sxz + Syz*Syz < 1e-3)
			return 0.0;
		vec3 wi(pRec.wi.x, pRec.wi.y, pRec.wi.z);
		vec3 wo(pRec.wo.x, pRec.wo.y, pRec.wo.z);
		wi = normalize(wi);
		wo = normalize(wo);
		//if (fabs(length) < 0.0001) return 0.0f;
		float value = eval_specular(wi, wo, Sxx, Syy, Szz, Sxy, Sxz, Syz);

	//	Frame frame(pRec.mRec.orientation);
	//	Vector wi = frame.toLocal(pRec.wi);
	//	Vector wo = frame.toLocal(pRec.wo);
	//	Vector H = wi + wo;
	//	Float length = H.length();

	//	if (length == 0)
	//		return 0.0f;
		#if defined(SGGXDEBUGEVAL)
		if (value > 0.0000)
		{
			FILE *f = fopen("log_phase.txt", "a+");
		//	fprintf(f, "ori %f %f %f\n", omega3.x, omega3.y, omega3.z);
		//	fprintf(f, "wi %f %f %f\n", wi.x, wi.y, wi.z);
		//	fprintf(f, "wo %f %f %f\n", wo.x, wo.y, wo.z);
			fprintf(f, "%f\n", value);
			fclose(f);
		}
		#endif
		return value;
	}
예제 #6
0
void dust(int len, char *s)
{
    int i, j, l, from, to, a, b, v;
    char *depadded = (char *)malloc(len);
    int *depad_to_pad = (int *)calloc(len, sizeof(int));
    int depadded_len;

    if (!depadded || !depad_to_pad)
        return;

    memcpy(depadded, s, len);
    depadded_len = len;
    depad_seq(depadded, &depadded_len, depad_to_pad);

    from = 0;
    to = -1;
    for (i=0; i < depadded_len; i += window2) {
        from -= window2;
        to -= window2;
        l = (depadded_len > i+window) ? window : depadded_len-i;
        v = wo(l, depadded+i, &a, &b);
        for (j = from; j <= to; j++) {
            if (isalpha(s[depad_to_pad[i+j]]))
                s[depad_to_pad[i+j]] = '#';
        }
        if (v > level) {
            for (j = a; j <= b && j < window2; j++) {
                if (isalpha(s[depad_to_pad[i+j]]))
                    s[depad_to_pad[i+j]] = '#';
            }
            from = j;
            to = b;
        } else {
            from = 0;
            to = -1;
        }
    }

    free(depadded);
    free(depad_to_pad);
}
예제 #7
0
Float microfacet(Float mu_o, Float mu_i, std::complex<Float> eta_,
                 Float alpha, Float phi_d) {
    Float sinThetaI = math::safe_sqrt(1-mu_i*mu_i),
          sinThetaO = math::safe_sqrt(1-mu_o*mu_o),
          cosPhi = std::cos(phi_d),
          sinPhi = std::sin(phi_d);

    Vector wi(-sinThetaI, 0, -mu_i);
    Vector wo(sinThetaO*cosPhi, sinThetaO*sinPhi, mu_o);
    bool reflect = -mu_i*mu_o > 0;

    if (mu_o == 0 || mu_i == 0)
        return 0.f;
    
    bool conductor = eta_.imag() != 0.0f;
    if (conductor && !reflect)
        return 0.0f;
    std::complex<Float> eta =
        (-mu_i > 0 || conductor) ? eta_ : std::complex<Float>(1) / eta_;

    Vector H = (wi + wo * (reflect ? 1.0f : eta.real())).normalized();
    H *= math::signum(Frame::cosTheta(H));

    Float cosThetaH2 = Frame::cosTheta2(H),
          exponent = -Frame::tanTheta2(H) / (alpha*alpha),
          D = std::exp(exponent) / (math::Pi * alpha*alpha * cosThetaH2*cosThetaH2),
          F = !conductor ? fresnelDielectric(wi.dot(H), eta_.real())
                         : fresnelConductor(std::abs(wi.dot(H)), eta),
          G = smithG1(wi, H, alpha) * smithG1(wo, H, alpha);

    if (reflect) {
        return F * D * G / (4.0f * std::abs(mu_i*mu_o));
    } else {
        Float sqrtDenom = wi.dot(H) + eta.real() * wo.dot(H);

        return std::abs(((1 - F) * D * G * eta.real() * eta.real() * wi.dot(H)
            * wo.dot(H)) / (mu_i*mu_o * sqrtDenom * sqrtDenom));
    }
}
예제 #8
0
void WoLineEdit::sParse()
{
  if (!_parsed)
  {
    if (text().stripWhiteSpace().length() == 0)
      setId(-1);

    else if (_useQuery)
    {
      XSqlQuery wo;
      wo.prepare(_sql);
      wo.exec();
      if (wo.findFirst("wonumber", text().stripWhiteSpace().upper()) != -1)
      {
        setId(wo.value("wo_id").toInt());
        return;
      }
    }

    else if (text().contains('-'))
    {
      int soNumber = text().left(text().find('-')).toInt();
      int subNumber = text().right(text().length() - text().find('-') - 1).toInt();
 //     bool statusCheck = FALSE;
      QString sql = QString( "SELECT wo_id "
                             "FROM wo "
                             "WHERE ((wo_number=%1)"
                             " AND (wo_subnumber=%2)" )
                    .arg(soNumber)
                    .arg(subNumber);

  //  Add in the Status checks
      QStringList statuses;
      if (_woType & cWoOpen)
        statuses << "(wo_status='O')";

      if (_woType & cWoExploded)
        statuses << "(wo_status='E')";

      if (_woType & cWoReleased)
        statuses << "(wo_status='R')";

      if (_woType & cWoIssued)
        statuses << "(wo_status='I')";

      if (_woType & cWoClosed)
        statuses << "(wo_status='C')";

      if(!statuses.isEmpty())
        sql += " AND (" + statuses.join(" OR ") + ")";

      sql += ")";

      XSqlQuery wo(sql);

      if (wo.first())
        setId(wo.value("wo_id").toInt());
      else
        setId(-1);
    }

    else
    {
      bool statusCheck = FALSE;
      QString sql = QString( "SELECT wo_id, wo_number "
                             "FROM wo "
                             "WHERE ((wo_number=%1)")
                    .arg(text().toInt());

//  Add in the Status checks
      if (_woType)
      {
	sql += " AND (";

	if (_woType & cWoOpen)
	{
	  sql += "(wo_status='O')";
	  statusCheck = TRUE;
	}

	if (_woType & cWoExploded)
	{
	  if (statusCheck)
	    sql += " OR ";
	  sql += "(wo_status='E')";
	  statusCheck = TRUE;
	}

	if (_woType & cWoReleased)
	{
	  if (statusCheck)
	    sql += " OR ";
	  sql += "(wo_status='R')";
	  statusCheck = TRUE;
	}

	if (_woType & cWoIssued)
	{
	  if (statusCheck)
	    sql += " OR ";
	  sql += "(wo_status='I')";
	  statusCheck = TRUE;
	}

	if (_woType & cWoClosed)
	{
	  if (statusCheck)
	    sql += " OR ";
	  sql += "(wo_status='C')";
	}

	sql += ")";
      }
      sql += ");";

      XSqlQuery wo(sql);

      if (wo.first())
      {
        if (wo.size() == 1)
          setId(wo.value("wo_id").toInt());
        else
        {
          setId(-1);
          setText(wo.value("wo_number").toString() + "-");
          focusNextPrevChild(FALSE);
          home(FALSE);
          end(FALSE);
        }
      }
      else
        setId(-1);
    }
  }
}
예제 #9
0
파일: nlwav.cpp 프로젝트: Fulg/mame
void convert(nlwav_options_t &opts)
{
	plib::pofilestream fo(opts.opt_out());
	if (fo.bad())
	{
		throw netlist::fatalerror_e("Error opening output file: " + opts.opt_out());
	}
	wav_t wo(fo, 48000);

	plib::pifilestream fin(opts.opt_inp());
	if (fin.bad())
		throw netlist::fatalerror_e("Error opening input file: " + opts.opt_inp());

	double dt = 1.0 / (double) wo.sample_rate();
	double ct = dt;
	//double mean = 2.4;
	double amp = opts.opt_amp();
	double mean = 0.0;
	double means = 0.0;
	double cursam = 0.0;
	double outsam = 0.0;
	double lt = 0.0;
	double maxsam = -1e9;
	double minsam = 1e9;
	int n = 0;
	//short sample = 0;
	pstring line;

	while(fin.readline(line))
	{
#if 1
		float t = 0.0; float v = 0.0;
		sscanf(line.cstr(), "%f %f", &t, &v);
		while (t >= ct)
		{
			outsam += (ct - lt) * cursam;
			outsam = outsam / dt;
			if (t>0.0)
			{
				means += outsam;
				maxsam = std::max(maxsam, outsam);
				minsam = std::min(minsam, outsam);
				n++;
				//mean = means / (double) n;
				mean += 5.0 / (double) wo.sample_rate() * (outsam - mean);
			}
			outsam = (outsam - mean) * amp;
			outsam = std::max(-32000.0, outsam);
			outsam = std::min(32000.0, outsam);
			wo.write_sample((int) outsam);
			outsam = 0.0;
			lt = ct;
			ct += dt;
		}
		outsam += (t-lt)*cursam;
		lt = t;
		cursam = v;
#else
		float t = 0.0; float v = 0.0;
		fscanf(FIN, "%f %f", &t, &v);
		while (ct <= t)
		{
			wo.write_sample(sample);
			n++;
			ct += dt;
		}
		means += v;
		mean = means / (double) n;
		v = v - mean;
		v = v * amp;
		if (v>32000.0)
			v = 32000.0;
		else if (v<-32000.0)
			v = -32000.0;
		sample = v;
		//printf("%f %f\n", t, v);
#endif
	}
	pout("Mean (low freq filter): {}\n", mean);
	pout("Mean (static):          {}\n", means / (double) n);
	pout("Amp + {}\n", 32000.0 / (maxsam- mean));
	pout("Amp - {}\n", -32000.0 / (minsam- mean));
	wo.close();
	fo.close();
	fin.close();

}
예제 #10
0
RGBColor Dielectric::shade(ShadeRec& sr)const
{
	RGBColor L(Phong::shade(sr));
		
	Vector3D 	wi;
	Vector3D 	wo(-sr.ray.d);
	RGBColor 	fr = fresnel_brdf->sample_f(sr, wo, wi);  	// computes wi
	Ray 		reflected_ray(sr.hit_point, wi); 
	double 		t;
	RGBColor 	Lr, Lt;
	float 		ndotwi =  sr.normal * wi;
		
	if(fresnel_btdf->tir(sr)) 
	{								// total internal reflection
		if (ndotwi < 0.0) 
		{  	
			// reflected ray is inside
			
			Lr = sr.w.tracer_ptr->trace_ray(reflected_ray, t, sr.depth + 1);
			L += cf_in.powc(t) * Lr;   						// inside filter color
		}
		else
		{				
			// reflected ray is outside
			
			Lr = sr.w.tracer_ptr->trace_ray(reflected_ray, t, sr.depth + 1);   // kr = 1  
			L += cf_out.powc(t) * Lr;   					// outside filter color
		}
	}
	else 
	{ 													// no total internal reflection
		Vector3D wt;
		RGBColor ft = fresnel_btdf->sample_f(sr, wo, wt);  	// computes wt
		Ray transmitted_ray(sr.hit_point, wt);
		float ndotwt = sr.normal * wt;
							
		if (ndotwi < 0.0)
		{
			// reflected ray is inside
						
			Lr = fr * sr.w.tracer_ptr->trace_ray(reflected_ray, t, sr.depth + 1) * fabs(ndotwi);
			L += cf_in.powc(t) * Lr;     					// inside filter color
				
			// transmitted ray is outside
							
			Lt = ft * sr.w.tracer_ptr->trace_ray(transmitted_ray, t, sr.depth + 1) * fabs(ndotwt); 
			L += cf_out.powc(t) * Lt;   					// outside filter color
		}
		else 
		{				
			// reflected ray is outside

			Lr = fr * sr.w.tracer_ptr->trace_ray(reflected_ray, t, sr.depth + 1) * fabs(ndotwi); 
			L += cf_out.powc(t) * Lr;						// outside filter color
				
			// transmitted ray is inside
			
			Lt = ft * sr.w.tracer_ptr->trace_ray(transmitted_ray, t, sr.depth + 1) * fabs(ndotwt); 
			L += cf_in.powc(t) * Lt; 						// inside filter color
		}		
	}	
	
	return (L);
}
예제 #11
0
파일: dust.c 프로젝트: hsptools/hsp-wrap
extern FloatHiPtr DustGraph (SeqPortPtr spp, Int4 length, Int2 level,
                             Int2 window, Int2 minwin, Int2 linker)
{
  DCURLOC     cloc;
  Int2        windowhalf;
  Int2        retlen;
  Int4        len;
  Int4        i, n;
  Int4        invrescount;
  FloatHi     maxval, curval;
  FloatHiPtr  fhead, ftemp;
  FloatHiPtr  fptr;
  UcharPtr    seq;

  invrescount = 0;
  windowhalf = window / 2;

  maxval = level * 5.0;
  if (maxval > 100.0)
    maxval = 100.0;

  fptr = (FloatHiPtr) MemNew ((sizeof (FloatHi)) * length);
  fhead = fptr;
  for (i = 0; i < length; i++)
    *fptr++ = 0.0;

  fptr = fhead;
  seq = MemNew ((size_t)window);			/* triplets */
  if (!seq)
      {
          ErrPostEx (SEV_FATAL, 4, 1,
                     "failed to allocate triplet buffer");
          ErrShow ();
          return 0;
      }

  for (i = 0; i < length; i += windowhalf)
  {
    len = (length > i+window) ? window : (Int2) (length-i);
    len -= 2;
    retlen = wo (len, spp, i, &cloc, &invrescount, seq);

    if ((cloc.curend - cloc.curstart + 1) < minwin)
    {
      if (retlen != len)
        i += (retlen - windowhalf + 3);
      continue;
    }
    curval = (FloatHi) cloc.curlevel;
    if (curval > maxval)
      curval = maxval;
    fptr = fhead + cloc.curstart + i;
    for (n = cloc.curstart; n < cloc.curend+1; n++)
      *fptr++ = curval;
  }
  MemFree(seq);
  fptr = fhead;
  for (i = 0; i < length-((Int4)linker); i++)
  {
    if (*fptr != 0)
    {
      ftemp = fptr + linker;
      if (*ftemp != 0)
      {
        curval = (*ftemp + *fptr) / 2;
        fptr++;
        for (n = 1; n < linker; n++)
          *fptr++ = curval;
        i += (linker - 1);
      }
    }
    else
    {
      fptr++;
    }
  }

  return fhead;
}
예제 #12
0
파일: dust.c 프로젝트: hsptools/hsp-wrap
static Int4 dust_segs (Int4 length, SeqPortPtr spp, Int4 start,
		       DREGION PNTR reg,
		       Int4 level, Int4 windowsize, Int4 minwin, Int4 linker)
{
        Int4    len;
	Int4	i, invrescount;
        Int4 retlen;
        UcharPtr seq;
	DREGION	PNTR regold = NULL;
	DCURLOC	cloc;
	Int4	nreg, windowhalf;

/* defaults are more-or-less in keeping with original dust */
	if (level < 2 || level > 64) level = 20;
	if (windowsize < 8 || windowsize > 64) windowsize = 64;
	if (minwin < 4 || minwin > 128) minwin = 4;
	if (linker < 1 || linker > 32) linker = 1;
	windowhalf = windowsize / 2;

/* keep track of weird invalid residues */
	invrescount = 0;

	nreg = 0;
	seq = MemNew (windowsize);			/* triplets */
	if (!seq)
	{
		ErrPostEx (SEV_FATAL, 4, 1,
			   "failed to allocate triplet buffer");
                ErrShow ();
		return nreg;
	}

	for (i = 0; i < length; i += windowhalf)
	{
		len = (Int4) ((length > i+windowsize) ? windowsize : length-i);
		len -= 2;
		retlen = wo (len, spp, i, &cloc, &invrescount, seq);

/* get rid of itsy-bitsy's, dusttripfind aborts - move 1 triplet away */
		if ((cloc.curend - cloc.curstart + 1) < minwin)
		{
			if (retlen != len)
			{
				i += (retlen - windowhalf + 3);
			}
			continue;
		}

		if (cloc.curlevel > level)
		{
			if (nreg &&
			    regold->to + linker >= cloc.curstart+i+start &&
			    regold->from <= cloc.curstart + i + start)
			{
/* overlap windows nicely if needed */
				regold->to = cloc.curend + i + start;
			}
			else
			{
/* new window or dusted regions do not overlap				*/
				reg->from = cloc.curstart + i + start;
				reg->to = cloc.curend + i + start;
/* 5' edge effects - 3' edge effects - are best handled interactively	*/
/* it prbly would be good to put 'linker' as an interactive option	*/
/* interactive means wrapping stuff up in a graphics shell		*/
				regold = reg;
				reg = MemNew (sizeof (DREGION));
				if (!reg)
				{
					ErrPostEx (SEV_FATAL, 3, 1,
						   "memory allocation error");
					ErrShow ();
                                        MemFree(seq);
					return nreg;
				}
				reg->next = NULL;
				regold->next = reg;
				nreg++;
			}
/* kill virtually all 3' tiling anomalies */
			if (cloc.curend < windowhalf)
			{
				i += (cloc.curend - windowhalf);
			}
		}				/* end 'if' high score	*/
	}					/* end for */
	MemFree (seq);
	if (invrescount > 0)
	{
		ErrPostEx (SEV_INFO, 3, 2,
		   "Total invalid residues found: %ld", (long) invrescount);
                ErrShow ();
	}
	return nreg;
}
예제 #13
0
파일: nlwav.c 프로젝트: matthewbauer/mame
void convert(nlwav_options_t &opts)
{
	
	wav_t wo(opts.opt_out(), 48000);
	
	FILE *FIN = std::fopen(opts.opt_inp(),"r");
	if (FIN==NULL)
		throw netlist::fatalerror_e("Error opening input file: %s", opts.opt_inp().cstr());
	
	double dt = 1.0 / (double) wo.sample_rate();
	double ct = dt;
	//double mean = 2.4;
	double amp = opts.opt_amp();
	double mean = 0.0;
	double means = 0.0;
	double cursam = 0.0;
	double outsam = 0.0;
	double lt = 0.0;
	double maxsam = -1e9;
	double minsam = 1e9;
	int n = 0;
	//short sample = 0;

	
	while(!std::feof(FIN))
	{
#if 1
		float t = 0.0; float v = 0.0;
		fscanf(FIN, "%f %f", &t, &v);
		while (t >= ct)
		{
			outsam += (ct - lt) * cursam;
			outsam = outsam / dt;
			if (t>0.0)
			{
				means += outsam;
				maxsam = std::max(maxsam, outsam);
				minsam = std::min(minsam, outsam);
				n++;
				//mean = means / (double) n;
				mean += 5.0 / (double) wo.sample_rate() * (outsam - mean);
			}
			outsam = (outsam - mean) * amp;
			outsam = std::max(-32000.0, outsam);
			outsam = std::min(32000.0, outsam);
			wo.write_sample((int) outsam);
			outsam = 0.0;
			lt = ct;
			ct += dt;
		}
		outsam += (t-lt)*cursam;
		lt = t;
		cursam = v;
#else
		float t = 0.0; float v = 0.0;
		fscanf(FIN, "%f %f", &t, &v);
		while (ct <= t)
		{
			wo.write_sample(sample);
			n++;
			ct += dt;
		}
		means += v;
		mean = means / (double) n;
		v = v - mean;
		v = v * amp;
		if (v>32000.0)
			v = 32000.0;
		else if (v<-32000.0)
			v = -32000.0;
		sample = v;	
		//printf("%f %f\n", t, v);
#endif
	}
	printf("Mean (low freq filter): %f\n", mean);
	printf("Mean (static):          %f\n", means / (double) n);
	printf("Amp + %f\n", 32000.0 / (maxsam- mean));
	printf("Amp - %f\n", -32000.0 / (minsam- mean));
	wo.close();
	fclose(FIN);

}