Beispiel #1
0
pts_t eMPEGStreamInformation::getInterpolated(off_t offset)
{
		/* get the PTS values before and after the offset. */
	std::map<off_t,pts_t>::iterator before, after;
	after = m_access_points.upper_bound(offset);
	before = after;

	if (before != m_access_points.begin())
		--before;
	else	/* we query before the first known timestamp ... FIXME */
		return 0;

		/* empty... */
	if (before == m_access_points.end())
		return 0;

		/* if after == end, then we need to extrapolate ... FIXME */
	if ((before->first == offset) || (after == m_access_points.end()))
		return before->second - getDelta(offset);

	pts_t before_ts = before->second - getDelta(before->first);
	pts_t after_ts = after->second - getDelta(after->first);

//	eDebug("[eMPEGStreamInformation] %08llx .. ? .. %08llx", before_ts, after_ts);
//	eDebug("[eMPEGStreamInformation] %08llx .. %08llx .. %08llx", before->first, offset, after->first);

	pts_t diff = after_ts - before_ts;
	off_t diff_off = after->first - before->first;

	diff = (offset - before->first) * diff / diff_off;
//	eDebug("[eMPEGStreamInformation] %08llx .. %08llx .. %08llx", before_ts, before_ts + diff, after_ts);
	return before_ts + diff;
}
Beispiel #2
0
void ScaleTo::_update()
{
	if (m_remainTimer <= 0)
		setStop(true);
	Vec2 scaleVector = m_dstScale - m_preScale;
	scaleVector *= (float)getDelta() / (float) m_remainTimer;
	m_preScale = getNode()->getScale() + scaleVector;
	getNode()->setScale(m_preScale);
	m_remainTimer -= getDelta();
	if (m_remainTimer <= 0)
		getNode()->setScale(m_dstScale);
}
Beispiel #3
0
		void update( const double& dt )
		{
			assert( dt > 0 );

			double last_time;
			double temporary;

			last_time = now_time;
			now_time += dt;

			if ( repeat == repeat_index ) return; // Animation has ended

			do {
				if ( now_time <= delay_time ) return; // waiting ...

				/* Delay no more */

				if ( duration == 0.f ) // special case
				{
					*element_ += delta_data;

					now_time = now_time - end_time;

					// Add repeat
					repeat_inc();

					continue;
				}

				if ( last_time < delay_time ) last_time = delay_time;

				if ( now_time < end_time ) {
					temporary = getDelta( last_time, now_time );
					*element_ += temporary;
					sigma_dx_ += temporary;

				} else if ( last_time < end_time ) {
					temporary = getDelta( last_time, end_time );
					*element_ += temporary;
					sigma_dx_ += temporary;

					now_time = now_time - end_time;

					// App repeat
					repeat_inc();

					// Just in case
					continue;
				}

			} while( end_time <= now_time && repeat != repeat_index );
		}
Beispiel #4
0
void RotateTo::_update()
{
	if (m_remainTimer <= 0)
		setStop(true);
	Vec3 scaleVector = m_dstRotate - m_preRotate;
	scaleVector *= (float)getDelta() / (float) m_remainTimer;
	m_preRotate = getNode()->getRotate() + scaleVector;

	getNode()->setRotate(m_preRotate);
	m_remainTimer -= getDelta();
	if (m_remainTimer <= 0)
		getNode()->setRotate(m_dstRotate);
}
//
// Set Bin Width property by setting the slider
//
void HistogramWindow::setBin(double x)
{
    if (bactive) return;
    bactive = true;
    binWidthSlider->setValue(x/getDelta());
    rBinSlider->setValue(x/getDelta());
    binWidthLineEdit->setText(QString("%1").arg(x, 0, 'f', getDigits()));
    rBinEdit->setText(QString("%1").arg(x, 0, 'f', getDigits()));
    powerHist->setBinWidth(x);
    bactive = false;

    // redraw
    stale = true;
    updateChart();
}
Beispiel #6
0
Datei: modl.c Projekt: nionjo/dm
/* -------------------------------------------------
 * brief       : split one interval to two 
 * Interval sp1: splited interval 1
 * Interval sp2: splited interval 2
 * Interval * I: intervals after greedInit
 * int l       : the number of current Intervals
 * int m       : the number of greedinited Intervals I
 * int n       : the number of elements
 * return      : the delta after split t to sp1, sp2
 * ------------------------------------------------- */
