-Working on JACK transport support

main
Harry van Haaren 2013-05-15 02:04:39 +01:00
parent 7061eaa173
commit c9c469858f
3 changed files with 37 additions and 13 deletions

View File

@ -22,9 +22,9 @@ class Buffers
jack_nframes_t nframes; jack_nframes_t nframes;
jack_nframes_t samplerate; jack_nframes_t samplerate;
jack_nframes_t transportFrame; jack_nframes_t transportFrame;
jack_position_t transportPosition; jack_position_t* transportPosition;
jack_transport_state_t transportState; jack_transport_state_t* transportState;
}; };

View File

@ -49,6 +49,8 @@ Jack::Jack()
loopers.push_back( new Looper() ); 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 // fill buffers with data, then pass to timeManager
buffers.transportFrame = jack_get_current_transport_frame(client); buffers.transportFrame = jack_get_current_transport_frame(client);
buffers.transportPosition = *pos; buffers.transportPosition = pos;
buffers.transportState = state; buffers.transportState =&state;
// update "time" from JACK master, or write master? // update "time" from JACK master, or write master?
timeManager.process( &buffers ); timeManager.process( &buffers );

View File

@ -12,25 +12,47 @@ using namespace std;
class TimeManager class TimeManager
{ {
public: public:
TimeManager() TimeManager():
oldBeat(0)
{ {
} }
void process(Buffers* buffers) 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! // time signature?
if ( framesPerBeat > 0 ) 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: private:
int samplerate; int oldBeat;
// list of Observers of this TimeManager Subject, "beat", "bar" updates? // list of Observers of this TimeManager Subject, "beat", "bar" updates?
/* /*