void Transport::locate ( nframes_t frame ) { if ( ! recording ) // don't allow seeking while record is in progress jack_transport_locate( client, frame ); }
static void jack_transport_float(jack_transport_t * x, float f) { if (!x->x_jack_client) return; jack_transport_locate(x->x_jack_client, (jack_nframes_t)f); }
static void cbox_jackio_control_transport(struct cbox_io_impl *impl, gboolean roll, uint32_t pos) { struct cbox_jack_io_impl *jii = (struct cbox_jack_io_impl *)impl; if (jii->debug_transport) g_message("JACK transport: control(op=%s, pos=%d)\n", roll ? "roll" : "stop", (int)pos); jack_transport_state_t state = jack_transport_query(jii->client, NULL); if (roll && pos != (uint32_t)-1) jack_transport_locate(jii->client, pos); if (roll && state == JackTransportStopped) jack_transport_start(jii->client); if (!roll && state != JackTransportStopped) jack_transport_stop(jii->client); if (!roll && pos != (uint32_t)-1) jack_transport_locate(jii->client, pos); }
static void com_locate(char *arg) { jack_nframes_t frame = 0; if (*arg != '\0') frame = atoi(arg); jack_transport_locate(client, frame); }
static void on_jack_seek( mlt_properties owner, mlt_filter filter, mlt_position *position ) { mlt_properties properties = MLT_FILTER_PROPERTIES( filter ); mlt_log_verbose( MLT_FILTER_SERVICE(filter), "%s: %d\n", __FUNCTION__, *position ); mlt_properties_set_int( properties, "_sync_guard", 1 ); mlt_profile profile = mlt_service_profile( MLT_FILTER_SERVICE( filter ) ); jack_client_t *jack_client = mlt_properties_get_data( properties, "jack_client", NULL ); jack_nframes_t jack_frame = jack_get_sample_rate( jack_client ); jack_frame *= *position / mlt_profile_fps( profile ); jack_transport_locate( jack_client, jack_frame ); }
void JackOutput::locate( unsigned long nFrame ) { if ( ( Preferences::get_instance() )->m_bJackTransportMode == Preferences::USE_JACK_TRANSPORT /*|| Preferences::get_instance()->m_bJackMasterMode == Preferences::USE_JACK_TIME_MASTER*/ ) { if ( client ) { WARNINGLOG( QString( "Calling jack_transport_locate(%1)" ).arg( nFrame ) ); jack_transport_locate( client, nFrame ); } } else { m_transport.m_nFrames = nFrame; } }
static PyObject* transport_locate (PyObject* self, PyObject* args) { pyjack_client_t * client = self_or_global_client(self); jack_nframes_t newfr; if (! PyArg_ParseTuple(args, "i", &newfr)) return NULL; if(client->pjc == NULL) { PyErr_SetString(JackNotConnectedError, "Jack connection has not yet been established."); return NULL; } jack_transport_locate (client->pjc,newfr); return Py_None; }
void JackAudioDriver::locate( unsigned long nFrame ) { if ( ( Preferences::get_instance() )->m_bJackTransportMode == Preferences::USE_JACK_TRANSPORT /*|| Preferences::get_instance()->m_bJackMasterMode == Preferences::USE_JACK_TIME_MASTER*/ ) { if ( m_pClient ) { // jack_transport_locate() (jack/transport.h ) // re-positions the transport to a new frame number. // May be called at any time by any client. The new // position takes effect in two process cycles. jack_transport_locate( m_pClient, nFrame ); } } else { m_transport.m_nFrames = nFrame; } }
static void do_jack(jack_client_t* client, char *button, int bk) { black_keys = bk; // Jack Transport if (button[0] && (button[0] != button_prev_val[0])) //select :: Change octave { if (oct == 0) { oct = 1; //C6 if (debug) printf("STAT: Changed base octave to C6\n"); } else if (oct == 1) { oct = 2; //C7 if (debug) printf("STAT: Changed base octave to C7\n"); } else if (oct == 2) { oct = -2; //C3 if (debug) printf("STAT: Changed base octave to C3\n"); } else if (oct == -2) { oct = -1; //C4 if (debug) printf("STAT: Changed base octave to C4\n"); } else { oct = 0; //C5 if (debug) printf("STAT: Changed base octave to C5\n"); } } else if (button[3] && (button[3] != button_prev_val[3])) //start :: Start/Stop Transport { state = jack_transport_query(client, NULL); if (state) { jack_transport_stop(client); if (debug) printf("STAT: Transport stopped\n"); } else { jack_transport_start(client); if (debug) printf("STAT: Transport started\n"); } } if (button[16] && (button[16] != button_prev_val[16])) //PS :: Panic button { if (debug) printf("STAT: Panic!\n"); jack_transport_stop(client); jack_transport_locate(client, 0); jack_transport_stop(client); int h; for (h=8; h<20; h++) { axis[h] = 0; axis_prev_velocity[h] = 0; } } else if (button[1]) //L3 :: Move transport backwards { jack_transport_query(client, &position); int prevJackFrame = position.frame - 100000; if (prevJackFrame < 0) prevJackFrame = 0; jack_transport_locate(client, prevJackFrame); if (button[1] != button_prev_val[1]) if (debug) printf("STAT: Transport backwards...\n"); } else if (button[1] != button_prev_val[1]) { if (debug) printf("STAT: Transport normal\n"); } else if (button[2]) //R3 :: Move transport forwards { jack_transport_query(client, &position); int nextJackFrame = position.frame + 100000; jack_transport_locate(client, nextJackFrame); if (button[2] != button_prev_val[2]) if (debug) printf("STAT: Transport forwards...\n"); } else if (button[2] != button_prev_val[2]) { if (debug) printf("STAT: Transport normal\n"); } button_prev_val[0] = button[0]; button_prev_val[1] = button[1]; button_prev_val[2] = button[2]; button_prev_val[3] = button[3]; button_prev_val[16] = button[16]; }
void jackt_rewind() { if (jack_client) { jack_transport_locate (jack_client,0); } }
void audioStreamer_JACK::timebase_cb(jack_transport_state_t state, jack_nframes_t nframes, jack_position_t *pos, int new_pos ) { static double jack_tick; static jack_nframes_t last_frame; static jack_nframes_t current_frame; jack_position_t cur_pos; static jack_transport_state_t state_current; static jack_transport_state_t state_last; static int locating = 0; #if 0 if( state != JackTransportRolling ) { jack_transport_locate( client, 0 ); jack_transport_start( client ); } #endif if( !njc ) return; int posi, len; njc->GetPosition(&posi,&len); float bpm = njc->GetActualBPM(); //posi = njc->GetSessionPosition() * m_srate / 1000; //len = (int)(njc->GetBPI() * m_srate * 60 / bpm); // sync jack_transport_frame to njframe //current_frame = jack_get_current_transport_frame( client ); jack_transport_query(client, &cur_pos); current_frame = cur_pos.frame; // FIXME: This will not work right, if there are slow-sync clients.... int diff = abs(current_frame % len) - (posi % len); if( diff > nframes ) { #if 1 jack_transport_locate( client, (current_frame / len) * len + (posi%len) + 2*nframes ); //printf( "no: current= %d diff = %d\n", (current_frame % len) - (posi % len), diff ); #endif } // taken from seq24-0.7.0 perform.cpp state_current = state; //printf( "jack_timebase_callback() [%d] [%d] [%d]", state, new_pos, current_frame); pos->valid = JackPositionBBT; pos->beats_per_bar = 4; pos->beat_type = 4; pos->ticks_per_beat = c_ppqn * 10; pos->beats_per_minute = bpm; /* 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. */ // if we are in a new position if ( state_last == JackTransportStarting && state_current == JackTransportRolling ){ //printf ( "Starting [%d] [%d]\n", last_frame, current_frame ); jack_tick = 0.0; last_frame = current_frame; } if ( current_frame > last_frame ){ double jack_delta_tick = (current_frame - last_frame) * pos->ticks_per_beat * pos->beats_per_minute / (pos->frame_rate * 60.0); jack_tick += jack_delta_tick; last_frame = current_frame; } long ptick = 0, pbeat = 0, pbar = 0; pbar = (long) ((long) jack_tick / (pos->ticks_per_beat * pos->beats_per_bar )); pbeat = (long) ((long) jack_tick % (long) (pos->ticks_per_beat * pos->beats_per_bar )); pbeat = pbeat / (long) pos->ticks_per_beat; ptick = (long) jack_tick % (long) pos->ticks_per_beat; pos->bar = pbar + 1; pos->beat = pbeat + 1; pos->tick = ptick;; pos->bar_start_tick = pos->bar * pos->beats_per_bar * pos->ticks_per_beat; //printf( " bbb [%2d:%2d:%4d]\n", pos->bar, pos->beat, pos->tick ); state_last = state_current; }
void Client::transport_locate ( nframes_t frame ) { jack_transport_locate( _client, frame ); }
void jack_assistant::position (bool songmode, midipulse tick) { #ifdef SEQ64_JACK_SUPPORT long current_tick = 0; if (songmode) /* master in song mode */ { if (! is_null_midipulse(tick)) current_tick = tick * 10; } int ticks_per_beat = m_ppqn * 10; int beats_per_minute = parent().get_beats_per_minute(); uint64_t tick_rate = (uint64_t(m_jack_frame_rate) * current_tick * 60.0); long tpb_bpm = ticks_per_beat * beats_per_minute * 4.0 / m_beat_width; uint64_t jack_frame = tick_rate / tpb_bpm; jack_transport_locate(m_jack_client, jack_frame); #ifdef SEQ64_STAZED_JACK_SUPPORT #if 0 /* * The call to jack_BBT_position() is not necessary to change JACK * position! Must set these here since they are set in timebase. */ jack_position_t pos; double jack_tick = current_tick * m_bw / 4.0; pos.ticks_per_beat = m_ppqn * 10; pos.beats_per_minute = m_master_bus.get_bpm(); jack_BBT_position(pos, jack_tick); /* * Calculate JACK frame to put into pos.frame; it is what matters for * position change. Very similar to the uncommented code above. */ uint64_t tick_rate = ((uint64_t)pos.frame_rate * current_tick * 60.0); long tpb_bpm = pos.ticks_per_beat * pos.beats_per_minute * 4.0 / pos.beat_type; pos.frame = tick_rate / tpb_bpm; /* * ticks * 10 = jack ticks; * jack ticks / ticks per beat = num beats; * num beats / beats per minute = num minutes * num minutes * 60 = num seconds * num secords * frame_rate = frame */ jack_transport_reposition(m_jack_client, &pos); #endif // 0 if (parent().is_running()) parent().set_reposition(false); #endif // SEQ64_STAZED_JACK_SUPPORT Tutorial code from jack_assistant::position(): #ifdef SAMPLE_AUDIO_CODE // disabled, shown only for reference & learning jack_transport_state_t ts = jack_transport_query(jack->client(), NULL); if (ts == JackTransportRolling) { jack_default_audio_sample_t * in; jack_default_audio_sample_t * out; if (client_state == Init) client_state = Run; in = jack_port_get_buffer(input_port, nframes); out = jack_port_get_buffer(output_port, nframes); memcpy(out, in, sizeof (jack_default_audio_sample_t) * nframes); } else if (ts == JackTransportStopped) { if (client_state == Run) client_state = Exit; } #endif }
void AUD_JackDevice::seekPlayback(float time) { if(time >= 0.0f) jack_transport_locate(m_client, time * m_specs.rate); }
int main(int argc, char *argv[]) { int ch; char *file_name, *autoconnect_port_name = NULL; #ifdef WITH_LASH lash_args_t *lash_args; #endif g_thread_init(NULL); #ifdef WITH_LASH lash_args = lash_extract_args(&argc, &argv); #endif g_log_set_default_handler(log_handler, NULL); while ((ch = getopt(argc, argv, "a:dnqr:stVx")) != -1) { switch (ch) { case 'a': autoconnect_port_name = strdup(optarg); break; case 'd': debug = 1; break; case 'n': start_stopped = 1; break; case 'q': be_quiet = 1; break; case 'r': rate_limit = strtod(optarg, NULL); if (rate_limit <= 0.0) { g_critical("Invalid rate limit specified.\n"); exit(EX_USAGE); } break; case 's': just_one_output = 1; break; case 't': use_transport = 0; break; case 'x': remote_control = 1; break; case 'V': show_version(); break; case '?': default: usage(); break; } } argc -= optind; argv += optind; if (argv[0] == NULL) { g_critical("No file name given."); usage(); } file_name = argv[0]; if (!remote_control) { smf_vol = smf = smf_load(file_name); if (smf == NULL) { g_critical("Loading SMF file failed."); exit(-1); } if (!be_quiet) g_message("%s.", smf_decode(smf)); if (smf->number_of_tracks > MAX_NUMBER_OF_TRACKS) { g_warning("Number of tracks (%d) exceeds maximum for per-track output; implying '-s' option.", smf->number_of_tracks); just_one_output = 1; } } #ifdef WITH_LASH init_lash(lash_args); #endif g_timeout_add(1000, emergency_exit_timeout, (gpointer)0); signal(SIGINT, ctrl_c_handler); init_jack(); if (autoconnect_port_name) { if (connect_to_input_port(autoconnect_port_name)) { g_critical("Couldn't connect to '%s', exiting.", autoconnect_port_name); exit(EX_UNAVAILABLE); } } if (use_transport && !start_stopped) { jack_transport_locate(jack_client, 0); jack_transport_start(jack_client); } if (!use_transport) playback_started = jack_frame_time(jack_client); if (remote_control) remote_control_start(argv[0]); g_main_loop_run(g_main_loop_new(NULL, TRUE)); /* Not reached. */ return 0; }
//------------------------------------------------------------------------ void TJackSynchro::StartSync() { assert(fClient); jack_transport_locate(fClient, 0); jack_transport_start(fClient); }
//------------------------------------------------------------------------ void TJackSynchro::Locate(int frames) { jack_transport_locate(fClient, frames); }
void rove_transport_stop() { jack_transport_stop(state.client); jack_transport_locate(state.client, 0); }
int luajack_transport_locate(luajack_t *client, jack_nframes_t frame) { cud_t *cud = get_cud(client); if(!cud) return 0; return jack_transport_locate(cud->client, frame); }