Loopp/src/jack.hxx

130 lines
3.4 KiB
C++
Raw Normal View History

2013-04-20 12:37:36 +02:00
#ifndef LUPPP_JACK_H
#define LUPPP_JACK_H
// Library
#include <vector>
2013-04-20 12:37:36 +02:00
#include <cstring>
#include <jack/jack.h>
#include <jack/midiport.h>
#include <jack/transport.h>
2013-04-20 12:37:36 +02:00
#include "state/state.hxx"
#include "logic.hxx"
#include "config.hxx"
#include "looper.hxx"
#include "metronome.hxx"
#include "gridlogic.hxx"
#include "trackoutput.hxx"
#include "timemanager.hxx"
#include "controllerupdater.hxx"
#include "dsp/dsp_reverb.hxx"
#include "dsp/dsp_dbmeter.hxx"
2013-08-16 01:57:44 +02:00
#include "dsp/dsp_sidechain_gain.hxx"
using namespace std;
2013-04-20 12:37:36 +02:00
2013-08-12 20:01:47 +02:00
/** Jack
This code contains the JACK client.
It allows reading / writing of audio / midi.
**/
2013-04-20 12:37:36 +02:00
class Jack
{
public:
Jack();
void activate();
int getBuffersize();
int getSamplerate();
/// get functions for components owned by Jack
Looper* getLooper(int t);
TrackOutput* getTrackOutput(int t);
State* getState(){return state;}
Logic* getLogic(){return logic;}
Metronome* getMetronome(){return metronome;}
GridLogic* getGridLogic(){return gridLogic;}
TimeManager* getTimeManager(){return &timeManager;}
ControllerUpdater* getControllerUpdater(){return controllerUpdater;}
/// register MIDI observers: they're called when a MIDI message arrives on
/// a port they're watching
void registerMidiObserver( MidiObserver* mo, std::string name );
/// writes MIDI messages to a MidiObserver's port
void midiObserverWriteMIDI( int portIndex, unsigned char* data );
2013-08-16 13:50:31 +02:00
void masterVolume( float vol ){masterVol = vol;}
2013-07-31 12:34:28 +02:00
/// sets reverb bus parameters
void setReverb( bool e, float d, float s );
2013-04-20 12:37:36 +02:00
private:
2013-08-13 17:35:27 +02:00
jack_client_t* client;
Buffers buffers;
TimeManager timeManager;
Metronome* metronome;
State* state;
Logic* logic;
GridLogic* gridLogic;
ControllerUpdater* controllerUpdater;
2013-04-20 12:37:36 +02:00
vector<Looper*> loopers;
vector<TrackOutput*> trackOutputs;
// FIXME: refactor MidiObserver ports / buffers into one class, single vector
vector<MidiObserver*> midiObservers;
vector<jack_port_t*> midiObserverInputPorts;
vector<jack_port_t*> midiObserverOutputPorts;
vector<void*> midiObserverInputBuffers;
vector<void*> midiObserverOutputBuffers;
// FX
Reverb* reverb;
SidechainGain* sidechainGain;
DBMeter* reverbMeter;
DBMeter* masterMeter;
2013-08-16 13:50:31 +02:00
float masterVol;
2013-04-20 12:37:36 +02:00
// JACK member variables
2013-07-31 18:19:15 +02:00
bool clientActive;
2013-04-20 12:37:36 +02:00
jack_port_t* masterInput;
2013-07-31 12:34:28 +02:00
jack_port_t* masterOutputL;
jack_port_t* masterOutputR;
2013-04-20 12:37:36 +02:00
jack_port_t* apcMidiInput;
jack_port_t* apcMidiOutput;
jack_port_t* masterMidiInput;
2013-04-20 12:37:36 +02:00
// JACK callbacks
int process (jack_nframes_t);
int timebase(jack_transport_state_t,
jack_nframes_t,
jack_position_t*,
int );
// static JACK callbacks
static int static_process (jack_nframes_t, void *);
static int static_timebase (jack_transport_state_t,
jack_nframes_t,
jack_position_t*,
int,
void* );
// UI update variables
int uiUpdateCounter;
int uiUpdateConstant;
2013-04-20 12:37:36 +02:00
};
#endif // LUPPP_JACK_H