MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / GetInterleavedAudioSamples

Method GetInterleavedAudioSamples

src/Frame.cpp:324–355  ·  view source on GitHub ↗

Get an array of sample data (all channels interleaved together), using any sample rate

Source from the content-addressed store, hash-verified

322
323// Get an array of sample data (all channels interleaved together), using any sample rate
324float* Frame::GetInterleavedAudioSamples(int* sample_count)
325{
326 // Copy audio data
327 juce::AudioBuffer<float> *buffer(audio.get());
328
329 float *output = NULL;
330 int num_of_channels = audio->getNumChannels();
331 int num_of_samples = GetAudioSamplesCount();
332
333 // INTERLEAVE all samples together (channel 1 + channel 2 + channel 1 + channel 2, etc...)
334 output = new float[num_of_channels * num_of_samples];
335 int position = 0;
336
337 // Loop through samples in each channel (combining them)
338 for (int sample = 0; sample < num_of_samples; sample++)
339 {
340 for (int channel = 0; channel < num_of_channels; channel++)
341 {
342 // Add sample to output array
343 output[position] = buffer->getReadPointer(channel)[sample];
344
345 // increment position
346 position++;
347 }
348 }
349
350 // Update sample count (since it might have changed due to resampling)
351 *sample_count = num_of_samples;
352
353 // return combined array
354 return output;
355}
356
357// Get number of audio channels
358int Frame::GetAudioChannelsCount()

Callers 2

write_audio_packetsMethod · 0.80
ResampleMappedAudioMethod · 0.80

Calls 1

getMethod · 0.45

Tested by

no test coverage detected