comparison data/model/WaveformOversampler.h @ 1536:eb10ed56d5a4 zoom

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