Initial import of gtk2_ardour.
[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
11 int
12 curvetest (string filename)
13 {
14         ifstream in (filename.c_str());
15         stringstream line;
16         Curve c (-1.0, +1.0, 0, true);
17         double minx = DBL_MAX;
18         double maxx = DBL_MIN;
19
20         while (in) {
21                 double x, y;
22
23                 in >> x;
24                 in >> y;
25                 
26                 if (!in) {
27                         break;
28                 }
29
30                 if (x < minx) {
31                         minx = x;
32                 }
33                 
34                 if (x > maxx) {
35                         maxx = x;
36                 }
37                 
38                 c.add (x, y);
39         }
40
41
42         float foo[1024];
43
44         c.get_vector (minx, maxx, foo, 1024);
45         
46         for (int i = 0; i < 1024; ++i) {
47                 cout << minx + (((double) i / 1024.0) * (maxx - minx)) << ' ' << foo[i] << endl;
48         }
49         
50         return 0;
51 }