hydrogen 1.1.1
Hydrogen Class Reference

Hydrogen Audio Engine. More...

#include <Hydrogen.h>

Inheritance diagram for Hydrogen:
Object

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
}
 
enum class  GUIState { notReady = -1 , unavailable = 0 , ready = 1 }
 Specifies the state of the Qt GUI. More...
 

Public Member Functions

 ~Hydrogen ()
 Destructor taking care of most of the clean up. More...
 
void sequencer_play ()
 Start the internal sequencer. More...
 
void sequencer_stop ()
 Stop the internal sequencer. More...
 
void midi_noteOn (Note *note)
 
void sequencer_setNextPattern (int pos)
 Adding and removing a Pattern from m_pNextPatterns. More...
 
void sequencer_setOnlyNextPattern (int pos)
 Clear m_pNextPatterns and add one Pattern. More...
 
void togglePlaysSelected ()
 Switches playback to focused pattern. More...
 
SonggetSong () const
 Get the current song. More...
 
void setSong (Song *newSong)
 Sets the current song __song to newSong. More...
 
void removeSong ()
 
void addRealtimeNote (int instrument, float velocity, float pan_L=1.0, float pan_R=1.0, float pitch=0.0, bool noteoff=false, bool forcePlay=false, int msg1=0)
 
float getMasterPeak_L ()
 
void setMasterPeak_L (float value)
 
float getMasterPeak_R ()
 
void setMasterPeak_R (float value)
 
void getLadspaFXPeak (int nFX, float *fL, float *fR)
 
void setLadspaFXPeak (int nFX, float fL, float fR)
 
unsigned long getTickPosition ()
 
unsigned long getRealtimeTickPosition ()
 Keep track of the tick position in realtime. More...
 
unsigned long getTotalFrames ()
 
void setRealtimeFrames (unsigned long frames)
 Sets m_nRealtimeFrames. More...
 
unsigned long getRealtimeFrames ()
 Returns the current realtime transport position TransportInfo::m_nFrames. More...
 
PatternListgetCurrentPatternList ()
 
void setCurrentPatternList (PatternList *pPatternList)
 Sets m_pPlayingPatterns. More...
 
PatternListgetNextPatterns ()
 
int getPatternPos ()
 Get the position of the current Pattern in the Song. More...
 
void setPatternPos (int pos)
 Relocate the position to another Pattern in the Song. More...
 
int getPosForTick (unsigned long TickPos, int *nPatternStartTick)
 Returns the pattern number corresponding to the tick position TickPos. More...
 
void resetPatternStartTick ()
 Move playback in Pattern mode to the beginning of the pattern. More...
 
long getTickForPosition (int pos)
 Get the total number of ticks passed up to a Pattern at position pos. More...
 
void restartDrivers ()
 
AudioOutputgetAudioOutput () const
 Used to display audio driver info. More...
 
MidiInputgetMidiInput () const
 Used to display midi driver info. More...
 
MidiOutputgetMidiOutput () const
 
int getState () const
 Returns the current state of the audio engine. More...
 
float getProcessTime () const
 
float getMaxProcessTime () const
 
int loadDrumkit (Drumkit *pDrumkitInfo)
 Wrapper around loadDrumkit( Drumkit, bool ) with the conditional argument set to true. More...
 
int loadDrumkit (Drumkit *pDrumkitInfo, bool conditional)
 Loads the H2Core::Drumkit provided in pDrumkitInfo into the current session. More...
 
bool instrumentHasNotes (Instrument *pInst)
 Test if an Instrument has some Note in the Pattern (used to test before deleting an Instrument) More...
 
void removeInstrument (int instrumentnumber, bool conditional)
 Delete an Instrument. More...
 
const QString & getCurrentDrumkitName ()
 
void setCurrentDrumkitName (const QString &sName)
 
Filesystem::Lookup getCurrentDrumkitLookup ()
 
void setCurrentDrumkitLookup (Filesystem::Lookup lookup)
 
void raiseError (unsigned nErrorCode)
 
void previewSample (Sample *pSample)
 
void previewInstrument (Instrument *pInstr)
 
void onTapTempoAccelEvent ()
 
void setTapTempo (float fInterval)
 
void setBPM (float fBPM)
 Updates the speed. More...
 
void restartLadspaFX ()
 
int getSelectedPatternNumber ()
 
void setSelectedPatternNumber (int nPat)
 Sets m_nSelectedPatternNumber. More...
 
int getSelectedInstrumentNumber ()
 
void setSelectedInstrumentNumber (int nInstrument)
 
void refreshInstrumentParameters (int nInstrument)
 
void renameJackPorts (Song *pSong)
 Calls audioEngine_renameJackPorts() if Preferences::m_bJackTrackOuts is set to true. More...
 
void toggleOscServer (bool bEnable)
 Starts/stops the OSC server. More...
 
void recreateOscServer ()
 Destroys and recreates the OscServer singleton in order to adopt a new OSC port. More...
 
void startNsmClient ()
 
void setbeatsToCount (int beatstocount)
 Updates m_nbeatsToCount. More...
 
int getbeatsToCount ()
 
void setNoteLength (float notelength)
 
float getNoteLength ()
 
int getBcStatus ()
 
void handleBeatCounter ()
 
void setBcOffsetAdjust ()
 
void offJackMaster ()
 Calling JackAudioDriver::releaseTimebaseMaster() directly from the GUI. More...
 
void onJackMaster ()
 Calling JackAudioDriver::initTimebaseMaster() directly from the GUI. More...
 
long getPatternLength (int nPattern)
 Get the length (in ticks) of the nPattern th pattern. More...
 
float getNewBpmJTM () const
 Returns the fallback speed. More...
 
void setNewBpmJTM (float bpmJTM)
 Set the fallback speed #m_nNewBpmJTM. More...
 
void __panic ()
 
unsigned int __getMidiRealtimeNoteTickPosition () const
 
void setTimelineBpm ()
 Updates Song::m_fBpm, TransportInfo::m_fBPM, and m_fNewBpmJTM to the local speed. More...
 
float getTimelineBpm (int nBar)
 Returns the local speed at a specific nBar in the Timeline. More...
 
TimelinegetTimeline () const
 
bool getIsExportSessionActive () const
 
void startExportSession (int rate, int depth)
 
void stopExportSession ()
 
void startExportSong (const QString &filename)
 Export a song to a wav file. More...
 
void stopExportSong ()
 
CoreActionControllergetCoreActionController () const
 
bool setPlaybackTrackState (const bool state)
 Wrapper around Song::setPlaybackTrackEnabled(). More...
 
bool getPlaybackTrackState () const
 Wrapper around Song::getPlaybackTrackEnabled(). More...
 
void loadPlaybackTrack (const QString filename)
 Wrapper function for loading the playback track. More...
 
GUIState getGUIState () const
 
void setGUIState (const GUIState state)
 
SonggetNextSong () const
 
void setNextSong (Song *pNextSong)
 
void setNextSongPath (const QString sSongPath)
 
QString getNextSongPath ()
 
int calculateLeadLagFactor (float fTickSize)
 Calculates the lookahead for a specific tick size. More...
 
int calculateLookahead (float fTickSize)
 Calculates time offset (in frames) used to determine the notes process by the audio engine. More...
 
bool haveJackAudioDriver () const
 
bool haveJackTransport () const
 
JackAudioDriver::Timebase getJackTimebaseState () const
 
bool isUnderSessionManagement () const
 
void setInitialSong (Song *pSong)
 Sets the first Song to be loaded under session management. More...
 
- Public Member Functions inherited from Object
 ~Object ()
 destructor More...
 
 Object (const Object &obj)
 copy constructor More...
 
 Object (const char *class_name)
 constructor More...
 
const char * class_name () const
 return the class name More...
 
virtual QString toQString (const QString &sPrefix, bool bShort=true) const
 Formatted string version for debugging purposes. More...
 
void Print (bool bShort=true) const
 Prints content of toQString() via DEBUGLOG. More...
 

Static Public Member Functions

static void create_instance ()
 Creates all the instances used within Hydrogen in the right order. More...
 
static Hydrogenget_instance ()
 Returns the current Hydrogen instance __instance. More...
 
- Static Public Member Functions inherited from Object
static void set_count (bool flag)
 enable/disable class instances counting More...
 
static bool count_active ()
 return true if class instances counting is enabled More...
 
static unsigned objects_count ()
 return the number of objects More...
 
static void write_objects_map_to (std::ostream &out)
 output the full objects map to a given ostream More...
 
static void write_objects_map_to_cerr ()
 output objects map to stderr More...
 
static int bootstrap (Logger *logger, bool count=false)
 must be called before any Object instantiation ! More...
 
static Loggerlogger ()
 return the logger instance More...
 

Data Fields

QString lastMidiEvent
 Last received midi message. More...
 
int lastMidiEventParameter
 
int m_nInstrumentLookupTable [MAX_INSTRUMENTS]
 midi lookuptable More...
 
int m_nMaxTimeHumanize
 Maximum time (in frames) a note's position can be off due to the humanization (lead-lag). More...
 

Private Member Functions

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

Private Attributes

Song__song
 Pointer to the current song. More...
 
float m_ntaktoMeterCompute
 beatcounter note length More...
 
int m_nbeatsToCount
 beatcounter beats to count More...
 
int m_nEventCount
 beatcounter event More...
 
int m_nTempoChangeCounter
 count tempochanges for timeArray More...
 
int m_nBeatCount
 beatcounter beat to count More...
 
double m_nBeatDiffs [16]
 beat diff More...
 
timeval m_CurrentTime
 timeval More...
 
int m_nCoutOffset
 
int m_nStartOffset
 ms default 0 More...
 
Song::SongMode m_oldEngineMode
 ms default 0 More...
 
bool m_bOldLoopEnabled
 
bool m_bExportSessionIsActive
 
GUIState m_GUIState
 Specifies whether the Qt5 GUI is active. More...
 
Songm_pNextSong
 Stores a new Song which is about of the loaded by the GUI. More...
 
QString m_sNextSongPath
 
Timelinem_pTimeline
 Local instance of the Timeline object. More...
 
CoreActionControllerm_pCoreActionController
 Local instance of the CoreActionController object. More...
 
QString m_sCurrentDrumkitName
 Name of the currently used Drumkit. More...
 
Filesystem::Lookup m_currentDrumkitLookup
 Whether the current Drumkit is located at user or system level. More...
 
std::list< Instrument * > __instrument_death_row
 Deleting instruments too soon leads to potential crashes. More...
 

Static Private Attributes

static Hydrogen__instance = nullptr
 Static reference to the Hydrogen singleton. More...
 

Additional Inherited Members

- Static Public Attributes inherited from Object
static QString sPrintIndention = " "
 String used to format the debugging string output of some core classes. More...
 
- Static Protected Attributes inherited from Object
static Logger__logger = nullptr
 logger instance pointer More...
 

Detailed Description

Hydrogen Audio Engine.

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 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.

◆ 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.

Constructor & Destructor Documentation

◆ ~Hydrogen()

~Hydrogen ( )

Destructor taking care of most of the clean up.

  1. Shuts down the NsmClient using NsmClient::shutdown() and deletes it.
  2. Deletes the OscServer object.
  3. Stops the AudioEngine if playing via audioEngine_stop().
  4. Calls removeSong(), audioEngine_stopAudioDrivers(), audioEngine_destroy(), __kill_instruments()
  5. Deletes the m_pCoreActionController and m_pTimeline object
  6. Sets __instance to NULL.

◆ 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.

Member Function Documentation

◆ __getMidiRealtimeNoteTickPosition()

unsigned int __getMidiRealtimeNoteTickPosition ( ) const

◆ __kill_instruments()

void __kill_instruments ( )
private

◆ __panic()

void __panic ( )

◆ addRealtimeNote()

void addRealtimeNote ( int  instrument,
float  velocity,
float  pan_L = 1.0,
float  pan_R = 1.0,
float  pitch = 0.0,
bool  noteoff = false,
bool  forcePlay = false,
int  msg1 = 0 
)

