Mercurial > hg > svcore
comparison data/fileio/WavFileWriter.cpp @ 1038:cc27f35aa75c cxx11
Introducing the signed 64-bit frame index type, and fixing build failures from inclusion of -Wconversion with -Werror. Not finished yet.
author | Chris Cannam |
---|---|
date | Tue, 03 Mar 2015 15:18:24 +0000 |
parents | 59e7fe1b1003 |
children | a1cd5abcb38b |
comparison
equal
deleted
inserted
replaced
1037:bf0e5944289b | 1038:cc27f35aa75c |
---|---|
118 selection->setSelection(Selection(source->getStartFrame(), | 118 selection->setSelection(Selection(source->getStartFrame(), |
119 source->getEndFrame())); | 119 source->getEndFrame())); |
120 ownSelection = true; | 120 ownSelection = true; |
121 } | 121 } |
122 | 122 |
123 int bs = 2048; | 123 sv_frame_t bs = 2048; |
124 float *ub = new float[bs]; // uninterleaved buffer (one channel) | 124 float *ub = new float[bs]; // uninterleaved buffer (one channel) |
125 float *ib = new float[bs * m_channels]; // interleaved buffer | 125 float *ib = new float[bs * m_channels]; // interleaved buffer |
126 | 126 |
127 for (MultiSelection::SelectionList::iterator i = | 127 for (MultiSelection::SelectionList::iterator i = |
128 selection->getSelections().begin(); | 128 selection->getSelections().begin(); |
129 i != selection->getSelections().end(); ++i) { | 129 i != selection->getSelections().end(); ++i) { |
130 | 130 |
131 int f0(i->getStartFrame()), f1(i->getEndFrame()); | 131 sv_frame_t f0(i->getStartFrame()), f1(i->getEndFrame()); |
132 | 132 |
133 for (int f = f0; f < f1; f += bs) { | 133 for (sv_frame_t f = f0; f < f1; f += bs) { |
134 | 134 |
135 int n = std::min(bs, f1 - f); | 135 sv_frame_t n = std::min(bs, f1 - f); |
136 | 136 |
137 for (int c = 0; c < int(m_channels); ++c) { | 137 for (int c = 0; c < int(m_channels); ++c) { |
138 source->getData(c, f, n, ub); | 138 source->getData(c, f, n, ub); |
139 for (int i = 0; i < n; ++i) { | 139 for (int i = 0; i < n; ++i) { |
140 ib[i * m_channels + c] = ub[i]; | 140 ib[i * m_channels + c] = ub[i]; |
157 | 157 |
158 return isOK(); | 158 return isOK(); |
159 } | 159 } |
160 | 160 |
161 bool | 161 bool |
162 WavFileWriter::writeSamples(float **samples, int count) | 162 WavFileWriter::writeSamples(float **samples, sv_frame_t count) |
163 { | 163 { |
164 if (!m_file) { | 164 if (!m_file) { |
165 m_error = QString("Failed to write model to audio file '%1': File not open") | 165 m_error = QString("Failed to write model to audio file '%1': File not open") |
166 .arg(getWriteFilename()); | 166 .arg(getWriteFilename()); |
167 return false; | 167 return false; |
168 } | 168 } |
169 | 169 |
170 float *b = new float[count * m_channels]; | 170 float *b = new float[count * m_channels]; |
171 for (int i = 0; i < int(count); ++i) { | 171 for (sv_frame_t i = 0; i < count; ++i) { |
172 for (int c = 0; c < int(m_channels); ++c) { | 172 for (int c = 0; c < int(m_channels); ++c) { |
173 b[i * m_channels + c] = samples[c][i]; | 173 b[i * m_channels + c] = samples[c][i]; |
174 } | 174 } |
175 } | 175 } |
176 | 176 |
177 sf_count_t written = sf_writef_float(m_file, b, count); | 177 sv_frame_t written = sf_writef_float(m_file, b, count); |
178 | 178 |
179 delete[] b; | 179 delete[] b; |
180 | 180 |
181 if (written < int(count)) { | 181 if (written < count) { |
182 m_error = QString("Only wrote %1 of %2 frames") | 182 m_error = QString("Only wrote %1 of %2 frames") |
183 .arg(written).arg(count); | 183 .arg(written).arg(count); |
184 } | 184 } |
185 | 185 |
186 return isOK(); | 186 return isOK(); |