OpenMediaLib User and Development Guide

The Sample Calculator

Although this is typically an issue for the plugin implementations to deal with, the cycle logic is exposed for general use (both in C++ and python).

There are two functions available – the first of which simply returns the number of required samples for a given frame offset and provided combination of frequency and frame rate and is prototyped in C++ as:

int audio_samples_for_frame( int frame, int frequency, int fps_num, int fps_den )

A sibling function is also provided which returns the number of samples which should have proceeded the requested frame position:

long long audio_samples_to_frame( int frame, int frequency, int fps_num, int fps_den )

And a final utility is provided to assist in the 'reseating' associated to frame rate interpolation:

audio_reseat_ptr create_audio_reseat( )

which returns a class with the following public interface:

	bool append( audio_type_ptr )
	audio_type_ptr retrieve( int samples, bool pad = false )
	void clear( )
	bool has( int )

Note that this doesn't provide resampling functionality – its role is simply to allow conversion from one frame rate to another by 'reseating' the audio samples according to the number of samples requested in the retrieve method.