◆ calculateLeadLagFactor()

int calculateLeadLagFactor ( float  fTickSize)

Calculates the lookahead for a specific tick size.

During the humanization the onset of a Note will be moved Note::__lead_lag times the value calculated by this function.

Since the size of a tick is tempo dependent, fTickSize allows you to calculate the lead-lag factor for an arbitrary position on the Timeline.

Parameters
fTickSizeNumber of frames that make up one tick.
Returns
Five times the current size of a tick (TransportInfo::m_fTickSize) (in frames)

◆ calculateLookahead()

int calculateLookahead ( float  fTickSize)

Calculates time offset (in frames) used to determine the notes process by the audio engine.

Due to the humanization there might be negative offset in the position of a particular note. To be able to still render it appropriately, we have to look into and handle notes from the future.

The Lookahead is the sum of the m_nMaxTimeHumanize and calculateLeadLagFactor() plus one (since it has to be larger than that).

Parameters
fTickSizeNumber of frames that make up one tick. Passed to calculateLeadLagFactor().
Returns
Frame offset

◆ create_instance()

void create_instance ( )
static

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

  1. H2Core::Logger::create_instance()
  2. MidiMap::create_instance()
  3. Preferences::create_instance()
  4. EventQueue::create_instance()
  5. MidiActionManager::create_instance()

If H2CORE_HAVE_OSC was set during compilation, the following instances will be created as well.

  1. NsmClient::create_instance()
  2. OscServer::create_instance() using Preferences::get_instance() as input

If all instances are created and the actual Hydrogen instance __instance is still 0, it will be properly constructed via Hydrogen().

The AudioEngine::create_instance(), Effects::create_instance(), and Playlist::create_instance() functions will be called from within audioEngine_init().

◆ get_instance()

static Hydrogen * get_instance ( )
inlinestatic

Returns the current Hydrogen instance __instance.

◆ getAudioOutput()

AudioOutput * getAudioOutput ( ) const

Used to display audio driver info.

◆ getBcStatus()

int getBcStatus ( )

◆ getbeatsToCount()

int getbeatsToCount ( )

◆ getCoreActionController()

CoreActionController * getCoreActionController ( ) const
inline

◆ getCurrentDrumkitLookup()

Filesystem::Lookup getCurrentDrumkitLookup ( )
inline
Returns
m_currentDrumkitLookup

◆ getCurrentDrumkitName()

const QString & getCurrentDrumkitName ( )
inline
Returns
m_sCurrentDrumkitName

◆ getCurrentPatternList()

PatternList * getCurrentPatternList ( )

◆ getGUIState()

Hydrogen::GUIState getGUIState ( ) const
inline
Returns
m_GUIState

◆ getIsExportSessionActive()

bool getIsExportSessionActive ( ) const
inline

◆ getJackTimebaseState()

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

◆ getLadspaFXPeak()

void getLadspaFXPeak ( int  nFX,
float *  fL,
float *  fR 
)

◆ getMasterPeak_L()

float getMasterPeak_L ( )

◆ getMasterPeak_R()

float getMasterPeak_R ( )

◆ getMaxProcessTime()

float getMaxProcessTime ( ) const

◆ getMidiInput()

MidiInput * getMidiInput ( ) const

Used to display midi driver info.

◆ getMidiOutput()

MidiOutput * getMidiOutput ( ) const

◆ getNewBpmJTM()

float getNewBpmJTM ( ) const

Returns the fallback speed.

Returns
m_fNewBpmJTM

◆ getNextPatterns()

PatternList * getNextPatterns ( )

◆ getNextSong()

Song * getNextSong ( ) const
inline
Returns
m_pNextSong

◆ getNextSongPath()

QString getNextSongPath ( )
inline

◆ getNoteLength()

float getNoteLength ( )

◆ getPatternLength()

long getPatternLength ( int  nPattern)

Get the length (in ticks) of the nPattern th pattern.

Access the length of the first Pattern found in the PatternList at nPattern - 1.

This function should also work if the loop mode is enabled in Song::getIsLoopEnabled().

