hydrogen 1.2.3
Hydrogen Class Reference

Hydrogen Audio Engine. More...

#include <Hydrogen.h>

Inheritance diagram for Hydrogen:
Object< Hydrogen > Base

Public Types

enum  ErrorMessages {
  UNKNOWN_DRIVER , ERROR_STARTING_DRIVER , JACK_SERVER_SHUTDOWN , JACK_CANNOT_ACTIVATE_CLIENT ,
  JACK_CANNOT_CONNECT_OUTPUT_PORT , JACK_CANNOT_CLOSE_CLIENT , JACK_ERROR_IN_PORT_REGISTER , OSC_CANNOT_CONNECT_TO_PORT ,
  PLAYBACK_TRACK_INVALID
}
 
enum class  GUIState { notReady = -1 , unavailable = 0 , ready = 1 }
 Specifies the state of the Qt GUI. More...
 
enum class  Tempo { Song = 0 , Timeline = 1 , Jack = 2 }
 Specifies where the #AudioEngine does get its current tempo updates from. More...
 

Public Member Functions

 ~Hydrogen ()
 Destructor taking care of most of the clean up.
 
void __panic ()
 
void addInstrumentToDeathRow (std::shared_ptr< Instrument > pInstr)
 Add pInstr to __instrument_death_row and triggers __kill_instruments().
 
void addRealtimeNote (int instrument, float velocity, float fPan=0.0f, bool noteoff=false, int msg1=0)
 
bool flushAndAddNextPattern (int nPatternNumber)
 Wrapper around AudioEngine::flushAndAddNextPattern().
 
Song::ActionMode getActionMode () const
 
AudioEnginegetAudioEngine () const
 
AudioOutputgetAudioOutput () const
 Used to display audio driver info.
 
int getBcStatus ()
 
int getbeatsToCount ()
 
int getColumnForTick (long nTick, bool bLoopMode, long *pPatternStartTick) const
 Find a PatternList/column corresponding to the supplied tick position nTick.
 
CoreActionControllergetCoreActionController () const
 
GUIState getGUIState () const
 
bool getIsExportSessionActive () const
 
bool getIsModified () const
 Wrapper around Song::getIsModified() that checks whether a song is set.
 
JackAudioDriver::Timebase getJackTimebaseState () const
 
QString getLastLoadedDrumkitName () const
 
QString getLastLoadedDrumkitPath () const
 
MidiMessage::Event getLastMidiEvent () const
 Last received midi message.
 
int getLastMidiEventParameter () const
 
float getMasterBpm () const
 
MidiInputgetMidiInput () const
 Used to display midi driver info.
 
MidiOutputgetMidiOutput () const
 
Song::Mode getMode () const
 
float getNoteLength ()
 
Song::PatternMode getPatternMode () const
 
Song::PlaybackTrack getPlaybackTrackState () const
 Wrapper around Song::getPlaybackTrackState().
 
std::shared_ptr< InstrumentgetSelectedInstrument () const
 
int getSelectedInstrumentNumber () const
 
int getSelectedPatternNumber () const
 
bool getSessionDrumkitNeedsRelinking () const
 
bool getSessionIsExported () const
 
std::shared_ptr< SonggetSong () const
 Get the current song.
 
SoundLibraryDatabasegetSoundLibraryDatabase () const
 
Tempo getTempoSource () const
 
long getTickForColumn (int nColumn) const
 Get the total number of ticks passed up to a nColumn / pattern group.
 
std::shared_ptr< TimelinegetTimeline () const
 
bool handleBeatCounter ()
 
bool hasJackAudioDriver () const
 
bool hasJackTransport () const
 
bool instrumentHasNotes (std::shared_ptr< Instrument > pInst)
 Test if an Instrument has some Note in the Pattern (used to test before deleting an Instrument)
 
bool isPatternEditorLocked () const
 Convenience function checking whether using the Pattern Editor is locked in the song settings and the song is in song mode.
 
bool isTimelineEnabled () const
 Convenience function checking whether using the Timeline tempo is set in the Preferences, Song::SONG_MODE is set, and there is a JACK timebase master present.
 
bool isUnderSessionManagement () const
 
void loadPlaybackTrack (QString sFilename)
 Wrapper function for loading the playback track.
 
void midi_noteOn (Note *note)
 
void mutePlaybackTrack (const bool bMuted)
 Wrapper around Song::setPlaybackTrackEnabled().
 
void offJackMaster ()
 Calling JackAudioDriver::releaseTimebaseMaster() directly from the GUI.
 
void onJackMaster ()
 Calling JackAudioDriver::initTimebaseMaster() directly from the GUI.
 
void onTapTempoAccelEvent ()
 
void previewInstrument (std::shared_ptr< Instrument > pInstr)
 
void previewSample (Sample *pSample)
 
void raiseError (unsigned nErrorCode)
 
