Get an array of sample data (all channels interleaved together), using any sample rate
| 322 | |
| 323 | // Get an array of sample data (all channels interleaved together), using any sample rate |
| 324 | float* 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 |
| 358 | int Frame::GetAudioChannelsCount() |
no test coverage detected