Exemplo n.º 1
0
void Renderer::FillSpan( float x0, float x1, int y, VertexShaderOutput& va0, VertexShaderOutput& va1, PixelShader& ps )
{
	int startX = Float2Int(x0);
	int endX = Float2Int(x1);
	float lenR = 1.0f / (x1 - x0);
	float xt = x0;

	VertexShaderOutput va;
	for (int x = startX; x < endX; x++)
	{
		xt = float(x + 1);
		Lerp(va, va0, va1, (x1 - xt) * lenR);

		// early z-test (before executing pixel shader)
		if (!m_depthBuffer->TestDepth(x, y, va.position.z))
		{
			continue;
		}
		
		// execute the pixel shader
		Vector4& color = ps.Main(va);

		int r = Float2Int(color.x * 255.0f);
		int g = Float2Int(color.y * 255.0f);
		int b = Float2Int(color.z * 255.0f);
		m_renderTarget->SetPixel(x, y, COLOR_RGB(r, g, b));
	}
}
Exemplo n.º 2
0
Vector4 Texture::Sample( float u, float v )
{
	float dummy;
	if (u > 1.0f)
	{
		u = modf(u, &dummy);
	}
	else if (u < 0.0f)
	{
		u = 1.0f + modf(u, &dummy);
	}

	if (v > 1.0f)
	{
		v = modf(v, &dummy);
	}
	else if (v < 0.0f)
	{
		v = 1.0f + modf(v, &dummy);
	}

	int texelIndex = (Float2Int(v * (m_height - 1.0f)) * m_width + Float2Int(u * (m_width - 1.0f))) << 2;

	Vector4 color;
	float r = 1.0f / 255.0f;
	color.x = m_colorData[texelIndex + 0] * r;
	color.y = m_colorData[texelIndex + 1] * r;
	color.z = m_colorData[texelIndex + 2] * r;
	color.w = m_colorData[texelIndex + 3] * r;

	return color;
}
Exemplo n.º 3
0
void CEQDisplay::SetBandInfo(tuint uiBand, tbool bEnabled, tfloat32 fFreqIndex, tfloat32 fdBIndex)
{
	tfloat32 fXIndex = fFreqIndex;
	tfloat32 fYIndex = 1 - fdBIndex;

	tint32 iXPositions = dynamic_cast<I2D*>(*(mControls.begin()))->GetXPositions();
	tint32 iYPositions = dynamic_cast<I2D*>(*(mControls.begin()))->GetYPositions();

	tint32 iXPos = Float2Int(fXIndex * (iXPositions - 1));
	tint32 iYPos = Float2Int(fYIndex * (iYPositions - 1));

	tint32 iValue = iXPos << 16 | iYPos;

	// Get the control
	std::list<IControl*>::iterator it = mControls.begin();
	tuint uiIndex = uiBand;
	while (uiIndex) {
		it++;
		uiIndex--;
	}
	IControl* pControl = *it;

	pControl->SetValue(iValue, false);
	pControl->SetVisible(bEnabled);
}
Exemplo n.º 4
0
		BOOL StdImpact013_T::GetIntAttrRefix(OWN_IMPACT & rImp, Obj_Character& rMe, CharIntAttrRefixs_T::Index_T nIdx, INT & rIntAttrRefix) const
		{
			__ENTER_FUNCTION
			INT nRefixRate = GetRefixRate(rImp);
			nRefixRate += 100;
			INT nValue = 0;
			switch (nIdx)
			{
				case CharIntAttrRefixs_T::REFIX_HIT:
					{
						if(0!=GetHitRefix(rImp))
						{
							nValue = Float2Int((GetHitRefix(rImp)*nRefixRate)/100.0f);
							rIntAttrRefix += nValue;
							return TRUE;
						}
					}
					break;
				case CharIntAttrRefixs_T::REFIX_MISS:
					{
						if(0!=GetMissRefix(rImp))
						{
							nValue = Float2Int((GetMissRefix(rImp)*nRefixRate)/100.0f);
							rIntAttrRefix += nValue;
							return TRUE;
						}
					}
					break;
				case CharIntAttrRefixs_T::REFIX_CRITICAL:
					{
						if(0!=GetCriticalRefix(rImp))
						{
							nValue = Float2Int((GetCriticalRefix(rImp)*nRefixRate)/100.0f);
							rIntAttrRefix += nValue;
							return TRUE;
						}
					}
					break;
				case CharIntAttrRefixs_T::REFIX_TOUGHNESS:
					{
						if(0!=GetToughnessRefix(rImp))
						{
							nValue = Float2Int((GetToughnessRefix(rImp)*nRefixRate)/100.0f);
							rIntAttrRefix += nValue;
							return TRUE;
						}
					}
					break;
					
				default:
					break;
			}
			__LEAVE_FUNCTION
			return FALSE;
		}
Exemplo n.º 5
0
 BOOL StdImpact004_T::RefixPowerByRate(OWN_IMPACT & rImp, INT nRate) const
 {
     __ENTER_FUNCTION
     nRate += 100;
     SetHpModification(rImp, Float2Int((GetHpModification(rImp)*nRate)/100.0f));
     SetMpModification(rImp, Float2Int((GetMpModification(rImp)*nRate)/100.0f));
     SetRageModification(rImp, Float2Int((GetRageModification(rImp)*nRate)/100.0f));
     SetStrikePointModification(rImp, Float2Int((GetStrikePointModification(rImp)*nRate)/100.0f));
     __LEAVE_FUNCTION
     return TRUE;
 }
Exemplo n.º 6
0
float InfiniteAreaLightIS::Pdf(const Point &,
		const Vector &w) const {
	Vector wi = WorldToLight(w);
	float theta = SphericalTheta(wi), phi = SphericalPhi(wi);
	int u = Clamp(Float2Int(phi * INV_TWOPI * uDistrib->count),
                  0, uDistrib->count-1);
	int v = Clamp(Float2Int(theta * INV_PI * vDistribs[u]->count),
                  0, vDistribs[u]->count-1);
	return (uDistrib->func[u] * vDistribs[u]->func[v]) /
           (uDistrib->funcInt * vDistribs[u]->funcInt) *
           1.f / (2.f * M_PI * M_PI * sin(theta));
}
Exemplo n.º 7
0
void CEQDisplay::OnDraw(const SRect &rUpdate)
{
	ASSERT(mpCallback != NULL);

	memset(mpfBufferCurveTotal, 0, GetSize().iCX * sizeof(tfloat32));
	tuint uiBand;
	for (uiBand = 0; uiBand < muiNrOfBands; uiBand++) {
		mpCallback->GetCurve(miCallbackUserDefined, uiBand, mpfBufferCurveBand, GetSize().iCX);

		tint iIndex;
		for (iIndex = 0; iIndex < GetSize().iCX; iIndex++) {
			mpfBufferCurveTotal[iIndex] += mpfBufferCurveBand[iIndex];
		}
	}

//	const tfloat32 fdBMax = 12.0f;
//	const tfloat32 fdBMin = -24.0f;

	tint iIndex;
	for (iIndex = 0; iIndex < GetSize().iCX; iIndex++) {
		tfloat32 fdB = mpfBufferCurveTotal[iIndex];
		//fdB = min(fdB, mfdBMax);
		//fdB = max(fdB, mfdBMin);
		if ((fdB>=mfdBMin)&&(fdB<=mfdBMax)) {
			tfloat32 fIndex = (fdB - mfdBMin) / (mfdBMax - mfdBMin);
			tint32 iYPos = Float2Int((GetSize().iCY - 1) * (1 - fIndex));

			SPos Pos(GetPos() + SPos(iIndex, iYPos));

			mpDrawPrimitives->DrawPoint(rUpdate, Pos, mColour);
		}
	}

	CPane::OnDraw(rUpdate);
}
Exemplo n.º 8
0
 INT StdImpact017_T::OnFiltrateImpact(OWN_IMPACT& rImp, Obj_Character& rMe, OWN_IMPACT& rImpactNeedCheck) const
 {
     __ENTER_FUNCTION
     INT nImmunoLevel = GetImmunoLevel(rImp);
     INT nRate = GetRefixRate(rImp);
     nRate += 100;
     nImmunoLevel = Float2Int((nImmunoLevel*nRate)/100.0f);
     IDCollection_T const* pCollection = NULL;
     for(INT nIdx=0; COLLECTION_COUNT>nIdx; ++nIdx)
     {
         INT nCollectionID = GetCollectionByIndex(rImp, nIdx);
         if(INVALID_ID != nCollectionID)
         {
             pCollection = g_IDCollectionMgr.GetInstanceByID(nCollectionID);
             if(NULL!=pCollection)
             {
                 if(0<pCollection->GetCollectionSize())
                 {
                     if(nImmunoLevel>=Impact_GetLevel(rImpactNeedCheck))
                     {
                         if(TRUE==Impact_IsImpactInCollection(rImpactNeedCheck, nCollectionID))
                         {
                             return MissFlag_T::FLAG_IMMU; //免疫该效果
                         }
                     }
                 }
             }
         }
     }
     return FALSE;
     __LEAVE_FUNCTION
     return FALSE;
 }
Exemplo n.º 9
0
 VOID StdImpact039_T::RefixRageRegeneration(OWN_IMPACT const& rImp, INT& rRageRegeneration) const
 {
     __ENTER_FUNCTION
     INT nValue = Float2Int((rRageRegeneration * GetRageRegenerateRefix(rImp))/100.0f);
     rRageRegeneration += nValue;
     __LEAVE_FUNCTION
 }            
Exemplo n.º 10
0
Spectrum InfiniteAreaLightIS::Sample_L(const Point &p, float u1,
		float u2, Vector *wi, float *pdf,
		VisibilityTester *visibility) const {
	// Find floating-point $(u,v)$ sample coordinates
	float pdfs[2];
	float fu = uDistrib->Sample(u1, &pdfs[0]);
	int u = Clamp(Float2Int(fu), 0, uDistrib->count-1);
	float fv = vDistribs[u]->Sample(u2, &pdfs[1]);
	if (pdfs[0] == 0.f || pdfs[1] == 0.f) {
		*pdf = 0.f;
		return Spectrum(0.f);
	}
	// Convert sample point to direction on the unit sphere
	float theta = fv * vDistribs[u]->invCount * M_PI;
	float phi = fu * uDistrib->invCount * 2.f * M_PI;
	float costheta = cos(theta), sintheta = sin(theta);
	if (sintheta == 0.f) return 0.f;
	float sinphi = sin(phi), cosphi = cos(phi);
	*wi = LightToWorld(Vector(sintheta * cosphi, sintheta * sinphi,
	                          costheta));
	// Compute PDF for sampled direction
	*pdf = (pdfs[0] * pdfs[1]) / (2. * M_PI * M_PI * sintheta);
	// Return radiance value for direction
	visibility->SetRay(p, *wi);
	return Lbase * radianceMap->Lookup(fu * uDistrib->invCount,
		fv * vDistribs[u]->invCount);
}
Exemplo n.º 11
0
void Waifu2x_Process_Base::process_core_gray()
{
    FLType *dstYd = nullptr, *srcYd = nullptr; // *refYd = nullptr

    // Get write/read pointer
    auto dstY = reinterpret_cast<_Ty *>(vsapi->getWritePtr(dst, 0));
    auto srcY = reinterpret_cast<const _Ty *>(vsapi->getReadPtr(src, 0));

    // Allocate memory for floating point Y data
    AlignedMalloc(dstYd, dst_pcount[0]);
    AlignedMalloc(srcYd, src_pcount[0]);

    // Convert src and ref from integer Y data to floating point Y data
    Int2Float(srcYd, srcY, src_height[0], src_width[0], src_stride[0], src_stride[0], false, d.para.full, false);

    // Execute kernel
    Kernel(dstYd, srcYd);

    // Convert dst from floating point Y data to integer Y data
    Float2Int(dstY, dstYd, dst_height[0], dst_width[0], dst_stride[0], dst_stride[0], false, d.para.full, !isFloat(_Ty));

    // Free memory for floating point Y data
    AlignedFree(dstYd);
    AlignedFree(srcYd);
}
Exemplo n.º 12
0
tint32 CConverterLinear::Parm2GUI(tint32 iParm) const
{
	tfloat64 fValue = Parm2Normalised(iParm);

	tint32 iMax = gControlMax - gControlMin;

	return Float2Int(fValue * iMax) + gControlMin;
}
Exemplo n.º 13
0
Vector4 Texture::Sample( float u, float v )
{
	// Float2Int函数在浮点数十分接近一个整数时并不稳定。
	// 在这里做UV wrap时不可预估的输出将可能导致crash。
	// 为了安全起见选用慢一些的modf实现功能。

	/*if (u > 1.0f || u < 0.0f)
	{
		u -= Float2Int(u - 0.00001f);
	}

	if (v > 1.0f || v < 0.0f)
	{
		v -= Float2Int(v - 0.00001f);
	}*/

	double dummy;
	if (u > 1.0f)
	{
		u = (float)modf(double(u), &dummy);
	}
	else if (u < 0.0f)
	{
		u = 1.0f + (float)modf(double(u), &dummy);
	}

	if (v > 1.0f)
	{
		v = (float)modf(double(v), &dummy);
	}
	else if (v < 0.0f)
	{
		v = 1.0f + (float)modf(double(v), &dummy);
	}

	int texelIndex = (Float2Int(v * (m_height - 1.0f)) * m_width + Float2Int(u * (m_width - 1.0f))) << 2;

	Vector4 color;
	float r = 1.0f / 255.0f;
	color.x = m_colorData[texelIndex + 0] * r;
	color.y = m_colorData[texelIndex + 1] * r;
	color.z = m_colorData[texelIndex + 2] * r;
	color.w = m_colorData[texelIndex + 3] * r;

	return color;
}
Exemplo n.º 14
0
void Waifu2x_Process_Base::process_core_yuv()
{
    FLType *dstYd = nullptr, *dstUd = nullptr, *dstVd = nullptr;
    FLType *srcYd = nullptr, *srcUd = nullptr, *srcVd = nullptr;

    // Get write/read pointer
    auto dstY = reinterpret_cast<_Ty *>(vsapi->getWritePtr(dst, 0));
    auto dstU = reinterpret_cast<_Ty *>(vsapi->getWritePtr(dst, 1));
    auto dstV = reinterpret_cast<_Ty *>(vsapi->getWritePtr(dst, 2));

    auto srcY = reinterpret_cast<const _Ty *>(vsapi->getReadPtr(src, 0));
    auto srcU = reinterpret_cast<const _Ty *>(vsapi->getReadPtr(src, 1));
    auto srcV = reinterpret_cast<const _Ty *>(vsapi->getReadPtr(src, 2));

    // Allocate memory for floating point YUV data
    AlignedMalloc(dstYd, dst_pcount[0]);
    if (d.process[1]) AlignedMalloc(dstUd, dst_pcount[1]);
    if (d.process[2]) AlignedMalloc(dstVd, dst_pcount[2]);

    AlignedMalloc(srcYd, src_pcount[0]);
    if (d.process[1]) AlignedMalloc(srcUd, src_pcount[1]);
    if (d.process[2]) AlignedMalloc(srcVd, src_pcount[2]);

    // Convert src and ref from integer YUV data to floating point YUV data
    Int2Float(srcYd, srcY, src_height[0], src_width[0], src_stride[0], src_stride[0], false, d.para.full, false);
    if (d.process[1]) Int2Float(srcUd, srcU, src_height[1], src_width[1], src_stride[1], src_stride[1], true, d.para.full, false);
    if (d.process[2]) Int2Float(srcVd, srcV, src_height[2], src_width[2], src_stride[2], src_stride[2], true, d.para.full, false);

    // Execute kernel
    if (d.chroma) Kernel(dstYd, dstUd, dstVd, srcYd, srcUd, srcVd);
    else Kernel(dstYd, srcYd);

    // Convert dst from floating point YUV data to integer YUV data
    Float2Int(dstY, dstYd, dst_height[0], dst_width[0], dst_stride[0], dst_stride[0], false, d.para.full, !isFloat(_Ty));
    if (d.process[1]) Float2Int(dstU, dstUd, dst_height[1], dst_width[1], dst_stride[1], dst_stride[1], true, d.para.full, !isFloat(_Ty));
    if (d.process[2]) Float2Int(dstV, dstVd, dst_height[2], dst_width[2], dst_stride[2], dst_stride[2], true, d.para.full, !isFloat(_Ty));

    // Free memory for floating point YUV data
    AlignedFree(dstYd);
    if (d.process[1]) AlignedFree(dstUd);
    if (d.process[2]) AlignedFree(dstVd);

    AlignedFree(srcYd);
    if (d.process[1]) AlignedFree(srcUd);
    if (d.process[2]) AlignedFree(srcVd);
}
Exemplo n.º 15
0
		BOOL StdImpact001_T::RefixPowerByRate(OWN_IMPACT & rImp, INT nRate) const
		{
			__ENTER_FUNCTION
			nRate += 100;
			SetDamage(rImp, Float2Int((GetDamage(rImp)*nRate)/100.0f));
			__LEAVE_FUNCTION
			return TRUE;
		}
Exemplo n.º 16
0
void CRegion_GUI::Set_Size_X()
{

    miSize_X = Float2Int(muiSample_Duration * mpKSPlugIn->GetPixelPrSample());

    if(mpText)
        mpText->SetVisible(miSize_X > 118);


}
Exemplo n.º 17
0
void CFFTOSX::Init(tuint uiOrder)
{
	muiOrder = uiOrder;
	muiFFTSize = Float2Int(pow(2, muiOrder));

	mA.realp = new float[muiFFTSize / 2];
	mA.imagp = new float[muiFFTSize / 2];

	mFFT = vDSP_create_fftsetup(muiOrder, FFT_RADIX2);
}
Exemplo n.º 18
0
void CFFTWin::Init(tuint uiOrder)
{
	if (mpFreqDomain) {
		delete[] mpFreqDomain;
	}

	muiOrder = uiOrder;
	muiFFTSize = Float2Int(pow((tfloat64)2, (tint)muiOrder));

	mpFreqDomain = (void*)new sample[muiFFTSize + 2];
}
Exemplo n.º 19
0
		VOID StdImpact023_T::OnDamageTarget(OWN_IMPACT& rImp, Obj_Character& rMe, Obj_Character& rTar, INT& rDamage, SkillID_t nSkillID) const
		{
			__ENTER_FUNCTION
			INT nMpDamageRate = GetMpDamageRate(rImp);
			INT nRageDamageRate = GetRageDamageRate(rImp);
			if(TRUE==rImp.IsFadeOut())
			{
				return;
			}
			if(0>=nMpDamageRate && 0>= nRageDamageRate)
			{
				return;
			}
			Scene* pScene = rMe.getScene();
			if(NULL==pScene)
			{
				return;
			}
			// 生效几率 
			INT nActivateOdds = GetActivateOdds(rImp);
			INT nRet = pScene->GetRand100();
			if (nRet > nActivateOdds)
			{// 没有生效则直接返回
				return;
			}
			// 命中时吸取敌人MP百分率
			if(0<nMpDamageRate)
			{
				INT nMP = Float2Int((nMpDamageRate*rDamage)/100.0f);
				rTar.ManaIncrement(-nMP, &rMe);
			}
			// 命中时吸取敌人怒气百分率
			if(0<nRageDamageRate)
			{
				INT nRage = rTar.GetRage();
				nRage = Float2Int((nRageDamageRate*nRage)/100.0f);
				rTar.RageIncrement(-nRage, &rMe); 
			}
			__LEAVE_FUNCTION
		}
