Add API functions to set and retrieve frame times

Setting a custom frame time will result in stable animation speeds if projectM does not render at real-time speeds, e.g. while encoding a video from an audio file as fast as possible.
This commit is contained in:
Kai Blaschke
2024-06-09 12:51:35 +02:00
parent bd2b1ba9f4
commit 2914d85ec3
6 changed files with 109 additions and 2 deletions

View File

@ -7,6 +7,7 @@
#include <cstring>
#include <sstream>
#include <projectM-4/render_opengl.h>
#include <projectM-4/parameters.h>
namespace libprojectM {
@ -179,6 +180,18 @@ void projectm_opengl_render_frame_fbo(projectm_handle instance, uint32_t framebu
projectMInstance->RenderFrame(framebuffer_object_id);
}
void projectm_set_frame_time(projectm_handle instance, double seconds_since_first_frame)
{
auto projectMInstance = handle_to_instance(instance);
projectMInstance->SetFrameTime(seconds_since_first_frame);
}
double projectm_get_last_frame_time(projectm_handle instance)
{
auto projectMInstance = handle_to_instance(instance);
return projectMInstance->GetFrameTime();
}
void projectm_set_beat_sensitivity(projectm_handle instance, float sensitivity)
{
auto projectMInstance = handle_to_instance(instance);