configurable subframes-per-frame, defaults to 80
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 20 Nov 2006 14:27:56 +0000 (14:27 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 20 Nov 2006 14:27:56 +0000 (14:27 +0000)
git-svn-id: svn://localhost/ardour2/trunk@1143 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/ardour.menus
gtk2_ardour/editor.h
gtk2_ardour/editor_actions.cc
libs/ardour/ardour/configuration_vars.h
libs/ardour/session_time.cc

index bd172183e79ebd8dbcb58118a584327df10c516f..0ca98b868ff073b72b6b3a6c4c495fef3e37d1fc 100644 (file)
                   <menuitem action='PullupMinus4'/>
                   <menuitem action='PullupMinus4Minus1'/>
                </menu>
+              <menu action='Subframes'>
+                  <menuitem action='Subframes80'/>
+                  <menuitem action='Subframes100'/>
+               </menu>
                <separator/>
                <menu action='Autoconnect'>
                    <menuitem action='InputAutoConnectPhysical'/>
index a88b9b314a2e0dcef58597604b2812d7ba9c4626..eb2c4a9b67720b0c190410a7239ce998175b033d 100644 (file)
@@ -295,10 +295,11 @@ class Editor : public PublicEditor
 
        void smpte_fps_chosen (ARDOUR::Session::SmpteFormat format);
        void video_pullup_chosen (ARDOUR::Session::PullupFormat pullup);
+       void subframes_per_frame_chosen (uint32_t);
 
        void update_smpte_mode();
        void update_video_pullup();
-
+       void update_subframes_per_frame ();
        /* xfades */
 
        void toggle_auto_xfade ();
index a55aee62327b11442d130837454291cb84ab28bb..9dfd87259b36fdac4ec70b41137d801756aa1c05 100644 (file)
@@ -42,6 +42,7 @@ Editor::register_actions ()
        ActionManager::register_action (editor_actions, X_("Layering"), _("Layering"));
        ActionManager::register_action (editor_actions, X_("Timecode"), _("Timecode fps"));
        ActionManager::register_action (editor_actions, X_("Pullup"), _("Pullup / Pulldown"));
+       ActionManager::register_action (editor_actions, X_("Subframes"), _("Subframes"));
        ActionManager::register_action (editor_actions, X_("addExistingAudioFiles"), _("Add Existing Audio"));
 
        /* add named actions for the editor */
@@ -402,6 +403,11 @@ Editor::register_actions ()
        ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupMinus4"), _("-4.1667%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Minus4));
        ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupMinus4Minus1"), _("-4.1667% - 0.1%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Minus4Minus1));
 
+       RadioAction::Group subframe_group;
+
+       ActionManager::register_radio_action (editor_actions, pullup_group,  X_("Subframes80"), _("80 per frame"), bind (mem_fun (*this, &Editor::subframes_per_frame_chosen), 80));
+       ActionManager::register_radio_action (editor_actions, pullup_group,  X_("Subframes100"), _("100 per frame"), bind (mem_fun (*this, &Editor::subframes_per_frame_chosen), 100));
+
        ActionManager::add_action_group (rl_actions);
        ActionManager::add_action_group (zoom_actions);
        ActionManager::add_action_group (mouse_mode_actions);
@@ -978,6 +984,70 @@ Editor::video_pullup_chosen (Session::PullupFormat pullup)
        }
 }
 
+void
+Editor::update_subframes_per_frame ()
+{
+       ENSURE_GUI_THREAD (mem_fun(*this, &Editor::update_subframes_per_frame));
+
+       RefPtr<Action> act;
+       const char* action = 0;
+
+       uint32_t sfpf = Config->get_subframes_per_frame();
+
+       if (sfpf == 80) {
+               action = X_("Subframes80");
+       } else if (sfpf == 100) {
+               action = X_("Subframes100");
+       } else {
+               warning << string_compose (_("Configuraton is using unhandled subframes per frame value: %1"), sfpf) << endmsg;
+               /*NOTREACHED*/
+               return;
+       }
+
+       act = ActionManager::get_action (X_("Editor"), action);
+
+       if (act) {
+               RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
+               if (ract && !ract->get_active()) {
+                       ract->set_active (true);
+               }
+       }
+}
+
+void
+Editor::subframes_per_frame_chosen (uint32_t sfpf)
+{
+       /* this is driven by a toggle on a radio group, and so is invoked twice,
+          once for the item that became inactive and once for the one that became
+          active.
+       */
+
+       const char* action = 0;
+
+       RefPtr<Action> act;
+       
+       if (sfpf == 80) {
+               action = X_("Subframes80");
+       } else if (sfpf == 100) {       
+               action = X_("Subframes100");
+       } else {
+               fatal << string_compose (_("programming error: %1 %2"), "Session received unexpected subframes per frame value: ", sfpf) << endmsg;
+               /*NOTREACHED*/
+       }
+       
+       act = ActionManager::get_action (X_("Editor"), action);
+       
+       if (act) {
+               RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
+               if (ract && ract->get_active()) {
+                       Config->set_subframes_per_frame ((uint32_t) rint (sfpf));
+               }
+               
+       } else  {
+               error << string_compose (_("programming error: %1"), "Editor::subframes_per_frame_chosen could not find action to match value.") << endmsg;
+       }
+}
+
 void
 Editor::toggle_auto_xfade ()
 {
@@ -1026,6 +1096,8 @@ Editor::parameter_changed (const char* parameter_name)
                update_crossfade_model ();
        } else if (PARAM_IS ("edit-mode")) {
                edit_mode_selector.set_active_text (edit_mode_to_string (Config->get_edit_mode()));
+       } else if (PARAM_IS ("subframes_per_frame")) {
+               update_subframes_per_frame ();
        }
 
 #undef PARAM_IS
index 8044190066c8ed38addc2a3214a2c48a37049e15..f54fe15b71da7c503f92b1a9aab0057c170f6568 100644 (file)
@@ -119,6 +119,7 @@ CONFIG_VARIABLE (bool, hiding_groups_deactivates_groups, "hiding-groups-deactiva
 CONFIG_VARIABLE (bool, verify_remove_last_capture, "verify-remove-last-capture", true)
 CONFIG_VARIABLE (bool, no_new_session_dialog, "no-new-session-dialog", false)
 CONFIG_VARIABLE (bool, use_vst, "use-vst", true)
+CONFIG_VARIABLE (uint32_t, subframes_per_frame, "subframes-per-frame", 100)
 
 /* BWAV */
 
index abe4f506963bed0544eafda392f54cc768b1b043..bc9778052fa33d5e2fb0527bd5a1a95bf9a378ed 100644 (file)
@@ -163,7 +163,7 @@ Session::smpte_to_sample( SMPTE::Time& smpte, nframes_t& sample, bool use_offset
        }
   
        if (use_subframes) {
-               sample += (long) (((double)smpte.subframes * _frames_per_smpte_frame) / 80.0);
+               sample += (long) (((double)smpte.subframes * _frames_per_smpte_frame) / Config->get_subframes_per_frame());
        }
   
        if (use_offset) {
@@ -224,10 +224,10 @@ Session::sample_to_smpte( nframes_t sample, SMPTE::Time& smpte, bool use_offset,
        // Calculate exact number of (exceeding) smpte frames and fractional frames
        smpte_frames_left_exact = (double) offset_sample / _frames_per_smpte_frame;
        smpte_frames_fraction = smpte_frames_left_exact - floor( smpte_frames_left_exact );
-       smpte.subframes = (long) rint(smpte_frames_fraction * 80.0);
+       smpte.subframes = (long) rint(smpte_frames_fraction * Config->get_subframes_per_frame());
   
        // XXX Not sure if this is necessary anymore...
-       if (smpte.subframes == 80) {
+       if (smpte.subframes == Config->get_subframes_per_frame()) {
                // This can happen with 24 fps (and 29.97 fps ?)
                smpte_frames_left_exact = ceil( smpte_frames_left_exact );
                smpte.subframes = 0;