void recalculateRubberband (float fBpm)
 Recalculates all Samples using RubberBand for a specific tempo fBpm.
 
void recreateOscServer ()
 Destroys and recreates the OscServer singleton in order to adopt a new OSC port.
 
void removeInstrument (int nInstrumentNumber)
 Delete an #Instrument.
 
void removeSong ()
 
void renameJackPorts (std::shared_ptr< Song > pSong)
 Calls audioEngine_renameJackPorts() if Preferences::m_bJackTrackOuts is set to true.
 
void restartDrivers ()
 
void restartLadspaFX ()
 
void sequencer_play ()
 Start the internal sequencer.
 
void sequencer_stop ()
 Stop the internal sequencer.
 
void setActionMode (Song::ActionMode mode)
 Wrapper around Song::setActionMode() which also triggers EVENT_ACTION_MODE_CHANGE and should be used by all parts of the code except for song reading/setting.
 
void setBcOffsetAdjust ()
 
void setbeatsToCount (int beatstocount)
 Updates m_nbeatsToCount.
 
void setGUIState (const GUIState state)
 
void setIsModified (bool bIsModified)
 Wrapper around Song::setIsModified() that checks whether a song is set.
 
void setIsPatternEditorLocked (bool bValue)
 
void setIsTimelineActivated (bool bEnabled)
 Wrapper around both Song::setIsTimelineActivated (recent) and Preferences::setUseTimelinebpm() (former place to store the variable but kept to maintain backward compatibility) which also triggers EVENT_TIMELINE_ACTIVATION.
 
void setLastMidiEvent (MidiMessage::Event event)
 
void setLastMidiEventParameter (int nParam)
 
void setMode (Song::Mode mode)
 Wrapper around Song::setMode() which also triggers EVENT_SONG_MODE_ACTIVATION and should be used by all parts of the code except for song reading/setting.
 
void setNoteLength (float notelength)
 
void setPatternMode (Song::PatternMode mode)
 Wrapper around Song::setPatternMode() which also triggers EVENT_STACKED_MODE_ACTIVATION and should be used by all parts of the code except for song reading/setting.
 
void setSelectedInstrumentNumber (int nInstrument, bool bTriggerEvent=true)
 
void setSelectedPatternNumber (int nPat, bool bNeedsLock=true, bool bForce=false)
 Sets m_nSelectedPatternNumber.
 
void setSessionDrumkitNeedsRelinking (bool bNeedsRelinking)
 
void setSessionIsExported (bool bIsExported)
 
void setSong (std::shared_ptr< Song > newSong, bool bRelinking=true)
 Sets the current song __song to newSong.
 
void setTapTempo (float fInterval)
 
void setTimeline (std::shared_ptr< Timeline >)
 
bool startExportSession (int rate, int depth)
 
void startExportSong (const QString &filename)
 Export a song to a wav file.
 
void startNsmClient ()
 
void stopExportSession ()
 
void stopExportSong ()
 
void toggleNextPattern (int nPatternNumber)
 Wrapper around AudioEngine::toggleNextPattern().
 
void toggleOscServer (bool bEnable)
 Starts/stops the OSC server.
 
QString toQString (const QString &sPrefix="", bool bShort=true) const override
 Formatted string version for debugging purposes.
 
void updateSelectedPattern (bool bNeedsLock=true)
 Updates the selected pattern to the one recorded note will be inserted to.
 
void updateSongSize ()
 
void updateVirtualPatterns ()
 Processes the patterns added to any virtual ones in the #PatternList of the current Song and ensure both the playing pattern representation in the #AudioEngine and the GUI are synced.
 
