예제 #1
0
int main(int argc, char *argv[])
{
    if (argc != 4)
        usage(0);
    struct stat stat_buf;
    if (stat(argv[1], &stat_buf) == -1) {
        usage(strerror(errno));
    }
    char *p;
    float beg = strtof(argv[2], &p);
    if (p != argv[2] + strlen(argv[2])) {
        usage("start time must be a number");
    }
    float end = strtof(argv[3], &p);
    if (p != argv[3] + strlen(argv[3])) {
        usage("end time must be a number");
    }

    get_f0_session *session = init_get_f0();
    session->par->min_f0 = 60.0;
    session->par->max_f0 = 650.0;
    session->par->wind_dur = 0.01;
    session->par->frame_step = 0.001;
    get_f0(argv[1], session, beg, end, &callback, 0);
    close_get_f0(session);
    return 0;
}
예제 #2
0
void CGlobalVars::calc_oh_symbols()
{
	/*
	*  Initialize OH symbols and variables
	*/

	init_userchair();	
	

	/////////////////////////////////////////////////////////
	////////////// OpenHoldem Calculated Symbols ////////////
	/////////////////////////////////////////////////////////
	DirtyOHVars();

	br = get_betround();
	sb = get_sblind();
	bb = get_bblind();	

	ntimesacted = get_didcall() + get_didchec() + get_didrais() + get_didswag();
	enabled_flag[0] = get_f0();
	enabled_flag[1] = get_f1();

	//////////////////////////////////////////////////////////////////
	//OWN VARS
	//////////////////////////////////////////////////////////////////
	int balance_not_0 = 0;
	for(int chair = 0; chair < k_max_chairs; chair++)
	{
		if(is_seated(chair))
		{
			currentbet[chair]	= ToMoney(m_state.CurState().m_player[chair].m_currentbet);
			balance[chair]		= ToMoney(m_state.CurState().m_player[chair].m_balance);

			assert(currentbet[chair] >= 0 && balance[chair] >= 0);

			if(get_betround() == ePreflop && ntimesacted == 0)
				initial_balance[chair] = balance[chair] + currentbet[chair];
		}
		else
		{
			balance[chair]			= 0.0;
			currentbet[chair]		= 0.0;
			initial_balance[chair]	= 0.0;
		}

		if (balance[chair] > 0)
			balance_not_0 ++;
	}

	//GENERAL VARS
	sb_posted = set_SB();

	ncurrentbet = set_maxcurrentbet();
	call = ToMoney(ncurrentbet - currentbet[userchair]);
	assert(call >= 0);

	//stack_depth = set_stack_depth(); //variable not used and not defined

	//OPPONENT VARS
	nopponentsbetting		= set_nopponentsbetting();
	nopponentscalling		= set_nopponentscalling();
	nopponents = nopponentsbetting + nopponentscalling;

	raischair				= set_raischair();
	adj_nopponentsraising	= set_adj_nopponentsraising();
	nplayersplaying			= bitcount(get_playersplayingbits());

	//PREFLOP VARS
	dealpositionrais = set_dealpositionrais();

	//updating card values
	set_card_values();
	//updating hand values
	issuited		= set_suited();
	rankhiplayer	= set_rankhiplayer();
	rankloplayer	= set_rankloplayer();

	//assign myHand
	getMyHand(); 
}
예제 #3
0
static bool pitch_track(Annotation &ann, get_f0_session *session)
{
    QString p = ann.getAudioPath();
    if (p.isEmpty())
        return false;

    SF_INFO sfinfo;
    SNDFILE *sndfile = sf_open(p.toUtf8().constData(), SFM_READ, &sfinfo);
    if (sndfile == 0)
        return false;
    sf_close(sndfile);

    double fend = ((double) sfinfo.frames) / sfinfo.samplerate;
    double beg = ann.getTargetStart() - 0.5;
    double end = ann.getTargetEnd() + 0.5;
    if (beg < 0.0)
        beg = 0.0;
    if (end > fend)
        end = fend;

    QVector<float> v;
    get_f0(p.toUtf8().constData(), session, beg, end, callback, &v);

    double t0 = ann.getTargetStart() - beg;
    double step = (ann.getTargetEnd() - ann.getTargetStart()) / 29.0;
    QVector<float> pitch_sample;
    for (int i=0; i < 30; ++i) {
        double t = t0 + step * i;
        double x = t / session->par->frame_step;
        double x1 = floor(x);
        double x2 = ceil(x);
        double x0 = x1 - 1.0;
        double x3 = x2 + 1.0;
        int i0 = int(x0) * 2;
        int i1 = int(x1) * 2;
        int i2 = int(x2) * 2;
        int i3 = int(x3) * 2;
        float vp0 = i0 >= 0 ? v.at(i0+1) : 0.0;
        float vp1 = v.at(i1+1);
        float vp2 = v.at(i2+1);
        float vp3 = i3 < 60 ? v.at(i3+1) : 0.0;
        double y;

        if (vp1 < 0.5) {
            // x1 unvoiced
            if (vp2 < 0.5) {
                // x1, x2 unvoiced
                y = -1.0;
            }
            else {
                // x1 unvoiced, x2 voiced
                if (x - x1 < 0.5) {
                    // x is closer to unvoiced x1
                    y = -1.0;
                }
                else {
                    // x is closer to voiced x2
                    if (vp3 < 0.5) {
                        // x3 is unvoiced or ob
                        y = v.at(i2);
                    }
                    else {
                        // x3 is voiced
                        // extrapolate with x2 and x3
                        int y2 = v.at(i2);
                        int y3 = v.at(i3);
                        y = (x3*y2 - x2*y3 + (y3-y2)*x) / (x3 - x2);
                    }
                }
            }
        }
        else {
            // x1 is voiced
            if (vp2 < 0.5) {
                // x1 voiced, x2 unvoiced
                if (x2 - x < 0.5) {
                    // x is closer to unvoiced x2
                    y = -1.0;
                }
                else {
                    // x is closer to voiced x1
                    if (vp0 < 0.5) {
                        // x0 is unvoiced or ob
                        y = v.at(i1);
                    }
                    else {
                        // x0 is voiced
                        // extraploate with x0 and x1
                        int y0 = v.at(i0);
                        int y1 = v.at(i1);
                        y = (x1*y0 - x0*y1 + (y1-y0)*x) / (x1 - x0);
                    }
                }
            }
            else {
                // interpolate with x1 and x2
                double y1 = v.at(i1);
                double y2 = v.at(i2);
                y = (y2 - y1) / (x2 - x1) * (x - x1) + y1;
            }
        }
        pitch_sample.push_back((float) y);
    }
    ann.setF0(pitch_sample);

    return true;
}