Vital
Loading...
Searching...
No Matches
SynthGuiInterface Class Reference

An interface class linking the Vital synthesizer backend (SynthBase) with a GUI. More...

#include <synth_gui_interface.h>

Inheritance diagram for SynthGuiInterface:
SynthEditor SynthEditor

Public Member Functions

 SynthGuiInterface (SynthBase *synth, bool use_gui=true)
 Constructs the SynthGuiInterface, optionally creating a FullInterface GUI.
 
virtual ~SynthGuiInterface ()
 Destroys the SynthGuiInterface, cleaning up any associated GUI resources.
 
virtual AudioDeviceManager * getAudioDeviceManager ()
 Retrieves the audio device manager if available.
 
SynthBasegetSynth ()
 Returns the SynthBase instance this interface is managing.
 
virtual void updateFullGui ()
 Updates the entire GUI to reflect the current synth state.
 
virtual void updateGuiControl (const std::string &name, vital::mono_float value)
 Updates a single GUI control to reflect a new parameter value.
 
vital::mono_float getControlValue (const std::string &name)
 Retrieves the current value of a named control from the synth.
 
void notifyModulationsChanged ()
 Notifies the GUI that modulation connections or states have changed.
 
void notifyModulationValueChanged (int index)
 Notifies the GUI that a specific modulation's value changed.
 
void connectModulation (std::string source, std::string destination)
 Connects a modulation source to a destination parameter through the GUI.
 
void connectModulation (vital::ModulationConnection *connection)
 Connects a modulation using a pre-existing ModulationConnection object.
 
void setModulationValues (const std::string &source, const std::string &destination, vital::mono_float amount, bool bipolar, bool stereo, bool bypass)
 Sets various modulation parameters (amount, bipolar, stereo, bypass) for a given connection.
 
void initModulationValues (const std::string &source, const std::string &destination)
 Initializes modulation values for a newly created modulation connection.
 
void disconnectModulation (std::string source, std::string destination)
 Disconnects a modulation from the GUI layer.
 
void disconnectModulation (vital::ModulationConnection *connection)
 Disconnects a modulation using a ModulationConnection object.
 
void setFocus ()
 Brings the GUI window or main component into focus.
 
void notifyChange ()
 Notifies the GUI that a parameter or modulation changed, prompting GUI updates.
 
void notifyFresh ()
 Notifies the GUI that a fresh state (like a new preset load) has occurred, prompting a full refresh.
 
void openSaveDialog ()
 Opens a save dialog (e.g., to save a preset) through the GUI.
 
void externalPresetLoaded (File preset)
 Notifies the GUI that a preset was loaded externally (outside the GUI controls).
 
void setGuiSize (float scale)
 Sets the GUI window or component size based on a scale factor.
 
FullInterfacegetGui ()
 Gets the FullInterface GUI component if it exists.
 

Protected Attributes

SynthBasesynth_
 The backend SynthBase this GUI interface controls.
 
std::unique_ptr< FullInterfacegui_
 The primary GUI component (if applicable).
 

Detailed Description

An interface class linking the Vital synthesizer backend (SynthBase) with a GUI.

SynthGuiInterface provides methods to:

  • Update GUI controls based on internal parameter changes.
  • Notify the GUI of changes to modulations and parameters.
  • Connect and disconnect modulations through GUI interactions.
  • Load and save presets, including invoking dialog boxes if applicable.

On some builds (HEADLESS mode), these functionalities may be stubbed out, meaning the GUI does nothing. When GUI is available, it typically integrates with a FullInterface GUI component that displays and updates Vital’s parameters and states.

Constructor & Destructor Documentation

◆ SynthGuiInterface()

SynthGuiInterface::SynthGuiInterface ( SynthBase * synth,
bool use_gui = true )

Constructs the SynthGuiInterface, optionally creating a FullInterface GUI.

Parameters
synthA pointer to the SynthBase instance to manage GUI for.
use_guiIf true, constructs a GUI interface. If false (or HEADLESS), no GUI is created.

◆ ~SynthGuiInterface()

SynthGuiInterface::~SynthGuiInterface ( )
virtual

Destroys the SynthGuiInterface, cleaning up any associated GUI resources.

Member Function Documentation

◆ connectModulation() [1/2]

void SynthGuiInterface::connectModulation ( std::string source,
std::string destination )

Connects a modulation source to a destination parameter through the GUI.

If a new modulation connection is created, the GUI may initialize default modulation values.

Parameters
sourceThe modulation source name.
destinationThe destination parameter name.

◆ connectModulation() [2/2]

void SynthGuiInterface::connectModulation ( vital::ModulationConnection * connection)

Connects a modulation using a pre-existing ModulationConnection object.

Parameters
connectionPointer to the ModulationConnection to connect.