- Public Member Functions inherited from Object< Hydrogen >
 Object ()
 
 Object (const Object< Hydrogen > &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.
 

Static Public Member Functions

static void create_instance ()
 Creates all the instances used within Hydrogen in the right order.
 
static Hydrogenget_instance ()
 Returns the current Hydrogen instance __instance.
 
- 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
 

Data Fields

int m_nInstrumentLookupTable [MAX_INSTRUMENTS]
 midi lookuptable
 

Private Member Functions

 Hydrogen ()
 Constructor, entry point, and initialization of the Hydrogen application.
 
void __kill_instruments ()
 
void initBeatcounter ()
 Auxiliary function setting a bunch of global variables.
 

Private Attributes

std::list< std::shared_ptr< Instrument > > __instrument_death_row
 Deleting instruments too soon leads to potential crashes.
 
std::shared_ptr< Song__song
 Pointer to the current song.
 
bool m_bExportSessionIsActive
 
bool m_bOldLoopEnabled
 
bool m_bSessionDrumkitNeedsRelinking
 When using Hydrogen with session management it tries to keep all central files within a session folder instead of using the once found at the data folder at either user or system level.
 
bool m_bSessionIsExported
 Indicates whether NSM session is saved or exported when entering the CoreActionController::saveSong() function.
 
timeval m_CurrentTime
 timeval
 
GUIState m_GUIState
 Specifies whether the Qt5 GUI is active.
 
MidiMessage::Event m_lastMidiEvent
 Cache last incoming MIDI event to be used in MidiSenseWidget.
 
int m_nBeatCount
 beatcounter beat to count
 
double m_nBeatDiffs [16]
 beat diff
 
int m_nbeatsToCount
 beatcounter beats to count
 
int m_nCoutOffset
 
int m_nEventCount
 beatcounter event
 
int m_nLastMidiEventParameter
 
int m_nLastRecordedMIDINoteTick
 Onset of the recorded last in addRealtimeNote().
 
int m_nSelectedInstrumentNumber
 Instrument currently focused/selected in the GUI.
 
int m_nSelectedPatternNumber
 Index of the pattern selected in the GUI or by a MIDI event.
 
int m_nStartOffset
 ms default 0
 
float m_ntaktoMeterCompute
 beatcounter note length
 
int m_nTempoChangeCounter
 count tempochanges for timeArray
 
Song::Mode m_oldEngineMode
 ms default 0
 
AudioEnginem_pAudioEngine
 Central instance of the audio engine.
 
CoreActionControllerm_pCoreActionController
 Local instance of the CoreActionController object.
 
SoundLibraryDatabasem_pSoundLibraryDatabase
 
std::shared_ptr< Timelinem_pTimeline
 Local instance of the Timeline object.
 

Static Private Attributes

static Hydrogen__instance = nullptr
 Static reference to the Hydrogen singleton.
 

Additional Inherited Members

- 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< Hydrogen >
 ~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

Hydrogen Audio Engine.

Definition at line 53 of file Hydrogen.h.

Member Enumeration Documentation

◆ ErrorMessages

Enumerator
UNKNOWN_DRIVER 

The provided input string in createDriver() does not match any of the choices for Preferences::m_sAudioDriver.

ERROR_STARTING_DRIVER 

Unable to connect the audio driver stored in H2Core::AudioEngine::m_pAudioDriver in audioEngine_startAudioDrivers().

The NullDriver will be used as a fallback instead.

JACK_SERVER_SHUTDOWN 
JACK_CANNOT_ACTIVATE_CLIENT 
JACK_CANNOT_CONNECT_OUTPUT_PORT 

Unable to connect either the JackAudioDriver::output_port_1 and the JackAudioDriver::output_port_name_1 as well as the JackAudioDriver::output_port_2 and the JackAudioDriver::output_port_name_2 port using jack_connect() (jack/jack.h) or the fallback version using the first two input ports in JackAudioDriver::connect().

JACK_CANNOT_CLOSE_CLIENT 

The client of Hydrogen can not be disconnected from the JACK server using jack_client_close() (jack/jack.h).

Used within JackAudioDriver::disconnect().

JACK_ERROR_IN_PORT_REGISTER 

Unable to register output ports for the JACK client using jack_port_register() (jack/jack.h) in JackAudioDriver::init() or JackAudioDriver::setTrackOutput().

OSC_CANNOT_CONNECT_TO_PORT 

Unable to start the OSC server with the given port number.

PLAYBACK_TRACK_INVALID 

Definition at line 239 of file Hydrogen.h.

◆ GUIState

enum class GUIState
strong

Specifies the state of the Qt GUI.

Enumerator
notReady 

There is a GUI but it is not ready yet (during startup).

unavailable 

No GUI available.

ready 

There is a working GUI.

Definition at line 388 of file Hydrogen.h.

◆ Tempo

enum class Tempo
strong

Specifies where the #AudioEngine does get its current tempo updates from.

Enumerator
Song 

BeatCounter, TapTempo, OSC and MIDI commands as well as the BPM widget in the PlayerControl are used to change the tempo.

Timeline 

Only tempo markers on the Timeline are considered.

Jack 

Hydrogen will disregard all internal tempo settings and uses the ones provided by the JACK server instead.

This mode is only used in case the JACK audio driver is used, JACK timebase support is activated in the Preferences, and an external timebase master is registered to the JACK server.

Definition at line 60 of file Hydrogen.h.

Constructor & Destructor Documentation

◆ ~Hydrogen()

~Hydrogen ( )

Destructor taking care of most of the clean up.

Definition at line 154 of file Hydrogen.cpp.

◆ Hydrogen()

Hydrogen ( )
private

Constructor, entry point, and initialization of the Hydrogen application.

It is called by the main() function after setting up a bunch of Qt5 stuff and creating an instance of the Logger and Preferences.

Only one Hydrogen object is allowed to exist. If the __instance object is present, the constructor will throw an error.

Definition at line 105 of file Hydrogen.cpp.

Member Function Documentation

◆ __kill_instruments()

void __kill_instruments ( )
private

Definition at line 1134 of file Hydrogen.cpp.

◆ __panic()

void __panic ( )

Definition at line 1160 of file Hydrogen.cpp.

◆ addInstrumentToDeathRow()

void addInstrumentToDeathRow ( std::shared_ptr< Instrument > pInstr)

Add pInstr to __instrument_death_row and triggers __kill_instruments().

Since there might still be some notes of pInstr left in one of the note queues, the instrument can not be deleted right away. Instead, this function will add it to a list of instruments marked for deletion and it will be dealt with at a later time.

Definition at line 1129 of file Hydrogen.cpp.

◆ addRealtimeNote()

void addRealtimeNote ( int instrument,
float velocity,
float fPan = 0.0f,
bool noteoff = false,
int msg1 = 0 )

Definition at line 357 of file Hydrogen.cpp.

◆ create_instance()

void create_instance ( )
static

Creates all the instances used within Hydrogen in the right order.

Definition at line 181 of file Hydrogen.cpp.

◆ flushAndAddNextPattern()

bool flushAndAddNextPattern ( int nPatternNumber)

Wrapper around AudioEngine::flushAndAddNextPattern().

Definition at line 610 of file Hydrogen.cpp.

◆ get_instance()

static Hydrogen * get_instance ( )
inlinestatic

Returns the current Hydrogen instance __instance.

Definition at line 83 of file Hydrogen.h.

◆ getActionMode()

Song::ActionMode getActionMode ( ) const

Definition at line 1290 of file Hydrogen.cpp.

◆ getAudioEngine()

AudioEngine * getAudioEngine ( ) const
inline

Definition at line 649 of file Hydrogen.h.

◆ getAudioOutput()

AudioOutput * getAudioOutput ( ) const

Used to display audio driver info.

Definition at line 719 of file Hydrogen.cpp.

◆ getBcStatus()

int getBcStatus ( )

Definition at line 978 of file Hydrogen.cpp.

◆ getbeatsToCount()

int getbeatsToCount ( )
Returns
m_nbeatsToCount

Definition at line 963 of file Hydrogen.cpp.

◆ getColumnForTick()

int getColumnForTick ( long nTick,
bool bLoopMode,
long * pPatternStartTick ) const

Find a PatternList/column corresponding to the supplied tick position nTick.

Adds up the lengths of all pattern columns until nTick lies in between the bounds of a Pattern.

Parameters
nTickPosition in ticks.
bLoopModeWhether looping is enabled in the Song, see Song::is_loop_enabled(). If true, nTick is allowed to be larger than the total length of the Song.
pPatternStartTickPointer to an integer the beginning of the found pattern list will be stored in (in ticks).
Returns
  • -1 : pattern list couldn't be found.
  • >=0 : PatternList index in Song::__pattern_group_sequence.

Definition at line 1504 of file Hydrogen.cpp.

◆ getCoreActionController()

CoreActionController * getCoreActionController ( ) const
inline

Definition at line 639 of file Hydrogen.h.

◆ getGUIState()

Hydrogen::GUIState getGUIState ( ) const
inline
Returns
m_GUIState

Definition at line 653 of file Hydrogen.h.

◆ getIsExportSessionActive()

bool getIsExportSessionActive ( ) const
inline

Definition at line 644 of file Hydrogen.h.

◆ getIsModified()

bool getIsModified ( ) const

Wrapper around Song::getIsModified() that checks whether a song is set.

Definition at line 1449 of file Hydrogen.cpp.

◆ getJackTimebaseState()

JackAudioDriver::Timebase getJackTimebaseState ( ) const
Returns
Whether we hasJackTransport() and there is an external JACK timebase master broadcasting us tempo information and making use disregard Hydrogen's Timeline information (see H2Core::JackAudioDriver::m_timebaseState).

Definition at line 1212 of file Hydrogen.cpp.

◆ getLastLoadedDrumkitName()

QString getLastLoadedDrumkitName ( ) const
Returns
m_sLastLoadedDrumkitName

Definition at line 1465 of file Hydrogen.cpp.

◆ getLastLoadedDrumkitPath()

QString getLastLoadedDrumkitPath ( ) const
Returns
m_sLastLoadedDrumkitPath

Definition at line 1456 of file Hydrogen.cpp.

◆ getLastMidiEvent()

MidiMessage::Event getLastMidiEvent ( ) const
inline

Last received midi message.

Definition at line 681 of file Hydrogen.h.

◆ getLastMidiEventParameter()

int getLastMidiEventParameter ( ) const
inline

Definition at line 687 of file Hydrogen.h.

◆ getMasterBpm()

float getMasterBpm ( ) const

Definition at line 1196 of file Hydrogen.cpp.

◆ getMidiInput()

MidiInput * getMidiInput ( ) const

Used to display midi driver info.

Definition at line 725 of file Hydrogen.cpp.

◆ getMidiOutput()

MidiOutput * getMidiOutput ( ) const

Definition at line 730 of file Hydrogen.cpp.

◆ getMode()

Song::Mode getMode ( ) const

Definition at line 1274 of file Hydrogen.cpp.

◆ getNoteLength()

float getNoteLength ( )

Definition at line 973 of file Hydrogen.cpp.

◆ getPatternMode()

Song::PatternMode getPatternMode ( ) const

Definition at line 1305 of file Hydrogen.cpp.

◆ getPlaybackTrackState()

Song::PlaybackTrack getPlaybackTrackState ( ) const

Wrapper around Song::getPlaybackTrackState().

Definition at line 240 of file Hydrogen.cpp.

◆ getSelectedInstrument()

std::shared_ptr< Instrument > getSelectedInstrument ( ) const

Definition at line 1622 of file Hydrogen.cpp.

◆ getSelectedInstrumentNumber()

int getSelectedInstrumentNumber ( ) const
inline

Definition at line 664 of file Hydrogen.h.

◆ getSelectedPatternNumber()

int getSelectedPatternNumber ( ) const
inline
Returns
m_nSelectedPatternNumber

Definition at line 660 of file Hydrogen.h.

◆ getSessionDrumkitNeedsRelinking()

bool getSessionDrumkitNeedsRelinking ( ) const
inline

Definition at line 672 of file Hydrogen.h.

◆ getSessionIsExported()

bool getSessionIsExported ( ) const
inline

Definition at line 678 of file Hydrogen.h.

◆ getSong()

std::shared_ptr< Song > getSong ( ) const
inline

Get the current song.

Returns
__song

Definition at line 122 of file Hydrogen.h.

◆ getSoundLibraryDatabase()

SoundLibraryDatabase * getSoundLibraryDatabase ( ) const
inline

Definition at line 94 of file Hydrogen.h.

◆ getTempoSource()

Hydrogen::Tempo getTempoSource ( ) const

Definition at line 1339 of file Hydrogen.cpp.

◆ getTickForColumn()

long getTickForColumn ( int nColumn) const

Get the total number of ticks passed up to a nColumn / pattern group.

The AudioEngine should be LOCKED when calling this!

Parameters
nColumnpattern group.
Returns
  • -1 : if nColumn is bigger than the number of patterns in the Song and Song::isLoopEnabled() is set to false or no Patterns could be found at all.
  • >= 0 : the total number of ticks passed.

Definition at line 1573 of file Hydrogen.cpp.

◆ getTimeline()

std::shared_ptr< Timeline > getTimeline ( ) const
inline

Definition at line 630 of file Hydrogen.h.

◆ handleBeatCounter()

bool handleBeatCounter ( )

Definition at line 993 of file Hydrogen.cpp.

◆ hasJackAudioDriver()

bool hasJackAudioDriver ( ) const
Returns
Whether JackAudioDriver is used as current audio driver.

Definition at line 1168 of file Hydrogen.cpp.

◆ hasJackTransport()

bool hasJackTransport ( ) const
Returns
Whether JackAudioDriver is used as current audio driver and JACK transport was activated via the GUI (H2Core::Preferences::m_bJackTransportMode).

Definition at line 1181 of file Hydrogen.cpp.

◆ initBeatcounter()

void initBeatcounter ( )
private

Auxiliary function setting a bunch of global variables.

Definition at line 206 of file Hydrogen.cpp.

◆ instrumentHasNotes()

bool instrumentHasNotes ( std::shared_ptr< Instrument > pInst)

Test if an Instrument has some Note in the Pattern (used to test before deleting an Instrument)

Definition at line 736 of file Hydrogen.cpp.

◆ isPatternEditorLocked()

bool isPatternEditorLocked ( ) const

Convenience function checking whether using the Pattern Editor is locked in the song settings and the song is in song mode.

Definition at line 1250 of file Hydrogen.cpp.

◆ isTimelineEnabled()

bool isTimelineEnabled ( ) const

Convenience function checking whether using the Timeline tempo is set in the Preferences, Song::SONG_MODE is set, and there is a JACK timebase master present.

Returns
Whether the Timeline is used to determine the current speed.

Definition at line 1240 of file Hydrogen.cpp.

◆ isUnderSessionManagement()

bool isUnderSessionManagement ( ) const
Returns
NsmClient::m_bUnderSessionManagement if NSM is supported.

Definition at line 1224 of file Hydrogen.cpp.

◆ loadPlaybackTrack()

void loadPlaybackTrack ( QString sFilename)

Wrapper function for loading the playback track.

Definition at line 262 of file Hydrogen.cpp.

◆ midi_noteOn()

void midi_noteOn ( Note * note)

Definition at line 352 of file Hydrogen.cpp.

◆ mutePlaybackTrack()

void mutePlaybackTrack ( const bool bMuted)

Wrapper around Song::setPlaybackTrackEnabled().

Definition at line 250 of file Hydrogen.cpp.

◆ offJackMaster()

void offJackMaster ( )

Calling JackAudioDriver::releaseTimebaseMaster() directly from the GUI.

Definition at line 1107 of file Hydrogen.cpp.

◆ onJackMaster()

void onJackMaster ( )

Calling JackAudioDriver::initTimebaseMaster() directly from the GUI.

Definition at line 1118 of file Hydrogen.cpp.

◆ onTapTempoAccelEvent()

void onTapTempoAccelEvent ( )

Definition at line 779 of file Hydrogen.cpp.

◆ previewInstrument()

void previewInstrument ( std::shared_ptr< Instrument > pInstr)

◆ previewSample()

void previewSample ( Sample * pSample)

◆ raiseError()

void raiseError ( unsigned nErrorCode)

Definition at line 774 of file Hydrogen.cpp.

◆ recalculateRubberband()

void recalculateRubberband ( float fBpm)

Recalculates all Samples using RubberBand for a specific tempo fBpm.

This function requires the calling function to lock the #AudioEngine first.

Definition at line 1389 of file Hydrogen.cpp.

◆ recreateOscServer()

void recreateOscServer ( )

Destroys and recreates the OscServer singleton in order to adopt a new OSC port.

Definition at line 1361 of file Hydrogen.cpp.

◆ removeInstrument()

void removeInstrument ( int nInstrumentNumber)

Delete an #Instrument.

Definition at line 754 of file Hydrogen.cpp.

◆ removeSong()

void removeSong ( )

Definition at line 346 of file Hydrogen.cpp.

◆ renameJackPorts()

void renameJackPorts ( std::shared_ptr< Song > pSong)

Calls audioEngine_renameJackPorts() if Preferences::m_bJackTrackOuts is set to true.

Parameters
pSongHanded to audioEngine_renameJackPorts().

Definition at line 931 of file Hydrogen.cpp.

◆ restartDrivers()

void restartDrivers ( )

Definition at line 626 of file Hydrogen.cpp.

◆ restartLadspaFX()

void restartLadspaFX ( )

Definition at line 864 of file Hydrogen.cpp.

◆ sequencer_play()

void sequencer_play ( )

Start the internal sequencer.

Definition at line 218 of file Hydrogen.cpp.

◆ sequencer_stop()

void sequencer_stop ( )

Stop the internal sequencer.

Definition at line 226 of file Hydrogen.cpp.

◆ setActionMode()

void setActionMode ( Song::ActionMode mode)

Wrapper around Song::setActionMode() which also triggers EVENT_ACTION_MODE_CHANGE and should be used by all parts of the code except for song reading/setting.

Definition at line 1297 of file Hydrogen.cpp.

◆ setBcOffsetAdjust()

void setBcOffsetAdjust ( )

Definition at line 983 of file Hydrogen.cpp.

◆ setbeatsToCount()

void setbeatsToCount ( int beatstocount)

Updates m_nbeatsToCount.

Parameters
beatstocountNew value

Definition at line 958 of file Hydrogen.cpp.

◆ setGUIState()

void setGUIState ( const GUIState state)
inline
Parameters
stateSpecifies whether the Qt5 GUI is active. Sets m_GUIState.

Definition at line 657 of file Hydrogen.h.

◆ setIsModified()

void setIsModified ( bool bIsModified)

Wrapper around Song::setIsModified() that checks whether a song is set.

Definition at line 1442 of file Hydrogen.cpp.

◆ setIsPatternEditorLocked()

void setIsPatternEditorLocked ( bool bValue)

Definition at line 1261 of file Hydrogen.cpp.

◆ setIsTimelineActivated()

void setIsTimelineActivated ( bool bEnabled)

Wrapper around both Song::setIsTimelineActivated (recent) and Preferences::setUseTimelinebpm() (former place to store the variable but kept to maintain backward compatibility) which also triggers EVENT_TIMELINE_ACTIVATION.

Definition at line 1474 of file Hydrogen.cpp.

◆ setLastMidiEvent()

void setLastMidiEvent ( MidiMessage::Event event)
inline

Definition at line 684 of file Hydrogen.h.

◆ setLastMidiEventParameter()

void setLastMidiEventParameter ( int nParam)
inline

Definition at line 690 of file Hydrogen.h.

◆ setMode()

void setMode ( Song::Mode mode)

Wrapper around Song::setMode() which also triggers EVENT_SONG_MODE_ACTIVATION and should be used by all parts of the code except for song reading/setting.

Definition at line 1282 of file Hydrogen.cpp.

◆ setNoteLength()

void setNoteLength ( float notelength)

Definition at line 968 of file Hydrogen.cpp.

◆ setPatternMode()

void setPatternMode ( Song::PatternMode mode)

Wrapper around Song::setPatternMode() which also triggers EVENT_STACKED_MODE_ACTIVATION and should be used by all parts of the code except for song reading/setting.

Definition at line 1312 of file Hydrogen.cpp.

◆ setSelectedInstrumentNumber()

void setSelectedInstrumentNumber ( int nInstrument,
bool bTriggerEvent = true )
Parameters
nInstrument#Instrument about to be selected
bTriggerEventWhether EVENT_SELECTED_INSTRUMENT_CHANGED should be queued. When e.g. changing the selected instrument as part of loading a different drumkit, it's important to only trigger a single event after the loading is done and to not fire some premature ones making the GUI act on a core that might be in an unclean state.

Definition at line 918 of file Hydrogen.cpp.

◆ setSelectedPatternNumber()

void setSelectedPatternNumber ( int nPat,
bool bNeedsLock = true,
bool bForce = false )

Sets m_nSelectedPatternNumber.

Parameters
nPatSets m_nSelectedPatternNumber
bNeedsLockWhether the function was called with the audio engine locked already or it should do so itself.
bForceWhen present, the EVENT_SELECTED_PATTERN_CHANGED will be triggered regardless of nPat. This is important when rearranging patterns in the song editor while the pattern editor is locked.

Definition at line 889 of file Hydrogen.cpp.

◆ setSessionDrumkitNeedsRelinking()

void setSessionDrumkitNeedsRelinking ( bool bNeedsRelinking)
inline

Definition at line 669 of file Hydrogen.h.

◆ setSessionIsExported()

void setSessionIsExported ( bool bIsExported)
inline

Definition at line 675 of file Hydrogen.h.

◆ setSong()

void setSong ( std::shared_ptr< Song > newSong,
bool bRelinking = true )

Sets the current song __song to newSong.

Parameters
newSongPointer to the new Song object.
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).

