andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | // Commandline tool to unpack audioproc debug files. |
| 12 | // |
| 13 | // The debug files are dumped as protobuf blobs. For analysis, it's necessary |
| 14 | // to unpack the file into its component parts: audio and other data. |
| 15 | |
| 16 | #include <stdio.h> |
| 17 | |
kwiberg | 62eaacf | 2016-02-17 06:39:05 -0800 | [diff] [blame] | 18 | #include <memory> |
| 19 | |
pbos@webrtc.org | 7fad4b8 | 2013-05-28 08:11:59 +0000 | [diff] [blame] | 20 | #include "gflags/gflags.h" |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 21 | #include "webrtc/base/format_macros.h" |
kwiberg | 77eab70 | 2016-09-28 17:42:01 -0700 | [diff] [blame^] | 22 | #include "webrtc/base/ignore_wundef.h" |
Andrew MacDonald | cb05b72 | 2015-05-07 22:17:51 -0700 | [diff] [blame] | 23 | #include "webrtc/modules/audio_processing/test/protobuf_utils.h" |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 24 | #include "webrtc/modules/audio_processing/test/test_utils.h" |
pbos@webrtc.org | 7fad4b8 | 2013-05-28 08:11:59 +0000 | [diff] [blame] | 25 | #include "webrtc/typedefs.h" |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 26 | |
kwiberg | 77eab70 | 2016-09-28 17:42:01 -0700 | [diff] [blame^] | 27 | RTC_PUSH_IGNORING_WUNDEF() |
| 28 | #include "webrtc/modules/audio_processing/debug.pb.h" |
| 29 | RTC_POP_IGNORING_WUNDEF() |
| 30 | |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 31 | // TODO(andrew): unpack more of the data. |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 32 | DEFINE_string(input_file, "input", "The name of the input stream file."); |
| 33 | DEFINE_string(output_file, "ref_out", |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 34 | "The name of the reference output stream file."); |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 35 | DEFINE_string(reverse_file, "reverse", |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 36 | "The name of the reverse input stream file."); |
| 37 | DEFINE_string(delay_file, "delay.int32", "The name of the delay file."); |
| 38 | DEFINE_string(drift_file, "drift.int32", "The name of the drift file."); |
| 39 | DEFINE_string(level_file, "level.int32", "The name of the level file."); |
andrew@webrtc.org | ce8e077 | 2014-02-12 15:28:30 +0000 | [diff] [blame] | 40 | DEFINE_string(keypress_file, "keypress.bool", "The name of the keypress file."); |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 41 | DEFINE_string(settings_file, "settings.txt", "The name of the settings file."); |
| 42 | DEFINE_bool(full, false, |
| 43 | "Unpack the full set of files (normally not needed)."); |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 44 | DEFINE_bool(raw, false, "Write raw data instead of a WAV file."); |
Bjorn Volcker | 40a6d59 | 2015-05-06 10:51:34 +0200 | [diff] [blame] | 45 | DEFINE_bool(text, |
| 46 | false, |
| 47 | "Write non-audio files as text files instead of binary files."); |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 48 | |
Minyue | 13b96ba | 2015-10-03 00:39:14 +0200 | [diff] [blame] | 49 | #define PRINT_CONFIG(field_name) \ |
| 50 | if (msg.has_##field_name()) { \ |
| 51 | fprintf(settings_file, " " #field_name ": %d\n", msg.field_name()); \ |
| 52 | } |
| 53 | |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 54 | namespace webrtc { |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 55 | |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 56 | using audioproc::Event; |
| 57 | using audioproc::ReverseStream; |
| 58 | using audioproc::Stream; |
| 59 | using audioproc::Init; |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 60 | |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 61 | void WriteData(const void* data, size_t size, FILE* file, |
| 62 | const std::string& filename) { |
| 63 | if (fwrite(data, size, 1, file) != 1) { |
| 64 | printf("Error when writing to %s\n", filename.c_str()); |
| 65 | exit(1); |
| 66 | } |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 67 | } |
| 68 | |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 69 | int do_main(int argc, char* argv[]) { |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 70 | std::string program_name = argv[0]; |
| 71 | std::string usage = "Commandline tool to unpack audioproc debug files.\n" |
| 72 | "Example usage:\n" + program_name + " debug_dump.pb\n"; |
| 73 | google::SetUsageMessage(usage); |
| 74 | google::ParseCommandLineFlags(&argc, &argv, true); |
| 75 | |
| 76 | if (argc < 2) { |
| 77 | printf("%s", google::ProgramUsage()); |
| 78 | return 1; |
| 79 | } |
| 80 | |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 81 | FILE* debug_file = OpenFile(argv[1], "rb"); |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 82 | |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 83 | Event event_msg; |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 84 | int frame_count = 0; |
pkasting | 25702cb | 2016-01-08 13:50:27 -0800 | [diff] [blame] | 85 | size_t reverse_samples_per_channel = 0; |
| 86 | size_t input_samples_per_channel = 0; |
| 87 | size_t output_samples_per_channel = 0; |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 88 | size_t num_reverse_channels = 0; |
| 89 | size_t num_input_channels = 0; |
| 90 | size_t num_output_channels = 0; |
kwiberg | 62eaacf | 2016-02-17 06:39:05 -0800 | [diff] [blame] | 91 | std::unique_ptr<WavWriter> reverse_wav_file; |
| 92 | std::unique_ptr<WavWriter> input_wav_file; |
| 93 | std::unique_ptr<WavWriter> output_wav_file; |
| 94 | std::unique_ptr<RawFile> reverse_raw_file; |
| 95 | std::unique_ptr<RawFile> input_raw_file; |
| 96 | std::unique_ptr<RawFile> output_raw_file; |
Minyue | 13b96ba | 2015-10-03 00:39:14 +0200 | [diff] [blame] | 97 | |
| 98 | FILE* settings_file = OpenFile(FLAGS_settings_file, "wb"); |
| 99 | |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 100 | while (ReadMessageFromFile(debug_file, &event_msg)) { |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 101 | if (event_msg.type() == Event::REVERSE_STREAM) { |
| 102 | if (!event_msg.has_reverse_stream()) { |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 103 | printf("Corrupt input file: ReverseStream missing.\n"); |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 104 | return 1; |
| 105 | } |
| 106 | |
| 107 | const ReverseStream msg = event_msg.reverse_stream(); |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 108 | if (msg.has_data()) { |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 109 | if (FLAGS_raw && !reverse_raw_file) { |
| 110 | reverse_raw_file.reset(new RawFile(FLAGS_reverse_file + ".pcm")); |
| 111 | } |
aluebs@webrtc.org | bac0726 | 2014-09-03 13:39:01 +0000 | [diff] [blame] | 112 | // TODO(aluebs): Replace "num_reverse_channels * |
| 113 | // reverse_samples_per_channel" with "msg.data().size() / |
| 114 | // sizeof(int16_t)" and so on when this fix in audio_processing has made |
| 115 | // it into stable: https://webrtc-codereview.appspot.com/15299004/ |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 116 | WriteIntData(reinterpret_cast<const int16_t*>(msg.data().data()), |
aluebs@webrtc.org | bac0726 | 2014-09-03 13:39:01 +0000 | [diff] [blame] | 117 | num_reverse_channels * reverse_samples_per_channel, |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 118 | reverse_wav_file.get(), |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 119 | reverse_raw_file.get()); |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 120 | } else if (msg.channel_size() > 0) { |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 121 | if (FLAGS_raw && !reverse_raw_file) { |
| 122 | reverse_raw_file.reset(new RawFile(FLAGS_reverse_file + ".float")); |
| 123 | } |
kwiberg | 62eaacf | 2016-02-17 06:39:05 -0800 | [diff] [blame] | 124 | std::unique_ptr<const float* []> data( |
kwiberg@webrtc.org | 00b8f6b | 2015-02-26 14:34:55 +0000 | [diff] [blame] | 125 | new const float* [num_reverse_channels]); |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 126 | for (size_t i = 0; i < num_reverse_channels; ++i) { |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 127 | data[i] = reinterpret_cast<const float*>(msg.channel(i).data()); |
| 128 | } |
| 129 | WriteFloatData(data.get(), |
aluebs@webrtc.org | bac0726 | 2014-09-03 13:39:01 +0000 | [diff] [blame] | 130 | reverse_samples_per_channel, |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 131 | num_reverse_channels, |
| 132 | reverse_wav_file.get(), |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 133 | reverse_raw_file.get()); |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 134 | } |
| 135 | } else if (event_msg.type() == Event::STREAM) { |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 136 | frame_count++; |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 137 | if (!event_msg.has_stream()) { |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 138 | printf("Corrupt input file: Stream missing.\n"); |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 139 | return 1; |
| 140 | } |
| 141 | |
| 142 | const Stream msg = event_msg.stream(); |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 143 | if (msg.has_input_data()) { |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 144 | if (FLAGS_raw && !input_raw_file) { |
| 145 | input_raw_file.reset(new RawFile(FLAGS_input_file + ".pcm")); |
| 146 | } |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 147 | WriteIntData(reinterpret_cast<const int16_t*>(msg.input_data().data()), |
aluebs@webrtc.org | bac0726 | 2014-09-03 13:39:01 +0000 | [diff] [blame] | 148 | num_input_channels * input_samples_per_channel, |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 149 | input_wav_file.get(), |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 150 | input_raw_file.get()); |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 151 | } else if (msg.input_channel_size() > 0) { |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 152 | if (FLAGS_raw && !input_raw_file) { |
| 153 | input_raw_file.reset(new RawFile(FLAGS_input_file + ".float")); |
| 154 | } |
kwiberg | 62eaacf | 2016-02-17 06:39:05 -0800 | [diff] [blame] | 155 | std::unique_ptr<const float* []> data( |
kwiberg@webrtc.org | 00b8f6b | 2015-02-26 14:34:55 +0000 | [diff] [blame] | 156 | new const float* [num_input_channels]); |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 157 | for (size_t i = 0; i < num_input_channels; ++i) { |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 158 | data[i] = reinterpret_cast<const float*>(msg.input_channel(i).data()); |
| 159 | } |
| 160 | WriteFloatData(data.get(), |
aluebs@webrtc.org | bac0726 | 2014-09-03 13:39:01 +0000 | [diff] [blame] | 161 | input_samples_per_channel, |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 162 | num_input_channels, |
| 163 | input_wav_file.get(), |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 164 | input_raw_file.get()); |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 165 | } |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 166 | |
| 167 | if (msg.has_output_data()) { |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 168 | if (FLAGS_raw && !output_raw_file) { |
| 169 | output_raw_file.reset(new RawFile(FLAGS_output_file + ".pcm")); |
| 170 | } |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 171 | WriteIntData(reinterpret_cast<const int16_t*>(msg.output_data().data()), |
aluebs@webrtc.org | bac0726 | 2014-09-03 13:39:01 +0000 | [diff] [blame] | 172 | num_output_channels * output_samples_per_channel, |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 173 | output_wav_file.get(), |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 174 | output_raw_file.get()); |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 175 | } else if (msg.output_channel_size() > 0) { |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 176 | if (FLAGS_raw && !output_raw_file) { |
| 177 | output_raw_file.reset(new RawFile(FLAGS_output_file + ".float")); |
| 178 | } |
kwiberg | 62eaacf | 2016-02-17 06:39:05 -0800 | [diff] [blame] | 179 | std::unique_ptr<const float* []> data( |
kwiberg@webrtc.org | 00b8f6b | 2015-02-26 14:34:55 +0000 | [diff] [blame] | 180 | new const float* [num_output_channels]); |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 181 | for (size_t i = 0; i < num_output_channels; ++i) { |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 182 | data[i] = |
| 183 | reinterpret_cast<const float*>(msg.output_channel(i).data()); |
| 184 | } |
| 185 | WriteFloatData(data.get(), |
aluebs@webrtc.org | bac0726 | 2014-09-03 13:39:01 +0000 | [diff] [blame] | 186 | output_samples_per_channel, |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 187 | num_output_channels, |
| 188 | output_wav_file.get(), |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 189 | output_raw_file.get()); |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | if (FLAGS_full) { |
| 193 | if (msg.has_delay()) { |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 194 | static FILE* delay_file = OpenFile(FLAGS_delay_file, "wb"); |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 195 | int32_t delay = msg.delay(); |
Bjorn Volcker | 40a6d59 | 2015-05-06 10:51:34 +0200 | [diff] [blame] | 196 | if (FLAGS_text) { |
| 197 | fprintf(delay_file, "%d\n", delay); |
| 198 | } else { |
| 199 | WriteData(&delay, sizeof(delay), delay_file, FLAGS_delay_file); |
| 200 | } |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | if (msg.has_drift()) { |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 204 | static FILE* drift_file = OpenFile(FLAGS_drift_file, "wb"); |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 205 | int32_t drift = msg.drift(); |
Bjorn Volcker | 40a6d59 | 2015-05-06 10:51:34 +0200 | [diff] [blame] | 206 | if (FLAGS_text) { |
| 207 | fprintf(drift_file, "%d\n", drift); |
| 208 | } else { |
| 209 | WriteData(&drift, sizeof(drift), drift_file, FLAGS_drift_file); |
| 210 | } |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | if (msg.has_level()) { |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 214 | static FILE* level_file = OpenFile(FLAGS_level_file, "wb"); |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 215 | int32_t level = msg.level(); |
Bjorn Volcker | 40a6d59 | 2015-05-06 10:51:34 +0200 | [diff] [blame] | 216 | if (FLAGS_text) { |
| 217 | fprintf(level_file, "%d\n", level); |
| 218 | } else { |
| 219 | WriteData(&level, sizeof(level), level_file, FLAGS_level_file); |
| 220 | } |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 221 | } |
andrew@webrtc.org | ce8e077 | 2014-02-12 15:28:30 +0000 | [diff] [blame] | 222 | |
| 223 | if (msg.has_keypress()) { |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 224 | static FILE* keypress_file = OpenFile(FLAGS_keypress_file, "wb"); |
andrew@webrtc.org | ce8e077 | 2014-02-12 15:28:30 +0000 | [diff] [blame] | 225 | bool keypress = msg.keypress(); |
Bjorn Volcker | 40a6d59 | 2015-05-06 10:51:34 +0200 | [diff] [blame] | 226 | if (FLAGS_text) { |
| 227 | fprintf(keypress_file, "%d\n", keypress); |
| 228 | } else { |
| 229 | WriteData(&keypress, sizeof(keypress), keypress_file, |
| 230 | FLAGS_keypress_file); |
| 231 | } |
andrew@webrtc.org | ce8e077 | 2014-02-12 15:28:30 +0000 | [diff] [blame] | 232 | } |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 233 | } |
Minyue | 13b96ba | 2015-10-03 00:39:14 +0200 | [diff] [blame] | 234 | } else if (event_msg.type() == Event::CONFIG) { |
| 235 | if (!event_msg.has_config()) { |
| 236 | printf("Corrupt input file: Config missing.\n"); |
| 237 | return 1; |
| 238 | } |
| 239 | const audioproc::Config msg = event_msg.config(); |
| 240 | |
| 241 | fprintf(settings_file, "APM re-config at frame: %d\n", frame_count); |
| 242 | |
| 243 | PRINT_CONFIG(aec_enabled); |
| 244 | PRINT_CONFIG(aec_delay_agnostic_enabled); |
| 245 | PRINT_CONFIG(aec_drift_compensation_enabled); |
| 246 | PRINT_CONFIG(aec_extended_filter_enabled); |
| 247 | PRINT_CONFIG(aec_suppression_level); |
| 248 | PRINT_CONFIG(aecm_enabled); |
| 249 | PRINT_CONFIG(aecm_comfort_noise_enabled); |
| 250 | PRINT_CONFIG(aecm_routing_mode); |
| 251 | PRINT_CONFIG(agc_enabled); |
| 252 | PRINT_CONFIG(agc_mode); |
| 253 | PRINT_CONFIG(agc_limiter_enabled); |
| 254 | PRINT_CONFIG(noise_robust_agc_enabled); |
| 255 | PRINT_CONFIG(hpf_enabled); |
| 256 | PRINT_CONFIG(ns_enabled); |
| 257 | PRINT_CONFIG(ns_level); |
| 258 | PRINT_CONFIG(transient_suppression_enabled); |
Alejandro Luebs | c9b0c26 | 2016-05-16 15:32:38 -0700 | [diff] [blame] | 259 | PRINT_CONFIG(intelligibility_enhancer_enabled); |
peah | 7789fe7 | 2016-04-15 01:19:44 -0700 | [diff] [blame] | 260 | if (msg.has_experiments_description()) { |
| 261 | fprintf(settings_file, " experiments_description: %s\n", |
| 262 | msg.experiments_description().c_str()); |
| 263 | } |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 264 | } else if (event_msg.type() == Event::INIT) { |
| 265 | if (!event_msg.has_init()) { |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 266 | printf("Corrupt input file: Init missing.\n"); |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 267 | return 1; |
| 268 | } |
| 269 | |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 270 | const Init msg = event_msg.init(); |
| 271 | // These should print out zeros if they're missing. |
| 272 | fprintf(settings_file, "Init at frame: %d\n", frame_count); |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 273 | int input_sample_rate = msg.sample_rate(); |
| 274 | fprintf(settings_file, " Input sample rate: %d\n", input_sample_rate); |
| 275 | int output_sample_rate = msg.output_sample_rate(); |
| 276 | fprintf(settings_file, " Output sample rate: %d\n", output_sample_rate); |
| 277 | int reverse_sample_rate = msg.reverse_sample_rate(); |
| 278 | fprintf(settings_file, |
| 279 | " Reverse sample rate: %d\n", |
| 280 | reverse_sample_rate); |
| 281 | num_input_channels = msg.num_input_channels(); |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 282 | fprintf(settings_file, " Input channels: %" PRIuS "\n", |
| 283 | num_input_channels); |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 284 | num_output_channels = msg.num_output_channels(); |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 285 | fprintf(settings_file, " Output channels: %" PRIuS "\n", |
| 286 | num_output_channels); |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 287 | num_reverse_channels = msg.num_reverse_channels(); |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 288 | fprintf(settings_file, " Reverse channels: %" PRIuS "\n", |
| 289 | num_reverse_channels); |
andrew@webrtc.org | cd82438 | 2011-11-11 19:13:36 +0000 | [diff] [blame] | 290 | |
| 291 | fprintf(settings_file, "\n"); |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 292 | |
| 293 | if (reverse_sample_rate == 0) { |
| 294 | reverse_sample_rate = input_sample_rate; |
| 295 | } |
| 296 | if (output_sample_rate == 0) { |
| 297 | output_sample_rate = input_sample_rate; |
| 298 | } |
| 299 | |
pkasting | 25702cb | 2016-01-08 13:50:27 -0800 | [diff] [blame] | 300 | reverse_samples_per_channel = |
| 301 | static_cast<size_t>(reverse_sample_rate / 100); |
| 302 | input_samples_per_channel = |
| 303 | static_cast<size_t>(input_sample_rate / 100); |
| 304 | output_samples_per_channel = |
| 305 | static_cast<size_t>(output_sample_rate / 100); |
aluebs@webrtc.org | bac0726 | 2014-09-03 13:39:01 +0000 | [diff] [blame] | 306 | |
aluebs@webrtc.org | 021e76f | 2014-09-04 18:12:00 +0000 | [diff] [blame] | 307 | if (!FLAGS_raw) { |
| 308 | // The WAV files need to be reset every time, because they cant change |
| 309 | // their sample rate or number of channels. |
aluebs | f03a8d4 | 2016-06-17 09:41:41 -0700 | [diff] [blame] | 310 | std::stringstream reverse_name; |
| 311 | reverse_name << FLAGS_reverse_file << frame_count << ".wav"; |
| 312 | reverse_wav_file.reset(new WavWriter(reverse_name.str(), |
andrew@webrtc.org | a3ed713 | 2014-10-31 21:51:03 +0000 | [diff] [blame] | 313 | reverse_sample_rate, |
| 314 | num_reverse_channels)); |
aluebs | f03a8d4 | 2016-06-17 09:41:41 -0700 | [diff] [blame] | 315 | std::stringstream input_name; |
| 316 | input_name << FLAGS_input_file << frame_count << ".wav"; |
| 317 | input_wav_file.reset(new WavWriter(input_name.str(), |
andrew@webrtc.org | a3ed713 | 2014-10-31 21:51:03 +0000 | [diff] [blame] | 318 | input_sample_rate, |
| 319 | num_input_channels)); |
aluebs | f03a8d4 | 2016-06-17 09:41:41 -0700 | [diff] [blame] | 320 | std::stringstream output_name; |
| 321 | output_name << FLAGS_output_file << frame_count << ".wav"; |
| 322 | output_wav_file.reset(new WavWriter(output_name.str(), |
andrew@webrtc.org | a3ed713 | 2014-10-31 21:51:03 +0000 | [diff] [blame] | 323 | output_sample_rate, |
| 324 | num_output_channels)); |
aluebs@webrtc.org | 841f58f | 2014-09-02 07:51:51 +0000 | [diff] [blame] | 325 | } |
andrew@webrtc.org | cb18121 | 2011-10-26 00:27:17 +0000 | [diff] [blame] | 326 | } |
| 327 | } |
| 328 | |
| 329 | return 0; |
| 330 | } |
andrew@webrtc.org | a8b9737 | 2014-03-10 22:26:12 +0000 | [diff] [blame] | 331 | |
| 332 | } // namespace webrtc |
| 333 | |
| 334 | int main(int argc, char* argv[]) { |
| 335 | return webrtc::do_main(argc, argv); |
| 336 | } |