◆ disconnectModulation() [1/2]

void SynthGuiInterface::disconnectModulation ( std::string source,
std::string destination )

Disconnects a modulation from the GUI layer.

Parameters
sourceThe modulation source name.
destinationThe destination parameter name.

◆ disconnectModulation() [2/2]

void SynthGuiInterface::disconnectModulation ( vital::ModulationConnection * connection)

Disconnects a modulation using a ModulationConnection object.

Parameters
connectionPointer to the ModulationConnection to disconnect.

◆ externalPresetLoaded()

void SynthGuiInterface::externalPresetLoaded ( File preset)

Notifies the GUI that a preset was loaded externally (outside the GUI controls).

Parameters
presetThe preset file that was loaded.

◆ getAudioDeviceManager()

virtual AudioDeviceManager * SynthGuiInterface::getAudioDeviceManager ( )
inlinevirtual

Retrieves the audio device manager if available.

By default, this returns nullptr. Subclasses or custom builds might return a valid manager.

Returns
A pointer to the AudioDeviceManager or nullptr if not implemented.

Reimplemented in SynthEditor.

◆ getControlValue()

vital::mono_float SynthGuiInterface::getControlValue ( const std::string & name)

Retrieves the current value of a named control from the synth.

Parameters
nameThe parameter/control name.
Returns
The current control value.

◆ getGui()

FullInterface * SynthGuiInterface::getGui ( )
inline

Gets the FullInterface GUI component if it exists.

Returns
A pointer to the FullInterface object or nullptr if no GUI is in use.

◆ getSynth()

SynthBase * SynthGuiInterface::getSynth ( )
inline

Returns the SynthBase instance this interface is managing.

Returns
A pointer to the managed SynthBase.

◆ initModulationValues()

void SynthGuiInterface::initModulationValues ( const std::string & source,
const std::string & destination )

Initializes modulation values for a newly created modulation connection.

Resets line mappings and other parameters to default linear states.

Parameters
sourceThe modulation source name.
destinationThe parameter to modulate.

◆ notifyChange()

void SynthGuiInterface::notifyChange ( )

Notifies the GUI that a parameter or modulation changed, prompting GUI updates.

◆ notifyFresh()

void SynthGuiInterface::notifyFresh ( )

Notifies the GUI that a fresh state (like a new preset load) has occurred, prompting a full refresh.

◆ notifyModulationsChanged()

void SynthGuiInterface::notifyModulationsChanged ( )

Notifies the GUI that modulation connections or states have changed.

This prompts the GUI to refresh displays related to modulation routing or amounts.

◆ notifyModulationValueChanged()

void SynthGuiInterface::notifyModulationValueChanged ( int index)

Notifies the GUI that a specific modulation's value changed.

Parameters
indexThe modulation connection index that changed.

◆ openSaveDialog()

void SynthGuiInterface::openSaveDialog ( )

Opens a save dialog (e.g., to save a preset) through the GUI.

◆ setFocus()

void SynthGuiInterface::setFocus ( )

Brings the GUI window or main component into focus.

◆ setGuiSize()

void SynthGuiInterface::setGuiSize ( float scale)

Sets the GUI window or component size based on a scale factor.

Adjusts the main interface dimensions relative to a default size and current display settings.

Parameters
scaleA scaling factor for the GUI size.

◆ setModulationValues()

void SynthGuiInterface::setModulationValues ( const std::string & source,
const std::string & destination,
vital::mono_float amount,
bool bipolar,
bool stereo,
bool bypass )

Sets various modulation parameters (amount, bipolar, stereo, bypass) for a given connection.

This function updates both the backend and GUI to reflect the new modulation settings.

Parameters
sourceThe modulation source name.
destinationThe parameter to modulate.
amountThe modulation amount.
bipolarTrue for bipolar modulation, false for unipolar.
stereoTrue if modulation is stereo, false if mono.
bypassTrue if modulation is bypassed, false otherwise.

◆ updateFullGui()

void SynthGuiInterface::updateFullGui ( )
virtual

Updates the entire GUI to reflect the current synth state.

This method is typically called after loading a new preset or making significant changes to parameters. It instructs the GUI to refresh all displayed values.

Reimplemented in SynthEditor.

◆ updateGuiControl()

void SynthGuiInterface::updateGuiControl ( const std::string & name,
vital::mono_float value )
virtual

Updates a single GUI control to reflect a new parameter value.

Parameters
nameThe parameter/control name.
valueThe new value to display on the GUI.

Member Data Documentation

◆ gui_

std::unique_ptr<FullInterface> SynthGuiInterface::gui_
protected

The primary GUI component (if applicable).

◆ synth_

SynthBase* SynthGuiInterface::synth_
protected

The backend SynthBase this GUI interface controls.


The documentation for this class was generated from the following files: