Ejemplo n.º 1
0
void Ableton::update()
{
    while(receiver.hasWaitingMessages())
    {
        ofxOscMessage m;
        receiver.getNextMessage(&m);
        
        displayOscMessage(m);
        
        if (m.getAddress() == "/live/device/param") {
            getParameterUpdate(m);
        }
        else if (m.getAddress() == "/live/devicelist") {
            getDeviceList(m);
        }
        else if (m.getAddress() == "/live/device/allparam") {
            getDeviceParameters(m);
        }
        else if (m.getAddress() == "/live/device/range") {
            getDeviceParametersRange(m);
        }
        else if (m.getAddress() == "/live/scenes") {
            getNumScenes(m);
        }
        else if (m.getAddress() == "/live/tracks") {
            getNumTracks(m);
        }
        else {
            displayOscMessage(m);
        }
    }
}
Ejemplo n.º 2
0
//public
Metadata *CdDecoder::getLastMetadata()
{
    for(int i = getNumTracks(); i > 0; --i)
    {
        Metadata *m = getMetadata(i);
        if(m)
            return m;
    }
    return NULL;
}
Ejemplo n.º 3
0
/**
 * @brief Fills an array with the x,y coordinates for each Track.
 * @details This class method is intended to be called by the OpenMOC
 *          Python "plotter" module as a utility to assist in plotting
 *          tracks. Although this method appears to require two arguments,
 *          in reality it only requires on due to SWIG and would be called
 *          from within Python as follows:
 *
 * @code
 *          num_tracks = track_generator.getNumTracks()
 *          coords = track_generator.retrieveTrackCoords(num_tracks*4)
 * @endcode
 *
 * @param coords an array of coords of length 4 times the number of Tracks
 * @param num_tracks the total number of Tracks
 */
