X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Faudioanalyser.cc;h=3acfc9bce445df28043c85ba44b6309347f041a0;hb=66760a574a1fc0ccc8a798c2900a717c134838ea;hp=eccc38434d9c0b39b1e6d3faf5521e67ea7a5e3e;hpb=a2a6cc0404757f445bd753d69f34d8bc2c0e87a9;p=ardour.git diff --git a/libs/ardour/audioanalyser.cc b/libs/ardour/audioanalyser.cc index eccc38434d..3acfc9bce4 100644 --- a/libs/ardour/audioanalyser.cc +++ b/libs/ardour/audioanalyser.cc @@ -1,13 +1,18 @@ -#include +#include + +#include "vamp-hostsdk/PluginLoader.h" + #include #include #include // for g_remove() -#include +#include "pbd/error.h" + +#include "ardour/audioanalyser.h" +#include "ardour/readable.h" +#include "ardour/readable.h" -#include -#include -#include +#include #include "i18n.h" @@ -21,11 +26,11 @@ AudioAnalyser::AudioAnalyser (float sr, AnalysisPluginKey key) , plugin_key (key) { /* create VAMP plugin and initialize */ - + if (initialize_plugin (plugin_key, sample_rate)) { error << string_compose (_("cannot load VAMP plugin \"%1\""), key) << endmsg; throw failed_constructor(); - } + } } AudioAnalyser::~AudioAnalyser () @@ -45,7 +50,7 @@ AudioAnalyser::initialize_plugin (AnalysisPluginKey key, float sr) if (!plugin) { error << string_compose (_("VAMP Plugin \"%1\" could not be loaded"), key) << endmsg; return -1; - } + } /* we asked for the buffering adapter, so set the blocksize to something that makes for efficient disk i/o @@ -74,7 +79,7 @@ AudioAnalyser::reset () plugin->reset (); } } - + int AudioAnalyser::analyse (const string& path, Readable* src, uint32_t channel) { @@ -91,7 +96,7 @@ AudioAnalyser::analyse (const string& path, Readable* src, uint32_t channel) if (!path.empty()) { /* store data in tmp file, not the real one */ - + tmp_path = path; tmp_path += ".tmp"; @@ -107,11 +112,11 @@ AudioAnalyser::analyse (const string& path, Readable* src, uint32_t channel) while (!done) { nframes64_t to_read; - + /* read from source */ to_read = min ((len - pos), bufsize); - + if (src->read (data, pos, to_read, channel) != to_read) { goto out; } @@ -121,7 +126,7 @@ AudioAnalyser::analyse (const string& path, Readable* src, uint32_t channel) if (to_read != bufsize) { memset (data + to_read, 0, (bufsize - to_read) * sizeof (Sample)); } - + features = plugin->process (bufs, RealTime::fromSeconds ((double) pos / sample_rate)); if (use_features (features, (path.empty() ? 0 : &ofile))) { @@ -156,9 +161,7 @@ AudioAnalyser::analyse (const string& path, Readable* src, uint32_t channel) g_rename (tmp_path.c_str(), path.c_str()); } - if (data) { - delete [] data; - } + delete [] data; return ret; }