float AHAI::predictPositionX(float Y) { double dX; CLine cLine(pPuckPosition.x, pPuckPosition.y, pPuckPosition.x + vPuckVelocity.x, pPuckPosition.y + vPuckVelocity.y); if(!cLine.can_calculate_x()) return pMyPosition.x; dX = cLine.x(Y); // check for bounce int iBounces = 0; while(dX < -(AH_TABLE_WIDTH / 2)) { ++iBounces; dX += AH_TABLE_WIDTH; } while(dX > (AH_TABLE_WIDTH / 2)) { ++iBounces; dX -= AH_TABLE_WIDTH; } // check if the number of bounces is odd if(iBounces % 2 == 1) dX = -dX; return (float)dX; }
void MCMIDIReceiver::message(unsigned char Byte0, unsigned char Byte1, unsigned char Byte2) { unsigned char iMIDIChannel = Byte0 & 0x0F; Byte0 = Byte0 & 0xF0; if(!bMIDIChannel[iMIDIChannel]) return; // NOTE ON if(Byte0 == 0x90) { unsigned char iPitch = Byte1; if(iPitch < iMinPitch || iPitch > iMaxPitch) return; unsigned char iVelocity = Byte2; // note on with velocity 0 --> note off if(iVelocity == 0) { mInstrument->release(iAttachedChannel[iPitch - iMinPitch]); return; } mNote.Pitch = iPitch; mNote.Channel = iAttachedChannel[iPitch - iMinPitch]; mNote.Intensity = iVelocity; mNote.Mode = iMode; mNote.Duration = 0; mInstrument->playNote(mNote); } // NOTE OFF else if(Byte0 == 0x80) { unsigned char iPitch = Byte1; mInstrument->release(iAttachedChannel[iPitch - iMinPitch]); } // CONTROL else if(Byte0 == 0xB0) { // damper if(Byte1 == 0x40) mInstrument->setDamper(Byte2 >= 64); } // PITCH WHEEL else if(Byte0 == 0xE0) { unsigned int iCents = 0; CLine cLine(0, -200, 16383, 200); if(cLine.can_calculate_y()) iCents = (unsigned int)cLine.y(Byte1 + (Byte2 << 7)); for(unsigned int i = 0; i < mInstrument->getNumberOfChannels(); i++) mInstrument->bend(i, iCents); } }
cLine cGraphicsMFC::pixelToSightLine(int xpix, int ypix) { /* This is a line that runs from the viewer's eye to the direction matching the pixel point. */ cVector planepoint = pixelToVector(xpix, ypix, 0.0); return cLine(planepoint, -cVector::ZAXIS); //Second arg should be a unit vector. }