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);
146 const auto zeroLineY = GetRowFromValue(.0f);
155 envelope !=
nullptr && (envelope->GetNumberOfPoints() > 0 ||
156 envelope->GetDefaultValue() != 1.0))
161 envelope->GetOffset(),
162 1.0 /
key.PixelsPerSecond);
164 for (
size_t column = 0; column < columnsCount; ++column)
166 const auto columnData = inputData[column];
170 columnData.min * envelopeValue,
171 columnData.max * envelopeValue,
172 columnData.rms * envelopeValue
199 for (
size_t column = 0; column < columnsCount; ++column)
201 const bool selected = firstPixel >= selFirst && firstPixel < selLast;
204 const auto columnData = inputData[column];
210 0, selected ? clipColors.Selected : clipColors.Normal, height);
215 size_t stopIndex = 0;
218 function.SetStop(stopIndex++, blankColor, globalMaxRow);
220 const auto maxRow = GetRowFromValue(columnData.max);
222 if(zeroLineY > globalMaxRow && maxRow > zeroLineY)
227 selected ? backgroundColors.Selected : backgroundColors.Normal,
240 selected ? backgroundColors.Selected : backgroundColors.Normal,
244 if (maxRow >= height)
249 const auto positiveRMSRow = GetRowFromValue(columnData.rms);
251 if (maxRow < positiveRMSRow)
255 selected ? sampleColors.Selected : sampleColors.Normal,
259 if (positiveRMSRow >= height)
262 const auto negativeRMSRow =
263 GetRowFromValue(std::max(-columnData.rms, columnData.min));
265 if (positiveRMSRow < negativeRMSRow)
268 stopIndex++, selected ? rmsColors.Selected : rmsColors.Normal,
272 if (negativeRMSRow >= height)
276 const auto minRow = GetRowFromValue(columnData.min);
280 stopIndex++, selected ? sampleColors.Selected : sampleColors.Normal,
281 minRow != maxRow ? minRow : minRow + 1);
283 if(zeroLineY < globalMinRow && minRow < zeroLineY)
288 selected ? backgroundColors.Selected : backgroundColors.Normal,
296 if (minRow < globalMinRow)
300 selected ? backgroundColors.Selected : backgroundColors.Normal,
304 if (globalMinRow < height)
305 function.SetStop(stopIndex++, blankColor, height);
316 std::array<ColorFunction, GraphicsDataCacheBase::CacheElementWidth>
321 std::array<double, GraphicsDataCacheBase::CacheElementWidth>
330 const WaveClip& waveClip, std::shared_ptr<WaveDataCache> dataCache,
331 ElementFactory elementFactory)
333 std::move(elementFactory) }
335 , mWaveClip { waveClip }
336 , mStretchChangedSubscription {
368 const ZoomInfo& zoomInfo,
double t0,
double t1,
bool selected)
370 const auto empty = !selected || t0 > t1 ||
371 ((t1 - t0) < std::numeric_limits<double>::epsilon());
373 const auto first = empty ? int64_t(-1) : zoomInfo.
TimeToPosition(t0);
375 empty ? int64_t(-1) : std::max(zoomInfo.
TimeToPosition(t1), first + 1);
405 const auto width = 1;
407 const auto bytes = element.
Allocate(width, height);
408 std::memset(bytes, 0, width * height * 3);
421 auto rowData = element.
Allocate(columnsCount, height);
423 for (uint32_t row = 0; row < height; ++row)
427 for (
size_t pixel = 0; pixel < columnsCount; ++pixel)
429 const auto color = colorFunction->GetColor(row, defaultColor);
431 *rowData++ = color.r;
432 *rowData++ = color.g;
433 *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
struct WaveBitmapCache::@133 mSelection
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)
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.
graphics::Color ZeroLineColor
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.