GUI: support 2/4, 3/4, 5/4 and other non-standard time signatures
authorStefan Westerfeld <stefan@space.twc.de>
Fri, 13 May 2011 12:03:14 +0000 (14:03 +0200)
committerStefan Westerfeld <stefan@space.twc.de>
Fri, 13 May 2011 12:03:14 +0000 (14:03 +0200)
beast-gtk/bstpianoroll.c
beast-gtk/bsttrackroll.c
beast-gtk/bsttrackroll.h
beast-gtk/bsttrackview.c

index 2f1e208..3f2ddef 100644 (file)
@@ -1045,7 +1045,7 @@ bst_piano_roll_hsetup (BstPianoRoll *self,
    */
 
   self->ppqn = MAX (ppqn, 1);
-  self->qnpt = CLAMP (qnpt, 3, 4);
+  self->qnpt = MAX (qnpt, 1);
   self->max_ticks = MAX (max_ticks, 1);
   self->hzoom = CLAMP (hzoom, 0.01, 100);
   
@@ -1171,6 +1171,17 @@ piano_roll_song_pointer_changed (BstPianoRoll *self,
 }
 
 static void
+piano_roll_time_signature_changed (BstPianoRoll *self)
+{
+  if (self->song)
+    {
+      SfiInt numerator, denominator;
+      bse_proxy_get (self->song, "numerator", &numerator, "denominator", &denominator, NULL);
+      bst_piano_roll_hsetup (self, self->ppqn, numerator, self->max_ticks, self->hzoom);
+    }
+}
+
+static void
 piano_roll_links_changed (BstPianoRoll *self)
 {
   if (self->plinks)
@@ -1269,10 +1280,13 @@ bst_piano_roll_set_proxy (BstPianoRoll *self,
           bse_proxy_connect (self->song,
                              "swapped_signal::release", piano_roll_release_proxy, self,
                              "swapped_signal::pointer-changed", piano_roll_song_pointer_changed, self,
+                            "swapped_signal::property-notify::numerator", piano_roll_time_signature_changed, self,
+                            "swapped_signal::property-notify::denominator", piano_roll_time_signature_changed, self,
                              NULL);
         }
       piano_roll_links_changed (self);
       piano_roll_song_pointer_changed (self, -1);
+      piano_roll_time_signature_changed (self);
     }
   gtk_widget_queue_resize (GTK_WIDGET (self));
 }
index 332d9b3..6b521f0 100644 (file)
@@ -1183,6 +1183,16 @@ bst_track_roll_set_marker (BstTrackRoll          *self,
     track_roll_move_2markers (self, marker);
 }
 
+void
+bst_track_roll_set_time_signature (BstTrackRoll *self,
+                                   guint         numerator,
+                                   guint         denominator)
+{
+  guint tpt = numerator * 4 * 384 / denominator;
+
+  bst_track_roll_hsetup (self, tpt, self->max_ticks, self->hzoom);
+}
+
 static void
 bst_track_roll_class_init (BstTrackRollClass *class)
 {
index 399e771..f191ca8 100644 (file)
@@ -142,6 +142,9 @@ void    bst_track_roll_set_marker          (BstTrackRoll           *self,
                                             guint                   mark_index,
                                             guint                   position,
                                             BstTrackRollMarkerType  mtype);
+void    bst_track_roll_set_time_signature  (BstTrackRoll           *self,
+                                            guint                   numerator,
+                                            guint                   denominator);
 
 
 G_END_DECLS
index 2c1564b..8ca4f83 100644 (file)
@@ -492,6 +492,18 @@ track_view_repeat_changed (BstTrackView *self)
 }
 
 static void
+track_view_time_signature_changed (BstTrackView *self)
+{
+  SfiProxy song = BST_ITEM_VIEW (self)->container;
+  if (self->troll && song)
+    {
+      SfiInt numerator, denominator;
+      bse_proxy_get (song, "numerator", &numerator, "denominator", &denominator, NULL);
+      bst_track_roll_set_time_signature (self->troll, numerator, denominator);
+    }
+}
+
+static void
 bst_track_view_init (BstTrackView *self)
 {
   BstItemView *iview = BST_ITEM_VIEW (self);
@@ -667,9 +679,12 @@ track_view_set_container (BstItemView *iview,
                         "swapped_signal::property-notify::loop-right", track_view_marks_changed, self,
                         "swapped_signal::property-notify::tick-pointer", track_view_marks_changed, self,
                         "swapped_signal::property-notify::loop-enabled", track_view_repeat_changed, self,
+                        "swapped_signal::property-notify::numerator", track_view_time_signature_changed, self,
+                        "swapped_signal::property-notify::denominator", track_view_time_signature_changed, self,
                         NULL);
       track_view_marks_changed (self);
       track_view_repeat_changed (self);
+      track_view_time_signature_changed (self);
     }
 }