To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Revision:

root / src / may / vamp / test / test_vamp.yeti @ 598:fb845664b699

History | View | Annotate | Download (4.23 KB)

1
module may.vamp.test.test_vamp;
2

    
3
v = load may.vamp;
4
synthetic = load may.stream.syntheticstream;
5
manip = load may.stream.manipulate;
6
mat = load may.matrix;
7
vec = load may.vector;
8

    
9
{ compare, compareUsing } = load may.test;
10

    
11
testPluginKey = "vamp-test-plugin:vamp-test-plugin";
12

    
13
rate = 44100;
14

    
15
testStream () = manip.withDuration (rate * 20) (synthetic.whiteNoise rate);
16

    
17
processTest output = 
18
    v.processStreamStructured testPluginKey output (testStream ());
19

    
20
float n is number -> number =
21
    // round number to float precision (for comparison with floats)
22
   (arr = new float[1];
23
    arr[0] := n;
24
    arr[0]);
25

    
26
floats nn = map float nn;
27

    
28
tests =
29
[
30

    
31
"version": \(
32
    case v.loadPlugin rate testPluginKey of
33
    Error e: (eprintln "version: Error: \(e)"; false);
34
    OK plugin: compare plugin.version 4;
35
    esac
36
),
37

    
38
"instants": \(
39
    case processTest "instants" of
40
    Instants ii:
41
        compare (map (.time) ii) [ 0, 1.5, 3, 4.5, 6, 7.5, 9, 10.5, 12, 13.5 ];
42
    other: failWith "wrong structure type: expected Instants tag, got \(other)";
43
    esac
44
),
45

    
46
"curve-oss": \(
47
    case processTest "curve-oss" of
48
    Series s:
49
        compare s.start 0 and
50
        //!!! want to specify step and block size for processing
51
            compare s.step (2048/rate) and
52
            compare s.values (floats (map (* 0.05) [0..19]));
53
    other: failWith "wrong structure type: expected Series tag, got \(other)";
54
    esac
55
),
56

    
57
"curve-fsr": \(
58
    case processTest "curve-fsr" of
59
    Curve c:
60
        compare (map (.time) c) (map (* 0.4) [0..9]) and
61
           compare (map (.value) c) (floats (map (* 0.1) [0..9]));
62
/*
63
        compare s.start 0 and
64
            compare s.step 0.4 and
65
            compare s.values (floats (map (* 0.1) [0..9]));
66
*/
67
    other: failWith "wrong structure type: expected Series tag, got \(other)";
68
    esac
69
),
70
    
71
"curve-fsr-timed": \(
72
    case processTest "curve-fsr-timed" of
73
    Curve c:
74
        compare (map (.time) c) [ 0, 0, 0, 0.4, 2, 2, 2, 2.4, 4, 4 ] and
75
           compare (map (.value) c) (floats (map (* 0.1) [0..9]));
76
    other: failWith "wrong structure type: expected Curve tag, got \(other)";
77
    esac
78
),
79

    
80
"curve-vsr": \(
81
    case processTest "curve-vsr" of
82
    Curve c:
83
        compare (map (.time) c) (map (* 0.75) [0..9]) and
84
           compare (map (.value) c) (floats (map (* 0.1) [0..9]));
85
    other: failWith "wrong structure type: expected Curve tag, got \(other)";
86
    esac
87
),
88

    
89
"grid-oss": \(
90
    case processTest "grid-oss" of //!!! test spacing?
91
    Grid g:
92
        compareUsing mat.equal g 
93
           (mat.fromColumns
94
               (map do x:
95
                   (vec.fromList . floats) (map do y:
96
                        (x + y + 2) / 30
97
                        done [0..9])
98
                    done [0..19]));
99
    other: failWith "wrong structure type: expected Grid tag, got \(other)";
100
    esac
101
),
102

    
103
"grid-fsr": \(
104
    case processTest "grid-fsr" of //!!! test spacing?
105
    Grid g:
106
        compareUsing mat.equal g 
107
           (mat.fromColumns
108
               (map do x:
109
                   (vec.fromList . floats) (map do y:
110
                        (x + y + 2) / 20
111
                        done [0..9])
112
                    done [0..9]));
113
    other: failWith "wrong structure type: expected Grid tag, got \(other)";
114
    esac
115
),
116

    
117
"notes-regions": \(
118
    case processTest "notes-regions" of
119
    Regions rr:
120
        compare (map (.time) rr) [0..9] and
121
           compare (map (.duration) rr) (map do i: Time (if i % 2 == 0 then 1.75 else 0.5 fi) done [0..9]) and
122
           compare (map (.values) rr) (map do i: array [float i] done (map (* 0.1) [0..9]));
123
    other: failWith "wrong structure type: expected Curve tag, got \(other)";
124
    esac
125
),
126
    
127
];
128

    
129
// Check we have the test plugin. Without it, all the tests must fail
130

    
131
if contains? testPluginKey v.pluginKeys then 
132
    tests
133
else
134
    eprintln
135
"** Vamp test plugin not found!
136
   Either the Vamp module is not working, or the test plugin is not installed.
137
   Please ensure vamp-test-plugin.{so,dll,dylib} is in the path,
138
   or set $VAMP_PATH to point to its location.
139

    
140
   Current path: \(v.pluginPath)
141
   Required plugin key: \"\(testPluginKey)\"
142
   Plugin keys found: \(v.pluginKeys)
143

    
144
   All of the Vamp plugin tests will fail until this is fixed.
145
";
146
    mapIntoHash id \\false (keys tests)
147
fi is hash<string, () -> boolean>;
148

    
149

    
150