/* * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
// Checks whether the format is supported or not. bool FormatSupported(WavFormat format) { // Only PCM and IEEE Float formats are supported. return format == WavFormat::kWavFormatPcm ||
format == WavFormat::kWavFormatIeeeFloat;
}
// Doesn't take ownership of the file handle and won't close it. class WavHeaderFileReader : public WavHeaderReader { public: explicit WavHeaderFileReader(FileWrapper* file) : file_(file) {}
void WavReader::Reset() {
RTC_CHECK(file_.SeekTo(data_start_pos_))
<< "Failed to set position in the file to WAV data start position";
num_unread_samples_ = num_samples_in_file_;
}
size_t WavReader::ReadSamples(const size_t num_samples,
int16_t* const samples) { #ifndef WEBRTC_ARCH_LITTLE_ENDIAN #error"Need to convert samples to big-endian when reading from WAV file" #endif
// Write a blank placeholder header, since we need to know the total number // of samples before we can fill in the real data. staticconst uint8_t blank_header[MaxWavHeaderSize()] = {0};
RTC_CHECK(file_.Write(blank_header, WavHeaderSize(format_)));
}
void WavWriter::WriteSamples(const int16_t* samples, size_t num_samples) { #ifndef WEBRTC_ARCH_LITTLE_ENDIAN #error"Need to convert samples to little-endian when writing to WAV file" #endif
for (size_t i = 0; i < num_samples; i += kMaxChunksize) { const size_t num_remaining_samples = num_samples - i; const size_t num_samples_to_write =
std::min(kMaxChunksize, num_remaining_samples);
void WavWriter::WriteSamples(constfloat* samples, size_t num_samples) { #ifndef WEBRTC_ARCH_LITTLE_ENDIAN #error"Need to convert samples to little-endian when writing to WAV file" #endif
for (size_t i = 0; i < num_samples; i += kMaxChunksize) { const size_t num_remaining_samples = num_samples - i; const size_t num_samples_to_write =
std::min(kMaxChunksize, num_remaining_samples);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.