2013-12-08 22:44:43 +01:00
|
|
|
/*
|
|
|
|
* Author: Harry van Haaren 2013
|
|
|
|
* harryhaaren@gmail.com
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2013-04-20 12:37:36 +02:00
|
|
|
|
|
|
|
#ifndef LUPPP_JACK_H
|
|
|
|
#define LUPPP_JACK_H
|
|
|
|
|
|
|
|
// Library
|
2013-05-13 23:04:12 +02:00
|
|
|
#include <vector>
|
2013-04-20 12:37:36 +02:00
|
|
|
#include <cstring>
|
|
|
|
#include <jack/jack.h>
|
|
|
|
#include <jack/midiport.h>
|
2013-05-14 01:03:43 +02:00
|
|
|
#include <jack/transport.h>
|
2013-04-20 12:37:36 +02:00
|
|
|
|
2013-10-12 14:19:37 +02:00
|
|
|
#include "event.hxx"
|
2013-09-03 18:44:43 +02:00
|
|
|
|
2013-10-12 14:19:37 +02:00
|
|
|
class MidiIO;
|
2013-05-13 23:04:12 +02:00
|
|
|
|
2013-10-12 14:19:37 +02:00
|
|
|
class Reverb;
|
|
|
|
class DBMeter;
|
2013-07-28 15:20:54 +02:00
|
|
|
|
2013-10-12 14:19:37 +02:00
|
|
|
class State;
|
|
|
|
class Logic;
|
|
|
|
class Looper;
|
|
|
|
class Metronome;
|
|
|
|
class GridLogic;
|
|
|
|
class TimeManager;
|
|
|
|
class ControllerUpdater;
|
|
|
|
|
|
|
|
class TrackOutput;
|
|
|
|
|
|
|
|
// INPUT_TO
|
|
|
|
//#include "gridlogic.hxx"
|
2013-09-11 13:57:31 +02:00
|
|
|
|
2013-05-13 23:04:12 +02:00
|
|
|
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:
|
2013-11-08 01:18:48 +01:00
|
|
|
Jack(std::string name);
|
2013-09-21 00:28:59 +02:00
|
|
|
~Jack();
|
2013-04-20 12:37:36 +02:00
|
|
|
|
2013-11-08 01:18:48 +01:00
|
|
|
static void setup(std::string name);
|
|
|
|
|
2013-04-20 12:37:36 +02:00
|
|
|
void activate();
|
2013-09-21 00:28:59 +02:00
|
|
|
/// quits the JACK client, destroying ports etc. Call only on exit of Luppp.
|
|
|
|
void quit();
|
|
|
|
|
2013-04-20 12:37:36 +02:00
|
|
|
int getBuffersize();
|
|
|
|
int getSamplerate();
|
2013-05-13 23:04:12 +02:00
|
|
|
|
2013-11-02 04:32:33 +01:00
|
|
|
// Luppp process callback: bar() events can occur between these
|
|
|
|
void processFrames(int nframes);
|
|
|
|
|
2013-07-31 18:31:47 +02:00
|
|
|
/// get functions for components owned by Jack
|
2013-08-26 17:34:51 +02:00
|
|
|
Looper* getLooper(int t);
|
|
|
|
TrackOutput* getTrackOutput(int t);
|
|
|
|
|
2013-09-06 01:28:11 +02:00
|
|
|
State* getState(){return state;}
|
2013-08-05 14:56:38 +02:00
|
|
|
Logic* getLogic(){return logic;}
|
2013-08-26 17:34:51 +02:00
|
|
|
Metronome* getMetronome(){return metronome;}
|
2013-08-04 19:04:26 +02:00
|
|
|
GridLogic* getGridLogic(){return gridLogic;}
|
2013-09-17 14:11:11 +02:00
|
|
|
TimeManager* getTimeManager(){return timeManager;}
|
2013-07-31 19:01:51 +02:00
|
|
|
ControllerUpdater* getControllerUpdater(){return controllerUpdater;}
|
|
|
|
|
2013-10-01 18:08:19 +02:00
|
|
|
/// register a MIDI observer
|
2013-10-03 01:25:48 +02:00
|
|
|
void registerMidiIO( MidiIO* mo );
|
|
|
|
void unregisterMidiIO( MidiIO* mo );
|
2013-09-06 15:05:57 +02:00
|
|
|
|
2013-09-20 14:11:47 +02:00
|
|
|
/// set the master i/o volume / sends
|
|
|
|
void inputVolume( float vol );
|
2013-09-20 11:29:05 +02:00
|
|
|
void masterVolume( float vol );
|
2013-10-07 16:21:24 +02:00
|
|
|
void returnVolume( float vol );
|
2013-09-20 13:40:50 +02:00
|
|
|
void inputTo(INPUT_TO to, float v);
|
2013-09-20 14:02:27 +02:00
|
|
|
void inputToActive(INPUT_TO to, bool a);
|
2013-07-31 12:34:28 +02:00
|
|
|
|
2013-10-01 18:42:16 +02:00
|
|
|
jack_client_t* getJackClientPointer()
|
|
|
|
{
|
|
|
|
return client;
|
|
|
|
};
|
2013-10-18 02:06:34 +02:00
|
|
|
|
2013-11-19 23:47:57 +01:00
|
|
|
void resetMidiBindingState();
|
|
|
|
|
2013-10-18 02:06:34 +02:00
|
|
|
// MIDI binding creation
|
|
|
|
bool bindingEventRecordEnable;
|
|
|
|
int bindingEventType;
|
2013-10-18 02:28:00 +02:00
|
|
|
int bindingTrack;
|
|
|
|
int bindingScene;
|
|
|
|
int bindingSend;
|
|
|
|
int bindingActive;
|
2013-04-20 12:37:36 +02:00
|
|
|
|
|
|
|
private:
|
2013-08-13 17:35:27 +02:00
|
|
|
jack_client_t* client;
|
|
|
|
|
2013-08-04 19:04:26 +02:00
|
|
|
Buffers buffers;
|
2013-09-17 14:11:11 +02:00
|
|
|
TimeManager* timeManager;
|
2013-08-04 19:04:26 +02:00
|
|
|
Metronome* metronome;
|
2013-09-06 01:28:11 +02:00
|
|
|
State* state;
|
2013-08-05 14:56:38 +02:00
|
|
|
Logic* logic;
|
2013-08-04 19:04:26 +02:00
|
|
|
GridLogic* gridLogic;
|
|
|
|
ControllerUpdater* controllerUpdater;
|
2013-04-20 12:37:36 +02:00
|
|
|
|
2013-08-04 19:04:26 +02:00
|
|
|
vector<Looper*> loopers;
|
|
|
|
vector<TrackOutput*> trackOutputs;
|
2013-09-06 15:05:57 +02:00
|
|
|
|
2013-10-03 01:25:48 +02:00
|
|
|
vector<MidiIO*> midiIO;
|
2013-07-31 19:01:51 +02:00
|
|
|
|
2013-07-28 15:20:54 +02:00
|
|
|
// FX
|
2013-09-10 22:44:47 +02:00
|
|
|
DBMeter* inputMeter;
|
2013-07-28 17:00:17 +02:00
|
|
|
DBMeter* masterMeter;
|
2013-09-20 14:11:47 +02:00
|
|
|
|
2013-09-20 13:40:50 +02:00
|
|
|
float inputVol;
|
2013-09-20 14:11:47 +02:00
|
|
|
float masterVol;
|
2013-10-07 16:21:24 +02:00
|
|
|
float returnVol;
|
2013-09-20 13:40:50 +02:00
|
|
|
|
|
|
|
float inputToMixVol;
|
|
|
|
float inputToSendVol;
|
2013-09-20 14:02:27 +02:00
|
|
|
float inputToXSideVol;
|
2013-09-20 16:38:23 +02:00
|
|
|
|
|
|
|
bool inputToKeyEnable;
|
|
|
|
bool inputToMixEnable;
|
|
|
|
bool inputToSendEnable;
|
2013-07-28 15:20:54 +02:00
|
|
|
|
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-09-11 02:32:58 +02:00
|
|
|
jack_port_t* masterReturnL;
|
|
|
|
jack_port_t* masterReturnR;
|
|
|
|
|
|
|
|
jack_port_t* sidechainKeyOutput;
|
|
|
|
jack_port_t* sidechainSignalOutput;
|
|
|
|
jack_port_t* sendOutput;
|
2013-04-20 12:37:36 +02:00
|
|
|
|
2013-05-18 17:37:03 +02:00
|
|
|
jack_port_t* masterMidiInput;
|
|
|
|
|
2013-11-02 04:32:33 +01:00
|
|
|
// JACK callback
|
|
|
|
int process (jack_nframes_t);
|
2013-04-20 12:37:36 +02:00
|
|
|
|
|
|
|
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* );
|
|
|
|
|
2013-07-28 15:20:54 +02:00
|
|
|
// UI update variables
|
|
|
|
int uiUpdateCounter;
|
|
|
|
int uiUpdateConstant;
|
2013-10-18 02:06:34 +02:00
|
|
|
|
2013-04-20 12:37:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // LUPPP_JACK_H
|
|
|
|
|