comparison data/model/WritableWaveFileModel.cpp @ 1096:4d9816ba0ebe simple-fft-model

Rework audio file reader API to prefer using std containers
author Chris Cannam
date Mon, 15 Jun 2015 12:19:47 +0100
parents 9f4505ac9072
children efea94b04d5a
comparison
equal deleted inserted replaced
1095:b66734b5f806 1096:4d9816ba0ebe
26 26
27 #include <cassert> 27 #include <cassert>
28 #include <iostream> 28 #include <iostream>
29 #include <stdint.h> 29 #include <stdint.h>
30 30
31 using namespace std;
32
31 //#define DEBUG_WRITABLE_WAVE_FILE_MODEL 1 33 //#define DEBUG_WRITABLE_WAVE_FILE_MODEL 1
32 34
33 WritableWaveFileModel::WritableWaveFileModel(sv_samplerate_t sampleRate, 35 WritableWaveFileModel::WritableWaveFileModel(sv_samplerate_t sampleRate,
34 int channels, 36 int channels,
35 QString path) : 37 QString path) :
167 { 169 {
168 // SVDEBUG << "WritableWaveFileModel::getFrameCount: count = " << m_frameCount << endl; 170 // SVDEBUG << "WritableWaveFileModel::getFrameCount: count = " << m_frameCount << endl;
169 return m_frameCount; 171 return m_frameCount;
170 } 172 }
171 173
172 sv_frame_t 174 vector<float>
173 WritableWaveFileModel::getData(int channel, sv_frame_t start, sv_frame_t count, 175 WritableWaveFileModel::getData(int channel, sv_frame_t start, sv_frame_t count) const
174 float *buffer) const 176 {
175 { 177 if (!m_model || m_model->getChannelCount() == 0) return {};
176 if (!m_model || m_model->getChannelCount() == 0) return 0; 178 return m_model->getData(channel, start, count);
177 return m_model->getData(channel, start, count, buffer); 179 }
178 } 180
179 181 vector<vector<float>>
180 sv_frame_t
181 WritableWaveFileModel::getMultiChannelData(int fromchannel, int tochannel, 182 WritableWaveFileModel::getMultiChannelData(int fromchannel, int tochannel,
182 sv_frame_t start, sv_frame_t count, 183 sv_frame_t start, sv_frame_t count) const
183 float **buffers) const 184 {
184 { 185 if (!m_model || m_model->getChannelCount() == 0) return {};
185 if (!m_model || m_model->getChannelCount() == 0) return 0; 186 return m_model->getMultiChannelData(fromchannel, tochannel, start, count);
186 return m_model->getMultiChannelData(fromchannel, tochannel, start, count, buffers);
187 } 187 }
188 188
189 int 189 int
190 WritableWaveFileModel::getSummaryBlockSize(int desired) const 190 WritableWaveFileModel::getSummaryBlockSize(int desired) const
191 { 191 {