MCPcopy Create free account
hub / github.com/Tracktion/choc / copyAudioData

Function copyAudioData

choc/audio/choc_AudioFileFormat.h:498–522  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

496}
497
498inline uint64_t copyAudioData (AudioFileWriter& dest, AudioFileReader& source, uint64_t maxNumFramesToCopy)
499{
500 constexpr uint32_t bufferSize = 2048;
501
502 auto& readerProperties = source.getProperties();
503 auto framesToDo = maxNumFramesToCopy != 0 ? std::min (maxNumFramesToCopy, readerProperties.numFrames) : readerProperties.numFrames;
504 auto tempBuffer = choc::buffer::ChannelArrayBuffer<double> (readerProperties.numChannels, bufferSize, false);
505 uint64_t readIndex = 0;
506
507 while (framesToDo != 0)
508 {
509 auto blockSize = static_cast<uint32_t> (std::min (static_cast<uint64_t> (bufferSize), framesToDo));
510 auto block = tempBuffer.getStart (blockSize);
511
512 if (! source.readFrames (readIndex, block))
513 break;
514
515 dest.appendFrames (block);
516
517 readIndex += blockSize;
518 framesToDo -= blockSize;
519 }
520
521 return readIndex;
522}
523
524//==============================================================================
525template <typename AudioFormatType>

Callers

nothing calls this directly

Calls 3

getStartMethod · 0.45
readFramesMethod · 0.45
appendFramesMethod · 0.45

Tested by

no test coverage detected