mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-05 09:01:39 -05:00
-Working on JACK transport support
This commit is contained in:
parent
7061eaa173
commit
c9c469858f
3 changed files with 37 additions and 13 deletions
|
@ -23,8 +23,8 @@ class Buffers
|
|||
jack_nframes_t samplerate;
|
||||
|
||||
jack_nframes_t transportFrame;
|
||||
jack_position_t transportPosition;
|
||||
jack_transport_state_t transportState;
|
||||
jack_position_t* transportPosition;
|
||||
jack_transport_state_t* transportState;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -49,6 +49,8 @@ Jack::Jack()
|
|||
|
||||
|
||||
loopers.push_back( new Looper() );
|
||||
|
||||
jack_transport_start(client);
|
||||
}
|
||||
|
||||
|
||||
|
@ -103,8 +105,8 @@ int Jack::timebase(jack_transport_state_t state,
|
|||
{
|
||||
// fill buffers with data, then pass to timeManager
|
||||
buffers.transportFrame = jack_get_current_transport_frame(client);
|
||||
buffers.transportPosition = *pos;
|
||||
buffers.transportState = state;
|
||||
buffers.transportPosition = pos;
|
||||
buffers.transportState =&state;
|
||||
|
||||
// update "time" from JACK master, or write master?
|
||||
timeManager.process( &buffers );
|
||||
|
|
|
@ -12,25 +12,47 @@ using namespace std;
|
|||
class TimeManager
|
||||
{
|
||||
public:
|
||||
TimeManager()
|
||||
TimeManager():
|
||||
oldBeat(0)
|
||||
{
|
||||
}
|
||||
|
||||
void process(Buffers* buffers)
|
||||
{
|
||||
float bpm = 120;
|
||||
int framesPerBeat = (int) samplerate / (bpm / 60.0);
|
||||
/*
|
||||
float bpm = 160;
|
||||
int framesPerBeat = (int) buffers->samplerate / (bpm / 60.0);
|
||||
|
||||
// divide by zero errors!
|
||||
if ( framesPerBeat > 0 )
|
||||
// time signature?
|
||||
buffers->transportPosition->beats_per_bar = 4;
|
||||
buffers->transportPosition->beat_type = 4;
|
||||
|
||||
int beatFloat = buffers->transportFrame / framesPerBeat;
|
||||
//int beat = int(beat);
|
||||
|
||||
//int tick = int( (beatFloat - beat) * 1920 );
|
||||
|
||||
if ( beat != oldBeat )
|
||||
{
|
||||
int newBeat = buffers->transportFrame / framesPerBeat;
|
||||
if ( beat % (int)buffers->transportPosition->beats_per_bar == 0 )
|
||||
buffers->transportPosition->bar++;
|
||||
|
||||
oldBeat = beat;
|
||||
}
|
||||
//cout << buffers->transportPosition.frame << endl;
|
||||
|
||||
buffers->transportPosition->valid = JackPositionBBT;
|
||||
buffers->transportPosition->tick += (buffers->nframes / buffers->samplerate);
|
||||
|
||||
buffers->transportPosition->beat = beat % 4;
|
||||
buffers->transportPosition->tick = 0;
|
||||
|
||||
buffers->transportPosition->ticks_per_beat = 1920;
|
||||
buffers->transportPosition->beats_per_minute = bpm;
|
||||
*/
|
||||
}
|
||||
|
||||
private:
|
||||
int samplerate;
|
||||
int oldBeat;
|
||||
|
||||
// list of Observers of this TimeManager Subject, "beat", "bar" updates?
|
||||
/*
|
||||
|
|
Loading…
Add table
Reference in a new issue