Definition at line 288 of file Hydrogen.cpp.

◆ setTapTempo()

void setTapTempo ( float fInterval)

Definition at line 804 of file Hydrogen.cpp.

◆ setTimeline()

void setTimeline ( std::shared_ptr< Timeline > pTimeline)
inline

Definition at line 634 of file Hydrogen.h.

◆ startExportSession()

bool startExportSession ( int rate,
int depth )
Returns
true on success.

Definition at line 631 of file Hydrogen.cpp.

◆ startExportSong()

void startExportSong ( const QString & filename)

Export a song to a wav file.

Definition at line 680 of file Hydrogen.cpp.

◆ startNsmClient()

void startNsmClient ( )

Definition at line 1376 of file Hydrogen.cpp.

◆ stopExportSession()

void stopExportSession ( )

Definition at line 699 of file Hydrogen.cpp.

◆ stopExportSong()

void stopExportSong ( )

Definition at line 692 of file Hydrogen.cpp.

◆ toggleNextPattern()

void toggleNextPattern ( int nPatternNumber)

Wrapper around AudioEngine::toggleNextPattern().

Definition at line 598 of file Hydrogen.cpp.

◆ toggleOscServer()

void toggleOscServer ( bool bEnable)

Starts/stops the OSC server.

Parameters
bEnabletrue = start, false = stop.

