Ardour  9.0-pre0-582-g084a23a80d
spline.h
Go to the documentation of this file.
1 /* This code is based upon work that bore the legend:
2  *
3  * Copyright (C) 1997 David Mosberger
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #pragma once
21 
23 
24 #include <cstdint>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 typedef struct _spline Spline;
31 typedef struct _spline_point SplinePoint;
32 
34 {
35  float x;
36  float y;
37 };
38 
41 
42 void spline_set (Spline *, uint32_t n, SplinePoint *);
43 void spline_add (Spline *, uint32_t n, SplinePoint *);
45 float spline_eval (Spline *, float val);
46 void spline_fill (Spline *, float x0, float x1, float *vec, uint32_t veclen);
49 
51 {
52  float *deriv2;
53  float *x;
54  float *y;
55  float max_x;
56  float min_x;
58  uint32_t npoints;
59  uint32_t space;
60 
61 #ifdef __cplusplus
62 
63  void set (uint32_t n, SplinePoint *points) {
64  spline_set (this, n, points);
65  }
66 
67  void add (uint32_t n, SplinePoint *points) {
68  spline_add (this, n, points);
69  }
70 
71  void solve () {
72  spline_solve (this);
73  }
74 
75  float eval (float val) {
76  return spline_eval (this, val);
77  }
78 
79  void fill (float x0, float x1, float *vec, uint32_t veclen) {
80  spline_fill (this, x0, x1, vec, veclen);
81  }
82 
83 #endif /* __cplusplus */
84 
85 };
86 
87 
88 #ifdef __cplusplus
89 }
90 #endif
91 
#define LIBARDOUR_API
void add(const Gtk::StockItem &item)
void spline_fill(Spline *, float x0, float x1, float *vec, uint32_t veclen)
void spline_add(Spline *, uint32_t n, SplinePoint *)
void spline_free(Spline *)
float spline_get_max_x(Spline *)
float spline_get_min_x(Spline *)
void spline_solve(Spline *)
void spline_set(Spline *, uint32_t n, SplinePoint *)
float spline_eval(Spline *, float val)
Spline * spline_new(void)
float x
Definition: spline.h:35
float y
Definition: spline.h:36
Definition: spline.h:51
float max_x
Definition: spline.h:55
SplinePoint * points
Definition: spline.h:57
float min_x
Definition: spline.h:56
float * x
Definition: spline.h:53
float * y
Definition: spline.h:54
uint32_t space
Definition: spline.h:59
float * deriv2
Definition: spline.h:52
uint32_t npoints
Definition: spline.h:58