| 556 | //------------------------------------------------------------------------------ |
| 557 | |
| 558 | bool 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 |
nothing calls this directly
no test coverage detected