more tranzport lowlevel fixes and rebinding
authorPaul Davis <paul@linuxaudiosystems.com>
Sat, 29 Apr 2006 15:40:52 +0000 (15:40 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Sat, 29 Apr 2006 15:40:52 +0000 (15:40 +0000)
git-svn-id: svn://localhost/trunk/ardour2@488 d708f5d6-7413-0410-9779-e7cbd77b26cf

18 files changed:
gtk2_ardour/audio_clock.cc
gtk2_ardour/canvas-imageframe.c
gtk2_ardour/canvas-ruler.c
gtk2_ardour/canvas-simpleline.c
gtk2_ardour/canvas-simplerect.c
gtk2_ardour/canvas-waveview.c
gtk2_ardour/editor_selection_list.cc
gtk2_ardour/editor_tempodisplay.cc
gtk2_ardour/imageframe_time_axis.cc
gtk2_ardour/marker_time_axis_view.cc
gtk2_ardour/redirect_box.cc
gtk2_ardour/route_params_ui.cc
gtk2_ardour/tempo_dialog.cc
libs/ardour/ardour/basic_ui.h
libs/ardour/basic_ui.cc
libs/ardour/session_state.cc
libs/surfaces/tranzport/tranzport_control_protocol.cc
libs/surfaces/tranzport/tranzport_control_protocol.h

index d7eb1e59369aaae3a0f34adbda657dc46791dd11..506b082b53538a25f7db7260775893e69080a12b 100644 (file)
@@ -1735,9 +1735,8 @@ AudioClock::set_mode (Mode m)
           started editing the clock and then we switch clock mode.
        */
 
-       // GTK2FIX might need an equivalent here for drop focus
-
-
+       clock_base.grab_focus ();
+               
        if (_mode == m) {
                return;
        }
index 6ba51c0fdc92b0c64b47d4ee96d938ea4e31a11b..e0f0f2f743ce5c20e50e028adc597a415776ae39 100644 (file)
@@ -180,8 +180,6 @@ gnome_canvas_imageframe_init (GnomeCanvasImageFrame *image)
        image->height = 0.0;
        image->drawwidth = 0.0;
        image->anchor = GTK_ANCHOR_CENTER;
-       // GTK2FIX
-       // GNOME_CANVAS_ITEM(image)->object.flags |= GNOME_CANVAS_ITEM_NO_AUTO_REDRAW;
 }
 
 static void
index e141d50a9e69705786c41ca0c0f6f4476b744ab7..8be3c89e51a483ed597e6f0c8b457c6100f97aef 100644 (file)
@@ -163,9 +163,6 @@ gnome_canvas_ruler_init (GnomeCanvasRuler *ruler)
        ruler->frames_per_unit = 1;
        ruler->fill_color = 0;
        ruler->tick_color = 0;
-
-       // GTK2FIX
-       //GNOME_CANVAS_ITEM(ruler)->object.flags |= GNOME_CANVAS_ITEM_NO_AUTO_REDRAW;
 }
 
 static void 
index 4ba3d6bc76f5ca692cff346b2775a0c2db086847..b65693a54806cc1dcb16d7e90cd976e8a00213b8 100644 (file)
@@ -172,8 +172,6 @@ gnome_canvas_simpleline_init (GnomeCanvasSimpleLine *simpleline)
        simpleline->y2 = 0.0;
        simpleline->color = RGBA_TO_UINT(98,123,174,241);
        simpleline->horizontal = TRUE; /* reset in the _update() method */
-       // GTK2FIX
-       // GNOME_CANVAS_ITEM(simpleline)->object.flags |= GNOME_CANVAS_ITEM_NO_AUTO_REDRAW;
 }
 
 static void
index 62d3a96bcf4da2dafdd8ed55ff84638d7b668be2..abddf5756b14d35246bb4c19af4c50db5ac439e4 100644 (file)
@@ -227,9 +227,6 @@ gnome_canvas_simplerect_init (GnomeCanvasSimpleRect *simplerect)
        simplerect->outline_color = 0;
        simplerect->outline_pixels = 1;
        simplerect->outline_what = 0xf;
-
-       // GTK2FIX
-       // GNOME_CANVAS_ITEM(simplerect)->object.flags |= GNOME_CANVAS_ITEM_NO_AUTO_REDRAW;
 }
 
 static void
