Пример #1
0
bool F0Contour::computeF0()
{
    if (_f0_session == 0) {
        _f0_session = init_get_f0();
        _f0_session->par->min_f0 = 60.0;
        _f0_session->par->max_f0 = 650.0;
        _f0_session->par->wind_dur = 0.01;
        _f0_session->par->frame_step = 0.005;
    }

    if (pitch_track(_ann, _f0_session)) {
        _redraw();
        return true;
    }
    else
        return false;
}
Пример #2
0
AUD_Int32s test_pitch_tracking()
{
	char            inputPath[256]  = { 0, };
	AUD_Int32s      data;

	setbuf( stdin, NULL );
	AUDLOG( "pls give test wav stream's path:\n" );
	inputPath[0] = '\0';
	data = scanf( "%s", inputPath );
	AUDLOG( "test stream path is: %s\n", inputPath );

	AUDLOG( "\n\n" );

	// file & directory operation, linux dependent
	entry      *pEntry         = NULL;
	dir        *pDir           = NULL;
	AUD_Int8s  fileName[256]   = { 0, };
	AUD_Int32s sampleNum;

	AUD_Int32s bufLen          = 0;
	AUD_Int16s *pBuf           = NULL;


	FILE *fPitch = fopen( "./pitch.log", "wb" );
	AUD_ASSERT( fPitch );

	pDir = openDir( (const char*)inputPath );
	while ( ( pEntry = scanDir( pDir ) ) )
	{
		bufLen = SAMPLE_RATE * BYTES_PER_SAMPLE * 10;
		pBuf   = (AUD_Int16s*)malloc( bufLen );
		AUD_ASSERT( pBuf );

		snprintf( (char*)fileName, 256, "%s/%s", (const char*)inputPath, pEntry->name );

		sampleNum = readWavFromFile( fileName, pBuf, bufLen );
		if ( sampleNum < 0 )
		{
			continue;
		}
		AUDLOG( "stream[%s] sample number[%d]\n", fileName, sampleNum );

		sig_preemphasis( pBuf, pBuf, sampleNum );

		// pitch tracking
		AUD_Int32s pitch;
		pitch_track( pBuf, sampleNum, &pitch );
		fprintf( fPitch, "%d, ", pitch );
		AUDLOG( "%d, \n", pitch );

		free( pBuf );
		pBuf = NULL;
	}

	fclose( fPitch );
	fPitch = NULL;

	AUDLOG( "PITCH-TRACKING finished\n" );

	return 0;
}