void TrackGenerator::retrieveTrackCoords(double* coords, int num_tracks) {

  if (num_tracks != 4*getNumTracks())
    log_printf(ERROR, "Unable to retrieve the Track coordinates since the "
               "TrackGenerator contains %d Tracks with %d coordinates but an "
               "array of length %d was input",
               getNumTracks(), 4*getNumTracks(), num_tracks);

  /* Fill the array of coordinates with the Track start and end points */
  int counter = 0;
  for (int i=0; i < _num_azim; i++) {
    for (int j=0; j < _num_tracks[i]; j++) {
      coords[counter] = _tracks[i][j].getStart()->getX();
      coords[counter+1] = _tracks[i][j].getStart()->getY();
      coords[counter+2] = _tracks[i][j].getEnd()->getX();
      coords[counter+3] = _tracks[i][j].getEnd()->getY();
      counter += 4;
    }
  }

  return;
}
Ejemplo n.º 4
0
int AudioCDReader::getCDDBId()
{
    int checksum = 0;
    const int numTracks = getNumTracks();

    for (int i = 0; i < numTracks; ++i)
        for (int offset = (trackStartSamples.getUnchecked(i) + 88200) / 44100; offset > 0; offset /= 10)
            checksum += offset % 10;

    const int length = (trackStartSamples.getLast() - trackStartSamples.getFirst()) / 44100;

    // CCLLLLTT: checksum, length, tracks
    return ((checksum & 0xff) << 24) | (length << 8) | numTracks;
}
Ejemplo n.º 5
0
Archivo: PlugCD.c Proyecto: AlexBu/pcsx
// gets track 
long getTN(unsigned char* buffer)
{
 int numtracks = getNumTracks();

//SysPrintf("start getTn()\r\n");

 if (-1 == numtracks)
 {
//        SysPrintf("end getTn()\r\n");
         return -1;
 }

 buffer[0]=1;
 buffer[1]=numtracks;

//   printf("getnumtracks %d %d\n", (int)buffer[0], (int)buffer[1]);
//SysPrintf("end getTn()\r\n");
   return 0;
}
Ejemplo n.º 6
0
void TimelineComponent::paintOverChildren (Graphics& g)
{
    const int numTracks = getNumTracks();
    int track = heights.trackAtY (0);
    Rectangle<int> r;

    while (true)
    {
        r.setX (0);
        r.setWidth (mTrackWidth);
        r.setY (heights.trackY (track));
        r.setHeight (heights.get (track));

        if (r.getY() > getHeight() || track >= numTracks)
            break;

        if (! heights.trackIsVisible (track)) {
            ++track;
            continue;
        }

        if (mTrackWidth > 0) {
            g.saveState();
            paintTrackHeader (g, track, r);
            g.restoreState();
        }

#if 0
        r.setX (mTrackWidth);
        r.setWidth (getWidth() - mTrackWidth);
        r.setHeight (r.getHeight() + heights.spacing());

        g.saveState();
        paintTrackLane (g, track, r);
        g.restoreState();
#endif
        ++track;
    }
}
void PlaneState::updateState(const Basic::Component* const actor)
{
   const Simulation::AirVehicle* airVehicle = dynamic_cast<const Simulation::AirVehicle*>(actor);
   setAlive(false);
   if (airVehicle != nullptr && airVehicle->isActive()) {
      setAltitude(airVehicle->getAltitude());
      setAlive(airVehicle->getMode() == Simulation::Player::ACTIVE);
      setHeading(airVehicle->getHeading());
      setPitch(airVehicle->getPitch());
      setRoll(airVehicle->getRoll());
      osg::Vec3d angularVels = airVehicle->getAngularVelocities();
      setRollRate(angularVels.x());
      setPitchRate(angularVels.y());
      setYawRate(angularVels.z());
      setTracking(false);
      setTargetTrack(MAX_TRACKS);  // 0 is a valid target track, use MAX_TRACKS to
                                   // signal "no tgt track"
      setSpeed(airVehicle->getCalibratedAirspeed());
      setNumEngines(airVehicle->getNumberOfEngines());
      setIncomingMissile(false);
      setMissileFired(false);

      // determine if we have a missile to fire
#if 1
      const Simulation::StoresMgr* stores = airVehicle->getStoresManagement();
      if (stores == nullptr || stores->getNextMissile() == nullptr) {
         // either we have no SMS, or we have no more missile
         setMissileFired(true);
      }
      else {
         // we have an sms, and we have a missile available
         // loop through player list and attempt to find out if one of our missiles is active
         // if there is an active missile, then for the time being, we do not have a missile to fire
         const Simulation::Simulation* sim = airVehicle->getSimulation();
         const Basic::PairStream* players = sim->getPlayers();
         bool finished = false;
         for (const Basic::List::Item* item = players->getFirstItem(); item != nullptr && !finished; item = item->getNext()) {
            // Get the pointer to the target player
            const Basic::Pair* pair = static_cast<const Basic::Pair*>(item->getValue());
            const Simulation::Player* player = static_cast<const Simulation::Player*>(pair->object());
            if (player->isMajorType(Simulation::Player::WEAPON) && (player->isActive() || player->isMode(Simulation::Player::PRE_RELEASE)) && (player->getSide() == airVehicle->getSide())) {
               // our side has a weapon on-the-way/in-the-air;
               setMissileFired(true);
               finished=true;
            }
         }
      }
#else
      // this state class has no way to determine whether we've fired a missile other than checking to see if sms is out of missiles to fire.
      // which means, it will fire all its missiles at first target.
      const Simulation::StoresMgr* stores = airVehicle->getStoresManagement();
      if (stores != 0) {
         const Simulation::Missile* wpn = stores->getNextMissile();
         if (!wpn)
            setMissileFired(true);
      }
      else {
         // we have no SMS, we can't fire a missile;
         setMissileFired(true);
      }
#endif

      //const Basic::String* playerName = airVehicle->getName();
      // DH - DOES NOT COMPILE WITH CONST -- ????
      Simulation::AirVehicle* airVehicleX = const_cast<Simulation::AirVehicle*>(airVehicle);
      const Basic::Pair* sensorPair = airVehicleX->getSensorByType(typeid(Simulation::Radar));

      if (sensorPair != nullptr) {
         const Simulation::Radar* radar = static_cast<const Simulation::Radar*>(sensorPair->object());
         if (radar != nullptr) {
            const Simulation::TrackManager* trackManager = radar->getTrackManager();
            Basic::safe_ptr<Simulation::Track> trackList[50];
            unsigned int nTracks = trackManager->getTrackList(trackList, 50);

            for (int trackIndex = nTracks -1; trackIndex >= 0; trackIndex--) {
               setHeadingToTracked(trackIndex, trackList[trackIndex]->getRelAzimuth());
               setPitchToTracked(trackIndex, trackList[trackIndex]->getElevation());
               setDistanceToTracked(trackIndex, trackList[trackIndex]->getRange());

               // do we have a live "target track"? (shootlist is 1-based)
               if (getTargetTrack()==MAX_TRACKS && (trackList[trackIndex]->getShootListIndex() == 1) && trackList[trackIndex]->getTarget()->isActive()  ) {
                  setTargetTrack(trackIndex);
               }
               setTracking(true);
               setNumTracks(nTracks);

               // hack to implement "missile warning"
               if (isIncomingMissile() == false) {
                  // is this track a weapon, and if so, is it targeting me?
                  Simulation::Player* target = trackList[trackIndex]->getTarget();
                  Simulation::Weapon* weapon = dynamic_cast<Simulation::Weapon*> (target);
                  if (weapon!=nullptr && !weapon->isDead()) {
                     Simulation::Player* wpntgt = weapon->getTargetPlayer();
                     if (wpntgt == airVehicle) {
                        setIncomingMissile(true);
                     }
                  }
               }

            }
         }
      }

      const Simulation::OnboardComputer* oc = airVehicle->getOnboardComputer();
      if (oc != nullptr) {
         const Simulation::TrackManager* rtm = oc->getTrackManagerByType(typeid(Simulation::RwrTrkMgr));
         if(rtm !=nullptr) {
            Basic::safe_ptr<Simulation::Track> trackList[50];
            unsigned int nTracks = rtm->getTrackList(trackList, 50);
            int newTracks = 0;
            for (unsigned int trackIndex = 0; trackIndex < nTracks; trackIndex++) {
               Simulation::Player* target = trackList[trackIndex]->getTarget();
               bool alreadyTracked = false;
               for (unsigned int currTracks = 0; currTracks>getNumTracks(); currTracks++) {
                  // tracks are the same if the associated players are the same
                  if(trackList[currTracks]->getTarget()==target) {
                     alreadyTracked = true;
                     break;
                  }
               }

               if (!alreadyTracked && (getNumTracks() + newTracks) < MAX_TRACKS) {
                  int newTrackIndex = getNumTracks() + newTracks;
                  newTracks++;
                  setHeadingToTracked(newTrackIndex, trackList[trackIndex]->getRelAzimuth());
                  setPitchToTracked(newTrackIndex, trackList[trackIndex]->getElevation());
                  setDistanceToTracked(newTrackIndex, trackList[trackIndex]->getRange());
                  setTracking(true);

                  // update numTracks to new sum of radar + rwr tracks
                  setNumTracks(getNumTracks()+newTracks);
               }

               // do we have a live "target track"? (shootlist is 1-based)
               if (getTargetTrack()==MAX_TRACKS && (trackList[trackIndex]->getShootListIndex() == 1) && trackList[trackIndex]->getTarget()->isActive()  ) {
                  setTargetTrack(trackIndex);
               }

               // hack to implement "missile warning"
               if (isIncomingMissile() == false) {
                  // is this track a weapon, and if so, is it targeting me?
                  Simulation::Weapon* weapon = dynamic_cast<Simulation::Weapon*> (target);
                  if (weapon!=nullptr && !weapon->isDead()) {
                     Simulation::Player* wpntgt = weapon->getTargetPlayer();
                     if (wpntgt == airVehicle) {
                        setIncomingMissile(true);
                     }
                  }
               }

            }
         }
      }
   }
   BaseClass::updateState(actor);
}
Ejemplo n.º 8
0
void TimelineComponent::paint (Graphics& g)
{
    g.setColour (Colour (0xff454545));
    g.fillAll();

    // track header divider line
    g.setColour (Colours::black.withAlpha (0.5f));
    g.drawVerticalLine (mTrackWidth + 1, 0, getHeight());

    int track = heights.trackAtY (0);
    Rectangle<int> r;
    while (true)
    {
        if (r.getY() > getHeight() || track >= getNumTracks())
            break;

        if (! heights.trackIsVisible (track)) {
            ++track;
            continue;
        }

        r.setX (mTrackWidth);
        r.setY (heights.trackY (track));
        r.setWidth (getWidth() - mTrackWidth);
        r.setHeight (heights.get (track) + heights.spacing());

        g.saveState();
        paintTrackLane (g, track, r);
        g.restoreState();

        ++track;
    }

#if 0
    int track = heights.trackAtY (0);
    Rectangle<int> r;

    while (true)
    {
        r.setX (0);
        r.setWidth (mTrackWidth);
        r.setY (heights.trackY (track));
        r.setHeight (heights.get (track));

        if (r.getY() > getHeight() || track >= getNumTracks())
            break;

        if (! heights.trackIsVisible (track)) {
            ++track;
            continue;
        }

        if (mTrackWidth > 0) {
            g.saveState();
            paintTrackHeader (g, track, r);
            g.restoreState();
        }

        r.setX (mTrackWidth);
        r.setWidth (getWidth() - mTrackWidth);
        r.setHeight (r.getHeight() + heights.spacing());

        g.saveState();
        paintTrackLane (g, track, r);
        g.restoreState();

        ++track;
    }
#endif

#if 0
    // paint grid lines
    g.saveState();
    g.setColour (Colours::white);

    for (int beat = scale.beatFromPixel (timeToX (timeSpan.getStart())) - 1;
         ++beat;)
    {
        const int pixel = scale.pixelFromBeat (beat) + mTrackWidth;

        if (pixel < 0)
            continue;

        if (scale.beatIsBar (beat))
        {
            g.saveState();
            g.setColour(Colours::white);
            g.drawText (String(beat), pixel, 0, 20, 16, Justification::left, true);
            g.restoreState();
            g.setOpacity (0.20);
        }
        else
            g.setOpacity (0.10);

        g.drawVerticalLine (pixel, 0, getHeight());

        if (pixel > getWidth())
            break;
    }

    g.restoreState();
    g.resetToDefaultState();
#endif

}