static double splitInterval(Interval t, Interval sp1, Interval sp2, Interval * I, int l, int m, int n, double * LogD){
    int i; double mxspd,spd;
    Interval s1, s2;
    if (t[2] ==1 || t[3] == 1) return 0.0;

    for (i = 0; I[i][0] != t[0] && i< m; i++){}
    memmove(s1,I[i],sizeof(Interval));
    mxspd = -10e12;
    for(; I[i][1] != t[1] && i < m; i++){
        if (I[i][0] != s1[0] || I[i][1] != s1[1]){
            mergeInterval(s1,I[i]);
        }
        s2[0] = s1[1] + 1;
        s2[1] = t[1];
        s2[2] = t[1] - s1[1];
        s2[4] = t[4] - s1[4];
        s2[5] = t[5] - s1[5];
        s2[3] = 0;
        if (s2[4] > 0) s2[3] += 1;
        if (s2[5] > 0) s2[3] += 1;
        spd = -1.0 * getDelta(s1, s2, t, l + 1, n, LogD);
        if (spd > mxspd){
            mxspd = spd;
            memmove(sp1,s1,sizeof(Interval));
            memmove(sp2,s2,sizeof(Interval));
        }
    }
    return mxspd;
}
Beispiel #7
0
//!-----------------------------------------------------------------------------
//! MAIN
//!-----------------------------------------------------------------------------
int main(int argc, char** argv, char** envp)
{
  // open window
  sf::RenderWindow window(sf::VideoMode(WINDOW_W, WINDOW_H), WINDOW_TITLE);
  window.setFramerateLimit(MAX_FPS);

  // create game objects
  n1.neighbours[0] = &n2;
  n1.neighbours[1] = &n3;
  n2.neighbours[2] = &n3;

  // main loop
  while (window.isOpen())
  {
    // deal with events
    if(treatEvents(window) == STOP)
      window.close();

    // update the game
    if(update(getDelta()) == STOP)
      window.close();

    // redraw the game
    renderTo(window);
    window.display();
  }

  // quit
  return EXIT_SUCCESS;
}
Beispiel #8
0
void HelloWorld::onTouchesMoved(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event  *event) {
	if (touches.size() && camera)
	{
		auto touch = touches[0];
		auto delta = touch->getDelta();

		_angle -= CC_DEGREES_TO_RADIANS(delta.x);
		camera->setPosition3D(car_cabine->getPosition3D() + Vec3(100.0f * sinf(_angle), 50.0f, 100.0f * cosf(_angle)));
		camera->lookAt(car_cabine->getPosition3D(), Vec3(0.0f, 1.0f, 0.0f));
		/**
		if (delta.lengthSquared() > 16)
		{
			shootBox = false;
		}**/
		//event->stopPropagation();

		////Moving obj in camera direction
		/**
		auto location = touches[0]->getLocationInView();
		Vec3 nearP((int)location.x, (int)location.y, -1.0f), farP((int)location.x, (int)location.y, 1.0f);
		nearP = camera->unproject(nearP);
		farP = camera->unproject(farP);
		Vec3 dir(farP - nearP);
		vectorcameraforbox = (camera->getPosition3D() + dir) -camera->getPosition3D();
		**/
	}
}
Beispiel #9
0
off_t eMPEGStreamInformation::getAccessPoint(pts_t ts, int marg)
{
	//eDebug("[eMPEGStreamInformation::getAccessPoint] ts=%llu, marg=%d", ts, marg);
		/* FIXME: more efficient implementation */
	off_t last = 0;
	off_t last2 = 0;
	ts += 1; // Add rounding error margin
	for (std::map<off_t, pts_t>::const_iterator i(m_access_points.begin()); i != m_access_points.end(); ++i)
	{
		pts_t delta = getDelta(i->first);
		pts_t c = i->second - delta;
		if (c > ts) {
			if (marg > 0)
				return (last + i->first)/376*188;
			else if (marg < 0)
				return (last + last2)/376*188;
			else
				return last;
		}
		last2 = last;
		last = i->first;
	}
	if (marg < 0)
		return (last + last2)/376*188;
	else
		return last;
}
//==============================================================================
Error SceneAmbientColorEvent::update(F32 /*prevUpdateTime*/, F32 crntTime)
{
	getSceneGraph().setAmbientColor(
		linearInterpolate(m_originalColor, m_finalColor, getDelta(crntTime)));

	return ErrorCode::NONE;
}
Beispiel #11
0
/*
 * getMoves(Board * const * const board) moves the characters who can move.
 *
 * It takes in as a parameter the board array. It then iterates over it, gets a
 * random direction, checks if the character can move then moves it.
 *
 * Remark: getMoves() needs to be called by casting the two lists with 
 * (Board * const * const) to squash a harmless (in this case) warning
 * from GCC.
 * See http://c-faq.com/ansi/constmismatch.html
 */
void getMoves(Board * const * const board)
{
	for (size_t i = 0; i < gameVar.dim.y; i++) {
		for (size_t j = 0; j < gameVar.dim.x; j++) {
			switch (board[i][j].character) {
				case INF:
				case DOC:
				case CIT:
				case SOL:
				case NUR:
					board[i][j].direction = rand()%4;
					if (checkOutBounds(board[i][j].direction, i, j)) {
						Board *target = getDelta(board, i, j);
						if ((board[i][j].character == CIT && target->character == INF)
							|| (board[i][j].character == INF && target->character == CIT)) {
							break;
						} else if (target->character != WALL && target->character != DEAD) {
							Characters tmp = target->character;
							target->character = board[i][j].character;
							board[i][j].character = tmp;
						}
					}
					break;
				case DEAD:	//fallthrough
				case WALL:
				case EMPTY:
					break;
			}
		}
	}
}
Beispiel #12
0
void Input::handleInput(std::shared_ptr<Camera> & camera)
{
    GLfloat delta = getDelta();

    if (keys_state[Settings::MoveForwardKey])
        camera->move(MoveDirection::Forward, delta);

    if (keys_state[Settings::MoveBackwardKey])
        camera->move(MoveDirection::Backward, delta);

    if (keys_state[Settings::MoveLeftKey])
        camera->move(MoveDirection::Left, delta);

    if (keys_state[Settings::MoveRightKey])
        camera->move(MoveDirection::Right, delta);

    if (keys_state[Settings::MoveUpKey])
        camera->move(MoveDirection::Up, delta);

    if (keys_state[Settings::MoveDownKey])
        camera->move(MoveDirection::Down, delta);

    camera->look(x_move, y_move);
    x_move = y_move = 0;

    if (switch_cam)
    {
        camera->switchLight();
        switch_cam = false;
    }
}
Beispiel #13
0
// fixupPTS is apparently called to get UI time information and such
int eMPEGStreamInformation::fixupPTS(const off_t &offset, pts_t &ts)
{
	//eDebug("[eMPEGStreamInformation::fixupPTS] offset=%llu pts=%llu", offset, ts);
	if (m_streamtime_accesspoints)
	{
		/*
		 * The access points are measured in stream time, rather than actual mpeg pts.
		 * Overrule the timestamp with the nearest access point pts.
		 */
		off_t nearestoffset = offset;
		getPTS(nearestoffset, ts);
		return 0;
	}
	if (m_timestamp_deltas.empty())
		return -1;

	std::multimap<pts_t, off_t>::const_iterator
		l = m_pts_to_offset.upper_bound(ts - 60 * 90000),
		u = m_pts_to_offset.upper_bound(ts + 60 * 90000),
		nearest = m_pts_to_offset.end();

	while (l != u)
	{
		if ((nearest == m_pts_to_offset.end()) || (llabs(l->first - ts) < llabs(nearest->first - ts)))
			nearest = l;
		++l;
	}
	if (nearest == m_pts_to_offset.end())
		return 1;

	ts -= getDelta(nearest->second);

	return 0;
}
/*--------------------------------------------------------*/
void AzOptOnTree::_update_with_features_TempFile(
                      double nlam, 
                      double nsig, 
                      double py_avg, 
                      AzRgf_forDelta *for_del) /* updated */
{
  int tree_num = ens->size();
  int tx; 
  for (tx = 0; tx < tree_num; ++tx) {
    ens->tree_u(tx)->restoreDataIndexes(); 
    AzIIarr iia_nx_fx; 
    tree_feat->featIds(tx, &iia_nx_fx); 
    int num = iia_nx_fx.size(); 
    int ix; 
    for (ix = 0; ix < num; ++ix) {
      int nx, fx; 
      iia_nx_fx.get(ix, &nx, &fx); 
      if (tree_feat->featInfo(fx)->isRemoved) continue; /* shouldn't happen though */

      double w = v_w.get(fx); 
      int dxs_num; 
      const int *dxs = data_points(fx, &dxs_num); 
      double my_nlam = reg_depth->apply(nlam, node(fx)->depth); 
      double my_nsig = reg_depth->apply(nsig, node(fx)->depth); 
      double delta = getDelta(dxs, dxs_num, w, my_nlam, my_nsig, py_avg, for_del); 
      v_w.set(fx, w+delta); 
      updatePred(dxs, dxs_num, delta, &v_p); 
    }
    ens->tree_u(tx)->releaseDataIndexes(); 
  }
}
Beispiel #15
0
void CCShuffleTiles::startWithTarget(CCNode *pTarget)
{
    CCTiledGrid3DAction::startWithTarget(pTarget);

    m_nTilesCount = m_sGridSize.width * m_sGridSize.height;
    m_pTilesOrder = new unsigned int[m_nTilesCount];
    int i, j;
    unsigned int k;

    /**
     * Use k to loop. Because m_nTilesCount is unsigned int,
     * and i is used later for int.
     */
    for (k = 0; k < m_nTilesCount; ++k)
    {
        m_pTilesOrder[k] = k;
    }

    shuffle(m_pTilesOrder, m_nTilesCount);

    m_pTiles = (struct Tile *)new Tile[m_nTilesCount];
    Tile *tileArray = (Tile*) m_pTiles;

    for (i = 0; i < m_sGridSize.width; ++i)
    {
        for (j = 0; j < m_sGridSize.height; ++j)
        {
            tileArray->position = ccp((float)i, (float)j);
            tileArray->startPosition = ccp((float)i, (float)j);
            tileArray->delta = getDelta(CCSizeMake(i, j));
            ++tileArray;
        }
    }
}
Beispiel #16
0
	void CCShuffleTiles::startWithTarget(CCNode *pTarget)
	{
		CCTiledGrid3DAction::startWithTarget(pTarget);

		if (m_nSeed != -1)
		{
			srand(m_nSeed);
		}

		m_nTilesCount = m_sGridSize.x * m_sGridSize.y;
		m_pTilesOrder = new int[m_nTilesCount];
		int i, j;

		for (i = 0; i < m_nTilesCount; ++i)
		{
			m_pTilesOrder[i] = i;
		}

		shuffle(m_pTilesOrder, m_nTilesCount);

		m_pTiles = (struct Tile *)new Tile[m_nTilesCount];
		Tile *tileArray = (Tile*) m_pTiles;

		for (i = 0; i < m_sGridSize.x; ++i)
		{
			for (j = 0; j < m_sGridSize.y; ++j)
			{
				tileArray->position = ccp((float)i, (float)j);
				tileArray->startPosition = ccp((float)i, (float)j);
				tileArray->delta = getDelta(ccg(i, j));
				++tileArray;
			}
		}
	}
