21 #ifndef ESSENTIA_METADATAUTILS_H
22 #define ESSENTIA_METADATAUTILS_H
32 void pcmMetadata(
const std::string& filename,
int& sr,
int& ch,
int& bitrate) {
34 size_t pos = filename.rfind(
'.');
35 if (pos != std::string::npos) {
36 std::string ext = filename.substr(pos, std::string::npos);
37 if (ext !=
".wav" && ext !=
".aiff" && ext !=
".aif") {
38 throw EssentiaException(
"metadatautils: pcmMetadata cannot read files which are neither \"wav\" nor \"aiff\"");
41 throw EssentiaException(
"metadatautils: pcmMetadata cannot guess the filetype by extension");
46 "filename", filename));
48 sr = (int)streaming::lastTokenProduced<Real>(audioloader->output(
"sampleRate"));
49 ch = streaming::lastTokenProduced<int>(audioloader->output(
"numberChannels"));
50 bitrate = int(16.0/1000.0*sr*ch);
static BaseAlgorithm * create(const std::string &id)
Definition: algorithmfactory.h:86
Definition: algorithm.h:28
void pcmMetadata(const std::string &filename, int &sr, int &ch, int &bitrate)
Definition: metadatautils.h:32