23 using namespace Audio;
34 const sample* startSample,
35 const sample* stopSample,
36 const unsigned char stride,
40 const sample *in = startSample;
41 sample vMin = *in, vMax = *in;
43 while (in < stopSample) {
66 if (levelCount == 1) {
70 stepTime =
step = fineStepSize;
73 else if (levelCount > 0) {
76 step = coarserStepSize;
77 prev->configureTree(
channelCount, levelCount - 1, fineStepSize, coarserStepSize);
78 stepTime =
step * prev->stepTime;
90 if (newSize !=
size) {
91 minmax = realloc(minmax, newSize * 2 *
channelCount *
sizeof(sample));
95 sample *
out = (sample*)minmax;
97 for (
int block = 0; block < prev->size; block +=
step) {
101 sample *in = (sample*)prev->minmax + block * skip + 2 * ch, *stop = in +
blockSize * skip;
102 sample vMin = in[0], vMax = in[1];
117 if (newSize !=
size) {
118 minmax = realloc(minmax, newSize * 2 *
channelCount *
sizeof(sample));
122 sample *
out = (sample*)minmax;
128 sample
min{ sample::MAX_VALUE },
max{ sample::MIN_VALUE };
148 b0 =
ceili(time0, stepTime);
149 b1 = time1 / stepTime;
155 prev->measure<sample>(time0, time1,
min,
max,
data);
160 prev->measure<sample>(time0, t0,
min,
max,
data);
167 b0 =
ceili(time0, stepTime);
168 b1 = time1 / stepTime;
174 if (time0 < t0 ||
t1 < time1) {
175 sample *pMin =
min, *pMax =
max;
176 for (
int ch = 0; ch <
channelCount; ch++, pMin++, pMax++) {
209 b0 = time0 / stepTime;
217 for (
int chSkip = 0; chSkip < skip; chSkip += 2) {
218 sample *ptr = (sample*)minmax + skip*b0 + chSkip, *stop = (sample*)minmax + skip*b1 + chSkip;
255 copy->plot.lookup.disposeTree();
296 const bool useLookup =
303 const void* sampleData =
nullptr;
datatype * ptr(int offset=0)
Data structure allowing to plot efficiently audio signal graphs.
void updateTree(const sample *data, int sampleCount)
Updates tree from raw sample data.
void configureTree(unsigned char channelCount, int levelCount, int fineStepSize, int coarserStepSize)
Sets up the tree structure.
DynamicsLookup * prev
previous (finer scale) level
void measure(dtime time0, dtime time1, sample *min, sample *max, const void *data) const
Measures dynamics from time0 to time1 in each channels separately.
int size
buffer size in points in one channel, i.e., size in bytes is 2*channelCount*sizeof(magnitude)*size
void * minmax
(2*size) points per channel, channel-wise multiplexed, interleaved minima and maxima
void disposeTree()
Frees the current level and all previous.
unsigned char blockSize
size in bytes of a channelwise-multiplexed sample (block containing 1 sample per channel)
void updateDynamicsLookup()
SignalFragment(AudioSampleFormat format, unsigned char channels, int samples)
struct Beatmup::Audio::SignalFragment::Plot plot
void measureDynamics(int time0, int time1, sample *min, sample *max, Signal::Meter::MeasuringMode mode)
Measures dynamics from time0 to time1 in each channels separately.
unsigned char channelCount
number of channels
virtual SignalFragment * clone() const
msize getSizeBytes() const
MeasuringMode
Specifies how to compute signal dynamics (minima and maxima in a given period of time)
@ approximateUsingLookup
Find an approximated range using a lookup tree.
@ preciseUsingLookupAndSamples
Use lookup and then precise the measurement using sample data.
@ preciseUsingSamples
Just run across all samples.
int sampleCount
number of samples within this frame
const int getSampleCount() const
static void insanity(const char *message)
static void check(const bool condition, const std::string &message)
#define BEATMUP_ASSERT_DEBUG(C)
const int AUDIO_SAMPLE_SIZE[]
AudioSampleFormat
Format of audio samples.
@ Int8
signed integer, 8 bit per sample
@ Int32
signed integer, 32 bit per sample
@ Float32
floating point, 32 bit per sample
@ Int16
signed integer, 16 bit per sample
CustomPoint< numeric > min(const CustomPoint< numeric > &a, const CustomPoint< numeric > &b)
CustomPoint< numeric > max(const CustomPoint< numeric > &a, const CustomPoint< numeric > &b)
void measureMultiplexedChannelDynamics(const sample *startSample, const sample *stopSample, const unsigned char stride, sample &min, sample &max)
Measures dynamics from samples for a single channel in a multiplexed stream.
#define ceili(x, y)
integer division x/y with ceiling
JNIEnv jobject jint jint jint channels
Beatmup::AbstractBitmap * copy