X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Ftransportque.C;h=01ba565d3bf60953085021c771516c3009ec6d21;hb=38cb4182e11e57fc426bede3825e825e9d61433b;hp=4a880ee0a2476221065a49f0a19d80cc18fa1cf2;hpb=e0fc7bf81ed20c8fb98de25151a8e3b6aaedc55a;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/transportque.C b/cinelerra-5.1/cinelerra/transportque.C index 4a880ee0..01ba565d 100644 --- a/cinelerra-5.1/cinelerra/transportque.C +++ b/cinelerra-5.1/cinelerra/transportque.C @@ -52,6 +52,8 @@ void TransportCommand::reset() infinite = 0; realtime = 0; resume = 0; + audio_toggle = 0; + displacement = 0; // Don't reset the change type for commands which don't perform the change if(command != STOP) change_type = 0; command = COMMAND_NONE; @@ -85,6 +87,8 @@ void TransportCommand::copy_from(TransportCommand *command) this->playbackstart = command->playbackstart; this->realtime = command->realtime; this->resume = command->resume; + this->audio_toggle = command->audio_toggle; + this->displacement = command->displacement; } TransportCommand& TransportCommand::operator=(TransportCommand &command) @@ -93,139 +97,140 @@ TransportCommand& TransportCommand::operator=(TransportCommand &command) return *this; } -int TransportCommand::single_frame() +int TransportCommand::single_frame(int command) { return (command == SINGLE_FRAME_FWD || command == SINGLE_FRAME_REWIND || command == CURRENT_FRAME); } - - -int TransportCommand::get_direction() +int TransportCommand::single_frame() { - switch(command) - { - case SINGLE_FRAME_FWD: - case NORMAL_FWD: - case FAST_FWD: - case SLOW_FWD: - case CURRENT_FRAME: - return PLAY_FORWARD; + return single_frame(command); +} - case SINGLE_FRAME_REWIND: - case NORMAL_REWIND: - case FAST_REWIND: - case SLOW_REWIND: - return PLAY_REVERSE; - default: - break; +int TransportCommand::get_direction(int command) +{ + switch(command) { + case SINGLE_FRAME_FWD: + case NORMAL_FWD: + case FAST_FWD: + case SLOW_FWD: + case CURRENT_FRAME: + return PLAY_FORWARD; + + case SINGLE_FRAME_REWIND: + case NORMAL_REWIND: + case FAST_REWIND: + case SLOW_REWIND: + return PLAY_REVERSE; + + default: + break; } return PLAY_FORWARD; } - -float TransportCommand::get_speed() +int TransportCommand::get_direction() { - switch(command) - { - case SLOW_FWD: - case SLOW_REWIND: - return 0.5; - - case NORMAL_FWD: - case NORMAL_REWIND: - case SINGLE_FRAME_FWD: - case SINGLE_FRAME_REWIND: - case CURRENT_FRAME: - return 1.; + return get_direction(command); +} - case FAST_FWD: - case FAST_REWIND: - return 2.; +float TransportCommand::get_speed(int command) +{ + switch(command) { + case SLOW_FWD: + case SLOW_REWIND: + return 0.5; + + case NORMAL_FWD: + case NORMAL_REWIND: + case SINGLE_FRAME_FWD: + case SINGLE_FRAME_REWIND: + case CURRENT_FRAME: + return 1.; + + case FAST_FWD: + case FAST_REWIND: + return 2.; } return 0.; } +float TransportCommand::get_speed() +{ + return get_speed(command); +} // Assume starting without pause -void TransportCommand::set_playback_range(EDL *edl, int use_inout) +void TransportCommand::set_playback_range(EDL *edl, + int use_inout, int toggle_audio, int use_displacement) { if(!edl) edl = this->edl; + double length = edl->tracks->total_playable_length(); + double frame_period = 1.0 / edl->session->frame_rate; + double start = edl->local_session->get_selectionstart(1); + double end = edl->local_session->get_selectionend(1); - - - switch(command) - { + displacement = 0; + if( use_inout ) { + if( edl->local_session->inpoint_valid() ) + start_position = edl->local_session->get_inpoint(); + if( edl->local_session->outpoint_valid() ) + end_position = edl->local_session->get_outpoint(); + } + else if( !EQUIV(start, end) ) { + start_position = start; + end_position = end; + } + else { + switch( command ) { case SLOW_FWD: case FAST_FWD: - case NORMAL_FWD: - start_position = edl->local_session->get_selectionstart(1); - if(EQUIV(edl->local_session->get_selectionend(1), edl->local_session->get_selectionstart(1))) - end_position = edl->tracks->total_playable_length(); - else - end_position = edl->local_session->get_selectionend(1); + case NORMAL_FWD: { + start_position = start; + end_position = length; // this prevents a crash if start position is after the loop when playing forwards - if (edl->local_session->loop_playback && - start_position > edl->local_session->loop_end) - { - start_position = edl->local_session->loop_start; + if( edl->local_session->loop_playback && + start_position > edl->local_session->loop_end ) { + start_position = edl->local_session->loop_start; } - break; + break; } case SLOW_REWIND: case FAST_REWIND: case NORMAL_REWIND: - end_position = edl->local_session->get_selectionend(1); - if(EQUIV(edl->local_session->get_selectionend(1), edl->local_session->get_selectionstart(1))) - start_position = 0; - else - start_position = edl->local_session->get_selectionstart(1); - + end_position = end; + start_position = 0; // this prevents a crash if start position is before the loop when playing backwards - if (edl->local_session->loop_playback && - end_position <= edl->local_session->loop_start) - { + if( edl->local_session->loop_playback && + end_position <= edl->local_session->loop_start ) { end_position = edl->local_session->loop_end; } break; case CURRENT_FRAME: case SINGLE_FRAME_FWD: - start_position = edl->local_session->get_selectionstart(1); - end_position = start_position + - 1.0 / - edl->session->frame_rate; + start_position = start; + end_position = start_position + frame_period; break; case SINGLE_FRAME_REWIND: - start_position = edl->local_session->get_selectionend(1); - end_position = start_position - - 1.0 / - edl->session->frame_rate; - break; - } - - - if(use_inout) - { - if(edl->local_session->inpoint_valid()) - start_position = edl->local_session->get_inpoint(); - if(edl->local_session->outpoint_valid()) - end_position = edl->local_session->get_outpoint(); - } - - switch(get_direction()) - { - case PLAY_FORWARD: - playbackstart = start_position; + end_position = end; + start_position = end_position - frame_period; break; + } - case PLAY_REVERSE: - playbackstart = end_position; - break; + if( use_displacement && command != CURRENT_FRAME && + get_direction() == PLAY_FORWARD ) { + start_position += frame_period; + end_position += frame_period; + displacement = 1; + } } + playbackstart = get_direction() == PLAY_FORWARD ? start_position : end_position; + audio_toggle = toggle_audio; } void TransportCommand::playback_range_adjust_inout() @@ -256,19 +261,11 @@ void TransportCommand::playback_range_project() end_position = edl->tracks->total_playable_length(); } - - - - - - - - - - - - - +void TransportCommand::playback_range_1frame() +{ + start_position = end_position = edl->local_session->get_selectionstart(1); + if( edl->session->frame_rate > 0 ) end_position += 1./edl->session->frame_rate; +} TransportQue::TransportQue() @@ -283,12 +280,9 @@ TransportQue::~TransportQue() delete output_lock; } -int TransportQue::send_command(int command, - int change_type, - EDL *new_edl, - int realtime, - int resume, - int use_inout) +int TransportQue::send_command(int command, int change_type, + EDL *new_edl, int realtime, int resume, + int use_inout, int toggle_audio, int use_displacement) { input_lock->lock("TransportQue::send_command 1"); this->command.command = command; @@ -315,7 +309,8 @@ int TransportQue::send_command(int command, } // Set playback range - this->command.set_playback_range(new_edl, use_inout); + this->command.set_playback_range(new_edl, + use_inout, toggle_audio, use_displacement); } input_lock->unlock();