33 using std::lock_guard;
34 using std::recursive_mutex;
37 using std::max_element;
39 using std::min_element;
41 using std::unique_ptr;
52 Segment(segment_id, samplerate, sizeof(float)),
57 lock_guard<recursive_mutex> lock(
mutex_);
63 lock_guard<recursive_mutex> lock(
mutex_);
69 size_t sample_count,
size_t stride)
73 lock_guard<recursive_mutex> lock(
mutex_);
78 unique_ptr<float[]> deint_data(
new float[sample_count]);
79 float *deint_data_ptr = deint_data.get();
80 for (uint32_t i = 0; i < sample_count; i++) {
81 *deint_data_ptr = (float)(*data);
93 prev_sample_count + 1, prev_sample_count + 1 + sample_count);
96 prev_sample_count + 1, prev_sample_count + 1);
101 assert(sample_num >= 0);
104 lock_guard<recursive_mutex> lock(
mutex_);
112 assert(start_sample >= 0);
114 assert(end_sample >= 0);
115 assert(end_sample <= (int64_t)sample_count_);
116 assert(start_sample <= end_sample);
117 assert(dest !=
nullptr);
119 lock_guard<recursive_mutex> lock(
mutex_);
121 get_raw_samples(start_sample, (end_sample - start_sample), (uint8_t*)dest);
137 uint64_t start, uint64_t end,
float min_length)
const 140 assert(start <= end);
141 assert(min_length > 0);
143 lock_guard<recursive_mutex> lock(
mutex_);
145 const unsigned int min_level =
max((
int)floorf(logf(min_length) /
147 const unsigned int scale_power = (min_level + 1) *
149 start >>= scale_power;
152 s.
start = start << scale_power;
153 s.
scale = 1 << scale_power;
174 uint64_t prev_length;
198 if (e0.
length == prev_length)
203 dest_ptr = e0.
samples + prev_length;
214 *min_element(samples, samples + EnvelopeScaleFactor),
215 *max_element(samples, samples + EnvelopeScaleFactor),
224 *dest_ptr++ = sub_sample;
238 if (e.
length == prev_length)
248 for (dest_ptr = e.
samples + prev_length;
249 dest_ptr < end_dest_ptr; dest_ptr++) {
254 while (src_ptr < end_src_ptr) {
260 *dest_ptr = sub_sample;
void end_sample_iteration(SegmentDataIterator *it)
void get_samples(int64_t start_sample, int64_t end_sample, float *dest) const
void get_raw_samples(uint64_t start, uint64_t count, uint8_t *dest) const
const pair< float, float > get_min_max() const
const uint8_t * get_raw_sample(uint64_t sample_num) const
void append_interleaved_samples(const float *data, size_t sample_count, size_t stride)
static const uint64_t EnvelopeDataUnit
static const unsigned int ScaleStepCount
void get_envelope_section(EnvelopeSection &s, uint64_t start, uint64_t end, float min_length) const
void min_max_changed(float min, float max)
float * get_iterator_value_ptr(SegmentDataIterator *it)
static const int EnvelopeScalePower
SegmentDataIterator * begin_sample_iteration(uint64_t start)
T max(const T v0, const T v1)
void append_payload_to_envelope_levels()
uint64_t get_sample_count() const
AnalogSegment(Analog &owner, uint32_t segment_id, uint64_t samplerate)
T min(const T v0, const T v1)
static const int EnvelopeScaleFactor
void continue_sample_iteration(SegmentDataIterator *it, uint64_t increase)
float get_sample(int64_t sample_num) const
void append_samples(void *data, uint64_t samples)
void notify_samples_added(shared_ptr< Segment > segment, uint64_t start_sample, uint64_t end_sample)
struct Envelope envelope_levels_[ScaleStepCount]
static const float LogEnvelopeScaleFactor
void reallocate_envelope(Envelope &e)
atomic< uint64_t > sample_count_