Get the next block of audio samples
| 29 | |
| 30 | // Get the next block of audio samples |
| 31 | void AudioBufferSource::getNextAudioBlock (const juce::AudioSourceChannelInfo& info) |
| 32 | { |
| 33 | int buffer_samples = buffer->getNumSamples(); |
| 34 | int buffer_channels = buffer->getNumChannels(); |
| 35 | |
| 36 | if (info.numSamples > 0) { |
| 37 | int start = position; |
| 38 | int number_to_copy = 0; |
| 39 | |
| 40 | // Determine how many samples to copy |
| 41 | if (start + info.numSamples <= buffer_samples) |
| 42 | { |
| 43 | // copy the full amount requested |
| 44 | number_to_copy = info.numSamples; |
| 45 | } |
| 46 | else if (start > buffer_samples) |
| 47 | { |
| 48 | // copy nothing |
| 49 | number_to_copy = 0; |
| 50 | } |
| 51 | else if (buffer_samples - start > 0) |
| 52 | { |
| 53 | // only copy what is left in the buffer |
| 54 | number_to_copy = buffer_samples - start; |
| 55 | } |
| 56 | else |
| 57 | { |
| 58 | // copy nothing |
| 59 | number_to_copy = 0; |
| 60 | } |
| 61 | |
| 62 | // Determine if any samples need to be copied |
| 63 | if (number_to_copy > 0) |
| 64 | { |
| 65 | // Loop through each channel and copy some samples |
| 66 | for (int channel = 0; channel < buffer_channels; channel++) |
| 67 | info.buffer->copyFrom(channel, info.startSample, *buffer, channel, start, number_to_copy); |
| 68 | |
| 69 | // Update the position of this audio source |
| 70 | position += number_to_copy; |
| 71 | } |
| 72 | |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | // Prepare to play this audio source |
| 77 | void AudioBufferSource::prepareToPlay(int, double) { } |
nothing calls this directly
no outgoing calls
no test coverage detected