hydrogen 1.2.3
CoreActionController Class Reference

#include <CoreActionController.h>

Inheritance diagram for CoreActionController:
Object< CoreActionController > Base

Public Member Functions

 CoreActionController ()
 
 ~CoreActionController ()
 
bool activateJackTimebaseMaster (bool bActivate)
 (De)activates the usage of Jack timebase master.
 
bool activateJackTransport (bool bActivate)
 (De)activates the usage of Jack transport.
 
bool activateLoopMode (bool bActivate)
 Toggle loop mode of playback.
 
bool activateSongMode (bool bActivate)
 Switches between Song and Pattern mode of playback.
 
bool activateTimeline (bool bActivate)
 (De)activates the usage of the Timeline.
 
bool addTag (int nPosition, const QString &sText)
 Adds a tag to the Timeline.
 
bool addTempoMarker (int nPosition, float fBpm)
 Adds a tempo marker to the Timeline.
 
bool deleteTag (int nPosition)
 Delete a tag from the Timeline.
 
bool deleteTempoMarker (int nPosition)
 Delete a tempo marker from the Timeline.
 
bool extractDrumkit (const QString &sDrumkitPath, const QString &sTargetDir="")
 Extracts the compressed .h2drumkit file in sDrumkitPath into sTargetDir.
 
bool initExternalControlInterfaces ()
 
bool locateToColumn (int nPatternGroup)
 Relocates transport to the beginning of a particular column/Pattern group.
 
bool locateToTick (long nTick, bool bWithJackBroadcast=true)
 Relocates transport to a particular tick.
 
bool newPattern (const QString &sPatternName)
 Creates an empty pattern and adds it to the pattern list.
 
bool newSong (const QString &songPath)
 Create an empty H2Core::Song, which will be stored in songPath.
 
bool openPattern (const QString &sPath, int nPatternNumber=-1)
 Opens a pattern from disk and adds it to the pattern list.
 
bool openSong (const QString &songPath, const QString &sRecoverSongPath="")
 Opens the H2Core::Song specified in songPath.
 
bool openSong (std::shared_ptr< Song > pSong, bool bRelinking=true)
 Opens the H2Core::Song specified in songPath.
 
bool quit ()
 Triggers the shutdown of Hydrogen.
 
bool removePattern (int nPatternNumber)
 Removes a pattern from the pattern list.
 
bool savePreferences ()
 Saves the current state of the H2Core::Preferences.
 
bool saveSong ()
 Saves the current H2Core::Song.
 
bool saveSongAs (const QString &sNewFilename)
 Saves the current H2Core::Song to the path provided in sNewFilename.
 
bool setDrumkit (const QString &sDrumkit, bool bConditional=true)
 Wrapper around setDrumkit() that allows loading drumkits by name or path.
 
bool setDrumkit (std::shared_ptr< Drumkit > pDrumkit, bool bConditional=true)
 Sets Drumkit pDrumkit as the one used in the current #Song.
 
bool setMasterIsMuted (bool isMuted)
 
bool setMasterVolume (float masterVolumeValue)
 
bool setMetronomeIsActive (bool isActive)
 
bool setPattern (Pattern *pPattern, int nPatternNumber)
 Opens a pattern to the current pattern list.
 
bool setStripIsMuted (int nStrip, bool isMuted)
 
bool setStripIsSoloed (int nStrip, bool isSoloed)
 
bool setStripPan (int nStrip, float fValue, bool bSelectStrip)
 
bool setStripPanSym (int nStrip, float fValue, bool bSelectStrip)
 
bool setStripVolume (int nStrip, float fVolumeValue, bool bSelectStrip)
 
bool toggleGridCell (int nColumn, int nRow)
 Fills or clears a specific grid cell in the SongEditor.
 
bool toggleStripIsMuted (int nStrip)
 
bool toggleStripIsSoloed (int nStrip)
 
void updatePreferences ()
 In case a different preferences file was loaded with Hydrogen already fully set up this function refreshes all corresponding values and informs the GUI.
 
bool upgradeDrumkit (const QString &sDrumkitPath, const QString &sNewPath="")
 Upgrades the drumkit found at absolute path sDrumkitPath.
 