Parameters
nPatternPosition + 1 of the desired PatternList.
Returns

◆ getPatternPos()

int getPatternPos ( )

Get the position of the current Pattern in the Song.

Returns
m_nSongPos

◆ getPlaybackTrackState()

bool getPlaybackTrackState ( ) const
inline

Wrapper around Song::getPlaybackTrackEnabled().

Returns
Whether the playback track is enabled or false, if no Song was selected (getSong() return nullptr).

◆ getPosForTick()

int getPosForTick ( unsigned long  TickPos,
int *  nPatternStartTick 
)

Returns the pattern number corresponding to the tick position TickPos.

Wrapper around function findPatternInTick() (globally defined in hydrogen.cpp).

Parameters
TickPosPosition in ticks.
nPatternStartTickPointer to an int the starting position (in ticks) of the corresponding pattern will be written to.
Returns

◆ getProcessTime()

float getProcessTime ( ) const

◆ getRealtimeFrames()

unsigned long getRealtimeFrames ( )

Returns the current realtime transport position TransportInfo::m_nFrames.

Returns
m_nRealtimeFrames

◆ getRealtimeTickPosition()

unsigned long getRealtimeTickPosition ( )

Keep track of the tick position in realtime.

Firstly, it gets the current transport position in frames m_nRealtimeFrames and converts it into ticks using TransportInfo::m_fTickSize. Afterwards, it accesses how much time passed since the last update of m_currentTickTime, converts the time difference + AudioOutput::getBufferSize()/ AudioOutput::getSampleRate() in frames, and adds the result to the first value to support keyboard and MIDI events as well.

Returns
Current position in ticks.

◆ getSelectedInstrumentNumber()

int getSelectedInstrumentNumber ( )

◆ getSelectedPatternNumber()

int getSelectedPatternNumber ( )

◆ getSong()

Song * getSong ( ) const
inline

Get the current song.

Returns
__song

◆ getState()

int getState ( ) const

Returns the current state of the audio engine.

Returns
m_audioEngineState

◆ getTickForPosition()

long getTickForPosition ( int  pos)

Get the total number of ticks passed up to a Pattern at position pos.

The function will loop over all and sums up their Pattern::__length. If one of the Pattern is NULL or no Pattern is present one of the PatternList, MAX_NOTES will be added instead.

The driver should be LOCKED when calling this!

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

◆ getTickPosition()

unsigned long getTickPosition ( )

◆ getTimeline()

Timeline * getTimeline ( ) const
inline

◆ getTimelineBpm()

float getTimelineBpm ( int  nBar)

Returns the local speed at a specific nBar in the Timeline.

If Hydrogen is in Song::PATTERN_MODE or Preferences::__useTimelineBpm is set to false, the global speed of the current Song Song::m_fBpm or, if no Song is present yet, the result of getNewBpmJTM() will be returned.

Its counterpart is setTimelineBpm().

Parameters
nBarPosition (in whole patterns) along the Timeline to access the tempo at.
Returns
Speed in beats per minute.

◆ getTotalFrames()

unsigned long getTotalFrames ( )

◆ handleBeatCounter()

void handleBeatCounter ( )

◆ haveJackAudioDriver()

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

◆ haveJackTransport()

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

◆ initBeatcounter()

void initBeatcounter ( )
private

Auxiliary function setting a bunch of global variables.

◆ instrumentHasNotes()

bool instrumentHasNotes ( Instrument pInst)

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

◆ isUnderSessionManagement()

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

◆ loadDrumkit() [1/2]

int loadDrumkit ( Drumkit pDrumkitInfo)

Wrapper around loadDrumkit( Drumkit, bool ) with the conditional argument set to true.

Returns
0 In case something unexpected happens, it will be indicated with ERRORLOG messages.

◆ loadDrumkit() [2/2]

int loadDrumkit ( Drumkit pDrumkitInfo,
bool  conditional 
)

Loads the H2Core::Drumkit provided in pDrumkitInfo into the current session.

When under session management (see NsmClient::m_bUnderSessionManagement) the function will create a symlink to the loaded H2Core::Drumkit using the name "drumkit" in the folder NsmClient::m_sSessionFolderPath.

