Add floating point support for writing and reading wav files
This CL adds support for reading and writing floating point wav files in WebRTC. It also updates the former wav handling code as well as adds some simplifications. Beyond this, the CL also adds support in the APM data_dumper and in the audioproc_f tool for using the floating point wav format. Bug: webrtc:11307 Change-Id: I2ea33fd12f590b6031ac85f75708f6cc88a266b4 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/162902 Reviewed-by: Sam Zackrisson <saza@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Per Åhgren <peah@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30423}
This commit is contained in:
@ -76,12 +76,14 @@ FILE* ApmDataDumper::GetRawFile(const char* name) {
|
||||
|
||||
WavWriter* ApmDataDumper::GetWavFile(const char* name,
|
||||
int sample_rate_hz,
|
||||
int num_channels) {
|
||||
int num_channels,
|
||||
WavFile::SampleFormat format) {
|
||||
std::string filename = FormFileName(output_dir_, name, instance_index_,
|
||||
recording_set_index_, ".wav");
|
||||
auto& f = wav_files_[filename];
|
||||
if (!f) {
|
||||
f.reset(new WavWriter(filename.c_str(), sample_rate_hz, num_channels));
|
||||
f.reset(
|
||||
new WavWriter(filename.c_str(), sample_rate_hz, num_channels, format));
|
||||
}
|
||||
return f.get();
|
||||
}
|
||||
|
||||
@ -242,7 +242,8 @@ class ApmDataDumper {
|
||||
int num_channels) {
|
||||
#if WEBRTC_APM_DEBUG_DUMP == 1
|
||||
if (recording_activated_) {
|
||||
WavWriter* file = GetWavFile(name, sample_rate_hz, num_channels);
|
||||
WavWriter* file = GetWavFile(name, sample_rate_hz, num_channels,
|
||||
WavFile::SampleFormat::kFloat);
|
||||
file->WriteSamples(v, v_length);
|
||||
}
|
||||
#endif
|
||||
@ -271,7 +272,10 @@ class ApmDataDumper {
|
||||
std::unordered_map<std::string, std::unique_ptr<WavWriter>> wav_files_;
|
||||
|
||||
FILE* GetRawFile(const char* name);
|
||||
WavWriter* GetWavFile(const char* name, int sample_rate_hz, int num_channels);
|
||||
WavWriter* GetWavFile(const char* name,
|
||||
int sample_rate_hz,
|
||||
int num_channels,
|
||||
WavFile::SampleFormat format);
|
||||
#endif
|
||||
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(ApmDataDumper);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user