bool validateDrumkit (const QString &sDrumkitPath, bool bCheckLegacyVersions=false)
 Checks whether the provided drumkit in sDrumkitPath can be found, can be loaded, and does comply with the current XSD definition.
 
- Public Member Functions inherited from Object< CoreActionController >
 Object ()
 
 Object (const Object< CoreActionController > &other)
 
- Public Member Functions inherited from Base
 Base ()
 
 Base (const Base &other)
 
virtual const char * class_name () const
 
void Print (bool bShort=true) const
 Prints content of toQString() via DEBUGLOG.
 
virtual QString toQString (const QString &sPrefix="", bool bShort=true) const
 Formatted string version for debugging purposes.
 

Private Member Functions

std::shared_ptr< InstrumentgetStrip (int nStrip) const
 
bool handleOutgoingControlChanges (std::vector< int > params, int nValue)
 
void insertRecentFile (const QString sFilename)
 Add sFilename to the list of recent songs in Preferences::m_recentFiles.
 
std::shared_ptr< DrumkitretrieveDrumkit (const QString &sDrumkitPath, bool *bIsCompressed, QString *sDrumkitDir, QString *sTemporaryFolder)
 Loads the drumkit specified in sDrumkitPath.
 
bool sendMasterIsMutedFeedback ()
 
bool sendMasterVolumeFeedback ()
 
bool sendMetronomeIsActiveFeedback ()
 
bool sendStripIsMutedFeedback (int nStrip)
 
bool sendStripIsSoloedFeedback (int nStrip)
 
bool sendStripPanFeedback (int nStrip)
 
bool sendStripPanSymFeedback (int nStrip)
 
bool sendStripVolumeFeedback (int nStrip)
 
bool setSong (std::shared_ptr< Song > pSong, bool bRelinking=true)
 Sets a H2Core::Song to be used by Hydrogen.
 

Private Attributes

const int m_nDefaultMidiFeedbackChannel
 

Additional Inherited Members

- Static Public Member Functions inherited from Base
static const char * _class_name ()
 return the class name
 
static QString base_clock (const QString &sMsg)
 Measures the current time and stores it in __last_clock.
 
static QString base_clock_in (const QString &sMsg)
 
static int bootstrap (Logger *logger, bool count=false)
 must be called before any Object instantiation !
 
static bool count_active ()
 
static int getAliveObjectCount ()
 
static object_map_t getObjectMap ()
 
static Loggerlogger ()
 return the logger instance
 
static int objects_count ()
 
static void printObjectMapDiff (object_map_t map)
 Creates the difference between a snapshot of the object map and its current state and prints it to std::cout.
 
static void set_count (bool flag)
 enable/disable class instances counting
 
static void write_objects_map_to (std::ostream &out, object_map_t *map=nullptr)
 output the full objects map to a given ostream
 
static void write_objects_map_to_cerr ()
 output objects map to stderr
 
- Static Public Attributes inherited from Base
static QString sPrintIndention = " "
 String used to format the debugging string output of some core classes.
 
- Protected Member Functions inherited from Object< CoreActionController >
 ~Object ()
 
- Protected Member Functions inherited from Base
 ~Base ()
 
- Static Protected Member Functions inherited from Base
static void registerClass (const char *name, const atomic_obj_cpt_t *counters)
 
- Static Protected Attributes inherited from Base
static bool __count = false
 should we count class instances
 
static timeval __last_clock = { 0, 0 }
 
static Logger__logger = nullptr
 

Detailed Description

Definition at line 38 of file CoreActionController.h.

Constructor & Destructor Documentation

◆ CoreActionController()

Definition at line 51 of file CoreActionController.cpp.

◆ ~CoreActionController()

Definition at line 56 of file CoreActionController.cpp.

Member Function Documentation

◆ activateJackTimebaseMaster()

bool activateJackTimebaseMaster ( bool bActivate)

(De)activates the usage of Jack timebase master.

Note that this function will fail if Jack is not used as audio driver.

Parameters
bActivateIf true - activate or if false - deactivate.
Returns
bool true on success