Parameters
pDrumkitInfoFull-fledged H2Core::Drumkit to load.
conditionalArgument passed on as second input argument to removeInstrument().
Returns
0 In case something unexpected happens, it will be indicated with ERRORLOG messages.

◆ loadPlaybackTrack()

void loadPlaybackTrack ( const QString  filename)

Wrapper function for loading the playback track.

Calls Song::setPlaybackTrackFilename() and Sampler::reinitialize_playback_track(). While the former one is responsible to store metadata about the playback track, the latter one does load it to a new InstrumentLayer. The function is called by SongEditorPanel::editPlaybackTrackBtnPressed()

Parameters
filenameName of the file to load as the playback track

◆ midi_noteOn()

void midi_noteOn ( Note note)

◆ offJackMaster()

void offJackMaster ( )

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

◆ onJackMaster()

void onJackMaster ( )

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

◆ onTapTempoAccelEvent()

void onTapTempoAccelEvent ( )

◆ previewInstrument()

void previewInstrument ( Instrument pInstr)

◆ previewSample()

void previewSample ( Sample pSample)

◆ raiseError()

void raiseError ( unsigned  nErrorCode)

◆ recreateOscServer()

void recreateOscServer ( )

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

◆ refreshInstrumentParameters()

void refreshInstrumentParameters ( int  nInstrument)

◆ removeInstrument()

void removeInstrument ( int  instrumentnumber,
bool  conditional 
)

Delete an Instrument.

If conditional is true, and there are some Pattern that are using this Instrument, it's not deleted anyway.

◆ removeSong()

void removeSong ( )

◆ renameJackPorts()

void renameJackPorts ( Song pSong)

◆ resetPatternStartTick()

void resetPatternStartTick ( )

Move playback in Pattern mode to the beginning of the pattern.

Resetting the global variable m_nPatternStartTick to -1 if the current Song mode is Song::PATTERN_MODE.

◆ restartDrivers()

void restartDrivers ( )

◆ restartLadspaFX()

void restartLadspaFX ( )

◆ sequencer_play()

void sequencer_play ( )

Start the internal sequencer.

◆ sequencer_setNextPattern()

void sequencer_setNextPattern ( int  pos)

Adding and removing a Pattern from m_pNextPatterns.

After locking the AudioEngine the function retrieves the particular pattern pos from the Song::m_pPatternList and either deletes it from m_pNextPatterns if already present or add it to the same pattern list if not present yet.

If the Song is not in Song::PATTERN_MODE or pos is not within the range of Song::m_pPatternList, m_pNextPatterns will be cleared instead.

Parameters
posIndex of a particular pattern in Song::m_pPatternList, which should be added to m_pNextPatterns.

◆ sequencer_setOnlyNextPattern()

void sequencer_setOnlyNextPattern ( int  pos)

Clear m_pNextPatterns and add one Pattern.

After locking the AudioEngine the function clears m_pNextPatterns, fills it with all currently played one in m_pPlayingPatterns, and appends the particular pattern pos from the Song::m_pPatternList.

If the Song is not in Song::PATTERN_MODE or pos is not within the range of Song::m_pPatternList, m_pNextPatterns will be just cleared.

Parameters
posIndex of a particular pattern in Song::m_pPatternList, which should be added to m_pNextPatterns.

◆ sequencer_stop()

void sequencer_stop ( )

Stop the internal sequencer.

◆ setBcOffsetAdjust()

void setBcOffsetAdjust ( )

◆ setbeatsToCount()

void setbeatsToCount ( int  beatstocount)

Updates m_nbeatsToCount.

Parameters
beatstocountNew value

◆ setBPM()

void setBPM ( float  fBPM)

Updates the speed.

It calls AudioOutput::setBpm() and setNewBpmJTM() with fBPM as input argument and sets Song::m_fBpm to fBPM.

This function will be called with the AudioEngine in LOCKED state.

Parameters
fBPMNew speed in beats per minute.

◆ setCurrentDrumkitLookup()

