Mercurial > hg > may
changeset 91:6d6627fbbb78
Introduce a type declaration which makes it possible to use values from returned feature (see comment)
author | Chris Cannam |
---|---|
date | Tue, 19 Mar 2013 13:43:39 +0000 |
parents | cf88733911fd |
children | 77d3292bbf12 |
files | vamp.yeti |
diffstat | 1 files changed, 31 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/vamp.yeti Tue Mar 19 13:23:43 2013 +0000 +++ b/vamp.yeti Tue Mar 19 13:43:39 2013 +0000 @@ -22,7 +22,7 @@ feature f is ~Feature -> 'a = { timestamp = if f#hasTimestamp then Time (realTime f#timestamp) else Untimed () fi, duration = if f#hasDuration then Time (realTime f#duration) else Untimed () fi, - values = list f#values, + values = f#values, label = f#label, }; @@ -209,16 +209,27 @@ Error "Failed to load Vamp plugin with key \(key)" yrt; -processed { p, sampleRate, hop } frames count = +processed { p, sampleRate, hop } frames count + // I don't know why this type declaration is necessary. Without + // it, yeti records the return type as 'a and can't do anything + // useful with it (giving IncompatibleClassChangeError when + // e.g. accessing the values array) + is 'a -> 'b -> 'c -> + list<hash<number, + list<{ timestamp is Time number | Untimed (), + duration is Time number | Untimed (), + label is string, + values is ~float[] + }>>> = case frames of - frame::rest: - p.process [frame] RealTime#frame2RealTime(count, sampleRate) - :. - \(processed { p, sampleRate, hop } rest (count + hop)); - _: - (rf = p.getRemainingFeatures (); - p.dispose (); - [rf]); + frame::rest: + p.process [frame] RealTime#frame2RealTime(count, sampleRate) + :. + \(processed { p, sampleRate, hop } rest (count + hop)); + _: + (rf = p.getRemainingFeatures (); + p.dispose (); + [rf]); esac; converted { p, sampleRate, hop } outputNo fl = @@ -236,13 +247,16 @@ }; if p.initialise params then OK { - key = key, - output = p.outputs[outputNo], - parameters = mapIntoHash id p.parameterValue (map (.identifier) p.parameters), - config = { channels, blockSize, stepSize, - sampleRate = stream.sampleRate }, - features = converted params outputNo - (processed params (fr.frames params stream) 0) + key = key, + output = p.outputs[outputNo], + parameters = mapIntoHash id p.parameterValue + (map (.identifier) p.parameters), + config = { + channels, blockSize, stepSize, + sampleRate = stream.sampleRate + }, + features = converted params outputNo + (processed params (fr.frames params stream) 0) }; // If processing completed successfully, then p is // disposed by processed and stream is closed by the