index 84881ae32baca8c63312b401fdd18b40e1806a09..34b64770a6b770293b997bdaf1361d03fb29a035 100644 (file)
@@ -314,9 +314,6 @@ gnome_canvas_waveview_init (GnomeCanvasWaveView *waveview)
        waveview->reload_cache_in_render = FALSE;
 
        waveview->wave_color = RGBA_TO_UINT(44,35,126,255);
-
-       // GTK2FIX
-       // GNOME_CANVAS_ITEM(waveview)->object.flags |= GNOME_CANVAS_ITEM_NO_AUTO_REDRAW;
 }
 
 static void
index be4c52d6217e02e92d63bf30e0f08fe40b30a3d9..3b5d00d9eddf34d8bd8354f187378d166efec565 100644 (file)
@@ -60,11 +60,8 @@ Editor::add_named_selection_to_named_selection_display (NamedSelection& selectio
 void
 Editor::redisplay_named_selections ()
 {
-        //GTK2FIX
-        //named_selection_display.freeze ();
        named_selection_model->clear ();
        session->foreach_named_selection (*this, &Editor::add_named_selection_to_named_selection_display);
-       //named_selection_display.thaw ();
 }
 
 gint
index 3aa95d022f1d9462bdef750d86598cda90087089..f4351fe51845b140563a67736995ed7ecbaf900b 100644 (file)
@@ -347,9 +347,6 @@ Editor::edit_meter_section (MeterSection* section)
        MeterDialog meter_dialog (*section, _("done"));
 
        meter_dialog.set_position (Gtk::WIN_POS_MOUSE);
-       // GTK2FIX
-       // meter_dialog.realize ();
-       // meter_dialog.get_window()->set_decorations (Gdk::WMDecoration (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH));
 
        ensure_float (meter_dialog);
 
@@ -378,9 +375,6 @@ Editor::edit_tempo_section (TempoSection* section)
        TempoDialog tempo_dialog (*section, _("done"));
 
        tempo_dialog.set_position (Gtk::WIN_POS_MOUSE);
-       // GTK2FIX
-       // tempo_dialog.realize ();
-       // tempo_dialog.get_window()->set_decorations (Gdk::WMDecoration (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH));
 
        ensure_float (tempo_dialog);
        
index 84229447797a2322b2a25985b42dd8f18537c3e7..4ed36f55e724546b081e55b8b0ff93d0cb8bc6f3 100644 (file)
@@ -64,8 +64,6 @@ ImageFrameTimeAxis::ImageFrameTimeAxis(const string & track_id, PublicEditor& ed
 {
        _color = unique_random_color() ;
        
-       //GTK2FIX -- how to get the group? is the canvas display really a group?
-       //selection_group = gnome_canvas_item_new (GNOME_CANVAS_GROUP(canvas_display), gnome_canvas_group_get_type (), NULL) ;
        selection_group = new ArdourCanvas::Group (*canvas_display);
        selection_group->hide();
 
index e08f5819519ecfbe1d87b0dc56e8875b4bd6b090..53e0aa87584be3fab70e52c3976708bde1b3de38 100644 (file)
@@ -52,8 +52,6 @@ MarkerTimeAxisView::MarkerTimeAxisView(MarkerTimeAxis& tv)
        region_color = _trackview.color();
        stream_base_color = color_map[cMarkerTrackBase];
 
-       //GTK2FIX -- how to get the group? is the canvas display really a group?
-       //canvas_group = gnome_canvas_item_new (GNOME_CANVAS_GROUP(_trackview.canvas_display), gnome_canvas_group_get_type (), 0);
        canvas_group = new ArdourCanvas::Group (*_trackview.canvas_display);
 
        canvas_rect =  new ArdourCanvas::SimpleRect (*canvas_group);
index 1b08b46ccd345e62d8316749641daa993c479af4..b3726e491633f2a46daf9a7cac7ec5bc2261e0d6 100644 (file)
@@ -424,10 +424,6 @@ RedirectBox::wierd_plugin_dialog (Plugin& p, uint32_t streams, IO& io)
        dialog.set_modal (true);
        dialog.show_all ();
 
-       // GTK2FIX
-       //dialog.realize();
-       //dialog.get_window()->set_decorations (Gdk::WMDecoration (GDK_DECOR_BORDER|GDK_DECOR_RESIZEH));
-
        dialog.run ();
 }
 
index 07f3bf865d57931239bbe98ae9841fdee3975039..906c7b5ed9517a75c0134eb140c0a864b6dc4b95 100644 (file)
@@ -356,9 +356,6 @@ RouteParams_UI::set_session (Session *sess)
 {
        ArdourDialog::set_session (sess);
 
-       // GTK2FIX
-       // route_select_list.freeze ();
-
        route_display_model->clear();
 
        if (session) {
index 2a449da946bbf69fbf0252ee14458d3b07b92121..9f5fbda13f0bf341cc9dcd5a631d2a9377435ac2 100644 (file)
@@ -259,9 +259,9 @@ MeterDialog::init (const BBT_Time& when, double bpb, double note_type, bool mova
        else
                note_types.set_active_text (_("quarter (4)"));
                
-       /* strings.back() just happens to be the longest one to display */
-       // GTK2FIX
-        //Gtkmm2ext::set_size_request_to_display_given_text (note_types, "thirty-second (32)", 7, 7);
+       /* the string here needs to be the longest one to display */
+       const guint32 FUDGE = 20; // Combo's are stupid - they steal space from the entry for the button
+        Gtkmm2ext::set_size_request_to_display_given_text (note_types, "thirty-second (32)", 7+FUDGE, 7);
 
        hspacer1.set_border_width (5);
        hspacer1.pack_start (note_types, false, false);
index aba8090addf59649c554ea81078a0fc747eeb7d8..ddfe0c5a0137cea953de478c7e9a4562a847ebad 100644 (file)
@@ -26,6 +26,8 @@ class BasicUI {
        void undo ();
        void redo ();
        void toggle_all_rec_enables ();
+       void toggle_punch_in ();
+       void toggle_punch_out ();
 
   protected:
        ARDOUR::Session& session;
index fcbd672cf468341eecb47fe4c3ae308555e1c536..cfed836eab6108aa6dcb54fbc41dd0edb5f1007f 100644 (file)
@@ -184,6 +184,14 @@ BasicUI::toggle_all_rec_enables ()
        }
 }
 
-               
-
+void
+BasicUI::toggle_punch_in ()
+{
+       session.set_punch_in (!session.get_punch_in());
+}
 
+void
+BasicUI::toggle_punch_out ()
+{
+       session.set_punch_out (!session.get_punch_out());
+}
index 0cab0fd28d6a986b50268ff075669d686024bcec..af0e39449eeef498cb040d4edc63b2f5e8d95304 100644 (file)
@@ -3212,7 +3212,7 @@ void
 Session::set_dirty ()
 {
        bool was_dirty = dirty();
-       
+
        _state_of_the_state = StateOfTheState (_state_of_the_state | Dirty);
 
        if (!was_dirty) {
index a0f04443ef5b1a1f505943b7a88656b590358afa..30ca270593ba8ee8c49f31d1ce026b1051ec2af5 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <iostream>
 #include <algorithm>
+#include <cmath>
 
 #include <float.h>
 #include <sys/time.h>
@@ -47,6 +48,23 @@ BaseUI::RequestType LEDChange = BaseUI::new_request_type ();
 BaseUI::RequestType Print = BaseUI::new_request_type ();
 BaseUI::RequestType SetCurrentTrack = BaseUI::new_request_type ();
 
+static inline double 
+gain_to_slider_position (ARDOUR::gain_t g)
+{
+       if (g == 0) return 0;
+       return pow((6.0*log(g)/log(2.0)+192.0)/198.0, 8.0);
+
+}
+
+static inline ARDOUR::gain_t 
+slider_position_to_gain (double pos)
+{
+       /* XXX Marcus writes: this doesn't seem right to me. but i don't have a better answer ... */
+       if (pos == 0.0) return 0;
+       return pow (2.0,(sqrt(sqrt(sqrt(pos)))*198.0-192.0)/6.0);
+}
+
+
 TranzportControlProtocol::TranzportControlProtocol (Session& s)
        : ControlProtocol  (s, X_("Tranzport")),
          AbstractUI<TranzportRequest> (X_("Tranzport"), false)
@@ -66,6 +84,7 @@ TranzportControlProtocol::TranzportControlProtocol (Session& s)
        last_wheel_dir = 1;
        last_track_gain = FLT_MAX;
        display_mode = DisplayNormal;
+       gain_fraction = 0.0;
 
        memset (current_screen, 0, sizeof (current_screen));
        memset (pending_screen, 0, sizeof (pending_screen));
@@ -102,11 +121,15 @@ TranzportControlProtocol::set_active (bool yn)
                        }
 
                } else {
-
+                       cerr << "Begin tranzport shutdown\n";
                        pthread_cancel_one (thread);
-                       lcd_clear ();
+                       cerr << "Thread dead\n";
+                       // lcd_clear ();
+                       // lights_off ();
+                       // cerr << "dev reset\n";
                        close ();
                        _active = false;
+                       cerr << "End tranzport shutdown\n";
                } 
        }
 
@@ -120,7 +143,7 @@ TranzportControlProtocol::show_track_gain ()
                gain_t g = current_route->gain();
                if (g != last_track_gain) {
                        char buf[16];
-                       snprintf (buf, sizeof (buf), "%6.1fdB", coefficient_to_dB (current_route->gain()));
+                       snprintf (buf, sizeof (buf), "%6.1fdB", coefficient_to_dB (current_route->effective_gain()));
                        print (0, 9, buf); 
                        last_track_gain = g;
                }
@@ -411,7 +434,7 @@ TranzportControlProtocol::lcd_clear ()
 
        for (uint8_t i = 0; i < 10; ++i) {
                cmd[2] = i;
-               usb_interrupt_write (udev, WRITE_ENDPOINT, (char*) cmd, 8, 500);
+               usb_interrupt_write (udev, WRITE_ENDPOINT, (char*) cmd, 8, 1000);
        }
        
        memset (current_screen, ' ', sizeof (current_screen));
@@ -432,31 +455,31 @@ TranzportControlProtocol::lights_off ()
        cmd[7] = 0x00;
 
        cmd[2] = LightRecord;
-       if (write (cmd, 500) == 0) {
+       if (write (cmd, 1000) == 0) {
                lights[LightRecord] = false;
        }
        cmd[2] = LightTrackrec;
-       if (write (cmd, 500) == 0) {
+       if (write (cmd, 1000) == 0) {
                lights[LightTrackrec] = false;
        }
        cmd[2] = LightTrackmute;
-       if (write (cmd, 500) == 0) {
+       if (write (cmd, 1000) == 0) {
                lights[LightTrackmute] = false;
        }
        cmd[2] = LightTracksolo;
-       if (write (cmd, 500) == 0) {
+       if (write (cmd, 1000) == 0) {
                lights[LightTracksolo] = false;
        }
        cmd[2] = LightAnysolo;
-       if (write (cmd, 500) == 0) {
+       if (write (cmd, 1000) == 0) {
                lights[LightAnysolo] = false;
        }
        cmd[2] = LightLoop;
-       if (write (cmd, 500) == 0) {
+       if (write (cmd, 1000) == 0) {
                lights[LightLoop] = false;
        }
        cmd[2] = LightPunch;
-       if (write (cmd, 500) == 0) {
+       if (write (cmd, 1000) == 0) {
                lights[LightPunch] = false;
        }
 }
@@ -477,7 +500,7 @@ TranzportControlProtocol::light_on (LightID light)
                cmd[6] = 0x00;
                cmd[7] = 0x00;
 
-               if (write (cmd, 500) == 0) {
+               if (write (cmd, 1000) == 0) {
                        lights[light] = true;
                        return 0;
                } else {
@@ -505,7 +528,7 @@ TranzportControlProtocol::light_off (LightID light)
                cmd[6] = 0x00;
                cmd[7] = 0x00;
 
-               if (write (cmd, 500) == 0) {
+               if (write (cmd, 1000) == 0) {
                        lights[light] = false;
                        return 0;
                } else {
@@ -524,6 +547,7 @@ TranzportControlProtocol::monitor_work ()
        int err;
        uint8_t buf[8];
        int val;
+       bool first_time = true;
 
        PBD::ThreadCreated (pthread_self(), X_("Tranzport"));
 
@@ -538,26 +562,22 @@ TranzportControlProtocol::monitor_work ()
        pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, 0);
        pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0);
 
-       /* set initial state */
-
-       lcd_clear ();
-       lights_off ();
-
-       show_wheel_mode();
        next_track ();
-       show_transport_time ();
 
        while (true) {
 
                /* bInterval for this beastie is 10ms */
 
-               pthread_testcancel();
-               usleep (20000);
-               pthread_testcancel();
-
                /* anything to read ? */
 
-               val = usb_interrupt_read (udev, READ_ENDPOINT, (char*) buf, 8, 0);
+               if (_device_status == STATUS_OFFLINE) {
+                       light_off (LightRecord);
+                       first_time = true;
+               }
+
+               pthread_testcancel();
+               val = usb_interrupt_read (udev, READ_ENDPOINT, (char*) buf, 8, 10);
+               pthread_testcancel();
 
                /* any requests to handle? */
 
@@ -567,9 +587,15 @@ TranzportControlProtocol::monitor_work ()
                        process (buf);
                }
 
-               /* update whatever needs updating */
-               
-               update_state ();
+               if (_device_status != STATUS_OFFLINE) {
+                       if (first_time) {
+                               lcd_clear ();
+                               lights_off ();
+                               first_time = false;
+                       }
+                       /* update whatever needs updating */
+                       update_state ();
+               }
        }
 
        return (void*) 0;
@@ -620,7 +646,7 @@ TranzportControlProtocol::update_state ()
                                cmd[6] = pending_screen[row][col_base+3];
                                cmd[7] = 0x00;
 
-                               if (usb_interrupt_write (udev, WRITE_ENDPOINT, (char *) cmd, 8, 500) == 8) {
+                               if (usb_interrupt_write (udev, WRITE_ENDPOINT, (char *) cmd, 8, 1000) == 8) {
                                        /* successful write: copy to current */
                                        memcpy (&current_screen[row][col_base], &pending_screen[row][col_base], 4);
                                }
@@ -1049,6 +1075,8 @@ void
 TranzportControlProtocol::button_event_in_press (bool shifted)
 {
        if (shifted) {
+               toggle_punch_in ();
+       } else {
                ControlProtocol::ZoomIn (); /* EMIT SIGNAL */
        }
 }
@@ -1062,6 +1090,8 @@ void
 TranzportControlProtocol::button_event_out_press (bool shifted)
 {
        if (shifted) {
+               toggle_punch_out ();
+       } else {
                ControlProtocol::ZoomOut (); /* EMIT SIGNAL */
        }
 }
@@ -1353,20 +1383,32 @@ void
 TranzportControlProtocol::step_gain_up ()
 {
        if (buttonmask & ButtonStop) {
-               current_route->inc_gain (0.01, this);
+               gain_fraction += 0.001;
        } else {
-               current_route->inc_gain (0.1, this);
+               gain_fraction += 0.01;
+       }
+
+       if (gain_fraction > 2.0) {
+               gain_fraction = 2.0;
        }
+       
+       current_route->set_gain (slider_position_to_gain (gain_fraction), this);
 }
 
 void
 TranzportControlProtocol::step_gain_down ()
 {
        if (buttonmask & ButtonStop) {
-               current_route->inc_gain (-0.01, this);
+               gain_fraction -= 0.001;
        } else {
-               current_route->inc_gain (-0.1, this);
+               gain_fraction -= 0.01;
+       }
+
+       if (gain_fraction < 0.0) {
+               gain_fraction = 0.0;
        }
+       
+       current_route->set_gain (slider_position_to_gain (gain_fraction), this);
 }
 
 void
@@ -1444,6 +1486,7 @@ TranzportControlProtocol::next_track ()
        }
 
        current_route = cr;
+       gain_fraction = gain_to_slider_position (current_route->effective_gain());
 }
 
 void
@@ -1477,6 +1520,7 @@ TranzportControlProtocol::prev_track ()
        }
 
        current_route = cr;
+       gain_fraction = gain_to_slider_position (current_route->effective_gain());
 }
 
 void
index cf4a9a7d3f3838e15b73aa99baa5443a62657c5c..69812cb5ec160ab2590591361c5d60c75d4e6310 100644 (file)
@@ -100,11 +100,13 @@ class TranzportControlProtocol : public ARDOUR::ControlProtocol, public Abstract
        uint8_t        _datawheel;
        uint8_t        _device_status;
        usb_dev_handle* udev;
+
        ARDOUR::Route*  current_route;
        uint32_t        current_track_id;
        WheelMode       wheel_mode;
        WheelShiftMode  wheel_shift_mode;
        DisplayMode     display_mode;
+       ARDOUR::gain_t  gain_fraction;
 
        void do_request (TranzportRequest*);