Definition at line 1351 of file Hydrogen.cpp.

◆ toQString()

QString toQString ( const QString & sPrefix = "",
bool bShort = true ) const
overridevirtual

Formatted string version for debugging purposes.

Parameters
sPrefixString prefix which will be added in front of every new line
bShortInstead of the whole content of all classes stored as members just a single unique identifier will be displayed without line breaks.
Returns
String presentation of current object.

Reimplemented from Base.

Definition at line 1667 of file Hydrogen.cpp.

◆ updateSelectedPattern()

void updateSelectedPattern ( bool bNeedsLock = true)

Updates the selected pattern to the one recorded note will be inserted to.

Definition at line 877 of file Hydrogen.cpp.

◆ updateSongSize()

void updateSongSize ( )

Definition at line 1618 of file Hydrogen.cpp.

◆ updateVirtualPatterns()

void updateVirtualPatterns ( )

Processes the patterns added to any virtual ones in the #PatternList of the current Song and ensure both the playing pattern representation in the #AudioEngine and the GUI are synced.

Definition at line 1646 of file Hydrogen.cpp.

Field Documentation

◆ __instance

Hydrogen * __instance = nullptr
staticprivate

Static reference to the Hydrogen singleton.

It is created using the Hydrogen::Hydrogen() constructor, initialized with NULL and assigned a new Hydrogen instance if still 0 in create_instance().