Beispiel #17
0
/**
 * Returns the timer value
 */
int cmTimer::get_timer(void)
{
    if(newFrame()) {
        delta_var = getDelta();
        return 1;
    }else
        return 0;
}
Beispiel #18
0
void TileDemoNew::onTouchesMoved(const std::vector<Touch*>& touches, Event  *event)
{
    auto touch = touches[0];

    auto diff = touch->getDelta();
    auto node = getChildByTag(kTagTileMap);
    auto currentPos = node->getPosition();
    node->setPosition(currentPos + diff);
}
//
// When user selects a different data series
//
void
HistogramWindow::seriesChanged()
{
    // series changed so tell power hist
    powerHist->setSeries(static_cast<RideFile::SeriesType>(seriesCombo->itemData(seriesCombo->currentIndex()).toInt()));
    powerHist->setDelta(getDelta());
    powerHist->setDigits(getDigits());

    // now update the slider stepper and linedit
    setBinEditors();

    // set an initial bin width value
    setBin(getDelta());

    // replot
    stale = true;
    updateChart();
}
Beispiel #20
0
void eMPEGStreamInformation::fixupDiscontinuties()
{
	m_timestamp_deltas.clear();
	if (!m_access_points.size())
		return;
		
//	eDebug("Fixing discontinuities ...");

			/* if we have no delta at the beginning, extrapolate it */
	if ((m_access_points.find(0) == m_access_points.end()) && (m_access_points.size() > 1))
	{
		std::map<off_t,pts_t>::const_iterator second = m_access_points.begin();
		std::map<off_t,pts_t>::const_iterator first  = second++;
		if (first->first < second->first) /* i.e., not equal or broken */
		{
			off_t diff = second->first - first->first;
			pts_t tdiff = second->second - first->second;
			tdiff *= first->first;
			tdiff /= diff;
			m_timestamp_deltas[0] = first->second - tdiff;
//			eDebug("first delta is %08llx", first->second - tdiff);
		}
	}

	if (m_timestamp_deltas.empty())
		m_timestamp_deltas[m_access_points.begin()->first] = m_access_points.begin()->second;

	pts_t currentDelta = m_timestamp_deltas.begin()->second, lastpts_t = 0;
	for (std::map<off_t,pts_t>::const_iterator i(m_access_points.begin()); i != m_access_points.end(); ++i)
	{
		pts_t current = i->second - currentDelta;
		pts_t diff = current - lastpts_t;
		
		if (llabs(diff) > (90000*5)) // 5sec diff
		{
//			eDebug("%llx < %llx, have discont. new timestamp is %llx (diff is %llx)!", current, lastpts_t, i->second, diff);
			currentDelta = i->second - lastpts_t; /* FIXME: should be the extrapolated new timestamp, based on the current rate */
//			eDebug("current delta now %llx, making current to %llx", currentDelta, i->second - currentDelta);
			m_timestamp_deltas[i->first] = currentDelta;
		}
		lastpts_t = i->second - currentDelta;
	}
	
	
//	eDebug("ok, found %d disconts.", m_timestamp_deltas.size());

#if 0	
	for (off_t x=0x25807E34ULL; x < 0x25B3CF70; x+= 100000)
	{
		off_t o = x;
		pts_t p;
		int r = getPTS(o, p);
		eDebug("%08llx -> %08llx | %08llx, %d, %08llx %08llx", x, getDelta(x), getInterpolated(x), r, o, p);
	}
#endif
}
Beispiel #21
0
/*
 * checkTarget(Board * const * const board, const int y, const int x, action getAction) finds the target and gets the action.
 *
 * It takes in as parameters the board array, the original coordinates and a
 * function pointer to action to execute. After getting the target through
 * getDelta(), it executes the action using getAction();
 */
