diff --git a/src/libprojectM/ProjectMCWrapper.cpp b/src/libprojectM/ProjectMCWrapper.cpp
index a5d5cb5f2..f12f8b7a8 100644
--- a/src/libprojectM/ProjectMCWrapper.cpp
+++ b/src/libprojectM/ProjectMCWrapper.cpp
@@ -135,11 +135,11 @@ projectm_handle projectm_create_settings(const projectm_settings* settings, int
cppSettings.titleFontURL = settings->title_font_url ? settings->title_font_url : "";
cppSettings.menuFontURL = settings->menu_font_url ? settings->menu_font_url : "";
cppSettings.datadir = settings->data_dir ? settings->data_dir : "";
- cppSettings.smoothPresetDuration = settings->smooth_preset_duration;
+ cppSettings.softCutDuration = settings->soft_cut_duration;
cppSettings.presetDuration = settings->preset_duration;
- cppSettings.hardcutEnabled = settings->hardcut_enabled;
- cppSettings.hardcutDuration = settings->hardcut_duration;
- cppSettings.hardcutSensitivity = settings->hardcut_sensitivity;
+ cppSettings.hardCutEnabled = settings->hard_cut_enabled;
+ cppSettings.hardCutDuration = settings->hard_cut_duration;
+ cppSettings.hardCutSensitivity = settings->hard_cut_sensitivity;
cppSettings.beatSensitivity = settings->beat_sensitivity;
cppSettings.aspectCorrection = settings->aspect_correction;
cppSettings.easterEgg = settings->easter_egg;
@@ -205,10 +205,16 @@ void projectm_reset_textures(projectm_handle instance)
projectMInstance->projectM_resetTextures();
}
+const char* projectm_get_title(projectm_handle instance)
+{
+ auto projectMInstance = handle_to_instance(instance);
+ return projectm_alloc_string_from_std_string(projectMInstance->getTitle());
+}
+
void projectm_set_title(projectm_handle instance, const char* title)
{
auto projectMInstance = handle_to_instance(instance);
- projectMInstance->projectM_setTitle(title);
+ projectMInstance->setTitle(title);
}
void projectm_render_frame(projectm_handle instance)
@@ -236,28 +242,136 @@ void projectm_default_key_handler(projectm_handle instance, projectMEvent event,
projectMInstance->default_key_handler(event, keycode);
}
-void projectm_set_texture_size(projectm_handle instance, int size)
+size_t projectm_get_texture_size(projectm_handle instance)
{
auto projectMInstance = handle_to_instance(instance);
- projectMInstance->changeTextureSize(size);
+ return projectMInstance->getTextureSize();
}
-void projectm_set_hardcut_duration(projectm_handle instance, double seconds)
+void projectm_set_texture_size(projectm_handle instance, size_t size)
{
auto projectMInstance = handle_to_instance(instance);
- projectMInstance->changeHardcutDuration(seconds);
+ projectMInstance->setTextureSize(size);
+}
+
+double projectm_get_hard_cut_duration(projectm_handle instance)
+{
+ auto projectMInstance = handle_to_instance(instance);
+ return projectMInstance->getHardCutDuration();
+}
+
+void projectm_set_hard_cut_duration(projectm_handle instance, double seconds)
+{
+ auto projectMInstance = handle_to_instance(instance);
+ projectMInstance->setHardCutDuration(seconds);
+}
+
+bool projectm_get_hard_cut_enabled(projectm_handle instance)
+{
+ auto projectMInstance = handle_to_instance(instance);
+ return projectMInstance->getHardCutEnabled();
+}
+
+void projectm_set_hard_cut_enabled(projectm_handle instance, bool enabled)
+{
+ auto projectMInstance = handle_to_instance(instance);
+ projectMInstance->setHardCutEnabled(enabled);
+}
+
+float projectm_get_hard_cut_sensitivity(projectm_handle instance)
+{
+ auto projectMInstance = handle_to_instance(instance);
+ return projectMInstance->getHardCutSensitivity();
+}
+
+void projectm_set_hard_cut_sensitivity(projectm_handle instance, float sensitivity)
+{
+ auto projectMInstance = handle_to_instance(instance);
+ projectMInstance->setHardCutSensitivity(sensitivity);
+}
+
+double projectm_get_soft_cut_duration(projectm_handle instance)
+{
+ auto projectMInstance = handle_to_instance(instance);
+ return projectMInstance->getSoftCutDuration();
+}
+
+void projectm_set_soft_cut_duration(projectm_handle instance, double seconds)
+{
+ auto projectMInstance = handle_to_instance(instance);
+ projectMInstance->setSoftCutDuration(seconds);
}
void projectm_set_preset_duration(projectm_handle instance, double seconds)
{
auto projectMInstance = handle_to_instance(instance);
- projectMInstance->changePresetDuration(seconds);
+ projectMInstance->setPresetDuration(seconds);
}
-void projectm_get_mesh_size(projectm_handle instance, int* width, int* height)
+void projectm_get_mesh_size(projectm_handle instance, size_t* width, size_t* height)
{
auto projectMInstance = handle_to_instance(instance);
- projectMInstance->getMeshSize(width, height);
+ projectMInstance->getMeshSize(*width, *height);
+}
+
+void projectm_set_mesh_size(projectm_handle instance, size_t width, size_t height)
+{
+ auto projectMInstance = handle_to_instance(instance);
+ projectMInstance->setMeshSize(width, height);
+}
+
+size_t projectm_get_fps(projectm_handle instance)
+{
+ auto projectMInstance = handle_to_instance(instance);
+ return projectMInstance->settings().fps;
+}
+
+const char* projectm_get_preset_path(projectm_handle instance)
+{
+ auto projectMInstance = handle_to_instance(instance);
+ return projectm_alloc_string_from_std_string(projectMInstance->settings().presetURL);
+}
+
+const char* projectm_get_title_font_filename(projectm_handle instance)
+{
+ auto projectMInstance = handle_to_instance(instance);
+ return projectm_alloc_string_from_std_string(projectMInstance->settings().titleFontURL);
+}
+
+const char* projectm_get_menu_font_filename(projectm_handle instance)
+{
+ auto projectMInstance = handle_to_instance(instance);
+ return projectm_alloc_string_from_std_string(projectMInstance->settings().menuFontURL);
+}
+
+const char* projectm_get_data_dir_path(projectm_handle instance)
+{
+ auto projectMInstance = handle_to_instance(instance);
+ return projectm_alloc_string_from_std_string(projectMInstance->settings().datadir);
+}
+
+void projectm_set_aspect_correction(projectm_handle instance, bool enabled)
+{
+ auto projectMInstance = handle_to_instance(instance);
+ projectMInstance->setAspectCorrection(enabled);
+}
+
+bool projectm_get_aspect_correction(projectm_handle instance)
+{
+ auto projectMInstance = handle_to_instance(instance);
+ return projectMInstance->getAspectCorrection();
+}
+
+void projectm_set_easter_egg(projectm_handle instance, float value)
+{
+ auto projectMInstance = handle_to_instance(instance);
+ projectMInstance->setEasterEgg(value);
+}
+
+float projectm_get_easter_egg(projectm_handle instance)
+{
+ auto projectMInstance = handle_to_instance(instance);
+ return projectMInstance->getEasterEgg();
}
void projectm_touch(projectm_handle instance, float x, float y, int pressure, projectm_touch_type touch_type)
@@ -322,11 +436,11 @@ projectm_settings* projectm_get_settings(projectm_handle instance)
settingsStruct->title_font_url = projectm_alloc_string_from_std_string(settings.titleFontURL);
settingsStruct->menu_font_url = projectm_alloc_string_from_std_string(settings.menuFontURL);
settingsStruct->data_dir = projectm_alloc_string_from_std_string(settings.datadir);
- settingsStruct->smooth_preset_duration = settings.smoothPresetDuration;
+ settingsStruct->soft_cut_duration = settings.softCutDuration;
settingsStruct->preset_duration = settings.presetDuration;
- settingsStruct->hardcut_enabled = settings.hardcutEnabled;
- settingsStruct->hardcut_duration = settings.hardcutDuration;
- settingsStruct->hardcut_sensitivity = settings.hardcutSensitivity;
+ settingsStruct->hard_cut_enabled = settings.hardCutEnabled;
+ settingsStruct->hard_cut_duration = settings.hardCutDuration;
+ settingsStruct->hard_cut_sensitivity = settings.hardCutSensitivity;
settingsStruct->beat_sensitivity = settings.beatSensitivity;
settingsStruct->aspect_correction = settings.aspectCorrection;
settingsStruct->easter_egg = settings.easterEgg;
@@ -349,11 +463,11 @@ void projectm_write_config(const char* config_file, const projectm_settings* set
cppSettings.titleFontURL = settings->title_font_url ? settings->title_font_url : "";
cppSettings.menuFontURL = settings->menu_font_url ? settings->menu_font_url : "";
cppSettings.datadir = settings->data_dir ? settings->data_dir : "";
- cppSettings.smoothPresetDuration = settings->smooth_preset_duration;
+ cppSettings.softCutDuration = settings->soft_cut_duration;
cppSettings.presetDuration = settings->preset_duration;
- cppSettings.hardcutEnabled = settings->hardcut_enabled;
- cppSettings.hardcutDuration = settings->hardcut_duration;
- cppSettings.hardcutSensitivity = settings->hardcut_sensitivity;
+ cppSettings.hardCutEnabled = settings->hard_cut_enabled;
+ cppSettings.hardCutDuration = settings->hard_cut_duration;
+ cppSettings.hardCutSensitivity = settings->hard_cut_sensitivity;
cppSettings.beatSensitivity = settings->beat_sensitivity;
cppSettings.aspectCorrection = settings->aspect_correction;
cppSettings.easterEgg = settings->easter_egg;
@@ -433,6 +547,12 @@ void projectm_select_preset_by_name(projectm_handle instance, const char* preset
return projectMInstance->selectPresetByName(preset_name, hard_cut);
}
+const char* projectm_get_search_text(projectm_handle instance)
+{
+ auto projectMInstance = handle_to_instance(instance);
+ return projectm_alloc_string_from_std_string(projectMInstance->getSearchText());
+}
+
void projectm_set_search_text(projectm_handle instance, const char* search_text)
{
if (!search_text)
@@ -456,7 +576,7 @@ void projectm_reset_search_text(projectm_handle instance)
return projectMInstance->resetSearchText();
}
-bool projectm_selected_preset_index(projectm_handle instance, unsigned int* index)
+bool projectm_get_selected_preset_index(projectm_handle instance, unsigned int* index)
{
if (!index)
{
@@ -515,7 +635,7 @@ bool projectm_preset_position_valid(projectm_handle instance)
return projectMInstance->presetPositionValid();
}
-const char* projectm_get_preset_url(projectm_handle instance, unsigned int index)
+const char* projectm_get_preset_filename(projectm_handle instance, unsigned int index)
{
auto projectMInstance = handle_to_instance(instance);
return projectm_alloc_string_from_std_string(projectMInstance->getPresetURL(index));
@@ -527,7 +647,7 @@ const char* projectm_get_preset_name(projectm_handle instance, unsigned int inde
return projectm_alloc_string_from_std_string(projectMInstance->getPresetName(index));
}
-void projectm_change_preset_name(projectm_handle instance, unsigned int index, const char* name)
+void projectm_set_preset_name(projectm_handle instance, unsigned int index, const char* name)
{
auto projectMInstance = handle_to_instance(instance);
projectMInstance->changePresetName(index, name);
@@ -539,8 +659,8 @@ int projectm_get_preset_rating(projectm_handle instance, unsigned int index, pro
return projectMInstance->getPresetRating(index, static_cast Frees the memory allocated by a call to projectm_alloc_string() or any
- * (const) char* pointers returned by an API call.
Do not use free() to delete the pointer!
* @@ -138,7 +140,11 @@ PROJECTM_EXPORT void projectm_free_string(const char* str); /** * @brief Allocates memory for a projectm_settings struct and returns the pointer. * - * To free the allocated memory, call projectm_free_settings(). Do not use free()! + *This will not allocate memory for the char* members in the struct. These will be set to NULL initially. + * To store a string in these members, use projectm_alloc_string() to allocate the required memory. Do not use + * malloc()!
+ * + *To free the allocated memory, call projectm_free_settings(). Do not use free()!
* * @return A pointer to a zero-initialized projectm_settings struct. */ @@ -293,15 +299,13 @@ PROJECTM_EXPORT void projectm_set_preset_rating_changed_event_callback(projectm_ /** * @brief Reset the projectM OpenGL renderer. * - * Required if anything invalidates the state of the current OpenGL context projectM is rendering to. - * This is the case on window resizes, restoring a window from minimized state or other events that - * required recreating of OpenGL objects. + *Required if anything invalidates the state of the current OpenGL context projectM is rendering to.
+ * + *For resize events, it is sufficient to call projectm_set_window_size()
* * @param instance The projectM instance handle. - * @param width The rendering viewport width. - * @param height The rendering viewport height. */ -PROJECTM_EXPORT void projectm_reset_gl(projectm_handle instance, int width, int height); +PROJECTM_EXPORT void projectm_reset_gl(projectm_handle instance); /** @@ -313,6 +317,13 @@ PROJECTM_EXPORT void projectm_reset_gl(projectm_handle instance, int width, int */ PROJECTM_EXPORT void projectm_reset_textures(projectm_handle instance); +/** + * @brief Returns the current title text. + * @param instance The projectM instance handle. + * @return The currently set title text. + */ +PROJECTM_EXPORT const char* projectm_get_title(projectm_handle instance); + /** * @brief Sets the current title text and displays it. * @param instance The projectM instance handle. @@ -344,11 +355,11 @@ PROJECTM_EXPORT unsigned int projectm_init_render_to_texture(projectm_handle ins /** * @brief Key handler that processes user input. * - * This method can be used to send user input in the host application to projectM, for example - * to switch presets, display the help and search menus or change settings like beat sensitivity. + *This method can be used to send user input in the host application to projectM, for example + * to switch presets, display the help and search menus or change settings like beat sensitivity.
* - * All actions executed by the key handler can also be run programmatically if the host application - * is not able to redirect keyboard input to projectM. + *All actions executed by the key handler can also be run programmatically if the host application + * is not able to redirect keyboard input to projectM.
* * @param instance The projectM instance handle. * @param event The key event, valid are either PROJECTM_KEYUP or PROJECTM_KEYDOWN. @@ -361,11 +372,11 @@ PROJECTM_EXPORT void projectm_key_handler(projectm_handle instance, projectMEven /** * @brief Default key handler that processes user input. * - * This method can be used to send user input in the host application to projectM, for example - * to switch presets, display the help and search menus or change settings like beat sensitivity. + *This method can be used to send user input in the host application to projectM, for example + * to switch presets, display the help and search menus or change settings like beat sensitivity.
* - * All actions executed by the key handler can also be run programmatically if the host application - * is not able to redirect keyboard input to projectM. + *All actions executed by the key handler can also be run programmatically if the host application + * is not able to redirect keyboard input to projectM.
* * @param instance The projectM instance handle. * @param event The key event, valid are either PROJECTM_KEYUP or PROJECTM_KEYDOWN. @@ -373,13 +384,28 @@ PROJECTM_EXPORT void projectm_key_handler(projectm_handle instance, projectMEven */ PROJECTM_EXPORT void projectm_default_key_handler(projectm_handle instance, projectMEvent event, projectMKeycode keycode); + +/** + * @brief Returns the size of the internal render texture. + * @param instance The projectM instance handle. + * @return The size of the internal rendering texture. + */ +PROJECTM_EXPORT size_t projectm_get_texture_size(projectm_handle instance); + /** * @brief Changes the size of the internal render texture. * @note This will recreate the internal renderer. * @param instance The projectM instance handle. * @param size The new size of the render texture. Must be a power of 2. */ -PROJECTM_EXPORT void projectm_set_texture_size(projectm_handle instance, int size); +PROJECTM_EXPORT void projectm_set_texture_size(projectm_handle instance, size_t size); + +/** + * @brief Returns the minimum display time before a hard cut can happen. + * @param instance The projectM instance handle. + * @return The minimum number of seconds the preset will be displayed before a hard cut. + */ +PROJECTM_EXPORT double projectm_get_hard_cut_duration(projectm_handle instance); /** * @brief Sets the minimum display time before a hard cut can happen. @@ -392,22 +418,162 @@ PROJECTM_EXPORT void projectm_set_texture_size(projectm_handle instance, int siz * @param instance The projectM instance handle. * @param seconds Minimum number of seconds the preset will be displayed before a hard cut. */ -PROJECTM_EXPORT void projectm_set_hardcut_duration(projectm_handle instance, double seconds); +PROJECTM_EXPORT void projectm_set_hard_cut_duration(projectm_handle instance, double seconds); + +/** + * @brief Returns whether hard cuts are enabled or not. + * @param instance The projectM instance handle. + * @return True if hard cuts are enabled, false otherwise. + */ +PROJECTM_EXPORT bool projectm_get_hard_cut_enabled(projectm_handle instance); + +/** + * @brief Enables or disables hard cuts. + * + * Even if enabled, the hard cut duration must be set to a value lower than the preset duration + * to work properly. + * + * @param instance The projectM instance handle. + * @param enabled True to enable hard cuts, false to disable. + */ +PROJECTM_EXPORT void projectm_set_hard_cut_enabled(projectm_handle instance, bool enabled); + +/** + * @brief Returns the current hard cut sensitivity. + * @param instance The projectM instance handle. + * @return The current hard cut sensitivity. + */ +PROJECTM_EXPORT float projectm_get_hard_cut_sensitivity(projectm_handle instance); + +/** + * @brief Sets the hard cut volume sensitivity. + * + * The beat detection volume difference that must be surpassed to trigger a hard cut. + * + * @param instance The projectM instance handle. + * @param sensitivity The volume threshold that triggers a hard cut if surpassed. + */ +PROJECTM_EXPORT void projectm_set_hard_cut_sensitivity(projectm_handle instance, float sensitivity); + +/** + * @brief Returns the time in seconds for a soft transition between two presets. + * @param instance The projectM instance handle. + * @return Time in seconds it takes to smoothly transition from one preset to another. + */ +PROJECTM_EXPORT double projectm_get_soft_cut_duration(projectm_handle instance); + +/** + * @brief Sets the time in seconds for a soft transition between two presets. + * + * During a soft cut, both presets are rendered and slowly transitioned from one + * to the other. + * + * @param instance The projectM instance handle. + * @param seconds Time in seconds it takes to smoothly transition from one preset to another. + */ +PROJECTM_EXPORT void projectm_set_soft_cut_duration(projectm_handle instance, double seconds); /** * @brief Sets the preset display duration before switching to the next using a soft cut. + * + * This can be considered as the maximum time a preset is displayed. If this time is reached, + * a smooth cut will be initiated. A hard cut, if any, will always happen before this time. + * * @param instance The projectM instance handle. * @param seconds The number of seconds a preset will be displayed before the next is shown. */ PROJECTM_EXPORT void projectm_set_preset_duration(projectm_handle instance, double seconds); /** - * @brief returns the per-pixel equation mesh size in units. + * @brief Returns the per-pixel equation mesh size in units. * @param instance The projectM instance handle. * @param width The width of the mesh. * @param height The height of the mesh. */ -PROJECTM_EXPORT void projectm_get_mesh_size(projectm_handle instance, int* width, int* height); +PROJECTM_EXPORT void projectm_get_mesh_size(projectm_handle instance, size_t* width, size_t* height); + +/** + * @brief Sets the per-pixel equation mesh size in units. + * @note This will recreate the renderer. + * @param instance The projectM instance handle. + * @param width The new width of the mesh. + * @param height The new height of the mesh. + */ +PROJECTM_EXPORT void projectm_set_mesh_size(projectm_handle instance, size_t width, size_t height); + +/** + * @brief Returns the target frames per second count. + * @note This is not the actual FPS, but the targeted refresh framerate if the integrating application. + * @param instance The projectM instance handle. + */ +PROJECTM_EXPORT size_t projectm_get_fps(projectm_handle instance); + +/** + * @brief Returns the search path for presets and textures. + * @param instance The projectM instance handle. + * @return The path used to search for presets and textures. + */ +PROJECTM_EXPORT const char* projectm_get_preset_path(projectm_handle instance); + +/** + * @brief Returns the path and filename of the font used to render the title overlay text. + * @param instance The projectM instance handle. + * @return The path and filename of the title text font. + */ +PROJECTM_EXPORT const char* projectm_get_title_font_filename(projectm_handle instance); + +/** + * @brief Returns the path and filename of the font used to render the menu overlay text. + * @param instance The projectM instance handle. + * @return The path and filename of the menu text font. + */ +PROJECTM_EXPORT const char* projectm_get_menu_font_filename(projectm_handle instance); + +/** + * @brief Returns the path projectM uses to search for additional data. + * @param instance The projectM instance handle. + * @return The data dir path. + */ +PROJECTM_EXPORT const char* projectm_get_data_dir_path(projectm_handle instance); + +/** + * @brief Enabled or disables aspect ratio correction in presets that support it. + * + * This sets a flag presets can use to aspect-correct rendered shapes, which otherwise would + * be distorted if the viewport isn't exactly square. + * + * @param instance The projectM instance handle. + * @param enabled True to enable aspect correction, false to disable it. + */ +PROJECTM_EXPORT void projectm_set_aspect_correction(projectm_handle instance, bool enabled); + +/** + * @brief Returns whether aspect ratio correction is enabled or not. + * @param instance The projectM instance handle. + * @return True if aspect ratio correction is enabled, false otherwise. + */ +PROJECTM_EXPORT bool projectm_get_aspect_correction(projectm_handle instance); + +/** + * @brief Sets the "easter egg" value. + * + *This doesn't enable any fancy feature, it only influences the randomized display time of presets. It's + * passed as the "sigma" value of the gaussian random number generator used to determine the maximum display time, + * effectively multiplying the generated number of seconds by this amount.
+ * + *See function sampledPresetDuration() of the TimeKeeper class on how it is used.
+ * + * @param instance The projectM instance handle. + * @param value The new "easter egg" value. + */ +PROJECTM_EXPORT void projectm_set_easter_egg(projectm_handle instance, float value); + +/** + * @brief Returns the current "easter egg" value. + * @param instance The projectM instance handle. + * @return The current "easter egg" value. + */ +PROJECTM_EXPORT float projectm_get_easter_egg(projectm_handle instance); /** * @brief Starts a touch event or moves an existing waveform. @@ -573,6 +739,13 @@ PROJECTM_EXPORT unsigned int projectm_get_preset_index(projectm_handle instance, */ PROJECTM_EXPORT void projectm_select_preset_by_name(projectm_handle instance, const char* preset_name, bool hard_cut); +/** + * @brief Returns the current preset search text. + * @param instance The projectM instance handle. + * @return The current search text used to search for presets in the playlist. + */ +PROJECTM_EXPORT const char* projectm_get_search_text(projectm_handle instance); + /** * @brief Sets the current preset search text. * @param instance The projectM instance handle. @@ -604,7 +777,7 @@ PROJECTM_EXPORT void projectm_reset_search_text(projectm_handle instance); * @param index A valid pointer to an unsigned int that will receive the preset index. * @return True if a preset idnex was returned, false if no preset was selected, e.g. the playlist is empty. */ -PROJECTM_EXPORT bool projectm_selected_preset_index(projectm_handle instance, unsigned int* index); +PROJECTM_EXPORT bool projectm_get_selected_preset_index(projectm_handle instance, unsigned int* index); /** * @brief Adds a new preset at the end of the playlist. @@ -658,7 +831,8 @@ PROJECTM_EXPORT bool projectm_preset_position_valid(projectm_handle instance); * @param index The playlist index to return the filename for. * @return The full path and filename of the preset at the given index. */ -PROJECTM_EXPORT const char* projectm_get_preset_url(projectm_handle instance, unsigned int index); +PROJECTM_EXPORT const char* projectm_get_preset_filename(projectm_handle instance, unsigned int index); + /** * @brief Returns the display name of the preset at the requested playlist index. * @note Make sure the index is inside the playlist bounds! @@ -674,7 +848,7 @@ PROJECTM_EXPORT const char* projectm_get_preset_name(projectm_handle instance, u * @param index the playlist item index to change. * @param name The new display name. */ -PROJECTM_EXPORT void projectm_change_preset_name(projectm_handle instance, unsigned int index, const char* name); +PROJECTM_EXPORT void projectm_set_preset_name(projectm_handle instance, unsigned int index, const char* name); /** * @brief Returns the rating for the given index and transition type. @@ -693,8 +867,8 @@ PROJECTM_EXPORT int projectm_get_preset_rating(projectm_handle instance, unsigne * @param rating The new rating value. * @param rating_type The type of the rating, either hard or soft cut. */ -PROJECTM_EXPORT void projectm_change_preset_rating(projectm_handle instance, unsigned int index, int rating, - projectm_preset_rating_type rating_type); +PROJECTM_EXPORT void projectm_set_preset_rating(projectm_handle instance, unsigned int index, int rating, + projectm_preset_rating_type rating_type); /** * @brief Returns the number of presets in the current playlist. @@ -703,6 +877,13 @@ PROJECTM_EXPORT void projectm_change_preset_rating(projectm_handle instance, uns */ PROJECTM_EXPORT unsigned int projectm_get_playlist_size(projectm_handle instance); +/** + * @brief Returns whether playlist shuffling is currently enabled or not. + * @param instance The projectM instance handle. + * @return True if shuffle is enabled, false if not. + */ +PROJECTM_EXPORT bool projectm_get_shuffle_enabled(projectm_handle instance); + /** * @brief Enables or disables preset playlist shuffling. * @param instance The projectM instance handle. @@ -710,13 +891,6 @@ PROJECTM_EXPORT unsigned int projectm_get_playlist_size(projectm_handle instance */ PROJECTM_EXPORT void projectm_set_shuffle_enabled(projectm_handle instance, bool shuffle_enabled); -/** - * @brief Returns whether playlist shuffling is currently enabled or not. - * @param instance The projectM instance handle. - * @return True if shuffle is enabled, false if not. - */ -PROJECTM_EXPORT bool projectm_is_shuffle_enabled(projectm_handle instance); - /** * @brief Gets the index of the provided preset name in the current search result list. * @param instance The projectM instance handle. @@ -733,7 +907,7 @@ PROJECTM_EXPORT unsigned int projectm_get_search_index(projectm_handle instance, * @param instance The projectM instance handle. * @param hard_cut True to immediately perform to the previous preset, false to do a soft transition. */ -PROJECTM_EXPORT void projectm_select_previous(projectm_handle instance, bool hard_cut); +PROJECTM_EXPORT void projectm_select_previous_preset(projectm_handle instance, bool hard_cut); /** * @brief Switches to the next preset in the current playlist. @@ -743,7 +917,7 @@ PROJECTM_EXPORT void projectm_select_previous(projectm_handle instance, bool har * @param instance The projectM instance handle. * @param hard_cut True to immediately perform to the next preset, false to do a soft transition. */ -PROJECTM_EXPORT void projectm_select_next(projectm_handle instance, bool hard_cut); +PROJECTM_EXPORT void projectm_select_next_preset(projectm_handle instance, bool hard_cut); /** * @brief Switches to a random preset in the current playlist. @@ -753,21 +927,26 @@ PROJECTM_EXPORT void projectm_select_next(projectm_handle instance, bool hard_cu * @param instance The projectM instance handle. * @param hard_cut True to immediately perform to a random preset, false to do a soft transition. */ -PROJECTM_EXPORT void projectm_select_random(projectm_handle instance, bool hard_cut); +PROJECTM_EXPORT void projectm_select_random_preset(projectm_handle instance, bool hard_cut); /** - * @brief Returns the current viewport width in pixels. + * @brief Returns the current viewport size in pixels. * @param instance The projectM instance handle. - * @return The viewport width in pixels. + * @param width Valid pointer to a size_t variable that will receive the window width value. + * @param height Valid pointer to a size_t variable that will receive the window height value. */ -PROJECTM_EXPORT int projectm_get_window_width(projectm_handle instance); +PROJECTM_EXPORT void projectm_get_window_size(projectm_handle instance, size_t* width, size_t* height); /** - * @brief Returns the current viewport height in pixels. + * @brief Sets the current viewport size in pixels. + * + * Calling this function will reset the OpenGL renderer. + * * @param instance The projectM instance handle. - * @return The viewport height in pixels. + * @param width New viewport width in pixels. + * @param height New viewport height in pixels. */ -PROJECTM_EXPORT int projectm_get_window_height(projectm_handle instance); +PROJECTM_EXPORT void projectm_set_window_size(projectm_handle instance, size_t width, size_t height); /** * @brief Returns whether the current preset was loaded successfully or not. diff --git a/src/libprojectM/projectM.hpp b/src/libprojectM/projectM.hpp index 89f2b5fe1..dbb828ae0 100644 --- a/src/libprojectM/projectM.hpp +++ b/src/libprojectM/projectM.hpp @@ -121,55 +121,40 @@ public: static const int FLAG_NONE = 0; static const int FLAG_DISABLE_PLAYLIST_LOAD = 1 << 0; - struct Settings { - int meshX; - int meshY; - int fps; - int textureSize; - int windowWidth; - int windowHeight; + class Settings { + public: + size_t meshX{ 32 }; + size_t meshY{ 24 }; + size_t fps{ 35 }; + size_t textureSize{ 512 }; + size_t windowWidth{ 512 }; + size_t windowHeight{ 512 }; std::string presetURL; std::string titleFontURL; std::string menuFontURL; std::string datadir; - double smoothPresetDuration; - double presetDuration; - bool hardcutEnabled; - int hardcutDuration; - float hardcutSensitivity; - float beatSensitivity; - bool aspectCorrection; - float easterEgg; - bool shuffleEnabled; - bool softCutRatingsEnabled; - - Settings() : - meshX(32), - meshY(24), - fps(35), - textureSize(512), - windowWidth(512), - windowHeight(512), - smoothPresetDuration(10.0), - presetDuration(15.0), - hardcutEnabled(false), - hardcutDuration(60), - hardcutSensitivity(2.0), - beatSensitivity(1.0), - aspectCorrection(true), - easterEgg(0.0), - shuffleEnabled(true), - softCutRatingsEnabled(false) {} - }; + double presetDuration{ 15.0 }; + double softCutDuration{ 10.0 }; + double hardCutDuration{ 60.0 }; + bool hardCutEnabled{ false }; + float hardCutSensitivity{ 2.0 }; + float beatSensitivity{ 1.0 }; + bool aspectCorrection{ true }; + float easterEgg{ 0.0 }; + bool shuffleEnabled{ true }; + bool softCutRatingsEnabled{ false }; + }; projectM(std::string config_file, int flags = FLAG_NONE); projectM(Settings settings, int flags = FLAG_NONE); virtual ~projectM(); - void projectM_resetGL( int width, int height ); + void projectM_resetGL(size_t width, size_t height); void projectM_resetTextures(); - void projectM_setTitle( std::string title ); + + std::string getTitle() const; + void setTitle(const std::string& title); void renderFrame(); Pipeline * renderFrameOnlyPass1(Pipeline *pPipeline); void renderFrameOnlyPass2(Pipeline *pPipeline,int xoffset,int yoffset,int eye); @@ -178,12 +163,26 @@ public: void key_handler( projectMEvent event, projectMKeycode keycode, projectMModifier modifier ); - void changeTextureSize(int size); - void changeHardcutDuration(int seconds); - void changeHardcutDuration(double seconds); - void changePresetDuration(int seconds); - void changePresetDuration(double seconds); - void getMeshSize(int *w, int *h); + void setTextureSize(size_t size); + size_t getTextureSize() const; + double getSoftCutDuration() const; + void setSoftCutDuration(int seconds); + void setSoftCutDuration(double seconds); + double getHardCutDuration() const; + void setHardCutDuration(int seconds); + void setHardCutDuration(double seconds); + bool getHardCutEnabled() const; + void setHardCutEnabled(bool enabled); + float getHardCutSensitivity() const; + void setHardCutSensitivity(float sensitivity); + void setPresetDuration(int seconds); + void setPresetDuration(double seconds); + bool getAspectCorrection() const; + void setAspectCorrection(bool enabled); + float getEasterEgg() const; + void setEasterEgg(float value); + void getMeshSize(size_t& w, size_t& h) const; + void setMeshSize(size_t w, size_t h); void touch(float x, float y, int pressure, int touchtype); void touchDrag(float x, float y, int pressure); void touchDestroy(float x, float y); @@ -239,6 +238,8 @@ public: /// Plays a preset immediately when given preset name void selectPresetByName(std::string name, bool hardCut = true); + // search based on keystroke + std::string getSearchText() const; // search based on keystroke void setSearchText(const std::string & searchKey); // delete part of search term (backspace) @@ -395,7 +396,7 @@ private: std::unique_ptr