Definition at line 490 of file Hydrogen.h.

◆ __instrument_death_row

std::list<std::shared_ptr<Instrument> > __instrument_death_row
private

Deleting instruments too soon leads to potential crashes.

Definition at line 551 of file Hydrogen.h.

◆ __song

std::shared_ptr<Song> __song
private

Pointer to the current song.

It is initialized with NULL in the Hydrogen() constructor, set via setSong(), and accessed via getSong().

Definition at line 497 of file Hydrogen.h.

◆ m_bExportSessionIsActive

bool m_bExportSessionIsActive
private

Definition at line 528 of file Hydrogen.h.

◆ m_bOldLoopEnabled

bool m_bOldLoopEnabled
private

Definition at line 527 of file Hydrogen.h.

◆ m_bSessionDrumkitNeedsRelinking

bool m_bSessionDrumkitNeedsRelinking
private

When using Hydrogen with session management it tries to keep all central files within a session folder instead of using the once found at the data folder at either user or system level.

This allows to zip and transfer a session without requiring to move the whole data folder as well.

As sample files can be quite large in both size and number the drumkit is only linked into the session folder.

This variable indicates whether a different drumkit was loaded into the current song (by either directly loading a drumkit or replacing the entire song) and thus a relinking is required upon saving the song.

Definition at line 582 of file Hydrogen.h.