void checkTarget(Board * const * const board, const int y, const int x, action getAction)
{
	Board *target = NULL;
	
	target = getDelta(board, y, x);

	if (target == NULL) exit(EXIT_FAILURE);

	getAction(&board[y][x], target);
}
Beispiel #22
0
 std::vector<double> BlackScholesGreeks::getAllGreeks()
 {
     std::vector<double> data;
     data.push_back(getPremium());
     data.push_back(getDelta());
     data.push_back(getGamma());
     data.push_back(getVega());
     data.push_back(getRho());
     data.push_back(getTheta());
     return data;
 }
//
// We need to config / update the controls when data series/metrics change
//
void
HistogramWindow::setBinEditors()
{
    // the line edit validator
    QValidator *validator;
    if (getDigits() == 0) {

        validator = new QIntValidator(binWidthSlider->minimum() * getDelta(),
                                      binWidthSlider->maximum() * getDelta(),
                                      binWidthLineEdit);
    } else {

        validator = new QDoubleValidator(binWidthSlider->minimum() * getDelta(),
                                         binWidthSlider->maximum() * getDelta(),
                                         getDigits(),
                                         binWidthLineEdit);
    }
    binWidthLineEdit->setValidator(validator);
    rBinEdit->setValidator(validator);
}
void ScenarioTest::onTouchesMoved(const std::vector<Touch*>& touches, Event  *event)
{
    auto touch = touches[0];
    
    auto diff = touch->getDelta();
    auto currentPos1 = _map1->getPosition();
    _map1->setPosition(currentPos1 + diff);
    
    auto currentPos2 = _map2->getPosition();
    _map2->setPosition(currentPos2 + diff);
}
void
HistogramWindow::treeSelectionTimeout()
{
    // new metric chosen, so set up all the bin width, line edit
    // delta, precision etc
    powerHist->setSeries(RideFile::none);
    powerHist->setDelta(getDelta());
    powerHist->setDigits(getDigits());

    // now update the slider stepper and linedit
    setBinEditors();

    // initial value -- but only if need to
    double minbinw = getDelta();
    double maxbinw = getDelta() * 100;
    double current = binWidthLineEdit->text().toDouble();
    if (current < minbinw || current > maxbinw) setBin(getDelta());

    // replot
    updateChart();
}
Beispiel #26
0
void Walker::updateEntity(const da::EntityPtr &entity) {
    // Only update once per millisecond
    mTime += getDelta();
    if (mTime < sf::milliseconds(1)) {
        return;
    }
    mTime = sf::Time::Zero;
    
    // Get attributes
    da::attr::Transform &xform = entity->getAttribute<da::attr::Transform>();
    attr::Poses &poses = entity->getAttribute<attr::Poses>();
    attr::Sprite &sprite = entity->getAttribute<attr::Sprite>();
    sf::Vector2f &prevPos =
        entity->getAttribute<attr::Person>().previousPosition;
    
    // Make sure they're enabled.  Early out if they're not.
    if (!poses.isEnabled || !sprite.isEnabled()) {
        return;
    }
    
    // Get change in position
    sf::Vector2f deltaPos = xform.getPosition() - prevPos;
    prevPos = xform.getPosition();
    
    float distance = da::MathHelper::length(deltaPos.x, deltaPos.y);
    
    // Don't bother if the distance is too small.  We may regret this on the
    // magical computers of tomorrow (or if we forget to limit the framerate)
    if (distance < DELTA_THRESH) {
        return;
    }
    
    // Calculate the angle of movement.
    float angle = atan2(deltaPos.y, deltaPos.x);
    
    // atan2 yields [-pi, +pi], so let's correct it to something more palatable:
    // [0, 2pi]
    if (angle < 0.f) {
        angle += da::MathHelper::TwoPi;
    }
    
    // Threshold checking
    float center = 0.f;
    for (unsigned int i = 0; i < DirectionCount; i++) {        
        if (angle > center - da::MathHelper::PiOverEight &&
            angle <= center + da::MathHelper::PiOverEight) {
            poses.direction = (CardinalDirection)i;
            break;
        }
        
        center += da::MathHelper::PiOverFour;
    }
}
Beispiel #27
0
 double GMM::fixCenterGmm(const std::vector<double> & data, int centers, std::vector< Gaussian > &re, double DELTA ) {
     if( centers <= 1 ) {
         re.push_back( getGaussian(data) );
         return caculateBIC(data, re);
     }
     bool fixDelta = true;
     if(DELTA <= 0.01) {
         fixDelta = false;
     }
     double mx = *max_element(data.begin(), data.end());
     double mn = *min_element(data.begin(), data.end());
     double diff = mx - mn;
     double delta = getDelta(data);
     for(int i = 0; i < centers; ++i) {
         if(fixDelta) {
             re.push_back( Gaussian(mn + i*diff/(centers-1), DELTA, 1.0 / centers) );
         } else {
             re.push_back( Gaussian(mn + i*diff/(centers-1), delta, 1.0 / centers) );
         }
     }
     std::vector< std::vector<double> > beta( data.size(), std::vector<double>(centers, 0.0) );
     std::vector< Gaussian > tmp(centers, Gaussian() );
     int itera = 0;
     while( itera++ < MAX_ITERATOR && !ok(re, tmp) ) {
         tmp = re;
         for(int i = 0; i < data.size(); ++i) {
             for(int j = 0; j < centers; ++j) {
                 beta[i][j] = re[j].getProbability(data[i]);
             }
             double sum = accumulate(beta[i].begin(), beta[i].end(), 0.0);
             for(int j = 0; j < centers; ++j) {
                 beta[i][j] /= sum;
             }
         }
         for(int j = 0; j < centers; ++j) {
             double sumBeta = 0.0, sumweightBeta = 0.0, sumVar = 0.0;
             for(int i = 0; i < data.size(); ++i) {
                 sumBeta += beta[i][j];
                 sumweightBeta += data[i] * beta[i][j];
             }
             re[j].weight = sumBeta / data.size();
             re[j].mean = sumweightBeta / sumBeta;
             for(int i = 0; i < data.size(); ++i) {
                 sumVar += beta[i][j] * (data[i] - re[j].mean) * (data[i] - re[j].mean);
             }
             if(!fixDelta) {
                 re[j].delta = std::pow( sumVar / sumBeta, 0.5);
             }
         }
     }
     return caculateBIC(data, re);
 }
