Commit 396a92da authored by Stefan Westerfeld's avatar Stefan Westerfeld

Optimize get_frame somewhat.

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 0f938fe7
...@@ -242,13 +242,13 @@ get_frame (const WavData& wav_data, int f, int ch) ...@@ -242,13 +242,13 @@ get_frame (const WavData& wav_data, int f, int ch)
{ {
auto& samples = wav_data.samples(); auto& samples = wav_data.samples();
vector<float> result;
size_t pos = (f * Params::frame_size) * wav_data.n_channels() + ch; size_t pos = (f * Params::frame_size) * wav_data.n_channels() + ch;
assert (pos + (Params::frame_size - 1) * wav_data.n_channels() < samples.size());
vector<float> result (Params::frame_size);
for (size_t x = 0; x < Params::frame_size; x++) for (size_t x = 0; x < Params::frame_size; x++)
{ {
if (pos < samples.size()) result[x] = samples[pos];
result.push_back (samples[pos]);
pos += wav_data.n_channels(); pos += wav_data.n_channels();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment