void Instrument::Compute(float dt, int & iLeft, int & iRight) { fTime += dt; if ( fTime > 1.0f / 60.0f ) { fTime -= 1.0f/60.0f; int iVolume = pParameters->iVolume; if ( pParameters->Tremolo.iAmplitude != 0 ) { int iSin = Sinus(iEffectTimer * 12868 * pParameters->Tremolo.iFrequency / 256) / 2 + 2048; int iAmplitude = pParameters->Tremolo.iAmplitude * pParameters->iVolume / 255; iVolume -= iSin * iAmplitude / 4096; } iLastEnvelope = oEnvelope.Compute(pParameters) * iVolume / 127; if ( pParameters->iArpeggio > 0 ) { iArpeggioTimer++; if ( iArpeggioTimer >= pParameters->iArpeggio ) { iArpeggioTimer = 0; iFrequency++; if ( iFrequency >= iNbFrequencies ) iFrequency = 0; } } iEffectTimer++; int iSweep = 0; if ( pParameters->Sweep.iLength != 0 && iEffectTimer < pParameters->Sweep.iLength ) iSweep = iSweepFrequency - (iEffectTimer * iSweepFrequency) / pParameters->Sweep.iLength; int iModulation = Sinus(iEffectTimer * 12868 * pParameters->Modulation.iFrequency / 256) * iModulationAmplitude / 4096; int iPortamento = 0; if ( pParameters->iPortamentoLength != 0 && iEffectTimer < pParameters->iPortamentoLength ) iPortamento = iPortamentoFrequency - (iEffectTimer * iPortamentoFrequency) / pParameters->iPortamentoLength; iLastFrequency = pFrequencies[iFrequency] + iSweep + iModulation + iPortamento; } pSoundGenerator->SetDuty(pParameters->iDuty); pSoundGenerator->SetFrequency(iLastFrequency); signed short iSample = pSoundGenerator->Compute(dt); iSample = iSample * iLastEnvelope / 128; iRight += iSample * pParameters->iPanning / 128; iLeft += iSample * (128 - pParameters->iPanning) / 128; }
//---------------------------------------------------------------------------- void Dest::EntfRichtung(double B1,double L1,double B2,double L2) { float re, degr; float fl; float s1,s2,s3,s4,br1,br2,l,e1,e2,zw,az,distanz,richtung,diff; #define PI 3.14159265358979 re = 6378.14; degr = 180/PI; fl = 1/298.257; br1 = (B1+B2)/2.0; br2 = (B1-B2)/2.0; l = (L1-L2)/2.0; e1 = fsqr(Sinus(br2))*fsqr(Cosinus(l))+fsqr(Cosinus(br1))*fsqr(Sinus(l)); e2 = fsqr(Cosinus(br2))*fsqr(Cosinus(l))+fsqr(Sinus(br1))*fsqr(Sinus(l)); zw = atan(sqrt(e1/e2)); s1 = sqrt(e1*e2)/zw; s2 = 2*zw*re; s3 = (3*s1-1)/(2*e2); s4 = (3*s1+1)/(2*e1); //Entfernung distanz = s2*(1+fl*s3*fsqr(Sinus(br1))*fsqr(Cosinus(br2))-fl*s4 * fsqr(Cosinus(br1))*fsqr(Sinus(br2))); Distanz = abs( (int)(distanz + 0.5) ); //Richtung diff = L1-L2; zw = Acs(Cosinus(B1)*Cosinus(diff)*Cosinus(B2)+Sinus(B1)*Sinus(B2)); az = Acs((Sinus(B2)-Sinus(B1)*Cosinus(zw))/(Cosinus(B1)*Sinus(zw))); if(Sinus(diff) < 0) richtung = az; else richtung = 360-az; Richtung = abs( (int)(richtung + 0.5) ); EntfRicht.sprintf("%d Km / %d Grad",Distanz,Richtung); }