MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / extract_interleaved_channel

Function extract_interleaved_channel

src/framework/audio/conversion.cpp:105–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105std::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
123std::vector<float> convert_wav_to_mono_linear_resampled(
124 const WavData & wav,

Callers 2

runMethod · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected