An implementation of DenseThreeDimensionalModel that makes FFT data derived from a DenseTimeValueModel available as a generic data grid. More...

#include <FFTModel.h>

Inheritance diagram for FFTModel:
Inheritance graph
Collaboration diagram for FFTModel:
Collaboration graph

Classes

struct  SavedColumn
 
struct  SavedSourceData
 

Public Types

enum  PeakPickType { AllPeaks, MajorPeaks, MajorPitchAdaptivePeaks }
 
typedef std::set< int > PeakLocationSet
 
typedef std::map< int, double > PeakSet
 
typedef ColumnOp::Column Column
 
typedef Id ModelId
 
typedef TypedId< ModelId
 
enum  { NO_ID = -1 }
 
typedef int ExportId
 
enum  { SortRole = Qt::UserRole }
 
enum  SortType { SortNumeric, SortAlphabetical }
 

Signals

void modelChanged (ModelId myId)
 Emitted when a model has been edited (or more data retrieved from cache, in the case of a cached model that generates slowly) More...
 
void modelChangedWithin (ModelId myId, sv_frame_t startFrame, sv_frame_t endFrame)
 Emitted when a model has been edited (or more data retrieved from cache, in the case of a cached model that generates slowly) More...
 
void completionChanged (ModelId myId)
 Emitted when some internal processing has advanced a stage, but the model has not changed externally. More...
 