◆ m_bSessionIsExported

bool m_bSessionIsExported
private

Indicates whether NSM session is saved or exported when entering the CoreActionController::saveSong() function.

Definition at line 587 of file Hydrogen.h.

◆ m_CurrentTime

timeval m_CurrentTime
private

timeval

Definition at line 519 of file Hydrogen.h.

◆ m_GUIState

GUIState m_GUIState
private

Specifies whether the Qt5 GUI is active.

When a new Song is set via the core part of Hydrogen, e.g. in the context of session management, the std::shared_ptr<Song> must* be set via the GUI if active. Else the GUI will freeze.

Set by setGUIState() and accessed via getGUIState().

Definition at line 539 of file Hydrogen.h.

◆ m_lastMidiEvent

MidiMessage::Event m_lastMidiEvent
private

Cache last incoming MIDI event to be used in MidiSenseWidget.

Definition at line 621 of file Hydrogen.h.

◆ m_nBeatCount

int m_nBeatCount
private

beatcounter beat to count

Definition at line 517 of file Hydrogen.h.

◆ m_nBeatDiffs

double m_nBeatDiffs[16]
private

beat diff

Definition at line 518 of file Hydrogen.h.

◆ m_nbeatsToCount

int m_nbeatsToCount
private

beatcounter beats to count

Definition at line 514 of file Hydrogen.h.

◆ m_nCoutOffset

int m_nCoutOffset
private

Definition at line 520 of file Hydrogen.h.

◆ m_nEventCount

int m_nEventCount
private

beatcounter event

Definition at line 515 of file Hydrogen.h.

◆ m_nInstrumentLookupTable

int m_nInstrumentLookupTable[MAX_INSTRUMENTS]

midi lookuptable

Definition at line 450 of file Hydrogen.h.

◆ m_nLastMidiEventParameter

int m_nLastMidiEventParameter
private

Definition at line 622 of file Hydrogen.h.

◆ m_nLastRecordedMIDINoteTick

int m_nLastRecordedMIDINoteTick
private

Onset of the recorded last in addRealtimeNote().

It is used to determine the custom length of the note in case the note on event is followed by a note off event.

Definition at line 594 of file Hydrogen.h.

◆ m_nSelectedInstrumentNumber

int m_nSelectedInstrumentNumber
private

Instrument currently focused/selected in the GUI.

Within the core it is relevant for the MIDI input. Using Preferences::__playselectedinstrument incoming MIDI signals can be used to play back only the selected instrument or the whole drumkit.

Definition at line 561 of file Hydrogen.h.

◆ m_nSelectedPatternNumber

int m_nSelectedPatternNumber
private

Index of the pattern selected in the GUI or by a MIDI event.

Definition at line 565 of file Hydrogen.h.

◆ m_nStartOffset

int m_nStartOffset
private

ms default 0

Definition at line 521 of file Hydrogen.h.

◆ m_ntaktoMeterCompute

float m_ntaktoMeterCompute
private

beatcounter note length

Definition at line 513 of file Hydrogen.h.

◆ m_nTempoChangeCounter

int m_nTempoChangeCounter
private

count tempochanges for timeArray

Definition at line 516 of file Hydrogen.h.

◆ m_oldEngineMode

Song::Mode m_oldEngineMode
private

ms default 0

Definition at line 526 of file Hydrogen.h.

◆ m_pAudioEngine

AudioEngine* m_pAudioEngine
private

Central instance of the audio engine.

Definition at line 598 of file Hydrogen.h.

◆ m_pCoreActionController

CoreActionController* m_pCoreActionController
private

Local instance of the CoreActionController object.

Definition at line 548 of file Hydrogen.h.

◆ m_pSoundLibraryDatabase

SoundLibraryDatabase* m_pSoundLibraryDatabase
private

Definition at line 600 of file Hydrogen.h.

◆ m_pTimeline

std::shared_ptr<Timeline> m_pTimeline
private

Local instance of the Timeline object.

Definition at line 544 of file Hydrogen.h.