Beispiel #28
0
int LimitedEnc::get(int enc_pos){
  int delta = getDelta(enc_pos);
  if(ccw){
    delta = -delta;
  }
  if(delta > 0){
    selected = my_min(selected + delta, n_item - 1);
  }
  if(delta < 0){
    selected = my_max(selected + delta, 0);
  }
  return selected;
}
Beispiel #29
0
void CSSceneSkyBoxTest::onTouchesMoved(const std::vector<Touch*>& touches, cocos2d::Event  *event)
{
    if (touches.size())
    {
        auto touch = touches[0];
        auto delta = touch->getDelta();

        static float _angle = 0.f;
        _angle -= CC_DEGREES_TO_RADIANS(delta.x);
        _camera->setPosition3D(Vec3(50.0f * sinf(_angle), 0.0f, 50.0f * cosf(_angle)));
        _camera->lookAt(Vec3(0.0f, 0.0f, 0.0f), Vec3(0.0f, 1.0f, 0.0f));
    }
}
Beispiel #30
0
//---------------------------------------------
void ProcessFFT::drawDebug(){
    ofPushMatrix();
    ofDrawBitmapStringHighlight("Loudest Band: " + ofToString(loudestBand), 250,20);
    ofDrawBitmapStringHighlight("Curr. Max Sound Val: "+ ofToString(maxSound), 250,40);
    ofDrawBitmapStringHighlight("Super Low Avg: " + ofToString(superLowEqAvg), 250,60);
    ofDrawBitmapStringHighlight("Low Avg: " + ofToString(lowEqAvg), 250,80);
    ofDrawBitmapStringHighlight("Mid Avg: " + ofToString(midEqAvg), 250,100);
    ofDrawBitmapStringHighlight("High Avg: " + ofToString(highEqAvg), 250,120);
    ofDrawBitmapStringHighlight("Noisiness: " + ofToString(noisiness), 250,140);
    ofDrawBitmapStringHighlight("SpectralCentroid: " + ofToString(spectralCentroid), 250,160);
    ofDrawBitmapStringHighlight("Avg Max Sound: " + ofToString(avgMaxSoundOverTime), 250,180);
    ofDrawBitmapStringHighlight("Delta: " + ofToString(getDelta()), 250,200);
    ofDrawBitmapStringHighlight("Delta Shift Detected: " + ofToString(abs(getDelta())>(avgMaxSoundOverTime*.20)), 250,220);
    
    
    ofDrawBitmapStringHighlight("Freq Range up to: " +ofToString(ofMap(FFTpercentage, 0, 0.23, 0, 5000)) + "hz", 450,60);
    float freqPerBin = ofMap(FFTpercentage, 0, 0.23, 0, 5000)/numFFTbins;
    ofDrawBitmapStringHighlight("Freq range per bin: " +ofToString(freqPerBin) + "hz", 450,80);
    ofDrawBitmapStringHighlight("Approx Number of octaves from C0: " +ofToString(ofMap(ofMap(FFTpercentage, 0, 0.23, 0, 5000),0,5000,0,8)), 450,100); //wrong wrong wrong - octave frequency doubles as it goes up - octave is from n to 2n hz, so do more math for this
    ofDrawBitmapStringHighlight("Approx Freq of Loudest Band: " +ofToString(freqPerBin*loudestBand)+"hz", 450,120);
    ofPopMatrix();
}