Exemplo n.º 20
0
COREDLL Spectrum WeightedSampleOneLight(const Scene *scene,
		const Point &p, const Normal &n,
		const Vector &wo, BSDF *bsdf,
		const Sample *sample, int lightSampleOffset,
		int lightNumOffset, int bsdfSampleOffset,
		int bsdfComponentOffset, float *&avgY,
		float *&avgYsample, float *&cdf,
		float &overallAvgY) {
	int nLights = int(scene->lights.size());
	// Initialize _avgY_ array if necessary
	if (!avgY) {
		avgY = new float[nLights];
		avgYsample = new float[nLights];
		cdf = new float[nLights+1];
		for (int i = 0; i < nLights; ++i)
			avgY[i] = avgYsample[i] = 0.;
	}
	Spectrum L(0.);
	if (overallAvgY == 0.) {
		// Sample one light uniformly and initialize luminance arrays
		L = UniformSampleOneLight(scene, p, n,
		    wo, bsdf, sample, lightSampleOffset,
			lightNumOffset, bsdfSampleOffset,
			bsdfComponentOffset);
		float luminance = L.y();
		overallAvgY = luminance;
		for (int i = 0; i < nLights; ++i)
			avgY[i] = luminance;
	}
	else {
		// Choose _light_ according to average reflected luminance
		float c, lightSampleWeight;
		for (int i = 0; i < nLights; ++i)
			avgYsample[i] = max(avgY[i], .1f * overallAvgY);
		ComputeStep1dCDF(avgYsample, nLights, &c, cdf);
		float t = SampleStep1d(avgYsample, cdf, c, nLights,
			sample->oneD[lightNumOffset][0], &lightSampleWeight);
		int lightNum = min(Float2Int(nLights * t), nLights-1);
		Light *light = scene->lights[lightNum];
		L = EstimateDirect(scene, light, p, n, wo, bsdf,
			sample, lightSampleOffset, bsdfSampleOffset,
			bsdfComponentOffset, 0);
		// Update _avgY_ array with reflected radiance due to light
		float luminance = L.y();
		avgY[lightNum] =
			ExponentialAverage(avgY[lightNum], luminance, .99f);
		overallAvgY =
			ExponentialAverage(overallAvgY, luminance, .999f);
		L /= lightSampleWeight;
	}
	return L;
}
Exemplo n.º 21
0
void CRegion_GUI::Update_Graphic()
{

    Set_Size_X();
    Set_Pos_X();
    Update_Size();

    mpPane->SetSize(ge::SSize(miSize_X, miSize_Y ? giTrack_Size_Big-1: giTrack_Size_Small-1));
    mpPane->SetPos(ge::SPos(miPos_X, 0));

    tfloat32 fSizeY			= miSize_Y ? giTrack_Size_Big - 6 : giTrack_Size_Small - 6;
    muiRegion_Volume_Pixel	= Float2Int( fSizeY - (mfRegion_Volume * fSizeY));


    Draw_Fade_In();
    Draw_Fade_Out();
    Draw_Region_Volume();
}
Exemplo n.º 22
0
void processLayer( int width, int height, unsigned int* cuda_int_dest) 
{
	if(gAction == DO_FORM0)
	{
		gObj0X = (float)gMousex;
		gObj0Y = (float)gMousey;
		gAction = DO_DEFAULT;
	}

//update random
	Randomize(cuRandArr, sim_width, sim_height);

	LayerProc(width, height, gCudaLayer[0], gCudaFuncLayer[0], cuTempData, (float)gObj0X, (float)gObj0Y, gObj1X, gObj1Y);
//physical
	int outPhLayer = (currPhLayer+1)%2;
	cudaMemset(gPhysLayer[outPhLayer], 0, sim_rect*sizeof(float));

	ParticleLayerProc(cuTempData, cuRandArr, gStateLayer[currPhLayer], gStateLayer[outPhLayer],
		gPhysLayer[currPhLayer], gRedBlueField, gVectorLayer, 
		gPhysLayer[outPhLayer], moveLayerx, moveLayery);

	FieldLayerProc(cuTempData,
		gRedBlueField, gRedBlueField, 
		gVectorLayer, sim_width, sim_height);

	Float2Int(width, height, cuTempData, gPhysLayer[outPhLayer], gStateLayer[outPhLayer],
		gRedBlueField, gVectorLayer, cuda_int_dest);

	currPhLayer = outPhLayer;

	SetVectorField(gMousex, gMousey, 20);
//debug
	if(debShowMax == 1)
		SetSpots(cuda_int_dest);

}
Exemplo n.º 23
0
		BOOL StdImpact011_T::GetIntAttrRefix(OWN_IMPACT & rImp, Obj_Character& rMe, CharIntAttrRefixs_T::Index_T nIdx, INT & rIntAttrRefix) const
		{
			__ENTER_FUNCTION
			INT nRefixRate = GetRefixRate(rImp);
			nRefixRate += 100;
			INT nValue = 0;
			switch (nIdx)
			{
				//Attacks
				case CharIntAttrRefixs_T::REFIX_ATTACK_NEAR:
					{
						if(0!=GetAttackNearRefix(rImp))
						{
							nValue = Float2Int((GetAttackNearRefix(rImp)*nRefixRate)/100.0f);
							rIntAttrRefix += nValue;
							return TRUE;
						}
					}
					break;
				case CharIntAttrRefixs_T::REFIX_ATTACK_FAR:
					{
						if(0!=GetAttackFarRefix(rImp))
						{
							nValue = Float2Int((GetAttackFarRefix(rImp)*nRefixRate)/100.0f);
							rIntAttrRefix += nValue;
							return TRUE;
						}
					}
					break;
				case CharIntAttrRefixs_T::REFIX_ATTACK_MAGIC_NEAR:
					{
						if(0!=GetAttackMagicNearRefix(rImp))
						{
							nValue = Float2Int((GetAttackMagicNearRefix(rImp)*nRefixRate)/100.0f);
							rIntAttrRefix += nValue;
							return TRUE;
						}
					}
					break;
				case CharIntAttrRefixs_T::REFIX_ATTACK_MAGIC_FAR:
					{
						if(0!=GetAttackMagicFarRefix(rImp))
						{
							nValue = Float2Int((GetAttackMagicFarRefix(rImp)*nRefixRate)/100.0f);
							rIntAttrRefix += nValue;
							return TRUE;
						}
					}
					break;
				case CharIntAttrRefixs_T::REFIX_ATTACK_GOLD:
					{
						if(0!=GetAttackGoldRefix(rImp))
						{
							nValue = Float2Int((GetAttackGoldRefix(rImp)*nRefixRate)/100.0f);
							rIntAttrRefix += nValue;
							return TRUE;
						}
					}
					break;
				case CharIntAttrRefixs_T::REFIX_ATTACK_WOOD:
					{
						if(0!=GetAttackWoodRefix(rImp))
						{
							nValue = Float2Int((GetAttackWoodRefix(rImp)*nRefixRate)/100.0f);
							rIntAttrRefix += nValue;
							return TRUE;
						}
					}
					break;

				case CharIntAttrRefixs_T::REFIX_ATTACK_WATER:
					{
						if(0!=GetAttackWaterRefix(rImp))
						{
							nValue = Float2Int((GetAttackWaterRefix(rImp)*nRefixRate)/100.0f);
							rIntAttrRefix += nValue;
							return TRUE;
						}
					}
					break;

				case CharIntAttrRefixs_T::REFIX_ATTACK_SOIL:
					{
						if(0!=GetAttackSoilRefix(rImp))
						{
							nValue = Float2Int((GetAttackSoilRefix(rImp)*nRefixRate)/100.0f);
							rIntAttrRefix += nValue;
							return TRUE;
						}
					}
					break;

				case CharIntAttrRefixs_T::REFIX_ATTACK_FIRE:
					{
						if(0!=GetAttackFireRefix(rImp))
						{
							nValue = Float2Int((GetAttackFireRefix(rImp)*nRefixRate)/100.0f);
							rIntAttrRefix += nValue;
							return TRUE;
						}
					}
					break;

				//Defences
				case CharIntAttrRefixs_T::REFIX_DEFENCE_NEAR:
					{
						if(0!=GetDefenceNearRefix(rImp))
						{
							nValue = Float2Int((GetDefenceNearRefix(rImp)*nRefixRate)/100.0f);
							rIntAttrRefix += nValue;
							return TRUE;
						}
					}
					break;
				case CharIntAttrRefixs_T::REFIX_DEFENCE_FAR:
					{
						if(0!=GetDefenceFarRefix(rImp))
						{
							nValue = Float2Int((GetDefenceFarRefix(rImp)*nRefixRate)/100.0f);
							rIntAttrRefix += nValue;
							return TRUE;
						}
					}
					break;
				case CharIntAttrRefixs_T::REFIX_DEFENCE_MAGIC_NEAR:
					{
						if(0!=GetDefenceMagicNearRefix(rImp))
						{
							nValue = Float2Int((GetDefenceMagicNearRefix(rImp)*nRefixRate)/100.0f);
							rIntAttrRefix += nValue;
							return TRUE;
						}
					}
					break;
				case CharIntAttrRefixs_T::REFIX_DEFENCE_MAGIC_FAR:
					{
						if(0!=GetDefenceMagicFarRefix(rImp))
						{
							nValue = Float2Int((GetDefenceMagicFarRefix(rImp)*nRefixRate)/100.0f);
							rIntAttrRefix += nValue;
							return TRUE;
						}
					}
					break;
				case CharIntAttrRefixs_T::REFIX_RESIST_GOLD:
					{
						if(0!=GetResistGoldRefix(rImp))
						{
							nValue = Float2Int((GetResistGoldRefix(rImp)*nRefixRate)/100.0f);
							rIntAttrRefix += nValue;
							return TRUE;
						}
					}
					break;
				case CharIntAttrRefixs_T::REFIX_RESIST_WOOD:
					{
						if(0!=GetResistWoodRefix(rImp))
						{
							nValue = Float2Int((GetResistWoodRefix(rImp)*nRefixRate)/100.0f);
							rIntAttrRefix += nValue;
							return TRUE;
						}
					}
					break;

				case CharIntAttrRefixs_T::REFIX_RESIST_WATER:
					{
						if(0!=GetResistWaterRefix(rImp))
						{
							nValue = Float2Int((GetResistWaterRefix(rImp)*nRefixRate)/100.0f);
							rIntAttrRefix += nValue;
							return TRUE;
						}
					}
					break;

				case CharIntAttrRefixs_T::REFIX_RESIST_FIRE:
					{
						if(0!=GetResistFireRefix(rImp))
						{
							nValue = Float2Int((GetResistFireRefix(rImp)*nRefixRate)/100.0f);
							rIntAttrRefix += nValue;
							return TRUE;
						}
					}
					break;

				case CharIntAttrRefixs_T::REFIX_RESIST_SOIL:
					{
						if(0!=GetResistSoilRefix(rImp))
						{
							nValue = Float2Int((GetResistSoilRefix(rImp)*nRefixRate)/100.0f);
							rIntAttrRefix += nValue;
							return TRUE;
						}
					}
					break;

				default:
					break;
			}
			__LEAVE_FUNCTION
			return FALSE;
		}
