Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/api/include/projectM-4/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,30 @@ PROJECTM_EXPORT void projectm_set_window_size(projectm_handle instance, size_t w
*/
PROJECTM_EXPORT void projectm_get_window_size(projectm_handle instance, size_t* width, size_t* height);

/**
* @brief Sets whether newly loaded presets should start with a clean (black) canvas.
*
* By default, when switching presets, the last frame of the previous preset is copied into
* the new preset's main texture, creating a visual continuity. Setting this flag to true
* will cause each new preset to start with a black canvas instead.
*
* This is useful for applications that want a clean start for each preset, avoiding the
* "ghosting" effect from the previous preset.
*
* @param instance The projectM instance handle.
* @param enabled True to start new presets with a clean canvas, false to copy the previous frame. Default: false
* @since 4.2.0
*/
PROJECTM_EXPORT void projectm_set_preset_start_clean(projectm_handle instance, bool enabled);

/**
* @brief Returns whether newly loaded presets start with a clean canvas.
* @param instance The projectM instance handle.
* @return True if presets start with a clean canvas, false if the previous frame is copied.
* @since 4.2.0
*/
PROJECTM_EXPORT bool projectm_get_preset_start_clean(projectm_handle instance);

#ifdef __cplusplus
} // extern "C"
#endif
12 changes: 11 additions & 1 deletion src/libprojectM/ProjectM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ void ProjectM::StartPresetTransition(std::unique_ptr<Preset>&& preset, bool hard
m_transition.reset();
}

if (m_activePreset)
if (m_activePreset && !m_presetStartClean)
{
preset->DrawInitialImage(m_activePreset->OutputTexture(), GetRenderContext());
}
Expand Down Expand Up @@ -367,6 +367,16 @@ auto ProjectM::PresetLocked() const -> bool
return m_presetLocked;
}

void ProjectM::SetPresetStartClean(bool enabled)
{
m_presetStartClean = enabled;
}

auto ProjectM::PresetStartClean() const -> bool
{
return m_presetStartClean;
}

void ProjectM::SetFrameTime(double secondsSinceStart)
{
m_timeKeeper->SetFrameTime(secondsSinceStart);
Expand Down
13 changes: 13 additions & 0 deletions src/libprojectM/ProjectM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,18 @@ class PROJECTM_EXPORT ProjectM
/// Returns true if the active preset is locked
auto PresetLocked() const -> bool;

/**
* @brief Sets whether newly loaded presets should start with a clean (black) canvas.
* @param enabled True to start with a clean canvas, false to copy the previous frame.
*/
void SetPresetStartClean(bool enabled);

/**
* @brief Returns whether newly loaded presets start with a clean canvas.
* @return True if presets start with a clean canvas.
*/
auto PresetStartClean() const -> bool;

auto PCM() -> Audio::PCM&;

auto WindowWidth() -> int;
Expand Down Expand Up @@ -290,6 +302,7 @@ class PROJECTM_EXPORT ProjectM

bool m_presetLocked{false}; //!< If true, the preset change event will not be sent.
bool m_presetChangeNotified{false}; //!< Stores whether the user has been notified that projectM wants to switch the preset.
bool m_presetStartClean{false}; //!< If true, new presets start with a black canvas instead of the previous frame.

std::unique_ptr<PresetFactoryManager> m_presetFactoryManager; //!< Provides access to all available preset factories.

Expand Down
12 changes: 12 additions & 0 deletions src/libprojectM/ProjectMCWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,18 @@ void projectm_set_window_size(projectm_handle instance, size_t width, size_t hei
projectMInstance->SetWindowSize(static_cast<uint32_t>(width), static_cast<uint32_t>(height));
}

void projectm_set_preset_start_clean(projectm_handle instance, bool enabled)
{
auto projectMInstance = handle_to_instance(instance);
projectMInstance->SetPresetStartClean(enabled);
}

bool projectm_get_preset_start_clean(projectm_handle instance)
{
auto projectMInstance = handle_to_instance(instance);
return projectMInstance->PresetStartClean();
}

unsigned int projectm_pcm_get_max_samples()
{
return libprojectM::Audio::WaveformSamples;
Expand Down
Loading