void setCurrentDrumkitLookup ( Filesystem::Lookup  lookup)
inline
Parameters
lookupsets m_currentDrumkitLookup

◆ setCurrentDrumkitName()

void setCurrentDrumkitName ( const QString &  sName)
inline
Parameters
sNamesets m_sCurrentDrumkitName

◆ setCurrentPatternList()

void setCurrentPatternList ( PatternList pPatternList)

Sets m_pPlayingPatterns.

Before setting the variable it first locks the AudioEngine. In addition, it also pushes the Event EVENT_PATTERN_CHANGED with the value -1 to the EventQueue.

Parameters
pPatternListSets m_pPlayingPatterns.

◆ setGUIState()

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

◆ setInitialSong()

void setInitialSong ( Song pSong)

Sets the first Song to be loaded under session management.

Enables the creation of a JACK client with all per track output ports present right from the start. This is necessary to ensure their connection can be properly restored by external tools.

The function will only work if no audio driver is present (since this is the intended use case and the function will be harmful if used otherwise. Use setSong() instead.) and fails if there is already a Song present.

Parameters
pSongSong to be loaded.

◆ setLadspaFXPeak()

void setLadspaFXPeak ( int  nFX,
float  fL,
float  fR 
)

◆ setMasterPeak_L()

void setMasterPeak_L ( float  value)

◆ setMasterPeak_R()

void setMasterPeak_R ( float  value)

◆ setNewBpmJTM()

void setNewBpmJTM ( float  bpmJTM)

Set the fallback speed #m_nNewBpmJTM.

Parameters
bpmJTMNew default tempo.

◆ setNextSong()

void setNextSong ( Song pNextSong)
inline
Parameters
pNextSongSets m_pNextSong. Song which is about to be loaded by the GUI.

◆ setNextSongPath()

void setNextSongPath ( const QString  sSongPath)
inline

◆ setNoteLength()

void setNoteLength ( float  notelength)

◆ setPatternPos()

void setPatternPos ( int  pos)

Relocate the position to another Pattern in the Song.

The position of a Pattern in frames (see TransportInfo::m_nFrames for details) will be determined by retrieving the tick number the Pattern is located at using getTickForPosition() and multiplying it with TransportInfo::m_fTickSize. The resulting value will be used by the AudioOutput::locate() function of your audio driver to relocate the playback position.

If m_audioEngineState is not STATE_PLAYING, the variables m_nSongPos and m_nPatternTickPosition will be set to pos and 0 right away.

Parameters
posPosition of the Pattern to relocate at. All values smaller than -1 will be set to -1, which marks the beginning of the Song.

◆ setPlaybackTrackState()

bool setPlaybackTrackState ( const bool  state)

Wrapper around Song::setPlaybackTrackEnabled().

Parameters
stateWhether the playback track is enabled. It will be replaced by false, if no Song was selected (getSong() return nullptr).

◆ setRealtimeFrames()

void setRealtimeFrames ( unsigned long  frames)

Sets m_nRealtimeFrames.

Parameters
framesCurrent transport realtime position

◆ setSelectedInstrumentNumber()

void setSelectedInstrumentNumber ( int  nInstrument)

◆ setSelectedPatternNumber()

void setSelectedPatternNumber ( int  nPat)

Sets m_nSelectedPatternNumber.

If Preferences::m_pPatternModePlaysSelected is set to true, the AudioEngine is locked before nPat will be assigned. But in any case the function will push the EVENT_SELECTED_PATTERN_CHANGED Event to the EventQueue.

If nPat is equal to m_nSelectedPatternNumber, the function will return right away.

Parameters
nPatSets m_nSelectedPatternNumber

◆ setSong()

void setSong ( Song newSong)

Sets the current song __song to newSong.

Parameters
newSongPointer to the new Song object.

◆ setTapTempo()

void setTapTempo ( float  fInterval)

◆ setTimelineBpm()

void setTimelineBpm ( )

Updates Song::m_fBpm, TransportInfo::m_fBPM, and m_fNewBpmJTM to the local speed.

