23#ifndef H2_JACK_OUTPUT_H
24#define H2_JACK_OUTPUT_H
30#if defined(H2CORE_HAVE_JACK) || _DOXYGEN_
37#include <jack/transport.h>
48class InstrumentComponent;
144 virtual int connect()
override;
160 virtual int getXRuns()
const override;
232 float*
getTrackOut_L( std::shared_ptr<Instrument> instr, std::shared_ptr<InstrumentComponent> pCompo );
247 float*
getTrackOut_R( std::shared_ptr<Instrument> instr, std::shared_ptr<InstrumentComponent> pCompo );
263 virtual int init(
unsigned bufferSize )
override;
417 jack_nframes_t nFrames,
418 jack_position_t* pJackPosition,
459 void setTrackOutput(
int n, std::shared_ptr<Instrument> instr, std::shared_ptr<InstrumentComponent> pCompo, std::shared_ptr<Song> pSong );
598 static QString
checkExecutable(
const QString& sExecutable,
const QString& sOption );
609class JackAudioDriver :
public NullDriver {
Base abstract class for audio output classes.
JACK (Jack Audio Connection Kit) server driver.
virtual void disconnect() override
Disconnects the JACK client of the Hydrogen from the JACK server.
int m_nTrackPortCount
Total number of output ports currently in use.
static QString checkExecutable(const QString &sExecutable, const QString &sOption)
Calls sExecutable in a subprocess using the sOption CLI option and reports the results.
jack_port_t * m_pTrackOutputPortsL[MAX_INSTRUMENTS]
Vector of all left audio output ports currently used by the local JACK client.
float getMasterBpm() const
bool compareAdjacentBBT() const
Compares the BBT information stored in m_JackTransportPos and m_previousJackTransportPos with respect...
virtual float * getOut_L() override
Get content in the left stereo output port.
Timebase m_timebaseState
More user-friendly version of m_nTimebaseTracking.
virtual int init(unsigned bufferSize) override
Initializes the JACK audio driver.
JackAudioDriver(JackProcessCallback m_processCallback)
Constructor of the JACK server driver.
bool m_bConnectDefaults
Specifies whether the default left and right (master) audio JACK ports will be automatically connecte...
static unsigned long jackServerSampleRate
Sample rate of the JACK audio server.
bool getConnectDefaults()
int m_nTimebaseTracking
Whether Hydrogen or another program is Jack timebase master.
static JackAudioDriver * pJackDriverInstance
Instance of the JackAudioDriver.
QString m_sOutputPortName2
Destination of the right source port m_pOutputPort2, for which a connection will be established in co...
QString m_sOutputPortName1
Destination of the left source port m_pOutputPort1, for which a connection will be established in con...
float * getTrackOut_R(unsigned nTrack)
Get content of right output port of a specific track.
static int jackDriverSampleRate(jack_nframes_t nframes, void *param)
Callback function for the JACK audio server to set the sample rate jackServerSampleRate.
void clearPerTrackAudioBuffers(uint32_t nFrames)
Resets the buffers contained in m_pTrackOutputPortsL and m_pTrackOutputPortsR.
jack_port_t * m_pOutputPort2
Right source port.
int m_trackMap[MAX_INSTRUMENTS][MAX_COMPONENTS]
Matrix containing the track number of each component of all instruments.
void startTransport()
Tells the JACK server to start transport.
virtual float * getOut_R() override
Get content in the right stereo output port.
static int jackServerXRuns
Number of XRuns since the driver started.
virtual unsigned getBufferSize() override
void setTrackOutput(int n, std::shared_ptr< Instrument > instr, std::shared_ptr< InstrumentComponent > pCompo, std::shared_ptr< Song > pSong)
Renames the n 'th port of JACK client and creates it if it's not already present.
Timebase
Whether Hydrogen or another program is Jack timebase master.
@ None
Only normal clients registered.
@ Master
Hydrogen itself is timebase master.
@ Slave
An external program is timebase master and Hydrogen will disregard all tempo markers on the Timeline ...
jack_client_t * m_pClient
Object holding the external client session with the JACK server.
static void printJackTransportPos(const jack_position_t *pPos)
void deactivate()
Deactivates the JACK client of Hydrogen and disconnects all ports belonging to it.
void setConnectDefaults(bool flag)
virtual int connect() override
Connects to output ports via the JACK server.
Timebase getTimebaseState() const
jack_position_t m_JackTransportPos
Current transport position obtained using jack_transport_query() (jack/transport.h).
jack_position_t m_previousJackTransportPos
Used for detecting changes in the BBT transport information with external timebase master application...
jack_port_t * m_pOutputPort1
Left source port.
static int jackDriverBufferSize(jack_nframes_t nframes, void *arg)
Callback function for the JACK audio server to set the buffer size jackServerBufferSize.
static jack_nframes_t jackServerBufferSize
Buffer size of the JACK audio server.
void stopTransport()
Tells the JACK server to stop transport.
void updateTransportPosition()
The function queries the transport position and additional information from the JACK server,...
static void jackDriverShutdown(void *arg)
Callback function for the JACK audio server to shutting down the JACK driver.
static int jackXRunCallback(void *arg)
Report an XRun event to the GUI.
void initTimebaseMaster()
Registers Hydrogen as JACK timebase master.
static bool checkSupport()
Attempts to call several JACK executables in order to check for existing JACK support.
void makeTrackOutputs(std::shared_ptr< Song > pSong)
Creates per component output ports for each instrument.
virtual unsigned getSampleRate() override
static void JackTimebaseCallback(jack_transport_state_t state, jack_nframes_t nFrames, jack_position_t *pJackPosition, int new_pos, void *arg)
Callback function for the JACK server to supply additional timebase information.
JackProcessCallback m_processCallback
Main process callback.
~JackAudioDriver()
Destructor of the JACK server driver.
void printState() const
Show debugging information.
float * getTrackOut_L(unsigned nTrack)
Get content of left output port of a specific track.
jack_transport_state_t m_JackTransportState
Current transport state returned by jack_transport_query() (jack/transport.h).
void releaseTimebaseMaster()
Release Hydrogen from the JACK timebase master responsibilities.
void relocateUsingBBT()
Uses the bar-beat-tick information to relocate the transport position.
jack_port_t * m_pTrackOutputPortsR[MAX_INSTRUMENTS]
Vector of all right audio output ports currently used by the local JACK client.
void locateTransport(long long nFrame)
Re-positions the transport position to nFrame.
virtual int getXRuns() const override
Get the number of XRuns that occurred since the audio driver has started.
#define MAX_INSTRUMENTS
Maximum number of instruments allowed in Hydrogen.
#define MAX_COMPONENTS
Maximum number of components each Instrument is allowed to have.
int(* audioProcessCallback)(uint32_t, void *)