Definition at line 857 of file CoreActionController.cpp.

◆ activateJackTransport()

bool activateJackTransport ( bool bActivate)

(De)activates the usage of Jack transport.

Note that this function will fail if Jack is not used as audio driver.

Parameters
bActivateIf true - activate or if false - deactivate.
Returns
bool true on success

Definition at line 832 of file CoreActionController.cpp.

◆ activateLoopMode()

bool activateLoopMode ( bool bActivate)

Toggle loop mode of playback.

Parameters
bActivateIf true - activates loop mode.
Returns
bool true on success

Definition at line 921 of file CoreActionController.cpp.

◆ activateSongMode()

bool activateSongMode ( bool bActivate)

Switches between Song and Pattern mode of playback.

Parameters
bActivateIf true - activates Song mode or if false - activates Pattern mode.
Returns
bool true on success

Definition at line 886 of file CoreActionController.cpp.

◆ activateTimeline()

bool activateTimeline ( bool bActivate)

(De)activates the usage of the Timeline.

Note that this function will fail in the presence of the Jack audio driver and an external timebase master (see Hydrogen::getJackTimebaseState()).

Parameters
bActivateIf true - activate or if false - deactivate.
Returns
bool true on success

Definition at line 728 of file CoreActionController.cpp.

◆ addTag()

bool addTag ( int nPosition,
const QString & sText )

Adds a tag to the Timeline.

Parameters
nPositionLocation of the tag in bars.
sTextMessage associated with the tag.
Returns
bool true on success

Definition at line 796 of file CoreActionController.cpp.

◆ addTempoMarker()

bool addTempoMarker ( int nPosition,
float fBpm )

Adds a tempo marker to the Timeline.

Parameters
nPositionLocation of the tempo marker in bars.
fBpmSpeed associated with the tempo marker.
Returns
bool true on success

Definition at line 749 of file CoreActionController.cpp.

◆ deleteTag()

bool deleteTag ( int nPosition)

Delete a tag from the Timeline.

If no tag is present at nPosition, the function will return true as well.

Parameters
nPositionLocation of the tag in bars.
Returns
bool true on success

Definition at line 815 of file CoreActionController.cpp.

◆ deleteTempoMarker()

bool deleteTempoMarker ( int nPosition)

Delete a tempo marker from the Timeline.

If no Tempo marker is present at nPosition, the function will return true as well.

Parameters
nPositionLocation of the tempo marker in bars.
Returns
bool true on success

Definition at line 774 of file CoreActionController.cpp.

◆ extractDrumkit()

bool extractDrumkit ( const QString & sDrumkitPath,
const QString & sTargetDir = "" )

Extracts the compressed .h2drumkit file in sDrumkitPath into sTargetDir.

The function does not automatically load the extracted kit into the current Hydrogen session in case a custom sTargetDir was supplied. To do so, the name of the folder contained in the tarball is required (might differ from the name of the tarball) and it is not easily obtained.

Parameters
sDrumkitPathTar-compressed drumkit with .h2drumkit extension
sTargetDirFolder to extract the drumkit to. If the folder is not present yet, it will be created. If left empty, the drumkit will be installed to the users drumkit data folder.

Definition at line 1330 of file CoreActionController.cpp.

◆ getStrip()

std::shared_ptr< Instrument > getStrip ( int nStrip) const
private

Definition at line 428 of file CoreActionController.cpp.

◆ handleOutgoingControlChanges()

bool handleOutgoingControlChanges ( std::vector< int > params,
int nValue )
private

Definition at line 407 of file CoreActionController.cpp.

◆ initExternalControlInterfaces()

bool initExternalControlInterfaces ( )

Definition at line 443 of file CoreActionController.cpp.

◆ insertRecentFile()

void insertRecentFile ( const QString sFilename)
private

Add sFilename to the list of recent songs in Preferences::m_recentFiles.

The function will also take care of removing any duplicates in the list in case sFilename is already present.

Parameters
sFilenameNew song to be added on top of the list.

Definition at line 1683 of file CoreActionController.cpp.

◆ locateToColumn()

bool locateToColumn ( int nPatternGroup)