void ready (ModelId myId)
 Emitted when internal processing is complete (i.e. More...
 
void alignmentCompletionChanged (ModelId myId)
 Emitted when the completion percentage changes for the calculation of this model's alignment model. More...
 

Public Member Functions

 FFTModel (ModelId model, int channel, WindowType windowType, int windowSize, int windowIncrement, int fftSize)
 !! threading requirements? !! doubles? since we're not caching much More...
 
 ~FFTModel ()
 
bool isOK () const override
 Return true if the model was constructed successfully. More...
 
int getCompletion () const override
 Return an estimated percentage value showing how far through any background operation used to calculate or load the model data the model thinks it is. More...
 
int getWidth () const override
 Return the number of columns of bins in the model. More...
 
int getHeight () const override
 Return the number of bins in each column. More...
 
float getValueAt (int x, int y) const override
 Get the single data point from the n'th bin of the given column. More...
 
sv_frame_t getStartFrame () const override
 Return the first audio frame spanned by the model. More...
 
sv_frame_t getTrueEndFrame () const override
 Return the audio frame at the end of the model. More...
 
sv_samplerate_t getSampleRate () const override
 Return the frame rate in frames per second. More...
 
int getResolution () const override
 Return the number of sample frames covered by each column of bins. More...
 
float getMinimumLevel () const override
 Return the minimum permissible value in each bin. More...
 
float getMaximumLevel () const override
 Return the maximum permissible value in each bin. More...
 
Column getColumn (int x) const override
 Get data from the given column of bin values. More...
 
bool hasBinValues () const override
 Return true if the bins have values as well as names. More...
 
QString getBinValueUnit () const override
 Obtain the name of the unit of the values returned from getBinValue(), if any. More...
 
bool shouldUseLogValueScale () const override
 Estimate whether a logarithmic scale might be appropriate for the value scale. More...
 
float getBinValue (int n) const override
 Return the value of bin n, if any. More...
 
QString getBinName (int n) const override
 Get the name of a given bin (i.e. More...
 
QVector< QString > getStringExportHeaders (DataExportOptions) const override
 Return a label for each column that would be written by toStringExportRows. More...
 
QVector< QVector< QString > > toStringExportRows (DataExportOptions, sv_frame_t, sv_frame_t) const override
 Emit events starting within the given range as string rows ready for conversion to an e.g. More...
 
QString getError () const
 
int getChannel () const
 
WindowType getWindowType () const
 
int getWindowSize () const
 
int getWindowIncrement () const
 
int getFFTSize () const
 
void setMaximumFrequency (double freq)
 
double getMaximumFrequency () const
 
float getMagnitudeAt (int x, int y) const
 !! review which of these are ever actually called More...
 
float getMaximumMagnitudeAt (int x) const
 
Column getPhases (int x) const
 
float getPhaseAt (int x, int y) const
 
void getValuesAt (int x, int y, float &real, float &imaginary) const
 
bool getMagnitudesAt (int x, float *values, int minbin=0, int count=0) const
 
bool getPhasesAt (int x, float *values, int minbin=0, int count=0) const
 
bool getValuesAt (int x, float *reals, float *imaginaries, int minbin=0, int count=0) const
 
virtual bool estimateStableFrequency (int x, int y, double &frequency)
 Calculate an estimated frequency for a stable signal in this bin, using phase unwrapping. More...
 
virtual PeakLocationSet getPeaks (PeakPickType type, int x, int ymin=0, int ymax=0) const
 Return locations of peak bins in the range [ymin,ymax]. More...
 
virtual PeakSet getPeakFrequencies (PeakPickType type, int x, int ymin=0, int ymax=0) const
 Return locations and estimated stable frequencies of peak bins. More...
 
QString getTypeName () const override
 Return the type of the model. More...
 
bool isLocalPeak (int x, int y)
 Utility function to query whether a given bin is greater than its (vertical) neighbours. More...
 
bool isOverThreshold (int x, int y, float threshold)
 Utility function to query whether a given bin is greater than a certain threshold. More...
 
int getRowCount () const override
 Return the number of rows (items) in the model. More...
 
int getColumnCount () const override
 Return the number of columns (values/labels/etc per item). More...
 
bool isEditable () const override
 Return true if the model is user-editable, false otherwise. More...
 
CommandgetSetDataCommand (int, int, const QVariant &, int) override
 Return a command to set the value in the given cell, for the given role, to the contents of the supplied variant. More...
 
CommandgetInsertRowCommand (int) override
 Return a command to insert a new row before the row with the given index. More...
 
CommandgetRemoveRowCommand (int) override
 Return a command to delete the row with the given index. More...
 
QString getHeading (int column) const override
 Return the heading for a given column, e.g. More...
 
QVariant getData (int row, int column, int) const override
 Get the value in the given cell, for the given role. More...
 
bool isColumnTimeValue (int col) const override
 Return true if the column is the frame time of the item, or an alternative representation of it (i.e. More...
 
SortType getSortType (int) const override
 Return the sort type (numeric or alphabetical) for the column. More...
 
sv_frame_t getFrameForRow (int row) const override
 Return the frame time for the given row. More...
 
int getRowForFrame (sv_frame_t frame) const override
 Return the number of the first row whose frame time is not less than the given one. More...
 
sv_frame_t getEndFrame () const
 Return the audio frame at the end of the model, i.e. More...
 
void extendEndFrame (sv_frame_t to)
 Extend the end of the model. More...
 
virtual sv_samplerate_t getNativeRate () const
 Return the frame rate of the underlying material, if the model itself has already been resampled. More...
 
virtual QString getTitle () const
 Return the "work title" of the model, if known. More...
 
virtual QString getMaker () const
 Return the "artist" or "maker" of the model, if known. More...
 
virtual QString getLocation () const
 Return the location of the data in this model (e.g. More...
 
virtual bool isSparse () const
 Return true if this is a sparse model. More...
 
virtual bool isReady (int *cp=nullptr) const
 Return true if the model has finished loading or calculating all its data, for a model that is capable of calculating in a background thread. More...
 
virtual const ZoomConstraintgetZoomConstraint () const
 If this model imposes a zoom constraint, i.e. More...
 
virtual ModelId getSourceModel () const
 If this model was derived from another, return the id of the model it was derived from. More...
 
virtual void setSourceModel (ModelId model)
 Set the source model for this model. More...
 
virtual void setAlignment (ModelId alignmentModel)
 Specify an alignment between this model's timeline and that of a reference model. More...
 
virtual const ModelId getAlignment () const
 Retrieve the alignment model for this model. More...
 
virtual const ModelId getAlignmentReference () const
 Return the reference model for the current alignment timeline, if any. More...
 
virtual sv_frame_t alignToReference (sv_frame_t frame) const
 Return the frame number of the reference model that corresponds to the given frame number in this model. More...
 
virtual sv_frame_t alignFromReference (sv_frame_t referenceFrame) const
 Return the frame number in this model that corresponds to the given frame number of the reference model. More...
 
virtual int getAlignmentCompletion () const
 Return the completion percentage for the alignment model: 100 if there is no alignment model or it has been entirely calculated, or less than 100 if it is still being calculated. More...
 
void setRDFTypeURI (QString uri)
 Set the event, feature, or signal type URI for the features contained in this model, according to the Audio Features RDF ontology. More...
 
QString getRDFTypeURI () const
 Retrieve the event, feature, or signal type URI for the features contained in this model, if previously set with setRDFTypeURI. More...
 
void toXml (QTextStream &stream, QString indent="", QString extraAttributes="") const override
 Stream this exportable object out to XML on a text stream. More...
 
ExportId getExportId () const
 Return the numerical export identifier for this object. More...
 
virtual QString toXmlString (QString indent="", QString extraAttributes="") const
 Convert this exportable object to XML in a string. More...
 
virtual bool canPlay () const
 
virtual QString getDefaultPlayClipId () const
 
virtual bool getDefaultPlayAudible () const
 

Static Public Member Functions

static QString encodeEntities (QString)
 
static QString encodeColour (int r, int g, int b)
 

Protected Member Functions

Id getId () const
 Return an id for this object. More...
 
int getUntypedId () const
 Return an id for this object. More...
 

Static Protected Member Functions

static QVariant adaptFrameForRole (sv_frame_t frame, sv_samplerate_t rate, int role)
 
static QVariant adaptValueForRole (float value, QString unit, int role)
 

Protected Attributes

QMutex m_mutex
 
ModelId m_sourceModel
 
ModelId m_alignmentModel
 
QString m_typeUri
 
std::atomic< sv_frame_tm_extendTo
 

Private Member Functions

 FFTModel (const FFTModel &)=delete
 
FFTModeloperator= (const FFTModel &)=delete
 
int getPeakPickWindowSize (PeakPickType type, sv_samplerate_t sampleRate, int bin, double &dist) const
 
std::pair< sv_frame_t, sv_frame_tgetSourceSampleRange (int column) const
 
const complexvec_tgetFFTColumn (int column) const
 
floatvec_t getSourceSamples (int column) const
 
floatvec_t getSourceData (std::pair< sv_frame_t, sv_frame_t >) const
 
floatvec_t getSourceDataUncached (std::pair< sv_frame_t, sv_frame_t >) const
 
void clearCaches ()
 

Private Attributes

const ModelId m_model
 
sv_samplerate_t m_sampleRate
 
int m_channel
 
WindowType m_windowType
 
int m_windowSize
 
int m_windowIncrement
 
int m_fftSize
 
Window< float > m_windower
 
breakfastquay::FFT m_fft
 
double m_maximumFrequency
 
QString m_error
 
SavedSourceData m_savedData
 
std::vector< SavedColumnm_cached
 
size_t m_cacheWriteIndex
 
size_t m_cacheSize
 

Detailed Description

An implementation of DenseThreeDimensionalModel that makes FFT data derived from a DenseTimeValueModel available as a generic data grid.

Definition at line 36 of file FFTModel.h.

Member Typedef Documentation

typedef std::set<int> FFTModel::PeakLocationSet

Definition at line 150 of file FFTModel.h.

typedef std::map<int, double> FFTModel::PeakSet

Definition at line 151 of file FFTModel.h.

typedef Id Model::ModelId
inherited

Definition at line 59 of file Model.h.

typedef TypedId<Model > WithTypedId< Model >::Id
inherited

Definition at line 180 of file ById.h.

typedef int XmlExportable::ExportId
inherited

Definition at line 33 of file XmlExportable.h.

Member Enumeration Documentation

Enumerator
AllPeaks 
MajorPeaks 

Any bin exceeding its immediate neighbours.

MajorPitchAdaptivePeaks 

Peaks picked using sliding median window.

Bigger window for higher frequencies

Definition at line 143 of file FFTModel.h.

anonymous enum
inherited
Enumerator
NO_ID 

Definition at line 28 of file XmlExportable.h.

anonymous enum
inherited
Enumerator
SortRole 

Definition at line 57 of file TabularModel.h.

enum TabularModel::SortType
inherited
Enumerator
SortNumeric 
SortAlphabetical 

Definition at line 58 of file TabularModel.h.

Constructor & Destructor Documentation

FFTModel::FFTModel ( ModelId  model,
int  channel,
WindowType  windowType,
int  windowSize,
int  windowIncrement,
int  fftSize 
)

!! threading requirements? !! doubles? since we're not caching much

Construct an FFT model derived from the given DenseTimeValueModel, with the given window parameters and FFT size (which may exceed the window size, for zero-padded FFTs).

If the model has multiple channels use only the given channel, unless the channel is -1 in which case merge all available channels.

Definition at line 35 of file FFTModel.cpp.

References clearCaches(), m_error, m_fft, m_fftSize, m_model, m_sampleRate, m_windowSize, Model::modelChanged(), Model::modelChangedWithin(), SVCERR, and TypedId< T >::untyped.

Referenced by getTypeName().

FFTModel::~FFTModel ( )

Definition at line 77 of file FFTModel.cpp.

FFTModel::FFTModel ( const FFTModel )
privatedelete

Member Function Documentation

bool FFTModel::isOK ( ) const
overridevirtual

Return true if the model was constructed successfully.

Classes that refer to the model should always test this before use.

Implements Model.

Definition at line 93 of file FFTModel.cpp.

References m_error, m_model, and TypedId< T >::untyped.

Referenced by estimateStableFrequency(), getPeakFrequencies(), getPeaks(), and FeatureExtractionModelTransformer::run().

int FFTModel::getCompletion ( ) const
overridevirtual

Return an estimated percentage value showing how far through any background operation used to calculate or load the model data the model thinks it is.

Must return 100 when the model is complete.

A model that carries out all its calculation from the constructor or accessor functions might return 0 if isOK() is false and 100 if isOK() is true. Other models may make the return value here depend on the internal completion status.

See also isReady().

Implements DenseThreeDimensionalModel.

Definition at line 108 of file FFTModel.cpp.

References m_model.

int FFTModel::getWidth ( ) const
overridevirtual

Return the number of columns of bins in the model.

Implements DenseThreeDimensionalModel.

Definition at line 126 of file FFTModel.cpp.

References m_model, and m_windowIncrement.

Referenced by estimateStableFrequency(), getMagnitudeAt(), getPhaseAt(), getTrueEndFrame(), and getValuesAt().

int FFTModel::getHeight ( ) const
overridevirtual

Return the number of bins in each column.

Implements DenseThreeDimensionalModel.

Definition at line 135 of file FFTModel.cpp.

References m_fftSize, m_maximumFrequency, and m_sampleRate.

Referenced by getFFTColumn(), getMagnitudeAt(), getMagnitudesAt(), getPeaks(), getPhaseAt(), getPhasesAt(), and getValuesAt().

float FFTModel::getValueAt ( int  column,
int  n 
) const
inlineoverridevirtual

Get the single data point from the n'th bin of the given column.

Implements DenseThreeDimensionalModel.

Definition at line 69 of file FFTModel.h.

References getMagnitudeAt().

sv_frame_t FFTModel::getStartFrame ( ) const
inlineoverridevirtual

Return the first audio frame spanned by the model.

Implements Model.

Definition at line 72 of file FFTModel.h.

sv_frame_t FFTModel::getTrueEndFrame ( ) const
inlineoverridevirtual

Return the audio frame at the end of the model.

This is identical to getEndFrame(), except that it ignores any extended duration set with extendEndFrame().

Implements Model.

Definition at line 75 of file FFTModel.h.

References getResolution(), and getWidth().

sv_samplerate_t FFTModel::getSampleRate ( ) const
inlineoverridevirtual

Return the frame rate in frames per second.

Implements Model.

Definition at line 78 of file FFTModel.h.

References m_sampleRate.

Referenced by estimateStableFrequency(), getPeakFrequencies(), and getPeaks().

int FFTModel::getResolution ( ) const
inlineoverridevirtual

Return the number of sample frames covered by each column of bins.

Implements DenseThreeDimensionalModel.

Definition at line 81 of file FFTModel.h.

References m_windowIncrement.

Referenced by estimateStableFrequency(), getPeakFrequencies(), and getTrueEndFrame().

float FFTModel::getMinimumLevel ( ) const
inlineoverridevirtual

Return the minimum permissible value in each bin.

Implements DenseThreeDimensionalModel.

Definition at line 85 of file FFTModel.h.

float FFTModel::getMaximumLevel ( ) const
inlineoverridevirtual

Return the maximum permissible value in each bin.

Implements DenseThreeDimensionalModel.

Definition at line 86 of file FFTModel.h.

References getColumn().

FFTModel::Column FFTModel::getColumn ( int  column) const
overridevirtual

Get data from the given column of bin values.

Implements DenseThreeDimensionalModel.

Definition at line 160 of file FFTModel.cpp.

References getFFTColumn().

Referenced by getMaximumLevel(), getMaximumMagnitudeAt(), and getPeaks().

bool FFTModel::hasBinValues ( ) const
inlineoverridevirtual

Return true if the bins have values as well as names.

If this returns true, getBinValue() may be used to retrieve the values.

Reimplemented from DenseThreeDimensionalModel.

Definition at line 90 of file FFTModel.h.

QString FFTModel::getBinValueUnit ( ) const
inlineoverridevirtual

Obtain the name of the unit of the values returned from getBinValue(), if any.

Reimplemented from DenseThreeDimensionalModel.

Definition at line 93 of file FFTModel.h.

bool FFTModel::shouldUseLogValueScale ( ) const
inlineoverridevirtual

Estimate whether a logarithmic scale might be appropriate for the value scale.

Implements DenseThreeDimensionalModel.

Definition at line 96 of file FFTModel.h.

References getBinName(), and getBinValue().

float FFTModel::getBinValue ( int  n) const
overridevirtual

Return the value of bin n, if any.

This is a "vertical scale" value which does not vary from one column to the next. This is only meaningful if hasBinValues() returns true.

Reimplemented from DenseThreeDimensionalModel.

Definition at line 154 of file FFTModel.cpp.

References m_fftSize, and m_sampleRate.

Referenced by getBinName(), and shouldUseLogValueScale().

QString FFTModel::getBinName ( int  n) const
overridevirtual

Get the name of a given bin (i.e.

a label to associate with that bin across all columns).

Implements DenseThreeDimensionalModel.

Definition at line 148 of file FFTModel.cpp.

References getBinValue().

Referenced by shouldUseLogValueScale().

QVector<QString> FFTModel::getStringExportHeaders ( DataExportOptions  options) const
inlineoverridevirtual

Return a label for each column that would be written by toStringExportRows.

Implements Model.

Definition at line 103 of file FFTModel.h.

QVector<QVector<QString> > FFTModel::toStringExportRows ( DataExportOptions  options,
sv_frame_t  startFrame,
sv_frame_t  duration 
) const
inlineoverridevirtual

Emit events starting within the given range as string rows ready for conversion to an e.g.

comma-separated data format.

Implements Model.

Definition at line 108 of file FFTModel.h.

QString FFTModel::getError ( ) const
inline

Definition at line 114 of file FFTModel.h.

References m_error.

Referenced by FeatureExtractionModelTransformer::run().

int FFTModel::getChannel ( ) const
inline

Definition at line 116 of file FFTModel.h.

References m_channel.

WindowType FFTModel::getWindowType ( ) const
inline

Definition at line 117 of file FFTModel.h.

References m_windowType.

int FFTModel::getWindowSize ( ) const
inline

Definition at line 118 of file FFTModel.h.

References m_windowSize.

int FFTModel::getWindowIncrement ( ) const
inline

Definition at line 119 of file FFTModel.h.

References m_windowIncrement.

int FFTModel::getFFTSize ( ) const
inline

Definition at line 120 of file FFTModel.h.

References m_fftSize, and setMaximumFrequency().

void FFTModel::setMaximumFrequency ( double  freq)

Definition at line 119 of file FFTModel.cpp.

References clearCaches(), and m_maximumFrequency.

Referenced by getFFTSize().

double FFTModel::getMaximumFrequency ( ) const
inline
float FFTModel::getMagnitudeAt ( int  x,
int  y 
) const

!! review which of these are ever actually called

Definition at line 182 of file FFTModel.cpp.

References getFFTColumn(), getHeight(), and getWidth().

Referenced by getMaximumFrequency(), and getValueAt().

float FFTModel::getMaximumMagnitudeAt ( int  x) const

Definition at line 192 of file FFTModel.cpp.

References getColumn().

Referenced by getMaximumFrequency().

FFTModel::Column FFTModel::getPhases ( int  x) const

Definition at line 170 of file FFTModel.cpp.

References getFFTColumn().

Referenced by getMaximumFrequency().

float FFTModel::getPhaseAt ( int  x,
int  y 
) const
void FFTModel::getValuesAt ( int  x,
int  y,
float &  real,
float &  imaginary 
) const

Definition at line 211 of file FFTModel.cpp.

References getFFTColumn(), getHeight(), and getWidth().

Referenced by getMaximumFrequency().

bool FFTModel::getMagnitudesAt ( int  x,
float *  values,
int  minbin = 0,
int  count = 0 
) const

Definition at line 224 of file FFTModel.cpp.

References getFFTColumn(), and getHeight().

Referenced by getMaximumFrequency(), and getPeaks().

bool FFTModel::getPhasesAt ( int  x,
float *  values,
int  minbin = 0,
int  count = 0 
) const

Definition at line 237 of file FFTModel.cpp.

References getFFTColumn(), and getHeight().

Referenced by getMaximumFrequency().

bool FFTModel::getValuesAt ( int  x,
float *  reals,
float *  imaginaries,
int  minbin = 0,
int  count = 0 
) const

Definition at line 248 of file FFTModel.cpp.

References getFFTColumn(), and getHeight().

bool FFTModel::estimateStableFrequency ( int  x,
int  y,
double &  frequency 
)
virtual

Calculate an estimated frequency for a stable signal in this bin, using phase unwrapping.

This will be completely wrong if the signal is not stable here.

Definition at line 424 of file FFTModel.cpp.

References getPhaseAt(), getResolution(), getSampleRate(), getWidth(), isOK(), m_fftSize, M_PI, and princarg().

Referenced by getMaximumFrequency().

FFTModel::PeakLocationSet FFTModel::getPeaks ( PeakPickType  type,
int  x,
int  ymin = 0,
int  ymax = 0 
) const
virtual
FFTModel::PeakSet FFTModel::getPeakFrequencies ( PeakPickType  type,
int  x,
int  ymin = 0,
int  ymax = 0 
) const
virtual

Return locations and estimated stable frequencies of peak bins.

Definition at line 625 of file FFTModel.cpp.

References getPeaks(), getPhaseAt(), getResolution(), getSampleRate(), isOK(), m_fftSize, M_PI, and princarg().

QString FFTModel::getTypeName ( ) const
inlineoverridevirtual

Return the type of the model.

For display purposes only.

Reimplemented from DenseThreeDimensionalModel.

Definition at line 166 of file FFTModel.h.

References FFTModel(), and operator=().

FFTModel& FFTModel::operator= ( const FFTModel )
privatedelete

Referenced by getTypeName().

int FFTModel::getPeakPickWindowSize ( PeakPickType  type,
sv_samplerate_t  sampleRate,
int  bin,
double &  dist 
) const
private

Definition at line 581 of file FFTModel.cpp.

References Pitch::getFrequencyForPitch(), m_fftSize, and MajorPeaks.

Referenced by getPeaks().

std::pair<sv_frame_t, sv_frame_t> FFTModel::getSourceSampleRange ( int  column) const
inlineprivate
floatvec_t FFTModel::getSourceSamples ( int  column) const
private

Definition at line 262 of file FFTModel.cpp.

References getSourceData(), getSourceSampleRange(), m_fftSize, and m_windowSize.

Referenced by getFFTColumn(), and getSourceSampleRange().

floatvec_t FFTModel::getSourceDataUncached ( std::pair< sv_frame_t, sv_frame_t ) const
private

Definition at line 334 of file FFTModel.cpp.

References m_channel, and m_model.

Referenced by getSourceData(), and getSourceSampleRange().

void FFTModel::clearCaches ( )
private
bool DenseThreeDimensionalModel::isLocalPeak ( int  x,
int  y 
)
inlineinherited

Utility function to query whether a given bin is greater than its (vertical) neighbours.

Definition at line 106 of file DenseThreeDimensionalModel.h.

References DenseThreeDimensionalModel::getHeight(), and DenseThreeDimensionalModel::getValueAt().

bool DenseThreeDimensionalModel::isOverThreshold ( int  x,
int  y,
float  threshold 
)
inlineinherited

Utility function to query whether a given bin is greater than a certain threshold.

Definition at line 117 of file DenseThreeDimensionalModel.h.

References DenseThreeDimensionalModel::getValueAt().

int DenseThreeDimensionalModel::getRowCount ( ) const
inlineoverridevirtualinherited

Return the number of rows (items) in the model.

Implements TabularModel.

Definition at line 132 of file DenseThreeDimensionalModel.h.

References DenseThreeDimensionalModel::getWidth().

int DenseThreeDimensionalModel::getColumnCount ( ) const
inlineoverridevirtualinherited

Return the number of columns (values/labels/etc per item).

Implements TabularModel.

Definition at line 133 of file DenseThreeDimensionalModel.h.

References DenseThreeDimensionalModel::getHeight().

bool DenseThreeDimensionalModel::isEditable ( ) const
inlineoverridevirtualinherited

Return true if the model is user-editable, false otherwise.

Implements TabularModel.

Definition at line 135 of file DenseThreeDimensionalModel.h.

Command* DenseThreeDimensionalModel::getSetDataCommand ( int  row,
int  column,
const QVariant &  ,
int  role 
)
inlineoverridevirtualinherited

Return a command to set the value in the given cell, for the given role, to the contents of the supplied variant.

If the model is not editable or the cell or value is out of range, return nullptr.

Implements TabularModel.

Definition at line 136 of file DenseThreeDimensionalModel.h.

Command* DenseThreeDimensionalModel::getInsertRowCommand ( int  beforeRow)
inlineoverridevirtualinherited

Return a command to insert a new row before the row with the given index.

If the model is not editable or the index is out of range, return nullptr.

Implements TabularModel.

Definition at line 137 of file DenseThreeDimensionalModel.h.

Command* DenseThreeDimensionalModel::getRemoveRowCommand ( int  row)
inlineoverridevirtualinherited

Return a command to delete the row with the given index.

If the model is not editable or the index is out of range, return nullptr.

Implements TabularModel.

Definition at line 138 of file DenseThreeDimensionalModel.h.

QString DenseThreeDimensionalModel::getHeading ( int  column) const
inlineoverridevirtualinherited

Return the heading for a given column, e.g.

"Time" or "Value". These are shown directly to the user, so must be translated already.

Implements TabularModel.

Definition at line 140 of file DenseThreeDimensionalModel.h.

References DenseThreeDimensionalModel::getBinName().

QVariant DenseThreeDimensionalModel::getData ( int  row,
int  column,
int  role 
) const
inlineoverridevirtualinherited

Get the value in the given cell, for the given role.

The role is actually a Qt::ItemDataRole.

Implements TabularModel.

Definition at line 154 of file DenseThreeDimensionalModel.h.

References RealTime::frame2RealTime(), DenseThreeDimensionalModel::getResolution(), Model::getSampleRate(), Model::getStartFrame(), DenseThreeDimensionalModel::getValueAt(), and RealTime::toText().

bool DenseThreeDimensionalModel::isColumnTimeValue ( int  col) const
inlineoverridevirtualinherited

Return true if the column is the frame time of the item, or an alternative representation of it (i.e.

anything that has the same sort order). Duration is not a time value by this meaning.

Implements TabularModel.

Definition at line 169 of file DenseThreeDimensionalModel.h.

SortType DenseThreeDimensionalModel::getSortType ( int  col) const
inlineoverridevirtualinherited

Return the sort type (numeric or alphabetical) for the column.

Implements TabularModel.

Definition at line 172 of file DenseThreeDimensionalModel.h.

References TabularModel::SortNumeric.

sv_frame_t DenseThreeDimensionalModel::getFrameForRow ( int  row) const
inlineoverridevirtualinherited

Return the frame time for the given row.

Implements TabularModel.

Definition at line 176 of file DenseThreeDimensionalModel.h.

References DenseThreeDimensionalModel::getResolution(), and Model::getStartFrame().

int DenseThreeDimensionalModel::getRowForFrame ( sv_frame_t  frame) const
inlineoverridevirtualinherited

Return the number of the first row whose frame time is not less than the given one.

If there is none, return getRowCount().

Implements TabularModel.

Definition at line 179 of file DenseThreeDimensionalModel.h.

References DenseThreeDimensionalModel::getResolution(), and Model::getStartFrame().

sv_frame_t Model::getEndFrame ( ) const
inlineinherited

Return the audio frame at the end of the model, i.e.

the final frame contained within the model plus 1 (rounded up to the model's "resolution" granularity, if more than 1). The end frame minus the start frame should yield the total duration in frames (as a multiple of the resolution) spanned by the model. This is broadly consistent with the definition of the end frame of a Selection object.

If the end has been extended by extendEndFrame() beyond the true end frame, return the extended end instead. This is usually the behaviour you want.

Definition at line 87 of file Model.h.

References Model::getTrueEndFrame(), and Model::m_extendTo.

Referenced by Model::alignFromReference(), ReadOnlyWaveFileModel::cacheFilled(), WaveformOversampler::getFixedRatioData(), SparseOneDimensionalModel::getNotes(), NoteModel::getNotes(), ReadOnlyWaveFileModel::isReady(), Model::toXml(), CSVFileWriter::write(), CSVStreamWriter::writeInChunks(), and WavFileWriter::writeModel().

void Model::extendEndFrame ( sv_frame_t  to)
inlineinherited

Extend the end of the model.

If this is set to something beyond the true end of the data within the model, then getEndFrame() will return this value instead of the true end. (This is used by the Tony application.)

Definition at line 109 of file Model.h.

References Model::getSampleRate(), and Model::m_extendTo.

virtual sv_samplerate_t Model::getNativeRate ( ) const
inlinevirtualinherited

Return the frame rate of the underlying material, if the model itself has already been resampled.

Reimplemented in WritableWaveFileModel, ReadOnlyWaveFileModel, and WaveFileModel.

Definition at line 122 of file Model.h.

References Model::getLocation(), Model::getMaker(), Model::getSampleRate(), Model::getTitle(), and Model::getTypeName().

QString Model::getTitle ( ) const
virtualinherited

Return the "work title" of the model, if known.

Reimplemented in WritableWaveFileModel, ReadOnlyWaveFileModel, and WaveFileModel.

Definition at line 177 of file Model.cpp.

References TypedById< Item, Id >::get(), Model::m_mutex, and Model::m_sourceModel.

Referenced by Model::getNativeRate().

QString Model::getMaker ( ) const
virtualinherited

Return the "artist" or "maker" of the model, if known.

Reimplemented in WritableWaveFileModel, ReadOnlyWaveFileModel, and WaveFileModel.

Definition at line 186 of file Model.cpp.

References TypedById< Item, Id >::get(), Model::m_mutex, and Model::m_sourceModel.

Referenced by Model::getNativeRate().

QString Model::getLocation ( ) const
virtualinherited

Return the location of the data in this model (e.g.

source URL). This should not normally be returned for editable models that have been edited.

Reimplemented in WritableWaveFileModel, ReadOnlyWaveFileModel, and WaveFileModel.

Definition at line 195 of file Model.cpp.

References TypedById< Item, Id >::get(), Model::m_mutex, and Model::m_sourceModel.

Referenced by Model::getNativeRate().

virtual bool Model::isSparse ( ) const
inlinevirtualinherited

Return true if this is a sparse model.

Reimplemented in NoteModel, SparseTimeValueModel, BoxModel, RegionModel, SparseOneDimensionalModel, ImageModel, and TextModel.

Definition at line 149 of file Model.h.

Referenced by CSVFileWriter::writeSelection().

virtual bool Model::isReady ( int *  cp = nullptr) const
inlinevirtualinherited

Return true if the model has finished loading or calculating all its data, for a model that is capable of calculating in a background thread.

If "completion" is non-NULL, return through it an estimated percentage value showing how far through the background operation it thinks it is (for progress reporting). This should be identical to the value returned by getCompletion().

A model that carries out all its calculation from the constructor or accessor functions would typically return true (and completion == 100) as long as isOK() is true. Other models may make the return value here depend on the internal completion status.

See also getCompletion().

Reimplemented in ReadOnlyWaveFileModel, AlignmentModel, BasicCompressedDenseThreeDimensionalModel, AggregateWaveModel, and EditableDenseThreeDimensionalModel.

Definition at line 169 of file Model.h.

References Model::getCompletion(), and Model::isOK().

virtual const ZoomConstraint* Model::getZoomConstraint ( ) const
inlinevirtualinherited

If this model imposes a zoom constraint, i.e.

some limit to the set of resolutions at which its data can meaningfully be displayed, then return it.

Reimplemented in WritableWaveFileModel, ReadOnlyWaveFileModel, AggregateWaveModel, and AlignmentModel.

Definition at line 196 of file Model.h.

virtual ModelId Model::getSourceModel ( ) const
inlinevirtualinherited

If this model was derived from another, return the id of the model it was derived from.

The assumption is that the source model's alignment will also apply to this model, unless some other property (such as a specific alignment model set on this model) indicates otherwise.

Definition at line 207 of file Model.h.

References Model::alignFromReference(), Model::alignToReference(), Model::getAlignment(), Model::getAlignmentCompletion(), Model::getAlignmentReference(), Model::m_sourceModel, Model::setAlignment(), and Model::setSourceModel().

void Model::setSourceModel ( ModelId  model)
virtualinherited

Set the source model for this model.

Definition at line 31 of file Model.cpp.

References Model::alignmentCompletionChanged(), TypedById< Item, Id >::get(), Model::m_mutex, and Model::m_sourceModel.

Referenced by RDFImporterImpl::getDataModelsSparse(), and Model::getSourceModel().

void Model::setAlignment ( ModelId  alignmentModel)
virtualinherited

Specify an alignment between this model's timeline and that of a reference model.

The alignment model, of type AlignmentModel, records both the reference and the alignment.

Definition at line 45 of file Model.cpp.

References Model::alignmentModelCompletionChanged(), Model::completionChanged(), TypedById< Item, Id >::get(), Model::m_alignmentModel, Model::m_mutex, and SVDEBUG.

Referenced by Model::getSourceModel().

const ModelId Model::getAlignment ( ) const
virtualinherited

Retrieve the alignment model for this model.

This is not a generally useful function, as the alignment you really want may be performed by the source model instead. You should normally use getAlignmentReference, alignToReference and alignFromReference instead of this. The main intended application for this function is in streaming out alignments to the session file.

Definition at line 72 of file Model.cpp.

References Model::m_alignmentModel, and Model::m_mutex.

Referenced by Model::getSourceModel().

const ModelId Model::getAlignmentReference ( ) const
virtualinherited

Return the reference model for the current alignment timeline, if any.

Definition at line 79 of file Model.cpp.

References Model::m_alignmentModel, and Model::m_mutex.

Referenced by Model::getSourceModel().

sv_frame_t Model::alignToReference ( sv_frame_t  frame) const
virtualinherited

Return the frame number of the reference model that corresponds to the given frame number in this model.

Definition at line 88 of file Model.cpp.

References TypedById< Item, Id >::get(), Model::m_alignmentModel, Model::m_mutex, and Model::m_sourceModel.

Referenced by Model::getSourceModel().

sv_frame_t Model::alignFromReference ( sv_frame_t  referenceFrame) const
virtualinherited

Return the frame number in this model that corresponds to the given frame number of the reference model.

Definition at line 116 of file Model.cpp.

References TypedById< Item, Id >::get(), Model::getEndFrame(), Model::m_alignmentModel, Model::m_mutex, and Model::m_sourceModel.

Referenced by Model::getSourceModel().

int Model::getAlignmentCompletion ( ) const
virtualinherited

Return the completion percentage for the alignment model: 100 if there is no alignment model or it has been entirely calculated, or less than 100 if it is still being calculated.

Definition at line 141 of file Model.cpp.

References TypedById< Item, Id >::get(), Model::m_alignmentModel, Model::m_mutex, Model::m_sourceModel, and SVCERR.

Referenced by Model::getSourceModel().

void Model::setRDFTypeURI ( QString  uri)
inlineinherited

Set the event, feature, or signal type URI for the features contained in this model, according to the Audio Features RDF ontology.

Definition at line 264 of file Model.h.

References Model::m_typeUri.

Referenced by FeatureExtractionModelTransformer::getAdditionalModel(), and RDFImporterImpl::getDataModelsSparse().

QString Model::getRDFTypeURI ( ) const
inlineinherited

Retrieve the event, feature, or signal type URI for the features contained in this model, if previously set with setRDFTypeURI.

Definition at line 271 of file Model.h.

References Model::alignmentCompletionChanged(), Model::alignmentModelCompletionChanged(), Model::completionChanged(), Model::getStringExportHeaders(), Model::m_typeUri, Model::modelChanged(), Model::modelChangedWithin(), Model::ready(), Model::toStringExportRows(), and Model::toXml().

void Model::completionChanged ( ModelId  myId)
signalinherited
void Model::ready ( ModelId  myId)
signalinherited

Emitted when internal processing is complete (i.e.

when isReady() would return true, with completion at 100).

Referenced by ReadOnlyWaveFileModel::cacheFilled(), Model::getRDFTypeURI(), AggregateWaveModel::isReady(), and ReadOnlyWaveFileModel::isReady().

void Model::alignmentCompletionChanged ( ModelId  myId)
signalinherited

Emitted when the completion percentage changes for the calculation of this model's alignment model.

(The ModelId provided is that of this model, not the alignment model.)

Referenced by Model::alignmentModelCompletionChanged(), Model::getRDFTypeURI(), and Model::setSourceModel().

Id WithTypedId< Model >::getId ( ) const
inlineprotectedinherited

Return an id for this object.

The id is a unique value for this object among all objects that implement WithId within this single run of the application.

Definition at line 193 of file ById.h.

References TypedId< T >::untyped.

Referenced by BoxModel::add(), RegionModel::add(), SparseTimeValueModel::add(), NoteModel::add(), Model::alignmentModelCompletionChanged(), ReadOnlyWaveFileModel::cacheFilled(), AggregateWaveModel::componentModelChanged(), WritableWaveFileModel::componentModelChanged(), AggregateWaveModel::componentModelChangedWithin(), WritableWaveFileModel::componentModelChangedWithin(), AggregateWaveModel::componentModelCompletionChanged(), ReadOnlyWaveFileModel::fillTimerTimedOut(), ImageModel::getInsertRowCommand(), TextModel::getInsertRowCommand(), SparseOneDimensionalModel::getInsertRowCommand(), RegionModel::getInsertRowCommand(), BoxModel::getInsertRowCommand(), SparseTimeValueModel::getInsertRowCommand(), NoteModel::getInsertRowCommand(), ImageModel::getRemoveRowCommand(), TextModel::getRemoveRowCommand(), SparseOneDimensionalModel::getRemoveRowCommand(), RegionModel::getRemoveRowCommand(), BoxModel::getRemoveRowCommand(), SparseTimeValueModel::getRemoveRowCommand(), NoteModel::getRemoveRowCommand(), ImageModel::getSetDataCommand(), TextModel::getSetDataCommand(), SparseOneDimensionalModel::getSetDataCommand(), RegionModel::getSetDataCommand(), BoxModel::getSetDataCommand(), SparseTimeValueModel::getSetDataCommand(), NoteModel::getSetDataCommand(), WritableWaveFileModel::init(), NoteModel::NoteModel(), AlignmentModel::pathSourceCompletionChanged(), ReadOnlyWaveFileModel::ReadOnlyWaveFileModel(), ImageModel::remove(), TextModel::remove(), SparseOneDimensionalModel::remove(), BoxModel::remove(), RegionModel::remove(), SparseTimeValueModel::remove(), NoteModel::remove(), EditableDenseThreeDimensionalModel::setBinName(), BasicCompressedDenseThreeDimensionalModel::setBinName(), EditableDenseThreeDimensionalModel::setBinNames(), BasicCompressedDenseThreeDimensionalModel::setBinNames(), EditableDenseThreeDimensionalModel::setColumn(), BasicCompressedDenseThreeDimensionalModel::setColumn(), EditableDenseThreeDimensionalModel::setCompletion(), BasicCompressedDenseThreeDimensionalModel::setCompletion(), AlignmentModel::setCompletion(), TextModel::setCompletion(), ImageModel::setCompletion(), SparseOneDimensionalModel::setCompletion(), BoxModel::setCompletion(), RegionModel::setCompletion(), SparseTimeValueModel::setCompletion(), NoteModel::setCompletion(), SparseOneDimensionalModel::SparseOneDimensionalModel(), SparseTimeValueModel::SparseTimeValueModel(), WritableWaveFileModel::writeComplete(), Model::~Model(), NoteModel::~NoteModel(), ReadOnlyWaveFileModel::~ReadOnlyWaveFileModel(), SparseOneDimensionalModel::~SparseOneDimensionalModel(), SparseTimeValueModel::~SparseTimeValueModel(), and WritableWaveFileModel::~WritableWaveFileModel().

int WithId::getUntypedId ( ) const
inlineprotectedinherited

Return an id for this object.

The id is a unique number for this object among all objects that implement WithId within this single run of the application.

Definition at line 168 of file ById.h.

int XmlExportable::getExportId ( ) const
inherited

Return the numerical export identifier for this object.

It's allocated the first time this is called, so objects on which this is never called do not get allocated one.

Definition at line 71 of file XmlExportable.cpp.

References XmlExportable::m_exportId, and mutex.

Referenced by EditableDenseThreeDimensionalModel::toXml(), BasicCompressedDenseThreeDimensionalModel::toXml(), EventSeries::toXml(), ImageModel::toXml(), TextModel::toXml(), Model::toXml(), SparseOneDimensionalModel::toXml(), RegionModel::toXml(), BoxModel::toXml(), SparseTimeValueModel::toXml(), NoteModel::toXml(), and XmlExportable::~XmlExportable().

QString XmlExportable::toXmlString ( QString  indent = "",
QString  extraAttributes = "" 
) const
virtualinherited

Convert this exportable object to XML in a string.

The default implementation calls toXml and returns the result as a string. Do not override this unless you really know what you're doing.

Definition at line 25 of file XmlExportable.cpp.

References XmlExportable::toXml().

Referenced by ModelTransformerFactory::getConfigurationForTransform(), RDFTransformFactoryImpl::getTransforms(), and XmlExportable::~XmlExportable().

QString XmlExportable::encodeColour ( int  r,
int  g,
int  b 
)
staticinherited

Definition at line 54 of file XmlExportable.cpp.

Referenced by XmlExportable::~XmlExportable().

virtual bool Playable::canPlay ( ) const
inlinevirtualinherited

Reimplemented in NoteModel, SparseTimeValueModel, SparseOneDimensionalModel, and DenseTimeValueModel.

Definition at line 26 of file Playable.h.

virtual QString Playable::getDefaultPlayClipId ( ) const
inlinevirtualinherited

Reimplemented in NoteModel, SparseOneDimensionalModel, and DenseTimeValueModel.

Definition at line 27 of file Playable.h.

Referenced by PlayParameterRepository::addPlayable().

virtual bool Playable::getDefaultPlayAudible ( ) const
inlinevirtualinherited

Reimplemented in SparseTimeValueModel.

Definition at line 28 of file Playable.h.

Referenced by PlayParameterRepository::addPlayable().

static QVariant TabularModel::adaptFrameForRole ( sv_frame_t  frame,
sv_samplerate_t  rate,
int  role 
)
inlinestaticprotectedinherited
static QVariant TabularModel::adaptValueForRole ( float  value,
QString  unit,
int  role 
)
inlinestaticprotectedinherited

Member Data Documentation

const ModelId FFTModel::m_model
private

Definition at line 172 of file FFTModel.h.

Referenced by FFTModel(), getCompletion(), getSourceDataUncached(), getWidth(), and isOK().

sv_samplerate_t FFTModel::m_sampleRate
private

Definition at line 173 of file FFTModel.h.

Referenced by FFTModel(), getBinValue(), getHeight(), and getSampleRate().

int FFTModel::m_channel
private

Definition at line 174 of file FFTModel.h.

Referenced by getChannel(), and getSourceDataUncached().

WindowType FFTModel::m_windowType
private

Definition at line 175 of file FFTModel.h.

Referenced by getWindowType().

int FFTModel::m_windowSize
private
int FFTModel::m_windowIncrement
private

Definition at line 177 of file FFTModel.h.

Referenced by getResolution(), getWidth(), and getWindowIncrement().

Window<float> FFTModel::m_windower
private

Definition at line 179 of file FFTModel.h.

Referenced by getFFTColumn().

breakfastquay::FFT FFTModel::m_fft
mutableprivate

Definition at line 180 of file FFTModel.h.

Referenced by FFTModel(), and getFFTColumn().

double FFTModel::m_maximumFrequency
private

Definition at line 181 of file FFTModel.h.

Referenced by getHeight(), getMaximumFrequency(), and setMaximumFrequency().

QString FFTModel::m_error
mutableprivate

Definition at line 182 of file FFTModel.h.

Referenced by FFTModel(), getError(), and isOK().

SavedSourceData FFTModel::m_savedData
mutableprivate

Definition at line 205 of file FFTModel.h.

Referenced by clearCaches(), and getSourceData().

std::vector<SavedColumn> FFTModel::m_cached
mutableprivate

Definition at line 211 of file FFTModel.h.

Referenced by clearCaches(), and getFFTColumn().

size_t FFTModel::m_cacheWriteIndex
mutableprivate

Definition at line 212 of file FFTModel.h.

Referenced by clearCaches(), and getFFTColumn().

size_t FFTModel::m_cacheSize
private

Definition at line 213 of file FFTModel.h.

Referenced by clearCaches(), and getFFTColumn().

QString Model::m_typeUri
protectedinherited

Definition at line 340 of file Model.h.

Referenced by Model::getRDFTypeURI(), and Model::setRDFTypeURI().

std::atomic<sv_frame_t> Model::m_extendTo
protectedinherited

Definition at line 341 of file Model.h.

Referenced by Model::extendEndFrame(), and Model::getEndFrame().


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