annotate data/model/WaveformOversampler.h @ 1660:b234d4d011df single-point

We do need haveTextLabels; restore it
author Chris Cannam
date Thu, 21 Mar 2019 13:33:30 +0000
parents eb10ed56d5a4
children 074b860a7828
rev   line source
Chris@1536 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@1536 2
Chris@1536 3 /*
Chris@1536 4 Sonic Visualiser
Chris@1536 5 An audio file viewer and annotation editor.
Chris@1536 6 Centre for Digital Music, Queen Mary, University of London.
Chris@1536 7
Chris@1536 8 This program is free software; you can redistribute it and/or
Chris@1536 9 modify it under the terms of the GNU General Public License as
Chris@1536 10 published by the Free Software Foundation; either version 2 of the
Chris@1536 11 License, or (at your option) any later version. See the file
Chris@1536 12 COPYING included with this distribution for more information.
Chris@1536 13 */
Chris@1536 14
Chris@1536 15 #ifndef SV_WAVEFORM_OVERSAMPLER_H
Chris@1536 16 #define SV_WAVEFORM_OVERSAMPLER_H
Chris@1536 17
Chris@1536 18 #include "base/BaseTypes.h"
Chris@1536 19
Chris@1536 20 class DenseTimeValueModel;
Chris@1536 21
Chris@1536 22 /** Oversample the sample data from a DenseTimeValueModel by an
Chris@1536 23 * integer factor, on the assumption that the model represents
Chris@1536 24 * audio. Oversampling is carried out using a windowed sinc filter
Chris@1536 25 * for a fixed 8x ratio with further linear interpolation to handle
Chris@1536 26 * other ratios. The aim is not to provide the "best-sounding"
Chris@1536 27 * interpolation, but to provide accurate and predictable projections
Chris@1536 28 * of the theoretical waveform shape for display rendering without
Chris@1536 29 * leaving decisions about interpolation up to a resampler library.
Chris@1536 30 */
Chris@1536 31 class WaveformOversampler
Chris@1536 32 {
Chris@1536 33 public:
Chris@1536 34 /** Return an oversampled version of the audio data from the given
Chris@1536 35 * source sample range. Will query sufficient source audio before
Chris@1536 36 * and after the requested range (where available) to ensure an
Chris@1536 37 * accurate-looking result after filtering. The returned vector
Chris@1536 38 * will have sourceFrameCount * oversampleBy samples, except when
Chris@1536 39 * truncated because the end of the model was reached.
Chris@1536 40 */
Chris@1536 41 static floatvec_t getOversampledData(const DenseTimeValueModel *source,
Chris@1536 42 int channel,
Chris@1536 43 sv_frame_t sourceStartFrame,
Chris@1536 44 sv_frame_t sourceFrameCount,
Chris@1536 45 int oversampleBy);
Chris@1536 46
Chris@1536 47 private:
Chris@1536 48 static floatvec_t getFixedRatioData(const DenseTimeValueModel *source,
Chris@1536 49 int channel,
Chris@1536 50 sv_frame_t sourceStartFrame,
Chris@1536 51 sv_frame_t sourceFrameCount);
Chris@1536 52
Chris@1536 53 static int m_filterRatio;
Chris@1536 54 static floatvec_t m_filter;
Chris@1536 55 };
Chris@1536 56
Chris@1536 57 #endif