The local speed will be obtained by calling getTimelineBpm() with getPatternPos() as input argument and set for the current song and transport. For setting the fallback speed m_fNewBpmJTM, getRealtimeTickPosition() will be used instead.

If Preferences::__useTimelineBpm is set to false or Hydrogen uses JACK transport in the presence of an external timebase master, the function will return without performing any actions.

◆ startExportSession()

void startExportSession ( int  rate,
int  depth 
)

◆ startExportSong()

void startExportSong ( const QString &  filename)

Export a song to a wav file.

◆ startNsmClient()

void startNsmClient ( )

◆ stopExportSession()

void stopExportSession ( )

◆ stopExportSong()

void stopExportSong ( )

◆ toggleOscServer()

void toggleOscServer ( bool  bEnable)

Starts/stops the OSC server.

Parameters
bEnabletrue = start, false = stop.

◆ togglePlaysSelected()

void togglePlaysSelected ( )

Switches playback to focused pattern.

If the current Song is in Song::PATTERN_MODE, the AudioEngine will be locked and Preferences::m_bPatternModePlaysSelected negated. If the latter was true before calling this function, m_pPlayingPatterns will be cleared and replaced by the Pattern indexed with m_nSelectedPatternNumber.

This function will be called either by MainForm::eventFilter() when pressing Qt::Key_L or by SongEditorPanel::modeActionBtnPressed().

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().

◆ __instrument_death_row

std::list<Instrument*> __instrument_death_row
private

Deleting instruments too soon leads to potential crashes.

◆ __song

Song* __song
private

Pointer to the current song.

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

◆ lastMidiEvent

QString lastMidiEvent

Last received midi message.

◆ lastMidiEventParameter

int lastMidiEventParameter

◆ m_bExportSessionIsActive

bool m_bExportSessionIsActive
private

◆ m_bOldLoopEnabled

bool m_bOldLoopEnabled
private

◆ m_currentDrumkitLookup

Filesystem::Lookup m_currentDrumkitLookup
private

Whether the current Drumkit is located at user or system level.

◆ m_CurrentTime

timeval m_CurrentTime
private

timeval

◆ 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 Song must be set via the GUI if active. Else the GUI will freeze.

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

◆ m_nBeatCount

int m_nBeatCount
private

beatcounter beat to count

◆ m_nBeatDiffs

double m_nBeatDiffs[16]
private

beat diff

◆ m_nbeatsToCount

int m_nbeatsToCount
private

beatcounter beats to count

◆ m_nCoutOffset

int m_nCoutOffset
private

◆ m_nEventCount

int m_nEventCount
private

beatcounter event

◆ m_nInstrumentLookupTable

int m_nInstrumentLookupTable[MAX_INSTRUMENTS]

midi lookuptable

◆ m_nMaxTimeHumanize

int m_nMaxTimeHumanize

Maximum time (in frames) a note's position can be off due to the humanization (lead-lag).

Required to calculateLookahead(). Set to 2000.

◆ m_nStartOffset

int m_nStartOffset
private

ms default 0

◆ m_ntaktoMeterCompute

float m_ntaktoMeterCompute
private

beatcounter note length

◆ m_nTempoChangeCounter

int m_nTempoChangeCounter
private

count tempochanges for timeArray

◆ m_oldEngineMode

Song::SongMode m_oldEngineMode
private

ms default 0

◆ m_pCoreActionController

CoreActionController* m_pCoreActionController
private

Local instance of the CoreActionController object.

◆ m_pNextSong

Song* m_pNextSong
private

Stores a new Song which is about of the loaded by the GUI.

If m_GUIState is true, the core part of must not load a new Song itself. Instead, the new Song is prepared and stored in this object to be loaded by HydrogenApp::updateSongEvent() if H2Core::EVENT_UPDATE_SONG is pushed with a '1'.

Set by setNextSong() and accessed via getNextSong().

◆ m_pTimeline

Timeline* m_pTimeline
private

Local instance of the Timeline object.

◆ m_sCurrentDrumkitName

QString m_sCurrentDrumkitName
private

Name of the currently used Drumkit.

◆ m_sNextSongPath

QString m_sNextSongPath
private