MCPcopy Create free account
hub / github.com/bbc/audiowaveform / resampleWaveformData

Method resampleWaveformData

src/OptionHandler.cpp:558–594  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

556//------------------------------------------------------------------------------
557
558bool OptionHandler::resampleWaveformData(
559 const boost::filesystem::path& input_filename,
560 FileFormat::FileFormat input_format,
561 const boost::filesystem::path& output_filename,
562 FileFormat::FileFormat output_format,
563 const Options& options)
564{
565 WaveformBuffer input_buffer;
566
567 if (!loadWaveformData(input_buffer, input_filename, input_format)) {
568 return false;
569 }
570
571 std::unique_ptr<ScaleFactor> scale_factor = createScaleFactor(options);
572
573 int output_samples_per_pixel = scale_factor->getSamplesPerPixel(
574 input_buffer.getSampleRate()
575 );
576
577 WaveformBuffer output_buffer;
578 WaveformRescaler rescaler;
579
580 rescaler.rescale(
581 input_buffer,
582 output_buffer,
583 output_samples_per_pixel
584 );
585
586 const int bits = options.hasBits() ? options.getBits() : input_buffer.getBits();
587
588 if (output_format == FileFormat::Dat) {
589 return output_buffer.save(output_filename.string().c_str(), bits);
590 }
591 else {
592 return output_buffer.saveAsJson(output_filename.string().c_str(), bits);
593 }
594}
595
596//------------------------------------------------------------------------------
597

Callers

nothing calls this directly

Calls 9

loadWaveformDataFunction · 0.85
createScaleFactorFunction · 0.85
rescaleMethod · 0.80
hasBitsMethod · 0.80
saveMethod · 0.80
saveAsJsonMethod · 0.80
getSamplesPerPixelMethod · 0.45
getSampleRateMethod · 0.45
getBitsMethod · 0.45

Tested by

no test coverage detected