From 0f08cac5b167b989ccf3607a231ee5e992cdee05 Mon Sep 17 00:00:00 2001
From: "Tim E. Real" <termtech@rogers.com>
Date: Tue, 30 Aug 2011 01:14:15 +0000
Subject: Small fix - could not add new points to discrete automation graphs.

---
 muse2/muse/arranger/pcanvas.cpp | 8 +++++---
 muse2/muse/song.cpp             | 8 ++++----
 2 files changed, 9 insertions(+), 7 deletions(-)

(limited to 'muse2')

diff --git a/muse2/muse/arranger/pcanvas.cpp b/muse2/muse/arranger/pcanvas.cpp
index 57bf71ba..ef45c9df 100644
--- a/muse2/muse/arranger/pcanvas.cpp
+++ b/muse2/muse/arranger/pcanvas.cpp
@@ -3587,6 +3587,7 @@ void PartCanvas::checkAutomation(Track * t, const QPoint &pointer, bool addNewCt
         double min, max;
         cl->range(&min,&max);
         //bool discrete = cl->valueType() == VAL_BOOL || cl->mode() == CtrlList::DISCRETE;  // Tim
+        bool discrete = cl->mode() == CtrlList::DISCRETE;  
 
         // First check that there IS automation, ic == cl->end means no automation
         if (ic == cl->end()) 
@@ -3611,7 +3612,7 @@ void PartCanvas::checkAutomation(Track * t, const QPoint &pointer, bool addNewCt
              }
              else 
                y = (y-min)/(max-min);  // we need to set curVal between 0 and 1
-
+             
              ypixel = mapy(trackY + trackH - 2 - y * trackH);
              xpixel = mapx(tempomap.frame2tick(ic->second.frame));
 
@@ -3625,7 +3626,7 @@ void PartCanvas::checkAutomation(Track * t, const QPoint &pointer, bool addNewCt
                double firstX=oldX;
                double lastX=xpixel;
                double firstY=oldY;
-               double lastY=ypixel;
+               double lastY = discrete ? oldY : ypixel;
 
                double proportion = (currX-firstX)/(lastX-firstX);
 
@@ -3807,7 +3808,8 @@ void PartCanvas::processAutomationMovements(QPoint pos, bool addPoint)
       // we need to set val between 0 and 1 (unless integer)
       cvval = yfraction * (max-min) + min;
       // 'Snap' to integer or boolean
-      if (automation.currentCtrlList->valueType() == VAL_INT || automation.currentCtrlList->valueType() == VAL_BOOL)
+      //if (automation.currentCtrlList->valueType() == VAL_INT || automation.currentCtrlList->valueType() == VAL_BOOL)
+      if (automation.currentCtrlList->mode() == CtrlList::DISCRETE)
         cvval = rint(cvval + 0.1); // LADSPA docs say add a slight bias to avoid rounding errors. Try this.
       if (cvval< min) cvval=min;
       if (cvval>max) cvval=max;
diff --git a/muse2/muse/song.cpp b/muse2/muse/song.cpp
index 9d1c3afb..e4749d19 100644
--- a/muse2/muse/song.cpp
+++ b/muse2/muse/song.cpp
@@ -2517,13 +2517,13 @@ int Song::execAutomationCtlPopup(AudioTrack* track, const QPoint& menupos, int a
     if(icl != track->controller()->end())
     {
       CtrlList *cl = icl->second;
-        canAdd = true;
-        ctlval = cl->curVal();
+      canAdd = true;
+      int frame = pos[0].frame();
+      ctlval = cl->curVal();
+      //ctlval = cl->value(frame);   // p4.0.32
       count = cl->size();
       if(count)
       {
-        int frame = pos[0].frame();
-
         iCtrl s = cl->lower_bound(frame);
         iCtrl e = cl->upper_bound(frame);
 
-- 
cgit v1.2.3