66 for (
auto stop :
Stops)
68 if (row < stop.second)
77 assert(index <
Stops.size());
79 Stops[index].first.SetColor(color);
80 Stops[index].second = position;
97 if (result ==
nullptr)
103 const auto columnsCount = result->AvailableColumns;
110 float sign = (value >= 0 ? 1 : -1);
115 value = (db + dbRange) / dbRange;
126 for (
size_t column = 0; column < columnsCount; ++column)
128 auto oldColumn = result->Data[column];
131 GetDBValue(oldColumn.max),
132 GetDBValue(oldColumn.rms) };
136 auto GetRowFromValue =
140 value = (max - value) / (max -
min);
141 return static_cast<int>(value * (height - 1) + 0.5);
153 envelope !=
nullptr && (envelope->GetNumberOfPoints() > 0 ||
154 envelope->GetDefaultValue() != 1.0))
159 1.0 /
key.PixelsPerSecond);
161 for (
size_t column = 0; column < columnsCount; ++column)
163 const auto columnData = inputData[column];
167 columnData.min * envelopeValue,
168 columnData.max * envelopeValue,
169 columnData.rms * envelopeValue
195 for (
size_t column = 0; column < columnsCount; ++column)
197 const bool selected = firstPixel >= selFirst && firstPixel < selLast;
200 const auto columnData = inputData[column];
206 0, selected ? clipColors.Selected : clipColors.Normal, height);
211 size_t stopIndex = 0;
214 function.SetStop(stopIndex++, blankColor, globalMaxRow);
216 const auto maxRow = GetRowFromValue(columnData.max);
222 selected ? backgroundColors.Selected : backgroundColors.Normal,
226 if (maxRow >= height)
231 const auto positiveRMSRow = GetRowFromValue(columnData.rms);
233 if (maxRow < positiveRMSRow)
237 selected ? sampleColors.Selected : sampleColors.Normal,
241 if (positiveRMSRow >= height)
244 const auto negativeRMSRow =
245 GetRowFromValue(std::max(-columnData.rms, columnData.min));
247 if (positiveRMSRow < negativeRMSRow)
250 stopIndex++, selected ? rmsColors.Selected : rmsColors.Normal,
254 if (negativeRMSRow >= height)
258 const auto minRow = GetRowFromValue(columnData.min);
262 stopIndex++, selected ? sampleColors.Selected : sampleColors.Normal,
263 minRow != maxRow ? minRow : minRow + 1);
265 if (minRow < globalMinRow)
269 selected ? backgroundColors.Selected : backgroundColors.Normal,
273 if (globalMinRow < height)
274 function.SetStop(stopIndex++, blankColor, height);
285 std::array<ColorFunction, GraphicsDataCacheBase::CacheElementWidth>
290 std::array<double, GraphicsDataCacheBase::CacheElementWidth>
299 const WaveClip& waveClip, std::shared_ptr<WaveDataCache> dataCache,
300 ElementFactory elementFactory)
302 std::move(elementFactory) }
304 , mWaveClip { waveClip }
305 , mStretchChangedSubscription {
337 const ZoomInfo& zoomInfo,
double t0,
double t1,
bool selected)
339 const auto empty = !selected || t0 > t1 ||
340 ((t1 - t0) < std::numeric_limits<double>::epsilon());
342 const auto first = empty ? int64_t(-1) : zoomInfo.
TimeToPosition(t0);
344 empty ? int64_t(-1) : std::max(zoomInfo.
TimeToPosition(t1), first + 1);
374 const auto width = 1;
376 const auto bytes = element.
Allocate(width, height);
377 std::memset(bytes, 0, width * height * 3);
390 auto rowData = element.
Allocate(columnsCount, height);
392 for (uint32_t row = 0; row < height; ++row)
396 for (
size_t pixel = 0; pixel < columnsCount; ++pixel)
398 const auto color = colorFunction->GetColor(row, defaultColor);
400 *rowData++ = color.r;
401 *rowData++ = color.g;
402 *rowData++ = color.b;
EffectDistortionSettings params
constexpr size_t ColorFunctionStops
size_t GetVersion() const
void GetValues(double *buffer, int len, double t0, double tstep) const
Get many envelope points at once.
@ WaveBitmapCachePreprocess
Time required to build the structures required for the bitmap cache population.
@ WaveBitmapCache
Time required to access the wave bitmaps cache.
static Stopwatch CreateStopwatch(SectionID section) noexcept
Create a Stopwatch for the section specified.
int64_t GetMaxViewportWidth() const noexcept
void Invalidate()
Invalidate the cache content.
double GetScaledSampleRate() const noexcept
Returns the sample rate associated with cache.
void SetScaledSampleRate(double scaledSampleRate)
An element, that contains a rasterized bitmap matching the WaveDataCacheElement.
~WaveBitmapCacheElement() override
virtual uint8_t * Allocate(size_t width, size_t height)=0
Cache containing rasterized bitmaps representing the waveform.
WavePaintParameters mPaintParamters
const Envelope * mEnvelope
WaveBitmapCache & SetSelection(const ZoomInfo &zoomInfo, double t0, double t1, bool selected)
WaveBitmapCache & SetPaintParameters(const WavePaintParameters ¶ms)
std::unique_ptr< LookupHelper > mLookupHelper
void CheckCache(const ZoomInfo &, double, double) override
~WaveBitmapCache() override
WaveBitmapCache(const WaveClip &waveClip, std::shared_ptr< WaveDataCache > dataCache, ElementFactory elementFactory)
struct WaveBitmapCache::@136 mSelection
const WaveClip & mWaveClip
bool InitializeElement(const GraphicsDataCacheKey &key, WaveBitmapCacheElement &element) override
This allows multiple clips to be a part of one WaveTrack.
double GetStretchRatio() const override
int GetRate() const override
int64 TimeToPosition(double time, int64 origin=0, bool ignoreFisheye=false) const
STM: Converts a project time to screen x position.
double GetRate(const Track &track)
std::array< std::pair< Triplet, uint32_t >, ColorFunctionStops > Stops
Triplet GetColor(uint32_t row, Triplet defaultColor) const noexcept
void SetStop(size_t index, graphics::Color color, uint32_t position)
bool IsComplete
Cache implementation is responsible to set this flag when all the data of the item is filled.
A key into the graphics data cache.
Triplet(Triplet &&)=default
void SetColor(graphics::Color color)
Triplet(graphics::Color color)
Triplet(const Triplet &)=default
std::array< double, GraphicsDataCacheBase::CacheElementWidth > EnvelopeValues
WaveCacheElement::Columns DBRemappedColumns
WaveCacheElement::Columns EnvRemappedColumns
bool PerformLookup(WaveBitmapCache *cache, GraphicsDataCacheKey key)
LookupHelper(std::shared_ptr< WaveDataCache > dataCache)
std::shared_ptr< WaveDataCache > DataCache
std::array< ColorFunction, GraphicsDataCacheBase::CacheElementWidth > ColorFunctions
std::array< WaveDisplayColumn, GraphicsDataCacheBase::CacheElementWidth > Columns
Parameters for the waveform painting.
bool ShowRMS
True, if we paint RMS values on top of min and max.
graphics::Color BlankColor
Color outside the waveform area.
ColorPair RMSColors
Color of the (-rms, +rms) line.
bool DBScale
True, if we paint in dB scale.
bool ShowClipping
True, if we mark clipped values.
double DBRange
Decibel range.
double Max
Max value used to clip the output.
ColorPair SampleColors
Color of the (min, max) line.
ColorPair ClippingColors
Color for the columns where clipping has occurred.
ColorPair BackgroundColors
Waveform background color.
int Height
Height of the of clip on screen.
double Min
Min value used to clip the output.
Class for storing color in 32-bit format.
constexpr uint8_t GetBlue() const noexcept
Returns blue component of this color.
constexpr uint8_t GetGreen() const noexcept
Returns green component of this color.
constexpr uint8_t GetRed() const noexcept
Returns red component of this color.