Merging from trunk
[ardour.git] / gtk2_ardour / curvetest.cc
1 #include <iostream>
2 #include <fstream>
3 #include <cfloat>
4 #include <unistd.h>
5
6 #include <ardour/curve.h>
7
8 using namespace std;
9 using namespace ARDOUR;
10 using namespace PBD;
11
12 int
13 curvetest (string filename)
14 {
15         ifstream in (filename.c_str());
16         stringstream line;
17         Curve c (-1.0, +1.0, 0, true);
18         double minx = DBL_MAX;
19         double maxx = DBL_MIN;
20
21         while (in) {
22                 double x, y;
23
24                 in >> x;
25                 in >> y;
26                 
27                 if (!in) {
28                         break;
29                 }
30
31                 if (x < minx) {
32                         minx = x;
33                 }
34                 
35                 if (x > maxx) {
36                         maxx = x;
37                 }
38                 
39                 c.add (x, y);
40         }
41
42
43         float foo[1024];
44
45         c.get_vector (minx, maxx, foo, 1024);
46         
47         for (int i = 0; i < 1024; ++i) {
48                 cout << minx + (((double) i / 1024.0) * (maxx - minx)) << ' ' << foo[i] << endl;
49         }
50         
51         return 0;
52 }