Exemplo n.º 24
0
tuint32 CDeviceWaveIO::GetSampleRate()
{
	return Float2Int(mfSampleRate);
}
Exemplo n.º 25
0
tuint32 CDeviceCoreAudio::GetSampleRate()
{
	return Float2Int(mfSampleRate);
}
Exemplo n.º 26
0
        BOOL StdImpact012_T::GetIntAttrRefix(OWN_IMPACT & rImp, Obj_Character& rMe, CharIntAttrRefixs_T::Index_T nIdx, INT & rIntAttrRefix) const
        {
            __ENTER_FUNCTION
            INT nRefixRate = GetRefixRate(rImp);
            nRefixRate += 100;
            INT nValue = 0;
            switch (nIdx)
            {
                //Attacks
                case CharIntAttrRefixs_T::REFIX_ATTACK_PHY:
                    {
                        if(0!=GetAttackPhysicsRefix(rImp))
                        {
                            nValue = Float2Int((GetAttackPhysicsRefix(rImp)*nRefixRate)/100.0f);
                            nValue = Float2Int((rMe.GetBaseAttackPhysics()*nValue)/100.0f);
                            rIntAttrRefix += nValue;
                            return TRUE;
                        }
                    }
                    break;
                case CharIntAttrRefixs_T::REFIX_ATTACK_MAGIC:
                    {
                        if(0!=GetAttackMagicRefix(rImp))
                        {
                            nValue = Float2Int((GetAttackMagicRefix(rImp)*nRefixRate)/100.0f);
                            nValue = Float2Int((rMe.GetBaseAttackMagic()*nValue)/100.0f);
                            rIntAttrRefix += nValue;
                            return TRUE;
                        }
                    }
                    break;
                case CharIntAttrRefixs_T::REFIX_ATTACK_COLD:
                    {
                        if(0!=GetAttackColdRefix(rImp))
                        {
                            nValue = Float2Int((GetAttackColdRefix(rImp)*nRefixRate)/100.0f);
                            nValue = Float2Int((rMe.GetBaseAttackCold()*nValue)/100.0f);
                            rIntAttrRefix += nValue;
                            return TRUE;
                        }
                    }
                    break;
                case CharIntAttrRefixs_T::REFIX_ATTACK_FIRE:
                    {
                        if(0!=GetAttackFireRefix(rImp))
                        {
                            nValue = Float2Int((GetAttackFireRefix(rImp)*nRefixRate)/100.0f);
                            nValue = Float2Int((rMe.GetBaseAttackFire()*nValue)/100.0f);
                            rIntAttrRefix += nValue;
                            return TRUE;
                        }
                    }
                    break;
                case CharIntAttrRefixs_T::REFIX_ATTACK_LIGHT:
                    {
                        if(0!=GetAttackLightRefix(rImp))
                        {
                            nValue = Float2Int((GetAttackLightRefix(rImp)*nRefixRate)/100.0f);
                            nValue = Float2Int((rMe.GetBaseAttackLight()*nValue)/100.0f);
                            rIntAttrRefix += nValue;
                            return TRUE;
                        }
                    }
                    break;
                case CharIntAttrRefixs_T::REFIX_ATTACK_POISON:
                    {
                        if(0!=GetAttackPoisonRefix(rImp))
                        {
                            nValue = Float2Int((GetAttackPoisonRefix(rImp)*nRefixRate)/100.0f);
                            nValue = Float2Int((rMe.GetBaseAttackPoison()*nValue)/100.0f);
                            rIntAttrRefix += nValue;
                            return TRUE;
                        }
                    }
                    break;

                //Defences
                case CharIntAttrRefixs_T::REFIX_DEFENCE_PHY:
                    {
                        if(0!=GetDefencePhysicsRefix(rImp))
                        {
                            nValue = Float2Int((GetDefencePhysicsRefix(rImp)*nRefixRate)/100.0f);
                            nValue = Float2Int((rMe.GetBaseDefencePhysics()*nValue)/100.0f);
                            rIntAttrRefix += nValue;
                            return TRUE;
                        }
                    }
                    break;
                case CharIntAttrRefixs_T::REFIX_DEFENCE_MAGIC:
                    {
                        if(0!=GetDefenceMagicRefix(rImp))
                        {
                            nValue = Float2Int((GetDefenceMagicRefix(rImp)*nRefixRate)/100.0f);
                            nValue = Float2Int((rMe.GetBaseDefenceMagic()*nValue)/100.0f);
                            rIntAttrRefix += nValue;
                            return TRUE;
                        }
                    }
                    break;
                case CharIntAttrRefixs_T::REFIX_RESIST_COLD:
                    {
                        if(0!=GetResistColdRefix(rImp))
                        {
                            nValue = Float2Int((GetResistColdRefix(rImp)*nRefixRate)/100.0f);
                            nValue = Float2Int((rMe.GetBaseDefenceCold()*nValue)/100.0f);
                            rIntAttrRefix += nValue;
                            return TRUE;
                        }
                    }
                    break;
                case CharIntAttrRefixs_T::REFIX_RESIST_FIRE:
                    {
                        if(0!=GetResistFireRefix(rImp))
                        {
                            nValue = Float2Int((GetResistFireRefix(rImp)*nRefixRate)/100.0f);
                            nValue = Float2Int((rMe.GetBaseDefenceFire()*nValue)/100.0f);
                            rIntAttrRefix += nValue;
                            return TRUE;
                        }
                    }
                    break;
                case CharIntAttrRefixs_T::REFIX_RESIST_LIGHT:
                    {
                        if(0!=GetResistLightRefix(rImp))
                        {
                            nValue = Float2Int((GetResistLightRefix(rImp)*nRefixRate)/100.0f);
                            nValue = Float2Int((rMe.GetBaseDefenceLight()*nValue)/100.0f);
                            rIntAttrRefix += nValue;
                            return TRUE;
                        }
                    }
                    break;
                case CharIntAttrRefixs_T::REFIX_RESIST_POISON:
                    {
                        if(0!=GetResistPoisonRefix(rImp))
                        {
                            nValue = Float2Int((GetResistPoisonRefix(rImp)*nRefixRate)/100.0f);
                            nValue = Float2Int((rMe.GetBaseDefencePoison()*nValue)/100.0f);
                            rIntAttrRefix += nValue;
                            return TRUE;
                        }
                    }
                    break;

                // Maxes
                case CharIntAttrRefixs_T::REFIX_MAX_HP:
                    {
                        if(0!=GetMaxHpRefix(rImp))
                        {
                            nValue = Float2Int((GetMaxHpRefix(rImp)*nRefixRate)/100.0f);
                            nValue = Float2Int((rMe.GetBaseMaxHP()*nValue)/100.0f);
                            rIntAttrRefix += nValue;
                            return TRUE;
                        }
                    }
                    break;
                case CharIntAttrRefixs_T::REFIX_MAX_MP:
                    {
                        if(0!=GetMaxMpRefix(rImp))
                        {
                            nValue = Float2Int((GetMaxMpRefix(rImp)*nRefixRate)/100.0f);
                            nValue = Float2Int((rMe.GetBaseMaxMP()*nValue)/100.0f);
                            rIntAttrRefix += nValue;
                            return TRUE;
                        }
                    }
                    break;
                case CharIntAttrRefixs_T::REFIX_MAX_RAGE:
                    {
                        if(0!=GetMaxRageRefix(rImp))
                        {
                            nValue = Float2Int((GetMaxRageRefix(rImp)*nRefixRate)/100.0f);
                            nValue = Float2Int((rMe.GetBaseMaxRage()*nValue)/100.0f);
                            rIntAttrRefix += nValue;
                            return TRUE;
                        }
                    }
                    break;
                case CharIntAttrRefixs_T::REFIX_MAX_STRIKE_POINT:
                    {
                        if(0!=GetMaxStrikePointRefix(rImp))
                        {
                            nValue = Float2Int((GetMaxStrikePointRefix(rImp)*nRefixRate)/100.0f);
                            nValue = Float2Int((rMe.GetBaseMaxStrikePoint()*nValue)/100.0f);
                            rIntAttrRefix += nValue;
                            return TRUE;
                        }
                    }
                    break;
                
                default:
                    break;
            }
            __LEAVE_FUNCTION
            return FALSE;
        }
