aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRichard <q@1bpm.net>2021-03-16 01:20:31 +0000
committerRichard <q@1bpm.net>2021-03-16 01:20:31 +0000
commit4e3f857cb84c2c2ba834d5ddd0c5e1d9375cd947 (patch)
tree4ffc6ef2c8db27689c1c230d1f1b93f365e03747 /include
downloadcsound-xtract-4e3f857cb84c2c2ba834d5ddd0c5e1d9375cd947.tar.gz
csound-xtract-4e3f857cb84c2c2ba834d5ddd0c5e1d9375cd947.tar.bz2
csound-xtract-4e3f857cb84c2c2ba834d5ddd0c5e1d9375cd947.zip
initial
Diffstat (limited to 'include')
-rw-r--r--include/dtw.h79
1 files changed, 79 insertions, 0 deletions
diff --git a/include/dtw.h b/include/dtw.h
new file mode 100644
index 0000000..4c8064d
--- /dev/null
+++ b/include/dtw.h
@@ -0,0 +1,79 @@
+/*
+Copyright (c) 2014, Calder Phillips-Grafflin (calder.pg@gmail.com)
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <plugin.h>
+
+#ifndef DTW_H
+#define DTW_H
+
+namespace DTW
+{
+
+class SimpleDTW
+{
+private:
+
+ double (*distance_fn_)(MYFLT* p1, MYFLT* p2, int bands);
+ MYFLT* data_;
+ size_t x_dim_;
+ size_t y_dim_;
+ int mfcc_bands;
+
+ inline size_t GetDataIndex(size_t x, size_t y)
+ {
+ return (x * y_dim_) + y;
+ }
+
+ inline double GetFromDTWMatrix(size_t x, size_t y)
+ {
+ return data_[GetDataIndex(x, y)];
+ }
+
+ inline void SetInDTWMatrix(size_t x, size_t y, MYFLT val)
+ {
+ data_[GetDataIndex(x, y)] = val;
+ }
+
+public:
+
+ SimpleDTW (csnd::Csound* csound, size_t x_size, size_t y_size, int mfcc_bands, MYFLT (*distance_fn)(MYFLT* p1, MYFLT* p2, int bands));
+
+ ~SimpleDTW() {}
+
+ double EvaluateWarpingCost(
+ MYFLT* sequence_1,
+ int seq1_items,
+ MYFLT* sequence_2,
+ int seq2_items
+ );
+
+};
+
+}
+
+#endif // DTW_H