164{
166
168
169 outTracks.clear();
170
172
173
174
176 uint32_t totalSamplesRead = 0;
177
178 {
179 const uint32_t bufferSize =
mNumChannels * SAMPLES_TO_READ;
183 uint32_t samplesRead = 0;
184
186 int16Buffer.
reinit(bufferSize);
188 floatBuffer.
reinit(bufferSize);
189 }
190
191 do {
192 samplesRead = WavpackUnpackSamples(
mWavPackContext, wavpackBuffer.get(), SAMPLES_TO_READ);
193
196 for (int64_t c = 0; c < samplesRead *
mNumChannels; c++)
197 int16Buffer[c] = static_cast<int16_t>(wavpackBuffer[c] * 256);
198 else
199 for (int64_t c = 0; c < samplesRead *
mNumChannels; c++)
200 int16Buffer[c] = static_cast<int16_t>(wavpackBuffer[c]);
201
202 unsigned chn = 0;
204 {
205 channel.AppendBuffer(
208 samplesRead,
211 );
212 ++chn;
213 });
215 unsigned chn = 0;
217 {
218 channel.AppendBuffer(
221 samplesRead,
224 );
225 ++chn;
226 });
227 } else {
228 for (int64_t c = 0; c < samplesRead *
mNumChannels; c++)
229 floatBuffer[c] = static_cast<float>(wavpackBuffer[c] / static_cast<double>(std::numeric_limits<int32_t>::max()));
230
231 unsigned chn = 0;
233 {
234 channel.AppendBuffer(
237 samplesRead,
240 );
241 ++chn;
242 });
243 }
244
245 totalSamplesRead += samplesRead;
246
249 }
250
254
256 {
258 return;
259 }
260
262 {
264 return;
265 }
266
267
269
270 if (wavpackMode & MODE_VALID_TAG) {
271 bool apeTag = wavpackMode & MODE_APETAG;
273
274 if (numItems > 0) {
276 for (int i = 0; i < numItems; i++) {
277 int itemLen = 0, valueLen = 0;
278 wxString value,
name;
279
280
282 std::string item (itemLen + 1, '\0');
283 WavpackGetTagItemIndexed(
mWavPackContext, i, item.data(), itemLen + 1);
284 item.resize(itemLen);
286
287
289 std::string itemValue (valueLen + 1, '\0');
290 WavpackGetTagItem(
mWavPackContext, item.data(), itemValue.data(), valueLen + 1);
291 itemValue.resize(valueLen);
292
293 if (apeTag) {
294 for (int j = 0; j < valueLen; j++) {
295
296 if (!itemValue[j]) {
297 itemValue[j] = '\n';
298 }
299 }
300 }
302
304 long val;
305 if (value.length() == 4 && value.ToLong(&val)) {
307 }
308 }
309
311 }
312 }
313 }
314
318}
This simplifies arrays of arrays, each array separately allocated with NEW[] But it might be better t...
void reinit(Integral count, bool initialize=false)
bool IsStopped() const noexcept
bool IsCancelled() const noexcept
virtual void OnImportResult(ImportResult result)=0
Used to report on import result for file handle passed as argument to OnImportFileOpened.
virtual void OnImportProgress(double progress)=0
static void ShowMessageBox(const TranslatableString &message, const TranslatableString &caption=XO("Import Project"))
static void ForEachChannel(TrackList &trackList, const std::function< void(WaveChannel &)> &op)
Iterates over channels in each wave track from the list.
static void FinalizeImport(TrackHolders &outTracks, const std::vector< std::shared_ptr< WaveTrack > > &importedStreams)
Flushes the given channels and moves them to outTracks.
TrackListHolder CreateMany(size_t nChannels)
Creates tracks with project's default rate and format and the given number of channels.
A Track that contains audio waveform data.
wxString ToWXString(const std::string &str)
const char * begin(const char *str) noexcept