Relocates transport to the beginning of a particular column/Pattern group.

Parameters
nPatternGroupPosition of the Song provided as the index of a particular pattern group (starting at zero).
Returns
bool true on success

Definition at line 1371 of file CoreActionController.cpp.

◆ locateToTick()

bool locateToTick ( long nTick,
bool bWithJackBroadcast = true )

Relocates transport to a particular tick.

Parameters
nTickDestination
bWithJackBroadcastRelocate not using the AudioEngine directly but using the JACK server.
Returns
bool true on success

Definition at line 1402 of file CoreActionController.cpp.

◆ newPattern()

bool newPattern ( const QString & sPatternName)

Creates an empty pattern and adds it to the pattern list.

Parameters
sPathName for the created pattern.
Returns
bool true on success

Definition at line 1422 of file CoreActionController.cpp.

◆ newSong()

bool newSong ( const QString & songPath)

Create an empty H2Core::Song, which will be stored in songPath.

This will be done immediately and without saving the current H2Core::Song. All unsaved changes will be lost! In addition, the new song won't be saved by this function. You can do so using saveSong().

The intended use of this function for session management. Therefore, the function will not store the provided songPath in Preferences::m_lastSongFilename and Hydrogen won't resume with the corresponding song on restarting.

Parameters
songPathAbsolute path to the .h2song file to be opened.
Returns
true on success

Definition at line 492 of file CoreActionController.cpp.

◆ openPattern()

bool openPattern ( const QString & sPath,
int nPatternNumber = -1 )

Opens a pattern from disk and adds it to the pattern list.

Parameters
sPathAbsolute path to an existing .h2pattern file.
nPatternNumberRow the pattern will be added to. If set to -1, the pattern will be appended at the end of the pattern list.
Returns
bool true on success

Definition at line 1428 of file CoreActionController.cpp.

◆ openSong() [1/2]

bool openSong ( const QString & songPath,
const QString & sRecoverSongPath = "" )

Opens the H2Core::Song specified in songPath.

This will be done immediately and without saving the current H2Core::Song. All unsaved changes will be lost!

Parameters
songPathAbsolute path to the .h2song file to be opened.
sRecoverSongPathIf set to a value other than "", the corresponding path will be used to load the song and the latter is assigned songPath as Song::m_sFilename afterwards. Using this mechanism the GUI can use an autosave backup file to load a song without the core having to do some string magic to retrieve the original name.
Returns
true on success

Definition at line 530 of file CoreActionController.cpp.

◆ openSong() [2/2]

bool openSong ( std::shared_ptr< Song > pSong,
bool bRelinking = true )

Opens the H2Core::Song specified in songPath.

This will be done immediately and without saving the current H2Core::Song. All unsaved changes will be lost!

Parameters
pSongNew Song.
bRelinkingWhether the drumkit last loaded should be relinked when under session management. This flag is used to distinguish between the regular load of a song file within a session and its replacement by another song (which requires an update of the linked drumkit).
Returns
true on success

Definition at line 565 of file CoreActionController.cpp.

◆ quit()

bool quit ( )

Triggers the shutdown of Hydrogen.

This will be done immediately and without saving the current H2Core::Song. All unsaved changes will be lost!

The shutdown will be triggered in both the CLI and the GUI via the H2Core::EVENT_QUIT event.

Returns
true on success

Definition at line 713 of file CoreActionController.cpp.

◆ removePattern()

bool removePattern ( int nPatternNumber)

Removes a pattern from the pattern list.

Parameters
nPatternNumberSpecifies the position/row of the pattern.
Returns
bool true on success

Definition at line 1482 of file CoreActionController.cpp.

◆ retrieveDrumkit()

std::shared_ptr< Drumkit > retrieveDrumkit ( const QString & sDrumkitPath,
bool * bIsCompressed,
QString * sDrumkitDir,
QString * sTemporaryFolder )
private

Loads the drumkit specified in sDrumkitPath.

Parameters
sDrumkitPathCan be either an absolute path to a folder containing a drumkit file (drumkit.xml), an absolute path to a drumkit file itself, or an absolute file to a compressed drumkit (.h2drumkit).
bIsCompressedStores whether the drumkit was provided as a compressed .h2drumkit file
sDrumkitDirStores the folder containing the drumkit file. If a compressed drumkit was provided, this will point to a temporary folder.
sTemporaryFolderRoot path of a temporary folder containing the extracted drumkit in case sDrumkitPath pointed to a compressed .h2drumkit file.

Definition at line 1238 of file CoreActionController.cpp.

◆ savePreferences()

bool savePreferences ( )

Saves the current state of the H2Core::Preferences.

Returns
true on success

Definition at line 702 of file CoreActionController.cpp.

◆ saveSong()

bool saveSong ( )

Saves the current H2Core::Song.

Returns
true on success

Definition at line 612 of file CoreActionController.cpp.

◆ saveSongAs()

bool saveSongAs ( const QString & sNewFilename)

Saves the current H2Core::Song to the path provided in sNewFilename.

The intended use of this function for session management. Therefore, the function will not store the provided sNewFilename in H2Core::Preferences::m_lastSongFilename and Hydrogen won't resume with the corresponding song on restarting.

Parameters
sNewFilenameAbsolute path to the file to store the current H2Core::Song in.
Returns
true on success

Definition at line 668 of file CoreActionController.cpp.

◆ sendMasterIsMutedFeedback()

bool sendMasterIsMutedFeedback ( )
private

Definition at line 299 of file CoreActionController.cpp.

◆ sendMasterVolumeFeedback()

bool sendMasterVolumeFeedback ( )
private

Definition at line 219 of file CoreActionController.cpp.

◆ sendMetronomeIsActiveFeedback()

bool sendMetronomeIsActiveFeedback ( )
private

Definition at line 277 of file CoreActionController.cpp.

◆ sendStripIsMutedFeedback()

bool sendStripIsMutedFeedback ( int nStrip)
private

Definition at line 325 of file CoreActionController.cpp.

◆ sendStripIsSoloedFeedback()

bool sendStripIsSoloedFeedback ( int nStrip)
private

Definition at line 353 of file CoreActionController.cpp.

◆ sendStripPanFeedback()

bool sendStripPanFeedback ( int nStrip)
private

Definition at line 380 of file CoreActionController.cpp.

◆ sendStripPanSymFeedback()

bool sendStripPanSymFeedback ( int nStrip)
private

◆ sendStripVolumeFeedback()

bool sendStripVolumeFeedback ( int nStrip)
private

Definition at line 247 of file CoreActionController.cpp.

◆ setDrumkit() [1/2]

bool setDrumkit ( const QString & sDrumkit,
bool bConditional = true )

Wrapper around setDrumkit() that allows loading drumkits by name or path.

The function tries to retrieve the #Drumkit from cache (#SoundLibraryDatabase) first and loads it from disk in case this fails.

Parameters
sDrumkitCan be either the name of a #Drumkit or a relative or absolute path pointing to it.
bConditionalWhether to remove all redundant H2Core::Instrument regardless of their content.

Definition at line 966 of file CoreActionController.cpp.

◆ setDrumkit() [2/2]

bool setDrumkit ( std::shared_ptr< Drumkit > pDrumkit,
bool bConditional = true )

Sets Drumkit pDrumkit as the one used in the current #Song.

The loading will overwrite the #InstrumentList of the current #Song with the one found in pDrumkit (among other things) and also can be used to reset the parameters of the current drumkit to its default values.

Parameters
pDrumkitFull-fledged H2Core::Drumkit to load.
bConditionalWhether to remove all redundant H2Core::Instrument regardless of their content.

Definition at line 979 of file CoreActionController.cpp.

◆ setMasterIsMuted()

bool setMasterIsMuted ( bool isMuted)

Definition at line 102 of file CoreActionController.cpp.

◆ setMasterVolume()

bool setMasterVolume ( float masterVolumeValue)

Definition at line 60 of file CoreActionController.cpp.

◆ setMetronomeIsActive()

bool setMetronomeIsActive ( bool isActive)

Definition at line 95 of file CoreActionController.cpp.

◆ setPattern()

