| 103 | } |
| 104 | |
| 105 | std::vector<float> extract_interleaved_channel( |
| 106 | const std::vector<float> & interleaved_samples, |
| 107 | int channel_count, |
| 108 | int channel_index) { |
| 109 | if (channel_count <= 0 || channel_index < 0 || channel_index >= channel_count) { |
| 110 | throw std::runtime_error("interleaved audio channel selection is invalid"); |
| 111 | } |
| 112 | if (interleaved_samples.size() % static_cast<size_t>(channel_count) != 0) { |
| 113 | throw std::runtime_error("interleaved audio sample count must be divisible by channel count"); |
| 114 | } |
| 115 | const size_t frames = interleaved_samples.size() / static_cast<size_t>(channel_count); |
| 116 | std::vector<float> channel(frames, 0.0F); |
| 117 | for (size_t frame = 0; frame < frames; ++frame) { |
| 118 | channel[frame] = interleaved_samples[frame * static_cast<size_t>(channel_count) + static_cast<size_t>(channel_index)]; |
| 119 | } |
| 120 | return channel; |
| 121 | } |
| 122 | |
| 123 | std::vector<float> convert_wav_to_mono_linear_resampled( |
| 124 | const WavData & wav, |
no test coverage detected