2013-12-08 22:44:43 +01:00
|
|
|
/*
|
|
|
|
* Author: Harry van Haaren 2013
|
|
|
|
* harryhaaren@gmail.com
|
2016-12-27 13:47:19 +01:00
|
|
|
*
|
2013-12-08 22:44:43 +01:00
|
|
|
* 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.
|
2016-12-27 13:47:19 +01:00
|
|
|
*
|
2013-12-08 22:44:43 +01:00
|
|
|
* 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.
|
2016-12-27 13:47:19 +01:00
|
|
|
*
|
2013-12-08 22:44:43 +01:00
|
|
|
* 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
|
|
|
|
2019-06-09 10:41:19 +02:00
|
|
|
#ifndef LOOPP_JACK_H
|
|
|
|
#define LOOPP_JACK_H
|
2013-04-20 12:37:36 +02:00
|
|
|
|
|
|
|
// 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;
|
2016-10-03 19:43:13 +02:00
|
|
|
class JackSendReturn;
|
2013-10-12 14:19:37 +02:00
|
|
|
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
|
|
|
|
{
|
2016-12-27 13:47:19 +01:00
|
|
|
public:
|
|
|
|
Jack(std::string name);
|
|
|
|
~Jack();
|
|
|
|
|
|
|
|
static void setup(std::string name);
|
|
|
|
|
|
|
|
void activate();
|
2019-06-09 10:41:19 +02:00
|
|
|
/// quits the JACK client, destroying ports etc. Call only on exit of Loopp.
|
2016-12-27 13:47:19 +01:00
|
|
|
void quit();
|
|
|
|
|
|
|
|
int getBuffersize();
|
|
|
|
int getSamplerate();
|
|
|
|
|
2019-06-09 10:41:19 +02:00
|
|
|
// Loopp process callback: bar() events can occur between these
|
2016-12-27 13:47:19 +01:00
|
|
|
void processFrames(int nframes);
|
|
|
|
|
|
|
|
//Sets the first nframes of all the internal output buffers to zero. NO LIMIT CHECKS
|
|
|
|
void clearInternalBuffers(int nframes);
|
|
|
|
|
|
|
|
/// 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;
|
|
|
|
}
|
2019-05-31 20:59:48 +02:00
|
|
|
int getClipLength()
|
|
|
|
{
|
|
|
|
return clipLength;
|
|
|
|
}
|
2019-06-06 10:31:01 +02:00
|
|
|
bool getFreeRecMode() {
|
|
|
|
return freeRecMode;
|
|
|
|
}
|
2016-12-27 13:47:19 +01:00
|
|
|
GridLogic* getGridLogic()
|
|
|
|
{
|
|
|
|
return gridLogic;
|
|
|
|
}
|
|
|
|
TimeManager* getTimeManager()
|
|
|
|
{
|
|
|
|
return timeManager;
|
|
|
|
}
|
|
|
|
ControllerUpdater* getControllerUpdater()
|
|
|
|
{
|
|
|
|
return controllerUpdater;
|
|
|
|
}
|
2018-05-08 13:45:15 +02:00
|
|
|
|
|
|
|
float getInputVolume()
|
|
|
|
{
|
|
|
|
return inputVol;
|
|
|
|
}
|
2016-12-27 13:47:19 +01:00
|
|
|
|
|
|
|
void transportRolling(bool rolling);
|
|
|
|
|
|
|
|
/// register a MIDI observer
|
|
|
|
void registerMidiIO( MidiIO* mo );
|
|
|
|
void unregisterMidiIO( MidiIO* mo );
|
|
|
|
|
|
|
|
/// set the master i/o volume / sends
|
|
|
|
void inputVolume( float vol );
|
|
|
|
void masterVolume( float vol );
|
|
|
|
void returnVolume( float vol );
|
|
|
|
void inputTo(INPUT_TO to, float v);
|
|
|
|
void inputToActive(INPUT_TO to, bool a);
|
|
|
|
|
2019-05-31 20:59:48 +02:00
|
|
|
void
|
|
|
|
setClipLength(int l);
|
2019-06-06 10:31:01 +02:00
|
|
|
void setFreeRecMode(bool e);
|
2019-05-31 20:59:48 +02:00
|
|
|
|
2016-12-27 13:47:19 +01:00
|
|
|
jack_client_t* getJackClientPointer()
|
|
|
|
{
|
|
|
|
return client;
|
|
|
|
};
|
|
|
|
|
|
|
|
void resetMidiBindingState();
|
|
|
|
|
|
|
|
// MIDI binding creation
|
|
|
|
bool bindingEventRecordEnable;
|
|
|
|
int bindingEventType;
|
|
|
|
int bindingTrack;
|
|
|
|
int bindingScene;
|
|
|
|
int bindingSend;
|
|
|
|
int bindingActive;
|
|
|
|
|
|
|
|
JackSendReturn *getJackSendReturn(int t);
|
2018-07-09 14:38:52 +02:00
|
|
|
|
2018-07-11 21:51:42 +02:00
|
|
|
float smoothing_value;
|
2019-06-15 10:24:13 +02:00
|
|
|
|
|
|
|
// Functions to count number of clips
|
|
|
|
int getRecordedClips () {
|
|
|
|
return recordedClips;
|
|
|
|
};
|
|
|
|
void addRecordedClip ();
|
|
|
|
void subRecordedClip ();
|
|
|
|
|
2019-06-18 12:34:26 +02:00
|
|
|
int getRecordingClips () {
|
|
|
|
return recordingClips;
|
|
|
|
};
|
|
|
|
void addRecordingClip ();
|
|
|
|
void subRecordingClip ();
|
|
|
|
|
2016-11-15 18:11:28 +01:00
|
|
|
private:
|
2016-12-27 13:47:19 +01:00
|
|
|
int lastnframes;
|
2018-07-09 13:26:30 +02:00
|
|
|
jack_client_t* client;
|
2016-12-27 13:47:19 +01:00
|
|
|
|
|
|
|
Buffers buffers;
|
|
|
|
TimeManager* timeManager;
|
|
|
|
Metronome* metronome;
|
|
|
|
State* state;
|
|
|
|
Logic* logic;
|
|
|
|
GridLogic* gridLogic;
|
|
|
|
ControllerUpdater* controllerUpdater;
|
|
|
|
|
2019-05-31 20:59:48 +02:00
|
|
|
int clipLength;
|
2019-06-06 10:31:01 +02:00
|
|
|
bool freeRecMode;
|
2019-06-15 10:24:13 +02:00
|
|
|
unsigned int recordedClips;
|
2019-06-18 12:34:26 +02:00
|
|
|
unsigned int recordingClips;
|
2019-06-06 10:31:01 +02:00
|
|
|
|
2016-12-27 13:47:19 +01:00
|
|
|
vector<Looper*> loopers;
|
|
|
|
vector<JackSendReturn*> tracksendreturns;
|
|
|
|
vector<TrackOutput*> trackOutputs;
|
|
|
|
|
|
|
|
vector<MidiIO*> midiIO;
|
|
|
|
|
|
|
|
// FX
|
|
|
|
DBMeter* inputMeter;
|
|
|
|
DBMeter* masterMeter;
|
2018-07-09 13:54:11 +02:00
|
|
|
|
|
|
|
/// *Lag are values that lag behind their corresponding value
|
2016-12-27 13:47:19 +01:00
|
|
|
/// This prohibits audible jumps when rapidly changing the volume
|
2018-07-09 13:54:11 +02:00
|
|
|
float inputVol;
|
|
|
|
float inputVolLag;
|
|
|
|
|
2016-12-27 13:47:19 +01:00
|
|
|
float masterVol;
|
|
|
|
float masterVolLag;
|
2018-07-09 13:50:39 +02:00
|
|
|
|
2016-12-27 13:47:19 +01:00
|
|
|
float returnVol;
|
2018-07-09 13:50:39 +02:00
|
|
|
float returnVolLag;
|
2016-12-27 13:47:19 +01:00
|
|
|
|
|
|
|
float inputToMixVol;
|
2018-07-09 13:26:30 +02:00
|
|
|
float inputToMixVolLag;
|
|
|
|
|
2016-12-27 13:47:19 +01:00
|
|
|
float inputToSendVol;
|
2018-07-09 13:34:13 +02:00
|
|
|
float inputToSendVolLag;
|
2018-07-09 13:46:31 +02:00
|
|
|
|
2016-12-27 13:47:19 +01:00
|
|
|
float inputToXSideVol;
|
2018-07-09 13:46:31 +02:00
|
|
|
float inputToXSideVolLag;
|
2016-12-27 13:47:19 +01:00
|
|
|
|
|
|
|
bool inputToKeyEnable;
|
2018-07-09 13:57:06 +02:00
|
|
|
float inputToKeyEnableLag;
|
2018-07-09 14:09:44 +02:00
|
|
|
|
2016-12-27 13:47:19 +01:00
|
|
|
bool inputToMixEnable;
|
2018-07-09 14:09:44 +02:00
|
|
|
float inputToMixEnableLag;
|
|
|
|
|
2016-12-27 13:47:19 +01:00
|
|
|
bool inputToSendEnable;
|
2018-07-09 14:16:41 +02:00
|
|
|
float inputToSendEnableLag;
|
2016-12-27 13:47:19 +01:00
|
|
|
|
|
|
|
// JACK member variables
|
|
|
|
bool clientActive;
|
|
|
|
int samplerate;
|
|
|
|
|
2017-03-19 12:45:04 +01:00
|
|
|
jack_port_t* masterInputL;
|
|
|
|
jack_port_t* masterInputR;
|
2016-12-27 13:47:19 +01:00
|
|
|
jack_port_t* masterOutputL;
|
|
|
|
jack_port_t* masterOutputR;
|
|
|
|
|
|
|
|
jack_port_t* masterReturnL;
|
|
|
|
jack_port_t* masterReturnR;
|
2017-03-19 15:58:28 +01:00
|
|
|
jack_port_t* headphonesPortL;
|
|
|
|
jack_port_t* headphonesPortR;
|
2016-12-27 13:47:19 +01:00
|
|
|
|
2017-03-19 15:58:28 +01:00
|
|
|
jack_port_t* sidechainKeyOutputL;
|
|
|
|
jack_port_t* sidechainKeyOutputR;
|
|
|
|
jack_port_t* sidechainSignalOutputL;
|
|
|
|
jack_port_t* sidechainSignalOutputR;
|
|
|
|
jack_port_t* sendOutputL;
|
|
|
|
jack_port_t* sendOutputR;
|
2016-12-27 13:47:19 +01:00
|
|
|
|
|
|
|
jack_port_t* masterMidiInput;
|
|
|
|
|
2017-03-19 15:58:28 +01:00
|
|
|
jack_port_t* trackJackOutputPorts[NTRACKS*2];
|
2016-12-27 13:47:19 +01:00
|
|
|
|
|
|
|
// JACK callback
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2019-06-09 10:41:19 +02:00
|
|
|
#endif // LOOPP_JACK_H
|
2013-04-20 12:37:36 +02:00
|
|
|
|