11namespace tracktion {
inline namespace engine
15 #pragma clang diagnostic push
16 #pragma clang diagnostic ignored "-Wsign-conversion"
17 #pragma clang diagnostic ignored "-Wunused-parameter"
18 #pragma clang diagnostic ignored "-Wshadow"
19 #pragma clang diagnostic ignored "-Wmacro-redefined"
20 #pragma clang diagnostic ignored "-Wconversion"
21 #pragma clang diagnostic ignored "-Wunused"
22 #if __has_warning("-Wzero-as-null-pointer-constant")
23 #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
25 #pragma clang diagnostic ignored "-Wextra-semi"
29 #pragma GCC diagnostic push
30 #pragma GCC diagnostic ignored "-Wsign-conversion"
31 #pragma GCC diagnostic ignored "-Wshadow"
33 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
35 #pragma GCC diagnostic ignored "-Wunused-variable"
36 #pragma GCC diagnostic ignored "-Wpedantic"
37 #pragma GCC diagnostic ignored "-Wunknown-pragmas"
40#include "soundtouch/include/BPMDetect.h"
43 #pragma clang diagnostic pop
47 #pragma GCC diagnostic pop
57 : numChannels (numChannels_),
58 bpmDetect (numChannels, (
int) sampleRate)
69 const SampleCount blockSize = 65536;
70 const bool useRightChan = numChannels > 1;
80 auto numThisTime = (
int)
std::min (numLeft, blockSize);
81 reader.
read (&buffer, 0, numThisTime, startSample,
true, useRightChan);
84 startSample += numThisTime;
85 numLeft -= numThisTime;
98 return bpm = bpmDetect.getBpm();
104 bool isBpmSensible()
const {
return getSensibleRange().
contains (bpm); }
117 return bpm = bpmDetect.getBpm();
120 void processSection (
const float*
const* inputSamples,
int numSamples)
123 float* interleaved = scratch.buffer.getWritePointer (0);
130 bpmDetect.inputSamples (interleaved, numSamples);
136 soundtouch::BPMDetect bpmDetect;
const Type *const * getArrayOfReadPointers() const noexcept
static void interleaveSamples(NonInterleavedSource< SourceFormat... > source, InterleavedDest< DestFormat... > dest, int numSamples)
ChannelData< true, false, Format... > InterleavedDest
ChannelData< false, true, Format... > NonInterleavedSource
constexpr bool contains(const ValueType position) const noexcept
An audio scratch buffer that has pooled storage.
Uses the SoundTouch BPMDetect class to guess the tempo of some audio.
float processReader(juce::AudioFormatReader &reader)
Processes an entire AudioFormatReader returning the tempo for it.
float getBpm() const
Returns the last BPM detected.
float finishAndDetect()
Completes the detection process and returns the BPM.
float processAndDetect(const float **const inputSamples, int numSamples)
Processes a block of audio returning the tempo for it.
void processSection(juce::AudioBuffer< float > &buffer, int numSamplesToProcess)
Processes a non-interleaved buffer section.