hydrogen 1.2.6
CoreActionController.h
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 * Copyright(c) 2008-2025 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
5 *
6 * http://www.hydrogen-music.org
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY, without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see https://www.gnu.org/licenses
20 *
21 */
22
23#ifndef CORE_ACTION_CONTROLLER_H
24#define CORE_ACTION_CONTROLLER_H
25
26#include <vector>
27#include <memory>
28
29#include <core/Object.h>
30#include <core/Basics/Song.h>
31
32namespace H2Core
33{
34 class Drumkit;
35 class Instrument;
36
38class CoreActionController : public H2Core::Object<CoreActionController> {
40
41 public:
44
45 bool setMasterVolume( float masterVolumeValue );
52 bool setStripVolume( int nStrip, float fVolumeValue, bool bSelectStrip );
59 bool setStripPan( int nStrip, float fValue, bool bSelectStrip );
66 bool setStripPanSym( int nStrip, float fValue, bool bSelectStrip );
67 bool setInstrumentPitch( int nInstrument, float fValue );
68 bool setMetronomeIsActive( bool isActive );
69 bool setMasterIsMuted( bool isMuted );
70
71 bool setStripIsMuted( int nStrip, bool isMuted );
72 bool toggleStripIsMuted( int nStrip );
73
74 bool setStripIsSoloed( int nStrip, bool isSoloed );
75 bool toggleStripIsSoloed( int nStrip );
76
78
79 // -----------------------------------------------------------
80 // Actions required for session management.
81
100 bool newSong( const QString& songPath );
117 bool openSong( const QString& songPath, const QString& sRecoverSongPath = "" );
132 bool openSong( std::shared_ptr<Song> pSong, bool bRelinking = true );
138 bool saveSong();
152 bool saveSongAs( const QString& sNewFilename );
158 bool savePreferences();
170 bool quit();
171
172 // -----------------------------------------------------------
173 // Further OSC commands
174
187 bool activateTimeline( bool bActivate );
196 bool addTempoMarker( int nPosition, float fBpm );
207 bool deleteTempoMarker( int nPosition );
216 bool addTag( int nPosition, const QString& sText );
227 bool deleteTag( int nPosition );
239 bool activateJackTransport( bool bActivate );
251 bool activateJackTimebaseControl( bool bActivate );
252
261 bool activateSongMode( bool bActivate );
269 bool activateLoopMode( bool bActivate );
282 bool setDrumkit( const QString& sDrumkit, bool bConditional = true );
295 bool setDrumkit( std::shared_ptr<Drumkit> pDrumkit, bool bConditional = true );
303 bool upgradeDrumkit( const QString& sDrumkitPath, const QString& sNewPath = "" );
304
317 bool validateDrumkit( const QString& sDrumkitPath, bool bCheckLegacyVersions = false );
343 bool extractDrumkit( const QString& sDrumkitPath,
344 const QString& sTargetDir = "",
345 QString* pInstalledPath = nullptr,
346 bool* pEncodingIssuesDetected = nullptr );
355 bool locateToColumn( int nPatternGroup );
364 bool locateToTick( long nTick, bool bWithJackBroadcast = true );
365
372 bool newPattern( const QString& sPatternName );
382 bool openPattern( const QString& sPath, int nPatternNumber = -1 );
390 bool setPattern( Pattern* pPattern, int nPatternNumber );
397 bool removePattern( int nPatternNumber );
407 bool clearInstrumentInPattern( int nInstrumentNumber,
408 int nPatternNumber = -1 );
416 bool toggleGridCell( int nColumn, int nRow );
417
427 bool handleNote( int nNote, float fVelocity, bool bNoteOff = false );
428
434 void updatePreferences();
435private:
437 bool sendStripVolumeFeedback( int nStrip );
440 bool sendStripIsMutedFeedback( int nStrip );
441 bool sendStripIsSoloedFeedback( int nStrip );
442 bool sendStripPanFeedback( int nStrip );
443 bool sendStripPanSymFeedback( int nStrip );
444
445 bool handleOutgoingControlChanges( std::vector<int> params, int nValue);
446 std::shared_ptr<Instrument> getStrip( int nStrip ) const;
447
448 // -----------------------------------------------------------
449 // Actions required for session management.
450
465 bool setSong( std::shared_ptr<Song> pSong, bool bRelinking = true );
466
486 std::shared_ptr<Drumkit> retrieveDrumkit(
487 const QString& sDrumkitPath,
488 bool* bIsCompressed,
489 QString* sDrumkitDir,
490 QString* sTemporaryFolder,
491 bool* pLegacyFormatEncountered );
501 void insertRecentFile( const QString sFilename );
502
504};
505
506}
507#endif
#define H2_OBJECT(name)
Definition Object.h:227
bool locateToColumn(int nPatternGroup)
Relocates transport to the beginning of a particular column/Pattern group.
bool setPattern(Pattern *pPattern, int nPatternNumber)
Opens a pattern to the current pattern list.
bool clearInstrumentInPattern(int nInstrumentNumber, int nPatternNumber=-1)
Deletes all notes for instrument pInstrument in a specified pattern.
bool addTag(int nPosition, const QString &sText)
Adds a tag to the Timeline.
bool setSong(std::shared_ptr< Song > pSong, bool bRelinking=true)
Sets a H2Core::Song to be used by Hydrogen.
void updatePreferences()
In case a different preferences file was loaded with Hydrogen already fully set up this function refr...
bool openSong(const QString &songPath, const QString &sRecoverSongPath="")
Opens the H2Core::Song specified in songPath.
bool locateToTick(long nTick, bool bWithJackBroadcast=true)
Relocates transport to a particular tick.
bool handleNote(int nNote, float fVelocity, bool bNoteOff=false)
Handle an incoming note event, e.g.
bool deleteTempoMarker(int nPosition)
Delete a tempo marker from the Timeline.
std::shared_ptr< Instrument > getStrip(int nStrip) const
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 savePreferences()
Saves the current state of the H2Core::Preferences.
bool extractDrumkit(const QString &sDrumkitPath, const QString &sTargetDir="", QString *pInstalledPath=nullptr, bool *pEncodingIssuesDetected=nullptr)
Extracts the compressed .h2drumkit file in sDrumkitPath into sTargetDir.
bool setStripVolume(int nStrip, float fVolumeValue, bool bSelectStrip)
bool activateSongMode(bool bActivate)
Switches between Song and Pattern mode of playback.
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...
bool setDrumkit(const QString &sDrumkit, bool bConditional=true)
Wrapper around setDrumkit() that allows loading drumkits by name or path.
bool setInstrumentPitch(int nInstrument, float fValue)
bool setStripPanSym(int nStrip, float fValue, bool bSelectStrip)
bool toggleGridCell(int nColumn, int nRow)
Fills or clears a specific grid cell in the SongEditor.
bool removePattern(int nPatternNumber)
Removes a pattern from the pattern list.
bool activateLoopMode(bool bActivate)
Toggle loop mode of playback.
std::shared_ptr< Drumkit > retrieveDrumkit(const QString &sDrumkitPath, bool *bIsCompressed, QString *sDrumkitDir, QString *sTemporaryFolder, bool *pLegacyFormatEncountered)
Loads the drumkit specified in sDrumkitPath.
bool upgradeDrumkit(const QString &sDrumkitPath, const QString &sNewPath="")
Upgrades the drumkit found at absolute path sDrumkitPath.
bool activateJackTimebaseControl(bool bActivate)
(Un)registers Hydrogen as JACK Timebaes constroller.
void insertRecentFile(const QString sFilename)
Add sFilename to the list of recent songs in Preferences::m_recentFiles.
bool activateJackTransport(bool bActivate)
(De)activates the usage of Jack transport.
bool setStripIsMuted(int nStrip, bool isMuted)
bool setMasterVolume(float masterVolumeValue)
bool activateTimeline(bool bActivate)
(De)activates the usage of the Timeline.
bool setStripIsSoloed(int nStrip, bool isSoloed)
bool saveSongAs(const QString &sNewFilename)
Saves the current H2Core::Song to the path provided in sNewFilename.
bool saveSong()
Saves the current H2Core::Song.
bool deleteTag(int nPosition)
Delete a tag from the Timeline.
bool sendStripPanSymFeedback(int nStrip)
bool setStripPan(int nStrip, float fValue, bool bSelectStrip)
bool quit()
Triggers the shutdown of Hydrogen.
bool addTempoMarker(int nPosition, float fBpm)
Adds a tempo marker to the Timeline.
bool openPattern(const QString &sPath, int nPatternNumber=-1)
Opens a pattern from disk and adds it to the pattern list.
bool handleOutgoingControlChanges(std::vector< int > params, int nValue)
Drumkit info.
Definition Drumkit.h:45
Instrument class.
Definition Instrument.h:55
Pattern class is a Note container.
Definition Pattern.h:46