8000 Add Panning descriptor to Freesound and Music extractors · Issue #363 · MTG/essentia · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Add Panning descriptor to Freesound and Music extractors #363
Open
@dbogdanov

Description

@dbogdanov

Re-use the code of an outdated "streaming_extractor_short_sounds" for Freesound extractor. Panning descriptors may be also useful for Music Extractor, as they have been used for genre classification task (see documentation of the algorithm for references).

Make sure unit tests are OK (#316) before adding this descriptor to extractors.

The code to re-use:

void Panning(SourceBase& input, Pool& pool, const Pool& options, const string& nspace) {

  options.set("panning.compute", false);                                           
  options.set("panning.frameSize", 8192);                                          
  options.set("panning.hopSize", 2048);                                            
  options.set("panning.zeroPadding", 8192);                                        
  options.set("panning.windowType", "hann");                                       
  options.set("panning.silentFrames", "noise"); 

   // namespace
  string llspace = "lowlevel.";
  if (!nspace.empty()) llspace = nspace + ".lowlevel.";

  Real sampleRate = options.value<Real>("sampleRate");
  int frameSize   = int(options.value<Real>("panning.frameSize"));
  int hopSize     = int(options.value<Real>("panning.hopSize"));
  int zeroPadding = int(options.value<Real>("panning.zeroPadding"));
  string silentFrames = options.value<string>("panning.silentFrames");
  string windowType = options.value<string>("panning.windowType");

  streaming::AlgorithmFactory& factory = streaming::AlgorithmFactory::instance();

  Algorithm* demuxer = factory.create("StereoDemuxer");

  Algorithm* fc_left = factory.create("FrameCutter",
                                      "frameSize", frameSize,
                                      "hopSize", hopSize,
                                      "startFromZero", false,
                                      "silentFrames", silentFrames);

  Algorithm* fc_right  = factory.create("FrameCutter",
                                        "frameSize", frameSize,
                                        "hopSize", hopSize,
                                        "startFromZero", false,
                                        "silentFrames", silentFrames);

  Algorithm* w_left= factory.create("Windowing",
                                    "size", frameSize,
                                    "zeroPadding", zeroPadding,
                                    "type", windowType);

  Algorithm* w_right = factory.create("Windowing",
                                      "size", frameSize,
                                      "zeroPadding", zeroPadding,
                                      "type", windowType);

  Algorithm* spec_left = factory.create("Spectrum");

  Algorithm* spec_right = factory.create("Spectrum");

  Algorithm* pan = factory.create("Panning",
                                  "sampleRate", sampleRate,
                                  "averageFrames", 43, // 2 seconds * sr/hopsize
                                  "panningBins", 512,
                                  "numCoeffs", 20,
                                  "numBands", 1,
                                  "warpedPanorama", true);

  connect(input, demuxer->input("audio"));

  demuxer->output("left")        >> fc_left->input("signal");
  demuxer->output("right")       >> fc_right->input("signal");
  // left channel
  fc_left->output("frame")       >> w_left->input("frame");
  w_left->output("frame")        >> spec_left->input("frame");
  spec_left->output("spectrum")  >> pan->input("spectrumLeft");
  // right channel
  fc_right->output("frame")      >> w_right->input("frame");
  w_right->output("frame")       >> spec_right->input("frame");
  spec_right->output("spectrum") >> pan->input("spectrumRight");

  // panning
  pan->output("panningCoeffs")   >> PC(pool, llspace + "panning_coefficients");
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0