<commit_before>
#include <iostream>
#include <fstream>
#include <essentia/algorithmfactory.h>
#include <essentia/essentiamath.h>
#include <essentia/pool.h>
#include "credit_libav.h"


using namespace essentia;
using namespace essentia::standard;
using namespace std;
int main (int argc,char* argv[]) {

    if (argc != 3) {
    cout << "ERROR: incorrect number of arguments." << endl;
    cout << "Usage: " << argv[0] << " audio_input yaml_output" << endl;
    exit(1);
  }

  setDebugLevel(EAll);
  string audioFilename1 = argv[1];
  string audioFilename2 = argv[2];
  // string outputFilename = argv[2];

  // register the algorithms in the factory(ies)
  essentia::init();


  AlgorithmFactory& factory = AlgorithmFactory::instance();


  Algorithm* audio1 = factory.create("AudioLoader",
                                    "filename", audioFilename1);

  Algorithm* audio2 = factory.create("AudioLoader",
                                    "filename", audioFilename2);

  Algorithm* le    = factory.create("LoudnessEBUR128");                                                             

  cout << "-------- connecting algos ---------" << endl;
  Real sr;
  int ch, br;
  std::string md5, cod;
  // Audio -> FrameCutter

  vector<StereoSample> audioBuffer;
  audio1->output("audio").set(audioBuffer);
  audio1->output("sampleRate").set(sr);
  audio1->output("numberChannels").set(ch);
  audio1->output("md5").set(md5);
  audio1->output("bit_rate").set(br);
  audio1->output("codec").set(cod);


  le->input("signal").set(audioBuffer);

  // FrameCutter -> GapsDetector
  vector<Real> momentaryLoudness, shortTermLoudness;
  Real integratedLoudness, loudnessRange;

  le->output("momentaryLoudness").set(momentaryLoudness);
  le->output("shortTermLoudness").set(shortTermLoudness);
  le->output("integratedLoudness").set(integratedLoudness);
  le->output("loudnessRange").set(loudnessRange);


  /////////// STARTING THE ALGORITHMS //////////////////
  cout << "-------- start processing " << audioFilename1 << " --------" << endl;
  audio1->compute();
  le->compute();

  // audioBuffer.clear();
  audio2->output("audio").set(audioBuffer); 
  audio2->output("audio").set(audioBuffer);
  audio2->output("sampleRate").set(sr);
  audio2->output("numberChannels").set(ch);
  audio2->output("md5").set(md5);
  audio2->output("bit_rate").set(br);
  audio2->output("codec").set(cod);
  /////////// STARTING THE ALGORITHMS //////////////////
  cout << "-------- start processing " << audioFilename2 << " --------" << endl;
  audio2->compute();
  le->compute();
                    

  delete audio1;
  delete audio2;
  delete le;

  essentia::shutdown();

  return 0;

}<commit_msg>New EBU R128 loudness CLI extractor<commit_after>
#include <iostream>
#include <fstream>
#include <essentia/algorithmfactory.h>
#include <essentia/essentiamath.h>
#include <essentia/pool.h>
#include "credit_libav.h"


using namespace essentia;
using namespace essentia::standard;
using namespace std;

int main (int argc,char* argv[]) {
    if (argc != 3) {
    cout << "ERROR: incorrect number of arguments." << endl;
    cout << "Usage: " << argv[0] << " input_audiofile output_jsonfile (use '-' for stdout)" << endl;
    exit(1);
  }

  string audioFilename = argv[1];
  string outputFilename = argv[2];

  // register the algorithms in the factory(ies)
  essentia::init();

  AlgorithmFactory& factory = AlgorithmFactory::instance();

  Algorithm* audio = factory.create("AudioLoader", "filename", audioFilename);
  Algorithm* le    = factory.create("LoudnessEBUR128");                                                             
  Real sr;
  int ch, br;
  std::string md5, cod;

  vector<StereoSample> audioBuffer;
  audio->output("audio").set(audioBuffer);
  audio->output("sampleRate").set(sr);
  audio->output("numberChannels").set(ch);
  audio->output("md5").set(md5);
  audio->output("bit_rate").set(br);
  audio->output("codec").set(cod);

  le->input("signal").set(audioBuffer);

  vector<Real> momentaryLoudness, shortTermLoudness;
  Real integratedLoudness, loudnessRange;

  le->output("momentaryLoudness").set(momentaryLoudness);
  le->output("shortTermLoudness").set(shortTermLoudness);
  le->output("integratedLoudness").set(integratedLoudness);
  le->output("loudnessRange").set(loudnessRange);

  audio->compute();
  le->compute();

  Pool pool = Pool();
  pool.set("loudness_ebu128.momentary", momentaryLoudness);
  pool.set("loudness_ebu128.short_term", shortTermLoudness);
  pool.set("loudness_ebu128.integrated", integratedLoudness);
  pool.set("loudness_ebu128.loudness_range", loudnessRange);

  Algorithm* yaml_writer = factory.create("YamlOutput",
                               "filename", outputFilename, "format", "json");
  yaml_writer->input("pool").set(pool);
  yaml_writer->compute();

  delete audio;
  delete le;
  delete yaml_writer;

  essentia::shutdown();
  return 0;
}
{'fraction_non_alphanumeric': 0.17521979145369046, 'fraction_numerical': 0.0136986301369863, 'mean_word_length': 3.5129151291512914, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 56, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '661580', 'n_tokens_mistral': 1605, 'n_tokens_neox': 1513, 'n_words': 283}