Loading...
Searching...
No Matches
Media::Sound::WaveformRenderer Class Referencefinal
Inheritance diagram for Media::Sound::WaveformRenderer:

Detailed Description

The waveform of a sound file, for a widget that draws it: the audio file manager decodes the file, a WaveformComputer renders it into images, and paint() draws them.

Images are requested once the file is decoded, and again whenever the size, pixel ratio or range change. They come back asynchronously: updated() tells the owner to repaint.

Public Member Functions

 WaveformRenderer (QSizeF size, bool threaded=true, QObject *parent=nullptr)
 threaded renders on a pool thread rather than on the GUI thread.
 
void setFile (const QString &path)
 
const QString & path () const noexcept
 
const std::shared_ptr< AudioFile > & file () const noexcept
 
void setRange (double begin, double end)
 The part of the file that is shown, as fractions of its length.
 
void setSize (QSizeF size, double devicePixelRatio)
 
bool hasWaveform () const noexcept
 Whether there is a waveform to draw.
 
void paint (QPainter &painter, const QRectF &rect, double devicePixelRatio)
 
void updated ()
 

Member Function Documentation

◆ paint()

void Media::Sound::WaveformRenderer::paint ( QPainter &  painter,
const QRectF &  rect,
double  devicePixelRatio 
)

Draws the waveform in rect, one band per channel. The rect's size and the pixel ratio become the ones the next images are rendered for.

◆ setFile()

void Media::Sound::WaveformRenderer::setFile ( const QString &  path)

path must be one the audio file manager can open: a resolved path, not a "<PROJECT>:" one. An empty path forgets the file.


The documentation for this class was generated from the following files: