| 84 | resamplingQuality_(resampling_quality) {} |
| 85 | |
| 86 | Sample LoadAudio::apply(const Sample& sample) const { |
| 87 | auto src = sample::check_key(sample, iKey_, ArrayType::Any); |
| 88 | auto okey = (oKey_.empty() ? iKey_ : oKey_); |
| 89 | auto res = sample; |
| 90 | |
| 91 | std::filesystem::path path; |
| 92 | if (!from_memory_) { |
| 93 | if (src->type() != ArrayType::Int8) { |
| 94 | throw std::runtime_error("LoadAudio: expected filename (int8 array)"); |
| 95 | } |
| 96 | path = prefix_; |
| 97 | std::string filename(reinterpret_cast<char*>(src->data()), src->size()); |
| 98 | path /= filename; |
| 99 | } |
| 100 | |
| 101 | std::shared_ptr<Array> info; |
| 102 | std::shared_ptr<Array> dst; |
| 103 | |
| 104 | // need to return only info? |
| 105 | if (info_ && infoKey_.empty()) { |
| 106 | auto audio_info = |
| 107 | from_memory_ ? core::audio::info(src) : core::audio::info(path); |
| 108 | res[okey] = extract_audio_info(audio_info, infoType_); |
| 109 | } else { |
| 110 | core::audio::AudioInfo audio_info; |
| 111 | auto audio = from_memory_ ? core::audio::load(src, &audio_info) |
| 112 | : core::audio::load(path, &audio_info); |
| 113 | audio = core::audio::resample( |
| 114 | audio, |
| 115 | convert_resample_mode(resamplingQuality_), |
| 116 | audio_info.sampleRate, |
| 117 | sampleRate_); |
| 118 | |
| 119 | if (!infoKey_.empty()) { |
| 120 | res[infoKey_] = extract_audio_info(audio_info, infoType_); |
| 121 | } |
| 122 | res[okey] = audio; |
| 123 | } |
| 124 | return res; |
| 125 | } |
| 126 | |
| 127 | ResampleAudio::ResampleAudio( |
| 128 | const std::string& ikey, |
nothing calls this directly
no test coverage detected