Chris@1536: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@1536: Chris@1536: /* Chris@1536: Sonic Visualiser Chris@1536: An audio file viewer and annotation editor. Chris@1536: Centre for Digital Music, Queen Mary, University of London. Chris@1536: Chris@1536: This program is free software; you can redistribute it and/or Chris@1536: modify it under the terms of the GNU General Public License as Chris@1536: published by the Free Software Foundation; either version 2 of the Chris@1536: License, or (at your option) any later version. See the file Chris@1536: COPYING included with this distribution for more information. Chris@1536: */ Chris@1536: Chris@1536: #ifndef SV_WAVEFORM_OVERSAMPLER_H Chris@1536: #define SV_WAVEFORM_OVERSAMPLER_H Chris@1536: Chris@1536: #include "base/BaseTypes.h" Chris@1536: Chris@1536: class DenseTimeValueModel; Chris@1536: Chris@1536: /** Oversample the sample data from a DenseTimeValueModel by an Chris@1536: * integer factor, on the assumption that the model represents Chris@1536: * audio. Oversampling is carried out using a windowed sinc filter Chris@1536: * for a fixed 8x ratio with further linear interpolation to handle Chris@1536: * other ratios. The aim is not to provide the "best-sounding" Chris@1536: * interpolation, but to provide accurate and predictable projections Chris@1536: * of the theoretical waveform shape for display rendering without Chris@1536: * leaving decisions about interpolation up to a resampler library. Chris@1536: */ Chris@1536: class WaveformOversampler Chris@1536: { Chris@1536: public: Chris@1536: /** Return an oversampled version of the audio data from the given Chris@1536: * source sample range. Will query sufficient source audio before Chris@1536: * and after the requested range (where available) to ensure an Chris@1536: * accurate-looking result after filtering. The returned vector Chris@1536: * will have sourceFrameCount * oversampleBy samples, except when Chris@1536: * truncated because the end of the model was reached. Chris@1536: */ Chris@1745: static floatvec_t getOversampledData(const DenseTimeValueModel &source, Chris@1536: int channel, Chris@1536: sv_frame_t sourceStartFrame, Chris@1536: sv_frame_t sourceFrameCount, Chris@1536: int oversampleBy); Chris@1536: Chris@1536: private: Chris@1745: static floatvec_t getFixedRatioData(const DenseTimeValueModel &source, Chris@1536: int channel, Chris@1536: sv_frame_t sourceStartFrame, Chris@1536: sv_frame_t sourceFrameCount); Chris@1536: Chris@1536: static int m_filterRatio; Chris@1536: static floatvec_t m_filter; Chris@1536: }; Chris@1536: Chris@1536: #endif