Exemplo n.º 27
0
 BOOL StdImpact056_T::GetIntAttrRefix(OWN_IMPACT & rImp, Obj_Character& rMe, CharIntAttrRefixs_T::Index_T nIdx, INT & rIntAttrRefix) const
 {
     __ENTER_FUNCTION
     INT nRefixRate = GetRefixRate(rImp);
     nRefixRate += 100;
     INT nValue = 0;
     switch (nIdx)
     {
         case CharIntAttrRefixs_T::REFIX_HIT:
             {
                 if(0!=GetHitRefix(rImp))
                 {
                     nValue = Float2Int((GetHitRefix(rImp)*nRefixRate)/100.0f);
                     rIntAttrRefix += nValue;
                     return TRUE;
                 }
             }
             break;
         case CharIntAttrRefixs_T::REFIX_MISS:
             {
                 if(0!=GetMissRefix(rImp))
                 {
                     nValue = Float2Int((GetMissRefix(rImp)*nRefixRate)/100.0f);
                     rIntAttrRefix += nValue;
                     return TRUE;
                 }
             }
             break;
         case CharIntAttrRefixs_T::REFIX_CRITICAL:
             {
                 if(0!=GetCriticalRefix(rImp))
                 {
                     nValue = Float2Int((GetCriticalRefix(rImp)*nRefixRate)/100.0f);
                     rIntAttrRefix += nValue;
                     return TRUE;
                 }
             }
             break;                
         //Attacks
         case CharIntAttrRefixs_T::REFIX_ATTACK_PHY:
             {
                 if(0!=GetAttackPhysicsRefix(rImp))
                 {
                     nValue = Float2Int((GetAttackPhysicsRefix(rImp)*nRefixRate)/100.0f);
                     nValue = Float2Int((rMe.GetBaseAttackPhysics()*nValue)/100.0f);
                     rIntAttrRefix += nValue;
                     return TRUE;
                 }
             }
             break;
         case CharIntAttrRefixs_T::REFIX_ATTACK_MAGIC:
             {
                 if(0!=GetAttackMagicRefix(rImp))
                 {
                     nValue = Float2Int((GetAttackMagicRefix(rImp)*nRefixRate)/100.0f);
                     nValue = Float2Int((rMe.GetBaseAttackMagic()*nValue)/100.0f);
                     rIntAttrRefix += nValue;
                     return TRUE;
                 }
             }
             break;
         //Defences
         case CharIntAttrRefixs_T::REFIX_DEFENCE_PHY:
             {
                 if(0!=GetDefencePhysicsRefix(rImp))
                 {
                     nValue = Float2Int((GetDefencePhysicsRefix(rImp)*nRefixRate)/100.0f);
                     nValue = Float2Int((rMe.GetBaseDefencePhysics()*nValue)/100.0f);
                     rIntAttrRefix += nValue;
                     return TRUE;
                 }
             }
             break;
         case CharIntAttrRefixs_T::REFIX_DEFENCE_MAGIC:
             {
                 if(0!=GetDefenceMagicRefix(rImp))
                 {
                     nValue = Float2Int((GetDefenceMagicRefix(rImp)*nRefixRate)/100.0f);
                     nValue = Float2Int((rMe.GetBaseDefenceMagic()*nValue)/100.0f);
                     rIntAttrRefix += nValue;
                     return TRUE;
                 }
             }
             break;
         // Maxes
         case CharIntAttrRefixs_T::REFIX_MAX_HP:
             {
                 if(0!=GetMaxHpRefix(rImp))
                 {
                     nValue = Float2Int((GetMaxHpRefix(rImp)*nRefixRate)/100.0f);
                     nValue = Float2Int((rMe.GetBaseMaxHP()*nValue)/100.0f);
                     rIntAttrRefix += nValue;
                     return TRUE;
                 }
             }
             break;
         default:
             break;
     }
     __LEAVE_FUNCTION
     return FALSE;
 }