bool setPattern ( Pattern * pPattern,
int nPatternNumber )

Opens a pattern to the current pattern list.

   @param pPattern pattern to be added.
   @param nPatternNumber Row the pattern will be added to.

   @return bool true on success

Definition at line 1452 of file CoreActionController.cpp.

◆ setSong()

bool setSong ( std::shared_ptr< Song > pSong,
bool bRelinking = true )
private

Sets a H2Core::Song to be used by Hydrogen.

This will be done immediately and without saving the current H2Core::Song. All unsaved changes will be lost!

Parameters
pSongPointer to the H2Core::Song to set.
bRelinkingWhether the drumkit last loaded should be relinked when under session management. This flag is used to distinguish between the regular load of a song file within a session and its replacement by another song (which requires an update of the linked drumkit).
Returns
true on success

Definition at line 583 of file CoreActionController.cpp.

◆ setStripIsMuted()

bool setStripIsMuted ( int nStrip,
bool isMuted )

Definition at line 129 of file CoreActionController.cpp.

◆ setStripIsSoloed()

bool setStripIsSoloed ( int nStrip,
bool isSoloed )

Definition at line 156 of file CoreActionController.cpp.

◆ setStripPan()

bool setStripPan ( int nStrip,
float fValue,
bool bSelectStrip )
Parameters
nStripInstrument which to set the pan for.
fValueNew pan.
bSelectStripWhether the corresponding instrument should be selected.

Definition at line 174 of file CoreActionController.cpp.

◆ setStripPanSym()

bool setStripPanSym ( int nStrip,
float fValue,
bool bSelectStrip )
Parameters
nStripInstrument which to set the pan for.
fValueNew pan. range in [-1;1] => symmetric respect to 0
bSelectStripWhether the corresponding instrument should be selected.

Definition at line 197 of file CoreActionController.cpp.

◆ setStripVolume()

bool setStripVolume ( int nStrip,
float fVolumeValue,
bool bSelectStrip )
Parameters
nStripInstrument which to set the volume for.
fVolumeValueNew volume.
bSelectStripWhether the corresponding instrument should be selected.

Definition at line 74 of file CoreActionController.cpp.

◆ toggleGridCell()

bool toggleGridCell ( int nColumn,
int nRow )

Fills or clears a specific grid cell in the SongEditor.

Parameters
nColumncolumn of the pattern.
nRowrow of the pattern.
Returns
bool true on success

Definition at line 1590 of file CoreActionController.cpp.

◆ toggleStripIsMuted()

bool toggleStripIsMuted ( int nStrip)

Definition at line 119 of file CoreActionController.cpp.

◆ toggleStripIsSoloed()

bool toggleStripIsSoloed ( int nStrip)

Definition at line 146 of file CoreActionController.cpp.

◆ updatePreferences()

void updatePreferences ( )

In case a different preferences file was loaded with Hydrogen already fully set up this function refreshes all corresponding values and informs the GUI.

Definition at line 1668 of file CoreActionController.cpp.

◆ upgradeDrumkit()

bool upgradeDrumkit ( const QString & sDrumkitPath,
const QString & sNewPath = "" )

Upgrades the drumkit found at absolute path sDrumkitPath.

If sNewPath is missing, the drumkit will be upgraded in place and a backup file will be created in order to not overwrite the existing state.

Definition at line 1030 of file CoreActionController.cpp.

◆ validateDrumkit()

bool validateDrumkit ( const QString & sDrumkitPath,
bool bCheckLegacyVersions = false )

Checks whether the provided drumkit in sDrumkitPath can be found, can be loaded, and does comply with the current XSD definition.

Parameters
sDrumkitPathCan be either an absolute path to a folder containing a drumkit file (drumkit.xml), an absolute path to a drumkit file itself, or an absolute file to a compressed drumkit (.h2drumkit).
bCheckLegacyVersionsWhether just the current XSD definition or also all previous versions should be checked.

Definition at line 1161 of file CoreActionController.cpp.

Field Documentation

◆ m_nDefaultMidiFeedbackChannel

const int m_nDefaultMidiFeedbackChannel
private

Definition at line 460 of file CoreActionController.h.