View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0000743 | ardour | bugs | public | 2004-10-26 14:30 | 2020-04-19 20:12 |
| Reporter | rcb | Assigned To | drobilla | ||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | closed | Resolution | fixed | ||
| Summary | 0000743: jack transport invalid data?? | ||||
| Description | When running ardour as jack transport master, I'm getting bad data on a transport client. I basically have test a client that calls jack_transport_query() in a while loop after the state goes to JackTransportStarting. On the first run, all is well with the following output: [Stopped ] bbb [ 1: 1: 0] framerate[44100] frame[0] valid flags[30] [Stopped ] bbb [ 1: 1: 0] framerate[44100] frame[0] valid flags[30] [Stopped ] bbb [ 1: 1: 0] framerate[44100] frame[0] valid flags[30] [Starting ] bbb [ 1: 1: 0] framerate[44100] frame[0] valid flags[30] jack_sync_callback() [JackTransportStarting] print_jack_pos() bar [1] beat [1] tick [0] bar_start_tick [0.000000] beats_per_bar [4.000000] beat_type [4.000000] ticks_per_beat [1920.000000] beats_per_minute [120.000000] frame_time [0.000000] next_time [-1.994141] [Rolling ] bbb [ 1: 1: 0] framerate[44100] frame[0] valid flags[30] [Rolling ] bbb [ 1: 1: 0] framerate[44100] frame[128] valid flags[30] [Rolling ] bbb [ 1: 1: 44] framerate[44100] frame[640] valid flags[30] [Rolling ] bbb [ 1: 1: 78] framerate[44100] frame[1024] valid flags[30] [Rolling ] bbb [ 1: 1: 111] framerate[44100] frame[1408] valid flags[30] [Rolling ] bbb [ 1: 1: 144] framerate[44100] frame[1792] valid flags[30] [Rolling ] bbb [ 1: 1: 178] framerate[44100] frame[2176] valid flags[30] [Rolling ] bbb [ 1: 1: 222] framerate[44100] frame[2688] valid flags[30] [Rolling ] bbb [ 1: 1: 267] framerate[44100] frame[3200] valid flags[30] [Rolling ] bbb [ 1: 1: 300] framerate[44100] frame[3584] valid flags[30] [Rolling ] bbb [ 1: 1: 334] framerate[44100] frame[3968] valid flags[30] [Rolling ] bbb [ 1: 1: 378] framerate[44100] frame[4480] valid flags[30] but on the 2nd time I start the transport, the beats bar and tick fields have the last stop position rather than the new start position on frame[0]: [Stopped ] bbb [ 1: 2:1501] framerate[44100] frame[0] valid flags[30] [Stopped ] bbb [ 1: 2:1501] framerate[44100] frame[0] valid flags[30] [Stopped ] bbb [ 1: 2:1501] framerate[44100] frame[0] valid flags[30] [Starting ] bbb [ 1: 2:1501] framerate[44100] frame[0] valid flags[30] jack_sync_callback() [JackTransportStarting] print_jack_pos() bar [1] beat [2] tick [1501] bar_start_tick [0.000000] beats_per_bar [4.000000] beat_type [4.000000] ticks_per_beat [1920.000000] beats_per_minute [120.000000] frame_time [0.000000] next_time [512.000123] ****** [Rolling ] bbb [ 1: 2:1501] framerate[44100] frame[0] valid flags[30] ****** [Rolling ] bbb [ 1: 1: 11] framerate[44100] frame[256] valid flags[30] [Rolling ] bbb [ 1: 1: 44] framerate[44100] frame[640] valid flags[30] [Rolling ] bbb [ 1: 1: 89] framerate[44100] frame[1152] valid flags[30] [Rolling ] bbb [ 1: 1: 122] framerate[44100] frame[1536] valid flags[30] [Rolling ] bbb [ 1: 1: 167] framerate[44100] frame[2048] valid flags[30] [Rolling ] bbb [ 1: 1: 200] framerate[44100] frame[2432] valid flags[30] attached is the client source. | ||||
| Tags | No tags attached. | ||||
|
2004-10-26 14:30
|
transport.cpp (5,024 bytes)
#include <jack/jack.h>
#include <jack/transport.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
/*
be timebase master
*/
jack_client_t *client;
float time_beats_per_bar = 4.0;
float time_beat_type = 4.0;
double time_ticks_per_beat = 1920.0;
double time_beats_per_minute = 120.0;
volatile int time_reset = 1; /* true when time values change */
void timebase(jack_transport_state_t state, jack_nframes_t nframes,
jack_position_t *pos, int new_pos, void *arg)
{
double min; /* minutes since frame 0 */
long abs_tick; /* ticks since frame 0 */
long abs_beat; /* beats since frame 0 */
if (new_pos || time_reset) {
pos->valid = JackPositionBBT;
pos->beats_per_bar = time_beats_per_bar;
pos->beat_type = time_beat_type;
pos->ticks_per_beat = time_ticks_per_beat;
pos->beats_per_minute = time_beats_per_minute;
time_reset = 0; /* time change complete */
/* Compute BBT info from frame number. This is relatively
* simple here, but would become complex if we supported tempo
* or time signature changes at specific locations in the
* transport timeline. */
min = pos->frame / ((double) pos->frame_rate * 60.0);
abs_tick = min * pos->beats_per_minute * pos->ticks_per_beat;
abs_beat = abs_tick / pos->ticks_per_beat;
pos->bar = abs_beat / pos->beats_per_bar;
pos->beat = abs_beat - (pos->bar * pos->beats_per_bar) + 1;
pos->tick = abs_tick - (abs_beat * pos->ticks_per_beat);
pos->bar_start_tick = pos->bar * pos->beats_per_bar *
pos->ticks_per_beat;
pos->bar++; /* adjust start to bar 1 */
} else {
/* Compute BBT info based on previous period. */
pos->tick +=
nframes * pos->ticks_per_beat * pos->beats_per_minute
/ (pos->frame_rate * 60);
while (pos->tick >= pos->ticks_per_beat) {
pos->tick -= pos->ticks_per_beat;
if (++pos->beat > pos->beats_per_bar) {
pos->beat = 1;
++pos->bar;
pos->bar_start_tick +=
pos->beats_per_bar
* pos->ticks_per_beat;
}
}
}
}
void jack_shutdown(void *arg)
{
printf("JACK shut down, exiting ...\n");
exit(1);
}
void print_jack_pos( jack_position_t* jack_pos ){
printf( "print_jack_pos()\n" );
printf( " bar [%d]\n", jack_pos->bar );
printf( " beat [%d]\n", jack_pos->beat );
printf( " tick [%d]\n", jack_pos->tick );
printf( " bar_start_tick [%lf]\n", jack_pos->bar_start_tick );
printf( " beats_per_bar [%f]\n", jack_pos->beats_per_bar );
printf( " beat_type [%f]\n", jack_pos->beat_type );
printf( " ticks_per_beat [%lf]\n", jack_pos->ticks_per_beat );
printf( " beats_per_minute [%lf]\n", jack_pos->beats_per_minute );
printf( " frame_time [%lf]\n", jack_pos->frame_time );
printf( " next_time [%lf]\n", jack_pos->next_time );
}
int jack_sync_callback(jack_transport_state_t state,
jack_position_t *pos, void *arg)
{
printf( "jack_sync_callback() " );
switch ( state ){
case JackTransportStopped:
printf( "[JackTransportStopped]\n" ); break;
case JackTransportRolling:
printf( "[JackTransportRolling]\n" ); break;
case JackTransportStarting:
{
printf( "[JackTransportStarting]\n" );
break;
}
}
print_jack_pos( pos );
return true;
}
int main ( void )
{
/* become a new client of the JACK server */
if ((client = jack_client_new("transport tester")) == 0) {
fprintf(stderr, "jack server not running?\n");
return 1;
}
jack_on_shutdown(client, jack_shutdown, 0);
jack_set_sync_callback(client, jack_sync_callback, NULL);
if (jack_activate(client)) {
fprintf(stderr, "cannot activate client");
return 1;
}
//bool cond = false; /* true if we want to fail if there is already a master */
//if (jack_set_timebase_callback(client, cond, timebase, NULL) != 0){
//printf("Unable to take over timebase or there is already a master.\n");
// exit(1);
// }
jack_position_t pos;
pos.valid = JackPositionBBT;
pos.bar = 0;
pos.beat = 0;
pos.tick = 0;
pos.beats_per_bar = time_beats_per_bar;
pos.beat_type = time_beat_type;
pos.ticks_per_beat = time_ticks_per_beat;
pos.beats_per_minute = time_beats_per_minute;
pos.bar_start_tick = 0.0;
jack_transport_state_t js;
while(1){
js = jack_transport_query( client, &pos );
switch ( js ){
case JackTransportStopped:
printf( "[Stopped ] " ); break;
case JackTransportRolling:
printf( "[Rolling ] " ); break;
case JackTransportStarting:
printf( "[Starting ] " ); break;
}
printf( " bbb [%3d:%2d:%4d] framerate[%d] frame[%d] valid flags[%x]\n",
pos.bar, pos.beat, pos.tick,
pos.frame_rate, pos.frame,
pos.valid );
usleep(10000);
}
//jack_transport_stop (client);
jack_release_timebase(client);
jack_client_close(client);
return 0;
}
|
|
|
Fixed in 3.0 r12993. |
|
|
Issue has been closed automatically, by Trigger Close Plugin. Feel free to re-open with additional information if you think the issue is not resolved. |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2004-10-26 14:30 | rcb | New Issue | |
| 2004-10-26 14:30 | rcb | File Added: transport.cpp | |
| 2004-10-26 14:30 | rcb | => rcb@filter24.org | |
| 2004-10-26 14:30 | rcb | Name | => rob buse |
| 2012-07-08 03:41 | drobilla | cost | => 0.00 |
| 2012-07-08 03:41 | drobilla | Note Added: 0013803 | |
| 2012-07-08 03:41 | drobilla | Assigned To | => drobilla |
| 2012-07-08 03:41 | drobilla | Status | new => resolved |
| 2012-07-08 03:41 | drobilla | Resolution | open => fixed |
| 2012-07-08 03:41 | drobilla | Description Updated | |
| 2020-04-19 20:12 | system | Note Added: 0021440 | |
| 2020-04-19 20:12 | system | Status | resolved => closed |