Exemplo n.º 28
0
void CRegion_GUI::OnDraw(const ge::SRect &rUpdate)
{
    if (mppfPeak[0] == NULL) {
        tint32 iChannel;
        for (iChannel = 0; iChannel < 2; iChannel++) {
            tint32 iPeakFile;
            for (iPeakFile = 0; iPeakFile < 2; iPeakFile++) {
                gpDSPEngine->GetRegionPeakFile(muiRegionID, &(mppPeakFile[iPeakFile + iChannel * 2]), iChannel, iPeakFile);

                if (mppPeakFile[iPeakFile + iChannel * 2] == NULL) {
                    mpiPeakFileSize[iPeakFile + iChannel * 2] = 0;
                    mppfPeak[iPeakFile + iChannel * 2] = NULL;
                }
                else {
                    mpiPeakFileSize[iPeakFile + iChannel * 2] = mppPeakFile[iPeakFile + iChannel * 2]->GetSizeWhenOpened();
                    mppfPeak[iPeakFile + iChannel * 2] = new tfloat32[(tint32)(mpiPeakFileSize[iPeakFile + iChannel * 2] / sizeof(tfloat32))];
                    mppPeakFile[iPeakFile + iChannel * 2]->Seek(0);
                    tint64 iWantsToRead = mpiPeakFileSize[iPeakFile + iChannel * 2];
                    tint64 iActuallyRead = mppPeakFile[iPeakFile + iChannel * 2]->Read((tchar*)mppfPeak[iPeakFile + iChannel * 2], iWantsToRead);
                    maiActuallyRead[iPeakFile + iChannel * 2] = iActuallyRead;
                }
            }
        }
    }
    tbool bDraw_Waveform	= mpKSPlugIn->GetGlobalParm(giParamID_Show_Waveform, giSectionGUI);
    if(bDraw_Waveform) {

        tint32 iChannels = 1;
        if (mppPeakFile[2] != NULL) {
            iChannels = 2;
        }

        ge::SPos PosThis;
        mpControl->GetPos(PosThis);

        ge::SSize SizeThis;
        mpControl->GetSize(SizeThis);


        tuint64 uiPixelOffset	=	Float2Int(mfSample_Start * mpKSPlugIn->GetPixelPrSample());

        tfloat64 fSamplesPerPixel	= mpKSPlugIn->GetSamplesPrPixel();

        tint32 iDrawStartX = 0;
        //if (iDrawStartX < 0) {
        if (PosThis.iX < 0) {
            iDrawStartX = -PosThis.iX;
        }
        tint32 iDrawEndX = SizeThis.iCX;
        if (iDrawEndX > rUpdate.iX + rUpdate.iCX - PosThis.iX) {
            iDrawEndX = rUpdate.iX + rUpdate.iCX - PosThis.iX;
        }

        const tint32 iSpaceMid = 5;

        if (iChannels == 1) {
            tfloat32* pfPeak = mppfPeak[0];
            tint32 iPeakSize = 1024;
            if (fSamplesPerPixel <= 512) {
                pfPeak = mppfPeak[1];
                iPeakSize = 64;
            }

            // (lasse) Crash-fix
            if (pfPeak == NULL) {
                // Don't attempt draw if peak file is missing
                iDrawEndX = iDrawStartX;
            }

            tint32 iPixel;
            for (iPixel = iDrawStartX; iPixel < iDrawEndX; iPixel++) {
                tfloat32 fPeakIndex = (tfloat32)((uiPixelOffset+iPixel) * fSamplesPerPixel);
                fPeakIndex /= iPeakSize;

                // Linear interpolate
                tint32 iPeakLow = (tint32)fPeakIndex;
                tint32 iPeakHigh = iPeakLow + 1;
                tfloat32 fAlpha = fPeakIndex - iPeakLow;
                tfloat32 fPeak = pfPeak[iPeakLow] * (1 - fAlpha) + pfPeak[iPeakHigh] * fAlpha;

                tint32 iPeak = (tint32)(fPeak * SizeThis.iCY / 2);

                mpDrawPrimitives->DrawLine(rUpdate,
                                           PosThis + ge::SPos(iPixel, SizeThis.iCY / 2 + iPeak),
                                           PosThis + ge::SPos(iPixel, SizeThis.iCY / 2 - iPeak),
                                           ge::SRGB(84, 84, 84));
            }
        }
        else {
            tfloat32* pfPeakL;
            tfloat32* pfPeakR;
            tint32 iPeakSize;
            if (fSamplesPerPixel <= 512) {
                pfPeakL = mppfPeak[1];
                pfPeakR = mppfPeak[3];
                iPeakSize = 64;

                // (Lasse) crash-fix: Don't read longer than there's peakfile
                if (iDrawEndX > maiActuallyRead[1])
                    iDrawEndX = maiActuallyRead[1];
                if (iDrawEndX > maiActuallyRead[3])
                    iDrawEndX = maiActuallyRead[3];
            }
            else {
                pfPeakL = mppfPeak[0];
                pfPeakR = mppfPeak[2];
                iPeakSize = 1024;

                // (Lasse) crash-fix: Don't read longer than there's peakfile
                if (iDrawEndX > maiActuallyRead[0])
                    iDrawEndX = maiActuallyRead[0];
                if (iDrawEndX > maiActuallyRead[2])
                    iDrawEndX = maiActuallyRead[2];
            }


            tint32 iPixel;
            for (iPixel = iDrawStartX; iPixel < iDrawEndX; iPixel++) {
                tfloat32 fPeakIndex = (tfloat32)((uiPixelOffset+iPixel) * fSamplesPerPixel);
                fPeakIndex /= iPeakSize;

                // Linear interpolate
                tint32 iPeakLow = (tint32)fPeakIndex;
                tint32 iPeakHigh = iPeakLow + 1;
                tfloat32 fAlpha = fPeakIndex - iPeakLow;
                tfloat32 fPeak = pfPeakL[iPeakLow] * (1 - fAlpha) + pfPeakL[iPeakHigh] * fAlpha;

                tint32 iPeakL = (tint32)(fPeak * (SizeThis.iCY - iSpaceMid) / 4);

                // Linear interpolate
                fPeak = pfPeakR[iPeakLow] * (1 - fAlpha) + pfPeakR[iPeakHigh] * fAlpha;

                tint32 iPeakR = (tint32)(fPeak * (SizeThis.iCY - iSpaceMid) / 4);

                mpDrawPrimitives->DrawLine(rUpdate,
                                           PosThis + ge::SPos(iPixel, (SizeThis.iCY - iSpaceMid) / 4 + iPeakL),
                                           PosThis + ge::SPos(iPixel, (SizeThis.iCY - iSpaceMid) / 4 - iPeakL),
                                           ge::SRGB(84, 84, 84));

                mpDrawPrimitives->DrawLine(rUpdate,
                                           PosThis + ge::SPos(iPixel, SizeThis.iCY - (SizeThis.iCY - iSpaceMid) / 4 + iPeakR),
                                           PosThis + ge::SPos(iPixel, SizeThis.iCY - (SizeThis.iCY - iSpaceMid) / 4 - iPeakR),
                                           ge::SRGB(84, 84, 84));
            }
        }
    }
}
Exemplo n.º 29
0
tbool CExportDSPTask::DoWork()
{
	tbool bError = false;

	switch (miActionOrder) {
		case geExportDSP_Start:
			{
				if (miChannels < 1) {
					// The Channels drop-down was left at "unchanged"
					// This always means stereo for DSP exports,
					// since all channels are processed stereo
					miChannels = 2;
				}

				// Save position
				muiPosSaved = gpApplication->GetSongPos();

				// Find end position + tail
				tint32 iTailFrames = Float2Int((miTailMS * gpApplication->GetSampleRate()) / 1000.0f);
				tint64 iLastSample = miFinalSample;
				if (iLastSample < 0) {
					if (IsOutMix()) {
						iLastSample = gpDSPEngine->Get_Session_End_Sample();
					}
					else {
						tint64 iFirstSample_Ignored;
						if (!gpDSPEngine->CalcTrackDuration(miTrack, &iFirstSample_Ignored, &iLastSample)) {
							// Fal back to full length
							iLastSample = gpDSPEngine->Get_Session_End_Sample();
						}
					}
				}
				muiEndPosPlusTail = iLastSample + iTailFrames;

				muiProgressTarget = 0;

				if (mfNormalizationFactor != 0.0f) {
					// We have a predefined normalization factor - don't do peak search
					miActionOrder = geExportDSP_Peak_After;
					miActionOrder++;
				}
				else {
					// Go to next task (peak search)
					miActionOrder++;
				}
			}
			break;

		case geExportDSP_Peak_Before:
			{
				gpApplication->Playback_InProgressTask(miFirstSample);
				if (IsOutMix())
					gpApplication->Playback_ExportOutMix(miFirstSample);
				else
					gpApplication->Playback_ExportTrack(miTrack, miFirstSample, miFinalSample);

				msProgress = "Peak search '";
				msProgress += msTrackName;

				msProgress += "'";
				muiProgressIx = 0;
				muiProgressTarget = muiEndPosPlusTail - miFirstSample;

				AllocBuffers(kiPeakPortionSize);

				mfPeak = 0.001f;
				muiPortionSize = kiPeakPortionSize;
				uiWholePortions = (muiEndPosPlusTail - miFirstSample) / kiPeakPortionSize;
				uiLastPortionSize = muiEndPosPlusTail % kiPeakPortionSize;

				if (!mbSkipFileOutput) {
					// Prepare for intermediate buffer file
					msIntermediateFiles[0] = sDestFolder + sDestNameAndExt + ".raw0";
					msIntermediateFiles[1] = sDestFolder + sDestNameAndExt + ".raw1";
					mpfIntermediateFiles[0] = IFile::Create();
					mpfIntermediateFiles[1] = IFile::Create();
					if ((mpfIntermediateFiles[0] == NULL) || (mpfIntermediateFiles[1] == NULL)) {
						msIntermediateFiles[0] = "";
						msIntermediateFiles[1] = "";
					}
					else {
						if (
							(!mpfIntermediateFiles[0]->Open(msIntermediateFiles[0].c_str(), IFile::FileCreate))
							||
							(!mpfIntermediateFiles[1]->Open(msIntermediateFiles[1].c_str(), IFile::FileCreate))
							)
						{
							msIntermediateFiles[0] = "";
							msIntermediateFiles[1] = "";
							mpfIntermediateFiles[0]->Destroy();
							mpfIntermediateFiles[0] = NULL;
							mpfIntermediateFiles[1]->Destroy();
							mpfIntermediateFiles[1] = NULL;
						}
						else if ((miFirstSample > 0) && (!mbRemoveInitialSilence)) {
							// Dump silence into file
							const tint32 kiChunkSamples = 1024;
							tint64 iSilentChunks = (miFirstSample / kiChunkSamples);
							tint64 iAfterChunks_Samples = miFirstSample - (iSilentChunks * kiChunkSamples);

							// Initialize a memory portion with silence
							tfloat32 afSilentChunk[kiChunkSamples];
							tchar* pacSilentChunk = (tchar*)afSilentChunk;
							memset(pacSilentChunk, '\0', kiChunkSamples * sizeof(tfloat32));

							// Write whole chunks
							for ( ;iSilentChunks > 0; iSilentChunks--) {
								// Since these are temporary files we ignore MSB / LSB questions
								mpfIntermediateFiles[0]->Write(pacSilentChunk, kiChunkSamples * sizeof(tfloat32));
								mpfIntermediateFiles[1]->Write(pacSilentChunk, kiChunkSamples * sizeof(tfloat32));
							}
							// Write extra samples after whole chunks
							if (iAfterChunks_Samples > 0) {
								// Since these are temporary files we ignore MSB / LSB questions
								mpfIntermediateFiles[0]->Write(pacSilentChunk, iAfterChunks_Samples * sizeof(tfloat32));
								mpfIntermediateFiles[1]->Write(pacSilentChunk, iAfterChunks_Samples * sizeof(tfloat32));
							}
						}
					}
				}

				miActionOrder++;
			}
			break;

		case geExportDSP_Peak_Action:
			{
				bError = !DoEncode_InALoop(false);
			}
			break;

		case geExportDSP_Peak_After:
			{
				msProgress = "Peak search done";
				muiProgressIx = muiProgressTarget = 1;

				mfNormalizationFactor = 1.0f;
				mfNormalizationFactor /= mfPeak;

				if (mpfIntermediateFiles[0]) {
					mpfIntermediateFiles[0]->Close();
				}
				if (mpfIntermediateFiles[1]) {
					mpfIntermediateFiles[1]->Close();
				}

				if (mbSkipFileOutput) {
					miActionOrder = geExportDSP_After;
				}
				miActionOrder++;
			}
			break;

		case geExportDSP_Before:
			{
				if (mbSkipFileOutput) {
					// Skip encoding
					gpApplication->Playback_InProgressTask(muiPosSaved);
					msProgress = "";
					muiProgressIx = muiProgressTarget = 0;

					miActionOrder = geExportDSP_After;
					miActionOrder++;
				}
				else {
					// Prepare for encoding
					tint64 iPosToStart = (mbRemoveInitialSilence) ? miFirstSample : 0;
					if (msIntermediateFiles[0].length()) {
						// Load from intermediate files
						mpfIntermediateFiles[0]->Open(msIntermediateFiles[0].c_str(), IFile::FileRead);
						mpfIntermediateFiles[1]->Open(msIntermediateFiles[1].c_str(), IFile::FileRead);
					}
					else {
						if (IsOutMix())
							gpApplication->Playback_ExportOutMix(iPosToStart);
						else
							gpApplication->Playback_ExportTrack(miTrack, iPosToStart, miFinalSample);
					}

					msProgress = "Exporting '";
					msProgress += sDestNameAndExt;

					msProgress += "'";
					muiProgressIx = 0;
					muiProgressTarget = (muiEndPosPlusTail - iPosToStart);

					AllocBuffers(miPortionSize);

					muiPortionSize = miPortionSize;
					uiWholePortions = (muiEndPosPlusTail - iPosToStart) / miPortionSize;
					uiLastPortionSize = muiEndPosPlusTail % miPortionSize;

					miActionOrder++;
				}
			}
			break;

		case geExportDSP_Action:
			{
				if (mpfOutput == NULL) {
					bError = !DoEncode_FirstTimeHere();
				}

				if (!bError) {
					bError = !DoEncode_InALoop(true);
				}
			}
			break;

		case geExportDSP_After:
			{
				gpApplication->Playback_InProgressTask(muiPosSaved);
				msProgress = "Export done";
				muiProgressIx = muiProgressTarget = 1;

				miActionOrder++;
			}
			break;

		default:
			// Why are we here?
			bError = true;
			break;

	}

	if (bError) {
		miActionOrder = geExportDSP_Done;
	}
	return !bError;
} // DoWork
Exemplo n.º 30
0
	// GridAccel Private Methods
	int PosToVoxel(const Point &P, int axis) const {
		int v = Float2Int((P[axis] - bounds.pMin[axis]) *
		                  InvWidth[axis]);
		return Clamp(v, 0, NVoxels[axis]-1);
	}